State sampling methods

The State classes are object managing the state being simulated by the MLMD simulations, and hence, the state being approximated by MLACS using Machine Learning potential. All the State classes are structured the same way with run_dynamics and initialize_momenta functions.

StateManager

class mlacs.state.StateManager(nsteps=1000, nsteps_eq=100, logfile=None, trajfile=None, loginterval=50, folder='MolecularDynamics', **kwargs)

Parent Class managing the state being simulated

initialize_momenta(atoms)

Setup the momenta during initialization of the simulation

abstract run_dynamics(supercell, pair_style, pair_coeff, model_post, atom_style='atomic', eq=False, elements=None)

Run the dynamics for the state, during nsteps then return the last atoms of the simulation

Thermodynamic states

These States are used to sample via MLMD simulation specific thermodyamic states/ensembles (NVT, NPT, …).

LangevinState

class mlacs.state.LangevinState(temperature, friction=0.01, dt=1.5, nsteps=1000, nsteps_eq=100, fixcm=True, logfile=None, trajfile=None, loginterval=50, rng=None, init_momenta=None, **kwargs)

State Class for running a Langevin simulation as implemented in ASE

Parameters:
  • temperature (float) – Temperature of the simulation, in Kelvin

  • friction (float (optional)) – Friction coefficient of the thermostat. Default 0.01.

  • dt (float (optional)) – Timestep, in fs. Default 1.5 fs.

  • nsteps (int (optional)) – Number of MLMD steps for production runs. Default 1000 steps.

  • nsteps_eq (int (optional)) – Number of MLMD steps for equilibration runs. Default 100 steps.

  • fixcm (Bool (optional)) – Fix position and momentum center of mass. Default True.

  • logfile (str (optional)) – Name of the file for logging the MLMD trajectory. If None, no log file is created. Default None.

  • trajfile (str (optional)) – Name of the file for saving the MLMD trajectory. If None, no traj file is created. Default None.

  • loginterval (int (optional)) – Number of steps between MLMD logging. Default 50.

  • rng (RNG object (optional)) – Rng object to be used with the Langevin thermostat. Default correspond to numpy.random.default_rng().

  • init_momenta (numpy.ndarray (optional)) – If None, velocities are initialized with a Maxwell Boltzmann distribution N * 3 velocities for the initial configuration

LammpsState

class mlacs.state.LammpsState(temperature, pressure=None, t_stop=None, p_stop=None, damp=None, langevin=True, gjf='vhalf', qtb=False, fd=200, n_f=100, pdamp=None, ptype='iso', twodimensional=False, dt=1.5, fixcm=True, rng=None, init_momenta=None, nsteps=1000, nsteps_eq=100, eq_mass_md=False, logfile=None, trajfile=None, loginterval=50, blocks=None, folder='Trajectory', **kwargs)

Class to perform NVT or NPT simulations with LAMMPS.

