PositionRestraint¶
- class PositionRestraint(atom_selection=None, spring_constant=None, reference_positions=None)¶
Class to apply spring restraints to tether the atomic position to its original values.
- Parameters:
atom_selection (sequence of int | str | None) – The selection of atoms that should be restrained. Can be given as list of indices or a tag. Default: All atoms.
spring_constant (PhysicalQuantity of type energy / length ** 2) – The spring constant used for the tethering springs. Default: 0.5 * eV / Ang ** 2.
reference_positions (PhysicalQuantity of type length) – If specified, the given positions will be used as reference positions. If set to None, the positions of the first configuration in the simulation will be used.
- frozenDegreesOfFreedom(local_atoms=None)¶
- Parameters:
local_atoms (list of int | None) – The group of atoms from which the frozen degrees of freedom should be calculated, e.g. a thermalized group of atoms. Default: All atoms.
- Returns:
The number of degrees of freedom that are frozen by this constraint object.
- Return type:
int
- uniqueString()¶
Return a unique string representing the state of the object.
Usage Examples¶
When studying crystallization at amorphous interfaces with SteeredMolecularDynamics the PositionRestraint can be used to prevent the crystal atoms from melting.
bulk_configuration.setCalculator(calculator)
# MolecularDynamics
diffraction_peak = DiffractionPeak(
cutoff_radius=10.0*Ang,
q_value=2.1/Ang,
included_atoms=[Cobalt],
)
hook_function = SteeredMolecularDynamics(
collective_variable=diffraction_peak,
velocity=300/1000/ps,
spring_constant=0.1*eV,
measurement_interval=50,
)
method = Langevin(
initial_velocity=MaxwellBoltzmannDistribution(
temperature=1400.0*Kelvin,
remove_center_of_mass_momentum=None
),
reservoir_temperature=1400.0*Kelvin,
friction=0.05*1/fs
)
constraints = [PositionRestraint(atom_selection='silicon', spring_constant=1.0*eV/Ang**2)]
md_trajectory_1 = MolecularDynamics(
configuration=bulk_configuration,
constraints=constraints,
trajectory_filename='restrained_steered_MD.hdf5',
steps=2000000,
post_step_hook=[
hook_function,
],
measurement_hook=hook_function.measurements,
log_interval=1000,
method=method
)
Notes¶
The PositionRestraint object can be used to tether the positions of selected atoms to their
initial positions via harmonic springs. This allows the atoms to vibrate and include thermal
effects, while they would not be able to leave their positions permanently, which avoids structural
changes. Instead of the initial positions one can also specify different reference positions via
the reference_positions
parameters. A PositionRestraint object can be passed as
constraint in MolecularDynamics or OptimizeGeometry.