@@ -32,15 +32,16 @@ TEST_CASE("kcontainer at gamma in 3D", "[longrange]")
3232 const std::vector<double > kcs = {blat, std::sqrt (2 ) * blat, std::sqrt (3 ) * blat};
3333 const std::vector<int > nks = {6 , 18 , 26 };
3434
35- CrystalLattice<OHMMS_PRECISION_FULL, OHMMS_DIM> lattice;
35+ Lattice lattice;
3636 lattice.R .diagonal (1.0 );
3737 lattice.set (lattice.R ); // compute Rv and Gv from R
3838
3939 KContainer klists;
4040 for (int ik = 0 ; ik < kcs.size (); ik++)
4141 {
4242 const double kc = kcs[ik] + 1e-6 ;
43- klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc, ndim);
43+ klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc,
44+ ndim);
4445 CHECK (klists.getKpts ().size () == nks[ik]);
4546 }
4647 const int mxk = klists.getKpts ().size ();
@@ -68,20 +69,22 @@ TEST_CASE("kcontainer at twist in 3D", "[longrange]")
6869 // twist one shell of kvectors
6970 const double kc = blat + 1e-6 ;
7071
71- CrystalLattice<OHMMS_PRECISION_FULL, OHMMS_DIM> lattice;
72+ Lattice lattice;
7273 lattice.R .diagonal (1.0 );
7374 lattice.set (lattice.R ); // compute Rv and Gv from R
7475
7576 KContainer klists;
7677
7778 PosType twist;
7879 twist[0 ] = 0.1 ;
79- klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc, ndim, twist);
80+ klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc,
81+ ndim, twist);
8082 CHECK (klists.getKpts ().size () == 1 );
8183 CHECK (klists.getKptsCartWorking ()[0 ][0 ] == Approx (blat * (twist[0 ] - 1 )));
8284
8385 twist = {-0.5 , 0 , 0.5 };
84- klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc, ndim, twist);
86+ klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc,
87+ ndim, twist);
8588 int gvecs[3 ][3 ] = {{0 , 0 , -1 }, {1 , 0 , -1 }, {1 , 0 , 0 }};
8689 CHECK (klists.getKpts ().size () == 3 );
8790 for (int ik = 0 ; ik < klists.getKpts ().size (); ik++)
@@ -99,15 +102,16 @@ TEST_CASE("kcontainer at gamma in 2D", "[longrange]")
99102 const std::vector<double > kcs = {blat, std::sqrt (2 ) * blat, 2 * blat};
100103 const std::vector<int > nks = {4 , 8 , 12 };
101104
102- CrystalLattice<OHMMS_PRECISION_FULL, OHMMS_DIM> lattice;
105+ Lattice lattice;
103106 lattice.R .diagonal (1.0 );
104107 lattice.set (lattice.R ); // compute Rv and Gv from R
105108
106109 KContainer klists;
107110 for (int ik = 0 ; ik < kcs.size (); ik++)
108111 {
109112 const double kc = kcs[ik] + 1e-6 ;
110- klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc, ndim);
113+ klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc,
114+ ndim);
111115 CHECK (klists.getKpts ().size () == nks[ik]);
112116 }
113117 const int mxk = klists.getKpts ().size ();
@@ -135,28 +139,31 @@ TEST_CASE("kcontainer at twist in 2D", "[longrange]")
135139 // twist one shell of kvectors
136140 const double kc = blat + 1e-6 ;
137141
138- CrystalLattice<OHMMS_PRECISION_FULL, OHMMS_DIM> lattice;
142+ Lattice lattice;
139143 lattice.R .diagonal (1.0 );
140144 lattice.set (lattice.R ); // compute Rv and Gv from R
141145
142146 KContainer klists;
143147
144148 PosType twist;
145149 twist[0 ] = 0.1 ;
146- klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc, ndim, twist);
150+ klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc,
151+ ndim, twist);
147152 CHECK (klists.getKpts ().size () == 1 );
148153 CHECK (klists.getKptsCartWorking ()[0 ][0 ] == Approx (blat * (twist[0 ] - 1 )));
149154
150155 twist[1 ] = 0.1 ;
151- klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc, ndim, twist);
156+ klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc,
157+ ndim, twist);
152158 CHECK (klists.getKpts ().size () == 2 );
153159 CHECK (klists.getKptsCartWorking ()[0 ][0 ] == Approx (blat * (twist[0 ] - 1 )));
154160 CHECK (klists.getKptsCartWorking ()[0 ][1 ] == Approx (blat * twist[1 ]));
155161 CHECK (klists.getKptsCartWorking ()[1 ][0 ] == Approx (blat * (twist[0 ])));
156162 CHECK (klists.getKptsCartWorking ()[1 ][1 ] == Approx (blat * (twist[1 ] - 1 )));
157163
158164 twist = {-0.5 , 0.5 , 0 };
159- klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc, ndim, twist);
165+ klists.updateKLists <typename std::remove_cv_t <std::remove_reference_t <decltype (lattice)>>::Scalar_t>(lattice, kc,
166+ ndim, twist);
160167 CHECK (klists.getKpts ().size () == 3 );
161168 // for (int ik=0;ik<3;ik++)
162169 // app_log() << klists.getKptsCartWorking()[ik] << std::endl;
@@ -170,27 +177,21 @@ TEST_CASE("kcontainer at twist in 2D", "[longrange]")
170177
171178TEST_CASE (" kcontainer for diamond" , " [longrange]" )
172179{
173- // Communicate* comm = OHMMS::Controller;
174- // ParticleSetPool particle_pool{MinimalParticlePool::make_diamondC_1x1x1(comm)};
175- // ParticleSet pset_ions{*(particle_pool.getParticleSet("ion"))};
176-
177180 int ndim = 3 ;
178181
179- // auto kcs = pset_ions.getSimulationCell().getKLists().numk;
180- // std::cout << "kcs:" << kcs << '\n';
181-
182- using Real = QMCTraits::RealType;
182+ using Real = QMCTraits::RealType;
183183 using FullPrecReal = QMCTraits::FullPrecRealType;
184-
185- CrystalLattice<FullPrecReal, OHMMS_DIM> lattice;
184+
185+ Lattice lattice;
186186 lattice.BoxBConds = {true , true , true };
187187 Tensor<double , 3 > lattice_mat{3.37316115 , 3.37316115 , 0.00000000 , 0.00000000 , 3.37316115 ,
188188 3.37316115 , 3.37316115 , 0.00000000 , 3.37316115 };
189189 lattice.set (lattice_mat);
190190 lattice.LR_dim_cutoff = 15 ;
191191 SimulationCell cell (lattice);
192192
193- const KContainerT<Real>& klists = cell.getKLists ();
193+ // In this test we check that both full and reduced precision KContainers agree
194+ const KContainerT<Real>& klists = cell.getKLists ();
194195 std::remove_cv_t <std::remove_reference_t <decltype (KContainer ().getKpts ())>> kpoint_lists = {
195196 {-1 , -1 , -1 }, {-1 , 0 , 0 }, {0 , -1 , 0 }, {0 , 0 , -1 }, {0 , 0 , 1 }, {0 , 1 , 0 }, {1 , 0 , 0 }, {1 , 1 , 1 },
196197 {-1 , -1 , 0 }, {-1 , 0 , -1 }, {0 , -1 , -1 }, {0 , 1 , 1 }, {1 , 0 , 1 }, {1 , 1 , 0 }, {-2 , -1 , -1 }, {-1 , -2 , -1 },
@@ -269,12 +270,18 @@ TEST_CASE("kcontainer for diamond", "[longrange]")
269270 {1 , 5 , 0 }, {1 , 5 , 4 }, {3 , -1 , 4 }, {3 , 4 , -1 }, {4 , -1 , -1 }, {4 , -1 , 3 }, {4 , 1 , 5 }, {4 , 3 , -1 },
270271 {4 , 5 , 1 }, {4 , 5 , 5 }, {5 , 0 , 1 }, {5 , 1 , 0 }, {5 , 1 , 4 }, {5 , 4 , 1 }, {5 , 4 , 5 }, {5 , 5 , 4 },
271272 };
272- double tolerance = 0.1 ;
273273 {
274274 INFO (" Checking kpoint_lists" );
275275 auto check = checkVector (klists.getKpts (), kpoint_lists, true );
276276 CHECKED_ELSE (check.result ) { FAIL (check.result_message ); }
277277 }
278+
279+ const KContainerT<FullPrecReal>& klists_full = cell.getKLists ();
280+ {
281+ INFO (" Checking kpoint_lists" );
282+ auto check = checkVector (klists_full.getKpts (), kpoint_lists, true );
283+ CHECKED_ELSE (check.result ) { FAIL (check.result_message ); }
284+ }
278285}
279286
280287
0 commit comments