Package ffx.potential.openmm
Class OpenMMEnergy
java.lang.Object
ffx.potential.ForceFieldEnergy
ffx.potential.openmm.OpenMMEnergy
- All Implemented Interfaces:
CrystalPotential,OptimizationInterface,Potential,LambdaInterface,OpenMMPotential
Compute the potential energy and derivatives using OpenMM.
- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Nested Class Summary
Nested classes/interfaces inherited from class ffx.potential.ForceFieldEnergy
ForceFieldEnergy.RestrainModeNested classes/interfaces inherited from interface ffx.numerics.Potential
Potential.STATE, Potential.VARIABLE_TYPE -
Field Summary
Fields inherited from class ffx.potential.ForceFieldEnergy
DEFAULT_CONSTRAINT_TOLERANCE, lambdaBondedTerms, lambdaTerm, maxDebugGradient, molecularAssembly, optimizationScaling -
Constructor Summary
ConstructorsConstructorDescriptionOpenMMEnergy(MolecularAssembly molecularAssembly, Platform requestedPlatform, int nThreads) ForceFieldEnergyOpenMM constructor; offloads heavy-duty computation to an OpenMM Platform while keeping track of information locally. -
Method Summary
Modifier and TypeMethodDescriptionbooleandestroy()Frees up assets associated with this ForceFieldEnergy, such as worker Threads.doubleenergy(double[] x) This method is called repeatedly to compute the function energy.doubleenergy(double[] x, boolean verbose) This method is called repeatedly to compute the function energy.doubleenergyAndGradient(double[] x, double[] g) This method is called repeatedly to compute the function energy and gradient.doubleenergyAndGradient(double[] x, double[] g, boolean verbose) This method is called repeatedly to compute the function energy and gradient.doubleenergyAndGradientFFX(double[] x, double[] g) Compute the energy and gradient using the pure Java code path.doubleenergyAndGradientFFX(double[] x, double[] g, boolean verbose) Compute the energy and gradient using the pure Java code path.doubleenergyFFX(double[] x) Compute the energy using the pure Java code path.doubleenergyFFX(double[] x, boolean verbose) Compute the energy using the pure Java code path.Returns the Context instance.doubleGet the 2nd partial derivative of the energy with respect to lambda.doublegetdEdL()Get the partial derivative of the energy with respect to lambda.voidgetdEdXdL(double[] gradients) Get the gradient of dEdL with respect to each parameter.static intgetDefaultDevice(org.apache.commons.configuration2.CompositeConfiguration props) Gets the default coprocessor device, ignoring any CUDA_DEVICE over-ride.double[]getGradient(double[] g) Re-compute the gradient using OpenMM and return it.Returns the MolecularAssembly instance.getOpenMMState(int mask) Create an immutable OpenMM State.Gets the Platform associated with this force field energy.Get a reference to the System instance.booleanUpdate active atoms.voidsetCoordinates(double[] x) Coordinates for active atoms in units of Angstroms.voidsetCrystal(Crystal crystal) Set the Crystal instance that specifies the periodic boundary conditions and symmetry.voidsetLambda(double lambda) Set the current value of the state variable.voidsetVelocity(double[] v) Velocities for active atoms in units of Angstroms.voidupdateContext(String integratorName, double timeStep, double temperature, boolean forceCreation) Create an OpenMM Context.voidupdateParameters(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, getAnglePotentialEnergy, getAngles, getAngleTorsionPotentialEnergy, getAtomArray, getBondPotentialEnergy, getConstraints, getCoordinates, getCrystal, getCutoffPlusBuffer, getEnergyTermState, getEsvBiasEnergy, getExtendedSystem, getGK, getImproperTorsionPotentialEnergy, getLambda, getLambdaTerm, getMass, getNumberOfVariables, getOutOfPlaneBendPotentialEnergy, getParallelTeam, getPDBHeaderString, getPermanentInteractions, getPermanentMultipoleEnergy, getPiOrbitalTorsionPotentialEnergy, getPmeNode, getPolarizationEnergy, getPreviousAcceleration, getRestrainDistancePotentialEnergy, getRestrainGroups, getRestrainMode, getRestrainPositionPotentialEnergy, getRestrainTorsionPotentialEnergy, getScaling, getSolvationEnergy, getSolvationInteractions, getStretchBendPotentialEnergy, getStretchTorsionPotentialEnergy, getTorsionPotentialEnergy, getTorsionTorsionPotentialEnergy, getTotalEnergy, getUreyBradleyPotentialEnergy, getVanDerWaalsEnergy, getVanDerWaalsInteractions, getVariableTypes, getVdwNode, getVelocity, logBondedTermsAndRestraints, setAcceleration, setCrystal, setEnergyTermState, setLambdaTerm, setPreviousAcceleration, setPrintOnFailure, setScaling, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ffx.numerics.OptimizationInterface
getUnderlyingPotentials, scaleCoordinates, scaleCoordinatesAndGradient, unscaleCoordinatesMethods inherited from interface ffx.numerics.Potential
writeAdditionalRestartInfo
-
Constructor Details
-
OpenMMEnergy
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
-
getDefaultDevice
public static int getDefaultDevice(org.apache.commons.configuration2.CompositeConfiguration props) Gets the default coprocessor device, ignoring any CUDA_DEVICE over-ride. This is either determined by process rank and the availableDevices/CUDA_DEVICES property, or just 0 if neither property is sets.- Parameters:
props- Properties in use.- Returns:
- Pre-override device index.
-
updateContext
public void updateContext(String integratorName, double timeStep, double temperature, boolean forceCreation) Create an OpenMM Context.Context.free() must be called to free OpenMM memory.
- Specified by:
updateContextin interfaceOpenMMPotential- Parameters:
integratorName- 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.
-
getOpenMMState
Create an immutable OpenMM State.State.free() must be called to free OpenMM memory.
- Specified by:
getOpenMMStatein interfaceOpenMMPotential- Parameters:
mask- The State mask.- Returns:
- Returns the State.
-
destroy
public boolean destroy()Frees up assets associated with this ForceFieldEnergy, such as worker Threads.- Specified by:
destroyin interfaceOptimizationInterface- Overrides:
destroyin 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:
energyin interfaceOptimizationInterface- Overrides:
energyin 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:
energyin interfaceOptimizationInterface- Overrides:
energyin classForceFieldEnergy- Parameters:
x- Input parameters.verbose- Display extra information.- Returns:
- Function value at
x
-
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)
-
energyAndGradient
public double energyAndGradient(double[] x, double[] g) This method is called repeatedly to compute the function energy and gradient.- Specified by:
energyAndGradientin interfaceOptimizationInterface- Overrides:
energyAndGradientin 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:
energyAndGradientin interfaceOptimizationInterface- Overrides:
energyAndGradientin 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)
-
getContext
Returns the Context instance.- Specified by:
getContextin interfaceOpenMMPotential- Returns:
- context
-
getMolecularAssembly
Returns the MolecularAssembly instance.- Overrides:
getMolecularAssemblyin classForceFieldEnergy- Returns:
- molecularAssembly
-
getGradient
public double[] getGradient(double[] g) Re-compute the gradient using OpenMM and return it.- Overrides:
getGradientin classForceFieldEnergy- Parameters:
g- Gradient array.- Returns:
- the gradient array.
-
getPlatform
Gets the Platform associated with this force field energy. For the reference platform, always returns FFX.- Overrides:
getPlatformin classForceFieldEnergy- Returns:
- A Platform.
-
getSystem
Get a reference to the System instance.- Specified by:
getSystemin interfaceOpenMMPotential- 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:
getd2EdL2in interfaceLambdaInterface- Overrides:
getd2EdL2in classForceFieldEnergy- Returns:
- d2EdL2
-
getdEdL
public double getdEdL()Get the partial derivative of the energy with respect to lambda.- Specified by:
getdEdLin interfaceLambdaInterface- Overrides:
getdEdLin classForceFieldEnergy- Returns:
- dEdL
-
getdEdXdL
public void getdEdXdL(double[] gradients) Get the gradient of dEdL with respect to each parameter.- Specified by:
getdEdXdLin interfaceLambdaInterface- Overrides:
getdEdXdLin classForceFieldEnergy- Parameters:
gradients- - A double array of length the number of parameters in the model (commonly 3 * number of atoms).
-
setActiveAtoms
public boolean setActiveAtoms()Update active atoms.- Specified by:
setActiveAtomsin interfaceOpenMMPotential- Returns:
- True if there are inactive atoms.
-
setCoordinates
public void setCoordinates(double[] x) Coordinates for active atoms in units of Angstroms.- Specified by:
setCoordinatesin interfaceOptimizationInterface- Overrides:
setCoordinatesin classForceFieldEnergy- Parameters:
x- Atomic coordinates active atoms.
-
setVelocity
public void setVelocity(double[] v) Velocities for active atoms in units of Angstroms.- Specified by:
setVelocityin interfacePotential- Overrides:
setVelocityin classForceFieldEnergy- Parameters:
v- Velocities for active atoms.
-
setCrystal
Set the Crystal instance that specifies the periodic boundary conditions and symmetry.Set the boundary conditions for this calculation.
- Specified by:
setCrystalin interfaceCrystalPotential- Overrides:
setCrystalin classForceFieldEnergy- Parameters:
crystal- a Crystal instance.
-
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:
setLambdain interfaceLambdaInterface- Overrides:
setLambdain classForceFieldEnergy- Parameters:
lambda- a double.
-
updateParameters
Update parameters if the Use flags and/or Lambda value has changed.- Specified by:
updateParametersin interfaceOpenMMPotential- Parameters:
atoms- Atoms in this list are considered.
-