QMCPACK
test_kspace_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) 2019 QMCPACK developers.
6 //
7 // File developed by: Yubo "Paul Yang", yubo.paul.yang@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Yubo "Paul Yang", yubo.paul.yang@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include "OhmmsData/Libxml2Doc.h"
16 #include "OhmmsPETE/OhmmsMatrix.h"
17 #include "Particle/ParticleSet.h"
22 #include "ParticleIO/LatticeIO.h"
23 
24 #include <stdio.h>
25 #include <string>
26 
27 using std::string;
28 
29 namespace qmcplusplus
30 {
31 TEST_CASE("kspace jastrow", "[wavefunction]")
32 {
34 
35  // initialize simulationcell for kvectors
36  const char* xmltext = R"(<tmp>
37  <simulationcell>
38  <parameter name="lattice" units="bohr">
39  6.00000000 0.00000000 0.00000000
40  0.00000000 6.00000000 0.00000000
41  0.00000000 0.00000000 6.00000000
42  </parameter>
43  <parameter name="bconds">
44  p p p
45  </parameter>
46  <parameter name="LR_dim_cutoff"> 15 </parameter>
47  </simulationcell>
48 </tmp>)";
50  bool okay = doc.parseFromString(xmltext);
51  REQUIRE(okay);
52 
53  xmlNodePtr root = doc.getRoot();
54  xmlNodePtr part1 = xmlFirstElementChild(root);
55 
56  // read lattice
59  lp.put(part1);
60  lattice.print(app_log(), 0);
61 
62  const SimulationCell simulation_cell(lattice);
63  ParticleSet ions_(simulation_cell);
64  ParticleSet elec_(simulation_cell);
65 
66  ions_.setName("ion");
67  ions_.create({1});
68  ions_.R[0] = {0.0, 0.0, 0.0};
69  elec_.setName("elec");
70  elec_.create({2, 0});
71  elec_.R[0] = {-0.28, 0.0225, -2.709};
72  elec_.R[1] = {-1.08389, 1.9679, -0.0128914};
73  SpeciesSet& tspecies = elec_.getSpeciesSet();
74  int upIdx = tspecies.addSpecies("u");
75  int downIdx = tspecies.addSpecies("d");
76  int chargeIdx = tspecies.addAttribute("charge");
77  tspecies(chargeIdx, upIdx) = -1;
78  tspecies(chargeIdx, downIdx) = -1;
79  // initialize SK
80  elec_.createSK();
81 
82  const char* particles = R"(<tmp>
83 <jastrow name="Jk" type="kSpace" source="ion">
84  <correlation kc="1.5" type="Two-Body" symmetry="isotropic">
85  <coefficients id="cG2" type="Array">
86  -100. -50.
87  </coefficients>
88  </correlation>
89 </jastrow>
90 </tmp>
91 )";
92  okay = doc.parseFromString(particles);
93  REQUIRE(okay);
94 
95  root = doc.getRoot();
96  xmlNodePtr jas1 = xmlFirstElementChild(root);
97 
98  kSpaceJastrowBuilder jastrow(c, elec_, ions_);
99  std::unique_ptr<WaveFunctionComponent> jas(jastrow.buildComponent(jas1));
100 
101  // update all distance tables
102  elec_.update();
103 
104  double logpsi_real = std::real(jas->evaluateLog(elec_, elec_.G, elec_.L));
105  CHECK(logpsi_real == Approx(-4.4088303951)); // !!!! value not checked
106 }
107 } // 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
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
Definition: SpeciesSet.cpp:45
Wrapping information on parallelism.
Definition: Communicate.h:68
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
Declaration of Long-range TwoBody Jastrow.
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
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
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
Declaration of ParticleSetPool.