Open In Colab

Single Point

janus-core contains various machine learnt interatomic potentials (MLIPs), including MACE based models (MACE-MP, MACE-OFF), CHGNet, SevenNet and more, full list on https://github.com/stfc/janus-core.

Other will be added as their utility is proven beyond a specific material.

Set up environment (optional)

These steps are required for Google Colab, but may work on other systems too:

[1]:
# import locale
# locale.getpreferredencoding = lambda: "UTF-8"

# ! pip uninstall torch torchaudio torchvision transformers numpy -y
# ! uv pip install janus-core[all] data-tutorials torch==2.5.1 --system
# get_ipython().kernel.do_shutdown(restart=True)

Use data_tutorials to get the data required for this tutorial:

[2]:
from data_tutorials.data import get_data

get_data(
    url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/",
    filename=["NaCl-set.xyz"],
    folder="../data",
)
try to download NaCl-set.xyz from https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/ and save it in ../data/NaCl-set.xyz
saved in ../data/NaCl-set.xyz

Command-line help and options

Once janus-core is installed, the janus CLI command should be available:

[3]:
! janus --help
                                                                                
 Usage: janus [OPTIONS] COMMAND [ARGS]...                                       
                                                                                
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --version                     Print janus version and exit.                  │
│ --install-completion          Install completion for the current shell.      │
│ --show-completion             Show completion for the current shell, to copy │
│                               it or customize the installation.              │
│ --help                        Show this message and exit.                    │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Calculations ───────────────────────────────────────────────────────────────╮
│ singlepoint   Perform single point calculations and save to file.            │
│ geomopt       Perform geometry optimization and save optimized structure to  │
│               file.                                                          │
│ md            Run molecular dynamics simulation, and save trajectory and     │
│               statistics.                                                    │
│ phonons       Calculate phonons and save results.                            │
│ eos           Calculate equation of state.                                   │
│ neb           Run Nudged Elastic Band method.                                │
│ descriptors   Calculate MLIP descriptors.                                    │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Training ───────────────────────────────────────────────────────────────────╮
│ train         Train or fine-tune an MLIP.                                    │
│ preprocess    Preprocess data before training.                               │
╰──────────────────────────────────────────────────────────────────────────────╯

 Try 'janus COMMAND --help' for subcommand options


Help for individual janus commands also be requested, describing all available options:

[4]:
! janus singlepoint --help
                                                                                
 Usage: janus singlepoint [OPTIONS]                                             
                                                                                
 Perform single point calculations and save to file.


╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --config        TEXT  Path to configuration file.                            │
│ --help                Show this message and exit.                            │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ MLIP calculator ────────────────────────────────────────────────────────────╮
│ *  --arch               [mace|mace_mp|mace_off|m  MLIP architecture to use   │
│                         3gnet|chgnet|alignn|seve  for calculations.          │
│                         nnet|nequip|dpa3|orb|mat  [required]                 │
│                         tersim|grace|esen|equifo                             │
│                         rmer]                                                │
│    --device             [cpu|cuda|mps|xpu]        Device to run calculations │
│                                                   on.                        │
│                                                   [default: cpu]             │
│    --model              TEXT                      MLIP model name, or path   │
│                                                   to model.                  │
│                                                   [default: None]            │
│    --model-path         TEXT                      Deprecated. Please use     │
│                                                   --model                    │
│                                                   [default: None]            │
│    --calc-kwargs        DICT                      Keyword arguments to pass  │
│                                                   to selected calculator.    │
│                                                   Must be passed as a        │
│                                                   dictionary wrapped in      │
│                                                   quotes, e.g. "{'key':      │
│                                                   value}".                   │
│                                                   [default: None]            │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Calculation ────────────────────────────────────────────────────────────────╮
│ *  --struct            PATH                       Path of structure to       │
│                                                   simulate.                  │
│                                                   [required]                 │
│    --properties        [energy|stress|forces|hes  Properties to calculate.   │
│                        sian]                      If not specified,          │
│                                                   'energy', 'forces' and     │
│                                                   'stress' will be returned. │
│                                                   [default: None]            │
│    --out               PATH                       Path to save structure     │
│                                                   with calculated results.   │
│                                                   Default is inferred from   │
│                                                   `file_prefix`.             │
│                                                   [default: None]            │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Structure I/O ──────────────────────────────────────────────────────────────╮
│ --file-prefix         PATH  Prefix for output files, including directories.  │
│                             Default directory is ./janus_results, and        │
│                             default filename prefix is inferred from the     │
│                             input stucture filename.                         │
│                             [default: None]                                  │
│ --read-kwargs         DICT  Keyword arguments to pass to ase.io.read. Must   │
│                             be passed as a dictionary wrapped in quotes,     │
│                             e.g. "{'key': value}". By default,               │
│                             read_kwargs['index'] = ':', so all structures    │
│                             are read.                                        │
│                             [default: None]                                  │
│ --write-kwargs        DICT  Keyword arguments to pass to ase.io.write when   │
│                             saving any structures. Must be passed as a       │
│                             dictionary wrapped in quotes, e.g. "{'key':      │
│                             value}".                                         │
│                             [default: None]                                  │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Logging/summary ────────────────────────────────────────────────────────────╮
│ --log                                  PATH  Path to save logs to. Default   │
│                                              is inferred from `file_prefix`  │
│                                              [default: None]                 │
│ --tracker         --no-tracker               Whether to save carbon          │
│                                              emissions of calculation        │
│                                              [default: tracker]              │
│ --summary                              PATH  Path to save summary of inputs, │
│                                              start/end time, and carbon      │
│                                              emissions. Default is inferred  │
│                                              from `file_prefix`.             │
│                                              [default: None]                 │
│ --progress-bar    --no-progress-bar          Whether to show progress bar.   │
│                                              [default: progress-bar]         │
╰──────────────────────────────────────────────────────────────────────────────╯

