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.
- Parameters:
path (str) – The path to the HDF5 file to store the results in.
object_id (str | Automatic) – The object id to use when saving to HDF5. Default: Automatic
- 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
- imageConstraints(image_index)¶
- Parameters:
image_index (int) – The index of the desired image.
- Returns:
The constraint objects for the image.
- Return type:
list of type
BaseConstraint
- 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)
- imageOptimizerMethod(image_index)¶
- Parameters:
image_index (int) – The index of the desired image.
- Returns:
The optimizer method object for the image.
- Return type:
OptimizerMethod
- imageStress(image_index)¶
- Parameters:
image_index (int) – The index of the desired image.
- Returns:
The stress of the image.
- Return type:
PhysicalQuantity of type pressure (e.g. GPa)
- 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 | None
- setMetatext(text)¶
Set a given metatext string on the object.
- Parameters:
metatext (str | 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]