srim¶
- class srim.TRIM(target, ion, calculation=1, number_ions=1000, **kwargs)¶
Automate TRIM Calculations
- Parameters:
target (
srim.core.target.Target) – constructed target for TRIM calculationion (
srim.core.ion.Ion) – constructed ion for TRIM calculationcalculation (
int, optional) – Default 1 quick KP calculation (1) Ion Distribution and Quick Calculation of Damage (quick KP) (2) Detailed Calculation with full Damage Cascades (full cascades) (3) Monolayer Collision Steps / Surface Sputtering (4) Ions with specific energy/angle/depth (quick KP damage) using TRIM.DAT (5) Ions with specific energy/angle/depth (full cascades) using TRIM.DAT (6) Recoil cascades from neutrons, etc. (full cascades) using TRIM.DAT (7) Recoil cascades and monolayer steps (full cascades) using TRIM.DAT (8) Recoil cascades from neutrons, etc. (quick KP damage) using TRIM.DATnumber_ions (
int, optional) – number of ions that you want to simulate. Default 1000. A lot better than the 99999 default in TRIM…kwargs – See
srim.srim.TRIMSettingsfor available TRIM options. There are many and none are required defaults are appropriate for most cases.
Notes
If you are doing a simulation with over 1,000 ions it is recomended to split the calculaion into several smaller calculations. TRIM has been known to unexpectedly crash mainly due to memory usage.
- beam¶
the sampled ions (
srim.beam.exact.sample_ions)- Type:
exact mode of a distributed spec
- static copy_output_files(src_directory, dest_directory, check_srim_output=True)¶
Copies known TRIM files in directory to destination directory
- Parameters:
src_directory (
str) – source directory to look for TRIM output filesdest_directory (
str) – destination directory to copy TRIM output files tocheck_srim_output (
bool, optional) – also copy the files that SRIM writes to itsSRIM Outputssubfolder (RANGE_3D.txt,COLLISON.txt…). Files are copied, never moved: the source is left as it is, so aResultsof it keeps working.
- classmethod from_spec(spec)¶
Build a
TRIMfrom asrim.spec.RunSpecor itsdictform.to_specfollowed byfrom_specwrites a byte-identicalTRIM.IN.
- run(srim_directory=None, write_spec=True, *, work_dir=None, output_dir=None, keep=False, lock_timeout=None, run_dir=None)¶
Run configured srim calculation
By default the calculation runs in its own private run directory, a lightweight copy of the installed SRIM (see
srim.rundir.RunDir), so any number of runs can happen at the same time and the installed SRIM directory is never written. This method:writes the input file to
<run directory>/TRIM.INlaunches
<run directory>/TRIM.exe. Useswineif available (needed for linux and osx), in a private clone of the wine prefixafter a successful run writes
<run directory>/run.yaml(see below)
The returned
Resultsreads from the run directory, which is kept (belowwork_dir, default<pysrim2 data dir>/runs); passoutput_dirto get the outputs in a folder of your choice instead, in which case the run directory is removed. A run that fails keeps its run directory for debugging; the error mentions its path.- Parameters:
srim_directory (
str, optional) – Run in place in this SRIM directory (the pre-0.9 behaviour: outputs are written into it) instead of in a private copy. Concurrent in-place runs on the same directory take turns (exclusive file lock). DefaultNone: run isolated, copyingsrim_dir()(resolved when this method is called:$PYSRIM2_SRIM_DIR, then pysrim2’s data directory, then/tmp/srimif it holds an install).write_spec (
bool, optional) – writerun.yamlnext to the outputs (in the run directory, where the results are read from;copy_output_files()copies it along with them). It holds theRunSpec(including the seed) and the provenance: pysrim2 version, SRIM SHA-256 (from the.pysrim2-installedmarker, if present), platform, backend (nativeorwine), start and end time (UTC) and host name. Default True.work_dir (
str, optional) – folder to create the run directory in (default<pysrim2 data dir>/runs).output_dir (
str, optional) – copy the output files (andrun.yaml) here and read the results from here; the run directory is then removed unlesskeep.keep (
bool, optional) – keep the run directory even whenoutput_diris given. Default False.lock_timeout (
float, optional) – in-place runs only: seconds to wait for the directory lock before raisingTimeoutError(default: wait; a message appears after 5 s).run_dir (
srim.rundir.RunDir, optional) – reuse this run directory (it is reset first, and left in place afterwards). For workers that run many calculations.
- Returns:
its
specattribute is the run spec as a dict (without provenance, so exports carry no host name), used byResults.to_parquetetc.- Return type:
- to_spec()¶
Describe this calculation as a
srim.spec.RunSpec.The random seed is always recorded (when none was given, the one
TRIMSettingspicked), so running the spec again gives the sameTRIM.IN.settingsonly holds values that differ from the defaults, plusdescriptionandranges.
- to_yaml(path, provenance=None)¶
Write this calculation as a
run.yaml(seesrim.spec.RunSpec.to_yaml()).
- class srim.SR(layer, ion, **kwargs)¶
Automate SR Calculations
- Parameters:
leyer (
srim.core.layer.Layer) – constructed layer for SR calculationion (
srim.core.ion.Ion) – constructed ion for SR calculationkwargs – See
srim.srim.SRSettingsfor available SR options. There are a few and none are required. Defaults are appropriate for most cases.
- run(srim_directory=None, *, work_dir=None, output_dir=None, keep=False, lock_timeout=None, run_dir=None)¶
Run configured srim calculation
Like
TRIM.run(), this runs in a private run directory by default (the installed SRIM is never written);srim_directory=runs in place under a file lock. This method:writes the input file to
<run directory>/SR Module/TRIM.INlaunches
<run directory>/SR Module/SRModule.exe. Useswineif available (needed for linux and osx)
- Parameters:
srim_directory (
str, optional) – run in place in this SRIM directory (TRIM.exeshould be located in it), the pre-0.9 behaviour, under an exclusive file lock. DefaultNone: run in a private copy ofsrim_dir()(resolved when this method is called:$PYSRIM2_SRIM_DIR, then pysrim2’s data directory, then/tmp/srimif it holds an install).work_dir – see
TRIM.run();output_dirreceives the SR output file.output_dir – see
TRIM.run();output_dirreceives the SR output file.keep – see
TRIM.run();output_dirreceives the SR output file.lock_timeout – see
TRIM.run();output_dirreceives the SR output file.run_dir – see
TRIM.run();output_dirreceives the SR output file.
- class srim.Ion(identifier, energy, mass=None)¶
Representation of ion traveling through medium
Similar to
srim.core.element.Elementbut associates an energy with the element.- Parameters:
identifier (
str,int) – Symbol, Name, or Atomic Number of ionenergy (
float) – Energy [eV] of ionmass (
float, optional) – Mass [amu] of element. Default is most common isotope atomic weight
Examples
Constructing a Helium Ion.
>>> Ion('He', 1e6) "<Ion element:He mass:4.00 energy:1.00e6 eV>"
>>> Ion('He', energy=1e6, mass=4.2) "<Ion element:He mass:4.20 energy:1.00e6 eV>"
- property energy¶
Ion’s energy [eV]
- property velocity¶
Ion’s velocity [m/s]
- class srim.Layer(elements, density, width, phase=0, name=None)¶
Represents a layer in target
- Parameters:
elements (
dict) –- dictionary of elements (
srim.core.elements.Element,str, orint) with properties stoich(float, int, required): Stoichiometry of element (fraction)E_d(float, int, optional): Displacement energy [eV] default 25.0 eVlattice(float, int, optional): Lattice binding energies [eV] default 0.0 eVsurface(float, int, optional): Surface binding energies [eV] default 3.0 eV
- dictionary of elements (
density (
float) – density [g/cm^3] of materialwidth (
float) – width [Angstroms] of layerphase (
int) – phase of material (solid = 0, gas = 1). Default solid (0).name (
str, optional) – name of the Layer (defaults to the element symbols joined by “+”, e.g.Si+C)
Examples
Construct a layer of SiC with experimental values.
>>> Layer({ 'Si': { 'stoich': 0.5, 'E_d': 35.0, # Displacement Energy [eV] 'lattice': 0.0, 'surface': 3.0 }, 'C': { 'stoich': 0.5, 'E_d': 20.0, # Displacement Energy [eV] 'lattice': 0.0, 'surface': 3.0 }, density=3.21, width=10000.0)
- classmethod from_formula(chemical_formula, density, width, phase=0, name=None)¶
Creation Layer from chemical formula string, density, width, phase, and name
- Parameters:
chemical_formula (str) – see
srim.core.material.Material.from_formula()for allowed formulas. Quite flexible.density (
float) – density [g/cm^3] of materialwidth (
float) – width [Angstroms] of layerphase (
int) – phase of material (solid = 0, gas = 1). Default solid (0).name (
str, optional) – name of the Layer (defaults tochemical_formula, e.g.SiC; unlikeLayer, which joins the element symbols with “+”)
Notes
This method is not used as much since you do not have an easy way to set the displacement energy.
- property name¶
Layer’s Name
- property width¶
Layer’s width
- class srim.Target(layers)¶
Target that Ion Impacts
- Parameters:
layers (list) – list of
srim.core.layer.Layerto construct Target
Examples
Lets construct a SiC target. While only one layer is shown an arbitrary number of them can be used.
>>> Target([Layer({ 'Si': { 'stoich': 0.5, 'E_d': 35.0, # Displacement Energy [eV] 'lattice': 0.0, 'surface': 3.0 }, 'C': { 'stoich': 0.5, 'E_d': 20.0, # Displacement Energy [eV] 'lattice': 0.0, 'surface': 3.0 }, density=3.21, width=10000.0)])
- property width¶
total width of target (sum of layers)
- class srim.Element(identifier, mass=None)¶
Element from periodic table
- Parameters:
identifier (
str,int) – Symbol, Name, or Atomic Number of elementmass (
float, optional) – Mass [amu] of element. Default is most common isotope atomic weight
Examples
Constructing a Helium Atom.
>>> Element('He') <Element symbol:He name:Helium mass:4.00>
>>> Element('Helium') <Element symbol:He name:Helium mass:4.00>
>>> Element(2) <Element symbol:He name:Helium mass:4.00>
>>> Element('He', 4.3) <Element symbol:He name:Helium mass:4.30>
- property atomic_number¶
Element’s atomic number
- property mass¶
Element’s mass
- property name¶
Element’s formal name
- property symbol¶
Element’s atomic symbol
- class srim.Material(elements, density, phase=0)¶
Material Representation
- property chemical_formula¶
Material’s chemical formula
- property density¶
Material’s density
- classmethod from_formula(chemical_formula, density, phase=0)¶
Creation Material from chemical formula string and density
- Parameters:
chemical_formula (
str) – chemical formula string in specific formatdensity (
float) – density [g/cm^3] of materialphase (
int, optional) – phase of material (solid = 0, gas = 1). Default solid (0).
Notes
- Examples of chemical_formula that can be used:
SiC
CO2
AuFe1.5
Al10.0Fe90.0
Chemical Formula will be normalized to 1.0
- property phase¶
Material’s phase