Skip to content

Commit fb8a154

Browse files
authored
Test: Add a unit test for read_kpoints ("Line_Cartesian") (#1675)
1 parent ae8ddf1 commit fb8a154

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

source/src_pw/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ AddTest(
1515
SOURCES force_multi_device_test.cpp stress_multi_device_test.cpp wf_multi_device_test.cpp ../../src_parallel/parallel_reduce.cpp ../../src_parallel/parallel_kpoints.cpp ../../src_parallel/parallel_global.cpp ../../src_parallel/parallel_common.cpp
1616
)
1717

18-
install(FILES KPT KPT1 KPT2 KPT4 DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
18+
install(FILES KPT KPT1 KPT2 KPT4 KPT5 DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

source/src_pw/test/KPT5

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
K_POINTS
2+
6
3+
Line_Cartesian
4+
0 0 0 10
5+
0 0 1 10
6+
0.5 0 1 10
7+
0.75 0.75 0 10
8+
0.5 0.5 0.5 10
9+
0 0 0 1

source/src_pw/test/klist_test.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ namespace GlobalC
4848
* - K_Vectors()
4949
* - basic parameters (nks,nkstot,nkstot_ibz) are set
5050
* - read_kpoints()
51-
* - read from file
51+
* - read from file
5252
* - generate KPT from kspacing parameter
5353
* - renew and memory allocation
54+
* - read from file (Line_Cartesian kpoint file)
5455
*/
5556

5657
#define private public
@@ -164,11 +165,11 @@ TEST_F(KlistTest, Renew)
164165
{
165166
K_Vectors kv;
166167
std::string k_file = "KPT4";
167-
//Cartesian: non-spin case nspin=0
168+
//Cartesian: non-spin case nspin=1
168169
kv.nspin = 1;
169170
kv.read_kpoints(k_file);
170171
EXPECT_EQ(kv.kvec_c.size(),5);
171-
//spin case nspin=1
172+
//spin case nspin=2
172173
kv.nspin = 2;
173174
kv.read_kpoints(k_file);
174175
EXPECT_EQ(kv.kvec_c.size(),10);
@@ -177,4 +178,24 @@ TEST_F(KlistTest, Renew)
177178

178179
}
179180

181+
TEST_F(KlistTest, LineCartesian)
182+
{
183+
K_Vectors kv;
184+
std::string k_file = "KPT5";
185+
//Line Cartesian: non-spin case nspin=1
186+
kv.nspin = 1;
187+
// Read from k point file under the case of Line_Cartesian.
188+
kv.read_kpoints(k_file);
189+
EXPECT_EQ(kv.nkstot,51);
190+
EXPECT_EQ(kv.kvec_c.size(),51);
191+
//Line Cartesian: spin case nspin=2
192+
kv.nspin = 2;
193+
// Read from k point file under the case of Line_Cartesian.
194+
kv.read_kpoints(k_file);
195+
EXPECT_EQ(kv.nkstot,51);
196+
EXPECT_EQ(kv.kvec_c.size(),102);
197+
remove("KPT5");
198+
199+
200+
}
180201
#undef private

0 commit comments

Comments
 (0)