irradiapy.analysis.clusters module

Cluster analysis module.

irradiapy.analysis.clusters.atom_to_object(aclusters)[source]

Transform atom clusters into object clusters.

Parameters:

aclusters (GenericAlias[Any]) – Atomic clusters.

Returns:

Object clusters.

Return type:

GenericAlias[Any]

irradiapy.analysis.clusters.cluster_size_scaling_law(analysisdb, oclusters_path, min_size, nbins)[source]

Calculates the cluster size distribution and fits power laws to small and large sizes.

Parameters:
  • analysisdb (AnalysisDB) – Database for storing results.

  • oclusters_path (Path) – Path to the object clusters file.

  • min_size (int) – Minimum cluster size to separate small and large sizes (inclusive). Bins above this size are logarithmic. Recommended value is around 5.

  • nbins (int) – Number of bins for the large sizes histogram. This is usually a low number, depending on the data (< 10).

Returns:

tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]], tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]], ]

Return type:

tuple[tuple[GenericAlias[double], GenericAlias[double]], tuple[GenericAlias[double], GenericAlias[double]]]

irradiapy.analysis.clusters.cluster_size_scaling_law_plot(analysisdb, show=False, vacs_plot_path=None, sias_plot_path=None, dpi=300)[source]

Plots the cluster size distribution with power law fits for small and large sizes.

Parameters:
  • analysisdb (AnalysisDB) – Database for storing results.

  • show (bool) – Whether to show the plots.

  • vacs_plot_path (Path | None) – Output path for the vacancies plot.

  • sias_plot_path (Path | None) – Output path for the interstitials plot.

  • dpi (int) – Dots per inch for the plot.

Return type:

None

irradiapy.analysis.clusters.clusterize_atoms(atoms, cutoff)[source]

Identify atom clusters.

Note

Atom clusters are the individual atoms with their cluster number, while object clusters are a single point representing the average position of the atoms in the cluster and the type of the cluster (the cluster type is taken from the first atom in the cluster).

Parameters:
  • atoms (GenericAlias[Any]) – Array of atoms with fields “type”, “x”, “y”, “z”.

  • cutoff (float) – Cutoff distance for clustering.

Returns:

Atomic and object clusters.

Return type:

tuple[GenericAlias[Any], GenericAlias[Any]]

irradiapy.analysis.clusters.clusterize_file(defects_path, cutoff_sia, cutoff_vac, interstitials_z=None, aclusters_path=None, oclusters_path=None)[source]

Finds defect clusters in the given file. Type 0 are vacancies, others are interstitials.

Parameters:
  • defects_path (Path) – Path of the file where defects are.

  • cutoff_sia (float) – Cutoff distance for interstitials clustering.

  • cutoff_vac (float) – Cutoff distance for vacancies clustering.

  • interstitials_z (list[int] | None) – List of atomic numbers that are considered interstitials. If None, all non-zero types are considered interstitials.

  • aclusters_path (Path | None) – Where atomic clusters will be stored if provided.

  • oclusters_path (Path | None) – Where object clusters will be stored if provided.

Return type:

None

irradiapy.analysis.clusters.depth_cluster_sizes_plot(oclusters_path, axis, global_min_counts, depth_nbins=100, log=True, dpi=300, plot_sias_path=None, plot_vacs_path=None, show=False)[source]

Plots the cluster size distribution as a function of depth.

Parameters:
  • oclusters_path (Path) – Path to the object clusters file.

  • axis (str) – Axis along which to compute depth (‘x’, ‘y’, or ‘z’).

  • global_min_counts (int) – Minimum cluster size counts to show a bin in the plot.

  • depth_nbins (int) – Number of bins for the depth histogram.

  • log (bool) – Whether to use a logarithmic scale for the color map.

  • dpi (int) – DPI for saving the plots.

  • plot_sias_path (Path | None) – Output path for the interstitials plot.

  • plot_vacs_path (Path | None) – Output path for the vacancies plot.

  • show (bool) – Whether to show the plots.

Returns:

A tuple containing depth edges, interstitials histogram, and vacancies histogram. Rows correspond to depth bins, columns to cluster sizes.

Return type:

tuple[GenericAlias[double], GenericAlias[double], GenericAlias[double]]

irradiapy.analysis.clusters.depth_clustering_fraction_hist(analysisdb, oclusters_path, axis, min_size, nbins=100)[source]

Calculates the clustering fraction as a function of depth and stores it in the analysis database.

Parameters:
  • analysisdb (AnalysisDB) – Database for storing results.

  • oclusters_path (Path) – Path to the object clusters file.

  • axis (str) – Axis along which to compute depth (‘x’, ‘y’, or ‘z’).

  • min_size (int) – Minimum cluster size to be considered clustered.

  • nbins (int) – Number of bins for the depth histogram.

Returns:

A tuple containing depth centers and clustering fractions for SIAs and vacancies.

Return type:

tuple[GenericAlias[double], GenericAlias[double], GenericAlias[double]]

irradiapy.analysis.clusters.depth_clustering_fraction_hist_plot(analysisdb, axis, min_size, plot_path=None, show=False)[source]

Plots the clustering fraction as a function of depth from the analysis database.

Parameters:
  • analysisdb (AnalysisDB) – Database for storing results.

  • axis (str) – Axis along which to compute depth (‘x’, ‘y’, or ‘z’).

  • min_size (int) – Minimum cluster size to be considered clustered.

  • plot_path (Path | None) – Output path for the plot.

  • show (bool) – Whether to show the plot.

Return type:

None