nanover.ase.imd_calculator module
Provides an implementation of IMD force field in ASE.
- class nanover.ase.imd_calculator.ImdCalculator(imd_state: ImdStateWrapper, calculator: Calculator, atoms: Atoms, dynamics: MolecularDynamics | None = None, reset_scale=0.5, **kwargs)
Bases:
Calculator
Implementation of IMD as an ASE calculator.
Given another ASE calculator to act as the internal calculator, will compute the external energy and forces via the IMD service, and add them to the internal force calculations.
- Parameters:
imd_state – A wrapper that provides access to the active interactive forces.
calculator – An existing ASE calculator to perform internal energy calculation.
atoms – An ASE atoms object to use.
dynamics – An ASE dynamics object from which to draw the equilibrium temperature for resetting velocities
reset_scale – A scale factor to apply to velocities when reset.
kwargs – Key word args passed to the base calculator.
See also
The
ImdServer
class makes use of this class, and makes running an interactive molecular dynamics simulation in ASE straightforward.- add_to_frame_data(frame_data: FrameData)
Add the iMD forces and energy to the frame data via the ImdForceManager.
- Parameters:
frame_data – The FrameData object to which the iMD results are appended.
- calculate(atoms: Atoms | None = None, properties=('energy', 'forces'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])
Calculates the given properties of the ASE atoms. The internal molecular calculator is called first, and then any interactive forces currently being applied to the system are added.
Results are stored in the results dictionary, as normal.
- Parameters:
atoms – Optional
Atoms
object to perform the calculation on. If no atoms is passed, the atoms object passed at initialisation are used.properties – The properties to calculate. The ImdCalculator support ‘energy’ and ‘forces’, but will pass any other requested properties to the internal atomic calculator. See
calculate()
for details.system_changes – List of what has changed since last calculation. See
calculate()
for details.
- property calculator: Calculator
The internal ASE calculator being used.
- Returns:
ASE calculator being used to compute internal forces.
- property interactions: Dict[str, ParticleInteraction]
Fetches a copy of the current interactions.
- property reset_temperature
The temperature this calculator will reset the velocities of atoms interacted with to if the interaction is set to reset velocities.
- Returns:
The reset temperature.
- Raises:
Attribute error, if not temperature has been defined.
- property temperature: float
Gets the temperature used for reinitialising velocities after an interaction.
By default, it will attempt to use the temperature of the dynamics. If a custom temperature has been set by this attributes setter, then that will be used.
- Returns:
The temperature used for reinitialising velocities after an interaction.
- Raises:
AttributeError: If no temperature is defined for this calculator, in the case that no dynamics object has been passed, or the dynamics object does not implement the temperature or ‘temp’ attribute.
- update_interactions()
Update the iMD interaction energies and forces (in ASE units) via the ImdForceManager, and subsequently resets the velocities (if applicable).
- class nanover.ase.imd_calculator.ImdForceManager(imd_state: ImdStateWrapper, atoms: Atoms)
Bases:
object
A class that calculates and stores the iMD forces and energies for an ASE simulation. This class manages data associated with the iMD interactions for the
ImdCalculator
.- Parameters:
imd_state – A wrapper that provides access to the active interactive forces.
atoms – An ASE atoms object to use.
- add_to_frame_data(frame_data: FrameData)
Add the iMD forces and energy to the frame data.
- Parameters:
frame_data – The FrameData object to which the iMD results are appended.
- update_interactions()
Update the iMD interaction energies and forces (in ASE units).
- nanover.ase.imd_calculator.get_periodic_box_lengths(atoms: Atoms) ndarray | None
Gets the periodic box lengths of an orthorhombic box, in nm, from an ASE atoms collection, if it exists.
- Parameters:
atoms – ASE atoms.
- Returns:
Array of periodic box lengths if periodic boundaries are in use,
None
otherwise.