QMCPACK
test_ci_configuration.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 
16 
17 namespace qmcplusplus
18 {
19 TEST_CASE("ci_configuration2", "[wavefunction]")
20 {
21  const int n_states = 6;
22  std::vector<size_t> ref{0, 1, 2, 3};
23  ci_configuration2 ref_state(ref);
24 
25  size_t n_excited;
26  double sign = 0.0;
27  std::vector<size_t> pos(n_states);
28  std::vector<size_t> occupied(n_states);
29  std::vector<size_t> unoccupied(n_states);
30 
31  std::vector<size_t> ext1{0, 1, 4, 5};
32  ci_configuration2 ext1_state(ext1);
33 
34  n_excited = ext1_state.calculateNumOfExcitations(ref_state);
35  REQUIRE(n_excited == 2);
36 
37  sign = ext1_state.calculateExcitations(ref_state, n_excited, pos, occupied, unoccupied);
38 
39  REQUIRE(n_excited == 2);
40  CHECK(sign == 1.0);
41  CHECK(pos[0] == 2);
42  CHECK(pos[1] == 3);
43  CHECK(occupied[0] == 4);
44  CHECK(occupied[1] == 5);
45  CHECK(unoccupied[0] == 2);
46  CHECK(unoccupied[1] == 3);
47 
48  std::vector<size_t> ext2{0, 1, 2, 6};
49  ci_configuration2 ext2_state(ext2);
50 
51  n_excited = ext2_state.calculateNumOfExcitations(ref_state);
52  REQUIRE(n_excited == 1);
53 
54  sign = ext2_state.calculateExcitations(ref_state, n_excited, pos, occupied, unoccupied);
55 
56  REQUIRE(n_excited == 1);
57  CHECK(sign == 1.0);
58  CHECK(pos[0] == 3);
59  CHECK(occupied[0] == 6);
60  CHECK(unoccupied[0] == 3);
61 
62  std::vector<size_t> ref2{0, 1};
63  ci_configuration2 ref2_state(ref2);
64  std::vector<size_t> ext3{1, 6};
65  ci_configuration2 ext3_state(ext3);
66 
67  sign = ext3_state.calculateExcitations(ref2_state, n_excited, pos, occupied, unoccupied);
68  REQUIRE(n_excited == 1);
69  CHECK(sign == -1.0);
70 
71  sign = ref2_state.calculateExcitations(ext3_state, n_excited, pos, occupied, unoccupied);
72  REQUIRE(n_excited == 1);
73  CHECK(sign == -1.0);
74 }
75 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
size_t calculateNumOfExcitations(const ci_configuration2 &c) const
REQUIRE(std::filesystem::exists(filename))
double sign(double x)
Definition: Standard.h:73
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
double calculateExcitations(const ci_configuration2 &c, size_t &n, std::vector< size_t > &pos, std::vector< size_t > &ocp, std::vector< size_t > &uno) const