Name

calculateAtomicForces Calculates the atomic forces on each atom in the system.

Synopsis

Namespace: ATK.KohnSham or ATK.TwoProbe
AtomicForces calculateAtomicForces(self_consistent_calculation)

Description

The function calculateAtomicForces() calculates and returns the forces on each atom. The input is a self-consistent calculation.

The atomic forces are calculated in ATK by performing the analytical differentiation with respect to the atomic displacements of the various terms which appears in the expression of the total energy.

List of arguments

self_consistent_calculation

An object returned from a previously performed self-consistent calculation.

Default: None

Returned object methods

The object returned from calculateAtomicForces() has the following two query methods:

  • Array toArray(): Returns the atomic forces as the Cartesian coordinates of the vectors in a NumPy array of dimensionality (natoms,3).

  • PhysicalUnit toUnit(): Returns the unit of the atomic forces.

Usage examples

Perform a self-consistent DFT calculation for a water molecule, and print a nicely formatted list of the atoms, their positions, and the forces on the atoms. Note how the units are handled! For the positions, each entry in the list has a unit (and so we use the inUnitsOf() method to extract the value), while the forces are stored in an array without units, and the unit itself is attached to the force object, and is extracted using the toUnit() method.

from ATK.KohnSham import *

h2o = MoleculeConfiguration([Oxygen,Hydrogen,Hydrogen], 
  [(0.000,0.000,0.0)*Ang, 
   (0.757,0.586,0.0)*Ang,
   (-0.757,0.586,0.0)*Ang])

scf = KohnShamMethod().apply(h2o)
forces_object = calculateAtomicForces(scf)
forces = forces_object.toArray()
unit = forces_object.toUnit()

print "Atom\tPosition (in Ang)\tForce (in %s)" % (unit)
print "Element\tX\tY\tZ\tFX\tFY\tFZ"
for i in range(len(forces)):
    print h2o.elements()[i].symbol(),
    for xyz in h2o.cartesianCoordinates()[i]:
        print "\t%.3f" % (xyz.inUnitsOf(Ang)),
    for f in forces[i]:
        print "\t%.4f" % (f),
    print

Notes

By extracting the forces, it is straight-forward to implement a user-defined geometry optimization method. There is also a generic optimization method in ATK, available through calculateOptimizedAtomicGeometry().