30 std::unique_ptr<Resource>
makeClone()
const override 32 return std::make_unique<MultiSlaterDetTableMethodMultiWalkerResource>(*this);
43 std::vector<std::unique_ptr<MultiDiracDeterminant>>&& dets,
44 bool use_pre_computing)
54 CI_Optimizable(false),
55 use_pre_computing_(use_pre_computing)
57 Dets = std::move(dets);
66 for (
int i = 0; i <
Last.size(); ++i)
71 std::unique_ptr<std::vector<ValueType>> C_in,
72 std::unique_ptr<opt_variables_type> myVars_in,
73 std::unique_ptr<CSFData> csf_data_in,
77 C2node = std::move(C2node_in);
79 myVars = std::move(myVars_in);
88 std::vector<std::unique_ptr<MultiDiracDeterminant>> dets_clone;
90 dets_clone.emplace_back(std::make_unique<MultiDiracDeterminant>(*
det));
120 for (
size_t ig = 0; ig <
Dets.size(); ig++)
123 for (
size_t i = 0; i <
Dets[0]->getNumDets(); ++i)
126 for (
size_t id = 0;
id <
Dets.size();
id++)
127 for (
size_t i = 0; i <
Dets[id]->getNumDets(); ++i)
128 for (
int k = 0,
n =
Dets[
id]->getFirstIndex(); k <
Dets[id]->getNumPtcls(); k++,
n++)
138 for (
size_t id = 0;
id <
Dets.size();
id++)
139 log_psi +=
Dets[
id]->getLogValueRefDet();
148 for (
size_t id = 0;
id <
Dets.size();
id++)
151 Dets[
id]->evaluateForWalkerMoveWithSpin(P);
153 Dets[id]->evaluateForWalkerMove(P);
158 for (
size_t i = 0; i < L.
size(); i++)
182 Dets[det_id]->evaluateDetsAndGradsForPtclMove(P, iat);
184 Dets[det_id]->evaluateGrads(P, iat);
186 const auto& grads = (newpos) ?
Dets[det_id]->getNewGrads() :
Dets[det_id]->getGrads();
188 (newpos) ?
Dets[det_id]->getNewRatiosToRefDet() :
Dets[det_id]->getRatiosToRefDet();
189 const size_t noffset =
Dets[det_id]->getFirstIndex();
194 for (
size_t i = 0; i <
Dets[det_id]->getNumDets(); i++)
196 psi += detValues0[i] *
C_otherDs[det_id][i];
197 g_sum +=
C_otherDs[det_id][i] * grads(i, iat - noffset);
213 Dets[det_id]->evaluateDetsAndGradsForPtclMoveWithSpin(P, iat);
215 Dets[det_id]->evaluateGradsWithSpin(P, iat);
217 const auto& grads = (newpos) ?
Dets[det_id]->getNewGrads() :
Dets[det_id]->getGrads();
219 (newpos) ?
Dets[det_id]->getNewRatiosToRefDet() :
Dets[det_id]->getRatiosToRefDet();
221 const size_t noffset =
Dets[det_id]->getFirstIndex();
224 for (
size_t i = 0; i <
Dets[det_id]->getNumDets(); i++)
226 psi += detValues0[i] *
C_otherDs[det_id][i];
227 g_at +=
C_otherDs[det_id][i] * grads(i, iat - noffset);
228 sg_at +=
C_otherDs[det_id][i] * spingrads(i, iat - noffset);
239 std::vector<GradType>& grad_now,
240 std::vector<PsiValue>& psi_list)
243 const int det_id = det_leader.
getDetID(iat);
244 const int nw = WFC_list.size();
245 const int ndets = det_leader.Dets[det_id]->getNumDets();
248 det_list.reserve(WFC_list.size());
249 for (
int iw = 0; iw < WFC_list.size(); iw++)
252 det_list.push_back(*
det.Dets[det_id]);
255 auto& mw_res = det_leader.mw_res_handle_.getResource();
256 auto& mw_grads = mw_res.mw_grads;
257 mw_grads.resize(3 * nw, ndets);
259 det_leader.Dets[det_id]->mw_evaluateDetsAndGradsForPtclMove(det_list, P_list, iat, mw_grads);
261 det_leader.Dets[det_id]->mw_evaluateGrads(det_list, P_list, iat, mw_grads);
263 auto& det_value_ptr_list = mw_res.det_value_ptr_list;
264 det_value_ptr_list.resize(nw);
265 for (
size_t iw = 0; iw < nw; iw++)
268 det_value_ptr_list[iw] = (newpos) ?
det.Dets[det_id]->getNewRatiosToRefDet().device_data()
269 :
det.Dets[det_id]->getRatiosToRefDet().device_data();
272 std::vector<ValueType> grad_now_list(nw * 3, 0);
273 auto* grad_now_list_ptr = grad_now_list.data();
274 auto* mw_grads_ptr = mw_grads.data();
275 auto* psi_list_ptr = psi_list.data();
276 auto* C_otherDs_ptr_list_ptr = mw_res.C_otherDs_ptr_list.data();
277 auto* det_value_ptr_list_ptr = det_value_ptr_list.data();
280 PRAGMA_OFFLOAD(
"omp target teams distribute map(from: psi_list_ptr[:nw]) \ 281 map(from: grad_now_list_ptr[:3 * nw]) \ 282 map(always, to: det_value_ptr_list_ptr[:nw]) \ 283 map(to: mw_grads_ptr[:mw_grads.size()])")
284 for (uint32_t iw = 0; iw < nw; iw++)
291 PRAGMA_OFFLOAD(
"omp parallel for reduction(+:psi_local, grad_local_x, grad_local_y, grad_local_z)")
292 for (uint32_t i = 0; i < ndets; i++)
294 psi_local += det_value_ptr_list_ptr[iw][i] * C_otherDs_ptr_list_ptr[iw][i];
295 grad_local_x += C_otherDs_ptr_list_ptr[iw][i] * mw_grads_ptr[(3 * iw + 0) * ndets + i];
296 grad_local_y += C_otherDs_ptr_list_ptr[iw][i] * mw_grads_ptr[(3 * iw + 1) * ndets + i];
297 grad_local_z += C_otherDs_ptr_list_ptr[iw][i] * mw_grads_ptr[(3 * iw + 2) * ndets + i];
299 psi_list_ptr[iw] = psi_local;
300 grad_now_list_ptr[iw * 3 + 0] = grad_local_x;
301 grad_now_list_ptr[iw * 3 + 1] = grad_local_y;
302 grad_now_list_ptr[iw * 3 + 2] = grad_local_z;
306 for (
size_t iw = 0; iw < nw; iw++)
309 grad_now[iw][0] = grad_now_list[iw * 3 + 0] * psi_inv;
310 grad_now[iw][1] = grad_now_list[iw * 3 + 1] * psi_inv;
311 grad_now[iw][2] = grad_now_list[iw * 3 + 2] * psi_inv;
323 Dets[det_id]->evaluateDetsAndGradsForPtclMove(P, iat);
325 Dets[det_id]->evaluateGrads(P, iat);
327 const auto& grads = (newpos) ?
Dets[det_id]->getNewGrads() :
Dets[det_id]->getGrads();
328 const auto& detValues0 = (newpos) ?
Dets[det_id]->getNewRatiosToRefDet() :
Dets[det_id]->getRatiosToRefDet();
329 const size_t* restrict det0 = (*C2node)[det_id].data();
331 const size_t nc =
C->size();
332 const size_t noffset =
Dets[det_id]->getFirstIndex();
334 for (
size_t i = 0; i < nc; ++i)
336 const size_t d0 = det0[i];
338 for (
size_t id = 0;
id <
Dets.size();
id++)
340 t *=
Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
341 psi += t * detValues0[d0];
342 g_at += t * grads(d0, iat - noffset);
357 Dets[det_id]->evaluateDetsAndGradsForPtclMoveWithSpin(P, iat);
359 Dets[det_id]->evaluateGradsWithSpin(P, iat);
361 const auto& grads = (newpos) ?
Dets[det_id]->getNewGrads() :
Dets[det_id]->getGrads();
362 const auto& detValues0 = (newpos) ?
Dets[det_id]->getNewRatiosToRefDet() :
Dets[det_id]->getRatiosToRefDet();
363 const auto& spingrads = (newpos) ?
Dets[det_id]->getNewSpinGrads() :
Dets[det_id]->getSpinGrads();
364 const size_t* restrict det0 = (*C2node)[det_id].data();
366 const size_t nc =
C->size();
367 const size_t noffset =
Dets[det_id]->getFirstIndex();
369 for (
size_t i = 0; i < nc; ++i)
371 const size_t d0 = det0[i];
373 for (
size_t id = 0;
id <
Dets.size();
id++)
375 t *=
Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
376 psi += t * detValues0[d0];
377 g_at += t * grads(d0, iat - noffset);
378 sg_at += t * spingrads(d0, iat - noffset);
411 spingrad += spingrad_iat;
419 std::vector<GradType>& grad_now)
const 430 const int nw = WFC_list.size();
432 std::vector<PsiValue> psi_list(nw, 0);
476 spingrad_iat += spindummy;
483 std::vector<WaveFunctionComponent::PsiValue>& ratios,
484 std::vector<GradType>& grad_new)
const 493 const int nw = WFC_list.size();
495 ScopedTimer local_timer(det_leader.RatioGradTimer);
496 std::vector<PsiValue> psi_list(nw, 0);
497 std::vector<GradType> dummy;
503 for (
size_t iw = 0; iw < nw; iw++)
506 det.new_psi_ratio_to_new_ref_det_ = psi_list[iw];
507 grad_new[iw] += dummy[iw];
508 det.curRatio =
det.Dets[det_id]->getRefDetRatio();
510 det.curRatio *= psi_list[iw] /
det.psi_ratio_to_ref_det_;
511 ratios[iw] =
det.curRatio;
517 const auto& detValues0 =
Dets[det_id]->getNewRatiosToRefDet();
526 for (
size_t i = 0; i <
Dets[det_id]->getNumDets(); i++)
527 psi += detValues0[i] *
C_otherDs[det_id][i];
531 const size_t* restrict det0 = (*C2node)[det_id].data();
533 const size_t nc =
C->size();
535 for (
size_t i = 0; i < nc; ++i)
538 for (
size_t id = 0;
id <
Dets.size();
id++)
540 t *=
Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
541 t *= detValues0[det0[i]];
555 Dets[det_id]->evaluateDetsForPtclMove(P, iat);
567 std::vector<PsiValue>& ratios)
const 580 const int nw = WFC_list.size();
581 const int ndets = det_leader.Dets[det_id]->getNumDets();
584 det_list.reserve(WFC_list.size());
585 for (
int iw = 0; iw < WFC_list.size(); iw++)
588 det_list.push_back(*
det.Dets[det_id]);
591 det_leader.Dets[det_id]->mw_evaluateDetsForPtclMove(det_list, P_list, iat);
593 auto& mw_res = det_leader.mw_res_handle_.getResource();
594 auto& det_value_ptr_list = mw_res.det_value_ptr_list;
595 det_value_ptr_list.resize(nw);
596 for (
size_t iw = 0; iw < nw; iw++)
601 det_value_ptr_list[iw] =
det.Dets[det_id]->getNewRatiosToRefDet().device_data();
604 std::vector<PsiValue> psi_list(nw, 0);
605 auto* psi_list_ptr = psi_list.data();
606 auto* C_otherDs_ptr_list_ptr = mw_res.C_otherDs_ptr_list.data();
607 auto* det_value_ptr_list_ptr = det_value_ptr_list.data();
610 PRAGMA_OFFLOAD(
"omp target teams distribute map(always,from: psi_list_ptr[:nw]) \ 611 map(always, to: det_value_ptr_list_ptr[:nw])")
612 for (uint32_t iw = 0; iw < nw; iw++)
615 PRAGMA_OFFLOAD(
"omp parallel for reduction(+ : psi_local)")
616 for (uint32_t i = 0; i < ndets; i++)
617 psi_local += det_value_ptr_list_ptr[iw][i] * C_otherDs_ptr_list_ptr[iw][i];
618 psi_list_ptr[iw] = psi_local;
622 for (
size_t iw = 0; iw < nw; iw++)
625 det.new_psi_ratio_to_new_ref_det_ = psi_list[iw];
626 det.curRatio =
det.Dets[det_id]->getRefDetRatio();
628 det.curRatio *= psi_list[iw] /
det.psi_ratio_to_ref_det_;
629 ratios[iw] =
det.curRatio;
639 for (
size_t iat = 0; iat < VP.
getTotalNum(); ++iat)
641 Dets[det_id]->evaluateDetsForPtclMove(VP, iat, VP.
refPtcl);
645 ratios[iat] =
Dets[det_id]->getRefDetRatio();
674 const std::vector<bool>& isAccepted,
675 bool safe_to_delay)
const 678 for (
size_t iw = 0; iw < isAccepted.size(); iw++)
683 det.psi_ratio_to_ref_det_ =
det.new_psi_ratio_to_new_ref_det_;
690 Dets[det_id]->mw_accept_rejectMove(det_list, p_list, iat, isAccepted);
695 for (
size_t id = 0;
id <
Dets.size();
id++)
708 for (
size_t id = 0;
id <
Dets.size();
id++)
714 for (
int i = 0; i < P.
L.size(); i++)
725 for (
size_t id = 0;
id <
Dets.size();
id++)
735 for (
int i = 0; i <
Dets.size(); i++)
743 myVars->setIndexDefault();
753 for (
size_t id = 0;
id <
Dets.size();
id++)
765 for (
int i = 0; i <
csf_data_->coeffs.size() - 1; i++)
767 int loc =
myVars->where(i);
770 CSFcoeff_p[i + 1] = (*myVars)[i] = active[loc];
776 for (
int i = 0; i <
csf_data_->dets_per_csf.size(); i++)
778 for (
int k = 0; k <
csf_data_->dets_per_csf[i]; k++)
780 C_p[cnt] = CSFcoeff_p[i] * CSFexpansion_p[cnt];
789 for (
int i = 0; i <
C->size() - 1; i++)
791 int loc =
myVars->where(i);
794 C_p[i + 1] = (*myVars)[i] = active[loc];
810 bool recalculate(
false);
811 for (
int k = 0; k <
myVars->size(); ++k)
813 int kk =
myVars->where(k);
824 for (
size_t id = 0;
id <
Dets.size();
id++)
830 for (
size_t i = 0; i <
laplSum[id].size(); i++)
833 for (
size_t k = 0; k <
Dets[id]->getNumPtcls(); k++)
840 for (
size_t id = 0;
id <
Dets.size();
id++)
841 for (
size_t i = 0; i <
Dets[id]->getNumDets(); i++)
845 lapl_sum += tmp *
laplSum[id][i];
846 for (
size_t k = 0, j =
Dets[
id]->getFirstIndex(); k <
Dets[id]->getNumPtcls(); k++, j++)
856 const int num =
csf_data_->coeffs.size() - 1;
861 for (
int i = 0; i < num; i++, ip++)
863 int kk =
myVars->where(i);
870 std::vector<ValueType> v(
Dets.size());
872 for (
int k = 0; k <
csf_data_->dets_per_csf[ip]; k++)
874 for (
size_t id = 0;
id <
Dets.size();
id++)
876 const auto& grads_spin =
Dets[id]->getGrads();
877 size_t spinC = (*C2node)[id][cnt];
878 ValueType tmp = CSFexpansion_p[cnt] * psiinv;
879 for (
size_t other_id = 0; other_id <
Dets.size(); other_id++)
884 size_t otherspinC = (*C2node)[other_id][cnt];
885 tmp *= detValues_otherspin[otherspinC];
887 q0 += tmp *
laplSum[id][spinC];
888 for (
size_t l = 0, j =
Dets[
id]->getFirstIndex(); l <
Dets[id]->getNumPtcls(); l++, j++)
890 static_cast<ValueType>(
dot(P.
G[j], grads_spin(spinC, l)) -
dot(
myG_temp[j], grads_spin(spinC, l)));
894 ValueType dhpsi = (
RealType)-0.5 * (q0 - dlogpsi[kk] * lapl_sum) - dlogpsi[kk] * gg;
895 for (
size_t id = 0;
id <
Dets.size();
id++)
897 dhpsioverpsi[kk] = dhpsi;
902 for (
size_t i = 1; i <
C->size(); i++)
904 int kk =
myVars->where(i - 1);
909 std::vector<ValueType> v(
Dets.size());
910 for (
size_t id = 0;
id <
Dets.size();
id++)
912 const auto& grads_spin =
Dets[id]->getGrads();
913 size_t spinC = (*C2node)[id][i];
915 for (
size_t other_id = 0; other_id <
Dets.size(); other_id++)
919 size_t otherspinC = (*C2node)[other_id][i];
920 tmp *=
Dets[other_id]->getRatiosToRefDet()[otherspinC];
922 q0 += tmp *
laplSum[id][spinC];
923 for (
size_t l = 0, j =
Dets[
id]->getFirstIndex(); l <
Dets[id]->getNumPtcls(); l++, j++)
925 static_cast<ValueType>(
dot(P.
G[j], grads_spin(spinC, l)) -
dot(
myG_temp[j], grads_spin(spinC, l)));
927 ValueType dhpsi = (
RealType)-0.5 * (q0 - dlogpsi[kk] * lapl_sum) - dlogpsi[kk] * gg;
928 for (
size_t id = 0;
id <
Dets.size();
id++)
930 dhpsioverpsi[kk] = dhpsi;
948 if (!
det->isOptimizable())
951 if (
Dets.size() != 2)
953 throw std::runtime_error(
954 "MultiSlaterDetTableMethod::evaluateDerivatives only compatible with two quantum particle types.");
958 Dets[0]->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi, *
Dets[1],
960 Dets[1]->evaluateDerivatives(P, optvars, dlogpsi, dhpsioverpsi, *
Dets[0],
975 bool recalculate(
false);
976 for (
int k = 0; k <
myVars->size(); ++k)
978 int kk =
myVars->where(k);
991 assert(dlogpsi_local.
size() == nparams);
992 for (
int i = 0; i < nparams; i++)
994 int kk =
myVars->where(i);
997 dlogpsi[kk] = dlogpsi_local[i];
1012 for (
size_t i = 0; i <
C->size(); i++)
1016 for (
size_t id = 0;
id <
Dets.size();
id++)
1017 cdet *=
Dets[
id]->getRatiosToRefDet()[(*C2node)[id][i]];
1033 const unsigned det_id = move? move->first : 0;
1034 const auto& detValues0 = move?
Dets[det_id]->getNewRatiosToRefDet() :
Dets[det_id]->getRatiosToRefDet();
1042 for (
int i = 1; i <
csf_data_->coeffs.size(); i++)
1045 for (
int k = 0; k <
csf_data_->dets_per_csf[i]; k++)
1047 ValueType t =
csf_data_->expansion[cnt] * psiinv * detValues0[(*C2node)[det_id][cnt]];
1049 for (
size_t id = 0;
id <
Dets.size();
id++)
1051 t *=
Dets[id]->getRatiosToRefDet()[(*C2node)[id][cnt]];
1055 dlogpsi[i - 1] = cdet;
1060 dlogpsi.
resize(
C->size() - 1);
1061 for (
size_t i = 1; i <
C->size(); i++)
1063 ValueType cdet = psiinv * detValues0[(*C2node)[det_id][i]];
1065 for (
size_t id = 0;
id <
Dets.size();
id++)
1067 cdet *=
Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
1068 dlogpsi[i - 1] = cdet;
1075 std::vector<ValueType>& ratios,
1080 bool recalculate(
false);
1082 for (
int k = 0; k <
myVars->size(); ++k)
1084 int kk =
myVars->where(k);
1096 for (
size_t iat = 0; iat < VP.
getTotalNum(); ++iat)
1098 Dets[det_id]->evaluateDetsForPtclMove(VP, iat, VP.
refPtcl);
1103 ratios[iat] =
Dets[det_id]->getRefDetRatio();
1113 assert(dlogpsi_vp.
size() == nparams);
1115 for (
int i = 0; i < nparams; i++)
1117 int kk =
myVars->where(i);
1120 dratios[iat][kk] = dlogpsi_vp[i] - dlogpsi_ref[i];
1134 if (!
det->isOptimizable())
1137 if (
Dets.size() != 2)
1139 throw std::runtime_error(
1140 "MultiSlaterDetTableMethod::evaluateDerivativesWF only compatible with two quantum particle types.");
1157 for (
size_t id = 0;
id <
Dets.size();
id++)
1176 const size_t nw = wfc_list.size();
1177 assert(
this == &det_leader);
1179 auto& C_otherDs_ptr_list = det_leader.mw_res_handle_.getResource().C_otherDs_ptr_list;
1180 C_otherDs_ptr_list.resize(nw);
1181 for (
int iw = 0; iw < nw; iw++)
1184 det.prepareGroup(p_list[iw], ig);
1185 C_otherDs_ptr_list[iw] =
det.C_otherDs[ig].device_data();
1187 C_otherDs_ptr_list.updateTo();
1209 for (
size_t i = 0; i <
C->size(); i++)
1213 for (
size_t id = 0;
id <
Dets.size();
id++)
1215 product *=
Dets[id]->getRatiosToRefDet()[(*C2node)[id][i]];
1224 collection.
addResource(std::make_unique<MultiSlaterDetTableMethodMultiWalkerResource>());
1226 det->createResource(collection);
1234 for (
int idet = 0; idet <
Dets.size(); idet++)
1237 Dets[idet]->acquireResource(collection, det_list);
1246 for (
int idet = 0; idet <
Dets.size(); idet++)
1249 Dets[idet]->releaseResource(collection, det_list);
const std::vector< ValueType > & getLinearExpansionCoefs() const
void resize(size_type n, Type_t val=Type_t())
Resize the container.
std::shared_ptr< CSFData > csf_data_
CSF data set. If nullptr, not using CSF.
ParticleSet::ParticleGradient myG_temp
bool recompute(int i) const
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
void takebackResource(ResourceHandle< RS > &res_handle)
helper functions for EinsplineSetBuilder
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
bool CI_Optimizable
if true, the CI coefficients are optimized
void evaluateMultiDiracDeterminantDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
QTBase::RealType RealType
MultiSlaterDetTableMethod(ParticleSet &targetPtcl, std::vector< std::unique_ptr< MultiDiracDeterminant >> &&dets, bool use_pre_computing)
constructor
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
std::shared_ptr< opt_variables_type > myVars
void mw_calcRatio(const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, std::vector< PsiValue > &ratios) const override
size_t getTotalNum() const
std::shared_ptr< std::vector< ValueType > > C
CI coefficients.
constexpr std::complex< float > czero
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
PsiValue evalGrad_impl_no_precompute(ParticleSet &P, int iat, bool newpos, GradType &g_at)
an implementation shared by evalGrad and ratioGrad.
size_t getTotalNum() const
int refPtcl
Reference particle.
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
LatticeGaussianProduct::GradType GradType
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
QTBase::ComplexType ComplexType
void precomputeC_otherDs(const ParticleSet &P, int ig)
precompute C_otherDs for a given particle group
void evaluateDerivativesMSD(Vector< ValueType > &dlogpsi, std::optional< std::pair< unsigned, PsiValue >> move=std::nullopt) const
compute parameter derivatives of CI/CSF coefficients
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
Attaches a unit to a Vector for IO.
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
ParticleLaplacian L
laplacians of the particles
void evaluateMultiDiracDeterminantDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)
void resetParametersExclusive(const opt_variables_type &active) override
reset the parameters during optimizations.
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
return a shared resource to a collection
void mw_evalGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
compute the current gradients for the iat-th particle of multiple walkers
RefVectorWithLeader< MultiDiracDeterminant > extract_DetRef_list(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, int det_id) const
std::complex< QTFull::RealType > LogValue
void prepareGroup(ParticleSet &P, int ig) override
Prepare internal data for updating WFC correspond to a particle group It should be called before movi...
void restore(int iat) override
If a move for iat-th particle is rejected, restore to the content.
int groups() const
return the number of groups
Specialized paritlce class for atomistic simulations.
PsiValue evalGradWithSpin_impl_no_precompute(ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
size_type size() const
return the current size
PsiValue ratioGradWithSpin(ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default im...
void calcIndividualDetRatios(Vector< ValueType > &ratios)
Compute ratios of the individual Slater determinants and the total MSD value.
std::unique_ptr< Resource > makeClone() const override
QTBase::ValueType ValueType
void product(const Matrix< T > &A, const Matrix< T > &B, Matrix< T > &C)
static function to perform C=AB for real matrices
static void mw_evalGrad_impl(const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, bool newpos, std::vector< GradType > &grad_now, std::vector< PsiValue > &psi_list)
multi walker version of evalGrad_impl
std::vector< OffloadVector< ValueType > > C_otherDs
C_n x D^1_n x D^2_n ... D^3_n with one D removed. Summed by group. [spin, unique det id]...
ParticleSet::ParticleGradient myG
std::vector< std::unique_ptr< MultiDiracDeterminant > > Dets
determinant collection
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
ParticleGradient G
gradients of the particles
PsiValue evalGradWithSpin_impl(ParticleSet &P, int iat, bool newpos, GradType &g_at, ComplexType &sg_at)
std::vector< int > Last
the last particle of each group
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
std::shared_ptr< std::vector< std::vector< size_t > > > C2node
map determinant in linear combination to unique det list map global det id to unique det id...
MultiSlaterDetTableMethodMultiWalkerResource(const MultiSlaterDetTableMethodMultiWalkerResource &)
void initialize(std::unique_ptr< std::vector< std::vector< size_t >>> C2node_in, std::unique_ptr< std::vector< ValueType >> C_in, std::unique_ptr< opt_variables_type > myVars_in, std::unique_ptr< CSFData > csf_data_in, bool optimizable, bool CI_optimizable)
initialize a few objects and states by the builder YL: it should be part of the constructor.
int last(int igroup) const
return the last index of a group i
QTFull::ValueType PsiValue
bool isOptimizable() const override
if true, this contains optimizable components
ParticleSet::ParticleLaplacian myL_temp
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
void evaluateDerivRatios(const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
const bool use_pre_computing_
use pre-compute (fast) algorithm
LogValue log_value_
Current .
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
PsiValue psi_ratio_to_ref_det_
current psi over ref single det
CASTTYPE & getCastedLeader() const
ResourceHandle< MultiSlaterDetTableMethodMultiWalkerResource > mw_res_handle_
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
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi) override
PsiValue evalGrad_impl(ParticleSet &P, int iat, bool newpos, GradType &g_at)
an implementation shared by evalGrad and ratioGrad.
~MultiSlaterDetTableMethod() override
destructor
Declaraton of ParticleAttrib<T>
Matrix< ValueType, OffloadAllocator< ValueType > > mw_grads
grads of each unique determinants for multiple walkers
GradType evalGradWithSpin(ParticleSet &P, int iat, ComplexType &spingrad) override
return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunc...
NewTimer & PrepareGroupTimer
void mw_evalGrad(const RefVectorWithLeader< WaveFunctionComponent > &WFC_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, std::vector< GradType > &grad_now) const override
compute the current gradients for the iat-th particle of multiple walkers
void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
LatticeGaussianProduct::ValueType ValueType
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
int getDetID(const int iat) const
ResourceHandle< RS > lendResource()
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
void mw_prepareGroup(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const override
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 ...
ParticleSet::ParticleLaplacian myL
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
PsiValue computeRatio_NewMultiDet_to_NewRefDet(int det_id) const
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.
void push_back(OptimizableObject &obj)
void put(std::complex< T1 > &x)
LogValue evaluate_vgl_impl(const ParticleSet &P, ParticleSet::ParticleGradient &g_tmp, ParticleSet::ParticleLaplacian &l_tmp)
Compute VGL of this MultiSlaterDetTableMethod.
OffloadVector< const ValueType * > C_otherDs_ptr_list
a collection of device pointers of multiple walkers fused for fast H2D transfer.
std::vector< ValueVector > laplSum
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
PsiValue new_psi_ratio_to_new_ref_det_
new psi over new ref single det when one particle is moved
An AntiSymmetric WaveFunctionComponent composed of a linear combination of SlaterDeterminants.
MultiSlaterDetTableMethodMultiWalkerResource()
OffloadVector< const ValueType * > det_value_ptr_list
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
void checkInVariablesExclusive(opt_variables_type &active) override
check in variational parameters to the global list of parameters used by the optimizer.
void add(std::complex< T1 > &x)
NewTimer & RatioGradTimer
int UpdateMode
current update mode
void get(std::complex< T1 > &x)