ASE calculators¶
Calorine provides two ASE calculators for NEP calculations, one that uses the GPU implementation and one that uses the CPU implementation of NEP. The former is better tested but is likely to be slow if many calculations are to performed, since it relies on reading and writing files.
GPU calculator¶
- class calorine.gpunep_calculator.GPUNEP(potential_filename, maximum_neighbors=None, directory=None, cutoff=None, label='GPUNEP', atoms=None, command='gpumd < PREFIX.txt', prefix='to_run')[source]¶
This class provides an ASE calculator for NEP calculations with GPUMD.
This calculator writes files that are input to the
gpumd
executable. It is thus likely to be slow if many calculations are to be performed.- Parameters
potential_filename (str) – Path to nep.txt potential
directory (str) – Directory to run GPUMD in. If None, a temporary directory will be created and removed once the calculations are finished. If specified, the directory will not be deleted. In the latter case, it is advisable to do no more than one calculation with this calculator (unless you know exactly what you are doing).
maximum_neighbors (int) – Maximum number of neighbors any atom can ever have. If None, the code will try to come up with a reasonable estimate. 1024 is always safe.
cutoff (float) – Initial cutoff distance used for building the neighbor list. Defaults to force cutoff + 1 Angstrom
label (str) – Label for this calculator
atoms (Atoms) – atoms to attach this calculator to
command (str) – Command to run GPUMD with. Default:
gpumd < PREFIX.txt
prefix (
str
) – Filename (excluding file ending) for run script. Default:to_run
Example
>>> calc = GPUNEP('nep.txt') >>> atoms.calc = calc >>> atoms.get_potential_energy()
- run_custom_md(parameters, return_last_atoms=False, only_prepare=False)[source]¶
Run a custom MD simulation.
- Parameters
parameters (List[Tuple[str, float]]) –
Parameters to be specified in the run.in file. The potential keyword is set automatically, all other keywords need to be set via this argument. Example:
[('dump_thermo', 1000), ('dump_position', 1000), ('velocity', 300), ('time_step', 1), ('ensemble', ['nvt_ber', 300, 300, 100]), ('neighbor', 1), ('run', 100000)]
return_last_atoms (Atoms) – If True, the last saved snapshot will be returned. Default: False
only_prepare (bool) – If True, the necessary input files will be written but the MD run will not be executed. Default: False
- Return type
The last snapshot (if return_last_atoms = True)
CPU calculator¶
- class calorine.nepy.cpunep_calculator.CPUNEP(potential_filename, atoms=None, label=None, debug=False)[source]¶
This class provides an ASE calculator for
nep_cpu
, the in-memory CPU implementation of GPUMD.- Parameters
potential_filename (str) – Path to nep.txt potential
atoms (Atoms) – Atoms to attach the calculator to
label (str) – Label for this calculator
debug (bool, optional) – Flag to toggle debug mode. Prints GPUMD output. Defaults to False.
- Raises
FileNotFoundError – Raises FileNotFoundError if
potential_filename
does not point to a valid file.ValueError – Raises ValueError atoms are not defined when trying to get energies and forces.
Example
>>> calc = CPUNEP('nep.txt') >>> atoms.calc = calc >>> atoms.get_potential_energy()