QMCPACK
test_lrhandler.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 and QMCPACK developers.
6 //
7 // File developed by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, University of Illinois Urbana-Champaign
8 //
9 // File created by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, University of Illinois Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "catch.hpp"
13 
14 #include "Configuration.h"
15 #include "Lattice/CrystalLattice.h"
16 #include "Particle/ParticleSet.h"
18 
19 namespace qmcplusplus
20 {
22 
23 struct CoulombF2
24 {
25  inline double operator()(double k2) { return 4 * M_PI / k2; }
26 };
27 
28 /** evalaute bare Coulomb using DummyLRHandler
29  */
30 TEST_CASE("dummy", "[lrhandler]")
31 {
33  Lattice.BoxBConds = true;
34  Lattice.LR_dim_cutoff = 30.;
35  Lattice.R.diagonal(5.0);
36  Lattice.reset();
37  CHECK(Lattice.Volume == Approx(125));
38  Lattice.SetLRCutoffs(Lattice.Rv);
39  //Lattice.printCutoffs(app_log());
40  CHECK(Lattice.LR_rc == Approx(2.5));
41  CHECK(Lattice.LR_kc == Approx(12));
42 
43  const SimulationCell simulation_cell(Lattice);
44  ParticleSet ref(simulation_cell); // handler needs ref.getSimulationCell().getKLists()
45  ref.createSK();
46  DummyLRHandler<CoulombF2> handler(Lattice.LR_kc);
47 
48  handler.initBreakup(ref);
49 
50  std::cout << "handler.MaxKshell is " << handler.MaxKshell << std::endl;
51  CHECK( (std::is_same<OHMMS_PRECISION, OHMMS_PRECISION_FULL>::value ?
52  handler.MaxKshell == 78 : handler.MaxKshell >= 117 && handler.MaxKshell <= 128 ));
53  CHECK(handler.LR_kc == Approx(12));
54  CHECK(handler.LR_rc == Approx(0));
55 
56  std::vector<pRealType> rhok1(handler.MaxKshell);
57  std::vector<pRealType> rhok2(handler.MaxKshell);
58  CoulombF2 fk;
59  double norm = 4 * M_PI / Lattice.Volume;
60  // no actual LR breakup happened in DummyLRHandler,
61  // the full Coulomb potential should be retained in kspace
62  for (int ish = 0; ish < handler.MaxKshell; ish++)
63  {
64  int ik = ref.getSimulationCell().getKLists().kshell[ish];
65  double k2 = ref.getSimulationCell().getKLists().ksq[ik];
66  double fk_expect = fk(k2);
67  CHECK(handler.Fk_symm[ish] == Approx(norm * fk_expect));
68  }
69  // ?? cannot access base class method, too many overloads?
70  // handler.evaluate(SK->getKLists().kshell, rhok1.data(), rhok2.data());
71 }
72 
73 } // namespace qmcplusplus
a class that defines a supercell in D-dimensional Euclean space.
double operator()(double k2)
void reset()
Evaluate the reciprocal vectors, volume and metric tensor.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
mRealType LR_kc
Maximum k cutoff.
Definition: LRHandlerBase.h:37
DECLARE_COULOMB_TYPES int MaxKshell
Maxkimum Kshell for the given Kc.
Definition: LRHandlerBase.h:35
TEST_CASE("complex_helper", "[type_traits]")
LRHandler without breakup.
Declaration of CrystalLattice<T,D>
TinyVector< SingleParticlePos, D > Rv
Real-space unit vectors.
const auto & getSimulationCell() const
Definition: ParticleSet.h:250
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
qmcplusplus::LRHandlerBase::pRealType pRealType
Scalar_t Volume
Physical properties of a supercell.
double norm(const zVec &c)
Definition: VectorOps.h:118
TinyVector< int, D > BoxBConds
The boundary condition in each direction.
mRealType LR_rc
Maximum r cutoff.
Definition: LRHandlerBase.h:39
void initBreakup(ParticleSet &ref) override
void diagonal(const T &rhs)
Definition: Tensor.h:205
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void createSK()
create Structure Factor with PBCs
Define LRHandlerBase and DummyLRHandler<typename Func>
Tensor_t R
Real-space unit vectors. R(i,j) i=vector and j=x,y,z.
Vector< mRealType > Fk_symm
Fourier component for each k-shell.
Definition: LRHandlerBase.h:49