Package ffx.algorithms.thermodynamics
Class OrthogonalSpaceTempering
java.lang.Object
ffx.algorithms.thermodynamics.OrthogonalSpaceTempering
- All Implemented Interfaces:
CrystalPotential
,OptimizationInterface
,Potential
,LambdaInterface
An implementation of the Orthogonal Space Tempering algorithm.
This only partially implements the LambdaInterface, since it does not return 2nd lambda derivatives. The 2nd derivatives of the bias require 3rd derivatives of the underlying Hamiltonian (not these derivatives are not needed for OST MD).
- Since:
- 1.0
- Author:
- Michael J. Schnieders, James Dama, Wei Yang and Pengyu Ren
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Store and operate on a 2D Histogram of (Lambda, dU/dL) observations to produce an OST bias.class
Parameters for running local optimizations during OST sampling.Nested classes/interfaces inherited from interface ffx.numerics.Potential
Potential.STATE, Potential.VARIABLE_TYPE
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AlgorithmListener
The AlgorithmListener is called each time a count is added.protected final Barostat
Reference to the Barostat in use; if present this must be turned off during optimization.protected double
Force Field Potential Energy (i.e. with no bias terms added).protected MolecularAssembly
The MolecularAssembly being simulated.protected final int
Number of variables.protected final CrystalPotential
The potential energy of the system.protected final boolean
Print detailed energy information.protected Potential.STATE
Are FAST varying energy terms being computed, SLOW varying energy terms, or BOTH. -
Constructor Summary
ConstructorDescriptionOrthogonalSpaceTempering
(LambdaInterface lambdaInterface, CrystalPotential potential, HistogramData histogramData, LambdaData lambdaData, org.apache.commons.configuration2.CompositeConfiguration properties, DynamicsOptions dynamicsOptions, LambdaParticleOptions lambdaParticleOptions, AlgorithmListener algorithmListener) OST Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHistogram
(HistogramData histogramData, LambdaData lambdaData) Add an alternate Histogram this OST can use.boolean
Returns true if dUdL is guaranteed to be zero at 0 and 1.boolean
destroy()
Destroys this Potential and frees up any associated resources, particularly worker Threads.double
energy
(double[] x) Compute the force field + bias energy.double
energyAndGradient
(double[] x, double[] gradient) This method is called repeatedly to compute the function energy and gradient.double[]
getAcceleration
(double[] acceleration) getAcceleration.double[]
getCoordinates
(double[] doubles) Load the current value of the parameters.Get the Crystal instance that specifies the periodic boundary conditions and symmetry.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[] gradient) Get the gradient of dEdL with respect to each parameter.long
Returns the number of energy evaluations performed by this OST, including those picked up in the lambda file.Get the Potential Energy terms that is active.double
Getter for the fieldforceFieldEnergy
.Return the current 2D Histogram of counts.double
Getter for the fieldlambda
.double[]
getMass()
Get the mass of each degree of freedom.int
Get the number of variables being operated on.Return the OST optimization information.getPotentialEnergy.double[]
getPreviousAcceleration
(double[] previousAcceleration) getPreviousAcceleration.boolean
If true, the Lambda extended system particle is propagated using Langevin dynamics.double[]
Get the problem scaling.double
getTotaldEdLambda.double
Get the total energy of the systemGet the type of all variables.double[]
getVelocity
(double[] velocity) getVelocity.void
logOutputFiles
(int index) void
setAcceleration
(double[] acceleration) setAcceleration.void
setCrystal
(Crystal crystal) Set the Crystal instance that specifies the periodic boundary conditions and symmetry.void
Set the Potential Energy terms that should be active.void
setHardWallConstraint
(boolean hardWallConstraint) If this flag is true, (lambda, dU/dL) Monte Carlo samples that have no weight in the Histogram are rejected.void
setLambda
(double lambda) Setter for the fieldlambda
.void
setMolecularAssembly
(MolecularAssembly molecularAssembly) void
setPreviousAcceleration
(double[] previousAcceleration) setPreviousAcceleration.void
setPropagateLambda
(boolean propagateLambda) Indicate if the Lambda extended system particle should be propagated using Langevin dynamics.void
setScaling
(double[] scaling) Scale the problem.void
setVelocity
(double[] velocity) setVelocity.void
switchHistogram
(int index) Switch to an alternate Histogram.void
writeAdditionalRestartInfo
(boolean recursive) Writes additional restart information, if any (e.g.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ffx.numerics.OptimizationInterface
energy, energyAndGradient, getUnderlyingPotentials, scaleCoordinates, scaleCoordinatesAndGradient, unscaleCoordinates
Methods inherited from interface ffx.numerics.Potential
getConstraints
-
Field Details
-
potential
The potential energy of the system. -
barostat
Reference to the Barostat in use; if present this must be turned off during optimization. -
algorithmListener
The AlgorithmListener is called each time a count is added. -
print
protected final boolean printPrint detailed energy information.- See Also:
-
nVariables
protected final int nVariablesNumber of variables. -
molecularAssembly
The MolecularAssembly being simulated. -
state
Are FAST varying energy terms being computed, SLOW varying energy terms, or BOTH. OST is not active when only FAST varying energy terms are being propagated. -
forceFieldEnergy
protected double forceFieldEnergyForce Field Potential Energy (i.e. with no bias terms added).
-
-
Constructor Details
-
OrthogonalSpaceTempering
public OrthogonalSpaceTempering(LambdaInterface lambdaInterface, CrystalPotential potential, HistogramData histogramData, LambdaData lambdaData, org.apache.commons.configuration2.CompositeConfiguration properties, DynamicsOptions dynamicsOptions, LambdaParticleOptions lambdaParticleOptions, AlgorithmListener algorithmListener) OST Constructor.- Parameters:
lambdaInterface
- defines Lambda and dU/dL.potential
- defines the Potential energy.histogramData
- contains histogram restart data.lambdaData
- contains lambda restart data.properties
- defines System properties.dynamicsOptions
- defines molecular dynamics parameters.lambdaParticleOptions
- defines lambda particle parameters.algorithmListener
- the AlgorithmListener to be notified of progress.
-
-
Method Details
-
addHistogram
Add an alternate Histogram this OST can use.- Parameters:
histogramData
- Settings to use for the new Histogram.
-
dEdLZeroAtEnds
public boolean dEdLZeroAtEnds()Returns true if dUdL is guaranteed to be zero at 0 and 1. Default implementation is to return false.- Specified by:
dEdLZeroAtEnds
in interfaceLambdaInterface
- Returns:
- True if dUdL is guaranteed 0 at endpoints.
-
destroy
public boolean destroy()Destroys this Potential and frees up any associated resources, particularly worker Threads. Default implementation is to return true (assume destruction successful).- Specified by:
destroy
in interfaceOptimizationInterface
- Returns:
- If resource reclamation successful, or resources already reclaimed.
-
energy
public double energy(double[] x) Compute the force field + bias energy.- Specified by:
energy
in interfaceOptimizationInterface
- Parameters:
x
- Input parameters.- Returns:
- Function value at
x
.
-
energyAndGradient
public double energyAndGradient(double[] x, double[] gradient) This method is called repeatedly to compute the function energy and gradient.- Specified by:
energyAndGradient
in interfaceOptimizationInterface
- Parameters:
x
- Input parameters.gradient
- Output gradients with respect to each parameter.- Returns:
- Function value at
x
.
-
getAcceleration
public double[] getAcceleration(double[] acceleration) getAcceleration.- Specified by:
getAcceleration
in interfacePotential
- Parameters:
acceleration
- an array ofinvalid reference
double
- Returns:
- an array of
invalid reference
double
-
getAllHistograms
-
getCoordinates
public double[] getCoordinates(double[] doubles) Load the current value of the parameters. If the supplied array is null or not large enough, a new one should be created. The filled array is returned.- Specified by:
getCoordinates
in interfaceOptimizationInterface
- Parameters:
doubles
- Supplied array.- Returns:
- The array filled with parameter values.
-
getCrystal
Get the Crystal instance that specifies the periodic boundary conditions and symmetry.- Specified by:
getCrystal
in interfaceCrystalPotential
- Returns:
- a Crystal instance.
-
setCrystal
Set the Crystal instance that specifies the periodic boundary conditions and symmetry.- Specified by:
setCrystal
in interfaceCrystalPotential
- Parameters:
crystal
- a Crystal instance.
-
getEnergyCount
public long getEnergyCount()Returns the number of energy evaluations performed by this OST, including those picked up in the lambda file.- Returns:
- Number of energy steps taken by this walker.
-
getEnergyTermState
Get the Potential Energy terms that is active.- Specified by:
getEnergyTermState
in interfacePotential
- Returns:
- the STATE
-
setEnergyTermState
Set the Potential Energy terms that should be active.- Specified by:
setEnergyTermState
in interfacePotential
- Parameters:
state
- include FAST varying energy terms, SLOW varying energy terms or BOTH.
-
getForceFieldEnergy
public double getForceFieldEnergy()Getter for the fieldforceFieldEnergy
.- Returns:
- a double.
-
getHistogram
Return the current 2D Histogram of counts.- Returns:
- the Histogram.
-
getLambda
public double getLambda()Getter for the fieldlambda
.- Specified by:
getLambda
in interfaceLambdaInterface
- Returns:
- a double.
-
setLambda
public void setLambda(double lambda) Setter for the fieldlambda
.- Specified by:
setLambda
in interfaceLambdaInterface
- Parameters:
lambda
- a double.
-
getMass
public double[] getMass()Get the mass of each degree of freedom. This is required for molecular dynamics. -
getNumberOfVariables
public int getNumberOfVariables()Get the number of variables being operated on.- Specified by:
getNumberOfVariables
in interfaceOptimizationInterface
- Returns:
- Number of variables.
-
getOptimizationParameters
Return the OST optimization information.- Returns:
- The OST optimization parameters.
-
getPotentialEnergy
getPotentialEnergy.- Returns:
- a
Potential
object.
-
getPreviousAcceleration
public double[] getPreviousAcceleration(double[] previousAcceleration) getPreviousAcceleration.- Specified by:
getPreviousAcceleration
in interfacePotential
- Parameters:
previousAcceleration
- an array ofinvalid reference
double
- Returns:
- an array of
invalid reference
double
-
getScaling
public double[] getScaling()Get the problem scaling.- Specified by:
getScaling
in interfaceOptimizationInterface
- Returns:
- The scaling value used for each variable.
-
setScaling
public void setScaling(double[] scaling) Scale the problem. A good choice for optimization is the square root of the median eigenvalue of a typical Hessian.- Specified by:
setScaling
in interfaceOptimizationInterface
- Parameters:
scaling
- The scaling value to use for each variable.
-
getTotalEnergy
public double getTotalEnergy()Get the total energy of the system- Specified by:
getTotalEnergy
in interfaceOptimizationInterface
- Returns:
- the total energy
-
getTotaldEdLambda
public double getTotaldEdLambda()getTotaldEdLambda.- Returns:
- a double.
-
getVariableTypes
Get the type of all variables.Return a reference to each variables type.
- Specified by:
getVariableTypes
in interfacePotential
- Returns:
- The VARIABLE_TYPE of each variable.
-
getVelocity
public double[] getVelocity(double[] velocity) getVelocity.- Specified by:
getVelocity
in interfacePotential
- Parameters:
velocity
- an array ofinvalid reference
double
- Returns:
- an array of
invalid reference
double
-
getd2EdL2
public double getd2EdL2()Get the 2nd partial derivative of the energy with respect to lambda.- Specified by:
getd2EdL2
in interfaceLambdaInterface
- Returns:
- d2EdL2
-
getdEdL
public double getdEdL()Get the partial derivative of the energy with respect to lambda.- Specified by:
getdEdL
in interfaceLambdaInterface
- Returns:
- dEdL
-
getdEdXdL
public void getdEdXdL(double[] gradient) Get the gradient of dEdL with respect to each parameter.- Specified by:
getdEdXdL
in interfaceLambdaInterface
- Parameters:
gradient
- - A double array of length the number of parameters in the model (commonly 3 * number of atoms).
-
logOutputFiles
public void logOutputFiles(int index) -
setAcceleration
public void setAcceleration(double[] acceleration) setAcceleration.- Specified by:
setAcceleration
in interfacePotential
- Parameters:
acceleration
- an array ofinvalid reference
double
-
setHardWallConstraint
public void setHardWallConstraint(boolean hardWallConstraint) If this flag is true, (lambda, dU/dL) Monte Carlo samples that have no weight in the Histogram are rejected.- Parameters:
hardWallConstraint
- If true, MC samples outside the current range are rejected.
-
setMolecularAssembly
-
setPreviousAcceleration
public void setPreviousAcceleration(double[] previousAcceleration) setPreviousAcceleration.- Specified by:
setPreviousAcceleration
in interfacePotential
- Parameters:
previousAcceleration
- an array ofinvalid reference
double
-
setPropagateLambda
public void setPropagateLambda(boolean propagateLambda) Indicate if the Lambda extended system particle should be propagated using Langevin dynamics.- Parameters:
propagateLambda
- If true, Lambda will be propagated using Langevin dynamics.
-
getPropagateLambda
public boolean getPropagateLambda()If true, the Lambda extended system particle is propagated using Langevin dynamics. -
setVelocity
public void setVelocity(double[] velocity) setVelocity.- Specified by:
setVelocity
in interfacePotential
- Parameters:
velocity
- an array ofinvalid reference
double
-
switchHistogram
public void switchHistogram(int index) Switch to an alternate Histogram.- Parameters:
index
- Index of the Histogram to use.
-
writeAdditionalRestartInfo
public void writeAdditionalRestartInfo(boolean recursive) Description copied from interface:Potential
Writes additional restart information, if any (e.g. OST histogram and lambda restart files). The recursive flag should generally only be true for the top-level Potential called.- Specified by:
writeAdditionalRestartInfo
in interfacePotential
- Parameters:
recursive
- Whether to have all underlying Potentials write additional restart info.
-