42 const char* particles = R
"(<simulationcell> 43 <parameter name="lattice" units="bohr"> 44 6.7463223 6.7463223 0.0 45 0.0 3.37316115 3.37316115 46 3.37316115 0.0 3.37316115 48 <parameter name="bconds"> 68 ions_.
R[0] = {0.0, 0.0, 0.0};
69 ions_.
R[1] = {1.686580575, 1.686580575, 1.686580575};
70 ions_.
R[2] = {3.37316115, 3.37316115, 0.0};
71 ions_.
R[3] = {5.059741726, 5.059741726, 1.686580575};
73 const int Cidx =
ispecies.addSpecies(
"C");
81 elec_.
R[0] = {0.0, 1.0, 0.0};
82 elec_.
R[1] = {0.0, 1.1, 0.0};
83 elec_.
R[2] = {0.0, 1.2, 0.0};
84 elec_.
R[3] = {0.0, 1.3, 0.0};
90 tspecies(chargeIdx, upIdx) = -1;
91 tspecies(chargeIdx, downIdx) = -1;
92 const int ei_table_index = elec_.
addTable(ions_);
96 const std::string wf_xml_str = R
"( 97 <sposet_collection type="molecularorbital" name="LCAOBSet" source="ion0" transform="yes" twist="0 0 0" href="C_Diamond_2x1x1-Gaussian.h5" PBCimages="5 5 5" gpu="no"> 98 <basisset name="LCAOBSet" key="GTO" transform="yes"> 99 <grid type="log" ri="1.e-6" rf="1.e2" npts="1001"/> 101 <sposet name="spoud" size="8"> 102 <occupation mode="ground"/> 103 <coefficient size="116" spindataset="0"/> 107 const std::string wf_omp_xml_str = R
"( 108 <sposet_collection type="molecularorbital" name="LCAOBSet" source="ion0" transform="yes" twist="0 0 0" href="C_Diamond_2x1x1-Gaussian.h5" PBCimages="5 5 5" gpu="omptarget"> 109 <basisset name="LCAOBSet" key="GTO" transform="yes"> 110 <grid type="log" ri="1.e-6" rf="1.e2" npts="1001"/> 112 <sposet name="spoud" size="8"> 113 <occupation mode="ground"/> 114 <coefficient size="116" spindataset="0"/> 123 xmlNodePtr bset_xml = xmlFirstElementChild(root);
124 xmlNodePtr sposet_xml = xmlNextElementSibling(bset_xml);
130 CHECK(!lcao_spos.isIdentity());
132 const int norb = spo->getOrbitalSetSize();
133 app_log() <<
"norb: " << norb << std::endl;
140 elec_2.
R[0] = elec_.
R[1];
141 elec_2.
R[1] = elec_.
R[0];
145 std::unique_ptr<SPOSet> spo_2(spo->makeClone());
152 spo->createResource(spo_res);
158 SECTION(
"LCAOrbitalSet::mw_evaluateVGL")
167 spo_2->evaluateVGL(elec_2, 0, psiref_1, dpsiref_1, d2psiref_1);
168 spo->evaluateVGL(elec_, 0, psiref_0, dpsiref_0, d2psiref_0);
169 SECTION(
"single-walker VGL")
197 spo->mw_evaluateValue(spo_list, p_list, 0, psi_v_list);
198 SECTION(
"multi-walker V")
200 CHECK(Approx(
std::real(psi_v_list[0].
get()[0])) == 0.10203360788082);
201 CHECK(Approx(
std::real(psi_v_list[0].
get()[1])) == 0.14111282090404);
202 CHECK(Approx(
std::real(psi_v_list[1].
get()[0])) == 0.09954792826469);
203 CHECK(Approx(
std::real(psi_v_list[1].
get()[1])) == 0.13558495733438);
216 spo->mw_evaluateVGL(spo_list, p_list, 0, psi_list, dpsi_list, d2psi_list);
217 SECTION(
"multi-walker VGL")
219 CHECK(Approx(
std::real(psi_list[0].
get()[0])) == 0.10203360788082);
220 CHECK(Approx(
std::real(d2psi_list[0].
get()[0])) == -0.14269632514649);
221 CHECK(Approx(
std::real(dpsi_list[0].
get()[0][0])) == 0.00031796000022);
222 CHECK(Approx(
std::real(dpsi_list[0].
get()[0][1])) == -0.01951178212495);
223 CHECK(Approx(
std::real(dpsi_list[0].
get()[0][2])) == -0.00031738324507);
224 CHECK(Approx(
std::real(psi_list[0].
get()[1])) == 0.14111282090404);
225 CHECK(Approx(
std::real(d2psi_list[0].
get()[1])) == -0.28230884342631);
226 CHECK(Approx(
std::real(dpsi_list[0].
get()[1][0])) == 0.01205368790709);
227 CHECK(Approx(
std::real(dpsi_list[0].
get()[1][1])) == -0.04876640907938);
228 CHECK(Approx(
std::real(dpsi_list[0].
get()[1][2])) == -0.01205402562448);
230 CHECK(Approx(
std::real(psi_list[1].
get()[0])) == 0.09954792826469);
231 CHECK(Approx(
std::real(d2psi_list[1].
get()[0])) == -0.10799468581785);
232 CHECK(Approx(
std::real(dpsi_list[1].
get()[0][0])) == 0.00024577684629);
233 CHECK(Approx(
std::real(dpsi_list[1].
get()[0][1])) == -0.02943596305516);
234 CHECK(Approx(
std::real(dpsi_list[1].
get()[0][2])) == -0.00024512723822);
235 CHECK(Approx(
std::real(psi_list[1].
get()[1])) == 0.13558495733438);
236 CHECK(Approx(
std::real(d2psi_list[1].
get()[1])) == -0.21885179829267);
237 CHECK(Approx(
std::real(dpsi_list[1].
get()[1][0])) == 0.00738771300147);
238 CHECK(Approx(
std::real(dpsi_list[1].
get()[1][1])) == -0.06080141726019);
239 CHECK(Approx(
std::real(dpsi_list[1].
get()[1][2])) == -0.00738811343748);
243 SECTION(
"compare MW/SW V/VGL")
245 for (
size_t iorb = 0; iorb < norb; iorb++)
257 for (
size_t iorb = 0; iorb < norb; iorb++)
258 for (
size_t iw = 0; iw < nw; iw++)
261 for (
size_t iorb = 0; iorb < norb; iorb++)
273 for (
size_t iorb = 0; iorb < norb; iorb++)
274 for (
size_t iw = 0; iw < nw; iw++)
297 for (
int i = 0; i < norb; i++)
299 psiMinv_data_0[i] = 0.1 * i;
300 psiMinv_data_1[i] = 0.2 * i;
305 std::vector<const SPOSet::ValueType*> invRow_ptr_list;
306 if (spo->isOMPoffload())
307 invRow_ptr_list = {psiMinv_data_0.device_data(), psiMinv_data_1.
device_data()};
309 invRow_ptr_list = {psiMinv_data_0.data(), psiMinv_data_1.
data()};
312 std::vector<SPOSet::ValueType> ratios(nw);
313 std::vector<SPOSet::GradType> grads(nw);
316 spo->mw_evaluateVGLandDetRatioGrads(spo_list, p_list, 0, invRow_ptr_list, phi_vgl_v, ratios, grads);
318 SECTION(
"multi-walker VGLandDetRatioGrads")
331 SECTION(
"LCAOrbitalSet::mw_evaluateDetRatios")
334 const size_t nvp_ = 4;
335 const size_t nvp_2 = 3;
336 const std::vector<size_t> nvp_list = {nvp_, nvp_2};
341 std::vector<ParticleSet::SingleParticlePos> newpos_vp_(nvp_);
342 std::vector<ParticleSet::SingleParticlePos> newpos_vp_2(nvp_2);
343 for (
int i = 0; i < nvp_; i++)
345 newpos_vp_[i][0] = 0.1 * i;
346 newpos_vp_[i][1] = 0.2 * i;
347 newpos_vp_[i][2] = 0.3 * i;
349 for (
int i = 0; i < nvp_2; i++)
351 newpos_vp_2[i][0] = 0.2 * i;
352 newpos_vp_2[i][1] = 0.3 * i;
353 newpos_vp_2[i][2] = 0.4 * i;
374 for (
int i = 0; i < norb; i++)
376 psiMinv_data_0[i] = 0.1 * i;
377 psiMinv_data_1[i] = 0.2 * i;
379 psiMinv_data_0.updateTo();
380 psiMinv_data_1.updateTo();
382 std::vector<const SPOSet::ValueType*> invRow_ptr_list;
383 if (spo->isOMPoffload())
384 invRow_ptr_list = {psiMinv_data_0.device_data(), psiMinv_data_1.device_data()};
386 invRow_ptr_list = {psiMinv_data_0.data(), psiMinv_data_1.data()};
389 std::vector<std::vector<SPOSet::ValueType>> ratios_list(nw);
390 for (
size_t iw = 0; iw < nw; iw++)
391 ratios_list[iw].resize(nvp_list[iw]);
397 invRow_ptr_list, ratios_list);
399 std::vector<SPOSet::ValueType> ratios_ref_0(nvp_);
400 std::vector<SPOSet::ValueType> ratios_ref_1(nvp_2);
402 spo->evaluateDetRatios(VP_, tmp_psi0, psiMinv_ref_0, ratios_ref_0);
403 spo_2->evaluateDetRatios(VP_2, tmp_psi1, psiMinv_ref_1, ratios_ref_1);
405 for (
int ivp = 0; ivp < nvp_; ivp++)
407 for (
int ivp = 0; ivp < nvp_2; ivp++)
410 for (
int ivp = 0; ivp < nvp_; ivp++)
415 for (
int ivp = 0; ivp < nvp_2; ivp++)
459 const char* particles = R
"(<simulationcell> 460 <parameter name="lattice" units="bohr"> 461 6.7463223 6.7463223 0.0 462 0.0 3.37316115 3.37316115 463 3.37316115 0.0 3.37316115 465 <parameter name="bconds"> 485 ions_.
R[0] = {0.0, 0.0, 0.0};
486 ions_.
R[1] = {1.686580575, 1.686580575, 1.686580575};
487 ions_.
R[2] = {3.37316115, 3.37316115, 0.0};
488 ions_.
R[3] = {5.059741726, 5.059741726, 1.686580575};
490 const int Cidx =
ispecies.addSpecies(
"C");
498 elec_.
R[0] = {0.0, 1.0, 0.0};
499 elec_.
R[1] = {0.0, 1.1, 0.0};
500 elec_.
R[2] = {0.0, 1.2, 0.0};
501 elec_.
R[3] = {0.0, 1.3, 0.0};
507 tspecies(chargeIdx, upIdx) = -1;
508 tspecies(chargeIdx, downIdx) = -1;
509 const int ei_table_index = elec_.
addTable(ions_);
513 const std::string wf_xml_str = R
"( 514 <sposet_collection type="molecularorbital" name="LCAOBSet" source="ion0" transform="yes" twist="0.07761248 0.07761248 -0.07761248" href="C_Diamond_2x1x1-Gaussian-tiled-cplx.h5" PBCimages="5 5 5" gpu="no"> 515 <basisset name="LCAOBSet" key="GTO" transform="yes"> 516 <grid type="log" ri="1.e-6" rf="1.e2" npts="1001"/> 518 <sposet name="spoud" size="8" > 519 <occupation mode="ground"/> 520 <coefficient size="52" spindataset="0"/> 524 const std::string wf_omp_xml_str = R
"( 525 <sposet_collection type="molecularorbital" name="LCAOBSet" source="ion0" transform="yes" twist="0.07761248 0.07761248 -0.07761248" href="C_Diamond_2x1x1-Gaussian-tiled-cplx.h5" PBCimages="5 5 5" gpu="omptarget"> 526 <basisset name="LCAOBSet" key="GTO" transform="yes"> 527 <grid type="log" ri="1.e-6" rf="1.e2" npts="1001"/> 529 <sposet name="spoud" size="8" > 530 <occupation mode="ground"/> 531 <coefficient size="52" spindataset="0"/> 540 xmlNodePtr bset_xml = xmlFirstElementChild(root);
541 xmlNodePtr sposet_xml = xmlNextElementSibling(bset_xml);
547 CHECK(!lcao_spos.isIdentity());
549 const int norb = spo->getOrbitalSetSize();
550 app_log() <<
"norb: " << norb << std::endl;
557 elec_2.
R[0] = elec_.
R[1];
558 elec_2.
R[1] = elec_.
R[0];
562 std::unique_ptr<SPOSet> spo_2(spo->makeClone());
569 spo->createResource(spo_res);
575 SECTION(
"LCAOrbitalSet::mw_evaluateVGL")
584 spo_2->evaluateVGL(elec_2, 0, psiref_1, dpsiref_1, d2psiref_1);
585 spo->evaluateVGL(elec_, 0, psiref_0, dpsiref_0, d2psiref_0);
586 SECTION(
"single-walker VGL")
636 spo->mw_evaluateValue(spo_list, p_list, 0, psi_v_list);
637 SECTION(
"multi-walker V")
639 CHECK(Approx(
std::real(psi_v_list[0].
get()[0])) == 0.10394953298732);
640 CHECK(Approx(
std::real(psi_v_list[0].
get()[1])) == 0.04007076321982);
641 CHECK(Approx(
std::real(psi_v_list[1].
get()[0])) == 0.10041826765555);
642 CHECK(Approx(
std::real(psi_v_list[1].
get()[1])) == 0.03692120161253);
644 CHECK(Approx(
std::imag(psi_v_list[0].
get()[0])) == 0.00920567821605);
645 CHECK(Approx(
std::imag(psi_v_list[0].
get()[1])) == -0.07297020296665);
646 CHECK(Approx(
std::imag(psi_v_list[1].
get()[0])) == 0.00921878891696);
647 CHECK(Approx(
std::imag(psi_v_list[1].
get()[1])) == -0.06736883166719);
660 spo->mw_evaluateVGL(spo_list, p_list, 0, psi_list, dpsi_list, d2psi_list);
661 SECTION(
"multi-walker VGL")
663 CHECK(Approx(
std::real(psi_list[0].
get()[0])) == 0.10394953298732);
664 CHECK(Approx(
std::real(d2psi_list[0].
get()[0])) == -0.15355833615767);
665 CHECK(Approx(
std::real(dpsi_list[0].
get()[0][0])) == -0.00066360565262);
666 CHECK(Approx(
std::real(dpsi_list[0].
get()[0][1])) == -0.03040447635885);
667 CHECK(Approx(
std::real(dpsi_list[0].
get()[0][2])) == 0.00066400579544);
668 CHECK(Approx(
std::real(psi_list[0].
get()[1])) == 0.04007076321982);
669 CHECK(Approx(
std::real(d2psi_list[0].
get()[1])) == -0.13347762878346);
670 CHECK(Approx(
std::real(dpsi_list[0].
get()[1][0])) == 0.06427121424074);
671 CHECK(Approx(
std::real(dpsi_list[0].
get()[1][1])) == -0.03145499248870);
672 CHECK(Approx(
std::real(dpsi_list[0].
get()[1][2])) == 0.09703977123104);
674 CHECK(Approx(
std::real(psi_list[1].
get()[0])) == 0.10041826765555);
675 CHECK(Approx(
std::real(d2psi_list[1].
get()[0])) == -0.11271657756448);
676 CHECK(Approx(
std::real(dpsi_list[1].
get()[0][0])) == -0.00056949645372);
677 CHECK(Approx(
std::real(dpsi_list[1].
get()[0][1])) == -0.03940982127946);
678 CHECK(Approx(
std::real(dpsi_list[1].
get()[0][2])) == 0.00056995118020);
679 CHECK(Approx(
std::real(psi_list[1].
get()[1])) == 0.03692120161253);
680 CHECK(Approx(
std::real(d2psi_list[1].
get()[1])) == -0.10225156633271);
681 CHECK(Approx(
std::real(dpsi_list[1].
get()[1][0])) == 0.05862729651642);
682 CHECK(Approx(
std::real(dpsi_list[1].
get()[1][1])) == -0.03141220770622);
683 CHECK(Approx(
std::real(dpsi_list[1].
get()[1][2])) == 0.08454924955444);
685 CHECK(Approx(
std::imag(psi_list[0].
get()[0])) == 0.00920567821605);
686 CHECK(Approx(
std::imag(d2psi_list[0].
get()[0])) == -0.01897980702117);
687 CHECK(Approx(
std::imag(dpsi_list[0].
get()[0][0])) == 0.00599757336742);
688 CHECK(Approx(
std::imag(dpsi_list[0].
get()[0][1])) == 0.00009471083794);
689 CHECK(Approx(
std::imag(dpsi_list[0].
get()[0][2])) == -0.00599734141981);
690 CHECK(Approx(
std::imag(psi_list[0].
get()[1])) == -0.07297020296665);
691 CHECK(Approx(
std::imag(d2psi_list[0].
get()[1])) == 0.24972839540365);
692 CHECK(Approx(
std::imag(dpsi_list[0].
get()[1][0])) == -0.14785027769482);
693 CHECK(Approx(
std::imag(dpsi_list[0].
get()[1][1])) == 0.05546078377043);
694 CHECK(Approx(
std::imag(dpsi_list[0].
get()[1][2])) == -0.19276310593334);
696 CHECK(Approx(
std::imag(psi_list[1].
get()[0])) == 0.00921878891696);
697 CHECK(Approx(
std::imag(d2psi_list[1].
get()[0])) == -0.01501853597019);
698 CHECK(Approx(
std::imag(dpsi_list[1].
get()[0][0])) == 0.00531194469490);
699 CHECK(Approx(
std::imag(dpsi_list[1].
get()[0][1])) == 0.00017539927704);
700 CHECK(Approx(
std::imag(dpsi_list[1].
get()[0][2])) == -0.00531168663225);
701 CHECK(Approx(
std::imag(psi_list[1].
get()[1])) == -0.06736883166719);
702 CHECK(Approx(
std::imag(d2psi_list[1].
get()[1])) == 0.19452200419216);
703 CHECK(Approx(
std::imag(dpsi_list[1].
get()[1][0])) == -0.13949226666533);
704 CHECK(Approx(
std::imag(dpsi_list[1].
get()[1][1])) == 0.05635953434634);
705 CHECK(Approx(
std::imag(dpsi_list[1].
get()[1][2])) == -0.17227552311686);
709 SECTION(
"compare MW/SW V/VGL")
712 for (
size_t iorb = 0; iorb < norb; iorb++)
724 for (
size_t iorb = 0; iorb < norb; iorb++)
725 for (
size_t iw = 0; iw < nw; iw++)
728 for (
size_t iorb = 0; iorb < norb; iorb++)
740 for (
size_t iorb = 0; iorb < norb; iorb++)
741 for (
size_t iw = 0; iw < nw; iw++)
780 SECTION(
"LCAOrbitalSet::mw_evaluateDetRatios")
783 const size_t nvp_ = 4;
784 const size_t nvp_2 = 3;
785 const std::vector<size_t> nvp_list = {nvp_, nvp_2};
790 std::vector<ParticleSet::SingleParticlePos> newpos_vp_(nvp_);
791 std::vector<ParticleSet::SingleParticlePos> newpos_vp_2(nvp_2);
792 for (
int i = 0; i < nvp_; i++)
794 newpos_vp_[i][0] = 0.1 * i;
795 newpos_vp_[i][1] = 0.2 * i;
796 newpos_vp_[i][2] = 0.3 * i;
798 for (
int i = 0; i < nvp_2; i++)
800 newpos_vp_2[i][0] = 0.2 * i;
801 newpos_vp_2[i][1] = 0.3 * i;
802 newpos_vp_2[i][2] = 0.4 * i;
823 for (
int i = 0; i < norb; i++)
825 psiMinv_data_0[i] = 0.1 * i;
826 psiMinv_data_1[i] = 0.2 * i;
828 psiMinv_data_0.updateTo();
829 psiMinv_data_1.updateTo();
831 std::vector<const SPOSet::ValueType*> invRow_ptr_list;
832 if (spo->isOMPoffload())
833 invRow_ptr_list = {psiMinv_data_0.device_data(), psiMinv_data_1.device_data()};
835 invRow_ptr_list = {psiMinv_data_0.data(), psiMinv_data_1.data()};
838 std::vector<std::vector<SPOSet::ValueType>> ratios_list(nw);
839 for (
size_t iw = 0; iw < nw; iw++)
840 ratios_list[iw].resize(nvp_list[iw]);
846 invRow_ptr_list, ratios_list);
848 std::vector<SPOSet::ValueType> ratios_ref_0(nvp_);
849 std::vector<SPOSet::ValueType> ratios_ref_1(nvp_2);
851 spo->evaluateDetRatios(VP_, tmp_psi0, psiMinv_ref_0, ratios_ref_0);
852 spo_2->evaluateDetRatios(VP_2, tmp_psi1, psiMinv_ref_1, ratios_ref_1);
854 for (
int ivp = 0; ivp < nvp_; ivp++)
856 for (
int ivp = 0; ivp < nvp_2; ivp++)
858 for (
int ivp = 0; ivp < nvp_; ivp++)
860 for (
int ivp = 0; ivp < nvp_2; ivp++)
913 TEST_CASE(
"LCAOrbitalSet batched PBC DiamondC",
"[wavefunction]")
921 TEST_CASE(
"LCAOrbitalSet batched PBC DiamondC offload",
"[wavefunction]")
a class that defines a supercell in D-dimensional Euclean space.
void setName(const std::string &aname)
class that handles xmlDoc
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
helper functions for EinsplineSetBuilder
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
TEST_CASE("complex_helper", "[type_traits]")
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
pointer device_data()
Return the device_ptr matching X if this is a vector attached or owning dual space memory...
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
void test_LCAO_DiamondC_2x1x1_cplx(const bool useOffload)
SPOSetBuilder using new LCAOrbitalSet and Soa versions.
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
void resize(const std::array< SIZET, D > &dims)
Resize the container.
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
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.
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
void test_LCAO_DiamondC_2x1x1_real(const bool useOffload)
QTBase::ValueType ValueType
REQUIRE(std::filesystem::exists(filename))
OrbitalSetTraits< ValueType >::ValueVector ValueVector
std::unique_ptr< SPOSet > createSPOSetFromXML(xmlNodePtr cur) override
create an sposet from xml (legacy)
static void mw_makeMoves(const RefVectorWithLeader< VirtualParticleSet > &vp_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< const std::vector< PosType >> &deltaV_list, const RefVector< const NLPPJob< RealType >> &joblist, bool sphere)
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void create(const std::vector< int > &agroup)
create grouped particles
std::vector< std::reference_wrapper< T > > RefVector
void print(std::ostream &os, const size_t maxParticlesToPrint=0) const
print particle coordinates to a std::ostream
OrbitalSetTraits< ValueType >::GradVector GradVector
bool parseFromString(const std::string_view data)
static void mw_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of update
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
handles acquire/release resource by the consumer (RefVectorWithLeader type).
meta data for NLPP calculation of a pair of ion and electron This is not just meta data...
class to handle linear combinations of basis orbitals used to evaluate the Dirac determinants.
Declaration of WaveFunctionComponent.
Custom container for set of attributes for a set of species.
void updateTo(size_type size=0, std::ptrdiff_t offset=0)
A D-dimensional Array class based on PETE.