|
AvogadroLibs 2.1.0-20261111
|
Constraints for optimization / dynamics. More...
#include <avogadro/core/constraint.h>
Public Types | |
| enum | Type { None = 0 , DistanceConstraint , AngleConstraint , TorsionConstraint , OutOfPlaneConstraint , UnknownConstraint } |
Public Member Functions | |
| Constraint (Index a, Index b, Index c=MaxIndex, Index d=MaxIndex, Real value=0.0) | |
| void | set (Index a, Index b, Index c=MaxIndex, Index d=MaxIndex, Real value=0.0) |
| void | setValue (Real value) |
| Real | value () const |
| std::tuple< Index, Index, Index, Index > | atoms () const |
| Index | aIndex () const |
| Index | bIndex () const |
| Index | cIndex () const |
| Index | dIndex () const |
| Real | k () const |
| void | setK (Real k) |
| Constraint::Type | type () const |
| bool | matches (Index a, Index b, Index c=MaxIndex, Index d=MaxIndex) const |
| bool | isValid (Index atomCount) const |
| bool | evaluate (const Array< Vector3 > &positions, Real &value) const |
| void | setType (Constraint::Type type) const |
Static Public Attributes | |
| static constexpr Real | DefaultDistanceK = 41840.0 |
| static constexpr Real | DefaultAngularK = 10000.0 |
Protected Attributes | |
| Index | m_aIndex = MaxIndex |
| Index | m_bIndex = MaxIndex |
| Index | m_cIndex = MaxIndex |
| Index | m_dIndex = MaxIndex |
| Real | m_value = 0.0 |
| Real | m_k = DefaultDistanceK |
| bool | m_kSet = false |
| Constraint::Type | m_type = None |
| bool | m_typeExplicit = false |
This class represents a distance, angle, or torsional constraint / restraint during optimization or dynamics. More technically, these are implemented as stiff harmonic oscillators restraining a particular atom set towards the value.
Distances are stored in Angstrom and angles / torsions in degrees, matching what the user sees in the property tables and constraint dialog. Energy calculators convert angular values to radians internally, so the angular force constants are in kJ/mol/radian^2.
| Constraint | ( | Index | a, |
| Index | b, | ||
| Index | c = MaxIndex, | ||
| Index | d = MaxIndex, | ||
| Real | value = 0.0 ) |
Constructor, results in a zero distance constraint
| a | Atom index of the first atom of the constraint |
| b | Atom index of the second atom of the constraint |
| c | Atom index of the third atom (for angles or torsions) or MaxIndex |
| d | Atom index of the fourth atom (for torsion constraints) or MaxIndex |
| value | The value of the constraint, either Angstrom for distance or degrees for angles and torsions |
| void set | ( | Index | a, |
| Index | b, | ||
| Index | c = MaxIndex, | ||
| Index | d = MaxIndex, | ||
| Real | value = 0.0 ) |
Set the constraint
| a | Atom index of the first atom of the constraint |
| b | Atom index of the second atom of the constraint |
| c | Atom index of the third atom (for angles or torsions) or MaxIndex |
| d | Atom index of the fourth atom (for torsion constraints) or MaxIndex |
| value | The value of the constraint, either Angstrom for distance or degrees for angles and torsions |
| void setValue | ( | Real | value | ) |
Set the constraint value (distance, angle, dihedral)
| value | The value of the constraint, either Angstrom for distance or degrees for angles and torsions |
| Real value | ( | ) | const |
| std::tuple< Index, Index, Index, Index > atoms | ( | ) | const |
| Index aIndex | ( | ) | const |
| Real k | ( | ) | const |
| Constraint::Type type | ( | ) | const |
| bool matches | ( | Index | a, |
| Index | b, | ||
| Index | c = MaxIndex, | ||
| Index | d = MaxIndex ) const |
Whether this constraint is on the coordinate the given atoms name. A coordinate read backwards is the same coordinate – the distance a-b is the distance b-a, and the torsion a-b-c-d is the torsion d-c-b-a – so both directions match. A table that lists a coordinate in its own order can then find the constraint on it however it happens to be stored. Out of plane constraints have no such symmetry and are matched exactly.
| bool isValid | ( | Index | atomCount | ) | const |
Check that every atom this constraint names still exists.
| atomCount | The number of atoms available |
Constraints outlive the atoms they name, since deleting an atom leaves the stored indices behind.
| bool evaluate | ( | const Array< Vector3 > & | positions, |
| Real & | value ) const |
Measure this constraint's coordinate in a set of atomic positions, which need not be the molecule's active one – a trajectory or relaxed scan can be measured frame by frame.
| positions | The atomic positions to measure |
| value | Receives the measurement: Angstrom for a distance, degrees for an angle or torsion, matching value() |
| void setType | ( | Constraint::Type | type | ) | const |
Set the type of constraint. An explicit type survives later set() calls, since it cannot always be inferred from the atom indices – an out-of-plane constraint has the same four indices as a torsion. Pass None to go back to inferring the type from the indices.
| type | The type of constraint |
|
staticconstexpr |
Default force constant for distance restraints, in kJ/mol/Angstrom^2
|
staticconstexpr |
Default force constant for angular restraints, in kJ/mol/radian^2