QMCPACK
test_rpa_jastrow.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include "OhmmsData/Libxml2Doc.h"
16 #include "OhmmsPETE/OhmmsMatrix.h"
17 #include "Particle/ParticleSet.h"
21 #include "ParticleIO/LatticeIO.h"
22 
23 
24 #include <stdio.h>
25 #include <string>
26 
27 using std::string;
28 
29 namespace qmcplusplus
30 {
31 TEST_CASE("RPA Jastrow", "[wavefunction]")
32 {
33  // initialize simulationcell for kvectors
34  const char* xmltext = R"(<tmp>
35  <simulationcell>
36  <parameter name="lattice" units="bohr">
37  6.00000000 0.00000000 0.00000000
38  0.00000000 6.00000000 0.00000000
39  0.00000000 0.00000000 6.00000000
40  </parameter>
41  <parameter name="bconds">
42  p p p
43  </parameter>
44  <parameter name="LR_dim_cutoff"> 15 </parameter>
45  </simulationcell>
46 </tmp>)";
48  bool okay = doc.parseFromString(xmltext);
49  REQUIRE(okay);
50 
51  xmlNodePtr root = doc.getRoot();
52  xmlNodePtr part1 = xmlFirstElementChild(root);
53 
54  // read lattice
57  lp.put(part1);
58  lattice.print(app_log(), 0);
59 
60  const SimulationCell simulation_cell(lattice);
61  ParticleSet ions_(simulation_cell);
62  ParticleSet elec_(simulation_cell);
63 
64  ions_.setName("ion");
65  ions_.create({2});
66  ions_.R[0] = {2.0, 0.0, 0.0};
67  ions_.R[1] = {-2.0, 0.0, 0.0};
68  SpeciesSet& source_species(ions_.getSpeciesSet());
69  source_species.addSpecies("O");
70  ions_.update();
71 
72  elec_.setName("elec");
73  elec_.create({2, 2});
74  elec_.R[0] = {1.00, 0.0, 0.0};
75  elec_.R[1] = {0.0, 0.0, 0.0};
76  elec_.R[2] = {-1.00, 0.0, 0.0};
77  elec_.R[3] = {0.0, 0.0, 2.0};
78  SpeciesSet& target_species(elec_.getSpeciesSet());
79  int upIdx = target_species.addSpecies("u");
80  int downIdx = target_species.addSpecies("d");
81  int chargeIdx = target_species.addAttribute("charge");
82  target_species(chargeIdx, upIdx) = -1;
83  target_species(chargeIdx, downIdx) = -1;
84 
85  // initialize SK
86  elec_.createSK();
87 
88  xmltext = R"(<tmp>
89  <jastrow name="Jee" type="Two-Body" function="rpa"/>
90 </tmp>)";
91  okay = doc.parseFromString(xmltext);
92  REQUIRE(okay);
93 
94  root = doc.getRoot();
95 
96  xmlNodePtr jas_node = xmlFirstElementChild(root);
97  auto jas = std::make_unique<RPAJastrow>(elec_);
98  jas->put(root);
99 
100  // update all distance tables
101  elec_.update();
102 
103  double logpsi_real = std::real(jas->evaluateLog(elec_, elec_.G, elec_.L));
104  CHECK(logpsi_real == Approx(-1.3327837613)); // note: number not validated
105 }
106 } // namespace qmcplusplus
a class that defines a supercell in D-dimensional Euclean space.
void setName(const std::string &aname)
Definition: ParticleSet.h:237
class that handles xmlDoc
Definition: Libxml2Doc.h:76
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
Definition: SpeciesSet.cpp:33
QMCTraits::RealType real
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
Definition: LatticeIO.cpp:32
TEST_CASE("complex_helper", "[type_traits]")
xmlNodePtr getRoot()
Definition: Libxml2Doc.h:88
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
REQUIRE(std::filesystem::exists(filename))
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
ParticlePos R
Position.
Definition: ParticleSet.h:79
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
void create(const std::vector< int > &agroup)
create grouped particles
bool parseFromString(const std::string_view data)
Definition: Libxml2Doc.cpp:204
Declaraton of ParticleAttrib<T>
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void createSK()
create Structure Factor with PBCs
Declaration of WaveFunctionComponent.
Custom container for set of attributes for a set of species.
Definition: SpeciesSet.h:33