13 #ifndef QMCPLUSPLUS_ROTATION_HELPER_H 14 #define QMCPLUSPLUS_ROTATION_HELPER_H 24 std::vector<QMCTraits::ValueType>&
getMyVarsFull(RotatedSPOs& rot);
25 std::vector<std::vector<QMCTraits::ValueType>>&
getHistoryParams(RotatedSPOs& rot);
32 RotatedSPOs(
const std::string& my_name, std::unique_ptr<SPOSet>&& spos);
36 std::string
getClassName()
const override {
return "RotatedSPOs"; }
72 const std::vector<ValueType>& param,
79 std::vector<ValueType>& param);
82 void apply_rotation(
const std::vector<ValueType>& param,
bool use_stored_copy);
89 const std::vector<ValueType>& old_param,
90 std::vector<ValueType>& new_param);
95 const std::vector<ValueType>& old_param,
98 std::vector<ValueType>& new_param,
107 void applyFullRotation(
const std::vector<ValueType>& full_param,
bool use_stored_copy);
129 std::unique_ptr<SPOSet>
makeClone()
const override;
157 const int& FirstIndex,
158 const int& LastIndex)
override;
164 int LastIndex)
override;
171 const std::vector<ValueType>& Coeff,
172 const std::vector<size_t>& C2node_up,
173 const std::vector<size_t>& C2node_dn,
186 const std::vector<int>& detData_up,
191 const std::vector<std::vector<int>>& lookup_tbl)
override;
197 const std::vector<ValueType>& Coeff,
198 const std::vector<size_t>& C2node_up,
199 const std::vector<size_t>& C2node_dn,
206 const std::vector<int>& detData_up,
207 const std::vector<std::vector<int>>& lookup_tbl)
override;
217 const std::vector<RealType>& Coeff,
218 const std::vector<size_t>& C2node_up,
219 const std::vector<size_t>& C2node_dn,
232 const std::vector<int>& detData_up,
237 const std::vector<std::vector<int>>& lookup_tbl);
243 const std::vector<RealType>& Coeff,
244 const std::vector<size_t>& C2node_up,
245 const std::vector<size_t>& C2node_dn,
252 const std::vector<int>& detData_up,
253 const std::vector<std::vector<int>>& lookup_tbl);
281 Phi_->evaluateValue(P, iat, psi);
288 Phi_->evaluateVGL(P, iat, psi, dpsi, d2psi);
299 Phi_->evaluateVGL_spin(P, iat, psi, dpsi, d2psi, dspin_psi);
305 std::vector<ValueType>& ratios)
override 307 Phi_->evaluateDetRatios(VP, psi, psiinv, ratios);
314 std::vector<ValueType>& ratios,
317 int LastIndex)
override;
326 Phi_->evaluateVGH(P, iat, psi, dpsi, grad_grad_psi);
337 Phi_->evaluateVGHGH(P, iat, psi, dpsi, grad_grad_psi, grad_grad_grad_psi);
348 Phi_->evaluate_notranspose(P, first, last, logdet, dlogdet, d2logdet);
353 Phi_->evaluate_spin(P, iat, psi, dspin_psi);
363 Phi_->evaluate_notranspose(P, first, last, logdet, dlogdet, grad_grad_logdet);
372 GGGMatrix& grad_grad_grad_logdet)
override 374 Phi_->evaluate_notranspose(P, first, last, logdet, dlogdet, grad_grad_logdet, grad_grad_grad_logdet);
384 Phi_->evaluateGradSource(P, first, last, source, iat_src, grad_phi);
396 Phi_->evaluateGradSource(P, first, last, source, iat_src, grad_phi, grad_grad_phi, grad_lapl_phi);
408 const std::vector<const ValueType*>& invRow_ptr_list,
409 std::vector<std::vector<ValueType>>& ratios_list)
const override;
429 OffloadMatrix<ComplexType>& mw_dspin)
const override;
434 const std::vector<const ValueType*>& invRow_ptr_list,
436 std::vector<ValueType>& ratios,
437 std::vector<GradType>& grads)
const override;
442 const std::vector<const ValueType*>& invRow_ptr_list,
444 std::vector<ValueType>& ratios,
445 std::vector<GradType>& grads,
446 std::vector<ValueType>& spingrads)
const override;
bool isOptimizable() const override
Query if this SPOSet is optimizable.
void resetParametersExclusive(const opt_variables_type &active) override
reset
base class for Single-particle orbital sets
void writeVariationalParameters(hdf_archive &hout) override
Write the variational parameters for this object to the VP HDF file.
OrbitalSetTraits< ValueType >::HessVector HessVector
void set_use_global_rotation(bool use_global_rotation)
Use history list (false) or global rotation (true)
static void log_antisym_matrix(const ValueMatrix &mat, ValueMatrix &output)
void evaluate_notranspose(const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, HessMatrix &grad_grad_logdet) override
evaluate the values, gradients and hessians of this single-particle orbital for [first,last) particles
static void constructAntiSymmetricMatrix(const RotationIndices &rot_indices, const std::vector< ValueType > ¶m, ValueMatrix &rot_mat)
RotationIndices m_act_rot_inds_
std::vector< ValueType > myVarsFull_
Full set of rotation matrix parameters for use in global rotation method.
void evaluateDetRatios(const VirtualParticleSet &VP, ValueVector &psi, const ValueVector &psiinv, std::vector< ValueType > &ratios) override
evaluate determinant ratios for virtual moves, e.g., sphere move for nonlocalPP
helper functions for EinsplineSetBuilder
void evaluateValue(const ParticleSet &P, int iat, ValueVector &psi) override
evaluate the values of this single-particle orbital set
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi, const int &FirstIndex, const int &LastIndex) override
Parameter derivatives of the wavefunction and the Laplacian of the wavefunction.
void evaluate_spin(const ParticleSet &P, int iat, ValueVector &psi, ValueVector &dspin_psi) override
evaluate the values of this single-particle orbital set
void checkInVariablesExclusive(opt_variables_type &active) override
check in variational parameters to the global list of parameters used by the optimizer.
void evaluate_notranspose(const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, ValueMatrix &d2logdet) override
evaluate the values, gradients and laplacians of this single-particle orbital for [first...
size_t nel_major_
the number of electrons of the majority spin
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, int FirstIndex, int LastIndex) override
Parameter derivatives of the wavefunction.
bool isOMPoffload() const override
Query if this SPOSet uses OpenMP offload.
RotatedSPOs(const std::string &my_name, std::unique_ptr< SPOSet > &&spos)
std::vector< std::vector< ValueType > > history_params_
List of previously applied parameters.
ParticleSet::ParticleGradient myG_temp
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
opt_variables_type myVars
Optimizable variables.
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
static void createRotationIndices(int nel, int nmo, RotationIndices &rot_indices)
Timer accumulates time and call counts.
Attaches a unit to a Vector for IO.
void mw_evaluateVGLWithSpin(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const RefVector< ValueVector > &psi_v_list, const RefVector< GradVector > &dpsi_v_list, const RefVector< ValueVector > &d2psi_v_list, OffloadMatrix< ComplexType > &mw_dspin) const override
evaluate the values, gradients and laplacians and spin gradient of this single-particle orbital sets ...
OrbitalSetTraits< ValueType >::ValueVector ValueVector
void mw_evaluateDetRatios(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, const RefVector< ValueVector > &psi_list, const std::vector< const ValueType *> &invRow_ptr_list, std::vector< std::vector< ValueType >> &ratios_list) const override
evaluate determinant ratios for virtual moves, e.g., sphere move for nonlocalPP, of multiple walkers ...
void setRotationParameters(const std::vector< RealType > ¶m_list)
For now, this takes the real optimizable parameters (real rotation coefficients) and converts them to...
void evaluate_notranspose(const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, HessMatrix &grad_grad_logdet, GGGMatrix &grad_grad_grad_logdet) override
evaluate the values, gradients, hessians and third derivatives of this single-particle orbital for [f...
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
void buildOptVariables(size_t nel)
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
Specialized paritlce class for atomistic simulations.
std::unique_ptr< SPOSet > makeClone() const override
make a clone of itself every derived class must implement this to have threading working correctly...
ParticleSet::ParticleLaplacian myL_temp
Array< ValueType, 3, OffloadPinnedAllocator< ValueType > > OffloadMWVGLArray
RotationIndices m_full_rot_inds_
static void extractParamsFromAntiSymmetricMatrix(const RotationIndices &rot_indices, const ValueMatrix &rot_mat, std::vector< ValueType > ¶m)
ParticleSet::ParticleLaplacian myL_J
void table_method_eval(Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi, const ParticleSet::ParticleLaplacian &myL_J, const ParticleSet::ParticleGradient &myG_J, const size_t nel, const size_t nmo, const ValueType &psiCurrent, const std::vector< RealType > &Coeff, const std::vector< size_t > &C2node_up, const std::vector< size_t > &C2node_dn, const ValueVector &detValues_up, const ValueVector &detValues_dn, const GradMatrix &grads_up, const GradMatrix &grads_dn, const ValueMatrix &lapls_up, const ValueMatrix &lapls_dn, const ValueMatrix &M_up, const ValueMatrix &M_dn, const ValueMatrix &Minv_up, const ValueMatrix &Minv_dn, const GradMatrix &B_grad, const ValueMatrix &B_lapl, const std::vector< int > &detData_up, const size_t N1, const size_t N2, const size_t NP1, const size_t NP2, const std::vector< std::vector< int >> &lookup_tbl)
void mw_evaluateVGL(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const RefVector< ValueVector > &psi_v_list, const RefVector< GradVector > &dpsi_v_list, const RefVector< ValueVector > &d2psi_v_list) const override
evaluate the values, gradients and laplacians of this single-particle orbital sets of multiple walker...
void mw_evaluate_notranspose(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int first, int last, const RefVector< ValueMatrix > &logdet_list, const RefVector< GradMatrix > &dlogdet_list, const RefVector< ValueMatrix > &d2logdet_list) const override
void evaluateVGHGH(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi, GGGVector &grad_grad_grad_psi) override
evaluate the values, gradients, hessians, and grad hessians of this single-particle orbital set ...
void applyDeltaRotation(const std::vector< ValueType > &delta_param, const std::vector< ValueType > &old_param, std::vector< ValueType > &new_param)
std::vector< QMCTraits::ValueType > & getMyVarsFull(RotatedSPOs &rot)
OrbitalSetTraits< ValueType >::ValueVector ValueVector
class to handle a set of variables that can be modified during optimizations
void evaluateGradSource(const ParticleSet &P, int first, int last, const ParticleSet &source, int iat_src, GradMatrix &grad_phi, HessMatrix &grad_grad_phi, GradMatrix &grad_lapl_phi) override
evaluate the gradients of values, gradients, laplacians of this single-particle orbital for [first...
IndexType OrbitalSetSize
number of Single-particle orbitals
void mw_evaluateValue(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const RefVector< ValueVector > &psi_v_list) const override
evaluate the values this single-particle orbital sets of multiple walkers
std::vector< std::pair< int, int > > RotationIndices
void evaluateDerivRatios(const VirtualParticleSet &VP, const opt_variables_type &optvars, ValueVector &psi, const ValueVector &psiinv, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios, int FirstIndex, int LastIndex) override
Determinant ratios and parameter derivatives of the wavefunction for virtual moves.
static void createRotationIndicesFull(int nel, int nmo, RotationIndices &rot_indices)
void checkObject() const override
check a few key parameters before putting the SPO into a determinant
size_type size() const
return the size
ParticleSet::ParticleGradient myG_J
void evaluateGradSource(const ParticleSet &P, int first, int last, const ParticleSet &source, int iat_src, GradMatrix &grad_phi) override
evaluate the gradients of this single-particle orbital for [first,last) target particles with respect...
static RefVectorWithLeader< SPOSet > extractPhiRefList(const RefVectorWithLeader< SPOSet > &spo_list)
std::string getClassName() const override
return class name
void evaluateVGL_spin(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi, ValueVector &dspin_psi) override
evaluate the values, gradients and laplacians and spin gradient of this single-particle orbital set ...
static void exponentiate_antisym_matrix(ValueMatrix &mat)
void table_method_evalWF(Vector< ValueType > &dlogpsi, const size_t nel, const size_t nmo, const ValueType &psiCurrent, const std::vector< RealType > &Coeff, const std::vector< size_t > &C2node_up, const std::vector< size_t > &C2node_dn, const ValueVector &detValues_up, const ValueVector &detValues_dn, const ValueMatrix &M_up, const ValueMatrix &M_dn, const ValueMatrix &Minv_up, const ValueMatrix &Minv_dn, const std::vector< int > &detData_up, const std::vector< std::vector< int >> &lookup_tbl)
std::vector< std::reference_wrapper< T > > RefVector
std::vector< std::vector< QMCTraits::ValueType > > & getHistoryParams(RotatedSPOs &rot)
static void constructDeltaRotation(const std::vector< ValueType > &delta_param, const std::vector< ValueType > &old_param, const RotationIndices &act_rot_inds, const RotationIndices &full_rot_inds, std::vector< ValueType > &new_param, ValueMatrix &new_rot_mat)
OrbitalSetTraits< ValueType >::GradHessVector GGGVector
void apply_rotation(const std::vector< ValueType > ¶m, bool use_stored_copy)
void mw_evaluateVGLandDetRatioGrads(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const std::vector< const ValueType *> &invRow_ptr_list, OffloadMWVGLArray &phi_vgl_v, std::vector< ValueType > &ratios, std::vector< GradType > &grads) const override
evaluate the values, gradients and laplacians of this single-particle orbital sets and determinant ra...
OrbitalSetTraits< ValueType >::GradVector GradVector
void setOrbitalSetSize(int norbs) override
set the OrbitalSetSize
std::unique_ptr< SPOSet > Phi_
bool use_global_rot_
Use global rotation or history list.
LatticeGaussianProduct::ValueType ValueType
void applyFullRotation(const std::vector< ValueType > &full_param, bool use_stored_copy)
std::vector< ValueType > params_
list of supplied orbital rotation parameters.
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
void applyRotationHistory()
void evaluateVGL(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi) override
evaluate the values, gradients and laplacians of this single-particle orbital set ...
OrbitalSetTraits< ValueType >::GradHessMatrix GGGMatrix
bool params_supplied_
true if SPO parameters (orbital rotation parameters) have been supplied by input
void readVariationalParameters(hdf_archive &hin) override
Read the variational parameters for this object from the VP HDF file.
NewTimer & apply_rotation_timer_
timer for apply_rotation
bool hasIonDerivs() const override
Query if this SPOSet has an explicit ion dependence.
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
void evaluateVGH(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi) override
evaluate the values, gradients and hessians of this single-particle orbital set
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
acquire a shared resource from collection
void push_back(OptimizableObject &obj)
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
return a shared resource to collection
OrbitalSetTraits< ValueType >::HessMatrix HessMatrix
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to collection
void mw_evaluateVGLandDetRatioGradsWithSpin(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const std::vector< const ValueType *> &invRow_ptr_list, OffloadMWVGLArray &phi_vgl_v, std::vector< ValueType > &ratios, std::vector< GradType > &grads, std::vector< ValueType > &spingrads) const override
evaluate the values, gradients and laplacians of this single-particle orbital sets and determinant ra...