Running single point calculations

First, we need a file to perform calculations on. Here, we build a periodic salt structure, visualise it, and write out to a file.

Tip: We use the ASE and WEAS Widget libaries here to build the structure and visualise it. We discuss these tools in more detail in the Python tutorials.

[5]:
from ase.build import bulk
from ase.io import write
from weas_widget import WeasWidget

NaCl = bulk("NaCl", "rocksalt", a=5.63, cubic=True)

write("../data/NaCl.xyz", NaCl)

v=WeasWidget()
v.from_ase(NaCl)
v.avr.model_style = 1
v.avr.show_hydrogen_bonds = True
v
[5]:

Now we can use an MLIP to run single point calculations. By default, this uses the MACE-MP model:

[6]:
! janus singlepoint --arch mace_mp --struct ../data/NaCl.xyz --no-tracker
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head Default out of ['Default']

Results from CLI calculations are saved in a newly created directory, janus_results:

[7]:
! ls janus_results/
NaCl-1040-npt-T1040.0-T1080.0-p0.0-final.extxyz
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-log.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-summary.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-stats.dat
NaCl-1040-npt-T1040.0-T1080.0-p0.0-traj.extxyz
NaCl-auto_bands.yml.xz
NaCl-bands.svg
NaCl-bs-dos.svg
NaCl-deformed-geomopt-log.yml
NaCl-deformed-geomopt-summary.yml
NaCl-deformed-opt.extxyz
NaCl-deformed-traj.extxyz
NaCl-dos.dat
NaCl-dos.svg
NaCl-force_constants.hdf5
NaCl-mace-geomopt-log.yml
NaCl-mace-geomopt-summary.yml
NaCl-mace-opt.extxyz
NaCl-nvt-T100.0-cor.dat
NaCl-nvt-T100.0-final.extxyz
NaCl-nvt-T100.0-md-log.yml
NaCl-nvt-T100.0-md-summary.yml
NaCl-nvt-T100.0-res-100.extxyz
NaCl-nvt-T100.0-res-150.extxyz
NaCl-nvt-T100.0-res-200.extxyz
NaCl-nvt-T100.0-res-250.extxyz
NaCl-nvt-T100.0-res-300.extxyz
NaCl-nvt-T100.0-res-50.extxyz
NaCl-nvt-T100.0-stats.dat
NaCl-nvt-T100.0-traj.extxyz
NaCl-opt.extxyz
NaCl-phonons-log.yml
NaCl-phonons-summary.yml
NaCl-phonopy.yml
NaCl-results.extxyz
NaCl-sevennet-geomopt-log.yml
NaCl-sevennet-geomopt-summary.yml
NaCl-sevennet-opt.extxyz
NaCl-singlepoint-log.yml
NaCl-singlepoint-summary.yml
NaCl-thermal.yml
ethanol_products-final-opt.extxyz
ethanol_products_1water-final-opt.extxyz
ethanol_products_2water-final-opt.extxyz
ethanol_reactants-init-opt.extxyz
ethanol_reactants-neb-band.extxyz
ethanol_reactants-neb-log.yml
ethanol_reactants-neb-plot.svg
ethanol_reactants-neb-results.dat
ethanol_reactants-neb-summary.yml
ethanol_reactants_1water-init-opt.extxyz
ethanol_reactants_1water-neb-band.extxyz
ethanol_reactants_1water-neb-log.yml
ethanol_reactants_1water-neb-plot.svg
ethanol_reactants_1water-neb-results.dat
ethanol_reactants_1water-neb-summary.yml
ethanol_reactants_2water-init-opt.extxyz
ethanol_reactants_2water-neb-band.extxyz
ethanol_reactants_2water-neb-log.yml
ethanol_reactants_2water-neb-plot.svg
ethanol_reactants_2water-neb-results.dat
ethanol_reactants_2water-neb-summary.yml
mof-5-auto_bands.yml.xz
mof-5-bands.svg
mof-5-bands.yml.xz
mof-5-bs-dos.svg
mof-5-dos.dat
mof-5-dos.svg
mof-5-force_constants.hdf5
mof-5-opt.extxyz
mof-5-phonons-log.yml
mof-5-phonons-summary.yml
mof-5-phonopy.yml
mof-5-thermal.yml

