QMCPACK
test_temp.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 
24 { // stripped down version of LRCoulombSingleton::CoulombFunctor for 3D
25  double norm;
26  inline double operator()(double r, double rinv) const { return rinv; }
27  void reset(ParticleSet& ref) { norm = 4.0 * M_PI / ref.getLRBox().Volume; }
28  inline double Xk(double k, double rc) const { return -norm / (k * k) * std::cos(k * rc); }
29  inline double Fk(double k, double rc) const { return -Xk(k, rc); }
30  inline double integrate_r2(double r) const { return 0.5 * r * r; }
31  inline double df(double r) const { return 0; } // ignore derivatives for now
32  void reset(ParticleSet& ref, double rs) { reset(ref); } // ignore rs
33 };
34 
35 /** evalaute bare Coulomb in 3D using LRHandlerTemp
36  */
37 TEST_CASE("temp3d", "[lrhandler]")
38 {
40  Lattice.BoxBConds = true;
41  Lattice.LR_dim_cutoff = 30.;
42  Lattice.R.diagonal(5.0);
43  Lattice.reset();
44  CHECK(Approx(Lattice.Volume) == 125);
45  Lattice.SetLRCutoffs(Lattice.Rv);
46  //Lattice.printCutoffs(app_log());
47  CHECK(Approx(Lattice.LR_rc) == 2.5);
48  CHECK(Approx(Lattice.LR_kc) == 12);
49 
50  const SimulationCell simulation_cell(Lattice);
51  ParticleSet ref(simulation_cell); // handler needs ref.getSimulationCell().getKLists()
52  ref.createSK();
54 
55  handler.initBreakup(ref);
56 
57  std::cout << "handler.MaxKshell is " << handler.MaxKshell << std::endl;
58  CHECK( (std::is_same<OHMMS_PRECISION, OHMMS_PRECISION_FULL>::value ?
59  handler.MaxKshell == 78 : handler.MaxKshell >= 117 && handler.MaxKshell <= 128 ));
60  CHECK(Approx(handler.LR_rc) == 2.5);
61  CHECK(Approx(handler.LR_kc) == 12);
62 
63  mRealType r, dr, rinv;
64  mRealType vsr, vlr;
65  int nr = 101;
66  dr = 5.0 / nr; // L/[# of grid points]
67  for (int ir = 1; ir < nr; ir++)
68  {
69  r = ir * dr;
70  rinv = 1. / r;
71  vsr = handler.evaluate(r, rinv);
72  vlr = handler.evaluateLR(r);
73  // short-range part must vanish after rcut
74  if (r > 2.5)
75  CHECK(Approx(vsr) == 0.0);
76  // sum must recover the Coulomb potential
77  CHECK(vsr + vlr == Approx(rinv));
78  }
79 }
80 
81 } // namespace qmcplusplus
a class that defines a supercell in D-dimensional Euclean space.
const auto & getLRBox() const
Definition: ParticleSet.h:253
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
void initBreakup(ParticleSet &ref) override
Definition: LRHandlerTemp.h:83
DECLARE_COULOMB_TYPES int MaxKshell
Maxkimum Kshell for the given Kc.
Definition: LRHandlerBase.h:35
TEST_CASE("complex_helper", "[type_traits]")
EwaldHandler3D::mRealType mRealType
double Fk(double k, double rc) const
Definition: test_temp.cpp:29
double integrate_r2(double r) const
Definition: test_temp.cpp:30
Declaration of CrystalLattice<T,D>
void reset(ParticleSet &ref)
Definition: test_temp.cpp:27
TinyVector< SingleParticlePos, D > Rv
Real-space unit vectors.
double operator()(double r, double rinv) const
Definition: test_temp.cpp:26
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
double Xk(double k, double rc) const
Definition: test_temp.cpp:28
double df(double r) const
Definition: test_temp.cpp:31
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
Scalar_t Volume
Physical properties of a supercell.
TinyVector< int, D > BoxBConds
The boundary condition in each direction.
mRealType LR_rc
Maximum r cutoff.
Definition: LRHandlerBase.h:39
Define a LRHandler with two template parameters.
void diagonal(const T &rhs)
Definition: Tensor.h:205
mRealType evaluateLR(mRealType r) const override
evaluate the contribution from the long-range part for for spline
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void createSK()
create Structure Factor with PBCs
mRealType evaluate(mRealType r, mRealType rinv) const override
void reset(ParticleSet &ref, double rs)
Definition: test_temp.cpp:32
Tensor_t R
Real-space unit vectors. R(i,j) i=vector and j=x,y,z.