-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathtest_temp.cpp
More file actions
80 lines (70 loc) · 2.71 KB
/
test_temp.cpp
File metadata and controls
80 lines (70 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//////////////////////////////////////////////////////////////////////////////////////
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2019 and QMCPACK developers.
//
// File developed by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, University of Illinois Urbana-Champaign
//
// File created by: Yubo "Paul" Yang, yubo.paul.yang@gmail.com, University of Illinois Urbana-Champaign
//////////////////////////////////////////////////////////////////////////////////////
#include "catch.hpp"
#include "Configuration.h"
#include "Lattice/CrystalLattice.h"
#include "Particle/ParticleSet.h"
#include "LongRange/LRHandlerTemp.h"
namespace qmcplusplus
{
using mRealType = LRHandlerBase::mRealType;
struct EslerCoulomb3D
{ // stripped down version of LRCoulombSingleton::CoulombFunctor for 3D
double norm;
inline double operator()(double r, double rinv) const { return rinv; }
void reset(ParticleSet& ref) { norm = 4.0 * M_PI / ref.getLRBox().Volume; }
inline double Xk(double k, double rc) const { return -norm / (k * k) * std::cos(k * rc); }
inline double Fk(double k, double rc) const { return -Xk(k, rc); }
inline double integrate_r2(double r) const { return 0.5 * r * r; }
inline double df(double r) const { return 0; } // ignore derivatives for now
void reset(ParticleSet& ref, double rs) { reset(ref); } // ignore rs
};
/** evalaute bare Coulomb in 3D using LRHandlerTemp
*/
TEST_CASE("temp3d", "[lrhandler]")
{
Lattice lattice;
lattice.BoxBConds = true;
lattice.LR_dim_cutoff = 30.;
lattice.R.diagonal(5.0);
lattice.reset();
CHECK(Approx(lattice.Volume) == 125);
lattice.SetLRCutoffs(lattice.Rv);
//lattice.printCutoffs(app_log());
CHECK(Approx(lattice.LR_rc) == 2.5);
CHECK(Approx(lattice.LR_kc) == 12);
const SimulationCell simulation_cell(lattice);
ParticleSet ref(simulation_cell); // handler needs ref.getSimulationCell().getKLists()
ref.createSK();
LRHandlerTemp<EslerCoulomb3D, LPQHIBasis> handler(ref);
handler.initBreakup(ref);
app_log() << "handler.MaxKshell is " << handler.MaxKshell << std::endl;
CHECK(handler.MaxKshell == 78);
CHECK(Approx(handler.LR_rc) == 2.5);
CHECK(Approx(handler.LR_kc) == 12);
mRealType r, dr, rinv;
mRealType vsr, vlr;
int nr = 101;
dr = 5.0 / nr; // L/[# of grid points]
for (int ir = 1; ir < nr; ir++)
{
r = ir * dr;
rinv = 1. / r;
vsr = handler.evaluate(r, rinv);
vlr = handler.evaluateLR(r);
// short-range part must vanish after rcut
if (r > 2.5)
CHECK(Approx(vsr) == 0.0);
// sum must recover the Coulomb potential
CHECK(vsr + vlr == Approx(rinv));
}
}
} // namespace qmcplusplus