Skip to content

manage_mlff_md.py

Julien Steffen edited this page May 22, 2024 · 1 revision

This scripts manages a molecular dynamics trajectory of a surface slab system simulated with a VASP ML-FF, which is potentially unstable.

During the MD, it checks whether single atoms unphysically desorb into the gas phase (a typical error in VASP ML_FFs for complicated surface slabs like liquid metals) and resets the calculation to the last time where the system was still fully intact.

The calculation is assumed to be ran on a calculation cluster with a slurm batch management system, such that the calculations are started or restarted via the sbatch slurm_script command.

Before invoking the script, set up the input for a VASP ML_FF sampling calculation (see on the ML-FF wiki page how to do this). It is important that the slab is located rather in the middle of the unit cell (along z-direction) and does not cross the z=0 plane!

Then, start the script in the main folder of the calculation. The calculation cluster might limit the runtime of python scripts on its headnodes. In this case, start the manage_mlff_md.py script via a slurm_script (a master process). In this case, the script must be restarted every 24 hours. Some command line arguments can/need to be given as well:

  • -tolerance=[value] How long an atom can depart from the slab surface, measured as the position of the atoms at the upper/lower edges of the slab, in Angstrom. Smaller values will result in a higher frequency of restarts during the calculation, too large values, however, might correct the dynamics too late, when everything is already exploded beyond the point of return. Values between 2 and 3 Angstrom should work well.
  • -buffer=[value] If a calculation is reset, it is not useful to search for the last structure where the highest atom is just beyond the tolerance limit, since then it can directly move outside the tolerance again in one time step. The `-buffer´ keyword gives an additional buffer distance that all atoms need to be away from the maximum tolerance in a structure acceptable for a restart. If, e.g., the tolerance is set to 2 Angstroms, and the buffer to 0.3 Angstroms, only structures with atoms not farther away then 1.7 Angstroms from the highest/lowest initial positions in the slab will be accepted as restart points. If the value is too small, restarts will happen more frequent, if its too large, the resets will be really large (many time steps repudiated) and potentially won't work at all. Values between 0.2 and 0.5 Angstrom should mostly work.
  • -check_range=[number1],[number2] If only a part of the system shall be checked for stability. This can be the case if a slab is simulated together with a gas phase. The dynamics should then only be resetted if slab atoms move into the gas phase, and not in the case of gas atoms. Then, a range of atom indixes (related to the positions in the POSCAR file) can be given that shall be checked (usually the atoms in the slab). Example: -check_range=1,60: Atoms 1 to 60 will be checked, but not 61 and higher (if they exist)

During the calculation, XDATCAR files of already simulated parts of the trajectory (until a problem occurs) are combined to a file XDATCAR_all, located in the main folder as well. After the whole trajectory has been simulated guided by manage_mlff_md.py, it is a continuous trajectory without visible reset points, since parts leading to atoms leaving the surface are "forgotten". Only discontinuities in the momenta can be observed, since the initial momenta will be sampled again by chance during a reset (else, the same error would occur again after the same time). This has no effect when a stochastic thermostat like the Andersen thermostat is used, but leads to a small degree of stochastic modification for deterministic thermostats like the Nose-Hoover (see also the AIMD section).