30 std::string
getClassName()
const override {
return "DummyDiracDetWithoutMW"; }
82 std::unique_ptr<DiracDeterminantBase>
makeCopy(std::unique_ptr<SPOSet>&& spo)
const override 91 DummyDiracDetWithMW(
const std::string& class_name, std::unique_ptr<SPOSet>&& spos,
int first,
int last)
98 std::vector<GradType>& grad_now)
const override 100 for (
auto& grad : grad_now)
110 std::vector<GradType>& grad_now,
111 std::vector<ComplexType>& spingrad_now)
const override 113 for (
auto& grad : grad_now)
119 for (
auto& spingrad : spingrad_now)
125 std::vector<PsiValue>& ratios,
126 std::vector<GradType>& grad_new)
const override 128 for (
auto& grad : grad_new)
138 std::vector<PsiValue>& ratios,
139 std::vector<GradType>& grad_new,
140 std::vector<ComplexType>& spingrad_new)
const override 142 for (
auto& grad : grad_new)
148 for (
auto& spingrad : spingrad_new)
162 std::unique_ptr<ConstantSPOSet> spo_ptr0 = std::make_unique<ConstantSPOSet>(
"dummySPO", 3, 3);
163 std::unique_ptr<ConstantSPOSet> spo_ptr1 = std::make_unique<ConstantSPOSet>(
"dummySPO", 3, 3);
169 std::unique_ptr<DiracDeterminantBase> det_ptr0 =
170 std::make_unique<DummyDiracDetWithoutMW>(
"dummy", std::move(spo_ptr0), 0, 12);
171 std::unique_ptr<DiracDeterminantBase> det_ptr1 =
172 std::make_unique<DummyDiracDetWithoutMW>(
"dummy", std::move(spo_ptr1), 0, 12);
174 std::vector<std::unique_ptr<DiracDeterminantBase>> dirac_dets0;
175 dirac_dets0.push_back(std::move(det_ptr0));
176 std::vector<std::unique_ptr<DiracDeterminantBase>> dirac_dets1;
177 dirac_dets1.push_back(std::move(det_ptr1));
179 SlaterDet slaterdet0(elec0, std::move(dirac_dets0));
180 SlaterDet slaterdet1(elec0, std::move(dirac_dets1));
187 std::vector<SPOSet::GradType> grads(2);
188 std::vector<WaveFunctionComponent::PsiValue> ratios(2);
189 std::vector<SPOSet::ComplexType> spingrads(2);
191 for (
auto grad : grads)
193 CHECK(grad[0] == ValueApprox(123.));
194 CHECK(grad[1] == ValueApprox(456.));
195 CHECK(grad[2] == ValueApprox(789.));
199 for (
auto grad : grads)
201 CHECK(grad[0] == ValueApprox(0.123));
202 CHECK(grad[1] == ValueApprox(0.456));
203 CHECK(grad[2] == ValueApprox(0.789));
205 for (
auto sgrad : spingrads)
208 slaterdet0.
mw_ratioGrad(sd_list, p_list, 0, ratios, grads);
209 for (
auto grad : grads)
211 CHECK(grad[0] == ValueApprox(123.));
212 CHECK(grad[1] == ValueApprox(456.));
213 CHECK(grad[2] == ValueApprox(789.));
217 for (
auto grad : grads)
219 CHECK(grad[0] == ValueApprox(0.123));
220 CHECK(grad[1] == ValueApprox(0.456));
221 CHECK(grad[2] == ValueApprox(0.789));
223 for (
auto sgrad : spingrads)
228 std::unique_ptr<DiracDeterminantBase> det_ptr0 =
229 std::make_unique<DummyDiracDetWithMW>(
"dummy", std::move(spo_ptr0), 0, 12);
230 std::unique_ptr<DiracDeterminantBase> det_ptr1 =
231 std::make_unique<DummyDiracDetWithMW>(
"dummy", std::move(spo_ptr1), 0, 12);
233 std::vector<std::unique_ptr<DiracDeterminantBase>> dirac_dets0;
234 dirac_dets0.push_back(std::move(det_ptr0));
235 std::vector<std::unique_ptr<DiracDeterminantBase>> dirac_dets1;
236 dirac_dets1.push_back(std::move(det_ptr1));
238 SlaterDet slaterdet0(elec0, std::move(dirac_dets0));
239 SlaterDet slaterdet1(elec1, std::move(dirac_dets1));
247 std::vector<SPOSet::GradType> grads(2);
248 std::vector<WaveFunctionComponent::PsiValue> ratios(2);
249 std::vector<SPOSet::ComplexType> spingrads(2);
251 for (
auto grad : grads)
253 CHECK(grad[0] == ValueApprox(321.));
254 CHECK(grad[1] == ValueApprox(654.));
255 CHECK(grad[2] == ValueApprox(987.));
259 for (
auto grad : grads)
261 CHECK(grad[0] == ValueApprox(0.321));
262 CHECK(grad[1] == ValueApprox(0.654));
263 CHECK(grad[2] == ValueApprox(0.987));
265 for (
auto sgrad : spingrads)
268 slaterdet0.
mw_ratioGrad(sd_list, p_list, 0, ratios, grads);
269 for (
auto grad : grads)
271 CHECK(grad[0] == ValueApprox(321.));
272 CHECK(grad[1] == ValueApprox(654.));
273 CHECK(grad[2] == ValueApprox(987.));
277 for (
auto grad : grads)
279 CHECK(grad[0] == ValueApprox(0.321));
280 CHECK(grad[1] == ValueApprox(0.654));
281 CHECK(grad[2] == ValueApprox(0.987));
283 for (
auto sgrad : spingrads)
Declaration of DiracDeterminantBase with a S(ingle)P(article)O(rbital)Set.
helper functions for EinsplineSetBuilder
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
TEST_CASE("complex_helper", "[type_traits]")
void mw_ratioGradWithSpin(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const override
compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of ...
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
DummyDiracDetWithoutMW(const std::string &class_name, std::unique_ptr< SPOSet > &&spos, int first, int last)
QTBase::ComplexType ComplexType
void mw_evalGradWithSpin(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const override
compute the current gradients and spin gradients for the iat-th particle of multiple walkers ...
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
Attaches a unit to a Vector for IO.
Communicate * Controller
Global Communicator for a process.
const int FirstIndex
index of the first particle with respect to the particle set
void mw_evalGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, std::vector< GradType > &grad_now) const override
compute the current gradients for the iat-th particle of multiple walkers
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
compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walk...
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...
std::complex< QTFull::RealType > LogValue
Wrapping information on parallelism.
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
static ParticleSetPool make_O2_spinor(Communicate *c)
Specialized paritlce class for atomistic simulations.
void restore(int iat) override
If a move for iat-th particle is rejected, restore to the content.
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
void mw_ratioGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_now) const override
compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walk...
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
class to handle a set of variables that can be modified during optimizations
const int LastIndex
index of the last particle with respect to the particle set
QTFull::ValueType PsiValue
DummyDiracDetWithMW(const std::string &class_name, std::unique_ptr< SPOSet > &&spos, int first, int last)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void mw_evalGradWithSpin(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const override
compute the current gradients and spin gradients for the iat-th particle of multiple walkers ...
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
handles acquire/release resource by the consumer (RefVectorWithLeader type).
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
void mw_ratioGradWithSpin(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new, std::vector< ComplexType > &spingrad_new) const override
compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of ...
GradType evalGradWithSpin(ParticleSet &P, int iat, ComplexType &spingrad) override
return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunc...
std::unique_ptr< DiracDeterminantBase > makeCopy(std::unique_ptr< SPOSet > &&spo) const override
cloning function
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
std::string getClassName() const override
return class name