Class Scine::Utils::NumericalHessianCalculator¶
-
class
NumericalHessianCalculator
¶ This class calculates the Hessian and, optionally, the dipole gradient (semi-)numerically.
Useful if analytic second derivatives are not available.
calculateFromEnergyDifferences uses the following, where D = delta / 2: d^2E/dx^2 = 1 / delta^2 * (E(x-2D) - 2 * E(x) + E(x+2D)) d^2E/dxdy = 1 / delta^2 * (E(x+D,y+D) - E(x+D,y-D) - E(x-D,y+D) + E(x-D,y-D))
calculateFromGradientDifferences uses the following, where D = delta / 2: d^2E/dxdy = 1 / (2*delta) * (g_j(i+D,j) - g_j(i-D,j) + g_i(i,j+D) - g_i(i,j-D))
The second formulation is more stable numerically and is used as default.
In order to calculate the dipole gradient, from each displacement the dipole is calculated. dmu/dx_i = 1 / (2*delta) * (mu_x(x_i + delta) - mu_x(x_i - delta)) Only 3N calculations are needed to fill the 3Nx3 dipole gradient matrix, as the dipole comes as a x,y,z vector at each single point calculation.
Public Functions
-
Results
calculate
(double delta = defaultDelta)¶ Calcualtes the hessian matrix and, if needed, the dipole gradient.
- Return
A Results class with an hessian matrix and, if needed, a dipole gradient.
- Parameters
delta
: The step size for the numerical derivative.
-
HessianMatrix
calculateFromEnergyDifferences
(double delta)¶ This method can ONLY calculate the hessian matrix, not the dipole gradient.
-
Results
calculateFromGradientDifferences
(double delta)¶ This method calculated the hessian matrix from the gradient differences and the dipole gradient as dipole difference for each displacement.
-
void
requiredDipoleGradient
(bool dipoleGradient)¶ Sets whether the dipole gradient is also calculated.
-
Results