Parameters:
  • temperature (float) – Temperature of the simulation, in Kelvin.

  • pressure (float or None (optional)) – Pressure of the simulation, in GPa. If None, no barostat is applied and the simulation is in the NVT ensemble. Default None

  • t_stop (float or None (optional)) – When this input is not None, the temperature of the molecular dynamics simulations is randomly chosen in a range between temperature and t_stop. Default None

  • p_stop (float or None (optional)) – When this input is not None, the pressure of the molecular dynamics simulations is randomly chosen in a range between pressure and p_stop. Naturally, the pressure input has to be set. Default None

  • damp (float or None (optional)) – The damping value for the thermostat. The default gives a sensible value of a hundred times the timestep.

  • langevin (Bool (optional)) – If True, a Langevin thermostat is used for the thermostat. Default True

  • gjf (no or vfull or vhalf (optional)) – Whether to use the Gronbech-Jensen/Farago integrator for the Langevin dynamics. Only apply if langevin is True. Default vhalf.

  • qtb (:clas::Bool (optional)) – Whether to use a quantum thermal bath to approximate quantum effects. If True, it override the langevin and gjf inputs. Default False

  • fd (float (optional)) – The frequency cutoff for the qtb thermostat. Should be around 2~3 times the Debye frequency. In THz. Default 200 THz.

  • n_f (int (optional)) – Frequency grid size for the qtb thermostat. Default 100.

  • pdamp (float or None (optional)) – Damping parameter for the barostat. If None, apply a damping parameter of 1000 times the timestep of the simulation. Default None

  • ptype (iso or aniso (optional)) – Handle the type of pressure applied. Default iso

  • twodimensional (bool (optional)) – If set to True and pressure is not None, set the pressure only on the x and y axis. Pressure along x and y axis can still be coupled by setting ptype to iso. default False

  • dt (float (optional)) – Timestep, in fs. Default 1.5 fs.

  • fixcm (Bool (optional)) – Fix position and momentum center of mass. Default True.

  • rng (RNG object (optional)) – Rng object to be used with the Langevin thermostat. Default correspond to numpy.random.default_rng()

  • init_momenta (numpy.ndarray (optional)) – Gives the (Nat, 3) shaped momenta array that will be used to initialize momenta when using the initialize_momenta function. If the default None is set, momenta are initialized with a Maxwell Boltzmann distribution.

  • nsteps (int (optional)) – Number of MLMD steps for production runs. Default 1000 steps.

  • nsteps_eq (int (optional)) – Number of MLMD steps for equilibration runs. Default 100 steps.

  • eq_mass_md (Bool (optional)) – If all atoms have the same mass for the MD. Default False If True, make sure your MLIP is also correctly parametrized

  • logfile (str (optional)) – Name of the file for logging the MLMD trajectory. If None, no log file is created. Default None.

  • trajfile (str (optional)) – Name of the file for saving the MLMD trajectory. If None, no traj file is created. Default None.

  • loginterval (int (optional)) – Number of steps between MLMD logging. Default 50.

  • blocks (LammpsBlockInput or list (optional)) – Custom block input class. Can be a list of blocks. If None, nothing is added in the input. Default None.

Examples

>>> from mlacs.state import LammpsState
>>>
>>> state = LammpsState(temperature=300, pressure=None) #NVT
>>> state = LammpsState(temperature=300, pressure=0)    #NPT
>>> state.run_dynamics(atoms, mlip.pair_style, mlip.pair_coeff)

PafiLammpsState

class mlacs.state.PafiLammpsState(temperature, mep=None, maxjump=0.4, dt=1.5, damp=None, prt=False, langevin=True, nsteps=1000, nsteps_eq=100, logfile=None, trajfile=None, loginterval=50, blocks=None, **kwargs)

Class to manage constrained MD along a reaction path using the fix Pafi with LAMMPS.

Parameters:
  • temperature (float) – Temperature of the simulation, in Kelvin.

  • mep (NebLammpsState) – Object contain all informations on the MEP (Minimum Energy Path).

  • maxjump (float) – Maximum atomic jump authorized for the free energy calculations. Configurations with an high maxjump will be removed. Default 0.4

  • dt (float (optional)) – Timestep, in fs. Default 1.5 fs.

  • damp (float or None) –

  • nsteps (int (optional)) – Number of MLMD steps for production runs. Default 1000 steps.

  • nsteps_eq (int (optional)) – Number of MLMD steps for equilibration runs. Default 100 steps.

  • langevin (Bool) – If True, a Langevin thermostat is used. Else, a Brownian dynamic is used. Default True

  • fixcm (Bool (optional)) – Fix position and momentum center of mass. Default True.

  • logfile (str (optional)) – Name of the file for logging the MLMD trajectory. If None, no log file is created. Default None.

  • trajfile (str (optional)) – Name of the file for saving the MLMD trajectory. If None, no traj file is created. Default None.

  • loginterval (int (optional)) – Number of steps between MLMD logging. Default 50.

  • rng (RNG object (optional)) – Rng object to be used with the Langevin thermostat. Default correspond to numpy.random.default_rng()

  • prt (Bool (optional)) – Printing options. Default True

