Class CcmaConstraint

java.lang.Object
ffx.potential.constraint.CcmaConstraint
All Implemented Interfaces:
Constraint

public class CcmaConstraint extends Object implements Constraint
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyConstraintToStep(double[] xPrior, double[] xNew, double[] masses, double tol)
    Applies this Constraint in the context of a partially calculated MD time-step.
    void
    applyConstraintToVelocities(double[] x, double[] v, double[] masses, double tol)
    Applies this Constraint to velocities, ensuring relative velocities are perpendicular to constrained bonds, etc., without affecting positions.
    ccmaFactory(List<Bond> constrainedBonds, List<Angle> constrainedAngles, Atom[] allAtoms, double[] masses, double nonzeroCutoff)
    Constructs a set of bond length Constraints to be satisfied using the Constaint Constraint Matrix Approximation, a parallelizable stable numeric method.
    int[]
    Returns the atomic XYZ indices of all Atoms constrained.
    boolean
    constraintSatisfied(double[] x, double tol)
    Checks if this Constraint is satisfied.
    boolean
    constraintSatisfied(double[] x, double[] v, double xTol, double vTol)
    Checks if this Constraint is satisfied.
    int
    Returns the number of degrees of freedom this Constraint constrains.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_CCMA_NONZERO_CUTOFF

      public static final double DEFAULT_CCMA_NONZERO_CUTOFF
      See Also:
  • Method Details

    • ccmaFactory

      public static CcmaConstraint ccmaFactory(List<Bond> constrainedBonds, List<Angle> constrainedAngles, Atom[] allAtoms, double[] masses, double nonzeroCutoff)
      Constructs a set of bond length Constraints to be satisfied using the Constaint Constraint Matrix Approximation, a parallelizable stable numeric method.

      The nonzeroCutoff field specifies how large an element of K-1 needs to be to be kept; smaller elements (indicating weak constraint-constraint couplings) are set to zero to make K-1 sparse and thus keep CCMA tractable.

      The constrainedAngles will constrain both component bonds and the triangle-closing distance. The constrainedBonds list should not include any bonds included in the constrained angles.

      Parameters:
      constrainedBonds - Bonds to be constrained, not included in constrainedAngles
      constrainedAngles - Angles to be constrained indirectly (by constructing a rigid triangle).
      allAtoms - All Atoms of the system, including unconstrained Atoms.
      masses - All masses of the system, including unconstrained atom masses.
      nonzeroCutoff - CCMA parameter defining how sparse/dense K-1 should be.
      Returns:
      Returns a new CcmaConstraint instance.
    • applyConstraintToStep

      public void applyConstraintToStep(double[] xPrior, double[] xNew, double[] masses, double tol)
      Applies this Constraint in the context of a partially calculated MD time-step. All arrays are globally indexed (i.e. includes all system atoms, not just the constrained ones).

      If there is no prior step (e.g. a newly loaded system that has not yet been rigidified), xPrior and xNew can be copies of each other when passed to the method.

      xPrior corresponds to atomCoordinates in the OpenMM constraint code. Ours will be in Angstroms, not nm. xNew corresponds to atomCoordinatesP in the OpenMM constraint code. Ours will be in Angstroms, not nm.

      Specified by:
      applyConstraintToStep in interface Constraint
      Parameters:
      xPrior - Atomic coordinates prior to the time-step to be constrained.
      xNew - Atomic coordinates after the time-step; updated in-place to satisfy the constraint.
      masses - Masses.
      tol - Acceptable constraint tolerance for numerical methods, as a fraction of bond length.
    • applyConstraintToVelocities

      public void applyConstraintToVelocities(double[] x, double[] v, double[] masses, double tol)
      Applies this Constraint to velocities, ensuring relative velocities are perpendicular to constrained bonds, etc., without affecting positions. All arrays are globally indexed (i.e. includes all system atoms, not just the constrained ones).

      Our positions will be in Angstroms, and velocities in Angstroms/ps, compared to the OpenMM nm and nm/ps.

      Specified by:
      applyConstraintToVelocities in interface Constraint
      Parameters:
      x - Atomic coordinates (unchanged).
      v - Velocities (updated in-place to satisfy constraints).
      masses - Masses.
      tol - Acceptable constraint tolerance for numerical methods; likely in Angstroms/ps
    • constrainedAtomIndices

      public int[] constrainedAtomIndices()
      Returns the atomic XYZ indices of all Atoms constrained. Guaranteed to be unique. The primary assumption will be that variables are in sets of 3x Cartesian coordinates.
      Specified by:
      constrainedAtomIndices in interface Constraint
      Returns:
      All indices of constrained Atoms.
    • constraintSatisfied

      public boolean constraintSatisfied(double[] x, double tol)
      Checks if this Constraint is satisfied.
      Specified by:
      constraintSatisfied in interface Constraint
      Parameters:
      x - Input coordinates to check.
      tol - Numerical tolerance as a fraction of bond stretch.
      Returns:
      Whether this Constraint is satisfied.
    • constraintSatisfied

      public boolean constraintSatisfied(double[] x, double[] v, double xTol, double vTol)
      Checks if this Constraint is satisfied. Also checks velocities; bond constraints, for example, require that relative velocity be orthogonal to the bond. If the velocities vector is null or the tolerance is zero, velocity checks are skipped.
      Specified by:
      constraintSatisfied in interface Constraint
      Parameters:
      x - Input coordinates to check.
      v - Input velocities to check. If null, velocity check disabled.
      xTol - Numerical tolerance for bond lengths.
      vTol - Numerical tolerance for velocity checks (typically in degrees). If zero, velocity check disabled.
      Returns:
      Whether this Constraint is satisfied.
    • getNumDegreesFrozen

      public int getNumDegreesFrozen()
      Returns the number of degrees of freedom this Constraint constrains.
      Specified by:
      getNumDegreesFrozen in interface Constraint
      Returns:
      Number of frozen DoF.