From 67c129a9be024f2b945b354b3f5049bec167a96b Mon Sep 17 00:00:00 2001 From: Jaron Krogel Date: Fri, 22 Nov 2024 16:35:41 -0500 Subject: [PATCH 1/8] include rotated slater-det in sh overlap estimator --- src/Estimators/SelfHealingOverlap.cpp | 95 ++++++++++++++----- src/Estimators/SelfHealingOverlap.h | 15 +++ src/Estimators/SelfHealingOverlapInput.h | 7 +- .../Fermion/MultiSlaterDetTableMethod.h | 2 + src/QMCWaveFunctions/TrialWaveFunction.cpp | 10 ++ src/QMCWaveFunctions/TrialWaveFunction.h | 4 + 6 files changed, 109 insertions(+), 24 deletions(-) diff --git a/src/Estimators/SelfHealingOverlap.cpp b/src/Estimators/SelfHealingOverlap.cpp index 2ac8328380..dbca60ec29 100644 --- a/src/Estimators/SelfHealingOverlap.cpp +++ b/src/Estimators/SelfHealingOverlap.cpp @@ -11,6 +11,7 @@ #include "SelfHealingOverlap.h" #include "TrialWaveFunction.h" #include "QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h" +#include "QMCWaveFunctions/Fermion/SlaterDet.h" #include #include @@ -19,20 +20,53 @@ namespace qmcplusplus { SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const TrialWaveFunction& wfn, DataLocality dl) - : OperatorEstBase(dl), input_(std::move(inp_)) + : OperatorEstBase(dl), input_(std::move(inp_)), wf_type(no_wf) { //my_name_ = input_.get_name(); auto& inp = this->input_.input_section_; + use_param_deriv = inp.get("param_deriv"); + auto msd_refvec = wfn.findMSD(); - if (msd_refvec.size() != 1) + auto sd_refvec = wfn.findSD(); + + auto nsd = sd_refvec.size(); + auto nmsd = msd_refvec.size(); + + size_t nparams; + if (nmsd==1 and nsd==0) + {// multi-slater-det wavefunction + wf_type = msd_wf; + const MultiSlaterDetTableMethod& msd = msd_refvec[0]; + if (!use_param_deriv) + nparams = msd.getLinearExpansionCoefs().size(); + else + nparams = msd.myVars->size(); + if(nparams==0) + throw std::runtime_error("SelfHealingOverlap: multidet wavefunction has no parameters."); + } + else if (nmsd==0 and nsd==1) + {// slater-det wavefunction + wf_type = sd_rot_wf; + const SlaterDet& sd = sd_refvec[0]; + nparams = sd.myVars.size(); + if(nparams==0) + throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction has no parameters.\n Please check that 's appear in the input file."); + } + else + { throw std::runtime_error( - "SelfHealingOverlap requires one and only one multi slater determinant component in the trial wavefunction."); + "SelfHealingOverlap requires a single slater or multi-slater determinant component in the trial wavefunction."); + } - const MultiSlaterDetTableMethod& msd = msd_refvec[0]; - const size_t data_size = msd.getLinearExpansionCoefs().size(); +#ifndef QMC_COMPLEX + const size_t data_size = nparams; +#else + const size_t data_size = 2*nparams; +#endif data_.resize(data_size, 0.0); + } @@ -78,31 +112,40 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, RealType weight = walker.Weight; auto& wcs = psi.getOrbitals(); - // separate jastrow and fermi wavefunction components + // find jastrow wavefunction components std::vector wcs_jastrow; - std::vector wcs_fermi; for (auto& wc : wcs) - if (wc->isFermionic()) - wcs_fermi.push_back(wc.get()); - else + if (!wc->isFermionic()) wcs_jastrow.push_back(wc.get()); - // fermionic must have only one component, and must be multideterminant - assert(wcs_fermi.size() == 1); - WaveFunctionComponent& wf = *wcs_fermi[0]; - if (!wf.isMultiDet()) - throw std::runtime_error("SelfHealingOverlap estimator requires use of multideterminant wavefunction"); - auto msd_refvec = psi.findMSD(); - MultiSlaterDetTableMethod& msd = msd_refvec[0]; - - // collect parameter derivatives: (dpsi/dc_i)/psi - msd.calcIndividualDetRatios(det_ratios); + if (wf_type==msd_wf) + { + auto msd_refvec = psi.findMSD(); + MultiSlaterDetTableMethod& msd = msd_refvec[0]; + // collect parameter derivatives: (dpsi/dc_i)/psi + if (!use_param_deriv) + msd.calcIndividualDetRatios(det_ratios); + else + { + const auto& vars = *msd.myVars; + msd.evaluateDerivativesWF(pset,vars,det_ratios); + } + } + else if(wf_type==sd_rot_wf) + { + auto sd_refvec = psi.findSD(); + SlaterDet& sd = sd_refvec[0]; + // collect parameter derivatives: (dpsi/dc_i)/psi + sd.evaluateDerivativesWF(pset,sd.myVars,det_ratios); + } + else + throw std::runtime_error("SelfHealingOverlap: impossible branch reached, contact the developers"); // collect jastrow prefactor WaveFunctionComponent::LogValue Jval = 0.0; for (auto& wc : wcs_jastrow) Jval += wc->get_log_value(); - auto Jprefactor = std::real(std::exp(-2. * Jval)); + auto Jprefactor = std::exp(-2. * Jval); // accumulate weight (required by all estimators, otherwise inf results) walkers_weight_ += weight; @@ -110,7 +153,15 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, // accumulate data assert(det_ratios.size() == data_.size()); for (int ic = 0; ic < det_ratios.size(); ++ic) - data_[ic] += weight * Jprefactor * std::real(det_ratios[ic]); // only real supported for now + { +#ifndef QMC_COMPLEX + data_[ic] += weight * Jprefactor * det_ratios[ic]; +#else + auto value = weight * Jprefactor * std::conj(det_ratios[ic]); + data_[2*ic ] += std::real(value); + data_[2*ic+1] += std::imag(value); +#endif + } } } diff --git a/src/Estimators/SelfHealingOverlap.h b/src/Estimators/SelfHealingOverlap.h index f3422b2395..05074c58ec 100644 --- a/src/Estimators/SelfHealingOverlap.h +++ b/src/Estimators/SelfHealingOverlap.h @@ -33,6 +33,14 @@ class SelfHealingOverlap : public OperatorEstBase using ValueType = QMCTraits::ValueType; using PosType = QMCTraits::PosType; + + enum wf_types + { + msd_wf = 0, + sd_rot_wf, + no_wf + }; + //data members set only during construction const SelfHealingOverlapInput input_; @@ -40,6 +48,13 @@ class SelfHealingOverlap : public OperatorEstBase */ Vector det_ratios; + /// wavefunction type + wf_types wf_type; + + /// use direct parameter derivative for MSD or not + bool use_param_deriv; + + public: /** Constructor for SelfHealingOverlapInput */ diff --git a/src/Estimators/SelfHealingOverlapInput.h b/src/Estimators/SelfHealingOverlapInput.h index 4b0106f3e0..adff1ec043 100644 --- a/src/Estimators/SelfHealingOverlapInput.h +++ b/src/Estimators/SelfHealingOverlapInput.h @@ -32,9 +32,12 @@ class SelfHealingOverlapInput SelfHealingOverlapInputSection() { section_name = "SelfHealingOverlap"; - attributes = {"type", "name"}; + attributes = {"type", "name", "param_deriv"}; strings = {"type", "name"}; - default_values = {{"type", std::string("sh_overlap")},{"name", std::string("sh_overlap")}}; + bools = {"param_deriv"}; + default_values = {{"type", std::string("sh_overlap")}, + {"name", std::string("sh_overlap")}, + {"param_deriv",false}}; } // clang-format: on }; diff --git a/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h b/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h index 9ed2391a8d..a94f10855c 100644 --- a/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h +++ b/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h @@ -285,8 +285,10 @@ class MultiSlaterDetTableMethod : public WaveFunctionComponent, public Optimizab std::shared_ptr> C; /// if true, the CI coefficients are optimized bool CI_Optimizable; +public: //optimizable variable is shared with the clones std::shared_ptr myVars; +private: /// CSF data set. If nullptr, not using CSF std::shared_ptr csf_data_; diff --git a/src/QMCWaveFunctions/TrialWaveFunction.cpp b/src/QMCWaveFunctions/TrialWaveFunction.cpp index faf97db21f..0f8e928d9e 100644 --- a/src/QMCWaveFunctions/TrialWaveFunction.cpp +++ b/src/QMCWaveFunctions/TrialWaveFunction.cpp @@ -24,6 +24,7 @@ #include "Concurrency/Info.hpp" #include "type_traits/ConvertToReal.h" #include "NaNguard.h" +#include "Fermion/SlaterDet.h" #include "Fermion/MultiSlaterDetTableMethod.h" namespace qmcplusplus @@ -107,6 +108,15 @@ const SPOSet& TrialWaveFunction::getSPOSet(const std::string& name) const return *spoit->second; } +RefVector TrialWaveFunction::findSD() const +{ + RefVector refs; + for (auto& component : Z) + if (auto* comp_ptr = dynamic_cast(component.get()); comp_ptr) + refs.push_back(*comp_ptr); + return refs; +} + RefVector TrialWaveFunction::findMSD() const { RefVector refs; diff --git a/src/QMCWaveFunctions/TrialWaveFunction.h b/src/QMCWaveFunctions/TrialWaveFunction.h index f3eaa1824a..3d46052709 100644 --- a/src/QMCWaveFunctions/TrialWaveFunction.h +++ b/src/QMCWaveFunctions/TrialWaveFunction.h @@ -38,6 +38,7 @@ namespace qmcplusplus { +class SlaterDet; class MultiSlaterDetTableMethod; /** @ingroup MBWfs @@ -539,6 +540,9 @@ class TrialWaveFunction /// spomap_ reference accessor const SPOMap& getSPOMap() const { return *spomap_; } + /// find SD WFCs if exist + RefVector findSD() const; + /// find MSD WFCs if exist RefVector findMSD() const; From 81e644eccc95094e39e842ff62354fb84160554e Mon Sep 17 00:00:00 2001 From: Jaron Krogel Date: Tue, 28 Jan 2025 15:51:10 -0500 Subject: [PATCH 2/8] add guards --- src/Estimators/SelfHealingOverlap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Estimators/SelfHealingOverlap.cpp b/src/Estimators/SelfHealingOverlap.cpp index dbca60ec29..1cd5e6b45d 100644 --- a/src/Estimators/SelfHealingOverlap.cpp +++ b/src/Estimators/SelfHealingOverlap.cpp @@ -128,6 +128,7 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, else { const auto& vars = *msd.myVars; + assert(vars.size()>0); msd.evaluateDerivativesWF(pset,vars,det_ratios); } } @@ -135,6 +136,8 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, { auto sd_refvec = psi.findSD(); SlaterDet& sd = sd_refvec[0]; + if(sd.myVars.size()==0) + throw std::runtime_error("SelfHealingOverlap: in accumulate, slaterdet has no parameters"); // collect parameter derivatives: (dpsi/dc_i)/psi sd.evaluateDerivativesWF(pset,sd.myVars,det_ratios); } From 887a6ce092418425378406c133cb649c622d4b55 Mon Sep 17 00:00:00 2001 From: Jaron Krogel Date: Tue, 28 Jan 2025 16:09:04 -0500 Subject: [PATCH 3/8] hold off on sh slaterdet --- src/Estimators/SelfHealingOverlap.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Estimators/SelfHealingOverlap.cpp b/src/Estimators/SelfHealingOverlap.cpp index 1cd5e6b45d..d2ca962029 100644 --- a/src/Estimators/SelfHealingOverlap.cpp +++ b/src/Estimators/SelfHealingOverlap.cpp @@ -48,11 +48,12 @@ SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const Tri } else if (nmsd==0 and nsd==1) {// slater-det wavefunction - wf_type = sd_rot_wf; - const SlaterDet& sd = sd_refvec[0]; - nparams = sd.myVars.size(); - if(nparams==0) - throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction has no parameters.\n Please check that 's appear in the input file."); + throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction implementation incomplete"); + //wf_type = sd_rot_wf; + //const SlaterDet& sd = sd_refvec[0]; + //nparams = sd.myVars.size(); + //if(nparams==0) + // throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction has no parameters.\n Please check that 's appear in the input file."); } else { @@ -134,12 +135,13 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, } else if(wf_type==sd_rot_wf) { + throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction implementation incomplete"); auto sd_refvec = psi.findSD(); - SlaterDet& sd = sd_refvec[0]; - if(sd.myVars.size()==0) - throw std::runtime_error("SelfHealingOverlap: in accumulate, slaterdet has no parameters"); - // collect parameter derivatives: (dpsi/dc_i)/psi - sd.evaluateDerivativesWF(pset,sd.myVars,det_ratios); + //SlaterDet& sd = sd_refvec[0]; + //if(sd.myVars.size()==0) + // throw std::runtime_error("SelfHealingOverlap: in accumulate, slaterdet has no parameters"); + //// collect parameter derivatives: (dpsi/dc_i)/psi + //sd.evaluateDerivativesWF(pset,sd.myVars,det_ratios); } else throw std::runtime_error("SelfHealingOverlap: impossible branch reached, contact the developers"); From 8ce54fc3f5280ea152c5f555685e638e17426a98 Mon Sep 17 00:00:00 2001 From: Jaron Krogel Date: Wed, 29 Jan 2025 15:56:49 -0500 Subject: [PATCH 4/8] remove commented code --- src/Estimators/SelfHealingOverlap.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Estimators/SelfHealingOverlap.cpp b/src/Estimators/SelfHealingOverlap.cpp index d2ca962029..326e1acd9e 100644 --- a/src/Estimators/SelfHealingOverlap.cpp +++ b/src/Estimators/SelfHealingOverlap.cpp @@ -49,11 +49,6 @@ SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const Tri else if (nmsd==0 and nsd==1) {// slater-det wavefunction throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction implementation incomplete"); - //wf_type = sd_rot_wf; - //const SlaterDet& sd = sd_refvec[0]; - //nparams = sd.myVars.size(); - //if(nparams==0) - // throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction has no parameters.\n Please check that 's appear in the input file."); } else { @@ -137,11 +132,6 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, { throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction implementation incomplete"); auto sd_refvec = psi.findSD(); - //SlaterDet& sd = sd_refvec[0]; - //if(sd.myVars.size()==0) - // throw std::runtime_error("SelfHealingOverlap: in accumulate, slaterdet has no parameters"); - //// collect parameter derivatives: (dpsi/dc_i)/psi - //sd.evaluateDerivativesWF(pset,sd.myVars,det_ratios); } else throw std::runtime_error("SelfHealingOverlap: impossible branch reached, contact the developers"); From bc666845d8e69527eeb4bcce3b1ee1b59a010faa Mon Sep 17 00:00:00 2001 From: Jaron Krogel Date: Wed, 29 Jan 2025 16:13:04 -0500 Subject: [PATCH 5/8] remove "scandalous" access to myVars --- src/Estimators/SelfHealingOverlap.cpp | 8 ++++---- src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Estimators/SelfHealingOverlap.cpp b/src/Estimators/SelfHealingOverlap.cpp index 326e1acd9e..619d98fcb2 100644 --- a/src/Estimators/SelfHealingOverlap.cpp +++ b/src/Estimators/SelfHealingOverlap.cpp @@ -42,7 +42,9 @@ SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const Tri if (!use_param_deriv) nparams = msd.getLinearExpansionCoefs().size(); else - nparams = msd.myVars->size(); + { + throw std::runtime_error("SelfHealingOverlap: use_param_deriv implementation incomplete, needs access to param count from wavefunction component myVars"); + } if(nparams==0) throw std::runtime_error("SelfHealingOverlap: multidet wavefunction has no parameters."); } @@ -123,9 +125,7 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, msd.calcIndividualDetRatios(det_ratios); else { - const auto& vars = *msd.myVars; - assert(vars.size()>0); - msd.evaluateDerivativesWF(pset,vars,det_ratios); + throw std::runtime_error("SelfHealingOverlap: use_param_deriv implementation incomplete, needs call to msd.evaluateDerivatives with correct myVars"); } } else if(wf_type==sd_rot_wf) diff --git a/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h b/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h index a94f10855c..9ed2391a8d 100644 --- a/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h +++ b/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.h @@ -285,10 +285,8 @@ class MultiSlaterDetTableMethod : public WaveFunctionComponent, public Optimizab std::shared_ptr> C; /// if true, the CI coefficients are optimized bool CI_Optimizable; -public: //optimizable variable is shared with the clones std::shared_ptr myVars; -private: /// CSF data set. If nullptr, not using CSF std::shared_ptr csf_data_; From c19ca892a90c8ab3775546e69a6e30e9c02cbd95 Mon Sep 17 00:00:00 2001 From: Jaron Krogel Date: Wed, 29 Jan 2025 16:23:00 -0500 Subject: [PATCH 6/8] apply minute changes from clang-format --- src/Estimators/SelfHealingOverlapInput.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Estimators/SelfHealingOverlapInput.h b/src/Estimators/SelfHealingOverlapInput.h index adff1ec043..6987571644 100644 --- a/src/Estimators/SelfHealingOverlapInput.h +++ b/src/Estimators/SelfHealingOverlapInput.h @@ -23,7 +23,7 @@ class SelfHealingOverlapInput { public: using Consumer = SelfHealingOverlap; - using Real = QMCTraits::RealType; + using Real = QMCTraits::RealType; class SelfHealingOverlapInputSection : public InputSection { @@ -37,7 +37,7 @@ class SelfHealingOverlapInput bools = {"param_deriv"}; default_values = {{"type", std::string("sh_overlap")}, {"name", std::string("sh_overlap")}, - {"param_deriv",false}}; + {"param_deriv", false}}; } // clang-format: on }; From 134617d427041db6f7c4b20dc9611ac901c54dd5 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 29 Jan 2025 15:52:28 -0600 Subject: [PATCH 7/8] Fix real build and use more const --- src/Estimators/SelfHealingOverlap.cpp | 10 ++-------- src/Estimators/SelfHealingOverlap.h | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Estimators/SelfHealingOverlap.cpp b/src/Estimators/SelfHealingOverlap.cpp index 619d98fcb2..e87dd6a74e 100644 --- a/src/Estimators/SelfHealingOverlap.cpp +++ b/src/Estimators/SelfHealingOverlap.cpp @@ -20,14 +20,8 @@ namespace qmcplusplus { SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const TrialWaveFunction& wfn, DataLocality dl) - : OperatorEstBase(dl), input_(std::move(inp_)), wf_type(no_wf) + : OperatorEstBase(dl), input_(std::move(inp_)), wf_type(no_wf), use_param_deriv(input_.input_section_.get("param_deriv")) { - //my_name_ = input_.get_name(); - - auto& inp = this->input_.input_section_; - - use_param_deriv = inp.get("param_deriv"); - auto msd_refvec = wfn.findMSD(); auto sd_refvec = wfn.findSD(); @@ -150,7 +144,7 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, for (int ic = 0; ic < det_ratios.size(); ++ic) { #ifndef QMC_COMPLEX - data_[ic] += weight * Jprefactor * det_ratios[ic]; + data_[ic] += weight * std::real(Jprefactor) * det_ratios[ic]; #else auto value = weight * Jprefactor * std::conj(det_ratios[ic]); data_[2*ic ] += std::real(value); diff --git a/src/Estimators/SelfHealingOverlap.h b/src/Estimators/SelfHealingOverlap.h index 05074c58ec..a761244db8 100644 --- a/src/Estimators/SelfHealingOverlap.h +++ b/src/Estimators/SelfHealingOverlap.h @@ -52,7 +52,7 @@ class SelfHealingOverlap : public OperatorEstBase wf_types wf_type; /// use direct parameter derivative for MSD or not - bool use_param_deriv; + const bool use_param_deriv; public: From 49993e1686db4717847ffb6a9f6f8ecdeca86ae6 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 29 Jan 2025 15:53:10 -0600 Subject: [PATCH 8/8] Formatting. --- src/Estimators/SelfHealingOverlap.cpp | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Estimators/SelfHealingOverlap.cpp b/src/Estimators/SelfHealingOverlap.cpp index e87dd6a74e..0e353086d3 100644 --- a/src/Estimators/SelfHealingOverlap.cpp +++ b/src/Estimators/SelfHealingOverlap.cpp @@ -20,7 +20,10 @@ namespace qmcplusplus { SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const TrialWaveFunction& wfn, DataLocality dl) - : OperatorEstBase(dl), input_(std::move(inp_)), wf_type(no_wf), use_param_deriv(input_.input_section_.get("param_deriv")) + : OperatorEstBase(dl), + input_(std::move(inp_)), + wf_type(no_wf), + use_param_deriv(input_.input_section_.get("param_deriv")) { auto msd_refvec = wfn.findMSD(); auto sd_refvec = wfn.findSD(); @@ -29,21 +32,22 @@ SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const Tri auto nmsd = msd_refvec.size(); size_t nparams; - if (nmsd==1 and nsd==0) - {// multi-slater-det wavefunction - wf_type = msd_wf; + if (nmsd == 1 and nsd == 0) + { // multi-slater-det wavefunction + wf_type = msd_wf; const MultiSlaterDetTableMethod& msd = msd_refvec[0]; if (!use_param_deriv) nparams = msd.getLinearExpansionCoefs().size(); else { - throw std::runtime_error("SelfHealingOverlap: use_param_deriv implementation incomplete, needs access to param count from wavefunction component myVars"); + throw std::runtime_error("SelfHealingOverlap: use_param_deriv implementation incomplete, needs access to param " + "count from wavefunction component myVars"); } - if(nparams==0) + if (nparams == 0) throw std::runtime_error("SelfHealingOverlap: multidet wavefunction has no parameters."); } - else if (nmsd==0 and nsd==1) - {// slater-det wavefunction + else if (nmsd == 0 and nsd == 1) + { // slater-det wavefunction throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction implementation incomplete"); } else @@ -55,10 +59,9 @@ SelfHealingOverlap::SelfHealingOverlap(SelfHealingOverlapInput&& inp_, const Tri #ifndef QMC_COMPLEX const size_t data_size = nparams; #else - const size_t data_size = 2*nparams; + const size_t data_size = 2 * nparams; #endif data_.resize(data_size, 0.0); - } @@ -110,21 +113,22 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, if (!wc->isFermionic()) wcs_jastrow.push_back(wc.get()); - if (wf_type==msd_wf) + if (wf_type == msd_wf) { - auto msd_refvec = psi.findMSD(); + auto msd_refvec = psi.findMSD(); MultiSlaterDetTableMethod& msd = msd_refvec[0]; // collect parameter derivatives: (dpsi/dc_i)/psi if (!use_param_deriv) msd.calcIndividualDetRatios(det_ratios); else { - throw std::runtime_error("SelfHealingOverlap: use_param_deriv implementation incomplete, needs call to msd.evaluateDerivatives with correct myVars"); + throw std::runtime_error("SelfHealingOverlap: use_param_deriv implementation incomplete, needs call to " + "msd.evaluateDerivatives with correct myVars"); } } - else if(wf_type==sd_rot_wf) + else if (wf_type == sd_rot_wf) { - throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction implementation incomplete"); + throw std::runtime_error("SelfHealingOverlap: slaterdet wavefunction implementation incomplete"); auto sd_refvec = psi.findSD(); } else @@ -147,8 +151,8 @@ void SelfHealingOverlap::accumulate(const RefVector& walkers, data_[ic] += weight * std::real(Jprefactor) * det_ratios[ic]; #else auto value = weight * Jprefactor * std::conj(det_ratios[ic]); - data_[2*ic ] += std::real(value); - data_[2*ic+1] += std::imag(value); + data_[2 * ic] += std::real(value); + data_[2 * ic + 1] += std::imag(value); #endif } }