Examples

>>> from ase.io import read
>>> initial = read('A.traj')
>>> final = read('B.traj')
>>>
>>> from mlacs.state import PafiLammpsState, NebLammpsState
>>> neb = NebLammpsState([initial, final])
>>> state = PafiLammpsState(temperature=300, mep=neb)
>>> state.run_dynamics(atoms, mlip.pair_style, mlip.pair_coeff)

SpinLammpsState

class mlacs.state.SpinLammpsState(temperature, t_stop=None, damp=None, dt=1.5, fixcm=True, nsteps=1000, nsteps_eq=100, logfile=None, trajfile=None, loginterval=50, blocks=None, **kwargs)

Class to manage magnetic spin simulations with LAMMPS and the SPIN package.

Tranchida, et al., Journal of Computational Physics, 372, 406-425, (2018).

Parameters:
  • temperature (float) – Temperature of the simulation, in Kelvin.

  • t_stop (float or None (optional)) – When this input is not None, the temperature of the molecular dynamics simulations is randomly chosen in a range between temperature and t_stop. Default None

  • damp (float or None (optional)) –

  • dt (float (optional)) – Timestep, in fs. Default 1.5 fs.

  • nsteps (int (optional)) – Number of MLMD steps for production runs. Default 1000 steps.

  • nsteps_eq (int (optional)) – Number of MLMD steps for equilibration runs. Default 100 steps.

  • fixcm (Bool (optional)) – Fix position and momentum center of mass. Default True.

  • logfile (str (optional)) – Name of the file for logging the MLMD trajectory. If None, no log file is created. Default None.

  • trajfile (str (optional)) – Name of the file for saving the MLMD trajectory. If None, no traj file is created. Default None.

  • loginterval (int (optional)) – Number of steps between MLMD logging. Default 50.

  • rng (RNG object (optional)) – Rng object to be used with the Langevin thermostat. Default correspond to numpy.random.default_rng()

  • init_momenta (numpy.ndarray (optional)) – Gives the (Nat, 3) shaped momenta array that will be used to initialize momenta when using the initialize_momenta function. If the default None is set, momenta are initialized with a Maxwell Boltzmann distribution.

Ground states

These States are used to determine/relax atomic positions at 0K.

OptimizeLammpsState

class mlacs.state.OptimizeLammpsState(min_style='cg', etol=0.0, ftol=1e-06, dt=0.5, pressure=None, ptype='iso', vmax=0.001, nsteps=1000, nsteps_eq=100, logfile=None, trajfile=None, loginterval=50, blocks=None, **kwargs)

Class to manage geometry optimizations with LAMMPS.

Parameters:
  • min_style (str) –

    Choose a minimization algorithm to use when a minimize command is performed. The options are the one available with the min_style command of LAMMPS.

    • cg

    • hftn

    • sd

    • quickmin

    • fire

    Default cg.

  • etol (float) – Stopping tolerance for energy Default 0.0

  • ftol (float) – Stopping tolerance for forces Default 1.0e-6

  • dt (float (optional)) – Timestep, in fs. Default 0.5 fs.

  • pressure (float or None (optional)) – Target pressure for the optimization, in GPa. Only available if min_style is ‘cg’. If None, no cell relaxation is applied. Default None

  • ptype (iso or aniso (optional)) – Only available if min_style is ‘cg’. Handle the type of pressure applied. Default iso

  • vmax (iso or aniso (optional)) – The vmax keyword can be used to limit the fractional change in the volume of the simulation box that can occur in one iteration of the minimizer. Default 1.0e-3

  • nsteps (int (optional)) – Maximum number of minimizer iterations during production phase. Also sets up the max number of force/energy evaluations. Default 10000 steps.

  • nsteps_eq (int (optional)) – Maximum number of minimizer iterations during equilibration phase. Also sets up the max number of force/energy evaluations. Default 1000 steps.

  • logfile (str (optional)) – Name of the file for logging the MLMD trajectory. If None, no log file is created. Default None.

  • trajfile (str (optional)) – Name of the file for saving the MLMD trajectory. If None, no traj file is created. Default None.

  • loginterval (int (optional)) – Number of steps between MLMD logging. Default 50.

  • blocks (LammpsBlockInput or list (optional)) – Custom block input class. Can be a list of blocks. If None, nothing is added in the input. Default None.

