Package ffx.xray
Class XRayEnergy
java.lang.Object
ffx.xray.XRayEnergy
- All Implemented Interfaces:
CrystalPotential
,OptimizationInterface
,Potential
,LambdaInterface
Combine the X-ray target and chemical potential energy.
- 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
ConstructorDescriptionXRayEnergy
(DiffractionData diffractionData, int nXYZ, int nB, int nOCC, RefinementMinimize.RefinementMode refinementMode) Diffraction data energy target -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
energyAndGradient
(double[] x, double[] g) This method is called repeatedly to compute the function energy and gradient.double[]
getAcceleration
(double[] acceleration) getAcceleration.double[]
getCoordinates
(double[] x) 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.Get the Potential Energy terms that is active.double
Get the current value of the state variable.double[]
getMass()
Get the mass of each degree of freedom.int
getNB()
get the number of B factor parameters being fitint
getNOcc()
get the number of occupancy parameters being fitint
Get the number of variables being operated on.int
getNXYZ()
Get the number of xyz parameters being fit.double[]
getPreviousAcceleration
(double[] previousAcceleration) getPreviousAcceleration.Getter for the fieldrefinementMode
.double[]
Get the problem scaling.double
Get the total energy of the systemGet the type of all variables.double[]
getVelocity
(double[] velocity) getVelocity.void
setAcceleration
(double[] acceleration) setAcceleration.void
setCoordinates
(double[] x) set atomic xyz coordinates based on current positionvoid
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
setLambda
(double lambda) Set the current value of the state variable.void
setNB
(int nB) set the number of B factor parametersvoid
setNOcc
(int nOCC) set the number of occupancy parametersvoid
setNXYZ
(int nXYZ) set the number of xyz parametersvoid
setOccupancies
(double[] x) set atom occupancies based on current positionvoid
setPreviousAcceleration
(double[] previousAcceleration) setPreviousAcceleration.void
setRefinementMode
(RefinementMinimize.RefinementMode refinementmode) Setter for the fieldrefinementMode
.void
setScaling
(double[] scaling) Scale the problem.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
energy, energyAndGradient, getUnderlyingPotentials, scaleCoordinates, scaleCoordinatesAndGradient, unscaleCoordinates
Methods inherited from interface ffx.numerics.Potential
getConstraints, writeAdditionalRestartInfo
-
Field Details
-
lambda
protected double lambda
-
-
Constructor Details
-
XRayEnergy
public XRayEnergy(DiffractionData diffractionData, int nXYZ, int nB, int nOCC, RefinementMinimize.RefinementMode refinementMode) Diffraction data energy target- Parameters:
diffractionData
-DiffractionData
object to associate with the targetnXYZ
- number of xyz parametersnB
- number of b factor parametersnOCC
- number of occupancy parametersrefinementMode
- theRefinementMinimize.RefinementMode
type of refinement requested
-
-
Method Details
-
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
.
-
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
- Parameters:
x
- Input parameters.g
- 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
-
getCoordinates
public double[] getCoordinates(double[] x) 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:
x
- 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.
-
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.
-
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. -
getNB
public int getNB()get the number of B factor parameters being fit- Returns:
- the number of B factor parameters
-
setNB
public void setNB(int nB) set the number of B factor parameters- Parameters:
nB
- requested number of B factor parameters
-
getNOcc
public int getNOcc()get the number of occupancy parameters being fit- Returns:
- the number of occupancy parameters
-
setNOcc
public void setNOcc(int nOCC) set the number of occupancy parameters- Parameters:
nOCC
- requested number of occupancy parameters
-
getNXYZ
public int getNXYZ()Get the number of xyz parameters being fit.- Returns:
- the number of xyz parameters
-
setNXYZ
public void setNXYZ(int nXYZ) set the number of xyz parameters- Parameters:
nXYZ
- requested number of xyz parameters
-
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
-
getRefinementMode
Getter for the fieldrefinementMode
.- Returns:
- a
RefinementMinimize.RefinementMode
object.
-
setRefinementMode
Setter for the fieldrefinementMode
.- Parameters:
refinementmode
- aRefinementMinimize.RefinementMode
object.
-
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
-
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).
-
setAcceleration
public void setAcceleration(double[] acceleration) setAcceleration.- Specified by:
setAcceleration
in interfacePotential
- Parameters:
acceleration
- an array ofinvalid reference
double
-
setCoordinates
public void setCoordinates(double[] x) set atomic xyz coordinates based on current position- Parameters:
x
- current parameters to set coordinates with
-
setOccupancies
public void setOccupancies(double[] x) set atom occupancies based on current position- Parameters:
x
- current parameters to set occupancies with
-
setPreviousAcceleration
public void setPreviousAcceleration(double[] previousAcceleration) setPreviousAcceleration.- Specified by:
setPreviousAcceleration
in interfacePotential
- Parameters:
previousAcceleration
- an array ofinvalid reference
double
-
setVelocity
public void setVelocity(double[] velocity) setVelocity.- Specified by:
setVelocity
in interfacePotential
- Parameters:
velocity
- an array ofinvalid reference
double
-