Module Contents


Potential(speciesA, speciesB, potentialFunction, h=1e-06) Class used to describe a potential to the writePotentials() function.
class atsim.potentials._potential.Potential(speciesA, speciesB, potentialFunction, h=1e-06)[source]

Bases: object

Class used to describe a potential to the writePotentials() function.

Potential objects encapsulate a python function or callable which is used by the energy() method to calculate potential energy.

The force() method returns \(\frac{-dU}{dr}\). If the energy callable provides .deriv() and .deriv2() methods these are used for evaluating the first and second derivatives of energy with respect to sepration. This allows analytical derivatives to be defined to the Potential object. When not defined, numerical derivatives are used instead.

The gradient() function is used to wrap the energy callable so that the correct derivative implementation is used.

energy(self, r)[source]
Parameters:r – Separation
Returns:Energy for given separation
force(self, r)[source]

Calculate force for this potential at a given separation.

If this object’s potentialFunction has a .deriv() method this will be used to calculate force (allowing analytical derivatives to be specified).

If potentialFunction doesn’t have a deriv method then a numerical derivative of the potential function will be returned instead.

Parameters:r (float) – Separation
Returns:-dU/dr at given separation
Return type:float