irradiapy.srim package

Subpackages

Submodules

irradiapy.srim.analysis module

Utility functions related to SRIM data analysis and debris production.

irradiapy.srim.analysis.generate_debris(srimdb, dir_mddb, compute_tdam, path_debris, tdam_mode, dpa_mode, add_injected, outsiders, seed=None, depth_offset=0.0, ylo=None, yhi=None, zlo=None, zhi=None)[source]

Turns SRIM’s collisions into .xyz files for the given database of cascades’ debris.

Warning

Assumes a monolayer monoatomic target and same element for all ions.

Parameters:
  • srimdb (SRIMDB) – SRIM database class.

  • dir_mddb (Path) – Directory where the database of cascades’ debris is stored.

  • compute_tdam (bool) – Whether to transform the PKA energies into damage energies. It should be True for MD simulations without electronic stopping.

  • path_debris (Path) – Directory where the ions debris will be stored as .xyz files.

  • tdam_mode (materials.Material.TdamMode) – Mode to convert the PKA energy into damage energy.

  • dpa_mode (materials.Material.DpaMode) – Formula to convert the residual energy into Frenkel pairs.

  • add_injected (bool) – Whether to add the injected interstitial.

  • outsiders (bool) – Whether to include defects generated outside the material (PKAs close to surfaces). This can cause an inmbalance between the number of vacancies and interstitials.

  • seed (int, optional) – Random seed for reproducibility.

  • depth_offset (float, optional (default=0.0)) – Offset to add to the depth of the defects.

  • ylo (float, optional (default=None)) – Minimum y-coordinate for the defects. If None, will be set to minus the target width.

  • yhi (float, optional (default=None)) – Maximum y-coordinate for the defects. If None, will be set to the target width.

  • zlo (float, optional (default=None)) – Minimum z-coordinate for the defects. If None, will be set to minus the target width.

  • zhi (float, optional (default=None)) – Maximum z-coordinate for the defects. If None, will be set to the target width.

Return type:

None

irradiapy.srim.analysis.plot_distances(srimdb, pka_e_lim=5000.0, dist_bins=100, energy_bins=100, plot_path=None, dpi=300)[source]

Plots a 2D histogram of pairwise distances and sum of PKA energies for each ion.

Parameters:
  • srimdb (SRIMDB) – SRIM database class.

  • pka_elim (float, optional (default=5e3)) – Minimum recoil energy to consider.

  • dist_bins (int, optional (default=100)) – Number of bins for the distance histogram.

  • energy_bins (int, optional (default=100)) – Number of bins for the energy histogram.

  • plot_path (Path, optional (default=None)) – Output path for the plot. If None, the plot is shown.

  • dpi (int, optional (default=300)) – Dots per inch for the plot.

Return type:

None

irradiapy.srim.analysis.plot_energy_depth(srimdb, depth_bins=100, pka_ebins=100, pka_e_max=200, plot_high_path=None, plot_low_path=None, dpi=300)[source]

Plots the depth-energy distribution of PKAs.

Parameters:
  • srimdb (SRIMDB) – SRIM database class.

  • depth_bins (int, optional (default=100)) – Number of bins for depth histogram.

  • pka_ebins (int, optional (default=100)) – Number of bins for PKA energy histogram.

  • pka_e_max (float, optional (default=200)) – Maximum PKA energy.

  • plot_high_path (Path, optional (default=None)) – Output path for the high energy plot. If None, the plot is shown.

  • plot_low_path (Path, optional (default=None)) – Output path for the low energy plot. If None, the plot is shown.

  • dpi (int, optional (default=300)) – Dots per inch for the plot.

Return type:

None

irradiapy.srim.analysis.plot_injected(srimdb, bins=100, plot_path=None, path_fit=None, p0=None, asymmetry=1.0, dpi=300)[source]

Plot injected ions final depth distribution.

