-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathtest_lrhandler.cpp
More file actions
72 lines (62 loc) · 2.41 KB
/
test_lrhandler.cpp
File metadata and controls
72 lines (62 loc) · 2.41 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
//////////////////////////////////////////////////////////////////////////////////////
// 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/LRHandlerBase.h"
namespace qmcplusplus
{
using pRealType = qmcplusplus::LRHandlerBase::pRealType;
struct CoulombF2
{
inline double operator()(double k2) { return 4 * M_PI / k2; }
};
/** evalaute bare Coulomb using DummyLRHandler
*/
TEST_CASE("dummy", "[lrhandler]")
{
Lattice lattice;
lattice.BoxBConds = true;
lattice.LR_dim_cutoff = 30.;
lattice.R.diagonal(5.0);
lattice.reset();
CHECK(lattice.Volume == Approx(125));
lattice.SetLRCutoffs(lattice.Rv);
//lattice.printCutoffs(app_log());
CHECK(lattice.LR_rc == Approx(2.5));
CHECK(lattice.LR_kc == Approx(12));
const SimulationCell simulation_cell(lattice);
ParticleSet ref(simulation_cell); // handler needs ref.getSimulationCell().getKLists()
ref.createSK();
DummyLRHandler<CoulombF2> handler(lattice.LR_kc);
handler.initBreakup(ref);
app_log() << "handler.MaxKshell is " << handler.MaxKshell << std::endl;
CHECK(handler.MaxKshell == 78);
CHECK(handler.LR_kc == Approx(12));
CHECK(handler.LR_rc == Approx(0));
std::vector<pRealType> rhok1(handler.MaxKshell);
std::vector<pRealType> rhok2(handler.MaxKshell);
CoulombF2 fk;
double norm = 4 * M_PI / lattice.Volume;
// no actual LR breakup happened in DummyLRHandler,
// the full Coulomb potential should be retained in kspace
for (int ish = 0; ish < handler.MaxKshell; ish++)
{
int ik = ref.getSimulationCell().getKLists().kshell[ish];
double k2 = ref.getSimulationCell().getKLists().ksq[ik];
double fk_expect = fk(k2);
CHECK(handler.Fk_symm[ish] == Approx(norm * fk_expect));
}
// ?? cannot access base class method, too many overloads?
// handler.evaluate(SK->getKLists().kshell, rhok1.data(), rhok2.data());
}
} // namespace qmcplusplus