Trajectory

class Trajectory(path=None, object_id=<class 'NL.ComputerScienceUtilities.NLFlag._NLFlag.Automatic'>)

Construct a Trajectory object that contains the configurations from an optimization run.

image(image_index)
Parameters:image_index (int) – The index of the desired image.
Returns:The configuration for this image.
Return type:MoleculeConfiguration | BulkConfiguration | DeviceConfiguration | SurfaceConfiguration
imageEnergy(image_index)
Parameters:image_index (int) – The index of the desired image.
Returns:The energy of the image.
Return type:PhysicalQuantity of type energy
imageForces(image_index)
Parameters:image_index (int) – The index of the desired image.
Returns:The forces of the image.
Return type:PhysicalQuantity of type force (e.g. eV/Angstrom)
images()
Returns:All the configurations in the trajectory.
Return type:list of MoleculeConfiguration | BulkConfiguration | DeviceConfiguration | SurfaceConfiguration
lastImage()
Returns:The last configuration in the trajectory.
Return type:MoleculeConfiguration | BulkConfiguration | DeviceConfiguration | SurfaceConfiguration
length()
Returns:The number of configurations in the trajectory.
Return type:int
metatext()
Returns:The metatext of the object or None if no metatext is set.
Return type:str | unicode | None
setMetatext(text)

Set a given metatext string on the object.

Parameters:metatext (str | unicode | None) – The metatext string that should be set. A value of “None” can be given to remove the current metatext.

Usage Examples

Optimize the geometry of a water molecule and read the result into a trajectory object

# 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 calculator
molecule_configuration.setCalculator(LCAOCalculator())

# perform optimization and read the relaxation trajectory
OptimizeGeometry(molecule_configuration, trajectory_filename='opt.nc')
trajectory = nlread('opt.nc', Trajectory)[0]


trajectory.py