We can now read the output file back into ASE, to see the saved energy, stresses, and forces:

[8]:
from ase.io import read

results = read("janus_results/NaCl-results.extxyz")
[9]:
print(f"Energy: {results.info['mace_mp_energy']}")
print()
print(f"Stress: {results.info['mace_mp_stress']}")
print()
print(f"Forces: {results.arrays['mace_mp_forces']}")
Energy: -27.0300815358917

Stress: [-5.81654699e-03 -5.81654699e-03 -5.81654699e-03 -1.95365728e-20
 -1.01673167e-19 -6.61872676e-19]

Forces: [[-0. -0. -0.]
 [ 0.  0. -0.]
 [ 0.  0.  0.]
 [-0.  0.  0.]
 [ 0.  0. -0.]
 [ 0. -0. -0.]
 [ 0.  0.  0.]
 [-0.  0. -0.]]

We can check the units corresponding to these quantities, which are also saved in the “info” dictionary:

[10]:
print(results.info["units"])
{'energy': 'eV', 'forces': 'ev/Ang', 'stress': 'ev/Ang^3'}

Using configuration files

All options to janus commands can be specified through a YAML input file. These are text files of the form:

key: value
list_key:
  - list_value_1
  - list_value_2
nested_key_1:
  nested_key_2: nested_value

which, in Python, would correspond to a dictionary of the form:

{
    "key": value,
    "list_key": [list_value_1, list_value_2],
    "nested_key": {"nested_key_2": nested_value},
}

Although you can specify every option, let’s first write a minimal configuration file for janus singlepoint:

[11]:
%%writefile singlepoint_config_1.yml

arch: mace_mp
struct: ../data/NaCl.xyz
tracker: False
Writing singlepoint_config_1.yml
[12]:
! cat singlepoint_config_1.yml

arch: mace_mp
struct: ../data/NaCl.xyz
tracker: False

We can then use this configuration file to re-run the calculation:

[13]:
! janus singlepoint --config singlepoint_config_1.yml
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head Default out of ['Default']

Options in the configuration files can be overwritten when running a command. For example, the following configuration file also defines the file_prefix, which specifies any directories and the prefix of the file names to be output:

[14]:
%%writefile singlepoint_config_2.yml

arch: mace_mp
struct: ../data/NaCl.xyz
file_prefix: examples/NaCl
tracker: False
Writing singlepoint_config_2.yml

We can now use this configuration file, but replace file_prefix:

[15]:
! janus singlepoint --config singlepoint_config_2.yml --file-prefix outputs/salt
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head Default out of ['Default']

Note: In the CLI, multi-word arguments must be separated by “-”. In configuration files, they are preferably separated by “_”, although “-” should be converted automatically.

This creates a new output directory, outputs, as well as starting all output files with “salt-”

[16]:
! ls outputs
salt-results.extxyz  salt-singlepoint-log.yml  salt-singlepoint-summary.yml

Running multiple calculations

By default, results from janus singlepoint are saved in two forms. For energies, this is an “info” dictionary, and a “results” dictionary.

One set of dictionary keys will be labelled with the MLIP model used (“mace_mp_energy”, “mace_mp_stress”, “mace_mp_forces”), which ensures these are not overwritten when running calculations with multiple models.

The unlabelled set of keys (“energy”, “forces”, “stress”) allow ASE to use the results for further calculations, but will be overwritten if a new calculation is run.

[17]:
print(results.info.keys())
print(results.arrays.keys())
print(results.calc.results.keys())