Examples

>>> from ase.io import read
>>> initial = read('A.traj')
>>>
>>> from mlacs.state import OptimizeLammpsState
>>> neb = OptimizeLammpsState(initial, pressure=0, ptype='iso')
>>> state.run_dynamics(initial, mlip.pair_style, mlip.pair_coeff)

OptimizeAseState

class mlacs.state.OptimizeAseState(optimizer=None, opt_parameters={}, constraints=None, cstr_parameters={}, filters=None, fltr_parameters={}, fmax=1e-05, nsteps=1000, nsteps_eq=100, **kwargs)

Class to manage Structure optimization with ASE Optimizers.

Parameters:
  • optimizer (ase.optimize) – Optimizer from ase.optimize. Default BFGS

  • opt_parameters (dict) – Dictionnary with the parameters for the Optimizer. Default: {}

  • constraints (ase.constraints or list) – Constraints to apply to the system during the minimization or list of constraints. By default there is no constraints.

  • cstr_parameters (dict or list) – Dictionnary with the parameter for the constraints or list of constraints parameters. Default: {}

  • filters (ase.filters) – Filters are constraints to apply on the cell during the minimization. By default there is no filters.

  • fltr_parameters (dict) – Dictionnary with the parameter for the constraints. Default: {}

  • fmax (float) – The maximum value for the forces to be considered converged. Default: 1e-5

Examples

>>> from ase.io import read
>>> initial = read('A.traj')
>>>
>>> from mlacs.state import OptimizeAseState
>>> opt = OptimizeAseState()
>>> opt.run_dynamics(initial, mlip.pair_style, mlip.pair_coeff)

To perform volume optimization, import the UnitCellFilter filter

>>> from ase.filters import UnitCellFilter
>>> opt = OptimizeAseState(filters=UnitCellFilter,
                           fltr_parameters=dict(cell_factor=10))
>>> opt.run_dynamics(initial, mlip.pair_style, mlip.pair_coeff)

Minimum Energy Path

These States are used to sample Minimum energy path.

BaseMepState

Main class for ASE method.

class mlacs.state.mep_ase_state.BaseMepState(images, xi=None, nimages=4, mode=None, model=None, interpolate='linear', parameters={}, print=True, **kwargs)

Class to manage Minimum Energy Path sampling with ASE Optimizers.

Parameters:
  • images (list or PathAtoms) – mlacs.PathAtoms or list of ase.Atoms object. The list contain initial and final configurations of the reaction path.

  • xi (numpy.array or float) – Value of the reaction coordinate for the constrained MD. Default None

  • nimages (int (optional)) – Number of images used along the reaction coordinate. Default 1. which is suposed the saddle point.

  • mode (float or string) – Value of the reaction coordinate or sampling mode: - float sampling at a precise coordinate. - rdm_true randomly return the coordinate of an images. - rdm_spl randomly return the coordinate of a splined images. - rdm_memory homogeneously sample the splined reaction coordinate. - None return the saddle point. Default saddle

  • model (LinearPotential or DeltaLearningPotential) – mlacs.mlip linear object. Default None

  • optimizer (ase.optimize) – Optimizer from ase.optimize. Default BFGS

  • ftol (float) – Stopping tolerance for energy Default 5.0e-2

  • interpolate (str) – Method for position interpolation, linear or idpp (Image dependent pair potential). Default linear

  • parameters (dict (optional)) – Parameters for ase.neb.NEB class.

