QMCPACK
MultiDiracDeterminant.cpp
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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Bryan Clark, bclark@Princeton.edu, Princeton University
8 // Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
9 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
10 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
11 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
12 //
13 // File created by: Bryan Clark, bclark@Princeton.edu, Princeton University
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #include "MultiDiracDeterminant.h"
19 #ifndef QMC_COMPLEX
21 #endif
22 #include "Message/Communicate.h"
24 #include "CPU/BLAS.hpp"
26 #include <algorithm>
27 #include <vector>
28 
29 // mmorales:
30 // NOTE NOTE NOTE:
31 // right now the code assumes that all the orbitals in the active space are used,
32 // this means that there can be problems if some of the orbitals are not used
33 
34 namespace qmcplusplus
35 {
36 void MultiDiracDeterminant::createDetData(const int ref_det_id,
37  const std::vector<ci_configuration2>& configlist_unsorted,
38  const std::vector<size_t>& C2nodes_unsorted,
39  std::vector<size_t>& C2nodes_sorted)
40 {
41  auto& ref = configlist_unsorted[ref_det_id];
42  auto& configlist_sorted = *ciConfigList;
43  auto& data = *detData;
44  auto& pairs = *uniquePairs;
45  auto& sign = *DetSigns;
46  auto& ndets_per_excitation_level = *ndets_per_excitation_level_;
47 
48  const size_t nci = configlist_unsorted.size();
49  std::vector<std::pair<int, int>> pairs_local;
50 
51  size_t nex_max = 0;
52  std::vector<size_t> pos(NumPtcls);
53  std::vector<size_t> ocp(NumPtcls);
54  std::vector<size_t> uno(NumPtcls);
55  // map key is exc. lvl
56  std::map<int, std::vector<int>> dataMap;
57  std::map<int, std::vector<int>> sortMap;
58  std::vector<RealType> tmp_sign(nci, 0);
59  for (size_t i = 0; i < nci; i++)
60  {
61  size_t nex;
62  tmp_sign[i] = ref.calculateExcitations(configlist_unsorted[i], nex, pos, ocp, uno);
63  nex_max = std::max(nex, nex_max);
64  dataMap[nex].push_back(nex);
65  sortMap[nex].push_back(i);
66  for (int k = 0; k < nex; k++)
67  dataMap[nex].push_back(pos[k]);
68  for (int k = 0; k < nex; k++)
69  dataMap[nex].push_back(uno[k]);
70  for (int k = 0; k < nex; k++)
71  dataMap[nex].push_back(ocp[k]);
72  // determine unique pairs, to avoid redundant calculation of matrix elements
73  // if storing the entire MOxMO matrix is too much, then make an array and a mapping to it.
74  // is there an easier way??
75  for (int k1 = 0; k1 < nex; k1++)
76  for (int k2 = 0; k2 < nex; k2++)
77  {
78  // std::pair<int,int> temp(ocp[k1],uno[k2]);
79  std::pair<int, int> temp(pos[k1], uno[k2]);
80  if (find(pairs_local.begin(), pairs_local.end(), temp) == pairs_local.end()) //pair is new
81  pairs_local.push_back(temp);
82  }
83  }
84  pairs.resize(pairs_local.size());
85  int* first = pairs.data(0);
86  int* second = pairs.data(1);
87 
88  for (size_t i = 0; i < pairs_local.size(); i++)
89  {
90  first[i] = pairs_local[i].first;
91  second[i] = pairs_local[i].second;
92  }
93 
94 
95  app_log() << "Number of terms in pairs array: " << pairs.size() << std::endl;
96  ndets_per_excitation_level.resize(nex_max + 1, 0);
97  //reorder configs and det data
98  std::vector<size_t> det_idx_order; // old indices in new order
99  std::vector<size_t> det_idx_reverse(nci, 0); // new indices in old order
100 
101  // populate data, ordered by exc. lvl.
102  // make mapping from new to old det idx
103  std::vector<int> data_local;
104  data_local.clear();
105  data.clear();
106 
107  for (const auto& [nex, det_idx_old] : sortMap)
108  {
109  data_local.insert(data_local.end(), dataMap[nex].begin(), dataMap[nex].end());
110  det_idx_order.insert(det_idx_order.end(), det_idx_old.begin(), det_idx_old.end());
111  ndets_per_excitation_level[nex] = det_idx_old.size();
112  }
113  data.resize(data_local.size());
114  for (size_t i = 0; i < data_local.size(); i++)
115  data[i] = data_local[i];
116 
117  assert(det_idx_order.size() == nci);
118 
119  // make reverse mapping (old to new) and reorder confgList by exc. lvl.
120  configlist_sorted.resize(nci);
121  sign.resize(nci);
122  for (size_t i = 0; i < nci; i++)
123  {
124  det_idx_reverse[det_idx_order[i]] = i;
125  configlist_sorted[i] = configlist_unsorted[det_idx_order[i]];
126  sign[i] = tmp_sign[det_idx_order[i]];
127  }
128 
129  auto& refdet_occup_ref(*refdet_occup);
130  refdet_occup_ref.resize(NumPtcls);
131  for (size_t i = 0; i < NumPtcls; i++)
132  refdet_occup_ref[i] = configlist_unsorted[ref_det_id].occup[i];
133 
134  {
135  ScopedTimer local_timer(transferH2D_timer);
136  sign.updateTo();
137  pairs.updateTo();
138  data.updateTo();
139  refdet_occup_ref.updateTo();
140  }
141  // update C2nodes for new det ordering
142  C2nodes_sorted.resize(C2nodes_unsorted.size());
143  for (int i = 0; i < C2nodes_unsorted.size(); i++)
144  C2nodes_sorted[i] = det_idx_reverse[C2nodes_unsorted[i]];
145 
146  /*
147  std::cout <<"ref: " <<ref << std::endl;
148  std::cout <<"list: " << std::endl;
149  for(int i=0; i<confgList.size(); i++)
150  std::cout <<confgList[i] << std::endl;
151 
152  std::cout <<"pairs: " << std::endl;
153  for(int i=0; i<pairs.size(); i++)
154  std::cout <<pairs[i].first <<" " <<pairs[i].second << std::endl;
155  */
156 
157  // make sure internal objects depending on the number of unique determinants are resized
158  resize();
159 }
160 
162 {
163  ScopedTimer local_timer(evalWalker_timer);
164  if (fromScratch)
165  {
166  ///Force host view as no implementation of evaluate_notranspose
167  Matrix<ValueType> psiM_host_view(psiM.data(), psiM.rows(), psiM.cols());
168  Matrix<GradType> dpsiM_host_view(dpsiM.data(), dpsiM.rows(), dpsiM.cols());
169  Matrix<ValueType> d2psiM_host_view(d2psiM.data(), d2psiM.rows(), d2psiM.cols());
170  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_host_view, dpsiM_host_view, d2psiM_host_view);
171  {
172  ScopedTimer local_timer(transferH2D_timer);
173  psiM.updateTo();
174  dpsiM.updateTo();
175  //d2psiM.updateTo();
176  }
177  }
178 
179 
180  const auto& confgList = *ciConfigList;
181 
182  {
183  ScopedTimer local_timer(inverse_timer);
184  auto it(confgList[ReferenceDeterminant].occup.begin());
185  for (size_t i = 0; i < NumPtcls; i++)
186  {
187  for (size_t j = 0; j < NumPtcls; j++)
188  psiMinv(j, i) = psiM(j, *it);
189  it++;
190  }
191 
192  for (size_t i = 0; i < NumPtcls; i++)
193  for (size_t j = 0; j < NumOrbitals; j++)
194  TpsiM(j, i) = psiM(i, j);
195 
196  std::complex<RealType> logValueRef;
197  InvertWithLog(psiMinv.data(), NumPtcls, NumPtcls, WorkSpace.data(), Pivot.data(), logValueRef);
198  log_value_ref_det_ = logValueRef;
199  }
200 
201  const RealType detsign = (*DetSigns)[ReferenceDeterminant];
204  ///Pinning ratios_to_ref_ to the device.
205 
206 
207  for (size_t iat = 0; iat < NumPtcls; iat++)
208  {
209  auto it(confgList[ReferenceDeterminant].occup.begin());
210  GradType gradRatio;
211  ValueType ratioLapl = 0.0;
212  for (size_t i = 0; i < NumPtcls; i++)
213  {
214  gradRatio += psiMinv(i, iat) * dpsiM(iat, *it);
215  ratioLapl += psiMinv(i, iat) * d2psiM(iat, *it);
216  it++;
217  }
218  lapls(ReferenceDeterminant, iat) = ratioLapl;
219  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
220  {
221  dpsiMinv = psiMinv;
222  it = confgList[ReferenceDeterminant].occup.begin();
223  for (size_t i = 0; i < NumPtcls; i++)
224  psiV_temp[i] = dpsiM(iat, *(it++))[idim];
225  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, iat, gradRatio[idim]);
226  for (size_t i = 0; i < NumOrbitals; i++)
227  TpsiM(i, iat) = dpsiM(iat, i)[idim];
229  gradRatio[idim], table_matrix, idim, iat, grads);
230  }
231  dpsiMinv = psiMinv;
232  it = confgList[ReferenceDeterminant].occup.begin();
233  for (size_t i = 0; i < NumPtcls; i++)
234  psiV_temp[i] = d2psiM(iat, *(it++));
236  for (size_t i = 0; i < NumOrbitals; i++)
237  TpsiM(i, iat) = d2psiM(iat, i);
240  // restore matrix
241  for (size_t i = 0; i < NumOrbitals; i++)
242  TpsiM(i, iat) = psiM(iat, i);
243  }
244 
245  {
246  ScopedTimer local_timer(transferH2D_timer);
247  ratios_to_ref_.updateTo();
248  psiMinv.updateTo();
249  TpsiM.updateTo();
250  }
251 
253 }
254 
256 {
257  ScopedTimer local_timer(evalWalker_timer);
258  if (fromScratch)
259  {
260  ///Force host view as no implementation of evaluate_notranspose
261  Matrix<ValueType> psiM_host_view(psiM.data(), psiM.rows(), psiM.cols());
262  Matrix<GradType> dpsiM_host_view(dpsiM.data(), dpsiM.rows(), dpsiM.cols());
263  Matrix<ValueType> d2psiM_host_view(d2psiM.data(), d2psiM.rows(), d2psiM.cols());
264  Phi->evaluate_notranspose_spin(P, FirstIndex, LastIndex, psiM_host_view, dpsiM_host_view, d2psiM_host_view,
265  dspin_psiM);
266  {
267  ScopedTimer local_timer(transferH2D_timer);
268  psiM.updateTo();
269  dpsiM.updateTo();
270  }
271  }
272 
273 
274  const auto& confgList = *ciConfigList;
275  std::complex<RealType> logValueRef;
276 
277  {
278  ScopedTimer local_timer(inverse_timer);
279  auto it(confgList[ReferenceDeterminant].occup.begin());
280  for (size_t i = 0; i < NumPtcls; i++)
281  {
282  for (size_t j = 0; j < NumPtcls; j++)
283  psiMinv(j, i) = psiM(j, *it);
284  it++;
285  }
286  for (size_t i = 0; i < NumPtcls; i++)
287  {
288  for (size_t j = 0; j < NumOrbitals; j++)
289  TpsiM(j, i) = psiM(i, j);
290  }
291  InvertWithLog(psiMinv.data(), NumPtcls, NumPtcls, WorkSpace.data(), Pivot.data(), logValueRef);
292  log_value_ref_det_ = logValueRef;
293  } ///Stop inverse_timerScop
294  const RealType detsign = (*DetSigns)[ReferenceDeterminant];
297 
298  for (size_t iat = 0; iat < NumPtcls; iat++)
299  {
300  auto it(confgList[ReferenceDeterminant].occup.begin());
301  GradType gradRatio;
302  ValueType ratioLapl = 0.0;
303  ValueType spingradRatio = 0.0;
304  for (size_t i = 0; i < NumPtcls; i++)
305  {
306  gradRatio += psiMinv(i, iat) * dpsiM(iat, *it);
307  ratioLapl += psiMinv(i, iat) * d2psiM(iat, *it);
308  spingradRatio += psiMinv(i, iat) * dspin_psiM(iat, *it);
309  it++;
310  }
311  lapls(ReferenceDeterminant, iat) = ratioLapl;
312  spingrads(ReferenceDeterminant, iat) = spingradRatio;
313  for (size_t idim = 0; idim < OHMMS_DIM; idim++)
314  {
315  dpsiMinv = psiMinv;
316  it = confgList[ReferenceDeterminant].occup.begin();
317  for (size_t i = 0; i < NumPtcls; i++)
318  psiV_temp[i] = dpsiM(iat, *(it++))[idim];
319  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, iat, gradRatio[idim]);
320  for (size_t i = 0; i < NumOrbitals; i++)
321  TpsiM(i, iat) = dpsiM(iat, i)[idim];
323  gradRatio[idim], table_matrix, idim, iat, grads);
324  }
325  dpsiMinv = psiMinv;
326  it = confgList[ReferenceDeterminant].occup.begin();
327  for (size_t i = 0; i < NumPtcls; i++)
328  psiV_temp[i] = d2psiM(iat, *(it++));
330  for (size_t i = 0; i < NumOrbitals; i++)
331  TpsiM(i, iat) = d2psiM(iat, i);
334 
335  //Adding the spin gradient
336  dpsiMinv = psiMinv;
337  it = confgList[ReferenceDeterminant].occup.begin();
338  for (size_t i = 0; i < NumPtcls; i++)
339  psiV_temp[i] = dspin_psiM(iat, *(it++));
340  InverseUpdateByColumn(dpsiMinv, psiV_temp, workV1, workV2, iat, spingradRatio);
341  for (size_t i = 0; i < NumOrbitals; i++)
342  TpsiM(i, iat) = dspin_psiM(iat, i);
345 
346  // restore matrix
347  for (size_t i = 0; i < NumOrbitals; i++)
348  TpsiM(i, iat) = psiM(iat, i);
349  }
350 
351  {
352  ScopedTimer local_timer(transferH2D_timer);
353  ratios_to_ref_.updateTo();
354  psiMinv.updateTo();
355  TpsiM.updateTo();
356  }
358 }
359 
360 
362 {
363  assert(P.isSpinor() == is_spinor_);
364  if (is_spinor_)
366  else
367  evaluateForWalkerMove(P, (fromscratch || UpdateMode == ORB_PBYP_RATIO));
368  buf.put(psiM.first_address(), psiM.last_address());
370  buf.put(d2psiM.first_address(), d2psiM.last_address());
371  buf.put(psiMinv.first_address(), psiMinv.last_address());
372  buf.put(log_value_ref_det_);
373  buf.put(ratios_to_ref_.first_address(), ratios_to_ref_.last_address());
376  if (is_spinor_)
377  {
378  buf.put(dspin_psiM.first_address(), dspin_psiM.last_address());
380  }
381  return 1.0;
382 }
383 
385 {
386  assert(P.isSpinor() == is_spinor_);
387  buf.get(psiM.first_address(), psiM.last_address());
389  buf.get(d2psiM.first_address(), d2psiM.last_address());
390  buf.get(psiMinv.first_address(), psiMinv.last_address());
391  buf.get(log_value_ref_det_);
392  buf.get(ratios_to_ref_.first_address(), ratios_to_ref_.last_address());
395  if (is_spinor_)
396  {
397  buf.get(dspin_psiM.first_address(), dspin_psiM.last_address());
399  }
400  // only used with ORB_PBYP_ALL,
402  int n1 = psiM.extent(0);
403  int n2 = psiM.extent(1);
404  for (int i = 0; i < n1; i++)
405  for (int j = 0; j < n2; j++)
406  TpsiM(j, i) = psiM(i, j);
407 }
408 
409 /** move was accepted, update the real container
410 */
411 void MultiDiracDeterminant::acceptMove(ParticleSet& P, int iat, bool safe_to_delay)
412 {
413  const int WorkingIndex = iat - FirstIndex;
414  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
415  assert(P.isSpinor() == is_spinor_);
416  if (curRatio == ValueType(0))
417  {
418  std::ostringstream msg;
419  msg << "MultiDiracDeterminant::acceptMove curRatio is " << curRatio << "! Report a bug." << std::endl;
420  throw std::runtime_error(msg.str());
421  }
423  curRatio = ValueType(1);
424  switch (UpdateMode)
425  {
426  case ORB_PBYP_RATIO:
428  // Ye: During acceptMove and restore, TpsiM is updated on the host, thus need to update the device copy.
429  // Ideally, this should be done directly on the device.
430  // However, acceptMove/restore are shared by both single walker and batched APIs.
431  // So the data motion must be kept consistently in all implementations.
432  // Right now in batched APIs, ratio and ratioGad implementation also doesn't have the same data motion.
433  // Thus also need a fix.
434  for (int i = 0; i < NumOrbitals; i++)
435  TpsiM(i, WorkingIndex) = psiV[i];
436  std::copy(psiV.begin(), psiV.end(), psiM[iat - FirstIndex]);
438  {
439  ScopedTimer local_timer(transferH2D_timer);
440  ratios_to_ref_.updateTo();
441  TpsiM.updateTo();
442  psiMinv.updateTo();
443  psiM.updateTo();
444  dpsiM.updateTo();
445  }
446  break;
447  case ORB_PBYP_PARTIAL:
449  for (int i = 0; i < NumOrbitals; i++)
450  TpsiM(i, WorkingIndex) = psiV[i];
452  std::copy(psiV.begin(), psiV.end(), psiM[WorkingIndex]);
453  std::copy(dpsiV.begin(), dpsiV.end(), dpsiM[WorkingIndex]);
454  std::copy(d2psiV.begin(), d2psiV.end(), d2psiM[WorkingIndex]);
455  {
456  ScopedTimer local_timer(transferH2D_timer);
457  ratios_to_ref_.updateTo();
458  TpsiM.updateTo();
459  psiMinv.updateTo();
460  psiM.updateTo();
461  dpsiM.updateTo();
462  }
463  if (is_spinor_)
464  std::copy(dspin_psiV.begin(), dspin_psiV.end(), dspin_psiM[WorkingIndex]);
465  break;
466  default:
468  for (int i = 0; i < NumOrbitals; i++)
469  TpsiM(i, WorkingIndex) = psiV[i];
470 
474  std::copy(psiV.begin(), psiV.end(), psiM[WorkingIndex]);
475  std::copy(dpsiV.begin(), dpsiV.end(), dpsiM[WorkingIndex]);
476  std::copy(d2psiV.begin(), d2psiV.end(), d2psiM[WorkingIndex]);
477  {
478  ScopedTimer local_timer(transferH2D_timer);
479  ratios_to_ref_.updateTo();
480  TpsiM.updateTo();
481  psiMinv.updateTo();
482  psiM.updateTo();
483  dpsiM.updateTo();
484  }
485  if (is_spinor_)
486  {
488  std::copy(dspin_psiV.begin(), dspin_psiV.end(), dspin_psiM[WorkingIndex]);
489  }
490  break;
491  }
492 }
493 
494 /** move was rejected. copy the real container to the temporary to move on
495 */
497 {
498  const int WorkingIndex = iat - FirstIndex;
499  assert(WorkingIndex >= 0 && WorkingIndex < LastIndex - FirstIndex);
501  for (int i = 0; i < NumOrbitals; i++)
502  TpsiM(i, WorkingIndex) = psiM(WorkingIndex, i);
503  {
504  ScopedTimer local_timer(transferH2D_timer);
505  TpsiM.updateTo();
506  }
507  curRatio = ValueType(1);
508  /*
509  switch(UpdateMode)
510  {
511  case ORB_PBYP_RATIO:
512  psiMinv_temp = psiMinv;
513  for(int i=0; i<NumOrbitals; i++)
514  TpsiM(i,WorkingIndex) = psiM(WorkingIndex,i);
515  break;
516  case ORB_PBYP_PARTIAL:
517  psiMinv_temp = psiMinv;
518  for(int i=0; i<NumOrbitals; i++)
519  TpsiM(i,WorkingIndex) = psiM(WorkingIndex,i);
520  break;
521  default:
522  break;
523  }
524  */
525 }
526 
528  const RefVectorWithLeader<ParticleSet>& p_list,
529  int iat,
530  const std::vector<bool>& isAccepted)
531 {
532  // TODO to be expanded to serve offload needs without relying on calling acceptMove and restore
533  for (int iw = 0; iw < wfc_list.size(); iw++)
534  if (isAccepted[iw])
535  wfc_list[iw].acceptMove(p_list[iw], iat, false);
536  else
537  wfc_list[iw].restore(iat);
538 }
539 
540 // this has been fixed
543  inverse_timer(s.inverse_timer),
544  buildTable_timer(s.buildTable_timer),
545  table2ratios_timer(s.table2ratios_timer),
546  evalWalker_timer(s.evalWalker_timer),
547  evalOrbValue_timer(s.evalOrbValue_timer),
548  evalOrbVGL_timer(s.evalOrbVGL_timer),
549  updateInverse_timer(s.updateInverse_timer),
550  calculateRatios_timer(s.calculateRatios_timer),
551  calculateGradRatios_timer(s.calculateGradRatios_timer),
552  updateRatios_timer(s.updateRatios_timer),
553  evaluateDetsForPtclMove_timer(s.evaluateDetsForPtclMove_timer),
554  evaluateDetsAndGradsForPtclMove_timer(s.evaluateDetsAndGradsForPtclMove_timer),
555  evaluateGrads_timer(s.evaluateGrads_timer),
556  offload_timer(s.offload_timer),
557  transferH2D_timer(s.transferH2D_timer),
558  transferD2H_timer(s.transferD2H_timer),
559  lookup_tbl(s.lookup_tbl),
560  Phi(s.Phi->makeClone()),
561  NumOrbitals(Phi->getOrbitalSetSize()),
562  FirstIndex(s.FirstIndex),
563  NumPtcls(s.NumPtcls),
564  LastIndex(s.LastIndex),
565  ciConfigList(s.ciConfigList),
566  refdet_occup(s.refdet_occup),
567  is_spinor_(s.is_spinor_),
568  detData(s.detData),
569  uniquePairs(s.uniquePairs),
570  DetSigns(s.DetSigns),
571  ndets_per_excitation_level_(s.ndets_per_excitation_level_)
572 {
573  resize();
574 }
575 
576 std::unique_ptr<SPOSet> MultiDiracDeterminant::clonePhi() const { return Phi->makeClone(); }
577 
578 std::unique_ptr<WaveFunctionComponent> MultiDiracDeterminant::makeClone(ParticleSet& tqp) const
579 {
580  APP_ABORT(" Illegal action. Cannot use MultiDiracDeterminant::makeClone");
581  return std::unique_ptr<MultiDiracDeterminant>();
582 }
583 
584 /** constructor
585  *@param spos the single-particle orbital set
586  *@param first index of the first particle
587  *@param spinor flag to determinane if spin arrays need to be resized and used
588  */
589 MultiDiracDeterminant::MultiDiracDeterminant(std::unique_ptr<SPOSet>&& spos, bool spinor, int first, int nel)
590  : inverse_timer(createGlobalTimer(getClassName() + "::invertRefDet")),
591  buildTable_timer(createGlobalTimer(getClassName() + "::buildTable")),
592  table2ratios_timer(createGlobalTimer(getClassName() + "::table2ratios")),
593  evalWalker_timer(createGlobalTimer(getClassName() + "::evalWalker")),
594  evalOrbValue_timer(createGlobalTimer(getClassName() + "::evalOrbValue")),
595  evalOrbVGL_timer(createGlobalTimer(getClassName() + "::evalOrbVGL")),
596  updateInverse_timer(createGlobalTimer(getClassName() + "::updateRefDetInv")),
597  calculateRatios_timer(createGlobalTimer(getClassName() + "::calcRatios")),
598  calculateGradRatios_timer(createGlobalTimer(getClassName() + "::calcGradRatios")),
599  updateRatios_timer(createGlobalTimer(getClassName() + "::updateRatios")),
600  evaluateDetsForPtclMove_timer(createGlobalTimer(getClassName() + "::evaluateDet")),
601  evaluateDetsAndGradsForPtclMove_timer(createGlobalTimer(getClassName() + "::evaluateDetAndGrad")),
602  evaluateGrads_timer(createGlobalTimer(getClassName() + "::evaluateGrad")),
603  offload_timer(createGlobalTimer(getClassName() + "::offload")),
604  transferH2D_timer(createGlobalTimer(getClassName() + "::transferH2D")),
605  transferD2H_timer(createGlobalTimer(getClassName() + "::transferD2H")),
606  Phi(std::move(spos)),
607  NumOrbitals(Phi->getOrbitalSetSize()),
608  FirstIndex(first),
609  NumPtcls(nel),
610  LastIndex(first + nel),
611  is_spinor_(spinor)
612 {
613  ciConfigList = std::make_shared<std::vector<ci_configuration2>>();
614  refdet_occup = std::make_shared<OffloadVector<size_t>>();
615  detData = std::make_shared<OffloadVector<int>>();
616  uniquePairs = std::make_shared<VectorSoaContainer<int, 2, OffloadPinnedAllocator<int>>>();
617  DetSigns = std::make_shared<OffloadVector<RealType>>();
618  ndets_per_excitation_level_ = std::make_shared<std::vector<int>>();
619 }
620 
621 ///default destructor
623 
625 {
626  assert(P.isSpinor() == is_spinor_);
627 
628  //extra pointers
629  FirstAddressOfGrads = &(grads(0, 0)[0]);
631  FirstAddressOfdpsiM = &(dpsiM(0, 0)[0]);
633 
634  //add the data:
635  buf.add(psiM.first_address(), psiM.last_address());
637  buf.add(d2psiM.first_address(), d2psiM.last_address());
638  buf.add(psiMinv.first_address(), psiMinv.last_address());
639  buf.add(log_value_ref_det_);
640  buf.add(ratios_to_ref_.first_address(), ratios_to_ref_.last_address());
643  if (is_spinor_)
644  {
645  buf.add(dspin_psiM.first_address(), dspin_psiM.last_address());
647  }
648 }
649 
651 {
652  collection.addResource(std::make_unique<MultiDiracDetMultiWalkerResource>());
653 }
654 
656  const RefVectorWithLeader<MultiDiracDeterminant>& wfc_list) const
657 {
658  auto& wfc_leader = wfc_list.getCastedLeader<MultiDiracDeterminant>();
660  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
661 
662  const size_t nw = wfc_list.size();
663  mw_res.resizeConstants(nw);
664 
665  auto& psiV_temp_deviceptr_list = mw_res.psiV_temp_deviceptr_list;
666  auto& psiMinv_temp_deviceptr_list = mw_res.psiMinv_temp_deviceptr_list;
667  auto& dpsiMinv_deviceptr_list = mw_res.dpsiMinv_deviceptr_list;
668  auto& workV1_deviceptr_list = mw_res.workV1_deviceptr_list;
669  auto& workV2_deviceptr_list = mw_res.workV2_deviceptr_list;
670 
671  auto& psiV_deviceptr_list = mw_res.psiV_deviceptr_list;
672  auto& dpsiV_deviceptr_list = mw_res.dpsiV_deviceptr_list;
673  auto& TpsiM_deviceptr_list = mw_res.TpsiM_deviceptr_list;
674  auto& psiM_deviceptr_list = mw_res.psiM_deviceptr_list;
675  auto& psiMinv_deviceptr_list = mw_res.psiMinv_deviceptr_list;
676  auto& dpsiM_deviceptr_list = mw_res.dpsiM_deviceptr_list;
677 
678  psiV_temp_deviceptr_list.resize(nw);
679  psiMinv_temp_deviceptr_list.resize(nw);
680  dpsiMinv_deviceptr_list.resize(nw);
681  workV1_deviceptr_list.resize(nw);
682  workV2_deviceptr_list.resize(nw);
683 
684  psiV_deviceptr_list.resize(nw);
685  dpsiV_deviceptr_list.resize(nw);
686  TpsiM_deviceptr_list.resize(nw);
687  psiM_deviceptr_list.resize(nw);
688  psiMinv_deviceptr_list.resize(nw);
689  dpsiM_deviceptr_list.resize(nw);
690 
691  for (size_t iw = 0; iw < nw; iw++)
692  {
693  auto& det = wfc_list.getCastedElement<MultiDiracDeterminant>(iw);
694  psiV_temp_deviceptr_list[iw] = det.psiV_temp.device_data();
695  psiMinv_temp_deviceptr_list[iw] = det.psiMinv_temp.device_data();
696  dpsiMinv_deviceptr_list[iw] = det.dpsiMinv.device_data();
697  workV1_deviceptr_list[iw] = det.workV1.device_data();
698  workV2_deviceptr_list[iw] = det.workV2.device_data();
699 
700  psiV_deviceptr_list[iw] = det.psiV.device_data();
701  dpsiV_deviceptr_list[iw] = det.dpsiV.device_data();
702  TpsiM_deviceptr_list[iw] = det.TpsiM.device_data();
703  psiM_deviceptr_list[iw] = det.psiM.device_data();
704  psiMinv_deviceptr_list[iw] = det.psiMinv.device_data();
705  dpsiM_deviceptr_list[iw] = det.dpsiM.device_data();
706  }
707 
708  psiV_temp_deviceptr_list.updateTo();
709  psiMinv_temp_deviceptr_list.updateTo();
710  dpsiMinv_deviceptr_list.updateTo();
711  workV1_deviceptr_list.updateTo();
712  workV2_deviceptr_list.updateTo();
713 
714  psiV_deviceptr_list.updateTo();
715  dpsiV_deviceptr_list.updateTo();
716  TpsiM_deviceptr_list.updateTo();
717  psiM_deviceptr_list.updateTo();
718  psiMinv_deviceptr_list.updateTo();
719  dpsiM_deviceptr_list.updateTo();
720 }
721 
723  const RefVectorWithLeader<MultiDiracDeterminant>& wfc_list) const
724 {
725  auto& wfc_leader = wfc_list.getCastedLeader<MultiDiracDeterminant>();
726  collection.takebackResource(wfc_leader.mw_res_handle_);
727 }
728 
729 ///reset the size: with the number of particles and number of orbtials
731 {
732  const int nel = NumPtcls;
733  assert(NumPtcls > 0);
734  const int NumDets = getNumDets();
735  assert(NumDets > 0);
736 
737  psiV_temp.resize(nel);
738  psiV.resize(NumOrbitals);
739  dpsiV.resize(NumOrbitals);
740  d2psiV.resize(NumOrbitals);
741  psiM.resize(nel, NumOrbitals);
742  dpsiM.resize(nel, NumOrbitals);
743  d2psiM.resize(nel, NumOrbitals);
744  TpsiM.resize(NumOrbitals, nel);
745  psiMinv.resize(nel, nel);
746  dpsiMinv.resize(nel, nel);
747  psiMinv_temp.resize(nel, nel);
748  //scratch spaces: stateless
749  WorkSpace.resize(std::max(nel, NumDets));
750  Pivot.resize(nel);
751  workV1.resize(nel);
752  workV2.resize(nel);
753  ratios_to_ref_.resize(NumDets);
754  new_ratios_to_ref_.resize(NumDets);
755  grads.resize(NumDets, nel);
756  new_grads.resize(NumDets, nel);
757  lapls.resize(NumDets, nel);
758  new_lapls.resize(NumDets, nel);
760  det_calculator_.resize(nel);
761 
762  if (is_spinor_)
763  {
764  dspin_psiV.resize(NumOrbitals);
765  dspin_psiM.resize(nel, NumOrbitals);
766  spingrads.resize(NumDets, nel);
767  new_spingrads.resize(NumDets, nel);
768  }
769 }
770 
771 void MultiDiracDeterminant::buildOptVariables(std::vector<size_t>& C2node)
772 {
773  if (!isOptimizable())
774  return;
775 
776  const size_t nel = NumPtcls;
777  const size_t nmo = NumOrbitals;
778  //a vector in which the element's index value correspond to Molecular Orbitals.
779  //The element value at an index indicates how many times an electron is excited from or to that orbital in the Multi-Slater expansion i.e the indices with non-zero elements are active space orbitals
780  std::vector<int> occupancy_vector(nmo, 0);
781 
782  // Function to fill occupancy_vectors and also return number of unique determinants
783  const size_t unique_dets = build_occ_vec(*detData, nel, nmo, occupancy_vector);
784 
785  // When calculating the parameter derivative of the Multi-Slater component of the wavefunction, each unique deterimant can contribute multiple times.
786  // The lookup_tbls are used so that a parameter derivative of a unique determinant is only done once and then scaled according to how many times it appears in the Multi-Slater expansion
787  lookup_tbl.resize(unique_dets);
788  //construct lookup table
789  for (int i(0); i < C2node.size(); i++)
790  {
791  lookup_tbl[C2node[i]].push_back(i);
792  }
793 
794  // create active rotation parameter indices
795  std::vector<std::pair<int, int>> m_act_rot_inds;
796  std::vector<std::pair<int, int>> other_rot_inds;
797 
798  for (int i = 0; i < nmo; i++)
799  for (int j = i + 1; j < nmo; j++)
800  {
801  bool core_i(!occupancy_vector[i] and i <= nel - 1); // true if orbital i is a 'core' orbital
802  bool core_j(!occupancy_vector[j] and j <= nel - 1); // true if orbital j is a 'core' orbital
803  bool virt_i(!occupancy_vector[i] and i > nel - 1); // true if orbital i is a 'virtual' orbital
804  bool virt_j(!occupancy_vector[j] and j > nel - 1); // true if orbital j is a 'virtual' orbital
805  if (!((core_i and core_j) or (virt_i and virt_j)))
806  {
807  m_act_rot_inds.push_back(
808  std::pair<
809  int,
810  int>(i,
811  j)); // orbital rotation parameter accepted as long as rotation isn't core-core or virtual-virtual
812  }
813  else
814  {
815  other_rot_inds.push_back(std::pair<int, int>(i, j));
816  }
817  }
818 
819  std::vector<std::pair<int, int>> full_rot_inds;
820 
821  // Copy the adjustable rotations first
822  full_rot_inds = m_act_rot_inds;
823  // Add the other rotations at the end
824  full_rot_inds.insert(full_rot_inds.end(), other_rot_inds.begin(), other_rot_inds.end());
825 
826 
827 #ifndef QMC_COMPLEX
828  RotatedSPOs* rot_spo = dynamic_cast<RotatedSPOs*>(Phi.get());
829  if (rot_spo)
830  rot_spo->buildOptVariables(m_act_rot_inds, full_rot_inds);
831 #endif
832 }
833 
835  const size_t nel,
836  const size_t nmo,
837  std::vector<int>& occ_vec)
838 {
839  size_t it = 0;
840  int count = 0; //number of determinants
841  while (it < data.size())
842  {
843  int k = data[it]; // number of excitations with respect to the reference matrix
844  if (count == 0)
845  {
846  it += 3 * k + 1;
847  count++;
848  }
849  else
850  {
851  for (int i = 0; i < k; i++)
852  {
853  //for determining active orbitals
854  occ_vec[data[it + 1 + i]]++;
855  occ_vec[data[it + 1 + k + i]]++;
856  }
857  it += 3 * k + 1;
858  count++;
859  }
860  }
861  return count;
862 }
863 
864 
866  const opt_variables_type& optvars,
867  Vector<ValueType>& dlogpsi,
868  Vector<ValueType>& dhpsioverpsi,
869  const MultiDiracDeterminant& pseudo_dn,
870  const ValueType& psiCurrent,
871  const std::vector<ValueType>& Coeff,
872  const std::vector<size_t>& C2node_up,
873  const std::vector<size_t>& C2node_dn)
874 {
875  if (!isOptimizable())
876  return;
877 
878  const OffloadVector<ValueType>& detValues_up = getRatiosToRefDet();
879  const OffloadVector<ValueType>& detValues_dn = pseudo_dn.getRatiosToRefDet();
880  const Matrix<GradType>& grads_up = grads;
881  const Matrix<GradType>& grads_dn = pseudo_dn.grads;
882  const Matrix<ValueType>& lapls_up = lapls;
883  const Matrix<ValueType>& lapls_dn = pseudo_dn.lapls;
884  const OffloadMatrix<ValueType>& M_up = psiM;
885  const OffloadMatrix<ValueType>& M_dn = pseudo_dn.psiM;
886  const OffloadMatrix<ValueType>& Minv_up = psiMinv;
887  const OffloadMatrix<ValueType>& Minv_dn = pseudo_dn.psiMinv;
888  const OffloadMatrix<GradType>& B_grad = dpsiM;
889  const OffloadMatrix<ValueType>& B_lapl = d2psiM;
890  std::vector<int> detData_local(detData->size());
891  for (size_t i = 0; i < detData->size(); i++)
892  detData_local[i] = (*detData)[i];
893 
894 
895  const size_t N1 = FirstIndex;
896  const size_t N2 = pseudo_dn.FirstIndex;
897  const size_t NP1 = NumPtcls;
898  const size_t NP2 = pseudo_dn.NumPtcls;
899  Vector<ValueType> detValues_up_host_view(const_cast<ValueType*>(detValues_up.data()), detValues_up.size());
900  Vector<ValueType> detValues_dn_host_view(const_cast<ValueType*>(detValues_dn.data()), detValues_dn.size());
901  Matrix<ValueType> M_up_host_view(const_cast<ValueType*>(M_up.data()), M_up.rows(), M_up.cols());
902  Matrix<ValueType> M_dn_host_view(const_cast<ValueType*>(M_dn.data()), M_dn.rows(), M_dn.cols());
903  Matrix<ValueType> Minv_up_host_view(const_cast<ValueType*>(Minv_up.data()), Minv_up.rows(), Minv_up.cols());
904  Matrix<ValueType> Minv_dn_host_view(const_cast<ValueType*>(Minv_dn.data()), Minv_dn.rows(), Minv_dn.cols());
905  Matrix<GradType> B_grad_host_view(const_cast<GradType*>(B_grad.data()), B_grad.rows(), B_grad.cols());
906  Matrix<ValueType> B_lapl_host_view(const_cast<ValueType*>(B_lapl.data()), B_lapl.rows(), B_lapl.cols());
907  Phi->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi, psiCurrent, Coeff, C2node_up, C2node_dn,
908  detValues_up_host_view, detValues_dn_host_view, grads_up, grads_dn, lapls_up, lapls_dn,
909  M_up_host_view, M_dn_host_view, Minv_up_host_view, Minv_dn_host_view, B_grad_host_view,
910  B_lapl_host_view, detData_local, N1, N2, NP1, NP2, lookup_tbl);
911 }
912 
913 
915  const opt_variables_type& optvars,
916  Vector<ValueType>& dlogpsi,
917  const MultiDiracDeterminant& pseudo_dn,
918  const PsiValue& psiCurrent,
919  const std::vector<ValueType>& Coeff,
920  const std::vector<size_t>& C2node_up,
921  const std::vector<size_t>& C2node_dn)
922 {
923  if (!isOptimizable())
924  return;
925 
926  const OffloadVector<ValueType>& detValues_up = getRatiosToRefDet();
927  const OffloadVector<ValueType>& detValues_dn = pseudo_dn.getRatiosToRefDet();
928  const OffloadMatrix<ValueType>& M_up = psiM;
929  const OffloadMatrix<ValueType>& M_dn = pseudo_dn.psiM;
930  const OffloadMatrix<ValueType>& Minv_up = psiMinv;
931  const OffloadMatrix<ValueType>& Minv_dn = pseudo_dn.psiMinv;
932 
933  std::vector<int> detData_local(detData->size());
934  for (size_t i = 0; i < detData->size(); i++)
935  detData_local[i] = (*detData)[i];
936  Vector<ValueType> detValues_up_host_view(const_cast<ValueType*>(detValues_up.data()), detValues_up.size());
937  Vector<ValueType> detValues_dn_host_view(const_cast<ValueType*>(detValues_dn.data()), detValues_dn.size());
938  Matrix<ValueType> M_up_host_view(const_cast<ValueType*>(M_up.data()), M_up.rows(), M_up.cols());
939  Matrix<ValueType> M_dn_host_view(const_cast<ValueType*>(M_dn.data()), M_dn.rows(), M_dn.cols());
940  Matrix<ValueType> Minv_up_host_view(const_cast<ValueType*>(Minv_up.data()), Minv_up.rows(), Minv_up.cols());
941  Matrix<ValueType> Minv_dn_host_view(const_cast<ValueType*>(Minv_dn.data()), Minv_dn.rows(), Minv_dn.cols());
942  Phi->evaluateDerivativesWF(P, optvars, dlogpsi, psiCurrent, Coeff, C2node_up, C2node_dn, detValues_up_host_view,
943  detValues_dn_host_view, M_up_host_view, M_dn_host_view, Minv_up_host_view,
944  Minv_dn_host_view, detData_local, lookup_tbl);
945 }
946 
947 } // namespace qmcplusplus
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
~MultiDiracDeterminant() override
default destructor
Container_t::iterator begin()
Definition: OhmmsMatrix.h:89
std::shared_ptr< OffloadVector< size_t > > refdet_occup
reference determinant occupation
Matrix< ValueType > lapls
store determinant lapls (old and new)
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
std::shared_ptr< std::vector< ci_configuration2 > > ciConfigList
use shared_ptr
void takebackResource(ResourceHandle< RS > &res_handle)
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::shared_ptr< OffloadVector< int > > detData
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
pointer last_address()
Definition: OhmmsMatrix.h:209
const int NumPtcls
number of particles which belong to this Dirac determinant
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
OffloadMatrix< GradType > dpsiM
dpsiM(i,j)
LogValue log_value_ref_det_
log value of the reference determinant
std::ostream & app_log()
Definition: OutputManager.h:65
OffloadMatrix< ValueType > psiMinv_temp
Matrix< GradType > grads
store determinant grads (old and new)
LatticeGaussianProduct::GradType GradType
std::shared_ptr< std::vector< int > > ndets_per_excitation_level_
number of unique determinants at each excitation level (relative to reference) {1, n_singles, n_doubles, n_triples, ...}
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
void evaluateForWalkerMoveWithSpin(const ParticleSet &P, bool fromScratch=true)
#define OHMMS_DIM
Definition: config.h:64
void createDetData(const int ref_det_id, const std::vector< ci_configuration2 > &configlist_unsorted, const std::vector< size_t > &C2nodes_unsorted, std::vector< size_t > &C2nodes_sorted)
create necessary structures related to unique determinants sort configlist_unsorted by excitation lev...
static void mw_accept_rejectMove(const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted)
static constexpr int ReferenceDeterminant
all the unique determinants are sorted, the id of the reference det id is always 0 ...
size_type cols() const
Definition: OhmmsMatrix.h:78
std::complex< QTFull::RealType > LogValue
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
void buildOptVariables(std::vector< size_t > &C2node)
create optimizable orbital rotation parameters
void buildOptVariables(size_t nel)
An abstract class for a component of a many-body trial wave function.
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void buildTableMatrix_calculateRatiosValueMatrixOneParticle(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, int iat, Matrix< ValueType > &ratios)
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list) const
OffloadVector< ValueType > ratios_to_ref_
determinant ratios with respect to the reference determinant
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< MultiDiracDeterminant > &wfc_list) const
size_type size() const
return the current size
Definition: OhmmsVector.h:162
OffloadVector< ValueType > psiV
value of single-particle orbital for particle-by-particle update
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::shared_ptr< OffloadVector< RealType > > DetSigns
void InvertWithLog(T *restrict x, int n, int m, T *restrict work, int *restrict pivot, std::complex< T1 > &logdet)
OffloadMatrix< ValueType > psiMinv
inverse Dirac determinant matrix of the reference det
CASTTYPE & getCastedElement(size_t i) const
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
int build_occ_vec(const OffloadVector< int > &data, const size_t nel, const size_t nmo, std::vector< int > &occ_vec)
helper function to buildOptVariables
std::shared_ptr< VectorSoaContainer< int, 2, OffloadPinnedAllocator< int > > > uniquePairs
ValueType curRatio
new value of the reference determinant over the old value upon a proposed move
OffloadVector< ValueType > WorkSpace
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
pointer first_address()
Definition: OhmmsMatrix.h:204
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
move was accepted, update the real container
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
size_type rows() const
Definition: OhmmsMatrix.h:77
double sign(double x)
Definition: Standard.h:73
OffloadMatrix< ValueType > d2psiM
d2psiM(i,j)
bool isOptimizable() const final
if true, this contains optimizable components
OffloadMatrix< ValueType > table_matrix
SmallMatrixDetCalculator< ValueType > det_calculator_
OffloadVector< ValueType > psiV_temp
std::unique_ptr< SPOSet > clonePhi() const
return a clone of Phi
Define determinant operators.
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, const MultiDiracDeterminant &pseudo_dn, const PsiValue &psiCurrent, const std::vector< ValueType > &Coeff, const std::vector< size_t > &C2node_up, const std::vector< size_t > &C2node_dn)
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
MultiDiracDeterminant(std::unique_ptr< SPOSet > &&spos, bool spinor, int first, int nel)
constructor
OffloadMatrix< ValueType > psiM
psiM(i,j) TpsiM(i,j)
OffloadVector< ValueType > new_ratios_to_ref_
new determinant ratios with respect to the updated reference determinant upon a proposed move ...
ResourceHandle< MultiDiracDetMultiWalkerResource > mw_res_handle_
void restore(int iat) override
move was rejected.
void evaluateForWalkerMove(const ParticleSet &P, bool fromScratch=true)
LatticeGaussianProduct::ValueType ValueType
void resize()
reset the size: with the number of particles
void buildTableMatrix_calculateRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, OffloadMatrix< ValueType > &table_matrix, OffloadVector< ValueType > &ratios)
compute the ratio of the excited determinants to the reference determinant
const int FirstIndex
index of the first particle with respect to the particle set
ResourceHandle< RS > lendResource()
const int LastIndex
index of the last particle with respect to the particle set
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
std::vector< std::vector< int > > lookup_tbl
Container_t::iterator end()
Definition: OhmmsMatrix.h:90
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
const OffloadVector< ValueType > & getRatiosToRefDet() const
void put(std::complex< T1 > &x)
Definition: PooledMemory.h:165
void InverseUpdateByColumn(Matrix< T, ALLOC > &Minv, Vector< T, ALLOC > &newcol, Vector< T, ALLOC > &rvec, Vector< T, ALLOC > &rvecinv, int colchanged, T c_ratio)
void buildTableMatrix_calculateGradRatios(int ref, const OffloadMatrix< ValueType > &psiinv, const OffloadMatrix< ValueType > &psi, const OffloadVector< int > &data, const VectorSoaContainer< int, 2, OffloadPinnedAllocator< int >> &pairs, const OffloadVector< RealType > &sign, const ValueType &det0_grad, OffloadMatrix< ValueType > &table_matrix, int dx, int iat, Matrix< GradType > &grads)
Function to calculate the ratio of the gradients of the excited determinant to the reference determin...
void add(std::complex< T1 > &x)
Definition: PooledMemory.h:113
void get(std::complex< T1 > &x)
Definition: PooledMemory.h:132