Skip to content

stfc/janus-core

Repository files navigation

Build Status Coverage Status Docs status PyPI version License DOI

janus-core

logo

Tools for machine learnt interatomic potentials

Features in development

  • Support for multiple MLIPs
    • MACE
    • M3GNET
    • CHGNET
  • Single point calculations
  • Geometry optimisation
  • Molecular Dynamics
    • NVE
    • NVT (Langevin(Eijnden/Ciccotti flavour) and Nosé-Hoover (Melchionna flavour))
    • NPT (Nosé-Hoover (Melchiona flavour))
  • Nudge Elastic Band
  • Phonons
    • vibroscopy
  • Training ML potentials
    • MACE
  • Fine tunning MLIPs
    • MACE
  • Rare events simulations
    • PLUMED

The code relies heavily on ASE, unless something else is mentioned.

Development

  1. Install poetry
  2. (Optional) Create a virtual environment
  3. Install janus-core with dependencies:
git clone https://github.com/stfc/janus-core
cd janus-core
pip install --upgrade pip
poetry install --with pre-commit,dev,docs  # install extra dependencies
pre-commit install  # install pre-commit hooks
pytest -v  # discover and run all tests

Manually updating ASE via https://gitlab.com/ase/ase is strongly recommended, as tags are no longer regularly published. For example:

pip install git+https://gitlab.com/ase/ase.git@b31569210d739bd12c8ad2b6ec0290108e049eea

To prevent poetry downgrading ASE when installing in future, add the commit to pyproject.toml:

poetry add git+https://gitlab.com:ase/ase.git#b31569210d739bd12c8ad2b6ec0290108e049eea

Examples

Single Point Calculations

Perform a single point calcuation (using the MACE-MP "small" force-field):

janus singlepoint --struct tests/data/NaCl.cif --arch mace_mp --calc-kwargs "{'model' : 'small'}"

This will calculate the energy, stress and forces and save this in NaCl-results.xyz, in addition to generating a log file, singlepoint.log, and summary of inputs, singlepoint_summary.yml.

Additional options may be specified. For example:

janus singlepoint --struct tests/data/NaCl.cif --arch mace --calc-kwargs "{'model' : '/path/to/your/ml.model'}" --properties energy --properties forces --log ./example.log --out ./example.xyz

This calculates both forces and energies, defines the MLIP architecture and path to your locally saved model, and changes where the log and results files are saved.

Note: the MACE calculator currently returns energy, forces and stress together, so in this case the choice of property will not change the output.

For all options, run janus singlepoint --help.

Geometry optimization

Perform geometry optimization (using the MACE-MP "small" force-field):

janus geomopt --struct tests/data/H2O.cif --arch mace_mp --calc-kwargs "{'model' : 'small'}"

This will optimize the atomic positions and save the resulting structure in H2O-opt.xyz, in addition to generating a log file, geomopt.log, and summary of inputs, geomopt_summary.yml.

Additional options may be specified. This shares most options with singlepoint, as well as a few additional options, such as:

janus geomopt --struct tests/data/NaCl.cif --arch mace_mp --calc-kwargs "{'model' : 'small'}" --vectors-only --traj 'NaCl-traj.xyz'

This allows the cell to be optimised, allowing only hydrostatic deformation, and saves the optimization trajector in addition to the final structure and log.

For all options, run janus geomopt --help.

Molecular dynamics

Run an NPT molecular dynamics simulation (using the MACE-MP "small" force-field) at 300K and 1 bar for 1000 steps (1 ps):

janus md --ensemble npt --struct tests/data/NaCl.cif --arch mace_mp --calc-kwargs "{'model' : 'small'}" --temp 300 --steps 1000 --pressure 1.0

This will generate several output files:

  • Thermodynamical statistics every 100 steps, written to NaCl-npt-T300.0-p1.0-stats.dat
  • The structure trajectory every 100 steps, written to NaCl-npt-T300.0-p1.0-traj.xyz
  • The structure to be able to restart the dynamics every 1000 steps, written to NaCl-npt-T300.0-p1.0-res-1000.xyz
  • The final structure written to NaCl-npt-T300.0-p1.0-final.xyz
  • A log of the processes carried out, written to md.log
  • A summary of the inputs and start/end time, written to md_summary.yml.

Additional options may be specified. For example:

janus md --ensemble nvt --struct tests/data/NaCl.cif --steps 1000 --timestep 0.5 --temp 300 --minimize --minimize-every 100 --rescale-velocities --remove-rot --rescale-every 100 --equil-steps 200

This performs an NVT molecular dynamics simulation at 300K for 1000 steps (0.5 ps), including performing geometry optimization, rescaling velocities, and removing rotation, both before beginning dynamics and at steps 100 and 200 of the simulation.

janus md --ensemble nve --struct tests/data/NaCl.cif --steps 200 --temp 300 --traj-start 100 --traj-every 10 --traj-file "example-trajectory.xyz" --stats-every 10 --stats-file "example-statistics.dat"

This performs an NVE molecular dynamics simulation at 300K for 200 steps (0.2 ps), saving the trajectory every 10 steps after the first 100, and the thermodynamical statistics every 10 steps, as well as changing the output file names for both.

For all options, run janus md --help.

Heating

Run an NVT heating simultation from 20K to 300K in steps of 20K, with 10fs at each temperature:

janus md --ensemble nvt --struct tests/data/NaCl.cif --temp-start 20 --temp-end 300 --temp-step 20 --temp-time 10

The produced statistics and trajectory files will indicate the heating range NaCl-nvt-T20.0-T300.0-stats.dat, NaCl-nvt-T20.0-T300.0-traj.xyz. There will also be final structure files at each temperature point:

NaCl-nvt-T20.0-final.xyz
NaCl-nvt-T40.0-final.xyz
...
NaCl-nvt-T300.0-final.xyz

MD can also be carried out after heating using the same options as described in Molecular dynamics. For example:

janus md --ensemble nvt --struct tests/data/NaCl.cif --temp-start 20 --temp-end 300 --temp-step 20 --temp-time 10 --steps 1000 --temp 300

This performs the same initial heating, before running a further 1000 steps (1 ps) at 300K.

When MD is run with heating the trajectory NaCl-nvt-T20.0-T300.0-T300.0-traj.xyz and statistics NaCl-nvt-T20.0-T300.0-T300.0-stats.dat files will indicate the heating range and MD temperature (which may be different). With heating and MD trajectories/statistics within the same files.

Using configuration files

Default values for all command line options may be specifed through a Yaml 1.1 formatted configuration file by adding the --config option. If an option is present in both the command line and configuration file, the command line value takes precedence.

For example, with the following configuration file and command:

struct: "NaCl.cif"
properties:
  - "energy"
out: "NaCl-results.xyz"
arch: mace_mp
calc-kwargs:
  model: medium
janus singlepoint --struct KCl.cif --out KCl-results.cif --config config.yml

This will run a singlepoint energy calculation on KCl.cif using the MACE-MP "medium" force-field, saving the results to KCl-results.cif.

Note

properties must be passed as a Yaml list, as above, not as a string.

License

BSD 3-Clause License

Funding

Contributors to this project were funded by

PSDI ALC CoSeC