etomica.util.numerical
Class CalcGradientDifferentiable

java.lang.Object
  extended by etomica.util.numerical.CalcGradientDifferentiable
All Implemented Interfaces:
AtomLeafAgentManager.AgentSource, FunctionMultiDimensional, FunctionMultiDimensionalDifferentiable

public class CalcGradientDifferentiable
extends Object
implements FunctionMultiDimensionalDifferentiable, AtomLeafAgentManager.AgentSource

Uses finite difference methods to determine the second order differential of the potential (i.e. dF/dx). Part of a larger scheme, a user may employ this to fill a two-dimensional array of changes in molecule A's Force with respect to the movement of other molecules.


Field Summary
 IteratorDirective allAtoms
           
 IBox box
           
 double forceConstant
           
 IPotentialMaster potentialMaster
           
 
Constructor Summary
CalcGradientDifferentiable(IBox aBox, IPotentialMaster aPotentialMaster, IMoleculeList movableSet, ISpace _space)
           
 
Method Summary
 double df(int[] d, double[] position)
          Returns the derivative indicated by the array d evaluated at the given point x.
 double[] df2(int[] d, double[] position)
          Uses the potential's force calculation at different displacements of a molecule in X, Y and Z to determine the second derivative of the potential.
 double f(double[] position)
           
 Class getAgentClass()
          Returns the Class of the agent.
 int getDimension()
          The dimension of the space of independent variables.
 Object makeAgent(IAtom a)
          Returns an agent for the given Atom.
 void releaseAgent(Object agent, IAtom atom)
          This informs the agent source that the agent is going away and that the agent source should disconnect the agent from other elements
 void setComponent(int aGradDcomponent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

box

public IBox box

potentialMaster

public IPotentialMaster potentialMaster

forceConstant

public double forceConstant

allAtoms

public IteratorDirective allAtoms
Constructor Detail

CalcGradientDifferentiable

public CalcGradientDifferentiable(IBox aBox,
                                  IPotentialMaster aPotentialMaster,
                                  IMoleculeList movableSet,
                                  ISpace _space)
Method Detail

setComponent

public void setComponent(int aGradDcomponent)

f

public double f(double[] position)
Specified by:
f in interface FunctionMultiDimensional

df

public double df(int[] d,
                 double[] position)
Description copied from interface: FunctionMultiDimensionalDifferentiable
Returns the derivative indicated by the array d evaluated at the given point x. The array d should be the same length as x. Each entry of d specifies the order of the derivative taken with respect to the corresponding variable in x. For example, for a function on a 2-dimensional space, d = {2,0}, indicates d2f/dx[0]^2, while d = {1,1}, indicates d2f/dx[0]dx[1]; d = {2,1} indicates d3f/dx[0]^2dx[1]; etc.

Specified by:
df in interface FunctionMultiDimensionalDifferentiable

df2

public double[] df2(int[] d,
                    double[] position)
Uses the potential's force calculation at different displacements of a molecule in X, Y and Z to determine the second derivative of the potential. Here, H (our displacement distance) is equal to 0.0001.

Parameters:
d - A one-dimensional array describing what column of our larger, global dF/dx array we are working with.
position - A one dimensional array of doubles describing the molecules positions.
Returns:

getDimension

public int getDimension()
Description copied from interface: FunctionMultiDimensional
The dimension of the space of independent variables. The length of the array passed to the f should be equal to this quantity.

Specified by:
getDimension in interface FunctionMultiDimensional

getAgentClass

public Class getAgentClass()
Description copied from interface: AtomLeafAgentManager.AgentSource
Returns the Class of the agent. This is used to create an array of the appropriate Class.

Specified by:
getAgentClass in interface AtomLeafAgentManager.AgentSource

makeAgent

public Object makeAgent(IAtom a)
Description copied from interface: AtomLeafAgentManager.AgentSource
Returns an agent for the given Atom.

Specified by:
makeAgent in interface AtomLeafAgentManager.AgentSource

releaseAgent

public void releaseAgent(Object agent,
                         IAtom atom)
Description copied from interface: AtomLeafAgentManager.AgentSource
This informs the agent source that the agent is going away and that the agent source should disconnect the agent from other elements

Specified by:
releaseAgent in interface AtomLeafAgentManager.AgentSource