Package ffx.xray
Class RefinementEnergy
java.lang.Object
ffx.xray.RefinementEnergy
- All Implemented Interfaces:
AlgorithmListener
,CrystalPotential
,OptimizationInterface
,Potential
,LambdaInterface
public class RefinementEnergy
extends Object
implements LambdaInterface, CrystalPotential, AlgorithmListener
Combine the X-ray target and chemical potential energy using the
CrystalPotential
interface- Since:
- 1.0
- Author:
- Timothy D. Fenn, Michael J. Schnieders
-
Nested Class Summary
Nested classes/interfaces inherited from interface ffx.numerics.Potential
Potential.STATE, Potential.VARIABLE_TYPE
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRefinementEnergy
(DataContainer data, RefinementMinimize.RefinementMode refinementMode) RefinementEnergy Constructor.RefinementEnergy
(DataContainer data, RefinementMinimize.RefinementMode refinementMode, double[] optimizationScaling) RefinementEnergy Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
algorithmUpdate
(MolecularAssembly active) After a successful step or interval of an algorithm, this method of the listener will be called.boolean
destroy()
Destroys this Potential and frees up any associated resources, particularly worker Threads.double
energy
(double[] x) This method is called repeatedly to compute the function energy.double
energy
(double[] x, boolean print) 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 print) This method is called repeatedly to compute the function energy and gradient.double[]
getAcceleration
(double[] acceleration) getAcceleration.Atom[]
getActiveAtoms.double[]
getCoordinates
(double[] parameters) 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.Getter for the fielddataEnergy
.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.Get the Potential Energy terms that is active.double
get the current kT scaling weightdouble
Get the current value of the state variable.double[]
getMass()
Get the mass of each degree of freedom.int
Get the number of variables being operated on.double[]
getPreviousAcceleration
(double[] previousAcceleration) getPreviousAcceleration.boolean
Getter for the fieldprintOnFailure
.double[]
Get the problem scaling.Getter for the fieldthermostat
.double
Get the total energy of the systemReturns a List of Potentials this Potential depends on with a recursive search, excluding the top level of this call.Get the type of all variables.double[]
getVelocity
(double[] velocity) getVelocity.double
Get the current data weight (wA).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
setKTScale
(double ktscale) set the current kT scaling weightvoid
setLambda
(double lambda) Set the current value of the state variable.void
setPreviousAcceleration
(double[] previousAcceleration) setPreviousAcceleration.void
setPrintOnFailure
(boolean onFail, boolean override) Sets the printOnFailure flag; if override is true, over-rides any existing property.void
setScaling
(double[] scaling) Scale the problem.void
setThermostat
(Thermostat thermostat) Setter for the fieldthermostat
.void
setVelocity
(double[] velocity) setVelocity.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ffx.potential.bonded.LambdaInterface
dEdLZeroAtEnds
Methods inherited from interface ffx.numerics.OptimizationInterface
scaleCoordinates, scaleCoordinatesAndGradient, unscaleCoordinates
Methods inherited from interface ffx.numerics.Potential
getConstraints, writeAdditionalRestartInfo
-
Field Details
-
thermostat
A thermostat instance.
-
-
Constructor Details
-
RefinementEnergy
RefinementEnergy Constructor.- Parameters:
data
- inputdata
for refinementrefinementMode
-RefinementMinimize.RefinementMode
for refinement
-
RefinementEnergy
public RefinementEnergy(DataContainer data, RefinementMinimize.RefinementMode refinementMode, double[] optimizationScaling) RefinementEnergy Constructor.- Parameters:
data
- inputdata
for refinementrefinementMode
-RefinementMinimize.RefinementMode
for refinementoptimizationScaling
- scaling of refinement parameters
-
-
Method Details
-
algorithmUpdate
After a successful step or interval of an algorithm, this method of the listener will be called.- Specified by:
algorithmUpdate
in interfaceAlgorithmListener
- Parameters:
active
- The system the algorithm is operating on.- Returns:
- A return of
true
indicates the algorithm continues.
-
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) This method is called repeatedly to compute the function energy.- Specified by:
energy
in interfaceOptimizationInterface
- Parameters:
x
- Input parameters.- Returns:
- Function value at
x
.
-
energy
public double energy(double[] x, boolean print) 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
- Parameters:
x
- Input parameters.print
- 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.Implementation of the
CrystalPotential
interface for the RefinementEnergy.- Specified by:
energyAndGradient
in interfaceOptimizationInterface
- 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 print) This method is called repeatedly to compute the function energy and gradient. The verbose flag may not be used by all implementations.Implementation of the
CrystalPotential
interface for the RefinementEnergy.- Specified by:
energyAndGradient
in interfaceOptimizationInterface
- Parameters:
x
- Input parameters.g
- Output gradients with respect to each parameter.print
- Display extra information.- 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
-
getActiveAtoms
getActiveAtoms.- Returns:
- an array of
Atom
objects.
-
getCoordinates
public double[] getCoordinates(double[] parameters) 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:
parameters
- 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.
-
getDataEnergy
Getter for the fielddataEnergy
.- Returns:
- a
CrystalPotential
object.
-
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.
-
getKTScale
public double getKTScale()get the current kT scaling weight- Returns:
- kT scale
-
setKTScale
public void setKTScale(double ktscale) set the current kT scaling weight- Parameters:
ktscale
- requested kT scale
-
getLambda
public double getLambda()Get the current value of the state variable.- Specified by:
getLambda
in interfaceLambdaInterface
- Returns:
- state
-
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
- 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.
-
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
-
getPrintOnFailure
public boolean getPrintOnFailure()Getter for the fieldprintOnFailure
.- Returns:
- a boolean.
-
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.
-
getThermostat
Getter for the fieldthermostat
.- Returns:
- a
Thermostat
object.
-
setThermostat
Setter for the fieldthermostat
.- Parameters:
thermostat
- aThermostat
object.
-
getTotalEnergy
public double getTotalEnergy()Get the total energy of the system- Specified by:
getTotalEnergy
in interfaceOptimizationInterface
- Returns:
- the total energy
-
getUnderlyingPotentials
Description copied from interface:OptimizationInterface
Returns a List of Potentials this Potential depends on with a recursive search, excluding the top level of this call. May not be implemented for all Potentials.- Specified by:
getUnderlyingPotentials
in interfaceOptimizationInterface
- Returns:
- By default, an empty list.
-
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
-
getXWeight
public double getXWeight()Get the current data weight (wA).- Returns:
- weight wA
-
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).
-
setAcceleration
public void setAcceleration(double[] acceleration) setAcceleration.- Specified by:
setAcceleration
in interfacePotential
- Parameters:
acceleration
- an array ofinvalid reference
double
-
setPreviousAcceleration
public void setPreviousAcceleration(double[] previousAcceleration) setPreviousAcceleration.- Specified by:
setPreviousAcceleration
in interfacePotential
- Parameters:
previousAcceleration
- an array ofinvalid reference
double
-
setPrintOnFailure
public void setPrintOnFailure(boolean onFail, boolean override) Sets the printOnFailure flag; if override is true, over-rides any existing property. Essentially sets the default value of printOnFailure for an algorithm. For example, rotamer optimization will generally run into force field issues in the normal course of execution as it tries unphysical self and 2-Body configurations, so the algorithm should not print out a large number of error PDBs.- Parameters:
onFail
- To setoverride
- Override properties
-
setVelocity
public void setVelocity(double[] velocity) setVelocity.- Specified by:
setVelocity
in interfacePotential
- Parameters:
velocity
- an array ofinvalid reference
double
-