Parameters:
  • srimdb (SRIMDB) – SRIM database class.

  • bins (int, optional (default=100)) – Depth bins.

  • plot_path (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.

  • 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:

None

irradiapy.srim.analysis.plot_pka_distribution(srimdb, bins=100, plot_path=None, fit_path=None, dpi=300)[source]

Plot the PKA energy distribution and tries to fit it.

Parameters:
  • srimdb (SRIMDB) – SRIM database class.

  • bins (int, optional (default=100)) – Energy bins. The fit will be done over non-empty bins.

  • plot_path (Path, optional (default=None)) – Output path for the plot. If None, the plot is shown.

  • fit_path (Path, optional (default=None)) – Output path for the fit parameters.

  • dpi (int, optional (default=300)) – Dots per inch.

Returns:

Scaling law function.

Return type:

Callable

irradiapy.srim.srimdb module

This module contains the SRIMDB class.

class irradiapy.srim.srimdb.SRIMDB(*, path_db, calculation=None, target=None, check_interval=0.2, seed=0, reminders=0, plot_type=5, xmin=0.0, xmax=0.0, do_ranges=1, do_backscatt=1, do_transmit=1, do_sputtered=1, do_collisions=1, exyz=0.0, bragg=1, autosave=0, dir_srim=<factory>)[source]

Bases: Connection

Base class for running SRIM calculations and storing the output data in a SQLite database.

path_db

Output database path.

Type:

Path

target

SRIM target.

Type:

Target, optional

calculation

SRIM calculation.

Type:

str, optional

check_interval

Interval to check for SRIM window/popups.

Type:

float

srim_path

Where all SRIM output files are. If given, it will automatically add all those files into the database.

Type:

Path

con

Database connection.

Type:

sqlite3.Connection

backscat

Class storing BACKSCAT.txt data.

Type:

Backscat

e2recoil

Class storing E2RECOIL.txt data.

Type:

E2Recoil

ioniz

Class storing IONIZ.txt data.

Type:

Ioniz

lateral

Class storing LATERAL.txt data.

Type:

Lateral

phonon

Class storing PHONON.txt data.

Type:

Phonon

range

Class storing RANGE.txt data.

Type:

Range

range3d

Class storing RANGE_3D.txt data.

Type:

Range3D

sputter

Class storing SPUTTER.txt data.

Type:

Sputter

transmit

Class storing TRANSMIT.txt data.

Type:

Transmit

trimdat

Class storing TRIM.DAT data.

Type:

Trimdat

vacancy

Class storing VACANCY.txt data.

Type:

Vacancy

append_backscat(backscat_path)[source]

Appends BACKSCAT.txt into the database.

Parameters:

backscat_path (Path) – BACKSCAT.txt path.

Return type:

None

append_e2recoil(e2recoil_path)[source]

Appends E2RECOIL.txt into the database.

Parameters:

e2recoil_path (Path) – E2RECOIL.txt path.

Return type:

None

append_ioniz(ioniz_path)[source]

Appends IONIZ.txt into the database.

Parameters:

ioniz_path (Path) – IONIZ.txt path.

Return type:

None

append_lateral(lateral_path)[source]

Appends LATERAL.txt into the database.

Parameters:

lateral_path (Path) – LATERAL.txt path.

Return type:

None

append_novac(novac_path)[source]

Appends NOVAC.txt into the database.

Parameters:

novac_path (Path) – NOVAC.txt path.

Return type:

None

append_phonon(phonon_path)[source]

Appends PHONON.txt into the database.

Parameters:

phonon_path (Path) – PHONON.txt path.

Return type:

None

append_range(range_path)[source]

Appends RANGE.txt into the database.

Parameters:

range_path (Path) – RANGE.txt path.

Return type:

None

append_range3d(range3d_path)[source]

Appends RANGE_3D.txt into the database.

Parameters:

range3d_path (Path) – RANGE_3D.txt path.

Return type:

None

append_sputter(sputter_path)[source]

Appends SPUTTER.txt into the database.

Parameters:

sputter_path (Path) – SPUTTER.txt path.

Return type:

None

append_subcollision(collision_path)[source]

Appends currect iteration COLLISON.txt into the database.

Parameters:

collision_path (Path) – COLLISON.txt path.

Return type:

None

append_transmit(transmit_path)[source]

Appends TRANSMIT.txt into the database.

Parameters:

transmit_path (Path) – TRANSMIT.txt path.

Return type:

None

append_trimdat(trimdat_path)[source]

Appends TRIM.DAT into the database.

Parameters:

trimdat_path (Path) – TRIM.DAT path.

Return type:

None

append_vacancy(vacancy_path)[source]

Appends VACANCY.txt into the database.

Parameters:

vacancy_path (Path) – VACANCY.txt path.

Return type:

None

autosave: int = 0
bragg: int = 1
calculation: None | str = None
check_interval: float = 0.2
dir_srim: Path
do_backscatt: int = 1
do_collisions: int = 1
do_ranges: int = 1
do_sputtered: int = 1
do_transmit: int = 1
exyz: float = 0.0
generate_trimdat(atomic_numbers, energies, depths=None, ys=None, zs=None, cosxs=None, cosys=None, coszs=None)[source]

Generates TRIM.DAT file.

Parameters:
  • atomic_numbers (npt.NDArray[np.int64]) – Atomic numbers.

  • energies (npt.NDArray[np.float64]) – Energies.

  • depths (npt.NDArray[np.float64], optional) – Depths.

  • ys (npt.NDArray[np.float64], optional) – Y positions.

  • zs (npt.NDArray[np.float64], optional) – Z positions.

  • cosxs (npt.NDArray[np.float64], optional) – X directions.

  • cosys (npt.NDArray[np.float64], optional) – Y directions.

  • coszs (npt.NDArray[np.float64], optional) – Z directions.

Returns:

TRIM.DAT data.

Return type:

npt.NDArray[np.float64]

generate_trimin(atomic_numbers, energies, target)[source]

Generates TRIM.IN file.

Return type:

None

get_nions()[source]

Gets the number of ions in the simulation.

Return type:

int

load_target_calculation()[source]

Loads the target and calculation parameters from the database.

Return type:

Target

merge(srimdb2, backscat=True, e2recoil=True, ioniz=True, lateral=True, phonon=True, range3d=True, range_=True, sputter=True, transmit=True, vacancy=True, collision=True, trimdat=True, novac=True)[source]

Merges two databases.

Parameters:
  • srimdb2 (SRIMDBIter) – SRIM database to merge.

  • backscat (bool, optional) – Merge backscattering data.

  • e2recoil (bool, optional) – Merge energy to recoil data.

  • ioniz (bool, optional) – Merge ionization data.

  • lateral (bool, optional) – Merge lateral data.

  • phonon (bool, optional) – Merge phonon data.

  • range3d (bool, optional) – Merge 3D range data.

  • range (bool, optional) – Merge range data.

  • sputter (bool, optional) – Merge sputtering data.

  • transmit (bool, optional) – Merge transmission data.

  • vacancy (bool, optional) – Merge vacancy data.

  • collision (bool, optional) – Merge collision data.

  • trimdat (bool, optional) – Merge TRIMDAT data.

  • novac (bool, optional) – Merge NOVAC data.

Return type:

None

minimize_and_handle_popup()[source]

Minimizes the SRIM window and handles the end of calculation popup.

optimize()[source]

Optimize the SQLite database.

This method performs two operations to optimize the database: 1. Executes the “PRAGMA optimize” command to analyze and optimize the database. 2. Executes the “VACUUM” command to rebuild the database file, repacking it into a minimal amount of disk space.

Return type:

None

path_db: Path
plot_type: int = 5
reminders: int = 0
run(criterion, atomic_numbers, energies, remove_offsets, depths=None, ys=None, zs=None, cosxs=None, cosys=None, coszs=None, iter_max=None, ignore_32bit_warning=True)[source]

Runs the SRIM simulation.

Parameters:
  • criterion (Callable) – Criterion to repeat calculation, must return False to repeat calculation. Its signature is: criterion(nion, energy, depth, y, z, se, atom_hit, pka_e, target_disp). Recommended to be defined as def criterion(**kwargs: dict) -> bool:.

  • atomic_numbers (npt.NDArray[np.int64]) – Ion atomic numbers.

  • energies (npt.NDArray[np.float64]) – Ion energies.

  • remove_offsets (bool) – Whether to remove initial depth offsets or not.

  • depths (npt.NDArray[np.float64], optional) – Ion initial depths.

  • ys (npt.NDArray[np.float64], optional) – Ion initial y positions.

  • zs (npt.NDArray[np.float64], optional) – Ion initial z positions.

  • cosxs (npt.NDArray[np.float64], optional) – Ion initial x directions.

  • cosys (npt.NDArray[np.float64], optional) – Ion initial y directions.

  • coszs (npt.NDArray[np.float64], optional) – Ion initial z directions.

  • iter_max (int, optional (default=None)) – Maximum number of iterations.

Return type:

None

save_target_calculation()[source]

Saves the target and calculation parameters into the database.

Return type:

None

seed: int = 0
table_exists(table_name)[source]

Checks if the given table already exists in the database.

Parameters:

table_name (str) – Table’s name to check.

Returns:

Whether the table already exists or not.

Return type:

bool

target: None | Target = None
xmax: float = 0.0
xmin: float = 0.0

Module contents

This subpackage provides a Python interface for SRIM for simulating collisional cascades.