47 std::unique_ptr<Resource>
makeClone()
const override {
return std::make_unique<TwoBodyJastrowMultiWalkerMem>(*this); }
62 const size_t nw = wfc_list.size();
63 auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
64 mw_allUat.resize(N_padded * (
DIM + 2) * nw);
65 for (
size_t iw = 0; iw < nw; iw++)
73 wfc.Uat.attachReference(mw_allUat.data() + iw * N_padded,
N);
80 wfc.dUat.attachReference(
N, N_padded, mw_allUat.data() + nw * N_padded + iw * N_padded *
DIM);
83 d2Uat_view = wfc.d2Uat;
85 wfc.d2Uat.attachReference(mw_allUat.data() + nw * N_padded * (
DIM + 1) + iw * N_padded,
N);
87 wfc_leader.mw_mem_handle_.getResource().mw_cur_allu.resize(N_padded * 3 * nw);
95 const size_t nw = wfc_list.size();
96 auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
97 for (
size_t iw = 0; iw < nw; iw++)
112 wfc.dUat = dUat_view;
117 wfc.d2Uat = d2Uat_view;
122 template<
typename FT>
125 for (
auto& [key, functor] : J2Unique)
129 template<
typename FT>
133 for (
auto& [key, functor] : J2Unique)
135 functor->myVars.getIndex(active);
136 myVars.insertFrom(functor->myVars);
139 myVars.removeInactive();
141 myVars.getIndex(active);
143 const size_t NumVars = myVars.size();
146 OffSet.resize(F.size());
150 for (
int i = 0; i < myVars.size(); i++)
152 varoffset = myVars.Index[i];
157 for (
int i = 0; i < F.size(); ++i)
158 if (F[i] && F[i]->myVars.Index.size())
160 OffSet[i].first = F[i]->myVars.Index.front() - varoffset;
161 OffSet[i].second = F[i]->myVars.Index.size() + OffSet[i].first;
164 OffSet[i].first = OffSet[i].second = -1;
168 template<
typename FT>
171 for (
int k = 0; k < ratios.size(); ++k)
176 template<
typename FT>
179 std::vector<std::vector<ValueType>>& ratios)
const 188 if (wfc_list.size() == 0)
192 const auto& mw_refPctls = vp_leader.getMultiWalkerRefPctls();
194 const int nw = wfc_list.size();
196 const size_t nVPs = mw_refPctls.size();
197 mw_vals.resize(nVPs);
201 const int igt = vp_leader.getRefPS().getGroupID(vp_list[0].refPtcl);
202 const auto& dt_leader(vp_leader.getDistTableAB(wfc_leader.my_table_ID_));
204 FT::mw_evaluateV(NumGroups, F.data() + igt * NumGroups, wfc_leader.N, grp_ids.data(), nVPs, mw_refPctls.data(),
205 dt_leader.getMultiWalkerDataPtr(), dt_leader.getPerTargetPctlStrideSize(), mw_vals.data(),
206 wfc_leader.mw_mem_handle_.getResource().transfer_buffer);
209 for (
int iw = 0; iw < nw; ++iw)
214 ratios[iw][k] =
std::exp(wfc.Uat[mw_refPctls[ivp]] - mw_vals[ivp]);
219 template<
typename FT>
222 if (Bytes_in_WFBuffer == 0)
224 Bytes_in_WFBuffer = buf.
current();
225 buf.
add(Uat.begin(), Uat.end());
226 buf.
add(dUat.data(), dUat.end());
227 buf.
add(d2Uat.begin(), d2Uat.end());
228 Bytes_in_WFBuffer = buf.
current() - Bytes_in_WFBuffer;
236 buf.
forward(Bytes_in_WFBuffer);
240 template<
typename FT>
248 template<
typename FT>
253 log_value_ = computeGL(P.
G, P.
L);
254 buf.
forward(Bytes_in_WFBuffer);
258 template<
typename FT>
262 const int igt = P.
GroupID[iat] * NumGroups;
263 for (
int jg = 0; jg < NumGroups; ++jg)
267 int iStart = P.
first(jg);
268 int iEnd = P.
last(jg);
269 curUat += f2.evaluateV(iat, iStart, iEnd, dist.
data(), DistCompressed.data());
274 template<
typename FT>
278 for (
int idim = 0; idim < ndim; ++idim)
280 const valT* restrict dX = displ.
data(idim);
283 #pragma omp simd reduction(+ : s) aligned(du, dX : QMC_SIMD_ALIGNMENT) 284 for (
int jat = 0; jat <
N; ++jat)
285 s += du[jat] * dX[jat];
291 template<
typename FT>
295 NumGroups(p.groups()),
296 ndim(p.getLattice().ndim),
298 use_offload_(use_offload),
300 my_table_ID_(p.addTable(p)),
301 j2_ke_corr_helper(p, F)
304 throw std::runtime_error(
"TwoBodyJastrow object name cannot be empty!");
312 for (
int j = p.
first(ig); j < p.
last(ig); j++)
322 template<
typename FT>
325 template<
typename FT>
328 if (std::any_of(F.begin(), F.end(), [](
auto* ptr) {
return ptr ==
nullptr; }))
329 app_warning() <<
"Two-body Jastrow \"" << my_name_ <<
"\" doesn't cover all the particle pairs. " 330 <<
"Consider fusing multiple entries if they are of the same type for optimal code performance." 334 template<
typename FT>
347 DistCompressed.resize(
N);
348 DistIndice.resize(
N);
351 template<
typename FT>
354 assert(ia < NumGroups);
355 assert(ib < NumGroups);
361 for (
int ig = 0; ig < NumGroups; ++ig)
362 for (
int jg = 0; jg < NumGroups; ++jg, ++ij)
363 if (F[ij] ==
nullptr)
367 F[ia * NumGroups + ib] = j.get();
374 for (
int ig = 0; ig < NumGroups; ++ig)
375 F[ig * NumGroups + ig] = j.get();
377 F[ia * NumGroups + ib] = j.get();
378 F[ib * NumGroups + ia] = j.get();
380 std::stringstream aname;
382 J2Unique[aname.str()] = std::move(j);
385 template<
typename FT>
388 auto j2copy = std::make_unique<TwoBodyJastrow<FT>>(my_name_, tqp, use_offload_);
389 std::map<const FT*, FT*> fcmap;
390 for (
int ig = 0; ig < NumGroups; ++ig)
391 for (
int jg = ig; jg < NumGroups; ++jg)
393 int ij = ig * NumGroups + jg;
396 typename std::map<const FT*, FT*>::iterator fit = fcmap.find(F[ij]);
397 if (fit == fcmap.end())
399 auto fc = std::make_unique<FT>(*F[ij]);
400 fcmap[F[ij]] = fc.get();
401 j2copy->addFunc(ig, jg, std::move(fc));
404 j2copy->KEcorr = KEcorr;
406 j2copy->myVars.clear();
407 j2copy->myVars.insertFrom(myVars);
408 j2copy->OffSet = OffSet;
421 template<
typename FT>
430 const int jelmax = triangle ? iat :
N;
436 const int igt = P.
GroupID[iat] * NumGroups;
437 for (
int jg = 0; jg < NumGroups; ++jg)
441 int iStart = P.
first(jg);
443 f2.evaluateVGL(iat, iStart, iEnd, dist.
data(), u, du, d2u, DistCompressed.data(), DistIndice.data());
450 template<
typename FT>
454 UpdateMode = ORB_PBYP_RATIO;
456 return std::exp(static_cast<PsiValue>(Uat[iat] - cur_Uat));
459 template<
typename FT>
463 std::vector<PsiValue>& ratios)
const 475 const auto& dt_leader = p_leader.getDistTableAA(my_table_ID_);
476 const int nw = wfc_list.size();
478 auto& mw_vgl = wfc_leader.mw_mem_handle_.getResource().mw_vgl;
479 mw_vgl.resize(nw,
DIM + 2);
481 auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
482 auto& mw_cur_allu = wfc_leader.mw_mem_handle_.getResource().mw_cur_allu;
484 FT::mw_evaluateVGL(iat, NumGroups, F.data() + p_leader.GroupID[iat] * NumGroups, wfc_leader.
N, grp_ids.data(), nw,
485 mw_vgl.data(), N_padded, dt_leader.getMultiWalkerTempDataPtr(), mw_cur_allu.data(),
486 wfc_leader.mw_mem_handle_.getResource().mw_ratiograd_buffer);
488 for (
int iw = 0; iw < nw; iw++)
492 ratios[iw] =
std::exp(static_cast<PsiValue>(wfc.Uat[iat] - wfc.cur_Uat));
497 template<
typename FT>
503 for (
int ig = 0; ig < NumGroups; ++ig)
505 const int igt = ig * NumGroups;
507 for (
int jg = 0; jg < NumGroups; ++jg)
511 int iStart = P.
first(jg);
512 int iEnd = P.
last(jg);
513 sumU += f2.evaluateV(-1, iStart, iEnd, dist.data(), DistCompressed.data());
516 for (
int i = P.
first(ig); i < P.
last(ig); ++i)
519 const valT Uself = F[igt + ig]->evaluate(dist[i]);
520 ratios[i] =
std::exp(Uat[i] + Uself - sumU);
525 template<
typename FT>
531 template<
typename FT>
534 UpdateMode = ORB_PBYP_PARTIAL;
538 DiffVal = Uat[iat] - cur_Uat;
540 return std::exp(static_cast<PsiValue>(DiffVal));
543 template<
typename FT>
547 std::vector<PsiValue>& ratios,
548 std::vector<GradType>& grad_new)
const 559 const auto& dt_leader = p_leader.getDistTableAA(my_table_ID_);
560 const int nw = wfc_list.size();
562 auto& mw_vgl = wfc_leader.mw_mem_handle_.getResource().mw_vgl;
563 mw_vgl.resize(nw,
DIM + 2);
565 auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
566 auto& mw_cur_allu = wfc_leader.mw_mem_handle_.getResource().mw_cur_allu;
568 FT::mw_evaluateVGL(iat, NumGroups, F.data() + p_leader.GroupID[iat] * NumGroups, wfc_leader.
N, grp_ids.data(), nw,
569 mw_vgl.data(), N_padded, dt_leader.getMultiWalkerTempDataPtr(), mw_cur_allu.data(),
570 wfc_leader.mw_mem_handle_.getResource().mw_ratiograd_buffer);
572 for (
int iw = 0; iw < nw; iw++)
576 ratios[iw] =
std::exp(static_cast<PsiValue>(wfc.Uat[iat] - wfc.cur_Uat));
577 for (
int idim = 0; idim < ndim; idim++)
578 grad_new[iw][idim] += mw_vgl[iw][idim + 1];
582 template<
typename FT>
587 computeU3(P, iat, d_table.getOldDists(), old_u.data(), old_du.data(), old_d2u.data());
588 if (UpdateMode == ORB_PBYP_RATIO)
591 computeU3(P, iat, dist, cur_u.data(), cur_du.data(), cur_d2u.data());
595 const auto& new_dr = d_table.getTempDispls();
596 const auto& old_dr = d_table.getOldDispls();
597 #pragma omp simd reduction(+ : cur_d2Uat) 598 for (
int jat = 0; jat <
N; jat++)
600 const valT du = cur_u[jat] - old_u[jat];
601 const valT newl = cur_d2u[jat] + lapfac * cur_du[jat];
602 const valT dl = old_d2u[jat] + lapfac * old_du[jat] - newl;
608 for (
int idim = 0; idim < ndim; ++idim)
610 const valT* restrict new_dX = new_dr.
data(idim);
611 const valT* restrict old_dX = old_dr.data(idim);
612 const valT* restrict cur_du_pt = cur_du.data();
613 const valT* restrict old_du_pt = old_du.data();
614 valT* restrict save_g = dUat.data(idim);
615 valT cur_g = cur_dUat[idim];
616 #pragma omp simd reduction(+ : cur_g) aligned(old_dX, new_dX, save_g, cur_du_pt, old_du_pt : QMC_SIMD_ALIGNMENT) 617 for (
int jat = 0; jat <
N; jat++)
619 const valT newg = cur_du_pt[jat] * new_dX[jat];
620 const valT dg = newg - old_du_pt[jat] * old_dX[jat];
624 cur_dUat[idim] = cur_g;
626 log_value_ += Uat[iat] - cur_Uat;
628 dUat(iat) = cur_dUat;
629 d2Uat[iat] = cur_d2Uat;
632 template<
typename FT>
636 const std::vector<bool>& isAccepted,
637 bool safe_to_delay)
const 648 const auto& dt_leader = p_leader.getDistTableAA(my_table_ID_);
649 const int nw = wfc_list.size();
651 auto& mw_vgl = wfc_leader.mw_mem_handle_.getResource().mw_vgl;
653 auto& mw_allUat = wfc_leader.mw_mem_handle_.getResource().mw_allUat;
654 auto& mw_cur_allu = wfc_leader.mw_mem_handle_.getResource().mw_cur_allu;
656 for (
int iw = 0; iw < nw; iw++)
659 wfc.
log_value_ += wfc.Uat[iat] - mw_vgl[iw][0];
663 FT::mw_updateVGL(iat, isAccepted, NumGroups, F.data() + p_leader.GroupID[iat] * NumGroups, wfc_leader.
N,
664 grp_ids.data(), nw, mw_vgl.data(), N_padded, dt_leader.getMultiWalkerTempDataPtr(), mw_allUat.data(),
665 mw_cur_allu.data(), wfc_leader.mw_mem_handle_.getResource().mw_update_buffer);
668 template<
typename FT>
672 for (
int ig = 0; ig < NumGroups; ++ig)
674 for (
int iat = P.
first(ig), last = P.
last(ig); iat < last; ++iat)
676 computeU3(P, iat, d_table.getDistRow(iat), cur_u.data(), cur_du.data(), cur_d2u.data(),
true);
680 const valT* restrict u = cur_u.data();
681 const valT* restrict du = cur_du.data();
682 const valT* restrict d2u = cur_d2u.data();
683 const auto& displ = d_table.getDisplRow(iat);
684 #pragma omp simd reduction(+ : lap) aligned(du, d2u : QMC_SIMD_ALIGNMENT) 685 for (
int jat = 0; jat < iat; ++jat)
686 lap += d2u[jat] + lapfac * du[jat];
687 for (
int idim = 0; idim < ndim; ++idim)
689 const valT* restrict dX = displ.data(idim);
691 #pragma omp simd reduction(+ : s) aligned(du, dX : QMC_SIMD_ALIGNMENT) 692 for (
int jat = 0; jat < iat; ++jat)
693 s += du[jat] * dX[jat];
699 #pragma omp simd aligned(u, du, d2u : QMC_SIMD_ALIGNMENT) 700 for (
int jat = 0; jat < iat; jat++)
703 d2Uat[jat] -= d2u[jat] + lapfac * du[jat];
705 for (
int idim = 0; idim < ndim; ++idim)
707 valT* restrict save_g = dUat.data(idim);
708 const valT* restrict dX = displ.data(idim);
709 #pragma omp simd aligned(save_g, du, dX : QMC_SIMD_ALIGNMENT) 710 for (
int jat = 0; jat < iat; jat++)
711 save_g[jat] -= du[jat] * dX[jat];
717 template<
typename FT>
720 const std::vector<bool>& recompute)
const 729 assert(
this == &wfc_leader);
730 for (
int iw = 0; iw < wfc_list.size(); iw++)
732 wfc_list[iw].recompute(p_list[iw]);
733 wfc_leader.mw_mem_handle_.getResource().mw_allUat.updateTo();
736 template<
typename FT>
742 return log_value_ = computeGL(G, L);
745 template<
typename FT>
759 const std::vector<bool> recompute_all(wfc_list.size(),
true);
760 mw_recompute(wfc_list, p_list, recompute_all);
762 for (
int iw = 0; iw < wfc_list.size(); iw++)
765 wfc.
log_value_ = wfc.computeGL(G_list[iw], L_list[iw]);
770 template<
typename FT>
774 for (
int iat = 0; iat <
N; ++iat)
777 L[iat] += d2Uat[iat];
782 template<
typename FT>
788 return log_value_ = computeGL(G, L);
791 template<
typename FT>
796 bool fromscratch)
const 805 for (
int iw = 0; iw < wfc_list.size(); iw++)
808 wfc.
log_value_ = wfc.computeGL(G_list[iw], L_list[iw]);
812 template<
typename FT>
816 throw std::runtime_error(
"double check! See 2d jastrow test.");
825 for (
int i = 1; i <
N; ++i)
827 const auto& dist = d_ee.getDistRow(i);
828 const auto& displ = d_ee.getDisplRow(i);
830 const int igt = ig * NumGroups;
831 for (
int j = 0; j < i; ++j)
837 auto uij = F[igt + jg]->evaluate(r, dudr, d2udr2);
839 auto hess = rinv * rinv *
outerProduct(dr, dr) * (d2udr2 - dudr * rinv) + ident * dudr * rinv;
840 grad_grad_psi[i] -= hess;
841 grad_grad_psi[j] -= hess;
846 template<
typename FT>
852 if (myVars.size() == 0)
855 evaluateDerivativesWF(P, active, dlogpsi);
856 bool recalculate(
false);
857 std::vector<bool> rcsingles(myVars.size(),
false);
858 for (
int k = 0; k < myVars.size(); ++k)
860 int kk = myVars.where(k);
869 for (
int k = 0; k < myVars.size(); ++k)
871 int kk = myVars.where(k);
882 template<
typename FT>
887 if (myVars.size() == 0)
890 resizeWFOptVectors();
892 bool recalculate(
false);
893 std::vector<bool> rcsingles(myVars.size(),
false);
894 for (
int k = 0; k < myVars.size(); ++k)
896 int kk = myVars.where(k);
906 std::vector<bool> RecalcSwitch(F.size(),
false);
907 for (
int i = 0; i < F.size(); ++i)
909 if (OffSet[i].first < 0)
912 RecalcSwitch[i] =
false;
916 bool recalcFunc(
false);
917 for (
int rcs = OffSet[i].first; rcs < OffSet[i].second; rcs++)
918 if (rcsingles[rcs] ==
true)
920 RecalcSwitch[i] = recalcFunc;
924 const size_t NumVars = myVars.size();
925 for (
int p = 0; p < NumVars; ++p)
930 std::vector<TinyVector<RealType, 3>> derivs(NumVars);
933 const size_t n = d_table.sources();
934 const size_t ng = P.
groups();
935 for (
size_t i = 1; i <
n; ++i)
937 const size_t ig = P.
GroupID[i] * ng;
938 const auto& dist = d_table.getDistRow(i);
939 const auto& displ = d_table.getDisplRow(i);
940 for (
size_t j = 0; j < i; ++j)
942 const size_t ptype = ig + P.
GroupID[j];
943 if (RecalcSwitch[ptype])
945 std::fill(derivs.begin(), derivs.end(), 0.0);
946 if (!F[ptype]->evaluateDerivatives(dist[j], derivs))
952 for (
int p = OffSet[ptype].first, ip = 0; p < OffSet[ptype].second; ++p, ++ip)
954 RealType dudr(rinv * derivs[ip][1]);
955 RealType lap(derivs[ip][2] + lapfac * dudr);
957 dLogPsi[p] -= derivs[ip][0];
958 gradLogPsi[p][i] += gr;
959 gradLogPsi[p][j] -= gr;
960 lapLogPsi[p][i] -= lap;
961 lapLogPsi[p][j] -= lap;
966 for (
int k = 0; k < myVars.size(); ++k)
968 int kk = myVars.where(k);
973 dlogpsi[kk] = dLogPsi[k];
980 template<
typename FT>
983 std::vector<ValueType>& ratios,
986 evaluateRatios(VP, ratios);
987 if (myVars.size() == 0)
990 bool recalculate(
false);
991 std::vector<bool> rcsingles(myVars.size(),
false);
992 for (
int k = 0; k < myVars.size(); ++k)
994 int kk = myVars.where(k);
1005 std::vector<bool> RecalcSwitch(F.size(),
false);
1006 for (
int i = 0; i < F.size(); ++i)
1008 if (OffSet[i].first < 0)
1011 RecalcSwitch[i] =
false;
1015 bool recalcFunc(
false);
1016 for (
int rcs = OffSet[i].first; rcs < OffSet[i].second; rcs++)
1017 if (rcsingles[rcs] ==
true)
1019 RecalcSwitch[i] = recalcFunc;
1022 const size_t NumVars = myVars.size();
1023 std::vector<RealType> derivs_ref(NumVars);
1024 std::vector<RealType> derivs(NumVars);
1026 const size_t n = d_table.sources();
1028 for (
size_t i = 0; i <
n; ++i)
1033 if (!RecalcSwitch[ptype])
1038 std::fill(derivs_ref.begin(), derivs_ref.end(), 0.0);
1039 F[ptype]->evaluateDerivatives(dist_ref, derivs_ref);
1040 for (
size_t j = 0; j < nt; ++j)
1042 std::fill(derivs.begin(), derivs.end(), 0.0);
1043 F[ptype]->evaluateDerivatives(d_table.getDistRow(j)[i], derivs);
1044 for (
int ip = 0, p = F[ptype]->myVars.Index.front(); ip < F[ptype]->myVars.Index.size(); ++ip, ++p)
1045 dratios[j][p] += derivs_ref[ip] - derivs[ip];
void checkSanity() const override
Validate the internal consistency of the object.
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
T Sum(const ParticleAttrib< T > &pa)
bool recompute(int i) const
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
size_t getAlignedSize(size_t n)
return size in T's of allocated aligned memory
std::ostream & app_warning()
void takebackResource(ResourceHandle< RS > &res_handle)
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
const ParticleSet & getRefPS() const
ParticleSet this object refers to.
void mw_evaluateLog(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const override
evaluate from scratch the same type WaveFunctionComponent of multiple walkers
helper functions for EinsplineSetBuilder
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
const DistanceTableAA & getDistTableAA(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAA
virtual void mw_recompute(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
std::unique_ptr< Resource > makeClone() const override
const DistRow & getDistRow(int iel) const
return a row of distances for a given target particle
void forward(size_type n)
void addFunc(int ia, int ib, std::unique_ptr< FT > j)
add functor for (ia,ib) pair
void fill_n(T *x, size_t count, const T &value)
constexpr std::complex< float > czero
Vector< char, OffloadPinnedAllocator< char > > mw_update_buffer
constexpr std::complex< float > cone
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
size_t getTotalNum() const
int refPtcl
Reference particle.
LatticeGaussianProduct::GradType GradType
SoA adaptor class for Vector<TinyVector<T,D> >
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
int first(int igroup) const
return the first index of a group i
const DisplRow & getTempDispls() const
return the temporary displacements when a move is proposed
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
Attaches a unit to a Vector for IO.
ParticleLaplacian L
laplacians of the particles
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
const DistRow & getTempDists() const
return the temporary distances when a move is proposed
void resizeInternalStorage()
initialize storage Uat,dUat, d2Uat
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
return a shared resource to a collection
ParticleIndex GroupID
Species ID.
virtual void mw_evaluateGL(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const
evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers ...
std::vector< FT * > F
Container for . treat every pointer as a reference.
std::complex< QTFull::RealType > LogValue
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
int groups() const
return the number of groups
An abstract class for a component of a many-body trial wave function.
posT accumulateG(const valT *restrict du, const DisplRow &displ) const
compute gradient
Specialized paritlce class for atomistic simulations.
TwoBodyJastrow(const std::string &obj_name, ParticleSet &p, bool use_offload)
Vector< char, OffloadPinnedAllocator< char > > transfer_buffer
void recompute(const ParticleSet &P) override
recompute internal data assuming distance table is fully ready
void mw_evaluateRatios(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const override
Tensor<T,D> class for D by D tensor.
Matrix< T, OffloadPinnedAllocator< T > > mw_vgl
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > outerProduct(const TinyVector< T1, D > &lhs, const TinyVector< T2, D > &rhs)
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
ParticleGradient G
gradients of the particles
CASTTYPE & getCastedElement(size_t i) const
ResourceHandle< TwoBodyJastrowMultiWalkerMem< RealType > > mw_mem_handle_
valT computeU(const ParticleSet &P, int iat, const DistRow &dist)
class to handle a set of variables that can be modified during optimizations
void mw_evaluateGL(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const override
evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers ...
Vector< char, OffloadPinnedAllocator< char > > mw_ratiograd_buffer
int last(int igroup) const
return the last index of a group i
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
QTFull::ValueType PsiValue
const DistRow & getDistRow(int iel) const
return a row of distances for a given target particle
typename FT::real_type valT
type of each component U, dU, d2U;
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
void evaluateDerivRatios(const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
~TwoBodyJastrow() override
T * data()
return the base
Specialization for two-body Jastrow function using multiple functors.
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const override
void diagonal(const T &rhs)
LogValue log_value_
Current .
void evaluateHessian(ParticleSet &P, HessVector &grad_grad_psi) override
void computeU3(const ParticleSet &P, int iat, const DistRow &dist, RealType *restrict u, RealType *restrict du, RealType *restrict d2u, bool triangle=false)
intenal function to compute
size_type current() const
virtual void mw_accept_rejectMove(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const
moves of the iat-th particle on some walkers in a batch is accepted.
std::vector< std::reference_wrapper< T > > RefVector
virtual void mw_evaluateLog(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const
evaluate from scratch the same type WaveFunctionComponent of multiple walkers
QMCTraits::RealType RealType
CASTTYPE & getCastedLeader() const
Vector< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
Vector< T, OffloadPinnedAllocator< T > > mw_cur_allu
memory pool for cur_u, cur_du, cur_d2u [3][Nw][N_padded]. 3 is for value, first and second derivative...
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
acquire a shared resource from a collection
const size_t NumGroups
number of groups of the target particleset
LogValue evaluateGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch=false) override
compute G and L after the sweep
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
Declaraton of ParticleAttrib<T>
virtual void mw_evaluateRatios(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const
evaluate ratios to evaluate the non-local PP multiple walkers
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
void free()
free allocated memory and clear status variables
OrbitalSetTraits< ValueType >::HessVector HessVector
LatticeGaussianProduct::ValueType ValueType
void checkOutVariables(const opt_variables_type &active) override
check out optimizable variables
void mw_recompute(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const override
ResourceHandle< RS > lendResource()
TwoBodyJastrowMultiWalkerMem()
Vector< T, OffloadPinnedAllocator< T > > mw_vals
virtual void mw_calcRatio(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const
compute the ratio of the new to old WaveFunctionComponent value of multiple walkers ...
void mw_accept_rejectMove(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const override
moves of the iat-th particle on some walkers in a batch is accepted.
RealType KEcorr
Correction.
FT FuncType
alias FuncType
SIMD version of functions in algorithm.
T1 * lendReference(size_type n)
void push_back(OptimizableObject &obj)
const size_t N
number of particles
void mw_calcRatio(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const override
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Vector< T, OffloadPinnedAllocator< T > > mw_allUat
memory pool for Uat, dUat, d2Uat [Nw][N_padded] + [Nw][DIM][N_padded] + [Nw][N_padded] ...
TwoBodyJastrowMultiWalkerMem(const TwoBodyJastrowMultiWalkerMem &)
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
void add(std::complex< T1 > &x)
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch