Package ffx.potential
Class XtalEnergy
java.lang.Object
ffx.potential.XtalEnergy
- All Implemented Interfaces:
OptimizationInterface,Potential
This class computes the energy and Cartesian coordinate gradient, plus finite difference
derivatives of lattice parameters.
- Since:
- 1.0
- Author:
- Jooyeon Park
-
Nested Class Summary
Nested classes/interfaces inherited from interface ffx.numerics.Potential
Potential.STATE, Potential.VARIABLE_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionXtalEnergy(ForceFieldEnergy forceFieldEnergy, MolecularAssembly molecularAssembly) Constructor for XtalEnergy.XtalEnergy(ForceFieldEnergy forceFieldEnergy, MolecularAssembly molecularAssembly, boolean latticeOnly) Constructor for XtalEnergy. -
Method Summary
Modifier and TypeMethodDescriptionbooleandestroy()Destroys this Potential and frees up any associated resources, particularly worker Threads.doubleenergy(double[] x) 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.double[]getAcceleration(double[] acceleration) getAcceleration.double[]getCoordinates(double[] x) Load the current value of the parameters.Get the Potential Energy terms that is active.double[]getMass()Get the mass of each degree of freedom.intGet the number of variables being operated on.double[]getPreviousAcceleration(double[] previousAcceleration) getPreviousAcceleration.double[]Get the problem scaling.doubleGet the total energy of the systemGet the type of all variables.double[]getVelocity(double[] velocity) getVelocity.voidsetAcceleration(double[] acceleration) setAcceleration.voidsetCoordinates(double[] x) Sets atomic coordinates and lattice parameters.voidSet the Potential Energy terms that should be active.voidsetFractionalCoordinateMode(MolecularAssembly.FractionalMode fractionalMode) setFractionalCoordinateMode.voidsetPreviousAcceleration(double[] previousAcceleration) setPreviousAcceleration.voidsetScaling(double[] scaling) Scale the problem.voidsetVelocity(double[] velocity) setVelocity.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ffx.numerics.OptimizationInterface
energy, energyAndGradient, getUnderlyingPotentials, scaleCoordinates, scaleCoordinatesAndGradient, unscaleCoordinatesMethods inherited from interface ffx.numerics.Potential
getConstraints, writeAdditionalRestartInfo
-
Constructor Details
-
XtalEnergy
Constructor for XtalEnergy.- Parameters:
forceFieldEnergy- aForceFieldEnergyobject.molecularAssembly- aMolecularAssemblyobject.
-
XtalEnergy
public XtalEnergy(ForceFieldEnergy forceFieldEnergy, MolecularAssembly molecularAssembly, boolean latticeOnly) Constructor for XtalEnergy.- Parameters:
forceFieldEnergy- aForceFieldEnergyobject.molecularAssembly- aMolecularAssemblyobject.latticeOnly- if true, only lattice parameters are optimized.
-
-
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:
destroyin 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:
energyin 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:
energyAndGradientin 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:
getAccelerationin interfacePotential- Parameters:
acceleration- an array of double values.- Returns:
- an array of double values.
-
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:
getCoordinatesin interfaceOptimizationInterface- Parameters:
x- Supplied array.- Returns:
- The array filled with parameter values.
-
getEnergyTermState
Get the Potential Energy terms that is active.- Specified by:
getEnergyTermStatein interfacePotential- Returns:
- the STATE
-
setEnergyTermState
Set the Potential Energy terms that should be active.- Specified by:
setEnergyTermStatein interfacePotential- Parameters:
state- include FAST varying energy terms, SLOW varying energy terms or BOTH.
-
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:
getNumberOfVariablesin interfaceOptimizationInterface- Returns:
- Number of variables.
-
getPreviousAcceleration
public double[] getPreviousAcceleration(double[] previousAcceleration) getPreviousAcceleration.- Specified by:
getPreviousAccelerationin interfacePotential- Parameters:
previousAcceleration- an array of double values.- Returns:
- an array of double values.
-
getScaling
public double[] getScaling()Get the problem scaling.- Specified by:
getScalingin 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:
setScalingin interfaceOptimizationInterface- Parameters:
scaling- The scaling value to use for each variable.
-
getTotalEnergy
public double getTotalEnergy()Get the total energy of the system- Specified by:
getTotalEnergyin interfaceOptimizationInterface- Returns:
- the total energy
-
getVariableTypes
Get the type of all variables.- Specified by:
getVariableTypesin interfacePotential- Returns:
- The VARIABLE_TYPE of each variable.
-
getVelocity
public double[] getVelocity(double[] velocity) getVelocity.- Specified by:
getVelocityin interfacePotential- Parameters:
velocity- an array of double values.- Returns:
- an array of double values.
-
setAcceleration
public void setAcceleration(double[] acceleration) setAcceleration.- Specified by:
setAccelerationin interfacePotential- Parameters:
acceleration- an array of double values.
-
setFractionalCoordinateMode
setFractionalCoordinateMode.- Parameters:
fractionalMode- aMolecularAssembly.FractionalModeobject.
-
setPreviousAcceleration
public void setPreviousAcceleration(double[] previousAcceleration) setPreviousAcceleration.- Specified by:
setPreviousAccelerationin interfacePotential- Parameters:
previousAcceleration- an array of double values.
-
setVelocity
public void setVelocity(double[] velocity) setVelocity.- Specified by:
setVelocityin interfacePotential- Parameters:
velocity- an array of double values.
-
setCoordinates
public void setCoordinates(double[] x) Sets atomic coordinates and lattice parameters.- Specified by:
setCoordinatesin interfaceOptimizationInterface- Parameters:
x- First 3*nActive parameters are coordinates, next 6 are x parameters.
-