narupatools.imd.forces

Code for calculating IMD forces.

Functions

calculate_imd_force

Calculate the forces and energy to apply for a given interaction.

get_force_function

Get the force function defined for a given interaction type.

register_imd_force_type

Register a new kind of interactive force.

narupatools.imd.forces.calculate_imd_force(*, interaction: narupa.imd.particle_interaction.ParticleInteraction, positions: numpy.ndarray[Any, numpy.dtype[numpy.float64]], masses: numpy.ndarray[Any, numpy.dtype[numpy.float64]])Tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], float]

Calculate the forces and energy to apply for a given interaction.

Parameters
  • interaction – Interaction to calculate forces and energy for.

  • positions – Positions of particles affected by this interaction.

  • masses – Masses of particles affected by this interaction.

narupatools.imd.forces.get_force_function(type: str, /)narupatools.imd.forces.InteractiveForce

Get the force function defined for a given interaction type.

Parameters

type – Interaction type to look up.

Raises

UnknownInteractiveForceError – Given interaction type is not recognized.

narupatools.imd.forces.register_imd_force_type(type: str, force: narupatools.imd.forces.InteractiveForce, /)None

Register a new kind of interactive force.

Parameters
  • type – String key that defines this interaction type.

  • force – Function that calculates the force and energy.

Raises

InteractionTypeAlreadyDefinedError – Interaction with the given name already exists.

Classes

InteractiveForce(*args, **kwargs)

Protocol for a force function that returns a set of forces and an energy.

Exceptions

InteractionTypeAlreadyDefinedError(type, /)

Error raised when an interaction type already exists.

UnknownInteractiveForceError(type, /)

Error raised when an interaction with an unknown type is used.