Package ffx.potential
Class ForceFieldEnergyOpenMM
java.lang.Object
ffx.potential.ForceFieldEnergy
ffx.potential.ForceFieldEnergyOpenMM
- All Implemented Interfaces:
CrystalPotential
,OptimizationInterface
,Potential
,LambdaInterface
Compute the potential energy and derivatives using OpenMM.
- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Creates and manage an OpenMM Context.class
Retrieve state information from an OpenMM Simulation.class
Create and manage an OpenMM System.Nested classes/interfaces inherited from class ffx.potential.ForceFieldEnergy
ForceFieldEnergy.Platform
Nested classes/interfaces inherited from interface ffx.numerics.Potential
Potential.STATE, Potential.VARIABLE_TYPE
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal int
Whether to enforce periodic boundary conditions when obtaining new States.Fields inherited from class ffx.potential.ForceFieldEnergy
DEFAULT_CONSTRAINT_TOLERANCE, lambdaTerm, molecularAssembly, optimizationScaling, rTors
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ForceFieldEnergyOpenMM
(MolecularAssembly molecularAssembly, ForceFieldEnergy.Platform requestedPlatform, int nThreads) ForceFieldEnergyOpenMM constructor; offloads heavy-duty computation to an OpenMM Platform while keeping track of information locally. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createContext
(String integratorString, double timeStep, double temperature, boolean forceCreation) Create an OpenMM Context.createState
(boolean positions, boolean energies, boolean forces, boolean velocities) Create an immutable OpenMM State.boolean
destroy()
Frees up assets associated with this ForceFieldEnergy, such as worker Threads.double
energy
(double[] x) This method is called repeatedly to compute the function energy.double
energy
(double[] x, boolean verbose) This method is called repeatedly to compute the function energy.double
energyAndGradient
(double[] x, double[] g) This method is called repeatedly to compute the function energy and gradient.double
energyAndGradient
(double[] x, double[] g, boolean verbose) This method is called repeatedly to compute the function energy and gradient.double
energyAndGradientFFX
(double[] x, double[] g) Compute the energy and gradient using the pure Java code path.double
energyAndGradientFFX
(double[] x, double[] g, boolean verbose) Compute the energy and gradient using the pure Java code path.double
energyFFX
(double[] x) Compute the energy using the pure Java code path.double
energyFFX
(double[] x, boolean verbose) Compute the energy using the pure Java code path.Returns the Context instance.double
Get the 2nd partial derivative of the energy with respect to lambda.double
getdEdL()
Get the partial derivative of the energy with respect to lambda.void
getdEdXdL
(double[] gradients) Get the gradient of dEdL with respect to each parameter.double[]
getGradient
(double[] g) Re-compute the gradient using OpenMM and return it.Gets the Platform associated with this force field energy.Get a reference to the System instance.void
Update active atoms.void
setCoordinates
(double[] x) Set FFX and OpenMM coordinates for active atoms.void
setCrystal
(Crystal crystal) void
setLambda
(double lambda) Set the current value of the state variable.void
updateParameters
(Atom[] atoms) Update parameters if the Use flags and/or Lambda value has changed.Methods inherited from class ffx.potential.ForceFieldEnergy
applyAllConstraintPositions, applyAllConstraintPositions, attachExtendedSystem, dEdLZeroAtEnds, energy, energy, energyFactory, energyFactory, getAcceleration, getAngleEnergy, getAngles, getAngles, getAngleTorsionEnergy, getAngleTorsions, getBondEnergy, getBonds, getCavitationEnergy, getConstraints, getCoordinates, getCoordRestraints, getCrystal, getCutoffPlusBuffer, getDispersionEnergy, getElectrostaticEnergy, getEnergyTermState, getEsvBiasEnergy, getExtendedSystem, getGK, getGKEnergy, getImproperTorsionEnergy, getImproperTorsions, getLambda, getMass, getNeutralNetworkEnergy, getNumberofAngles, getNumberofAngleTorsions, getNumberofBonds, getNumberofImproperTorsions, getNumberofOutOfPlaneBends, getNumberofPiOrbitalTorsions, getNumberofStretchBends, getNumberofStretchTorsions, getNumberofTorsions, getNumberofTorsionTorsions, getNumberofUreyBradleys, getNumberOfVariables, getOutOfPlaneBendEnergy, getOutOfPlaneBends, getParallelTeam, getPDBHeaderString, getPermanentInteractions, getPermanentMultipoleEnergy, getPermanentRealSpaceEnergy, getPermanentReciprocalMpoleEnergy, getPermanentReciprocalSelfEnergy, getPiOrbitalTorsionEnergy, getPiOrbitalTorsions, getPmeNode, getPolarizationEnergy, getPreviousAcceleration, getRelativeSolvationEnergy, getRestrainGroups, getRestraintBonds, getScaling, getSolvationEnergy, getSolvationInteractions, getStrenchBendEnergy, getStretchBends, getStretchTorsionEnergy, getStretchTorsions, getTorsionEnergy, getTorsions, getTorsionTorsionEnergy, getTorsionTorsions, getTotalElectrostaticEnergy, getTotalEnergy, getUreyBradleyEnergy, getUreyBradleys, getVanDerWaalsEnergy, getVanDerWaalsInteractions, getVariableTypes, getVdwNode, getVelocity, logBondedTerms, reInit, setAcceleration, setCrystal, setEnergyTermState, setPreviousAcceleration, setPrintOnFailure, setScaling, setVelocity, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ffx.numerics.OptimizationInterface
getUnderlyingPotentials, scaleCoordinates, scaleCoordinatesAndGradient, unscaleCoordinates
Methods inherited from interface ffx.numerics.Potential
writeAdditionalRestartInfo
-
Field Details
-
enforcePBC
public final int enforcePBCWhether to enforce periodic boundary conditions when obtaining new States.
-
-
Constructor Details
-
ForceFieldEnergyOpenMM
protected ForceFieldEnergyOpenMM(MolecularAssembly molecularAssembly, ForceFieldEnergy.Platform requestedPlatform, int nThreads) ForceFieldEnergyOpenMM constructor; offloads heavy-duty computation to an OpenMM Platform while keeping track of information locally.- Parameters:
molecularAssembly
- Assembly to construct energy for.requestedPlatform
- requested OpenMM platform to be used.nThreads
- Number of threads to use in the super class ForceFieldEnergy instance.
-
-
Method Details
-
createContext
public void createContext(String integratorString, double timeStep, double temperature, boolean forceCreation) Create an OpenMM Context.Context.free() must be called to free OpenMM memory.
- Parameters:
integratorString
- Integrator to use.timeStep
- Time step.temperature
- Temperature (K).forceCreation
- Force a new Context to be created, even if the existing one matches the request.
-
createState
public ForceFieldEnergyOpenMM.State createState(boolean positions, boolean energies, boolean forces, boolean velocities) Create an immutable OpenMM State.State.free() must be called to free OpenMM memory.
- Parameters:
positions
- Retrieve positions.energies
- Retrieve energies.forces
- Retrieve forces.velocities
- Retrieve velocities.- Returns:
- Returns the State.
-
destroy
public boolean destroy()Frees up assets associated with this ForceFieldEnergy, such as worker Threads.- Specified by:
destroy
in interfaceOptimizationInterface
- Overrides:
destroy
in classForceFieldEnergy
- Returns:
- If successful in freeing up assets.
-
energy
public double energy(double[] x) This method is called repeatedly to compute the function energy.- Specified by:
energy
in interfaceOptimizationInterface
- Overrides:
energy
in classForceFieldEnergy
- Parameters:
x
- Input parameters.- Returns:
- Function value at
x
.
-
energy
public double energy(double[] x, boolean verbose) This method is called repeatedly to compute the function energy. The verbose flag may not be used by all implementations.- Specified by:
energy
in interfaceOptimizationInterface
- Overrides:
energy
in classForceFieldEnergy
- Parameters:
x
- Input parameters.verbose
- Display extra information.- Returns:
- Function value at
x
-
energyAndGradient
public double energyAndGradient(double[] x, double[] g) This method is called repeatedly to compute the function energy and gradient.- Specified by:
energyAndGradient
in interfaceOptimizationInterface
- Overrides:
energyAndGradient
in classForceFieldEnergy
- Parameters:
x
- Input parameters.g
- Output gradients with respect to each parameter.- Returns:
- Function value at
x
.
-
energyAndGradient
public double energyAndGradient(double[] x, double[] g, boolean verbose) This method is called repeatedly to compute the function energy and gradient. The verbose flag may not be used by all implementations.- Specified by:
energyAndGradient
in interfaceOptimizationInterface
- Overrides:
energyAndGradient
in classForceFieldEnergy
- Parameters:
x
- Input parameters.g
- Output gradients with respect to each parameter.verbose
- Display extra information.- Returns:
- Function value at
x
.
-
energyAndGradientFFX
public double energyAndGradientFFX(double[] x, double[] g) Compute the energy and gradient using the pure Java code path.- Parameters:
x
- Input atomic coordinatesg
- Storage for the gradient vector.- Returns:
- The energy (kcal/mol)
-
energyAndGradientFFX
public double energyAndGradientFFX(double[] x, double[] g, boolean verbose) Compute the energy and gradient using the pure Java code path.- Parameters:
x
- Input atomic coordinatesg
- Storage for the gradient vector.verbose
- Use verbose logging.- Returns:
- The energy (kcal/mol)
-
energyFFX
public double energyFFX(double[] x) Compute the energy using the pure Java code path.- Parameters:
x
- Atomic coordinates.- Returns:
- The energy (kcal/mol)
-
energyFFX
public double energyFFX(double[] x, boolean verbose) Compute the energy using the pure Java code path.- Parameters:
x
- Input atomic coordinatesverbose
- Use verbose logging.- Returns:
- The energy (kcal/mol)
-
getContext
Returns the Context instance.- Returns:
- context
-
getGradient
public double[] getGradient(double[] g) Re-compute the gradient using OpenMM and return it.- Overrides:
getGradient
in classForceFieldEnergy
- Parameters:
g
- Gradient array.- Returns:
- an array of
invalid reference
double
-
getPlatform
Gets the Platform associated with this force field energy. For the reference platform, always returns FFX.- Overrides:
getPlatform
in classForceFieldEnergy
- Returns:
- A Platform.
-
getSystem
Get a reference to the System instance.- Returns:
- Java wrapper to an OpenMM system.
-
getd2EdL2
public double getd2EdL2()Get the 2nd partial derivative of the energy with respect to lambda.- Specified by:
getd2EdL2
in interfaceLambdaInterface
- Overrides:
getd2EdL2
in classForceFieldEnergy
- Returns:
- d2EdL2
-
getdEdL
public double getdEdL()Get the partial derivative of the energy with respect to lambda.- Specified by:
getdEdL
in interfaceLambdaInterface
- Overrides:
getdEdL
in classForceFieldEnergy
- Returns:
- dEdL
-
getdEdXdL
public void getdEdXdL(double[] gradients) Get the gradient of dEdL with respect to each parameter.- Specified by:
getdEdXdL
in interfaceLambdaInterface
- Overrides:
getdEdXdL
in classForceFieldEnergy
- Parameters:
gradients
- - A double array of length the number of parameters in the model (commonly 3 * number of atoms).
-
setActiveAtoms
public void setActiveAtoms()Update active atoms. -
setCoordinates
public void setCoordinates(double[] x) Set FFX and OpenMM coordinates for active atoms.- Overrides:
setCoordinates
in classForceFieldEnergy
- Parameters:
x
- Atomic coordinates.
-
setCrystal
Set the boundary conditions for this calculation.
- Specified by:
setCrystal
in interfaceCrystalPotential
- Overrides:
setCrystal
in classForceFieldEnergy
-
setLambda
public void setLambda(double lambda) Set the current value of the state variable. May be ignored if lambda is not being applied.- Specified by:
setLambda
in interfaceLambdaInterface
- Overrides:
setLambda
in classForceFieldEnergy
- Parameters:
lambda
- a double.
-
updateParameters
Update parameters if the Use flags and/or Lambda value has changed.- Parameters:
atoms
- Atoms in this list are considered.
-