class rgpot::HessianVectorCache¶
Overview¶
Centre forces and counters for Hessian-vector products. More…
#include <HessianVector.hpp>
class HessianVectorCache {
public:
// structs
struct Cached;
struct Geometry;
struct Key;
// construction
HessianVectorCache();
HessianVectorCache(const HessianVectorCache&);
// methods
HessianVectorCache& operator=(const HessianVectorCache&);
template <ForceKernel Pot>
HvpCentre centre(Pot& pot, const ForceInput& in);
template <ForceKernel Pot>
void apply(Pot& pot, const ForceInput& in, const double* v, double* hv, double step = 0.0, HvpScheme scheme = HvpScheme::Auto);
void invalidate();
HvpCounts counts() const;
void resetCounts();
};
Detailed Documentation¶
Centre forces and counters for Hessian-vector products.
Safe to share between threads; the lock covers the cached centre, not the force calls. The potential passed to each call must be the one the cache was filled with, or invalidate() must be called in between.
Methods¶
template <ForceKernel Pot>
HvpCentre centre(Pot& pot, const ForceInput& in)
Energy and forces at in.
Served from the cached centre when its positions, species and cell carry the same bits, otherwise one force call that becomes the centre. A search that needs the centre forces asks here, so the products that follow reuse them.
template <ForceKernel Pot>
void apply(Pot& pot, const ForceInput& in, const double* v, double* hv, double step = 0.0, HvpScheme scheme = HvpScheme::Auto)
Write \(H v\) to hv.
v and hv hold 3*in.nAtoms doubles and must not overlap. step 0 selects kHvpDefaultStep. A zero direction gives a zero product without a call.
Parameters:
std::invalid_argument |
for a malformed request. |
std::domain_error |
when the kernel returns a non-finite value. |
void invalidate()
Drop the cached centre. Call it when the potential changes while the geometry does not.
void resetCounts()
Zero the counters. The cached centre stays.