Name

Forces — Class for calculating the forces on the atomic configuration.

Synopsis

Namespace: NanoLanguage
Forces(configuration)

Description

Constructor for the Forces object.

Forces Arguments

configuration

Configuration with a calculator that supports forces calculations

Type: A MoleculeConfiguration and BulkConfiguration

Default: None

Forces Methods

A Forces object provides the following methods:

  • evaluate(): For a system consisting of N atoms, return an N by 3 matrix where the i'th row corresponds to the forces on i'th atom. Each matrix entry is a physical quantity object.

  • nlprint(stream): Print a formatted string with the forces.

    stream

    The stream the forces should be written to.

    Type: A stream that supports strings being written to using 'write'.

    Default: sys.stdout
  • stress(): For a system consisting of N atoms, return an N by 3 matrix where the i'th row corresponds to the forces on i'th atom. Each matrix entry is a physical quantity object.

Usage Examples

Calculate and print the forces on a water molecule

# Define elements
elements = [Oxygen, Hydrogen, Hydrogen]

# Define coordinates
cartesian_coordinates = [[  0.0,  -1.70000000e-05,   1.20198000e-01],
                         [  0.0,   7.59572000e-01,  -4.86714000e-01],
                         [  0.0,  -7.59606000e-01,  -4.86721000e-01]]*Angstrom

# Set up configuration
molecule_configuration = MoleculeConfiguration(
    elements=elements,
    cartesian_coordinates=cartesian_coordinates
    )

# define a a calculator
molecule_configuration.setCalculator(LCAOCalculator())

# calculate and print the forces
forces = Forces(molecule_configuration)
forces.nlprint()

forces.py

Notes

To print the data of the Forces, use the method nlprint.