Package ffx.algorithms.dynamics
Class Barostat
java.lang.Object
ffx.algorithms.dynamics.Barostat
- All Implemented Interfaces:
CrystalPotential,OptimizationInterface,Potential
The Barostat class maintains constant pressure using random trial moves in lattice parameters,
which are consistent with the space group.
Frenkel and Smit, "Understanding Molecular Simulation, 2nd Edition", Academic Press, San Diego, CA, 2002; Section 5.4
- Author:
- Michael J. Schnieders
-
Nested Class Summary
Nested classes/interfaces inherited from interface ffx.numerics.Potential
Potential.STATE, Potential.VARIABLE_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionBarostat(MolecularAssembly molecularAssembly, CrystalPotential potential) Initialize the Barostat.Barostat(MolecularAssembly molecularAssembly, CrystalPotential potential, double temperature) Initialize the Barostat. -
Method Summary
Modifier and TypeMethodDescriptiondoubledensity()density.booleandestroy()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[] parameters) Load the current value of the parameters.Get the Crystal instance that specifies the periodic boundary conditions and symmetry.Get the CrystalPotential that this Barostat is applying to.Get the Potential Energy terms that is active.double[]getMass()Get the mass of each degree of freedom.intReturns the mean number of steps between barostat applications.intGet the number of variables being operated on.doubleGets the pressure of this Barostat in atm.double[]getPreviousAcceleration(double[] previousAcceleration) getPreviousAcceleration.double[]Get the problem scaling.doubleGet 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.booleanisActive()booleanRestrict the MC Barostat to isotropic moves.voidsetAcceleration(double[] acceleration) setAcceleration.voidsetActive(boolean active) Setter for the fieldactive.voidsetBarostatPrintFrequency(int frequency) Set the Barostat print frequency.voidsetCoordinates(double[] parameters) Set the current value of the parameters.voidsetCrystal(Crystal crystal) Set the Crystal instance that specifies the periodic boundary conditions and symmetry.voidsetDensity(double density) setDensity.voidSet the Potential Energy terms that should be active.voidsetIsotropic(boolean isotropic) Restrict the MC Barostat to isotropic moves.voidsetMaxAngleMove(double maxAngleMove) Setter for the fieldmaxAngleMove.voidsetMaxDensity(double maxDensity) Setter for the fieldmaxDensity.voidsetMaxVolumeMove(double maxVolumeMove) Setter for the fieldmaxVolumeMove.voidsetMeanBarostatInterval(int meanBarostatInterval) Setter for the fieldmeanBarostatInterval.voidsetMinDensity(double minDensity) Setter for the fieldminDensity.voidsetPressure(double pressure) Setter for the fieldpressure.voidsetPreviousAcceleration(double[] previousAcceleration) setPreviousAcceleration.voidsetScaling(double[] scaling) Scale the problem.voidsetTemperature(double temperature) Set the Metropolis Monte Carlo temperature.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, scaleCoordinates, scaleCoordinatesAndGradient, unscaleCoordinatesMethods inherited from interface ffx.numerics.Potential
getConstraints, writeAdditionalRestartInfo
-
Constructor Details
-
Barostat
Initialize the Barostat.- Parameters:
molecularAssembly- The molecular assembly to apply the MC barostat to.potential- aCrystalPotentialobject.
-
Barostat
public Barostat(MolecularAssembly molecularAssembly, CrystalPotential potential, double temperature) Initialize the Barostat.- Parameters:
molecularAssembly- The molecular assembly to apply the MC barostat to.potential- aCrystalPotentialobject.temperature- The Metropolis Monte Carlo temperature (Kelvin).
-
-
Method Details
-
density
public double density()density.- Returns:
- a double.
-
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.
-
isIsotropic
public boolean isIsotropic()Restrict the MC Barostat to isotropic moves. The lattice angles are held fixed, and lattice lengths are scaled equally.- Returns:
- Returns true if only isotropic moves are allowed.
-
setIsotropic
public void setIsotropic(boolean isotropic) Restrict the MC Barostat to isotropic moves. The lattice angles are held fixed, and lattice lengths are scaled equally.- Parameters:
isotropic- If true, if only isotropic moves are allowed.
-
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[] 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:
getCoordinatesin interfaceOptimizationInterface- Parameters:
parameters- Supplied array.- Returns:
- The array filled with parameter values.
-
setCoordinates
public void setCoordinates(double[] parameters) Set the current value of the parameters. If the supplied array is null or not large enough, no action is taken.- Specified by:
setCoordinatesin interfaceOptimizationInterface- Parameters:
parameters- The array with parameter values.
-
getCrystal
Get the Crystal instance that specifies the periodic boundary conditions and symmetry.- Specified by:
getCrystalin interfaceCrystalPotential- Returns:
- a Crystal instance.
-
setCrystal
Set the Crystal instance that specifies the periodic boundary conditions and symmetry.- Specified by:
setCrystalin interfaceCrystalPotential- Parameters:
crystal- a Crystal instance.
-
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. -
getMeanBarostatInterval
public int getMeanBarostatInterval()Returns the mean number of steps between barostat applications.- Returns:
- Mean steps between barostat applications.
-
setMeanBarostatInterval
public void setMeanBarostatInterval(int meanBarostatInterval) Setter for the fieldmeanBarostatInterval.- Parameters:
meanBarostatInterval- The mean number of steps between barostat applications.
-
getNumberOfVariables
public int getNumberOfVariables()Get the number of variables being operated on.- Specified by:
getNumberOfVariablesin interfaceOptimizationInterface- Returns:
- Number of variables.
-
getPressure
public double getPressure()Gets the pressure of this Barostat in atm.- Returns:
- Pressure in atm.
-
setPressure
public void setPressure(double pressure) Setter for the fieldpressure.- Parameters:
pressure- a double.
-
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
-
getUnderlyingPotentials
Description copied from interface:OptimizationInterfaceReturns 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:
getUnderlyingPotentialsin interfaceOptimizationInterface- Returns:
- By default, an empty list.
-
getCrystalPotential
Get the CrystalPotential that this Barostat is applying to.- Returns:
- The CrystalPotential.
-
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.
-
isActive
public boolean isActive() -
setActive
public void setActive(boolean active) Setter for the fieldactive.- Parameters:
active- a boolean.
-
setAcceleration
public void setAcceleration(double[] acceleration) setAcceleration.- Specified by:
setAccelerationin interfacePotential- Parameters:
acceleration- an array of double values.
-
setDensity
public void setDensity(double density) setDensity.- Parameters:
density- a double.
-
setMaxAngleMove
public void setMaxAngleMove(double maxAngleMove) Setter for the fieldmaxAngleMove.- Parameters:
maxAngleMove- a double.
-
setMaxVolumeMove
public void setMaxVolumeMove(double maxVolumeMove) Setter for the fieldmaxVolumeMove.- Parameters:
maxVolumeMove- a double.
-
setMaxDensity
public void setMaxDensity(double maxDensity) Setter for the fieldmaxDensity.- Parameters:
maxDensity- a double.
-
setMinDensity
public void setMinDensity(double minDensity) Setter for the fieldminDensity.- Parameters:
minDensity- a double.
-
setBarostatPrintFrequency
public void setBarostatPrintFrequency(int frequency) Set the Barostat print frequency.- Parameters:
frequency- The number of Barostat moves between print statements.
-
setPreviousAcceleration
public void setPreviousAcceleration(double[] previousAcceleration) setPreviousAcceleration.- Specified by:
setPreviousAccelerationin interfacePotential- Parameters:
previousAcceleration- an array of double values.
-
setTemperature
public void setTemperature(double temperature) Set the Metropolis Monte Carlo temperature.- Parameters:
temperature- Temperature (Kelvin).
-
setVelocity
public void setVelocity(double[] velocity) setVelocity.- Specified by:
setVelocityin interfacePotential- Parameters:
velocity- an array of double values.
-