QMCPACK
test_NonLocalTOperator.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) 2021 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 #include <limits>
16 
17 namespace qmcplusplus
18 {
19 
20 TEST_CASE("NonLocalTOperator", "[hamiltonian]")
21 {
23  NonLocalTOperator t_op;
24  t_op.thingsThatShouldBeInMyConstructor("v0", 1.0, 0.0, 0.0);
25 
26  std::vector<NonLocalData> Txy;
27  Txy.emplace_back(0, 0.4, PosType(0.1, 0.2, 0.3));
28  Txy.emplace_back(1, -0.4, PosType(0.2, 0.3, 0.1));
29  Txy.emplace_back(1, -0.3, PosType(0.2, 0.1, 0.3));
30  Txy.emplace_back(2, -0.2, PosType(0.3, 0.1, 0.2));
31  Txy.emplace_back(2, -0.1, PosType(0.3, 0.1, 0.2));
32  Txy.emplace_back(3, 0.0, PosType(0.3, 0.2, 0.1));
33 
34  auto select0 = t_op.selectMove(0.0, Txy);
35  CHECK(select0 == nullptr);
36 
37  auto select1 = t_op.selectMove(0.4, Txy);
38  CHECK(select1 == nullptr);
39 
40  auto select2 = t_op.selectMove(0.5, Txy);
41  REQUIRE(select2 != nullptr);
42  CHECK(select2->PID == 1);
43 
44  auto select3 = t_op.selectMove(0.6, Txy);
45  REQUIRE(select3 != nullptr);
46  CHECK(select3->PID == 1);
47 
48  auto select4 = t_op.selectMove(0.85, Txy);
49  REQUIRE(select4 != nullptr);
50  CHECK(select4->PID == 2);
51 
52  auto select5 = t_op.selectMove(0.9, Txy);
53  REQUIRE(select5 != nullptr);
54  CHECK(select5->PID == 2);
55 
56  auto select6 = t_op.selectMove(float(1) - std::numeric_limits<float>::epsilon(), Txy);
57  REQUIRE(select6 != nullptr);
58  CHECK(select6->PID == 2);
59 
60  t_op.groupByElectron(4, Txy);
61 
62  auto select7 = t_op.selectMove(0.7, 1);
63  REQUIRE(select7 != nullptr);
64  CHECK(select7->Weight == Approx(-0.4));
65 
66  auto select8 = t_op.selectMove(0.7, 2);
67  REQUIRE(select8 == nullptr);
68 
69  auto select9 = t_op.selectMove(0.8, 2);
70  REQUIRE(select9 != nullptr);
71  CHECK(select9->Weight == Approx(-0.2));
72 }
73 }
void groupByElectron(size_t num_elec, const std::vector< NonLocalData > &txy)
sort all the Txy elements by electron
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
int thingsThatShouldBeInMyConstructor(const std::string &non_local_move_option, const double tau, const double alpha, const double gamma)
replacement for put because wouldn&#39;t it be cool to know what the classes configuration actually is...
Declaration of NonLocalTOperator.
REQUIRE(std::filesystem::exists(filename))
QTBase::PosType PosType
Definition: Configuration.h:61
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
TinyVector< double, 3 > PosType
const NonLocalData * selectMove(RealType prob, const std::vector< NonLocalData > &txy)
select the move for a given probability