Learn on the Fly embedding scheme

Module containing LOTFDynamics integrator for doing ‘Learn on the Fly’ predictor-corrector dynamics within the ASE molecular dynamics framework.

Module contents for quippy.lotf:

Classes

LOTFDynamics(atoms, timestep, extrapolate_steps) ‘Learn on the Fly’ dynamics with extrapolation and interpolation

Functions

update_hysteretic_qm_region(atoms, …[, …]) Update the QM region in atoms
iter_atom_centered_clusters(at[, mark_name]) Iterate over all atom-centered (little) clusters in at.
class quippy.lotf.LOTFDynamics(atoms, timestep, extrapolate_steps, trajectory=None, logfile=None, loginterval=1, check_force_error=False, qm_update_func=None)[source]

‘Learn on the Fly’ dynamics with extrapolation and interpolation

Subclass of ase.md.md.MolecularDynamics which implements LOTF predictor/corrector dynamics. See the step() method for a description of the algorithm.

The calculator associated with Atoms should be a quippy.potential.Potential object.

Attributes:
extrapolate_steps

Number of small time-steps used when extrapolating or interpolating in the LOTF predictor-corrector loop.

state_label

One-character label for current dynamical state: either “E” or “I” for extrapolation or interpolation, respectively.

Methods

advance_verlet(f) Single advance using velocity Verlet with forces f
fit_forces(atoms) Evaluate QM forces and optimise the adjustable potential to reproduce them
get_extrapolation_forces(atoms, i) Get LOTF forces at extrapolation step i
get_interpolation_forces(atoms, i) Get LOTF forces at interpolation step i
get_reference_forces(atoms, i) Do a reference QM calculation and return forces resulting from standard force mixing.
get_state() Save dynamical state, including random number seeds
initialise_adjustable_potential(atoms) Bootstrap the potential by doing a QM calculation and fitting the adj.
set_qm_update_func(qm_update_func) Specify a function that will be called up update the QM region
set_state(saved_state) Restore dynamics to a previously saved state.
step() Advance the dynamics by one LOTF cycle
advance_verlet(f)[source]

Single advance using velocity Verlet with forces f

Do not call this method directly: it is invoked by step() once for each extrapolation and interpolation step.

Note that order of the two half-steps is inverted, to fit in with the predictor-corrector loops. This means the momenta are half-stepped outside of this routine.

fit_forces(atoms)[source]

Evaluate QM forces and optimise the adjustable potential to reproduce them

Returns the QM forces on the atoms at the fit point

get_extrapolation_forces(atoms, i)[source]

Get LOTF forces at extrapolation step i

get_interpolation_forces(atoms, i)[source]

Get LOTF forces at interpolation step i

get_number_of_steps()[source]

Return number of steps taken since start of dynamics

get_reference_forces(atoms, i)[source]

Do a reference QM calculation and return forces resulting from standard force mixing.

Useful for checking errors during predictor/corrector extrapolation and interpolation. Does not change the current set of adjustable potential parameters.

get_state()[source]

Save dynamical state, including random number seeds

get_time()[source]

Return current time (in ASE time units)

initialise_adjustable_potential(atoms)[source]

Bootstrap the potential by doing a QM calculation and fitting the adj. pot.

Returns the initial QM/MM forces on the atoms

run(steps)[source]

Run LOTF dynamics forwards for given number of small time steps

Number of LOTF cycles is given by step/extrapolate_steps.

set_qm_update_func(qm_update_func)[source]

Specify a function that will be called up update the QM region

qm_update_func should take a single argument, which is the Atoms object representing the current state of the dynamical system.

set_state(saved_state)[source]

Restore dynamics to a previously saved state. Sets arrays directly, ignoring any constraints.

step()[source]

Advance the dynamics by one LOTF cycle

