mod hvp¶
- module hvp¶
Hessian-vector products of a potential handle.
The product is
H v, whereHis the Hessian of the energy with respect to the3NCartesian positions andvis a direction laid out like the positions ([n_atoms, 3], row-major). A minimum-mode search (Lanczos, dimer) appliesHto many directions at one geometry. With only a force callback each product is a difference of two force evaluations, and one of them is the centre the search has not moved from.A handle keeps the forces of the last centre it evaluated, keyed on the bits of the positions, the atomic numbers and the cell.
kforward products at one centre therefore costk + 1force calls instead of2k. Another geometry, species list or cell is a new centre, andrgpot_potential_t::invalidate_hvp_centredrops the cached one when the potential itself changes. A potential that knows its Hessian registers aHessianVectorCallbackand the products make no force call at all.Scheme
Force calls per product
Error
RGPOT_HVP_FORWARD1, plus 1 for each new centre
O(h)RGPOT_HVP_CENTRAL2
O(h^2)RGPOT_HVP_ANALYTIC0
that of the callback
his the length of the displacement along the unit directionv / |v|, in the units of the positions. The difference is scaled back by|v|, so the product is homogeneous in|v|; the forward scheme is not linear inv, because itsO(h)term keeps its sign whenvdoes. Neither finite difference can beO(h^2)and cost one call per product: the forward error is(h / 2) T(u, u) |v|, withTthe third derivative, and cancelling it takes the second evaluation that the central scheme makes.Types
- type HessianVectorCallback¶
Analytic Hessian-vector product of a potential.
The callback receives the
user_dataof the potential handle, the geometry, a direction of3 * n_atomsdoubles and room for as many doubles of output. It writesH directiontohv_outand returnsRGPOT_SUCCESS, or an error status code.directionandhv_outdo not overlap.
Variables
- const RGPOT_HVP_DEFAULT_STEP: f64¶
Displacement length used when a caller passes a step of 0.
Enums
- enum HvpError¶
Why a Hessian-vector request failed.
- Invalid(String)¶
A malformed argument or callback result. C callers see
RGPOT_INVALID_PARAMETERand this sentence inrgpot_last_error.
- Callback(rgpot_status_t)¶
A callback returned this status. Its own
rgpot_last_errormessage, if it set one, is left in place.
Implementations
- impl HvpError¶
Functions
- fn status(&self) -> rgpot_status_t¶
The status a C caller receives.
Traits implemented
- enum rgpot_hvp_scheme_t¶
How a Hessian-vector product is computed.
- RGPOT_HVP_AUTO¶
The analytic callback when one is registered, otherwise forward.
- RGPOT_HVP_FORWARD¶
One displaced force call against the cached centre forces.
- RGPOT_HVP_CENTRAL¶
Two displaced force calls, one on each side of the centre.
- RGPOT_HVP_ANALYTIC¶
The registered callback. Refused when none is registered.
Implementations
- impl rgpot_hvp_scheme_t¶
Functions
- fn from_raw(raw: i32) -> Option<Self>¶
The scheme with this value, or
Nonefor a value the enum lacks.
Structs and Unions
- struct HvpCentre¶
Energy, variance and forces (
3 * n_atoms, row-major) at a centre.- energy: f64¶
- variance: f64¶
- forces: Vec<f64>¶
- struct rgpot_hvp_counts_t¶
Work done by the Hessian-vector entry points of one handle.
- products: u64¶
Products answered, a zero direction’s zero product included.
- force_calls: u64¶
Force callback invocations made for products and centres.
- centre_reused: u64¶
Requests answered from the cached centre without a force call.
- analytic: u64¶
Products answered by the analytic callback.