irradiapy.analysis package
Submodules
irradiapy.analysis.clusters module
Cluster analysis module.
- irradiapy.analysis.clusters.atom_to_object(aclusters)[source]
Transform atom clusters into object clusters.
- Parameters:
aclusters (dtypes.Acluster) – Atomic clusters.
- Returns:
Object clusters.
- Return type:
dtypes.Ocluster
- irradiapy.analysis.clusters.clusterize(defects, 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).
- irradiapy.analysis.clusters.clusterize_file(path_defects, cutoff_sia, cutoff_vac, path_aclusters, path_oclusters)[source]
Finds defect clusters in the given file.
- Parameters:
path_defects (Path) – Path of the file where defects are.
cutoff_sia (float) – Cutoff distance for interstitials clustering.
cutoff_vac (float) – Cutoff distance for vacancies clustering.
path_aclusters (Path) – Where atomic clusters will be stored.
path_oclusters (Path) – Where object clusters will be stored.
- Return type:
- irradiapy.analysis.clusters.get_clusters_0d(path_oclusters, path_db, scale=1.0)[source]
Perform a cluster size histogram for interstitials and vacancies.
This is useful for cluster analysis and cluster dynamics codes.
- irradiapy.analysis.clusters.get_clusters_1d(path_oclusters, path_db, axis='x', depth_bins=100, depth_offset=0.0, min_depth=None, max_depth=None, scale=1.0)[source]
Perform a cluster size histogram as a function of depth along a specified axis.
This is useful for cluster analysis and cluster dynamics codes.
- Parameters:
path_oclusters (Path) – Path to the input file containing object clusters.
path_db (Path) – Path to the output SQLite database file.
axis (str, optional (default="x")) – Axis along which to measure depth. It can be “x”, “y”, or “z”.
depth_bins (int, optional (default=100)) – Number of bins for the depth histogram.
depth_offset (float, optional (default=0.0)) – Offset to add to the depth values.
min_depth (float, optional (default=None)) – Minimum depth to consider. If None, the minimum depth from the data is used.
max_depth (float, optional (default=None)) – Maximum depth to consider. If None, the maximum depth from the data is used.
scale (float, optional (default=1.0)) – All bin counts are multiplied by this factor. Useful for normalization.
- Return type:
- irradiapy.analysis.clusters.plot_clustering_fraction_1d(db_path, path_plot=None, axis='x', depth_offset=0.0, dpi=300)[source]
Plot the clustering fraction as a function of depth.
Note
The clustering fraction is defined as the ratio of the number of defects in clusters of size greater than 1 to the number of unclustered defects.
- Parameters:
db_path (Path) – Path to the SQLite database file containing the cluster data generated by irradiapy.analysis.clusters.get_clusters_1d.
path_plot (Path, optional (default=None)) – Path to save the clustering fraction plot. If None, the plot is shown instead of saved.
axis (str, optional (default="x")) – Axis along which the histogram was computed. It can be “x”, “y”, or “z”.
depth_offset (float, optional (default=0.0)) – Offset to add to the depth values.
dpi (int, optional (default=300)) – Dots per inch.
- Return type:
- irradiapy.analysis.clusters.plot_mddb_cluster_size(target_dir, sia_cutoff, vac_cutoff, rel, sia_bin_width=10, vac_bin_width=10, path_sias=None, path_vacs=None, max_sia=None, max_vac=None, vmin=1e-05, dpi=300)[source]
Plot the cluster size distribution from a molecular dynamics database.
- Parameters:
target_dir (Path) – Directory containing the MD database.
sia_cutoff (float) – Cutoff distance for interstitial cluster identification.
vac_cutoff (float) – Cutoff distance for vacancy cluster identification.
rel (bool) – If True, each size bin is the number of clusters of that size divided by the total number of clusters for the given energy. If False, each size bin is the number of clusters of that size divided by the total number of simulations of the corresponding energy.
sia_bin_width (int, optional (default=10)) – Bin size for interstitial histogram.
vac_bin_width (int, optional (default=10)) – Bin size for vacancy histogram.
path_sias (Path, optional (default=None)) – Path to save the interstitials size distribution plot. If None, the plot is shown instead of saved.
path_vacs (Path, optional (default=None)) – Path to save the vacancies size distribution plot. If None, the plot is shown instead of saved.
max_sia (int, optional (default=None)) – Sets an upper limit for interstitial cluster sizes. It has to be greater than the maximum interstitial cluster size in the data. If None, it is determined from the data. Useful to compare multiple databases with different maximum sizes.
max_vac (int, optional (default=None)) – Sets an upper limit for vacancy cluster sizes. It has to be greater than the maximum vacancy cluster size in the data. If None, it is determined from the data. Useful to compare multiple databases with different maximum sizes.
vmin (float, optional (default=1e-5)) – Minimum value for the color scale if rel is True.
dpi (int, optional (default=300)) – Dots per inch.
- Return type:
- irradiapy.analysis.clusters.plot_size_1d(db_path, path_sias=None, path_vacs=None, axis='x', depth_offset=0.0, transpose=True, dpi=300)[source]
Plot the depth-size 1D histogram for interstitials and vacancies.
Note
The color bar’s label shows “Mean counts”, then it assumes that in irradiapy.analysis.clusters.get_clusters_1d a proper scale parameter was used.
- Parameters:
db_path (Path) – Path to the SQLite database file containing the cluster data generated by irradiapy.analysis.clusters.get_clusters_1d.
path_sias (Path, optional (default=None)) – Path to save the interstitials plot. If None, the plot is shown instead of saved.
path_vacs (Path, optional (default=None)) – Path to save the vacancies plot. If None, the plot is shown instead of saved.
axis (str, optional (default="x")) – Axis along which the histogram was computed. It can be “x”, “y”, or “z”.
depth_offset (float, optional (default=0.0)) – Offset to add to the depth values.
transpose (bool, optional (default=True)) – If True, the depth is on the x-axis and size on the y-axis. If False, the axes are swapped.
dpi (int, optional (default=300)) – Dots per inch.
- Return type:
- irradiapy.analysis.clusters.read_clusters_0d(path_db)[source]
Read the 0D cluster size histogram from the database.
This is useful for cluster analysis and cluster dynamics codes.
- irradiapy.analysis.clusters.read_clusters_1d(path_db, axis='x')[source]
Read the 1D cluster size histogram from the database.
This is useful for cluster analysis and cluster dynamics codes.
- Parameters:
path_db (Path) – Path to the SQLite database file.
axis (str, optional (default="x")) – Axis along which the histogram was computed. It can be “x”, “y”,or “z”.
- Returns:
A dictionary containing: - “depth_edges”: The edges of the depth bins. - “interstitials”: The histogram of interstitial sizes for each depth bin. - “vacancies”: The histogram of vacancy sizes for each depth bin.
- Return type:
irradiapy.analysis.defects module
Defects analysis module.
- irradiapy.analysis.defects.identify_defects(lattice, a0, data_atoms, a1=None, pos_pka=None, theta_pka=None, phi_pka=None, transform=False, debug=False)[source]
Identify defects in a given atomic structure.
- Parameters:
lattice (str) – Lattice type. Currently only “bcc” is supported.
a0 (float) – Lattice parameter.
data_atoms (defaultdict) – Dictionary containing simulation data as given by the LAMMPSReader and similar readers. Must include keys: ‘atoms’, ‘natoms’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, ‘timestep’.
a1 (float, optional (default=None)) – Final lattice parameter. If provided, defect positions are rescaled to this value (independently of the transform value).
pos_pka (npt.NDArray[np.float64], optional (default=None)) – Position vector of the PKA. If provided with theta_pka and phi_pka, defects are recentered and aligned.
theta_pka (float, optional (default=None)) – Polar angle (in radians) for the PKA direction.
phi_pka (float, optional (default=None)) – Azimuthal angle (in radians) for the PKA direction.
transform (bool, optional (default=False)) – If True, defects are recentered and aligned with the PKA direction (if provided). If True but no PKA parameters are provided, defects are recentered based on their average position. Note that the box boundaries are not modified for visualization purposes, only the atomic positions are transformed.
debug (bool, optional (default=False)) – If True, enables debug mode for additional output.
- Returns:
An array of identified defects in the structure.
- Return type:
dtypes.Defect
- irradiapy.analysis.defects.identify_lammps_dump(lattice, a0, path_dump, path_dump_defects, a1=None, pos_pka=None, theta_pka=None, phi_pka=None, transform=False, overwrite=False, debug=False)[source]
Identify defects in a LAMMPS dump file.
- Parameters:
lattice (str) – Lattice type. Currently only “bcc” is supported.
a0 (float) – Lattice parameter.
data_atoms (defaultdict) – Dictionary containing simulation data as given by the LAMMPSReader and similar readers.
data_atoms – Dictionary containing simulation data as given by the LAMMPSReader and similar readers. Must include keys: ‘atoms’, ‘natoms’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, ‘timestep’.
path_dump (Path) – Path to the LAMMPS dump file to read. Can be compressed with .bz2 or not.
path_dump_defects (Path) – Path to the output file where identified defects will be written (in text format).
a1 (float, optional) – Final lattice parameter. If provided, defect positions are rescaled to this value (independently of the transform value).
pos_pka (npt.NDArray[np.float64], optional) – Position vector of the PKA. If provided with theta_pka and phi_pka, defects are recentered and aligned.
theta_pka (float, optional) – Polar angle (in radians) for the PKA direction.
phi_pka (float, optional) – Azimuthal angle (in radians) for the PKA direction.
transform (bool, optional) – If True, defects are recentered and aligned with the PKA direction (if provided). If True but no PKA parameters are provided, defects are recentered based on their average position. Note that the box boundaries are not modified for visualization purposes, only the atomic positions are transformed.
overwrite (bool, optional (default=False)) – If True, allows overwriting the output file if it already exists.
debug (bool, optional (default=False)) – If True, enables debug mode for additional output.
- Return type:
- irradiapy.analysis.defects.plot_mddb_nd(target_dir, mat_pka, mat_target, path_plot, dpi=300)[source]
Plot the number of defects (vacancies) as a function of the PKA energy from a molecular dynamics database.
Note
The number of defects is estimated from the vacancy counts.
- Parameters:
target_dir (Path) – Directory containing the MD database.
mat_pka (materials.Material) – Material of the PKA.
mat_target (materials.Material) – Target material.
path_plot (Path, optional) – Path to save the plot. If None, the plot is shown but not saved.
dpi (int, optional (default=300)) – Dots per inch.
- Return type:
irradiapy.analysis.defectsidentifier module
This module provides a class to find and analyze defects in crystalline structures.
- class irradiapy.analysis.defectsidentifier.DefectsIdentifier(lattice, a0, debug=False, _DefectsIdentifier__sub_count=2)[source]
Bases:
objectClass to identify defects in crystalline structures.
This class provides methods to identify point defects (vacancies and interstitials) in a body-centered cubic (bcc) lattice based on atomic positions from simulation data. It supports optional rescaling and recentering of defect positions, and can align the system with a specified primary knock-on atom (PKA) direction.
- Parameters:
- identify(data_atoms, a1=None, pos_pka=None, theta_pka=None, phi_pka=None, transform=False)[source]
Identify defects in the crystalline structure based on atomic positions.
- Parameters:
data_atoms (defaultdict) – Dictionary containing simulation data as given by the LAMMPSReader and similar readers. Must include keys: ‘atoms’, ‘natoms’, ‘boundary’, ‘xlo’, ‘xhi’, ‘ylo’, ‘yhi’, ‘zlo’, ‘zhi’, ‘timestep’.
a1 (float, optional) – Final lattice parameter. If provided, defect positions are rescaled to this value (independently of the transform value).
pos_pka (npt.NDArray[np.float64], optional) – Position vector of the PKA. If provided with theta_pka and phi_pka, defects are recentered and aligned.
theta_pka (float, optional) – Polar angle (in radians) for the PKA direction.
phi_pka (float, optional) – Azimuthal angle (in radians) for the PKA direction.
transform (bool, optional) – If True, defects are recentered and aligned with the PKA direction (if provided). If True but no PKA parameters are provided, defects are recentered based on their average position. Note that the box boundaries are not modified for visualization purposes, only the atomic positions are transformed.
- Returns:
data_defects – Dictionary containing the defects found in the structure. Keys are the same as in data_atoms, but the ‘atoms’ key contains only defects and ‘natoms’ reflects the number of defects found.
- Return type:
defaultdict
irradiapy.analysis.dpa module
dpa analysis module.
- irradiapy.analysis.dpa.get_dpa_1d(srimdb, path_debris, path_db, fluence, axis='x', nbins=100, depth_offset=0.0)[source]
Perform a dpa histogram as a function of depth along a specified axis.
Notes
dpa is calculated from vacancies in the debris file.
Depth range is determined from the defect positions in the debris file.
- Parameters:
srimdb (SRIMDB) – SRIM database class.
path_debris (Path) – File containing all collision debris to analyze.
path_db (Path) – Path to the database file.
fluence (float) – Fluence, in ions/A2.
axis (str, optional (default="x")) – Axis along which the histogram was computed. It can be “x”, “y”, or “z”.
nbins (int, optional (default=100)) – Number of depth bins. Depth range determined from path_debris defect positions.
depth_offset (float, optional (default=0.0)) – Offset to add to the depth values.
- Return type:
- irradiapy.analysis.dpa.get_dpa_lammps_dump(path, lattice, a0)[source]
Get the dpa (from vacancies) in the full box from a LAMMPS dump file.
- irradiapy.analysis.dpa.plot_dpa_1d(path_db, path_plot=None, path_fit=None, axis='x', depth_offset=0.0, p0=None, asymmetry=1.0, dpi=300)[source]
Plot the 1D dpa analysis results from the database.
- Parameters:
path_db (Path) – Path to the database file.
path_plot (Path, optional (default=None)) – Output path for the plot. If None, the plot is shown.
path_fit (Path, optional (default=None)) – Output path for the fit parameters.
axis (str, optional (default="x")) – Axis along which the histogram was computed. It can be “x”, “y”, or “z”.
depth_offset (float, optional (default=0.0)) – Offset to add to the depth values.
p0 (float, optional (default=None)) – Initial guess of fit parameters.
asymmetry (float, optional (default=1.0)) – Asymmetry fit parameter bound.
dpi (int, optional (default=300)) – Dots per inch.
- Return type:
Module contents
This subpackage provides tools for irradiation damage analysis.