print()
print(results.calc.results["energy"])
print(results.get_potential_energy())
print(results.get_total_energy())
dict_keys(['units', 'model', 'arch', 'mace_mp_stress', 'mace_mp_energy', 'system_name'])
dict_keys(['numbers', 'positions', 'mace_mp_forces'])
dict_keys(['forces', 'energy', 'free_energy', 'stress'])

-27.0300815358917
-27.0300815358917
-27.0300815358917

For example, if we re-run the calculation using SevenNet, saving the results to a new output file, we see that “mace_mp_energy” is still saved, other unlabelled results are updated:

[18]:
! janus singlepoint --struct janus_results/NaCl-results.extxyz --arch sevennet --out janus_results/NaCl-updated-results.extxyz --no-tracker
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
[19]:
updated_results = read("janus_results/NaCl-updated-results.extxyz")
[20]:
print(updated_results.info.keys())
print(updated_results.arrays.keys())
print(updated_results.calc.results.keys())

print()
print(updated_results.info["mace_mp_energy"])
print(updated_results.info["sevennet_energy"])
print(updated_results.calc.results["energy"])
print(updated_results.get_potential_energy())
print(updated_results.get_total_energy())
dict_keys(['units', 'model', 'arch', 'mace_mp_stress', 'mace_mp_energy', 'system_name', 'sevennet_energy', 'sevennet_stress'])
dict_keys(['numbers', 'positions', 'mace_mp_forces', 'sevennet_forces'])
dict_keys(['energies', 'forces', 'free_energy', 'energy', 'stress'])

-27.0300815358917
-27.057369232177734
-27.057369232177734
-27.057369232177734
-27.057369232177734

Output files

In addition to the resulting structure file, all calculations run through the CLI generate log (NaCl-singlepoint-log.yml) and summary (NaCl-singlepoint-summary.yml) files.

In this case, the log file captures timestamps for the start and end of the calculation, but it will also capture any Python warnings generated, and carbon tracking information:

[21]:
! cat janus_results/NaCl-singlepoint-log.yml

- timestamp: 2025-05-20 14:37:44,750
  level: INFO
  message:
    - "Starting single point calculation"
  trace: single_point
  line: 356


- timestamp: 2025-05-20 14:37:44,933
  level: INFO
  message:
    - "Single point calculation complete"
  trace: single_point
  line: 372

The summary file contains:

  • The main command run

  • The CLI options specified

  • Basic information about the structure

  • Output files generated by the calculation

  • Start and end times of the calculation

  • Carbon tracking summary, if applicable

[22]:
! cat janus_results/NaCl-singlepoint-summary.yml
command: janus singlepoint
config:
  arch: mace_mp
  calc_kwargs: {}
  device: cpu
  file_prefix: null
  log: null
  model: null
  model_path: null
  out: null
  progress_bar: true
  properties: []
  read_kwargs: {}
  struct: ../data/NaCl.xyz
  summary: null
  tracker: false
  write_kwargs: {}
info:
  struct:
    formula: Cl4Na4
    n_atoms: 8
    struct_path: ../data/NaCl.xyz
output_files:
  log: /home/runner/work/janus-core/janus-core/docs/source/tutorials/cli/janus_results/NaCl-singlepoint-log.yml
  results: /home/runner/work/janus-core/janus-core/docs/source/tutorials/cli/janus_results/NaCl-results.extxyz
  summary: /home/runner/work/janus-core/janus-core/docs/source/tutorials/cli/janus_results/NaCl-singlepoint-summary.yml
start_time: 20/05/2025, 14:37:44
end_time: 20/05/2025, 14:37:44

Reusing configuration files

We can extract the configuration used to run our first calculation from the summary file, reusing it with a slight modification.

First, we read in the configuration via the summary file:

[23]:
import yaml

with open("janus_results/NaCl-singlepoint-summary.yml", encoding="utf8") as file:
    summary = yaml.safe_load(file)

config = summary["config"]
print(config)
{'arch': 'mace_mp', 'calc_kwargs': {}, 'device': 'cpu', 'file_prefix': None, 'log': None, 'model': None, 'model_path': None, 'out': None, 'progress_bar': True, 'properties': [], 'read_kwargs': {}, 'struct': '../data/NaCl.xyz', 'summary': None, 'tracker': False, 'write_kwargs': {}}

Next, let’s change the structure to run the calculations on, ensure we read all images the file (this is actaully the default for single point calculations), and change the calculated property:

[24]:
config["struct"] = "../data/NaCl-set.xyz"
config["read_kwargs"] = {"index": ":"} # Key word arguments, passed to ase.io.read`
config["properties"] = ["hessian"] # This must be a list, even for a single quantity

