32 const char* particles = R
"(<tmp> 33 <particleset name="ion0" size="2"> 35 <parameter name="charge">4</parameter> 36 <parameter name="valence">2</parameter> 37 <parameter name="atomicnumber">6</parameter> 40 <parameter name="charge">5</parameter> 41 <parameter name="valence">3</parameter> 42 <parameter name="atomicnumber">7</parameter> 44 <attrib name="position" datatype="posArray"> 45 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 46 0.0000000000e+00 0.0000000000e+00 2.0786985865e+00 48 <attrib name="ionid" datatype="stringArray"> 52 <particleset name="e"> 53 <group name="u" size="5"> 54 <parameter name="charge">-1</parameter> 55 <attrib name="position" datatype="posArray"> 56 -0.55936725 -0.26942464 0.14459603 57 0.19146719 1.40287983 0.63931251 58 1.14805915 -0.52057335 3.49621107 59 0.28293870 -0.10273952 0.01707021 60 0.60626935 -0.25538121 1.75750740 63 <group name="d" size="4"> 64 <parameter name="charge">-1</parameter> 65 <attrib name="position" datatype="posArray"> 66 -0.47405939 0.59523171 -0.59778601 67 0.03150661 -0.27343474 0.56279442 68 -1.32648025 0.00970226 2.26944242 69 2.42944286 0.64884151 1.87505288 80 xmlNodePtr part1 = xmlFirstElementChild(root);
81 xmlNodePtr part2 = xmlNextElementSibling(part1);
99 ions.
R[0] = {0.1, 0.1, 0.1};
100 ions.
R[1] = {1.6865805750, 1.6865805750, 1.6865805750};
101 ions.
R[0][0] += -1
e-5;
105 int iatnumber = ion_species.
addAttribute(
"atomic_number");
106 ion_species(pChargeIdx, pIdx) = 4;
107 ion_species(iatnumber, pIdx) = 6;
111 elec.
R[0] = {3.6006741306e+00, 1.0104445324e+00, 3.9141099719e+00};
112 elec.
R[1] = {2.6451694427e+00, 3.4448681473e+00, 5.8351296103e+00};
113 elec.
R[2] = {2.5458446692e+00, 4.5219372791e+00, 4.4785209995e+00};
114 elec.
R[3] = {2.8301650128e+00, 1.5351128324e+00, 1.5004137310e+00};
115 elec.
R[4] = {5.6422291182e+00, 2.9968904592e+00, 3.3039907052e+00};
116 elec.
R[5] = {2.6062992989e+00, 4.0493925313e-01, 2.5900053291e+00};
117 elec.
R[6] = {8.1001577415e-01, 9.7303865512e-01, 1.3901383112e+00};
118 elec.
R[7] = {1.6343332400e+00, 6.1895704609e-01, 1.2145253306e+00};
125 tspecies(chargeIdx, upIdx) = -1;
126 tspecies(massIdx, upIdx) = 1.0;
127 tspecies(chargeIdx, dnIdx) = -1;
128 tspecies(massIdx, dnIdx) = 1.0;
144 const char* hamiltonian_xml = R
"(<hamiltonian name="h0" type="generic" target="e"> 145 <pairpot type="coulomb" name="ElecElec" source="e" target="e"/> 146 <pairpot type="coulomb" name="IonIon" source="ion0" target="ion0"/> 147 <pairpot name="PseudoPot" type="pseudo" source="ion0" wavefunction="psi0" format="xml" algorithm="non-batched"> 148 <pseudo elementType="C" href="C.ccECP.xml"/> 149 <pseudo elementType="N" href="N.ccECP.xml"/> 163 TEST_CASE(
"Eloc_Derivatives:slater_noj",
"[hamiltonian]")
165 app_log() <<
"====Ion Derivative Test: Single Slater No Jastrow====\n";
171 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
172 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
173 auto &ions(*ions_ptr), elec(*elec_ptr);
177 int Nions = ions.getTotalNum();
178 int Nelec = elec.getTotalNum();
181 particle_set_map.emplace(
"e", std::move(elec_ptr));
182 particle_set_map.emplace(
"ion0", std::move(ions_ptr));
187 bool wfokay = wfdoc.
parse(
"cn.wfnoj.xml");
191 xmlNodePtr wfroot = wfdoc.
getRoot();
193 psi_map.emplace(
"psi0", wff.
buildTWF(wfroot, runtime_options));
211 CHECK(logpsi == Approx(-14.233853149));
223 CHECK(eloc == Approx(-1.6170527168
e+01));
251 CHECK(wf_grad[0][0] == Approx(-1.9044650674260308));
252 CHECK(wf_grad[0][1] == Approx(2.1257764985627148));
253 CHECK(wf_grad[0][2] == Approx(7.0556319963444016));
254 CHECK(wf_grad[1][0] == Approx(1.4233346821157509));
255 CHECK(wf_grad[1][1] == Approx(-0.1446706081154048));
256 CHECK(wf_grad[1][2] == Approx(0.1440176276013005));
261 (
ham.
getHamiltonian(KINETIC))->evaluateWithIonDerivsDeterministic(elec, ions, *psi, hf_term, pulay_term);
262 #if defined(MIXED_PRECISION) 263 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(1.0852823603357820).epsilon(1
e-4));
264 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(24.2154119471038562).epsilon(1
e-4));
265 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(111.8849364775797852).epsilon(1
e-4));
266 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.1572063443997536).epsilon(1
e-4));
267 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(-3.3743242489947529).epsilon(1
e-4));
268 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(7.5625192454964454).epsilon(1
e-4));
270 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(1.0852823603357820));
271 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(24.2154119471038562));
272 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(111.8849364775797852));
273 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.1572063443997536));
274 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(-3.3743242489947529));
275 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(7.5625192454964454));
281 (
ham.
getHamiltonian(NONLOCALECP))->evaluateWithIonDerivsDeterministic(elec, ions, *psi, hf_term, pulay_term);
284 #if defined(MIXED_PRECISION) 285 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(24.2239540340527491).epsilon(2
e-4));
286 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(-41.9981344310649263).epsilon(2
e-4));
287 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(-98.9123955744908159).epsilon(2
e-4));
288 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.5105943834091704).epsilon(2
e-4));
289 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(1.1345766918857692).epsilon(2
e-4));
290 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(-5.2293234395150989).epsilon(2
e-4));
292 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(24.2239540340527491));
293 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(-41.9981344310649263));
294 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(-98.9123955744908159));
295 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.5105943834091704));
296 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(1.1345766918857692));
297 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(-5.2293234395150989));
308 CHECK(
dot(hf_term[0], hf_term[0]) != Approx(0));
309 CHECK(
dot(pulay_term[0], pulay_term[0]) != Approx(0));
310 CHECK(
dot(wf_grad[0], wf_grad[0]) != Approx(0));
312 CHECK(
dot(hf_term[1], hf_term[1]) != Approx(0));
313 CHECK(
dot(pulay_term[1], pulay_term[1]) != Approx(0));
314 CHECK(
dot(wf_grad[1], wf_grad[1]) != Approx(0));
323 CHECK(
dot(hf_term[0], hf_term[0]) != Approx(0));
324 CHECK(
dot(pulay_term[0], pulay_term[0]) != Approx(0));
325 CHECK(
dot(wf_grad[0], wf_grad[0]) != Approx(0));
327 CHECK(
dot(hf_term[1], hf_term[1]) != Approx(0));
328 CHECK(
dot(pulay_term[1], pulay_term[1]) != Approx(0));
329 CHECK(
dot(wf_grad[1], wf_grad[1]) != Approx(0));
332 TEST_CASE(
"Eloc_Derivatives:slater_wj",
"[hamiltonian]")
334 app_log() <<
"====Ion Derivative Test: Single Slater+Jastrow====\n";
340 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
341 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
342 auto &ions(*ions_ptr), elec(*elec_ptr);
346 int Nions = ions.getTotalNum();
347 int Nelec = elec.getTotalNum();
350 particle_set_map.emplace(
"e", std::move(elec_ptr));
351 particle_set_map.emplace(
"ion0", std::move(ions_ptr));
356 bool wfokay = wfdoc.
parse(
"cn.wfj.xml");
360 xmlNodePtr wfroot = wfdoc.
getRoot();
362 psi_map.emplace(
"psi0", wff.
buildTWF(wfroot, runtime_options));
379 CHECK(logpsi == Approx(-8.9455094611
e+00));
392 CHECK(eloc == Approx(-1.77926812569
e+01));
420 CHECK(wf_grad[0][0] == Approx(-1.8996878390353797));
421 CHECK(wf_grad[0][1] == Approx(2.3247646590007776));
422 CHECK(wf_grad[0][2] == Approx(7.9587196049502031));
423 CHECK(wf_grad[1][0] == Approx(1.8093817104158914));
424 CHECK(wf_grad[1][1] == Approx(-0.0966225639942308));
425 CHECK(wf_grad[1][2] == Approx(-1.5197874544625731));
430 (
ham.
getHamiltonian(KINETIC))->evaluateWithIonDerivsDeterministic(elec, ions, *psi, hf_term, pulay_term);
431 #if defined(MIXED_PRECISION) 432 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(-3.3359153349010735).epsilon(1
e-4));
433 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(30.0487085581835309).epsilon(1
e-4));
434 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(126.5885230360197369).epsilon(1
e-4));
435 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.7271604366774223).epsilon(1
e-4));
436 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(-3.5321234918228579).epsilon(1
e-4));
437 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(5.8844148870917925).epsilon(1
e-4));
439 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(-3.3359153349010735));
440 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(30.0487085581835309));
441 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(126.5885230360197369));
442 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.7271604366774223));
443 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(-3.5321234918228579));
444 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(5.8844148870917925));
450 (
ham.
getHamiltonian(NONLOCALECP))->evaluateWithIonDerivsDeterministic(elec, ions, *psi, hf_term, pulay_term);
452 #if defined(MIXED_PRECISION) 453 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(27.1517161490208956).epsilon(2
e-4));
454 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(-42.8268964286715459).epsilon(2
e-4));
455 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(-101.5046844660360961).epsilon(2
e-4));
456 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.2255825024686260).epsilon(2
e-4));
457 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(1.1362118534918864).epsilon(2
e-4));
458 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(-4.5825638607333019).epsilon(2
e-4));
460 CHECK(hf_term[0][0] + pulay_term[0][0] == Approx(27.1517161490208956));
461 CHECK(hf_term[0][1] + pulay_term[0][1] == Approx(-42.8268964286715459));
462 CHECK(hf_term[0][2] + pulay_term[0][2] == Approx(-101.5046844660360961));
463 CHECK(hf_term[1][0] + pulay_term[1][0] == Approx(2.2255825024686260));
464 CHECK(hf_term[1][1] + pulay_term[1][1] == Approx(1.1362118534918864));
465 CHECK(hf_term[1][2] + pulay_term[1][2] == Approx(-4.5825638607333019));
476 CHECK(
dot(hf_term[0], hf_term[0]) != Approx(0));
477 CHECK(
dot(pulay_term[0], pulay_term[0]) != Approx(0));
478 CHECK(
dot(wf_grad[0], wf_grad[0]) != Approx(0));
480 CHECK(
dot(hf_term[1], hf_term[1]) != Approx(0));
481 CHECK(
dot(pulay_term[1], pulay_term[1]) != Approx(0));
482 CHECK(
dot(wf_grad[1], wf_grad[1]) != Approx(0));
491 CHECK(
dot(hf_term[0], hf_term[0]) != Approx(0));
492 CHECK(
dot(pulay_term[0], pulay_term[0]) != Approx(0));
493 CHECK(
dot(wf_grad[0], wf_grad[0]) != Approx(0));
495 CHECK(
dot(hf_term[1], hf_term[1]) != Approx(0));
496 CHECK(
dot(pulay_term[1], pulay_term[1]) != Approx(0));
497 CHECK(
dot(wf_grad[1], wf_grad[1]) != Approx(0));
500 TEST_CASE(
"Eloc_Derivatives:multislater_noj",
"[hamiltonian]")
502 app_log() <<
"====Ion Derivative Test: Multislater No Jastrow====\n";
508 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
509 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
510 auto &ions(*ions_ptr), elec(*elec_ptr);
514 int Nions = ions.getTotalNum();
515 int Nelec = elec.getTotalNum();
518 particle_set_map.emplace(
"e", std::move(elec_ptr));
519 particle_set_map.emplace(
"ion0", std::move(ions_ptr));
524 bool wfokay = wfdoc.
parse(
"cn.msd-wfnoj.xml");
528 xmlNodePtr wfroot = wfdoc.
getRoot();
530 psi_map.emplace(
"psi0", wff.
buildTWF(wfroot, runtime_options));
547 CHECK(logpsi == Approx(-1.41149961982
e+01));
560 CHECK(eloc == Approx(-1.59769057565
e+01));
639 TEST_CASE(
"Eloc_Derivatives:multislater_wj",
"[hamiltonian]")
641 app_log() <<
"====Ion Derivative Test: Multislater+Jastrow====\n";
647 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
648 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
649 auto &ions(*ions_ptr), elec(*elec_ptr);
653 int Nions = ions.getTotalNum();
654 int Nelec = elec.getTotalNum();
657 particle_set_map.emplace(
"e", std::move(elec_ptr));
658 particle_set_map.emplace(
"ion0", std::move(ions_ptr));
663 bool wfokay = wfdoc.
parse(
"cn.msd-wfj.xml");
667 xmlNodePtr wfroot = wfdoc.
getRoot();
669 psi_map.emplace(
"psi0", wff.
buildTWF(wfroot, runtime_options));
687 CHECK(logpsi == Approx(-8.69329994846
e+00));
700 CHECK(eloc == Approx(-1.75211124679
e+01));
778 TEST_CASE(
"Eloc_Derivatives:proto_sd_noj",
"[hamiltonian]")
780 app_log() <<
"========================================================================================\n";
781 app_log() <<
"========================================================================================\n";
782 app_log() <<
"====================Ion Derivative Test: Prototype Single Slater+ No Jastrow===========\n";
783 app_log() <<
"========================================================================================\n";
784 app_log() <<
"========================================================================================\n";
791 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
792 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
793 auto &ions(*ions_ptr), elec(*elec_ptr);
803 xmlNodePtr root2 = doc2.
getRoot();
806 particle_set_map.emplace(
"e", std::move(elec_ptr));
807 particle_set_map.emplace(
"ion0", std::move(ions_ptr));
812 psi_map.emplace(
"psi0", wff.
buildTWF(root2, runtime_options));
852 upmat.resize(Nup, Norb);
853 dnmat.resize(Ndn, Norb);
857 std::vector<ValueMatrix> matlist;
858 std::vector<ValueMatrix>
B, X;
864 std::vector<std::vector<ValueMatrix>> dM;
865 std::vector<std::vector<ValueMatrix>> dB;
866 matlist.push_back(upmat);
867 matlist.push_back(dnmat);
869 dM.push_back(matlist);
870 dM.push_back(matlist);
871 dM.push_back(matlist);
873 dB.push_back(matlist);
874 dB.push_back(matlist);
875 dB.push_back(matlist);
883 twf.getM(elec, matlist);
890 std::vector<ValueMatrix> minv;
891 std::vector<ValueMatrix> B_gs, M_gs;
893 B_gs.push_back(upmat);
894 B_gs.push_back(dnmat);
895 M_gs.push_back(upmat);
896 M_gs.push_back(dnmat);
897 minv.push_back(upmat);
898 minv.push_back(dnmat);
902 std::vector<std::vector<ValueMatrix>> dB_gs;
903 std::vector<std::vector<ValueMatrix>> dM_gs;
904 std::vector<ValueMatrix> tmp_gs;
905 twf.getGSMatrices(
B, B_gs);
906 twf.getGSMatrices(matlist, M_gs);
907 twf.invertMatrices(M_gs, minv);
908 twf.buildX(minv, B_gs, X);
909 for (
int id = 0;
id < matlist.size();
id++)
912 int ptclnum = (
id == 0 ? Nup : Ndn);
914 gs_m.resize(ptclnum, ptclnum);
915 tmp_gs.push_back(gs_m);
919 dB_gs.push_back(tmp_gs);
920 dB_gs.push_back(tmp_gs);
921 dB_gs.push_back(tmp_gs);
923 dM_gs.push_back(tmp_gs);
924 dM_gs.push_back(tmp_gs);
925 dM_gs.push_back(tmp_gs);
933 for (
int ionid = 0; ionid < ions.getTotalNum(); ionid++)
935 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
937 twf.wipeMatrices(dB[idim]);
938 twf.wipeMatrices(dM[idim]);
941 twf.getIonGradM(elec, ions, ionid, dM);
944 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
946 twf.getGSMatrices(dB[idim], dB_gs[idim]);
947 twf.getGSMatrices(dM[idim], dM_gs[idim]);
948 fkin_complex[ionid][idim] =
twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
956 keval =
twf.trAB(minv, B_gs);
958 CHECK(keobs == Approx(9.1821937928
e+00));
959 #if defined(MIXED_PRECISION) 960 CHECK(fkin[0][0] == Approx(1.0852823603357820).epsilon(1
e-4));
961 CHECK(fkin[0][1] == Approx(24.2154119471038562).epsilon(1
e-4));
962 CHECK(fkin[0][2] == Approx(111.8849364775797852).epsilon(1
e-4));
963 CHECK(fkin[1][0] == Approx(2.1572063443997536).epsilon(1
e-4));
964 CHECK(fkin[1][1] == Approx(-3.3743242489947529).epsilon(1
e-4));
965 CHECK(fkin[1][2] == Approx(7.5625192454964454).epsilon(1
e-4));
967 CHECK(fkin[0][0] == Approx(1.0852823603357820));
968 CHECK(fkin[0][1] == Approx(24.2154119471038562));
969 CHECK(fkin[0][2] == Approx(111.8849364775797852));
970 CHECK(fkin[1][0] == Approx(2.1572063443997536));
971 CHECK(fkin[1][1] == Approx(-3.3743242489947529));
972 CHECK(fkin[1][2] == Approx(7.5625192454964454));
975 app_log() <<
" KEVal = " << keval << std::endl;
977 app_log() <<
" Now evaluating nonlocalecp\n";
979 app_log() <<
"nlppop = " << nlppop << std::endl;
980 app_log() <<
" Evaluated. Calling evaluteOneBodyOpMatrix\n";
984 twf.wipeMatrices(B_gs);
987 twf.getGSMatrices(
B, B_gs);
988 twf.buildX(minv, B_gs, X);
992 nlpp =
twf.trAB(minv, B_gs);
995 app_log() <<
"NLPP = " << nlpp << std::endl;
997 CHECK(nlpp_obs == Approx(1.3849558361
e+01));
1001 for (
int ionid = 0; ionid < ions.getTotalNum(); ionid++)
1003 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1005 twf.wipeMatrices(dB[idim]);
1006 twf.wipeMatrices(dM[idim]);
1009 twf.getIonGradM(elec, ions, ionid, dM);
1012 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1014 twf.getGSMatrices(dB[idim], dB_gs[idim]);
1015 twf.getGSMatrices(dM[idim], dM_gs[idim]);
1016 fnlpp_complex[ionid][idim] =
twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
1021 #if defined(MIXED_PRECISION) 1022 CHECK(fnlpp[0][0] == Approx(24.2239540340527491).epsilon(2
e-4));
1023 CHECK(fnlpp[0][1] == Approx(-41.9981344310649263).epsilon(2
e-4));
1024 CHECK(fnlpp[0][2] == Approx(-98.9123955744908159).epsilon(2
e-4));
1025 CHECK(fnlpp[1][0] == Approx(2.5105943834091704).epsilon(2
e-4));
1026 CHECK(fnlpp[1][1] == Approx(1.1345766918857692).epsilon(2
e-4));
1027 CHECK(fnlpp[1][2] == Approx(-5.2293234395150989).epsilon(2
e-4));
1029 CHECK(fnlpp[0][0] == Approx(24.2239540340527491));
1030 CHECK(fnlpp[0][1] == Approx(-41.9981344310649263));
1031 CHECK(fnlpp[0][2] == Approx(-98.9123955744908159));
1032 CHECK(fnlpp[1][0] == Approx(2.5105943834091704));
1033 CHECK(fnlpp[1][1] == Approx(1.1345766918857692));
1034 CHECK(fnlpp[1][2] == Approx(-5.2293234395150989));
1040 app_log() <<
"========================================================================================\n";
1041 app_log() <<
"========================================================================================\n";
1042 app_log() <<
"====================Ion Derivative Test: Prototype Single Slater+Jastrow===========\n";
1043 app_log() <<
"========================================================================================\n";
1044 app_log() <<
"========================================================================================\n";
1051 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
1052 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
1053 auto &ions(*ions_ptr), elec(*elec_ptr);
1063 xmlNodePtr root2 = doc2.
getRoot();
1066 particle_set_map.emplace(
"e", std::move(elec_ptr));
1067 particle_set_map.emplace(
"ion0", std::move(ions_ptr));
1072 psi_map.emplace(
"psi0", wff.
buildTWF(root2, runtime_options));
1112 upmat.resize(Nup, Norb);
1113 dnmat.resize(Ndn, Norb);
1117 std::vector<ValueMatrix> matlist;
1118 std::vector<ValueMatrix>
B, X;
1124 std::vector<std::vector<ValueMatrix>> dM;
1125 std::vector<std::vector<ValueMatrix>> dB;
1126 matlist.push_back(upmat);
1127 matlist.push_back(dnmat);
1129 dM.push_back(matlist);
1130 dM.push_back(matlist);
1131 dM.push_back(matlist);
1133 dB.push_back(matlist);
1134 dB.push_back(matlist);
1135 dB.push_back(matlist);
1143 twf.getM(elec, matlist);
1150 std::vector<ValueMatrix> minv;
1151 std::vector<ValueMatrix> B_gs, M_gs;
1153 B_gs.push_back(upmat);
1154 B_gs.push_back(dnmat);
1155 M_gs.push_back(upmat);
1156 M_gs.push_back(dnmat);
1157 minv.push_back(upmat);
1158 minv.push_back(dnmat);
1162 std::vector<std::vector<ValueMatrix>> dB_gs;
1163 std::vector<std::vector<ValueMatrix>> dM_gs;
1164 std::vector<ValueMatrix> tmp_gs;
1165 twf.getGSMatrices(
B, B_gs);
1166 twf.getGSMatrices(matlist, M_gs);
1167 twf.invertMatrices(M_gs, minv);
1168 twf.buildX(minv, B_gs, X);
1169 for (
int id = 0;
id < matlist.size();
id++)
1172 int ptclnum = (
id == 0 ? Nup : Ndn);
1174 gs_m.resize(ptclnum, ptclnum);
1175 tmp_gs.push_back(gs_m);
1179 dB_gs.push_back(tmp_gs);
1180 dB_gs.push_back(tmp_gs);
1181 dB_gs.push_back(tmp_gs);
1183 dM_gs.push_back(tmp_gs);
1184 dM_gs.push_back(tmp_gs);
1185 dM_gs.push_back(tmp_gs);
1193 for (
int ionid = 0; ionid < ions.getTotalNum(); ionid++)
1195 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1197 twf.wipeMatrices(dB[idim]);
1198 twf.wipeMatrices(dM[idim]);
1201 twf.getIonGradM(elec, ions, ionid, dM);
1204 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1206 twf.getGSMatrices(dB[idim], dB_gs[idim]);
1207 twf.getGSMatrices(dM[idim], dM_gs[idim]);
1208 fkin_complex[ionid][idim] =
twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
1216 keval =
twf.trAB(minv, B_gs);
1218 CHECK(keobs == Approx(7.6732404154
e+00));
1220 #if defined(MIXED_PRECISION) 1221 CHECK(fkin[0][0] == Approx(-3.3359153349010735).epsilon(1
e-4));
1222 CHECK(fkin[0][1] == Approx(30.0487085581835309).epsilon(1
e-4));
1223 CHECK(fkin[0][2] == Approx(126.5885230360197369).epsilon(1
e-4));
1224 CHECK(fkin[1][0] == Approx(2.7271604366774223).epsilon(1
e-4));
1225 CHECK(fkin[1][1] == Approx(-3.5321234918228579).epsilon(1
e-4));
1226 CHECK(fkin[1][2] == Approx(5.8844148870917925).epsilon(1
e-4));
1228 CHECK(fkin[0][0] == Approx(-3.3359153349010735));
1229 CHECK(fkin[0][1] == Approx(30.0487085581835309));
1230 CHECK(fkin[0][2] == Approx(126.5885230360197369));
1231 CHECK(fkin[1][0] == Approx(2.7271604366774223));
1232 CHECK(fkin[1][1] == Approx(-3.5321234918228579));
1233 CHECK(fkin[1][2] == Approx(5.8844148870917925));
1235 app_log() <<
" KEVal = " << keval << std::endl;
1237 app_log() <<
" Now evaluating nonlocalecp\n";
1239 app_log() <<
"nlppop = " << nlppop << std::endl;
1240 app_log() <<
" Evaluated. Calling evaluteOneBodyOpMatrix\n";
1243 twf.wipeMatrices(
B);
1244 twf.wipeMatrices(B_gs);
1245 twf.wipeMatrices(X);
1247 twf.getGSMatrices(
B, B_gs);
1248 twf.buildX(minv, B_gs, X);
1252 nlpp =
twf.trAB(minv, B_gs);
1255 app_log() <<
"NLPP = " << nlpp << std::endl;
1257 CHECK(nlpp_obs == Approx(1.37365415248
e+01));
1261 for (
int ionid = 0; ionid < ions.getTotalNum(); ionid++)
1263 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1265 twf.wipeMatrices(dB[idim]);
1266 twf.wipeMatrices(dM[idim]);
1269 twf.getIonGradM(elec, ions, ionid, dM);
1272 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1274 twf.getGSMatrices(dB[idim], dB_gs[idim]);
1275 twf.getGSMatrices(dM[idim], dM_gs[idim]);
1276 fnlpp_complex[ionid][idim] =
twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
1281 #if defined(MIXED_PRECISION) 1282 CHECK(fnlpp[0][0] == Approx(27.1517161490208956).epsilon(2
e-4));
1283 CHECK(fnlpp[0][1] == Approx(-42.8268964286715459).epsilon(2
e-4));
1284 CHECK(fnlpp[0][2] == Approx(-101.5046844660360961).epsilon(2
e-4));
1285 CHECK(fnlpp[1][0] == Approx(2.2255825024686260).epsilon(2
e-4));
1286 CHECK(fnlpp[1][1] == Approx(1.1362118534918864).epsilon(2
e-4));
1287 CHECK(fnlpp[1][2] == Approx(-4.5825638607333019).epsilon(2
e-4));
1289 CHECK(fnlpp[0][0] == Approx(27.1517161490208956));
1290 CHECK(fnlpp[0][1] == Approx(-42.8268964286715459));
1291 CHECK(fnlpp[0][2] == Approx(-101.5046844660360961));
1292 CHECK(fnlpp[1][0] == Approx(2.2255825024686260));
1293 CHECK(fnlpp[1][1] == Approx(1.1362118534918864));
1294 CHECK(fnlpp[1][2] == Approx(-4.5825638607333019));
1306 TEST_CASE(
"Eloc_Derivatives:slater_fastderiv_complex_pbc",
"[hamiltonian]")
1309 app_log() <<
"====Ion Derivative Test: Single Slater No Jastrow Complex PBC====\n";
1310 std::ostringstream section_name;
1311 section_name <<
"Carbon diamond off gamma unit test: ";
1315 CrystalLattice<OHMMS_PRECISION, OHMMS_DIM>
lattice;
1319 RealType lat_const = 3.37316115000000e+00;
1320 lattice.R = {lat_const, lat_const, 0, 0, lat_const, lat_const, lat_const, 0, lat_const};
1324 const SimulationCell simulation_cell(
lattice);
1325 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
1326 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
1327 auto &ions(*ions_ptr), elec(*elec_ptr);
1332 int Nions = ions.getTotalNum();
1333 int Nelec = elec.getTotalNum();
1336 particle_set_map.emplace(
"e", std::move(elec_ptr));
1337 particle_set_map.emplace(
"ion0", std::move(ions_ptr));
1339 WaveFunctionFactory wff(elec, particle_set_map, c);
1342 bool wfokay = wfdoc.
parse(
"C_diamond-twist-third-cart.wfj.xml");
1345 RuntimeOptions runtime_options;
1346 xmlNodePtr wfroot = wfdoc.
getRoot();
1350 psi_map.emplace(
"psi0", wff.buildTWF(wfnode[0], runtime_options));
1352 TrialWaveFunction* psi = psi_map[
"psi0"].get();
1355 HamiltonianFactory hf(
"h0", elec, particle_set_map, psi_map, c);
1357 const char* hamiltonian_xml =
"<hamiltonian name=\"h0\" pbc=\"yes\" type=\"generic\" target=\"e\"> \ 1358 <pairpot type=\"coulomb\" name=\"ElecElec\" source=\"e\" target=\"e\"/> \ 1359 <pairpot type=\"coulomb\" name=\"IonIon\" source=\"ion0\" target=\"ion0\"/> \ 1360 <pairpot name=\"PseudoPot\" type=\"pseudo\" source=\"ion0\" wavefunction=\"psi0\" format=\"xml\" algorithm=\"non-batched\"> \ 1361 <pseudo elementType=\"C\" href=\"C.BFD.xml\"/> \ 1370 xmlNodePtr hroot = hdoc.
getRoot();
1373 QMCHamiltonian&
ham = *hf.getH();
1378 RealType logpsi = psi->evaluateLog(elec);
1379 app_log() <<
" LOGPSI = " << logpsi << std::endl;
1390 app_log() <<
"LocalEnergy = " << std::setprecision(13) << eloc << std::endl;
1403 wfgradraw.resize(Nions);
1404 wf_grad.resize(Nions);
1405 hf_term.resize(Nions);
1406 pulay_term.resize(Nions);
1408 TWFFastDerivWrapper
twf;
1410 psi->initializeTWFFastDerivWrapper(elec,
twf);
1422 upmat.resize(Nup, Norb);
1423 dnmat.resize(Ndn, Norb);
1427 std::vector<ValueMatrix> matlist;
1428 std::vector<ValueMatrix>
B, X;
1434 std::vector<std::vector<ValueMatrix>> dM;
1435 std::vector<std::vector<ValueMatrix>> dB;
1436 matlist.push_back(upmat);
1437 matlist.push_back(dnmat);
1439 dM.push_back(matlist);
1440 dM.push_back(matlist);
1441 dM.push_back(matlist);
1443 dB.push_back(matlist);
1444 dB.push_back(matlist);
1445 dB.push_back(matlist);
1453 twf.getM(elec, matlist);
1456 app_log() << kinop << std::endl;
1457 kinop->evaluateOneBodyOpMatrix(elec,
twf,
B);
1460 std::vector<ValueMatrix> minv;
1461 std::vector<ValueMatrix> B_gs, M_gs;
1463 B_gs.push_back(upmat);
1464 B_gs.push_back(dnmat);
1465 M_gs.push_back(upmat);
1466 M_gs.push_back(dnmat);
1467 minv.push_back(upmat);
1468 minv.push_back(dnmat);
1472 std::vector<std::vector<ValueMatrix>> dB_gs;
1473 std::vector<std::vector<ValueMatrix>> dM_gs;
1474 std::vector<ValueMatrix> tmp_gs;
1475 twf.getGSMatrices(
B, B_gs);
1476 twf.getGSMatrices(matlist, M_gs);
1477 twf.invertMatrices(M_gs, minv);
1478 twf.buildX(minv, B_gs, X);
1479 for (
int id = 0;
id < matlist.size();
id++)
1482 int ptclnum = (
id == 0 ? Nup : Ndn);
1484 gs_m.resize(ptclnum, ptclnum);
1485 tmp_gs.push_back(gs_m);
1489 dB_gs.push_back(tmp_gs);
1490 dB_gs.push_back(tmp_gs);
1491 dB_gs.push_back(tmp_gs);
1493 dM_gs.push_back(tmp_gs);
1494 dM_gs.push_back(tmp_gs);
1495 dM_gs.push_back(tmp_gs);
1503 for (
int ionid = 0; ionid < ions.getTotalNum(); ionid++)
1505 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1507 twf.wipeMatrices(dB[idim]);
1508 twf.wipeMatrices(dM[idim]);
1511 twf.getIonGradM(elec, ions, ionid, dM);
1512 kinop->evaluateOneBodyOpMatrixForceDeriv(elec, ions,
twf, ionid, dB);
1514 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1516 twf.getGSMatrices(dB[idim], dB_gs[idim]);
1517 twf.getGSMatrices(dM[idim], dM_gs[idim]);
1518 fkin_complex[ionid][idim] =
twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
1526 keval =
twf.trAB(minv, B_gs);
1528 CHECK(keobs == Approx(7.3599525590
e+00));
1531 #if defined(MIXED_PRECISION) 1532 CHECK(fkin[0][0] == Approx(-3.0056583106).epsilon(1
e-4));
1533 CHECK(fkin[0][1] == Approx(2.3690133680).epsilon(1
e-4));
1534 CHECK(fkin[0][2] == Approx(-1.3344162436).epsilon(1
e-4));
1535 CHECK(fkin[1][0] == Approx(2.7879500000).epsilon(1
e-4));
1536 CHECK(fkin[1][1] == Approx(-4.5397950000).epsilon(1
e-4));
1537 CHECK(fkin[1][2] == Approx(-2.3463500000).epsilon(1
e-4));
1539 CHECK(fkin[0][0] == Approx(-3.0056583106));
1540 CHECK(fkin[0][1] == Approx(2.3690133680));
1543 CHECK(fkin[0][2] == Approx(-1.3344162436).epsilon(1
e-4));
1544 CHECK(fkin[1][0] == Approx(2.7879500000));
1545 CHECK(fkin[1][1] == Approx(-4.5397950000));
1546 CHECK(fkin[1][2] == Approx(-2.3463500000));
1548 app_log() <<
" KEVal = " << keval << std::endl;
1550 app_log() <<
" Now evaluating nonlocalecp\n";
1552 app_log() <<
" Evaluated. Calling evaluteOneBodyOpMatrix\n";
1555 twf.wipeMatrices(
B);
1556 twf.wipeMatrices(B_gs);
1557 twf.wipeMatrices(X);
1558 nlppop->evaluateOneBodyOpMatrix(elec,
twf,
B);
1559 twf.getGSMatrices(
B, B_gs);
1560 twf.buildX(minv, B_gs, X);
1564 nlpp =
twf.trAB(minv, B_gs);
1567 app_log() <<
"NLPP = " << nlpp << std::endl;
1569 CHECK(nlpp_obs == Approx(-2.4018757000
e-02));
1573 for (
int ionid = 0; ionid < ions.getTotalNum(); ionid++)
1575 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1577 twf.wipeMatrices(dB[idim]);
1578 twf.wipeMatrices(dM[idim]);
1581 twf.getIonGradM(elec, ions, ionid, dM);
1582 nlppop->evaluateOneBodyOpMatrixForceDeriv(elec, ions,
twf, ionid, dB);
1584 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
1586 twf.getGSMatrices(dB[idim], dB_gs[idim]);
1587 twf.getGSMatrices(dM[idim], dM_gs[idim]);
1588 fnlpp_complex[ionid][idim] =
twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
1593 #if defined(MIXED_PRECISION) 1594 CHECK(fnlpp[0][0] == Approx(-0.0922161020).epsilon(2
e-4));
1595 CHECK(fnlpp[0][1] == Approx(-0.3309802962).epsilon(2
e-4));
1596 CHECK(fnlpp[0][2] == Approx(-0.1599170783).epsilon(2
e-4));
1597 CHECK(fnlpp[1][0] == Approx(0.0463607500).epsilon(2
e-4));
1598 CHECK(fnlpp[1][1] == Approx(0.0176553000).epsilon(2
e-4));
1599 CHECK(fnlpp[1][2] == Approx(0.0252567500).epsilon(2
e-4));
1601 CHECK(fnlpp[0][0] == Approx(-0.0922161020));
1602 CHECK(fnlpp[0][1] == Approx(-0.3309802962));
1603 CHECK(fnlpp[0][2] == Approx(-0.1599170783));
1604 CHECK(fnlpp[1][0] == Approx(0.0463607500));
1605 CHECK(fnlpp[1][1] == Approx(0.0176553000));
1606 CHECK(fnlpp[1][2] == Approx(0.0252567500));
void resize(size_type n, Type_t val=Type_t())
Resize the container.
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
FullPrecRealType evaluateIonDerivsDeterministicFast(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi_in, TWFFastDerivWrapper &psi_wrapper, ParticleSet::ParticlePos &dedr, ParticleSet::ParticlePos &wf_grad)
evaluate local energy and derivatives w.r.t ionic coordinates, but deterministically.
void setName(const std::string &aname)
class that handles xmlDoc
std::string getObservableName(int i) const
return the name of the i-th observable
QMCHamiltonian & create_CN_Hamiltonian(HamiltonianFactory &hf)
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
helper functions for EinsplineSetBuilder
QTBase::RealType RealType
xmlXPathContextPtr getXPathContext()
OperatorBase * getHamiltonian(const std::string &aname)
return OperatorBase with the name aname
void create_CN_particlesets(ParticleSet &elec, ParticleSet &ions)
TEST_CASE("complex_helper", "[type_traits]")
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
RealType getObservable(int i) const
return the value of the i-th observable
QMCHamiltonian * getH() const
get targetH
Collection of Local Energy Operators.
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
void update(bool skipSK=false)
update the internal data
Attaches a unit to a Vector for IO.
Communicate * Controller
Global Communicator for a process.
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
class to handle xmlXPathObject
Wrapping information on parallelism.
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
Specialized paritlce class for atomistic simulations.
virtual void evaluateOneBodyOpMatrix(ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B)
Evaluate "B" matrix for observable.
QTBase::ValueType ValueType
std::unique_ptr< TrialWaveFunction > buildTWF(xmlNodePtr cur, const RuntimeOptions &runtime_options)
read from xmlNode
REQUIRE(std::filesystem::exists(filename))
Factory class to build a many-body wavefunction.
bool put(xmlNodePtr cur)
read from xmlNode
Factory class to build a many-body wavefunction.
void create_C_pbc_particlesets(ParticleSet &elec, ParticleSet &ions)
OrbitalSetTraits< ValueType >::ValueVector ValueVector
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the so...
int sizeOfObservables() const
return the size of observables
FullPrecRealType evaluateIonDerivsDeterministic(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms, ParticleSet::ParticlePos &wf_grad)
evaluate local energy and derivatives w.r.t ionic coordinates, but deterministically.
FullPrecRealType evaluateDeterministic(ParticleSet &P)
evaluate Local Energy deterministically.
bool readXML(xmlNodePtr cur)
process xmlnode <particleset/> which contains everything about the particle set to initialize ...
std::map< std::string, const std::unique_ptr< TrialWaveFunction > > PsiPoolType
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void create(const std::vector< int > &agroup)
create grouped particles
An abstract class for Local Energy operators.
QMCTraits::RealType RealType
OrbitalSetTraits< ValueType >::GradVector GradVector
Class to represent a many-body trial wave function.
bool parseFromString(const std::string_view data)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
ParticleAttrib< SingleParticlePos > ParticlePos
bool parse(const std::string &fname)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
LatticeGaussianProduct::ValueType ValueType
ParticleAttrib< QTFull::GradType > ParticleGradient
void createSK()
create Structure Factor with PBCs
Custom container for set of attributes for a set of species.
double B(double x, int k, int i, const std::vector< double > &t)
void setRandomGenerator(RandomBase< FullPrecRealType > *rng)
Declare a global Random Number Generator.
virtual void evaluateOneBodyOpMatrixForceDeriv(ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce)
Evaluate "dB/dR" matrices for observable.
static lr_type this_lr_type
Declaration of QMCHamiltonian.
void initializeTWFFastDerivWrapper(const ParticleSet &P, TWFFastDerivWrapper &twf) const
Initialize a TWF wrapper for fast derivative evaluation.
FullPrecRealType evaluateIonDerivs(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms, ParticleSet::ParticlePos &wf_grad)
evaluate local energy and derivatives w.r.t ionic coordinates.