The Learn on the Fly algorithm proceeds as follows:

  1. QM selection using the function registered with the set_qm_update_func() method.
  2. Save state of the dynamical system using the get_state() method.
  3. Extrapolation of the dynamics with fixed parameters for extrapolate_steps, each of size dt. This is the predictor part of the predictor-corrector cycle. The adjustable potential parameters are remapped if the set of QM atoms has changed since the most recent fit.
  4. QM force calculation and optimisation of the adjustable potential parameters to reproduce the QM forces at the fit point. With the linear ‘spings’ method, the fit can be reposed as a linear algebra problem and solved via singular value decomposition (SVD). See the adjustable potential code for full details in :svn:`QUIP_Core/AdjustablePotential.f95`.
  5. Restore state of the dynamical system saved at step 2, returning to before the extrapolation phase.
  6. Interpolation of the dynamics, with the adjustable potential parameters interpolated between their values at the two fit points.
extrapolate_steps

Number of small time-steps used when extrapolating or interpolating in the LOTF predictor-corrector loop. See step() for a more detailed description.

state_label

One-character label for current dynamical state: either “E” or “I” for extrapolation or interpolation, respectively.

quippy.lotf.update_hysteretic_qm_region(atoms, old_qm_list, qm_centre, qm_inner_radius, qm_outer_radius, use_avgpos=False, update_marks=True)[source]

Update the QM region in atoms

Calls set_qm_atoms() to mark the atoms if the Atoms’ calculator is an instance of ForceMixingPotential.

Parameters:
old_qm_list : list

List of QM atoms at previous update

qm_centre : array with shape (3,)

Position of the new centre of the QM region

qm_inner_radius : float

Atoms which come within this distance of any core atom will become selected for QM treatment.

qm_outer_radius : float

Atoms stay QM until they are more than this distance from any core atom

update_marks : bool

If true (default), call set_qm_atoms() to mark the atoms

Returns:
qm_list : list

List of the new QM atom indices

quippy.lotf.iter_atom_centered_clusters(at, mark_name='hybrid_mark', **cluster_args)[source]

Iterate over all atom-centered (little) clusters in at.

If at has a property with name mark_name (default “hybrid_mark”), only those atoms where hybrid_mark == HYBRID_ACTIVE_MARK are included. Otherwise, all atoms are included.

Clusters are constructed by calling create_hybrid_weights() and create_cluster_simple() once for each atom of interest, after setting hybrid_mark=HYBRID_ACTIVE_MARK for that atom only.

Any keyword arguments given are passed along to both cluster creation functions.

Module contents for quippy.adjustablepotential:

Functions

adjustable_potential_init(…)
Parameters:
adjustable_potential_force(…)
Parameters:
adjustable_potential_finalise()

References

Attributes

Name Value
AP_bad_atom_threshold 0.1
adjustable_potential_max_spring_constant 1.0
adjustable_potential_nparams 1
quippy.adjustablepotential.adjustable_potential_init(atoms_in, fitlist, directionn[, spring_hops, map, method, nnonly])
Parameters:
atoms_in : Atoms object
fitlist : Table object
directionn : input int
spring_hops : input int, optional
map : input int, optional
method : input string(len=-1), optional
nnonly : input int, optional

References

Routine is wrapper around Fortran routine adjustable_potential_init defined in file src/Potentials/AdjustablePotential.f95.

quippy.adjustablepotential.adjustable_potential_force(atoms_in, n0[, interp, interp_space, interp_order, energy, power])
Parameters:
atoms_in : Atoms object
n0 : input int

shape(qp_force,0)

interp : input float, optional
interp_space : input int, optional
interp_order : input string(len=-1), optional
energy : in/output rank-0 array(float,’d’), optional
power : in/output rank-0 array(float,’d’), optional
Returns:
force : rank-2 array(‘d’) with bounds (3,qp_n0)

References

Routine is wrapper around Fortran routine adjustable_potential_force defined in file src/Potentials/AdjustablePotential.f95.

quippy.adjustablepotential.adjustable_potential_finalise()

References

Routine is wrapper around Fortran routine adjustable_potential_finalise defined in file src/Potentials/AdjustablePotential.f95.