Now, we write this file out, and use it to run our calculation:

[25]:
with open("singlepoint_config_3.yml", "w", encoding="utf8") as file:
    yaml.dump(config, file)
[26]:
! cat singlepoint_config_3.yml
arch: mace_mp
calc_kwargs: {}
device: cpu
file_prefix: null
log: null
model: null
model_path: null
out: null
progress_bar: true
properties:
- hessian
read_kwargs:
  index: ':'
struct: ../data/NaCl-set.xyz
summary: null
tracker: false
write_kwargs: {}
[27]:
! janus singlepoint --config singlepoint_config_3.yml
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head Default out of ['Default']
There should be a progress bar...
Computing Hessian... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11/11 0:00:00

We can read in these results, ensuring we read in all structures from the file:

[28]:
NaCl_set_results = read("janus_results/NaCl-set-results.extxyz", index=":")
[29]:
print(NaCl_set_results[0].info["mace_mp_hessian"])
[[[ 1.25015779e+01 -2.14723399e-21 -1.06979383e-20]
  [-1.29279560e+01  0.00000000e+00 -4.53281591e-22]
  [ 3.29895005e-01  0.00000000e+00 -1.08420217e-19]
  [-2.34182749e-01  0.00000000e+00  1.73472348e-18]
  [-3.13032441e-02  0.00000000e+00 -3.46944695e-18]
  [ 1.96636174e-01  0.00000000e+00  1.19262239e-18]
  [-3.13032441e-02 -9.75781955e-19  0.00000000e+00]
  [ 1.96636174e-01 -4.33680869e-19  0.00000000e+00]]

 [[-3.20216407e-20 -7.62354636e-01  1.89931272e-17]
  [ 0.00000000e+00  1.52481636e+00  2.15789117e-19]
  [ 0.00000000e+00 -6.53117090e-01 -2.81892565e-18]
  [ 0.00000000e+00 -4.14234119e-02 -6.93889390e-18]
  [ 5.42101086e-19 -4.88497760e-03  4.33680869e-19]
  [ 0.00000000e+00 -1.07996124e-01  0.00000000e+00]
  [ 1.68051337e-18  2.02868811e-01  2.16840434e-19]
  [ 0.00000000e+00 -1.57908927e-01 -2.07792804e-23]]

 [[ 1.72561751e-19  3.84280339e-18 -7.62354636e-01]
  [-7.32468834e-20  9.98608211e-19  1.52481636e+00]
  [ 0.00000000e+00 -8.67361738e-19 -6.53117090e-01]
  [-8.67361738e-19  0.00000000e+00 -4.14234119e-02]
  [-8.13151629e-19 -2.16840434e-19  2.02868811e-01]
  [ 0.00000000e+00  0.00000000e+00 -1.57908927e-01]
  [ 0.00000000e+00 -2.16840434e-19 -4.88497760e-03]
  [-1.08420217e-19  2.50147008e-21 -1.07996124e-01]]

 [[-1.29279560e+01  0.00000000e+00 -3.83516847e-22]
  [ 1.25015779e+01 -3.40668124e-20 -2.51215346e-20]
  [-2.34182749e-01  0.00000000e+00  0.00000000e+00]
  [ 3.29895005e-01  0.00000000e+00 -4.87890978e-19]
  [ 1.96636174e-01  0.00000000e+00 -4.33680869e-19]
  [-3.13032441e-02  0.00000000e+00  1.95156391e-18]
  [ 1.96636174e-01 -4.33680869e-19  0.00000000e+00]
  [-3.13032441e-02  1.73472348e-18  0.00000000e+00]]

 [[ 0.00000000e+00  1.52481636e+00  1.10221180e-20]
  [ 0.00000000e+00 -7.62354636e-01 -6.95305939e-18]
  [ 0.00000000e+00 -4.14234119e-02  3.46944695e-18]
  [ 2.16840434e-19 -6.53117090e-01  8.67361738e-19]
  [ 0.00000000e+00 -1.07996124e-01 -2.16840434e-19]
  [ 4.33680869e-19 -4.88497760e-03  0.00000000e+00]
  [ 0.00000000e+00 -1.57908927e-01  0.00000000e+00]
  [ 7.58941521e-19  2.02868811e-01 -1.39088968e-23]]

 [[-1.34012077e-19  5.37183777e-20  1.52481636e+00]
  [ 3.89393402e-19  2.02710745e-18 -7.62354636e-01]
  [ 0.00000000e+00  1.73472348e-18 -4.14234119e-02]
  [ 0.00000000e+00  1.08420217e-18 -6.53117090e-01]
  [ 0.00000000e+00  2.16840434e-19 -1.57908927e-01]
  [ 5.42101086e-19 -6.50521303e-19  2.02868811e-01]
  [ 2.16840434e-19  2.16840434e-19 -1.07996124e-01]
  [ 2.16840434e-19 -8.68482679e-19 -4.88497760e-03]]

 [[ 3.29895005e-01  0.00000000e+00  1.64769868e-22]
  [-2.34182749e-01  0.00000000e+00  3.46784505e-18]
  [ 1.25015779e+01  0.00000000e+00 -6.93889390e-18]
  [-1.29279560e+01  0.00000000e+00  0.00000000e+00]
  [-3.13032441e-02 -9.75781955e-19  0.00000000e+00]
  [ 1.96636174e-01 -2.16840434e-19  0.00000000e+00]
  [-3.13032441e-02  0.00000000e+00 -7.58941521e-19]
  [ 1.96636174e-01  0.00000000e+00 -2.16840434e-19]]

 [[ 2.16840434e-19 -6.53117090e-01 -3.08847845e-18]
  [ 0.00000000e+00 -4.14234119e-02  1.73286429e-18]
  [ 0.00000000e+00 -7.62354636e-01  5.20417043e-18]
  [ 0.00000000e+00  1.52481636e+00  0.00000000e+00]
  [-1.73472348e-18  2.02868811e-01  0.00000000e+00]
  [ 0.00000000e+00 -1.57908927e-01  0.00000000e+00]
  [ 2.16840434e-19 -4.88497760e-03  2.16840434e-19]
  [ 0.00000000e+00 -1.07996124e-01  3.96075607e-23]]

 [[ 1.95873468e-19 -6.17068189e-18 -6.53117090e-01]
  [ 4.52410124e-19  1.75390776e-18 -4.14234119e-02]
  [ 0.00000000e+00 -1.73472348e-18 -7.62354636e-01]
  [ 0.00000000e+00  4.33680869e-19  1.52481636e+00]
  [-1.08420217e-19  2.16840434e-19 -4.88497760e-03]
  [-1.08420217e-19  0.00000000e+00 -1.07996124e-01]
  [-6.50521303e-19  0.00000000e+00  2.02868811e-01]
  [ 0.00000000e+00 -4.42219020e-19 -1.57908927e-01]]

 [[-2.34182749e-01  0.00000000e+00 -3.47102702e-18]
  [ 3.29895005e-01  0.00000000e+00  1.56226458e-21]
  [-1.29279560e+01  0.00000000e+00  3.46944695e-18]
  [ 1.25015779e+01  0.00000000e+00  2.08166817e-17]
  [ 1.96636174e-01 -4.33680869e-19  0.00000000e+00]
  [-3.13032441e-02 -1.62630326e-18  0.00000000e+00]
  [ 1.96636174e-01  0.00000000e+00 -4.33680869e-19]
  [-3.13032441e-02  0.00000000e+00 -2.15756232e-17]]

 [[ 0.00000000e+00 -4.14234119e-02 -1.74137651e-18]
  [ 0.00000000e+00 -6.53117090e-01  8.66856596e-19]
  [ 0.00000000e+00  1.52481636e+00  4.33680869e-19]
  [ 0.00000000e+00 -7.62354636e-01 -3.46944695e-18]
  [ 0.00000000e+00 -1.57908927e-01  1.08420217e-19]
  [ 8.67361738e-19  2.02868811e-01  0.00000000e+00]
  [-1.08420217e-19 -1.07996124e-01 -4.33680869e-19]
  [-8.67361738e-19 -4.88497760e-03 -8.67355214e-19]]

 [[-1.39734745e-19 -4.95794377e-19 -4.14234119e-02]
  [-4.60157648e-20  4.24854714e-18 -6.53117090e-01]
  [ 0.00000000e+00  2.16840434e-19  1.52481636e+00]
  [ 0.00000000e+00  5.20417043e-18 -7.62354636e-01]
  [-4.33680869e-19 -6.50521303e-19 -1.07996124e-01]
  [ 6.50521303e-19 -8.67361738e-19 -4.88497760e-03]
  [ 1.08420217e-19  5.42101086e-20 -1.57908927e-01]
  [-4.87890978e-19  2.16492609e-19  2.02868811e-01]]

 [[-3.13032441e-02  0.00000000e+00 -1.57899564e-22]
  [ 1.96636174e-01  0.00000000e+00 -7.15088525e-22]
  [-3.13032441e-02  0.00000000e+00 -2.16840434e-19]
  [ 1.96636174e-01  0.00000000e+00  0.00000000e+00]
  [ 2.90228947e+00  4.33680869e-18  7.80625564e-18]
  [-3.26931171e+00  5.42101086e-20  5.42101086e-20]
  [ 3.63270571e-02  2.16840434e-19  0.00000000e+00]
  [ 2.93250854e-05  0.00000000e+00 -3.46944695e-18]]

 [[ 0.00000000e+00 -4.88497760e-03  1.20188620e-18]
  [ 0.00000000e+00 -1.07996124e-01 -4.31797925e-19]
  [ 0.00000000e+00  2.02868811e-01  0.00000000e+00]
  [-5.42101086e-20 -1.57908927e-01  5.42101086e-19]
  [-1.73472348e-18 -1.57196463e-01  1.73472348e-18]
  [ 2.16840434e-19  5.54360680e-01 -2.16840434e-19]
  [ 0.00000000e+00 -2.90072704e-01  4.33680869e-19]
  [ 0.00000000e+00 -3.91702947e-02  4.33654765e-19]]

 [[ 1.16022304e-20  2.00947789e-19  2.02868811e-01]
  [ 3.64124090e-20 -6.07322855e-19 -1.57908927e-01]
  [ 0.00000000e+00 -6.50521303e-19 -4.88497760e-03]
  [ 0.00000000e+00  0.00000000e+00 -1.07996124e-01]
  [ 3.46944695e-18  5.20417043e-18 -1.57196463e-01]
  [-1.08420217e-19  0.00000000e+00  5.54360680e-01]
  [ 0.00000000e+00  1.51788304e-18 -2.90072704e-01]
  [-8.67361738e-19  2.14975141e-21 -3.91702947e-02]]

 [[ 1.96636174e-01  0.00000000e+00  5.73062165e-19]
  [-3.13032441e-02  0.00000000e+00  3.03293437e-22]
  [ 1.96636174e-01  5.69206141e-19  0.00000000e+00]
  [-3.13032441e-02  0.00000000e+00  0.00000000e+00]
  [-3.26931171e+00  5.42101086e-20  5.42101086e-20]
  [ 2.90228947e+00 -5.20417043e-18 -1.73472348e-18]
  [ 2.93250854e-05  0.00000000e+00  0.00000000e+00]
  [ 3.63270571e-02 -1.12698699e-19  1.04141735e-19]]

 [[ 0.00000000e+00 -1.07996124e-01  1.31702355e-20]
  [ 0.00000000e+00 -4.88497760e-03 -3.56646724e-19]
  [ 5.42101086e-20 -1.57908927e-01  7.04731412e-19]
  [ 0.00000000e+00  2.02868811e-01  0.00000000e+00]
  [-1.08420217e-19  5.54360680e-01  0.00000000e+00]
  [-8.67361738e-19 -1.57196463e-01  0.00000000e+00]
  [ 0.00000000e+00 -3.91702947e-02  0.00000000e+00]
  [ 0.00000000e+00 -2.90072704e-01  8.18297472e-24]]

 [[ 2.27490487e-20 -6.23641208e-19 -1.57908927e-01]
  [-2.48595823e-20 -2.43806771e-19  2.02868811e-01]
  [ 0.00000000e+00  8.67361738e-19 -1.07996124e-01]
  [ 0.00000000e+00 -4.33680869e-19 -4.88497760e-03]
  [ 6.50521303e-19  0.00000000e+00  5.54360680e-01]
  [-8.67361738e-19  0.00000000e+00 -1.57196463e-01]
  [ 0.00000000e+00  0.00000000e+00 -3.91702947e-02]
  [ 0.00000000e+00 -1.89293062e-22 -2.90072704e-01]]

 [[-3.13032441e-02  0.00000000e+00 -2.05697250e-19]
  [ 1.96636174e-01  0.00000000e+00 -6.60715611e-22]
  [-3.13032441e-02  0.00000000e+00  0.00000000e+00]
  [ 1.96636174e-01  0.00000000e+00  0.00000000e+00]
  [ 3.63270571e-02 -2.16840434e-19 -2.16840434e-19]
  [ 2.93250854e-05  0.00000000e+00  0.00000000e+00]
  [ 2.90228947e+00 -4.33680869e-18  3.49551876e-18]
  [-3.26931171e+00 -8.13151629e-20 -1.62630326e-19]]

 [[ 0.00000000e+00  2.02868811e-01  1.62575567e-20]
  [ 0.00000000e+00 -1.57908927e-01 -2.15947495e-19]
  [ 0.00000000e+00 -4.88497760e-03  1.30104261e-18]
  [ 0.00000000e+00 -1.07996124e-01  2.16840434e-19]
  [ 0.00000000e+00 -2.90072704e-01 -2.90566182e-17]
  [-8.67361738e-19 -3.91702947e-02 -1.30104261e-18]
  [ 2.60208521e-18 -1.57196463e-01  2.42725342e-17]
  [-1.08420217e-19  5.54360680e-01 -1.41928563e-24]]

 [[ 2.46044089e-19 -1.34166999e-18 -4.88497760e-03]
  [ 1.16226033e-20  6.58813000e-19 -1.07996124e-01]
  [ 0.00000000e+00  0.00000000e+00  2.02868811e-01]
  [-5.42101086e-20 -5.42101086e-19 -1.57908927e-01]
  [ 0.00000000e+00  6.50521303e-19 -2.90072704e-01]
  [ 8.67361738e-19  0.00000000e+00 -3.91702947e-02]
  [ 2.60208521e-18  1.73472348e-18 -1.57196463e-01]
  [-2.16840434e-19  2.17594154e-19  5.54360680e-01]]

 [[ 1.96636174e-01 -1.91239976e-19  2.16618827e-19]
  [-3.13032441e-02  0.00000000e+00 -1.25164055e-20]
  [ 1.96636174e-01  2.16840434e-19 -1.89735380e-19]
  [-3.13032441e-02  0.00000000e+00  0.00000000e+00]
  [ 2.93250854e-05  0.00000000e+00  0.00000000e+00]
  [ 3.63270571e-02 -1.84346008e-19 -1.84346008e-19]
  [-3.26931171e+00  5.42101086e-20  2.71050543e-20]
  [ 2.90228947e+00  4.34945496e-18 -5.19152416e-18]]

 [[ 5.42101086e-20 -1.57908927e-01  3.89092480e-21]
  [ 0.00000000e+00  2.02868811e-01 -4.22078472e-21]
  [ 0.00000000e+00 -1.07996124e-01 -1.30104261e-18]
  [-8.67361738e-19 -4.88497760e-03 -2.16840434e-19]
  [ 0.00000000e+00 -3.91702947e-02  0.00000000e+00]
  [ 0.00000000e+00 -2.90072704e-01  0.00000000e+00]
  [ 3.25260652e-19  5.54360680e-01  0.00000000e+00]
  [ 2.60208521e-18 -1.57196463e-01 -1.61325930e-21]]

 [[ 4.36214454e-21  1.74330721e-18 -1.07996124e-01]
  [-9.78899748e-19  1.36754347e-19 -4.88497760e-03]
  [ 5.42101086e-20  0.00000000e+00 -1.57908927e-01]
  [ 0.00000000e+00 -4.33680869e-19  2.02868811e-01]
  [ 0.00000000e+00  0.00000000e+00 -3.91702947e-02]
  [ 0.00000000e+00 -1.38777878e-17 -2.90072704e-01]
  [ 1.08420217e-19 -1.08420217e-19  5.54360680e-01]
  [ 2.60208521e-18  9.45355148e-22 -1.57196463e-01]]]

