Name

OptimizeGeometry — Function for optimizing the geometry of the given configuration.

Synopsis

Namespace: NanoLanguage
OptimizeGeometry(
configuration,
max_forces,
max_stress,
max_steps,
max_step_length,
scf_restart_step_length,
constraints,
trajectory_filename,
disable_stress,
optimizer_method
)

Description

Function for optimizing the geometry of the given configuration. Returns: The optimized configuration. The returned optimized configuration is assigned the self-consistent calculation associated with the final step of the optimization loop.

OptimizeGeometry Arguments

configuration

The configuration to be optimized.

Type: A BulkConfiguration or MoleculeConfiguration or DeviceConfiguration

Default: None
max_forces

The maximum forces when the optimization should stop.

Type: A physical quantity with unit eV/Ang

Default: 0.05*eV/Ang
max_stress

The maximum stress when the optimization should stop.

Type: A physical quantity with unit eV/Ang**3

Default: 0.05*eV/Ang**3
max_steps

The maximum number of steps.

Type: A positive integer.

Default: 1000
max_step_length

The maximum step length the optimizer may take.

Type: A physical quantity with length units.

Default: 0.5*Ang
scf_restart_step_length

The maximum step length for running a restart scf calculation for the new geometry.

Type: A physical quantity with length units.

Default: 0.1*Ang
constraints

A list of indices of the atom with fixed positions, and Constraints objects.

Type: A list of integers and Constraints objects.

Default: []
trajectory_filename

The filename of the file to be used for storing the trajectory in.

Type: A string.

Default: None
disable_stress

Disable the stress for device and bulk calculations.

Type: bool

Default: False for LCAO calculators, True for other calculators.
optimizer_method

The optimizer to use for optimizing the structure.

Type: QuasiNewton | FIRE

Default: An instance of QuasiNewton

Usage Examples

Optimize the geometry of 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 calculator
molecule_configuration.setCalculator(LCAOCalculator())

# Perform optimization and store the relaxation trajectory
optimized_configuration = OptimizeGeometry(molecule_configuration,
			                   trajectory_filename='opt.nc'
					   )

# Save the relaxed configuration
nlsave('optimized_configuration.nc', optimized_configuration)

optimize.py

Notes

We use the Broyden–Fletcher–Goldfarb–Shanno (BFGS) method for optimization, which is a Quasi-Newton method.

Our implementation uses the ASE code.