Package: lammpsgenie
lammpsgenieThis package is a collection of tools for handling LAMMPS data and dump files.ScriptsmergedatafilesThe main way to interact with lammpsgenie is using the scriptmergedatafiles, which should be called with a settings file (YAML format) like so:mergedatafiles merge_settings.yamlIf called without any argument, it will search the current directory for amerge.yamlandmerge.yml(in this order) and use the first one it finds, or return an error.The YAML file should contain two dictionaries (inputsandoutput), with the following format:output:
  filename: <filename/path where to write merged file>
  boxsize: # new boxsize for the merged file
    xlo: float
    xhi: float
    ylo: float
    yhi: float
    zlo: float
    zhi: float
inputs:
  # as many of the following as needed
  <filename/path of a data file to read from>:
    minormax: <min or max>
    value: floatThe script will gather the information from all the input files, shift coordinates to make sure they match the min/max values as given, and then write a new merged data file, with the new box limits provided.Example:output:
  filename: merged_uadodecane.lammps
  boxsize:
    xlo: 0.0
    xhi: 55.088
    ylo: 0.0
    yhi: 50.38
    zlo: -20.0
    zhi: 120.0
inputs:
  ../data/Fe2O3_50_down.lammps:
    minormax: max
    value: -1.5
  ../data/Fe2O3_50_up.lammps:
    minormax: min
    value: 80.0
  uadodecane.data:
    minormax: min
    value: 1.5saveironThere are three variants of thesaveironscript that write to the current working directory data files of the iron oxide surface:saveiron50saveiron100saveironallThe first one writes the files of surfaces with side 50Å, the second the files for surfaces with side 100Å, and the last one writes the files for surfaces of both 50 and 100Å.DevelopmentVirtual EnvironmentA virtual environment (venv) is like a sandbox, lets you install fresh version of packages (including local ones) without conflicting with your main python installation.
It is recommended to usevirtualenvwrapper, a series of shell scripts that automates the creation, activation, deactivation, (among other things) of venvs.
To installvirtualenvwrapperuse the command:pip install virtualenvwrapperThen you might need to export some variables on your~/.profile(order matters):# virtualenvwrapper
# if you have python2 installed, you might need:
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
# location of virtualenvwrapper.sh
source $(which virtualenvwrapper.sh)
# where to store the files for each venv
export WORKON_HOME=$HOME/.virtualenvs
# used when creating new projects
export PROJECT_HOME=$HOME/codeAnd restart your shell (or source~/.profile).To create a new venv, use:mkvirtualenv <name>This will create the venv and activate it.
Exit the venv withdeactivateand return to the venv withworkon <name>Sometimes, you need to add the path of the project to a venv.
That is done, when one has the venv activated, with:add2virtualenv /absolute/path/to/package/TestsYou will need pytest and some plugins to run tests.
The required python packages are provided in test_requirements.txt, and can be installed withpip install -r test_requirements.txtThis is better done inside a virtual environment, see the previous section.Tests can be run from the package folder with:pytestThis will run every test in thetests/folder.
To run only one of the test files, use:pytest tests/test_<name>.pyDuring development, a good way to keep an eye on tests when changing code (or adding new tests/test data) is to keep a separate terminal runningpytest-watch.
This will scan the module and test files, and run the new test, or the tests affected by any changes, once it detects a file has been written.
Use the commmand:ptw --runner "pytest --testmon"To check that the test cover the entirety of your code, use the coverage plugin for pytest:pytest --cov=lammpsgenieThere are several settings that can be changed for this tool, to do so, add a.coveragercfile to the project directory.
The following are a good set of defaults:[run]
branch = True

[paths]
source =
  lammpsgenie

[report]
show_missing = True
skip_empty = True
precision = 2DocStringsThenumpy styleguidewas followed for DocString documentation.ReleaseInstall required packages with:pip install --upgrade build twineModify codeAssure tests pass, and cover 100% of the code.Modify version in_version.pyCreate a build withpython3 -m build.Check that the distribution files pass checks withtwine check dist/*Upload to PyPi withpython3 -m twine upload --repository pypi dist/lammpsgenie-<version>*Note: you need an account on pypi, and the necessary rights to upload, and aregistered tokensaved on.pypircTo test your distribution, you might want to test upload to the PyPi test repository withpython3 -m twine upload --repository pypi dist/lammpsgenie-<version>*(Needs a separate registered account).