Setting keyword arguments

All janus commands accept keyword arguments (kwargs), which are input in the form of Python dictionaries: {"key": value}.

One useful example is passing options that are specific to an MLIP calculator.

For example, MACE has an option to run with D3 dispersion correction, through the dispersion option. In the command-line, this can be set using:

[30]:
! janus singlepoint --config singlepoint_config_1.yml --calc-kwargs "{'dispersion': True}" --out janus_results/NaCl-dispersion-results.extxyz
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head Default out of ['Default']
Using TorchDFTD3Calculator for D3 dispersion corrections

To avoid the complications of nested quotations, setting this in the configuration file is preferable:

[31]:
%%writefile singlepoint_config_4.yml

arch: mace_mp
struct: ../data/NaCl.xyz
tracker: False
calc_kwargs:
  dispersion: True
out: janus_results/NaCl-dispersion-results.extxyz
Writing singlepoint_config_4.yml
[32]:
! janus singlepoint --config singlepoint_config_4.yml
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/20231210mace128L0_energy_epoch249model
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head Default out of ['Default']
Using TorchDFTD3Calculator for D3 dispersion corrections

Comparing the results before and after the correction:

[33]:
dispersion_results = read("janus_results/NaCl-dispersion-results.extxyz")

print(f"Original results: {results.info['mace_mp_energy']}")
print(f"Results with dispersion correction: {dispersion_results.info['mace_mp_energy']}")
Original results: -27.0300815358917
Results with dispersion correction: -28.749976781125884