InteractionConstraint

class narupatools.ase.constraints.imd_constraint.InteractionConstraint(*, dynamics: Union[ase.atoms.Atoms, narupatools.ase.constraints.imd_constraint.ASEAtomsWrapper], key: str, interaction: narupa.imd.particle_interaction.ParticleInteraction, start_time: float)

An ASE constraint that applies an iMD force.

This conflates both an implementation of a narupatools interaction and an ASE constraint.

Inheritance

Inheritance diagram of InteractionConstraint

Methods

__init__

Create an ASE constraint that will apply an interactive force.

adjust_forces

Adjust the forces in-place for an ASE Atoms object.

adjust_momenta

Adjust the momenta in-place for an ASE Atoms object.

adjust_positions

Adjust the positions in-place for an ASE Atoms object.

adjust_potential_energy

Get the difference in potential energy due to this constraint.

get_positions

Get the positions of the affected particles for this interaction, in nanometers.

on_post_step

Perform any tasks necessary after a dynamics step.

on_pre_step

Perform any tasks necessary before a dynamics step.

update_energy_and_forces

Calculate the forces and energy of this interaction.

__init__(*, dynamics: Union[ase.atoms.Atoms, narupatools.ase.constraints.imd_constraint.ASEAtomsWrapper], key: str, interaction: narupa.imd.particle_interaction.ParticleInteraction, start_time: float)

Create an ASE constraint that will apply an interactive force.

Parameters
  • dynamics – Dynamics this interaction is attached to.

  • key – Unique key to identify this interaction.

  • interaction – Initial parameters of the interaction.

  • start_time – Start time of interaction in simulation time in picoseconds

adjust_forces(atoms: ase.atoms.Atoms, forces: numpy.ndarray, /)None

Adjust the forces in-place for an ASE Atoms object.

Parameters
  • atoms – The ASE Atoms object this constraint applies to.

  • forces – The forces to be modified by this constraint, in eV per nm.

adjust_momenta(atoms: ase.atoms.Atoms, momenta: numpy.ndarray, /)None

Adjust the momenta in-place for an ASE Atoms object.

Parameters
  • atoms – The ASE Atoms object this constraint applies to.

  • momenta – The momenta to be modified by this constraint, in a.m.u angstrom per ASE time unit.

adjust_positions(atoms: ase.atoms.Atoms, positions: numpy.ndarray, /)None

Adjust the positions in-place for an ASE Atoms object.

Parameters
  • atoms – The ASE Atoms object this constraint applies to.

  • positions – The positions to be modified by this constraint, in angstrom.

adjust_potential_energy(atoms: ase.atoms.Atoms)float

Get the difference in potential energy due to this constraint.

Parameters

atoms – The ASE Atoms object this constraint applies to.

Returns

The difference in potential energy, in eV.

get_positions()numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Get the positions of the affected particles for this interaction, in nanometers.

These are needed to calculate work.

Returns

Array of positions for the particles affected by this interaction.

on_post_step()None

Perform any tasks necessary after a dynamics step.

on_pre_step()None

Perform any tasks necessary before a dynamics step.

update_energy_and_forces(*, atoms: Optional[ase.atoms.Atoms] = None)Tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], float]

Calculate the forces and energy of this interaction.

Overriding this allows a subclass to implement features such as caching.

Returns

Tuple of forces (in kilojoules per mole per nanometer) and energy (in kilojoules per mole).

Attributes

forces

Forces that will be applied by the interaction.

interaction

Current parameters of the interaction.

particle_indices

List of indices affected by this interaction.

potential_energy

Potential energy of the interaction, in kilojoules per mole.

start_time

Start time of the interaction in picoseconds.

total_work

Total work performed by interaction in kilojoules per mole.

work_last_step

Work performed last step in kilojoules per mole.

forces

Forces that will be applied by the interaction.

The forces are in kilojoules per mole per nanometer.

This is a (N, 3) NumPy array, where N is the number of particles affected by this interaction.

interaction

Current parameters of the interaction.

particle_indices

List of indices affected by this interaction.

potential_energy

Potential energy of the interaction, in kilojoules per mole.

start_time

Start time of the interaction in picoseconds.

total_work

Total work performed by interaction in kilojoules per mole.

work_last_step

Work performed last step in kilojoules per mole.