{ "info": { "author": "Christopher Ostrouchov", "author_email": "chris.ostrouchov+pysrim@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "![srim heatmap](https://gitlab.com/costrouc/pysrim/raw/master/examples/images/length-heatmap-log-cropped.png)\n\n**All issues and contributions should be done on\n[Gitlab](https://gitlab.com/costrouc/pysrim). Github is used only as a\nmirror for visibility**\n\n# pysrim: Automation, Analysis, and Plotting of SRIM Calculations\n\n`pysrim` is a python package that aims to wrap and extend SRIM a\npopular tool for simulating ions traveling through a material. There\nare many pain points to SRIM and this package aims to address\nthem. These include compatibility with all OS's, automation and crash\nrecovery of SRIM calculations, parsing of all output files, and\npublication quality plots.\n\nThere is now a docker image\n[costrouc/pysrim](https://hub.docker.com/r/costrouc/pysrim/tags/) for\nrunning pysrim and SRIM! **No setup necissary and does not require a\ndisplay so it is server ready**. If you would like to try it run the\nshort command below (obviously requires docker). All output files will\nbe stored in `/tmp/output` for this example. [Benchmarks\nshow](https://pysrim.readthedocs.io/en/latest/benchmarks.html) the\ndocker container is around 50-60% faster. I believe this is due to\nusing [xvfb](https://linux.die.net/man/1/xvfb)\n\n``` bash\ndocker run -v $PWD/examples/docker:/opt/pysrim/ \\\n -v /tmp/output:/tmp/output \\\n -it costrouc/pysrim sh -c \"xvfb-run -a python3.6 /opt/pysrim/ni.py\"\nls /tmp/output\n```\n\n\n\n \n \n\n\n \n \n\n\n \n \n\n\n \n \n\n\n \n \n\n\n \n \n\n\n \n \n\n\n \n \n\n\n \n \n\n
Latest Release\"latest
\"latest
Package Status\"status\"
License\"license\"
Build Status
Coverage \"coverage\"
Conda \"conda
Documentation \"readthedocs
Publication
DOI Repository Archive\"DOI\"
\n\n# Documentation\n\nLink to [documentation on readthedocs](https://pysrim.readthedocs.io/en/latest/)\n\n# Features\n\n## Automate running SRIM and TRIM on all operating systems\n\nWhile TRIM is a great code it has many downsides regarding\nautomation. The `TRIM.IN` input file is tedious to write yourself and\nthe gui that constructs the `TRIM.IN` will crash at unexpeced moments.\nOne of these crashes everyone has encountered is the fact that a float\ntext field can never be empty. TRIM also has a tendancy to crash\nbecuase it stores all cascades in memory. Meaning that for large runs\nwith full cascades greater than 1,000 ions it will run out of\nmemory. `pysrim` addresses all of these issues by providing a simple\nAPI wrapper for the input file (supporting all of the features),\nability to run on all operating systems (using\n[wine](https://appdb.winehq.org/objectManager.php?sClass=version&iId=13202)\nfor linux and OSX), and allowing batch runs of calculations see [this\nnotebook\nexample](https://gitlab.com/costrouc/pysrim/blob/master/examples/notebooks/SiC.ipynb).\n\nBelow is a hello world example of using `pysrim` for running a TRIM\ncalcualtion. Note that `/tmp/srim` is the path to the SRIM executable\ndirectory (`SRIM.exe` should reside in this directory). `pysrim` will\nadd all the necessary input files. If this ran successfully for you a\nSRIM window will popup and start the calculation.\n\n``` python\nfrom srim import Ion, Layer, Target, TRIM\n\n# Construct a 3MeV Nickel ion\nion = Ion('Ni', energy=3.0e6)\n\n# Construct a layer of nick 20um thick with a displacement energy of 30 eV\nlayer = Layer({\n 'Ni': {\n 'stoich': 1.0,\n 'E_d': 30.0,\n 'lattice': 0.0,\n 'surface': 3.0\n }}, density=8.9, width=20000.0)\n\n# Construct a target of a single layer of Nickel\ntarget = Target([layer])\n\n# Initialize a TRIM calculation with given target and ion for 25 ions, quick calculation\ntrim = TRIM(target, ion, number_ions=25, calculation=1)\n\n# Specify the directory of SRIM.exe\n# For windows users the path will include C://...\nsrim_executable_directory = '/tmp/srim'\n\n# takes about 10 seconds on my laptop\nresults = trim.run(srim_executable_directory)\n# If all went successfull you should have seen a TRIM window popup and run 25 ions!\n# results is `srim.output.Results` and contains all output files parsed\n```\n\nSee [documentation](https://pysrim.readthedocs.io/en/latest/) for all available options.\n\n## Copy SRIM output files to directory\n\nAfter a SRIM calculation has completed run `copy_output_files` to take\nall of the output files and move them to a directory of your liking.\n\n``` python\nfrom srim import TRIM\n\nTRIM.copy_output_files('/tmp/srim', '/home/costrouc/scratch/srim')\n```\n\n## Post processes SRIM output as numpy arrays\n\nBy far the hardest part about running TRIM calculations is analyzing\nthe output files. `pysrim` comes with parsers for\n[IONIZ.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Ioniz),\n[VACANCY.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Vacancy),\n[NOVAC.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.NoVacancy),\n[E2RECOIL.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.EnergyToRecoils),\n[PHONON.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Phonons),\n[RANGE.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Range),\nand\n[COLLISON.txt](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Collision). The\nCOLLISON.txt file can get quite large so the `Collision` parser uses a\nbuffered reader that can handle any file size. Additinally a class\n[srim.output.Results](https://pysrim.readthedocs.io/en/latest/source/srim.html#srim.output.Results)\nwill processes all output files in a directory and provide a\ndictionary of each parsed output file. `pysrim` comes with some\nhelpful plotting utilities such a plotting the DPA vs depth. However,\n`pysrim's` most powerful feature is that all of the text files are\nexposed as numpy arrays. The example below shows how to plot DPA using\na simple math and numpy. This enables the user to seamlessly use TRIM\nand do analysis.\n\n``` python\nfrom srim.output import Phonons, Ioniz\n\ndef plot_damage_energy(folder, ax):\n phon = Phonons(folder)\n dx = max(phon.depth) / 100.0\n energy_damage = (phon.ions + phon.recoils) * dx\n ax.plot(phon.depth, energy_damage / phon.num_ions, label='{}'.format(folder))\n return sum(energy_damage)\n\ndef plot_ionization(folder, ax):\n ioniz = Ioniz(folder)\n dx = max(ioniz.depth) / 100.0\n ax.plot(ioniz.depth, ioniz.ions, label='Ionization from Ions')\n ax.plot(ioniz.depth, ioniz.recoils, label='Ionization from Recoils')\n```\n\nSet `folders` to list of directories to SRIM outputs. See\n[Analysis](https://gitlab.com/costrouc/pysrim/blob/master/examples/notebooks/Analysis.ipynb)\nfor detailed example. Notice how there is a python class for each SRIM\noutput file and gives simple access to each column. This did require\nsome complex regex to get working just right.\n\n``` python\nfolders = ['test_files/2', 'test_files/4']\nimage_directory = 'examples/images'\n\nfig, axes = plt.subplots(1, len(folders), sharey=True, sharex=True)\n\nfor ax, folder in zip(np.ravel(axes), folders):\n plot_damage_energy(folder, ax)\n plot_ionization(folder, ax)\n ax.legend()\n ax.set_ylabel('eV')\n ax.set_xlabel('Depth [Angstroms]')\nfig.suptitle('Ionization Energy vs Depth', fontsize=15)\nfig.set_size_inches((20, 6))\nfig.savefig(os.path.join(image_directory, 'ionizationvsdepth.png'), transparent=True)\n```\n\n![srim heatmap](https://gitlab.com/costrouc/pysrim/raw/master/examples/images/ionizationvsdepth.png)\n\nSee [jupyter\nnotebook](