LinearInterpolation

class mlacs.state.LinearInterpolation(images, xi=None, nimages=4, mode=None, model=None, interpolate='linear', parameters={}, print=False, **kwargs)

Class to do a simple Linear interpolation of positions with ASE. Can be used with the Image dependent pair potential method.

NebAseState

class mlacs.state.NebAseState(images, xi=None, nimages=4, mode=None, model=None, interpolate='linear', Kspring=0.1, optimizer=None, ftol=0.05, parameters={}, print=False, **kwargs)

Class to run the Nudged Elastic Band method with ASE Optimizers.

CiNebAseState

class mlacs.state.CiNebAseState(images, xi=None, nimages=3, mode=None, model=None, interpolate='linear', Kspring=0.1, optimizer=None, ftol=0.05, parameters={}, print=False, **kwargs)

Class to run the Climbing Image Nudged Elastic Band method with ASE Optimizers.

StringMethodAseState

class mlacs.state.StringMethodAseState(images, xi=None, nimages=4, mode=None, model=None, interpolate='linear', Kspring=0.1, optimizer=None, ftol=0.05, parameters={}, print=False, **kwargs)

Class to run the String Method with ASE Optimizers.

NebLammpsState

class mlacs.state.NebLammpsState(images, xi=None, min_style='quickmin', Kspring=1.0, etol=0.0, ftol=0.001, dt=1.5, nimages=4, nprocs=None, mode=None, interval=None, linear=False, print=False, nsteps=1000, nsteps_eq=100, logfile=None, trajfile=None, loginterval=50, blocks=None, **kwargs)

Class to manage Nudged Elastic Band (NEB) calculation with LAMMPS. This class is a part of TransPath objects, meaning that it produces positions interpolation according to a reaction coordinate.

Parameters:
  • images (list or PathAtoms) – mlacs.PathAtoms or list of ase.Atoms object. The list contain initial and final configurations of the reaction path.

  • xi (numpy.array or float) – Value of the reaction coordinate for the constrained MD. Default None

  • min_style (str) – Choose a minimization algorithm to use when a minimize command is performed. Default quickmin.

  • Kspring (float) – Spring constante for the NEB calculation. Default 1.0

  • etol (float) – Stopping tolerance for energy Default 0.0

  • ftol (float) – Stopping tolerance for energy Default 1.0e-3

  • dt (float (optional)) – Timestep, in fs. Default 1.5 fs.

  • nimages (int (optional)) – Number of images used along the reaction coordinate. Default 1. which is suposed the saddle point.

  • nprocs (int (optional)) – Total number of process used to run LAMMPS. Have to be a multiple of the number of images. If nprocs > than nimages, each image will be parallelized using the partition scheme of LAMMPS. Per default it assumes that nprocs = nimages

  • mode (float or string) – Value of the reaction coordinate or sampling mode: - float sampling at a precise coordinate. - rdm_true randomly return the coordinate of an images. - rdm_spl randomly return the coordinate of a splined images. - rdm_memory homogeneously sample the splined reaction coordinate. - None return the saddle point. Default saddle

  • linear (Bool (optional)) – If true, the reaction coordinate is a linear interpolation. Default False

  • logfile (str (optional)) – Name of the file for logging the MLMD trajectory. If None, no log file is created. Default None.

  • trajfile (str (optional)) – Name of the file for saving the MLMD trajectory. If None, no traj file is created. Default None.

  • loginterval (int (optional)) – Number of steps between MLMD logging. Default 50.

  • prt (Bool (optional)) – Printing options. Default True

Examples

>>> from ase.io import read
>>> initial = read('A.traj')
>>> final = read('B.traj')
>>>
>>> from mlacs.state import NebLammpsState
>>> neb = NebLammpsState([initial, final])
>>> state.run_dynamics(None, mlip.pair_style, mlip.pair_coeff)