QMCPACK
RotatedSPOs.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 //// This file is distributed under the University of Illinois/NCSA Open Source License.
3 //// See LICENSE file in top directory for details.
4 ////
5 //// Copyright (c) QMCPACK developers.
6 ////
7 //// File developed by: Sergio D. Pineda Flores, sergio_pinedaflores@berkeley.edu, University of California, Berkeley
8 //// Eric Neuscamman, eneuscamman@berkeley.edu, University of California, Berkeley
9 //// Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 ////
11 //// File created by: Sergio D. Pineda Flores, sergio_pinedaflores@berkeley.edu, University of California, Berkeley
12 ////////////////////////////////////////////////////////////////////////////////////////
13 #ifndef QMCPLUSPLUS_ROTATION_HELPER_H
14 #define QMCPLUSPLUS_ROTATION_HELPER_H
15 
17 
18 
19 namespace qmcplusplus
20 {
21 class RotatedSPOs;
22 namespace testing
23 {
24 std::vector<QMCTraits::ValueType>& getMyVarsFull(RotatedSPOs& rot);
25 std::vector<std::vector<QMCTraits::ValueType>>& getHistoryParams(RotatedSPOs& rot);
26 } // namespace testing
27 
28 class RotatedSPOs : public SPOSet, public OptimizableObject
29 {
30 public:
31  //constructor
32  RotatedSPOs(const std::string& my_name, std::unique_ptr<SPOSet>&& spos);
33  //destructor
34  ~RotatedSPOs() override;
35 
36  std::string getClassName() const override { return "RotatedSPOs"; }
37  bool isOptimizable() const override { return true; }
38  bool isOMPoffload() const override { return Phi_->isOMPoffload(); }
39  bool hasIonDerivs() const override { return Phi_->hasIonDerivs(); }
40 
41  // Vector of rotation matrix indices
42  using RotationIndices = std::vector<std::pair<int, int>>;
43  //NOTE: Rotation indices are stored according to the convention (occupied,unoccupied).
44  //So an excitation (i,j) is the excitation of an electron in orbital i to orbital j.
45  //This list of indices, in conjunction with the vector "params", is a sparse representation
46  //of the matrix K'.
47  //
48  //Comparing with Umrigar and other's definitions, the object that effects the orbital rotation is K = sum_i,j k_ij E_ij,
49  //where E_ij is the singlet creation operator taking an electron from orbital j to orbital i. Comparing these two,
50  // <phi_i | K | phi_j> = k_ij = k'_ji. So the real object that gets exponentiated is the transpose of what is stored and
51  // reported. This tranpose is properly taken into account in constructAntiSymmetricMatrix(...).
52 
53  // Active orbital rotation parameter indices
55 
56  // Full set of rotation values for global rotation
58 
59  // Construct a list of the matrix indices for non-zero rotation parameters.
60  // (The structure for a sparse representation of the matrix)
61  // Only core->active rotations are created.
62  static void createRotationIndices(int nel, int nmo, RotationIndices& rot_indices);
63 
64  // Construct a list for all the matrix indices, including core->active, core->core and active->active
65  static void createRotationIndicesFull(int nel, int nmo, RotationIndices& rot_indices);
66 
67  // Takes a sparse representation of the antisymmetric/antihermitian K' matrix ( (i->j) excitation indices rot_indices
68  // and and coefficient vector param and constructs a dense antisymmetric/antihermitian K matrix (rot_mat).
69  // The latter is what is needed for the orbital rotation.
70  // This function assumes rot_mat is properly sized upon input and is set to zero.
71  static void constructAntiSymmetricMatrix(const RotationIndices& rot_indices,
72  const std::vector<ValueType>& param,
73  ValueMatrix& rot_mat);
74 
75  // Extract the list of rotation parameters from the entries in an antisymmetric matrix
76  // This function expects rot_indices and param are the same length.
77  static void extractParamsFromAntiSymmetricMatrix(const RotationIndices& rot_indices,
78  const ValueMatrix& rot_mat,
79  std::vector<ValueType>& param);
80 
81  //function to perform orbital rotations
82  void apply_rotation(const std::vector<ValueType>& param, bool use_stored_copy);
83 
84  // For global rotation, inputs are the old parameters and the delta parameters.
85  // The corresponding rotation matrices are constructed, multiplied together,
86  // and the new parameters extracted.
87  // The new rotation is applied to the underlying SPO coefficients
88  void applyDeltaRotation(const std::vector<ValueType>& delta_param,
89  const std::vector<ValueType>& old_param,
90  std::vector<ValueType>& new_param);
91 
92  // Perform the construction of matrices and extraction of parameters for a delta rotation.
93  // Split out and made static for testing.
94  static void constructDeltaRotation(const std::vector<ValueType>& delta_param,
95  const std::vector<ValueType>& old_param,
96  const RotationIndices& act_rot_inds,
97  const RotationIndices& full_rot_inds,
98  std::vector<ValueType>& new_param,
99  ValueMatrix& new_rot_mat);
100 
101  // When initializing the rotation from VP files
102  // This function applies the rotation history
103  void applyRotationHistory();
104 
105  // This function applies the global rotation (similar to apply_rotation, but for the full
106  // set of rotation parameters)
107  void applyFullRotation(const std::vector<ValueType>& full_param, bool use_stored_copy);
108 
109  // Compute matrix exponential of an antisymmetric/antihermitian matrix for
110  // the real/complex case. Overwrites matrix with its exponential (result is rotation matrix)
111  static void exponentiate_antisym_matrix(ValueMatrix& mat);
112 
113  // Compute matrix log of rotation matrix to produce antisymmetric matrix. Technically, this
114  // performs the log of any matrix where the eigenproblem is stable, but we only take logs of
115  // matrices of the form A=e^K, where K is antisymmetric/antihermitian.
116  static void log_antisym_matrix(const ValueMatrix& mat, ValueMatrix& output);
117 
118  //A particular SPOSet used for Orbitals
119  std::unique_ptr<SPOSet> Phi_;
120 
121  /// For now, this takes the real optimizable parameters (real rotation coefficients) and converts
122  /// them to ValueType parameter lists for internal consumption by the real and complex orb-opt code.
123  /// This will do something more non-trivial when bona fide complex orbital optimization is working.
124  void setRotationParameters(const std::vector<RealType>& param_list);
125 
126  /// the number of electrons of the majority spin
127  size_t nel_major_;
128 
129  std::unique_ptr<SPOSet> makeClone() const override;
130 
131  // myG_temp (myL_temp) is the Gradient (Laplacian) value of of the Determinant part of the wfn
132  // myG_J is the Gradient of the all other parts of the wavefunction (typically just the Jastrow).
133  // It represents \frac{\nabla\psi_{J}}{\psi_{J}}
134  // myL_J will be used to represent \frac{\nabla^2\psi_{J}}{\psi_{J}} . The Laplacian portion
135  // IMPORTANT NOTE: The value of P.L holds \nabla^2 ln[\psi] but we need \frac{\nabla^2 \psi}{\psi} and this is what myL_J will hold
138 
144 
145 
146  // Single Slater creation
147  void buildOptVariables(size_t nel);
148 
149  // For the MSD case rotations must be created in MultiSlaterDetTableMethod class
150  void buildOptVariables(const RotationIndices& rotations, const RotationIndices& full_rotations);
151 
152 
154  const opt_variables_type& optvars,
155  Vector<ValueType>& dlogpsi,
156  Vector<ValueType>& dhpsioverpsi,
157  const int& FirstIndex,
158  const int& LastIndex) override;
159 
161  const opt_variables_type& optvars,
162  Vector<ValueType>& dlogpsi,
163  int FirstIndex,
164  int LastIndex) override;
165 
167  const opt_variables_type& optvars,
168  Vector<ValueType>& dlogpsi,
169  Vector<ValueType>& dhpsioverpsi,
170  const ValueType& psiCurrent,
171  const std::vector<ValueType>& Coeff,
172  const std::vector<size_t>& C2node_up,
173  const std::vector<size_t>& C2node_dn,
174  const ValueVector& detValues_up,
175  const ValueVector& detValues_dn,
176  const GradMatrix& grads_up,
177  const GradMatrix& grads_dn,
178  const ValueMatrix& lapls_up,
179  const ValueMatrix& lapls_dn,
180  const ValueMatrix& M_up,
181  const ValueMatrix& M_dn,
182  const ValueMatrix& Minv_up,
183  const ValueMatrix& Minv_dn,
184  const GradMatrix& B_grad,
185  const ValueMatrix& B_lapl,
186  const std::vector<int>& detData_up,
187  const size_t N1,
188  const size_t N2,
189  const size_t NP1,
190  const size_t NP2,
191  const std::vector<std::vector<int>>& lookup_tbl) override;
192 
194  const opt_variables_type& optvars,
195  Vector<ValueType>& dlogpsi,
196  const QTFull::ValueType& psiCurrent,
197  const std::vector<ValueType>& Coeff,
198  const std::vector<size_t>& C2node_up,
199  const std::vector<size_t>& C2node_dn,
200  const ValueVector& detValues_up,
201  const ValueVector& detValues_dn,
202  const ValueMatrix& M_up,
203  const ValueMatrix& M_dn,
204  const ValueMatrix& Minv_up,
205  const ValueMatrix& Minv_dn,
206  const std::vector<int>& detData_up,
207  const std::vector<std::vector<int>>& lookup_tbl) override;
208 
209  //helper function to evaluatederivative; evaluate orbital rotation parameter derivative using table method
210  void table_method_eval(Vector<ValueType>& dlogpsi,
211  Vector<ValueType>& dhpsioverpsi,
214  const size_t nel,
215  const size_t nmo,
216  const ValueType& psiCurrent,
217  const std::vector<RealType>& Coeff,
218  const std::vector<size_t>& C2node_up,
219  const std::vector<size_t>& C2node_dn,
220  const ValueVector& detValues_up,
221  const ValueVector& detValues_dn,
222  const GradMatrix& grads_up,
223  const GradMatrix& grads_dn,
224  const ValueMatrix& lapls_up,
225  const ValueMatrix& lapls_dn,
226  const ValueMatrix& M_up,
227  const ValueMatrix& M_dn,
228  const ValueMatrix& Minv_up,
229  const ValueMatrix& Minv_dn,
230  const GradMatrix& B_grad,
231  const ValueMatrix& B_lapl,
232  const std::vector<int>& detData_up,
233  const size_t N1,
234  const size_t N2,
235  const size_t NP1,
236  const size_t NP2,
237  const std::vector<std::vector<int>>& lookup_tbl);
238 
240  const size_t nel,
241  const size_t nmo,
242  const ValueType& psiCurrent,
243  const std::vector<RealType>& Coeff,
244  const std::vector<size_t>& C2node_up,
245  const std::vector<size_t>& C2node_dn,
246  const ValueVector& detValues_up,
247  const ValueVector& detValues_dn,
248  const ValueMatrix& M_up,
249  const ValueMatrix& M_dn,
250  const ValueMatrix& Minv_up,
251  const ValueMatrix& Minv_dn,
252  const std::vector<int>& detData_up,
253  const std::vector<std::vector<int>>& lookup_tbl);
254 
255  void extractOptimizableObjectRefs(UniqueOptObjRefs& opt_obj_refs) override { opt_obj_refs.push_back(*this); }
256 
258  {
259  if (myVars.size())
260  active.insertFrom(myVars);
261  }
262 
263  void checkOutVariables(const opt_variables_type& active) override { myVars.getIndex(active); }
264 
265  ///reset
266  void resetParametersExclusive(const opt_variables_type& active) override;
267 
268  void writeVariationalParameters(hdf_archive& hout) override;
269 
270  void readVariationalParameters(hdf_archive& hin) override;
271 
272  //*********************************************************************************
273  //the following functions simply call Phi's corresponding functions
274  void setOrbitalSetSize(int norbs) override { Phi_->setOrbitalSetSize(norbs); }
275 
276  void checkObject() const override { Phi_->checkObject(); }
277 
278  void evaluateValue(const ParticleSet& P, int iat, ValueVector& psi) override
279  {
280  assert(psi.size() <= OrbitalSetSize);
281  Phi_->evaluateValue(P, iat, psi);
282  }
283 
284 
285  void evaluateVGL(const ParticleSet& P, int iat, ValueVector& psi, GradVector& dpsi, ValueVector& d2psi) override
286  {
287  assert(psi.size() <= OrbitalSetSize);
288  Phi_->evaluateVGL(P, iat, psi, dpsi, d2psi);
289  }
290 
292  int iat,
293  ValueVector& psi,
294  GradVector& dpsi,
295  ValueVector& d2psi,
296  ValueVector& dspin_psi) override
297  {
298  assert(psi.size() <= OrbitalSetSize);
299  Phi_->evaluateVGL_spin(P, iat, psi, dpsi, d2psi, dspin_psi);
300  }
301 
303  ValueVector& psi,
304  const ValueVector& psiinv,
305  std::vector<ValueType>& ratios) override
306  {
307  Phi_->evaluateDetRatios(VP, psi, psiinv, ratios);
308  }
309 
311  const opt_variables_type& optvars,
312  ValueVector& psi,
313  const ValueVector& psiinv,
314  std::vector<ValueType>& ratios,
315  Matrix<ValueType>& dratios,
316  int FirstIndex,
317  int LastIndex) override;
318 
319  void evaluateVGH(const ParticleSet& P,
320  int iat,
321  ValueVector& psi,
322  GradVector& dpsi,
323  HessVector& grad_grad_psi) override
324  {
325  assert(psi.size() <= OrbitalSetSize);
326  Phi_->evaluateVGH(P, iat, psi, dpsi, grad_grad_psi);
327  }
328 
329 
330  void evaluateVGHGH(const ParticleSet& P,
331  int iat,
332  ValueVector& psi,
333  GradVector& dpsi,
334  HessVector& grad_grad_psi,
335  GGGVector& grad_grad_grad_psi) override
336  {
337  Phi_->evaluateVGHGH(P, iat, psi, dpsi, grad_grad_psi, grad_grad_grad_psi);
338  }
339 
340 
342  int first,
343  int last,
344  ValueMatrix& logdet,
345  GradMatrix& dlogdet,
346  ValueMatrix& d2logdet) override
347  {
348  Phi_->evaluate_notranspose(P, first, last, logdet, dlogdet, d2logdet);
349  }
350 
351  void evaluate_spin(const ParticleSet& P, int iat, ValueVector& psi, ValueVector& dspin_psi) override
352  {
353  Phi_->evaluate_spin(P, iat, psi, dspin_psi);
354  }
355 
357  int first,
358  int last,
359  ValueMatrix& logdet,
360  GradMatrix& dlogdet,
361  HessMatrix& grad_grad_logdet) override
362  {
363  Phi_->evaluate_notranspose(P, first, last, logdet, dlogdet, grad_grad_logdet);
364  }
365 
367  int first,
368  int last,
369  ValueMatrix& logdet,
370  GradMatrix& dlogdet,
371  HessMatrix& grad_grad_logdet,
372  GGGMatrix& grad_grad_grad_logdet) override
373  {
374  Phi_->evaluate_notranspose(P, first, last, logdet, dlogdet, grad_grad_logdet, grad_grad_grad_logdet);
375  }
376 
378  int first,
379  int last,
380  const ParticleSet& source,
381  int iat_src,
382  GradMatrix& grad_phi) override
383  {
384  Phi_->evaluateGradSource(P, first, last, source, iat_src, grad_phi);
385  }
386 
388  int first,
389  int last,
390  const ParticleSet& source,
391  int iat_src,
392  GradMatrix& grad_phi,
393  HessMatrix& grad_grad_phi,
394  GradMatrix& grad_lapl_phi) override
395  {
396  Phi_->evaluateGradSource(P, first, last, source, iat_src, grad_phi, grad_grad_phi, grad_lapl_phi);
397  }
398 
399  // void evaluateThirdDeriv(const ParticleSet& P, int first, int last, GGGMatrix& grad_grad_grad_logdet)
400  // {Phi->evaluateThridDeriv(P, first, last, grad_grad_grad_logdet); }
401 
402  /// Use history list (false) or global rotation (true)
403  void set_use_global_rotation(bool use_global_rotation) { use_global_rot_ = use_global_rotation; }
404 
407  const RefVector<ValueVector>& psi_list,
408  const std::vector<const ValueType*>& invRow_ptr_list,
409  std::vector<std::vector<ValueType>>& ratios_list) const override;
410 
411  void mw_evaluateValue(const RefVectorWithLeader<SPOSet>& spo_list,
412  const RefVectorWithLeader<ParticleSet>& P_list,
413  int iat,
414  const RefVector<ValueVector>& psi_v_list) const override;
415 
416  void mw_evaluateVGL(const RefVectorWithLeader<SPOSet>& spo_list,
417  const RefVectorWithLeader<ParticleSet>& P_list,
418  int iat,
419  const RefVector<ValueVector>& psi_v_list,
420  const RefVector<GradVector>& dpsi_v_list,
421  const RefVector<ValueVector>& d2psi_v_list) const override;
422 
424  const RefVectorWithLeader<ParticleSet>& P_list,
425  int iat,
426  const RefVector<ValueVector>& psi_v_list,
427  const RefVector<GradVector>& dpsi_v_list,
428  const RefVector<ValueVector>& d2psi_v_list,
429  OffloadMatrix<ComplexType>& mw_dspin) const override;
430 
432  const RefVectorWithLeader<ParticleSet>& P_list,
433  int iat,
434  const std::vector<const ValueType*>& invRow_ptr_list,
435  OffloadMWVGLArray& phi_vgl_v,
436  std::vector<ValueType>& ratios,
437  std::vector<GradType>& grads) const override;
438 
440  const RefVectorWithLeader<ParticleSet>& P_list,
441  int iat,
442  const std::vector<const ValueType*>& invRow_ptr_list,
443  OffloadMWVGLArray& phi_vgl_v,
444  std::vector<ValueType>& ratios,
445  std::vector<GradType>& grads,
446  std::vector<ValueType>& spingrads) const override;
447 
449  const RefVectorWithLeader<ParticleSet>& P_list,
450  int first,
451  int last,
452  const RefVector<ValueMatrix>& logdet_list,
453  const RefVector<GradMatrix>& dlogdet_list,
454  const RefVector<ValueMatrix>& d2logdet_list) const override;
455 
456  void createResource(ResourceCollection& collection) const override;
457 
458  void acquireResource(ResourceCollection& collection, const RefVectorWithLeader<SPOSet>& spo_list) const override;
459 
460  void releaseResource(ResourceCollection& collection, const RefVectorWithLeader<SPOSet>& spo_list) const override;
461 
462 private:
463  /// true if SPO parameters (orbital rotation parameters) have been supplied by input
465  /// list of supplied orbital rotation parameters.
466  std::vector<ValueType> params_;
467 
468  /// Full set of rotation matrix parameters for use in global rotation method
469  std::vector<ValueType> myVarsFull_;
470 
471  /// timer for apply_rotation
473 
474  /// List of previously applied parameters
475  std::vector<std::vector<ValueType>> history_params_;
476 
478 
479  /// Use global rotation or history list
480  bool use_global_rot_ = true;
481 
482  friend std::vector<ValueType>& testing::getMyVarsFull(RotatedSPOs& rot);
483  friend std::vector<std::vector<ValueType>>& testing::getHistoryParams(RotatedSPOs& rot);
484 };
485 
486 
487 } //namespace qmcplusplus
488 
489 #endif
bool isOptimizable() const override
Query if this SPOSet is optimizable.
Definition: RotatedSPOs.h:37
void resetParametersExclusive(const opt_variables_type &active) override
reset
base class for Single-particle orbital sets
Definition: SPOSet.h:46
void writeVariationalParameters(hdf_archive &hout) override
Write the variational parameters for this object to the VP HDF file.
OrbitalSetTraits< ValueType >::HessVector HessVector
Definition: SPOSet.h:53
void set_use_global_rotation(bool use_global_rotation)
Use history list (false) or global rotation (true)
Definition: RotatedSPOs.h:403
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
Definition: RotatedSPOs.h:356
static void constructAntiSymmetricMatrix(const RotationIndices &rot_indices, const std::vector< ValueType > &param, ValueMatrix &rot_mat)
Definition: RotatedSPOs.cpp:76
RotationIndices m_act_rot_inds_
Definition: RotatedSPOs.h:54
std::vector< ValueType > myVarsFull_
Full set of rotation matrix parameters for use in global rotation method.
Definition: RotatedSPOs.h:469
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
Definition: RotatedSPOs.h:302
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void evaluateValue(const ParticleSet &P, int iat, ValueVector &psi) override
evaluate the values of this single-particle orbital set
Definition: RotatedSPOs.h:278
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
Definition: RotatedSPOs.h:351
void checkInVariablesExclusive(opt_variables_type &active) override
check in variational parameters to the global list of parameters used by the optimizer.
Definition: RotatedSPOs.h:257
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...
Definition: RotatedSPOs.h:341
size_t nel_major_
the number of electrons of the majority spin
Definition: RotatedSPOs.h:127
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.
Definition: RotatedSPOs.h:38
RotatedSPOs(const std::string &my_name, std::unique_ptr< SPOSet > &&spos)
Definition: RotatedSPOs.cpp:22
std::vector< std::vector< ValueType > > history_params_
List of previously applied parameters.
Definition: RotatedSPOs.h:475
RealType ValueType
Definition: QMCTypes.h:42
ParticleSet::ParticleGradient myG_temp
Definition: RotatedSPOs.h:136
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
opt_variables_type myVars
Optimizable variables.
Definition: SPOSet.h:568
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Definition: SPOSet.h:50
class to handle hdf file
Definition: hdf_archive.h:51
static void createRotationIndices(int nel, int nmo, RotationIndices &rot_indices)
Definition: RotatedSPOs.cpp:48
Timer accumulates time and call counts.
Definition: NewTimer.h:135
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 > &param_list)
For now, this takes the real optimizable parameters (real rotation coefficients) and converts them to...
Definition: RotatedSPOs.cpp:36
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...
Definition: RotatedSPOs.h:366
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Definition: SPOSet.h:52
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
Definition: RotatedSPOs.h:263
void buildOptVariables(size_t nel)
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
Definition: RotatedSPOs.h:255
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
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
Definition: RotatedSPOs.h:137
Array< ValueType, 3, OffloadPinnedAllocator< ValueType > > OffloadMWVGLArray
Definition: SPOSet.h:58
RotationIndices m_full_rot_inds_
Definition: RotatedSPOs.h:57
static void extractParamsFromAntiSymmetricMatrix(const RotationIndices &rot_indices, const ValueMatrix &rot_mat, std::vector< ValueType > &param)
Definition: RotatedSPOs.cpp:97
ParticleSet::ParticleLaplacian myL_J
Definition: RotatedSPOs.h:137
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 ...
Definition: RotatedSPOs.h:330
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
Definition: SPOSet.h:49
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
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...
Definition: RotatedSPOs.h:387
IndexType OrbitalSetSize
number of Single-particle orbitals
Definition: SPOSet.h:566
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
Definition: RotatedSPOs.h:42
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)
Definition: RotatedSPOs.cpp:55
void checkObject() const override
check a few key parameters before putting the SPO into a determinant
Definition: RotatedSPOs.h:276
size_type size() const
return the size
Definition: VariableSet.h:88
ParticleSet::ParticleGradient myG_J
Definition: RotatedSPOs.h:136
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...
Definition: RotatedSPOs.h:377
static RefVectorWithLeader< SPOSet > extractPhiRefList(const RefVectorWithLeader< SPOSet > &spo_list)
std::string getClassName() const override
return class name
Definition: RotatedSPOs.h:36
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 ...
Definition: RotatedSPOs.h:291
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
Definition: SPOSet.h:55
void apply_rotation(const std::vector< ValueType > &param, 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
Definition: SPOSet.h:51
void setOrbitalSetSize(int norbs) override
set the OrbitalSetSize
Definition: RotatedSPOs.h:274
std::unique_ptr< SPOSet > Phi_
Definition: RotatedSPOs.h:119
bool use_global_rot_
Use global rotation or history list.
Definition: RotatedSPOs.h:480
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.
Definition: RotatedSPOs.h:466
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
Definition: VariableSet.cpp:37
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 ...
Definition: RotatedSPOs.h:285
OrbitalSetTraits< ValueType >::GradHessMatrix GGGMatrix
Definition: SPOSet.h:56
bool params_supplied_
true if SPO parameters (orbital rotation parameters) have been supplied by input
Definition: RotatedSPOs.h:464
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
Definition: RotatedSPOs.h:472
bool hasIonDerivs() const override
Query if this SPOSet has an explicit ion dependence.
Definition: RotatedSPOs.h:39
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
Definition: RotatedSPOs.h:319
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
Definition: SPOSet.h:54
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...