pysrim
Table of contents
Introduction
The Python package pysrim
provides a slick and convenient way of scripting some of the tedious aspects involed with running many similar SRIM
calculations. Its key strength is it provides a convenient interface to programatically define the calculation input. This is particularly advantageous as it:
- allows for easy “batch” calculations where a few simulation parameters are systematically varied (e.g., the ion implantation energy).
- allows the use of
for
loops when creat multilayered heterostructures, which is arduous otherwise. - makes the record of the calculation much more readable than
SRIM
’s own custom (and dated) input format.
It even works well when running on Linux (i.e., it automatically calls wine SRIM.exe
, wine TRIM.exe
, etc.)!
As a bonus, it also has a short paper that can be cited:
- Title
- pysrim: automation, analysis, and plotting of SRIM calculations
- Author
- C. Ostrouchov, Y. Zhang, W. J. Weber
- Journal
- J. Open Source Software
- Volume
- 3
- Issue
- 28
- Pages
- 829
- Year
- 2018
- 10.21105/joss.00829
- costrouc/pysrim
Example: a multi-layered heterostructure
Here I give an example showcasing pysrim
’s capabilities. The script below creates a target with a complex layered structure (one that would be particularly unpleasent construct “by hand”) and runs several TRIM
calculations for a single ion at a few different implantation energies. Conveniently, the script takes care of moving all the results to their own (new) folder after each calculation completes.
Try it out yourself!
Download heterostructure.py
.
Caveats
pysrim
, unfortunately, isn’t perfect and I ran into the following issues while using it:
Everytime it runs, it complains that the.yaml
file it’s reading isn’t done safely. This is due to a recent change inpyYAML
, requiring aLoader
to be specified as akwarg
. There is currently a merge request on the project’s GitLab page (https://gitlab.com/costrouc/pysrim) to fix this, but until this gets officially patched it can be mended by editing line 10 ofsrim/core/elemementdb.py
so that it reads:
It fails to parseIONIZ.txt
output when the ion energy is less than 1 keV. The problem is with the regex expression used to parse the output. As a simple workaround, rather than fixing the problem, it is sufficient to just comment out line 36 ofsrim/output.py
so that it reads:
The autosave input inTRIM
setup does not appear to work; the calculation won’t run if thekwarg
is specified. This is relatively minor, so my workaround is to just avoid providing the parameter.SRIM’s default values for (element specific) displacement, lattice, and surface binding energies do not appear to be used automatically and need to specified manually.Bragg corrections are not implemented on a per-layer basis. This is relatively easy to fix by editing lines 42-48 insrim/core/layer.py
to read:
as well as lines 150-153 in srim/input.py
to read:
pysrim
fails to parse results where no ions were stopped in the target. At least the fix is easy - simply comment out the exception raised on line 72 insrim.py
.
These issues/shortcomings are rectified in my custom fork of pysrim
; it can be obtained from: https://github.com/rmlmcfadden/pysrim