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 Kelvinfriction (
float(optional)) – Friction coefficient of the thermostat. Default 0.01.dt (
float(optional)) – Timestep, in fs. Default1.5fs.nsteps (
int(optional)) – Number of MLMD steps for production runs. Default1000steps.nsteps_eq (
int(optional)) – Number of MLMD steps for equilibration runs. Default100steps.fixcm (
Bool(optional)) – Fix position and momentum center of mass. Default True.logfile (
str(optional)) – Name of the file for logging the MLMD trajectory. IfNone, no log file is created. DefaultNone.trajfile (
str(optional)) – Name of the file for saving the MLMD trajectory. IfNone, no traj file is created. DefaultNone.loginterval (
int(optional)) – Number of steps between MLMD logging. Default50.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)) – IfNone, 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 (
floatorNone(optional)) – Pressure of the simulation, in GPa. IfNone, no barostat is applied and the simulation is in the NVT ensemble. DefaultNonet_stop (
floatorNone(optional)) – When this input is notNone, the temperature of the molecular dynamics simulations is randomly chosen in a range between temperature and t_stop. DefaultNonep_stop (
floatorNone(optional)) – When this input is notNone, 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. DefaultNonedamp (
floatorNone(optional)) – The damping value for the thermostat. The default gives a sensible value of a hundred times the timestep.langevin (
Bool(optional)) – IfTrue, a Langevin thermostat is used for the thermostat. DefaultTruegjf (
noorvfullorvhalf(optional)) – Whether to use the Gronbech-Jensen/Farago integrator for the Langevin dynamics. Only apply if langevin isTrue. Defaultvhalf.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 (
floatorNone(optional)) – Damping parameter for the barostat. IfNone, apply a damping parameter of 1000 times the timestep of the simulation. DefaultNoneptype (
isooraniso(optional)) – Handle the type of pressure applied. Defaultisotwodimensional (
bool(optional)) – If set toTrueand pressure is notNone, set the pressure only on the x and y axis. Pressure along x and y axis can still be coupled by settingptypeto iso. defaultFalsedt (
float(optional)) – Timestep, in fs. Default1.5fs.fixcm (
Bool(optional)) – Fix position and momentum center of mass. DefaultTrue.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 defaultNoneis set, momenta are initialized with a Maxwell Boltzmann distribution.nsteps (
int(optional)) – Number of MLMD steps for production runs. Default1000steps.nsteps_eq (
int(optional)) – Number of MLMD steps for equilibration runs. Default100steps.eq_mass_md (
Bool(optional)) – If all atoms have the same mass for the MD. DefaultFalseIf True, make sure your MLIP is also correctly parametrizedlogfile (
str(optional)) – Name of the file for logging the MLMD trajectory. IfNone, no log file is created. DefaultNone.trajfile (
str(optional)) – Name of the file for saving the MLMD trajectory. IfNone, no traj file is created. DefaultNone.loginterval (
int(optional)) – Number of steps between MLMD logging. Default50.blocks (
LammpsBlockInputorlist(optional)) – Custom block input class. Can be a list of blocks. IfNone, nothing is added in the input. DefaultNone.
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. Default0.4dt (
float(optional)) – Timestep, in fs. Default1.5fs.damp (
floatorNone) –nsteps (
int(optional)) – Number of MLMD steps for production runs. Default1000steps.nsteps_eq (
int(optional)) – Number of MLMD steps for equilibration runs. Default100steps.langevin (
Bool) – IfTrue, a Langevin thermostat is used. Else, a Brownian dynamic is used. DefaultTruefixcm (
Bool(optional)) – Fix position and momentum center of mass. DefaultTrue.logfile (
str(optional)) – Name of the file for logging the MLMD trajectory. IfNone, no log file is created. DefaultNone.trajfile (
str(optional)) – Name of the file for saving the MLMD trajectory. IfNone, no traj file is created. DefaultNone.loginterval (
int(optional)) – Number of steps between MLMD logging. Default50.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. DefaultTrue
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 (
floatorNone(optional)) – When this input is notNone, the temperature of the molecular dynamics simulations is randomly chosen in a range between temperature and t_stop. DefaultNonedamp (
floatorNone(optional)) –dt (
float(optional)) – Timestep, in fs. Default1.5fs.nsteps (
int(optional)) – Number of MLMD steps for production runs. Default1000steps.nsteps_eq (
int(optional)) – Number of MLMD steps for equilibration runs. Default100steps.fixcm (
Bool(optional)) – Fix position and momentum center of mass. DefaultTrue.logfile (
str(optional)) – Name of the file for logging the MLMD trajectory. IfNone, no log file is created. DefaultNone.trajfile (
str(optional)) – Name of the file for saving the MLMD trajectory. IfNone, no traj file is created. DefaultNone.loginterval (
int(optional)) – Number of steps between MLMD logging. Default50.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 defaultNoneis 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_stylecommand of LAMMPS.cg
hftn
sd
quickmin
fire
Default cg.
etol (
float) – Stopping tolerance for energy Default0.0ftol (
float) – Stopping tolerance for forces Default1.0e-6dt (
float(optional)) – Timestep, in fs. Default0.5fs.pressure (
floatorNone(optional)) – Target pressure for the optimization, in GPa. Only available if min_style is ‘cg’. IfNone, no cell relaxation is applied. DefaultNoneptype (
isooraniso(optional)) – Only available if min_style is ‘cg’. Handle the type of pressure applied. Defaultisovmax (
isooraniso(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. Default1.0e-3nsteps (
int(optional)) – Maximum number of minimizer iterations during production phase. Also sets up the max number of force/energy evaluations. Default10000steps.nsteps_eq (
int(optional)) – Maximum number of minimizer iterations during equilibration phase. Also sets up the max number of force/energy evaluations. Default1000steps.logfile (
str(optional)) – Name of the file for logging the MLMD trajectory. IfNone, no log file is created. DefaultNone.trajfile (
str(optional)) – Name of the file for saving the MLMD trajectory. IfNone, no traj file is created. DefaultNone.loginterval (
int(optional)) – Number of steps between MLMD logging. Default50.blocks (
LammpsBlockInputorlist(optional)) – Custom block input class. Can be a list of blocks. IfNone, nothing is added in the input. DefaultNone.
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. DefaultBFGSopt_parameters (
dict) – Dictionnary with the parameters for the Optimizer. Default: {}constraints (
ase.constraintsorlist) – Constraints to apply to the system during the minimization or list of constraints. By default there is no constraints.cstr_parameters (
dictorlist) – 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 (
listor PathAtoms) – mlacs.PathAtoms or list of ase.Atoms object. The list contain initial and final configurations of the reaction path.xi (
numpy.arrayor float) – Value of the reaction coordinate for the constrained MD. DefaultNonenimages (
int(optional)) – Number of images used along the reaction coordinate. Default1. which is suposed the saddle point.mode (
floatorstring) – Value of the reaction coordinate or sampling mode: -floatsampling at a precise coordinate. -rdm_truerandomly return the coordinate of an images. -rdm_splrandomly return the coordinate of a splined images. -rdm_memoryhomogeneously sample the splined reaction coordinate. -Nonereturn the saddle point. Defaultsaddlemodel (
LinearPotentialorDeltaLearningPotential) – mlacs.mlip linear object. DefaultNoneoptimizer (
ase.optimize) – Optimizer from ase.optimize. DefaultBFGSftol (
float) – Stopping tolerance for energy Default5.0e-2interpolate (
str) – Method for position interpolation, linear or idpp (Image dependent pair potential). Defaultlinearparameters (
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 (
listor PathAtoms) – mlacs.PathAtoms or list of ase.Atoms object. The list contain initial and final configurations of the reaction path.xi (
numpy.arrayor float) – Value of the reaction coordinate for the constrained MD. DefaultNonemin_style (
str) – Choose a minimization algorithm to use when a minimize command is performed. Default quickmin.Kspring (
float) – Spring constante for the NEB calculation. Default1.0etol (
float) – Stopping tolerance for energy Default0.0ftol (
float) – Stopping tolerance for energy Default1.0e-3dt (
float(optional)) – Timestep, in fs. Default1.5fs.nimages (
int(optional)) – Number of images used along the reaction coordinate. Default1. 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 = nimagesmode (
floatorstring) – Value of the reaction coordinate or sampling mode: -floatsampling at a precise coordinate. -rdm_truerandomly return the coordinate of an images. -rdm_splrandomly return the coordinate of a splined images. -rdm_memoryhomogeneously sample the splined reaction coordinate. -Nonereturn the saddle point. Defaultsaddlelinear (
Bool(optional)) – If true, the reaction coordinate is a linear interpolation. DefaultFalselogfile (
str(optional)) – Name of the file for logging the MLMD trajectory. IfNone, no log file is created. DefaultNone.trajfile (
str(optional)) – Name of the file for saving the MLMD trajectory. IfNone, no traj file is created. DefaultNone.loginterval (
int(optional)) – Number of steps between MLMD logging. Default50.prt (
Bool(optional)) – Printing options. DefaultTrue
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)