pysrim

pysrim: Automation, Analysis, and Plotting of SRIM Calculations - Published in JOSS (2018)

https://gitlab.com/costrouc/pysrim

Science Score: 89.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    1 of 4 committers (25.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Scientific Fields

Engineering Computer Science - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

Basic Info
  • Host: gitlab.com
  • Owner: costrouc
  • License: mit
  • Default Branch: master
Statistics
  • Stars: 11
  • Forks: 12
  • Open Issues: 11
  • Releases: 0
Created over 7 years ago

https://gitlab.com/costrouc/pysrim/blob/master/

![srim heatmap](https://gitlab.com/costrouc/pysrim/raw/master/examples/images/length-heatmap-log-cropped.png)

**All issues and contributions should be done on
[Gitlab](https://gitlab.com/costrouc/pysrim). Github is used only as a
mirror for visibility**

# pysrim: Automation, Analysis, and Plotting of SRIM Calculations

`pysrim` is a python package that aims to wrap and extend SRIM a
popular tool for simulating ions traveling through a material. There
are many pain points to SRIM and this package aims to address
them. These include compatibility with all OS's, automation and crash
recovery of SRIM calculations, parsing of all output files, and
publication quality plots.

There is now a docker image
[costrouc/pysrim](https://hub.docker.com/r/costrouc/pysrim/tags/) for
running pysrim and SRIM! **No setup necissary and does not require a
display so it is server ready**. If you would like to try it run the
short command below (obviously requires docker). All output files will
be stored in `/tmp/output` for this example. [Benchmarks
show](https://pysrim.readthedocs.io/en/latest/benchmarks.html) the
docker container is around 50-60% faster. I believe this is due to
using [xvfb](https://linux.die.net/man/1/xvfb)

``` bash
docker run -v $PWD/examples/docker:/opt/pysrim/ \
           -v /tmp/output:/tmp/output \
           -it costrouc/pysrim sh -c "xvfb-run -a python3.6 /opt/pysrim/ni.py"
ls /tmp/output
```

Latest Release latest release
latest release
Package Status status
License license
Build Status gitlab pipeline status
Coverage coverage
Conda conda downloads
Documentation readthedocs documentation
Publication
DOI Repository Archive DOI
# Documentation Link to [documentation on readthedocs](https://pysrim.readthedocs.io/en/latest/) # Features ## Automate running SRIM and TRIM on all operating systems While TRIM is a great code it has many downsides regarding automation. The `TRIM.IN` input file is tedious to write yourself and the gui that constructs the `TRIM.IN` will crash at unexpeced moments. One of these crashes everyone has encountered is the fact that a float text field can never be empty. TRIM also has a tendancy to crash becuase it stores all cascades in memory. Meaning that for large runs with full cascades greater than 1,000 ions it will run out of memory. `pysrim` addresses all of these issues by providing a simple API wrapper for the input file (supporting all of the features), ability to run on all operating systems (using [wine](https://appdb.winehq.org/objectManager.php?sClass=version&iId=13202) for linux and OSX), and allowing batch runs of calculations see [this notebook example](https://gitlab.com/costrouc/pysrim/blob/master/examples/notebooks/SiC.ipynb). Below is a hello world example of using `pysrim` for running a TRIM calcualtion. Note that `/tmp/srim` is the path to the SRIM executable directory (`SRIM.exe` should reside in this directory). `pysrim` will add all the necessary input files. If this ran successfully for you a SRIM window will popup and start the calculation. ``` python from srim import Ion, Layer, Target, TRIM # Construct a 3MeV Nickel ion ion = Ion('Ni', energy=3.0e6) # Construct a layer of nick 20um thick with a displacement energy of 30 eV layer = Layer({ 'Ni': { 'stoich': 1.0, 'E_d': 30.0, 'lattice': 0.0, 'surface': 3.0 }}, density=8.9, width=20000.0) # Construct a target of a single layer of Nickel target = Target([layer]) # Initialize a TRIM calculation with given target and ion for 25 ions, quick calculation trim = TRIM(target, ion, number_ions=25, calculation=1) # Specify the directory of SRIM.exe # For windows users the path will include C://... srim_executable_directory = '/tmp/srim' # takes about 10 seconds on my laptop results = trim.run(srim_executable_directory) # If all went successfull you should have seen a TRIM window popup and run 25 ions! # results is `srim.output.Results` and contains all output files parsed ``` See [documentation](https://pysrim.readthedocs.io/en/latest/) for all available options. ## Copy SRIM output files to directory After a SRIM calculation has completed run `copy_output_files` to take all of the output files and move them to a directory of your liking. ``` python from srim import TRIM TRIM.copy_output_files('/tmp/srim', '/home/costrouc/scratch/srim') ``` ## Post processes SRIM output as numpy arrays By far the hardest part about running TRIM calculations is analyzing the output files. `pysrim` comes with parsers for [IONIZ.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Ioniz), [VACANCY.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Vacancy), [NOVAC.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.NoVacancy), [E2RECOIL.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.EnergyToRecoils), [PHONON.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Phonons), [RANGE.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Range), and [COLLISON.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Collision). The COLLISON.txt file can get quite large so the `Collision` parser uses a buffered reader that can handle any file size. Additinally a class [srim.output.Results](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Results) will processes all output files in a directory and provide a dictionary of each parsed output file. `pysrim` comes with some helpful plotting utilities such a plotting the DPA vs depth. However, `pysrim's` most powerful feature is that all of the text files are exposed as numpy arrays. The example below shows how to plot DPA using a simple math and numpy. This enables the user to seamlessly use TRIM and do analysis. ``` python from srim.output import Phonons, Ioniz def plot_damage_energy(folder, ax): phon = Phonons(folder) dx = max(phon.depth) / 100.0 energy_damage = (phon.ions + phon.recoils) * dx ax.plot(phon.depth, energy_damage / phon.num_ions, label='{}'.format(folder)) return sum(energy_damage) def plot_ionization(folder, ax): ioniz = Ioniz(folder) dx = max(ioniz.depth) / 100.0 ax.plot(ioniz.depth, ioniz.ions, label='Ionization from Ions') ax.plot(ioniz.depth, ioniz.recoils, label='Ionization from Recoils') ``` Set `folders` to list of directories to SRIM outputs. See [Analysis](https://gitlab.com/costrouc/pysrim/blob/master/examples/notebooks/Analysis.ipynb) for detailed example. Notice how there is a python class for each SRIM output file and gives simple access to each column. This did require some complex regex to get working just right. ``` python folders = ['test_files/2', 'test_files/4'] image_directory = 'examples/images' fig, axes = plt.subplots(1, len(folders), sharey=True, sharex=True) for ax, folder in zip(np.ravel(axes), folders): plot_damage_energy(folder, ax) plot_ionization(folder, ax) ax.legend() ax.set_ylabel('eV') ax.set_xlabel('Depth [Angstroms]') fig.suptitle('Ionization Energy vs Depth', fontsize=15) fig.set_size_inches((20, 6)) fig.savefig(os.path.join(image_directory, 'ionizationvsdepth.png'), transparent=True) ``` ![srim heatmap](https://gitlab.com/costrouc/pysrim/raw/master/examples/images/ionizationvsdepth.png) See [jupyter notebook](

JOSS Publication

pysrim: Automation, Analysis, and Plotting of SRIM Calculations
Published
August 02, 2018
Volume 3, Issue 28, Page 829
Authors
Christopher Ostrouchov ORCID
Department of Material Science and Engineering, University of Tennessee
Yanwen Zhang ORCID
Division Materials Science and Technology, Oak Ridge National Laboratory
William J. Weber ORCID
Department of Material Science and Engineering, University of Tennessee, Division Materials Science and Technology, Oak Ridge National Laboratory
Editor
Kathryn Huff ORCID
Tags
SRIM nuclear materials simulation monte carlo python

Committers

Last synced: 4 months ago

All Time
  • Total Commits: 168
  • Total Committers: 4
  • Avg Commits per committer: 42.0
  • Development Distribution Score (DDS): 0.042
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Chris Ostrouchov c****v@g****m 161
Jesse Carter j****r@g****m 5
Anton Såmark-Roth a****h@g****m 1
Arun Persaud a****d@l****v 1
Committer Domains (Top 20 + Academic)
lbl.gov: 1

Issues and Pull Requests

Last synced: 4 months ago

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 163 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 2
  • Total versions: 23
  • Total maintainers: 1
pypi.org: pysrim

Srim Automation of Tasks via Python

  • Versions: 23
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 163 Last month
Rankings
Dependent packages count: 10.1%
Forks count: 10.9%
Dependent repos count: 11.6%
Average: 13.2%
Downloads: 15.6%
Stargazers count: 17.7%
Maintainers (1)
Last synced: 4 months ago

Dependencies

setup.py pypi
  • numpy >=1.10.0
  • pyyaml *