QMCPACK
test_ParticleBConds.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include <stdio.h>
16 #include <string>
17 
18 #include "OhmmsPETE/OhmmsMatrix.h"
19 #include "OhmmsPETE/TinyVector.h"
20 #include "Lattice/CrystalLattice.h"
21 #include "Lattice/ParticleBConds.h"
22 #include "Configuration.h"
23 
24 using std::string;
25 
26 namespace qmcplusplus
27 {
29 
30 TEST_CASE("open_bconds", "[lattice]")
31 {
34 
35  vec_t v(3.0, 4.0, 5.0);
36 
37  OHMMS_PRECISION r2 = bcond.apply_bc(v);
38  CHECK(Approx(r2) == 50.0);
39 
40 
41  std::vector<vec_t> disps(1);
42  disps[0] = v;
43  std::vector<OHMMS_PRECISION> r(1), rinv(1), rr(1);
44 
45  bcond.apply_bc(disps, r, rinv);
46 
47  CHECK(Approx(r[0]) == std::sqrt(50.0));
48  CHECK(Approx(rinv[0]) == 1.0 / std::sqrt(50.0));
49 
50  r[0] = 0.0;
51  bcond.apply_bc(disps, r);
52  CHECK(Approx(r[0]) == std::sqrt(50.0));
53 
54  bcond.evaluate_rsquared(disps.data(), rr.data(), disps.size());
55  CHECK(Approx(rr[0]) == 50.0);
56 }
57 
58 /** Lattice is defined but Open BC is also used.
59  */
60 TEST_CASE("periodic_bulk_bconds", "[lattice]")
61 {
63  Lattice.BoxBConds = false; // Open BC
64  Lattice.R.diagonal(0.4);
65  Lattice.reset();
66 
67  CHECK(Lattice.Volume == Approx(0.4 * 0.4 * 0.4));
68 
70 
71  vec_t v1(0.0, 0.0, 0.0);
72 
73  OHMMS_PRECISION r2 = bcond.apply_bc(v1);
74  REQUIRE(r2 == 0.0);
75 
76  vec_t v2(0.5, 0.0, 0.0);
77  r2 = bcond.apply_bc(v2);
78  CHECK(r2 == Approx(0.01));
79 }
80 
81 TEST_CASE("uniform 3D Lattice layout", "[lattice]")
82 {
84  Lattice.BoxBConds = true; // periodic
85 
86  Lattice.R.diagonal(1.0);
87  Lattice.reset();
88 
89  REQUIRE(Lattice.R(0, 0) == 1.0);
90  REQUIRE(Lattice.R(0, 1) == 0.0);
91  REQUIRE(Lattice.R(0, 2) == 0.0);
92  REQUIRE(Lattice.R(1, 0) == 0.0);
93  REQUIRE(Lattice.R(1, 1) == 1.0);
94  REQUIRE(Lattice.R(1, 2) == 0.0);
95  REQUIRE(Lattice.R(2, 0) == 0.0);
96  REQUIRE(Lattice.R(2, 1) == 0.0);
97  REQUIRE(Lattice.R(2, 2) == 1.0);
98 }
99 
100 } // namespace qmcplusplus
a class that defines a supercell in D-dimensional Euclean space.
TinyVector< double, 3 > vec_t
void reset()
Evaluate the reciprocal vectors, volume and metric tensor.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
#define OHMMS_PRECISION
Definition: config.h:70
TEST_CASE("complex_helper", "[type_traits]")
Declaration of CrystalLattice<T,D>
T apply_bc(TinyVector< T, D > &displ) const
apply BC on displ and return |displ|^2
Scalar_t Volume
Physical properties of a supercell.
TinyVector< int, D > BoxBConds
The boundary condition in each direction.
REQUIRE(std::filesystem::exists(filename))
void evaluate_rsquared(TinyVector< T, D > *restrict dr, T *restrict rr, int n)
void diagonal(const T &rhs)
Definition: Tensor.h:205
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
Tensor_t R
Real-space unit vectors. R(i,j) i=vector and j=x,y,z.