Skip to content

Commit e591a7d

Browse files
committed
add new integral test
1 parent 47beb63 commit e591a7d

File tree

13 files changed

+111
-17
lines changed

13 files changed

+111
-17
lines changed

source/module_elecstate/test/elecstate_print_test.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ class ElecStatePrintTest : public ::testing::Test
6969
{
7070
p_klist = new K_Vectors;
7171
p_klist->set_nks(2);
72+
p_klist->set_nkstot(2);
7273
p_klist->isk = {0, 1};
7374
p_klist->ngk = {100, 101};
7475
p_klist->kvec_c.resize(2);
7576
p_klist->kvec_c[0].set(0.1, 0.11, 0.111);
7677
p_klist->kvec_c[1].set(0.2, 0.22, 0.222);
78+
p_klist->ik2iktot.resize(2);
79+
p_klist->ik2iktot[0] = 0;
80+
p_klist->ik2iktot[1] = 1;
7781
// initialize klist of elecstate
7882
elecstate.klist = p_klist;
7983
// initialize ekb of elecstate
@@ -116,11 +120,11 @@ TEST_F(ElecStatePrintTest, PrintFormat)
116120
TEST_F(ElecStatePrintTest, PrintEigenvalueS2)
117121
{
118122
PARAM.input.nspin = 2;
119-
GlobalV::ofs_running.open("test.dat", std::ios::out);
123+
GlobalV::ofs_running.open("running_scf.log", std::ios::out);
120124
// print eigenvalue
121125
elecstate.print_eigenvalue(GlobalV::ofs_running);
122126
GlobalV::ofs_running.close();
123-
ifs.open("test.dat", std::ios::in);
127+
ifs.open("running_scf.log", std::ios::in);
124128
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
125129
EXPECT_THAT(str, testing::HasSubstr("STATE ENERGY(eV) AND OCCUPATIONS"));
126130
EXPECT_THAT(str, testing::HasSubstr("NSPIN == 2"));
@@ -133,17 +137,17 @@ TEST_F(ElecStatePrintTest, PrintEigenvalueS2)
133137
EXPECT_THAT(str, testing::HasSubstr("1 40.8171 0.300000"));
134138
EXPECT_THAT(str, testing::HasSubstr("2 54.4228 0.400000"));
135139
ifs.close();
136-
std::remove("test.dat");
140+
std::remove("running_scf.log");
137141
}
138142

139143
TEST_F(ElecStatePrintTest, PrintEigenvalueS4)
140144
{
141145
PARAM.input.nspin = 4;
142-
GlobalV::ofs_running.open("test.dat", std::ios::out);
146+
GlobalV::ofs_running.open("running_scf.log", std::ios::out);
143147
// print eigenvalue
144148
elecstate.print_eigenvalue(GlobalV::ofs_running);
145149
GlobalV::ofs_running.close();
146-
ifs.open("test.dat", std::ios::in);
150+
ifs.open("running_scf.log", std::ios::in);
147151
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
148152
EXPECT_THAT(str, testing::HasSubstr("STATE ENERGY(eV) AND OCCUPATIONS"));
149153
EXPECT_THAT(str, testing::HasSubstr("NSPIN == 4"));
@@ -154,51 +158,51 @@ TEST_F(ElecStatePrintTest, PrintEigenvalueS4)
154158
EXPECT_THAT(str, testing::HasSubstr("1 40.8171 0.300000"));
155159
EXPECT_THAT(str, testing::HasSubstr("2 54.4228 0.400000"));
156160
ifs.close();
157-
std::remove("test.dat");
161+
std::remove("running_scf.log");
158162
}
159163

160164
TEST_F(ElecStatePrintTest, PrintBand)
161165
{
162166
PARAM.input.nspin = 1;
163167
PARAM.input.nbands = 2;
164168
GlobalV::MY_RANK = 0;
165-
GlobalV::ofs_running.open("test.dat", std::ios::out);
169+
GlobalV::ofs_running.open("running_scf.log", std::ios::out);
166170
// print eigenvalue
167171
elecstate.print_band(0, 1, 0);
168172
GlobalV::ofs_running.close();
169-
ifs.open("test.dat", std::ios::in);
173+
ifs.open("running_scf.log", std::ios::in);
170174
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
171175
EXPECT_THAT(str, testing::HasSubstr("Energy (eV) & Occupations for spin=1 K-point=1"));
172176
EXPECT_THAT(str, testing::HasSubstr("1 13.6057 0.100000"));
173177
EXPECT_THAT(str, testing::HasSubstr("2 27.2114 0.200000"));
174178
ifs.close();
175-
std::remove("test.dat");
179+
std::remove("running_scf.log");
176180
}
177181

178182
TEST_F(ElecStatePrintTest, PrintEigenvalueWarning)
179183
{
180184
elecstate.ekb(0, 0) = 1.0e11;
181185
PARAM.input.nspin = 4;
182-
GlobalV::ofs_running.open("test.dat", std::ios::out);
186+
GlobalV::ofs_running.open("running_scf.log", std::ios::out);
183187
testing::internal::CaptureStdout();
184188
EXPECT_EXIT(elecstate.print_eigenvalue(GlobalV::ofs_running), ::testing::ExitedWithCode(1), "");
185189
output = testing::internal::GetCapturedStdout();
186190
EXPECT_THAT(output, testing::HasSubstr("Eigenvalues are too large!"));
187191
GlobalV::ofs_running.close();
188-
std::remove("test.dat");
192+
std::remove("running_scf.log");
189193
}
190194

191195
TEST_F(ElecStatePrintTest, PrintBandWarning)
192196
{
193197
elecstate.ekb(0, 0) = 1.0e11;
194198
PARAM.input.nspin = 4;
195-
GlobalV::ofs_running.open("test.dat", std::ios::out);
199+
GlobalV::ofs_running.open("running_scf.log", std::ios::out);
196200
testing::internal::CaptureStdout();
197201
EXPECT_EXIT(elecstate.print_band(0, 1, 0), ::testing::ExitedWithCode(1), "");
198202
output = testing::internal::GetCapturedStdout();
199203
EXPECT_THAT(output, testing::HasSubstr("Eigenvalues are too large!"));
200204
GlobalV::ofs_running.close();
201-
std::remove("test.dat");
205+
std::remove("running_scf.log");
202206
}
203207

204208
TEST_F(ElecStatePrintTest, PrintEtot)
@@ -342,6 +346,7 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS2)
342346
PARAM.input.nspin = 2;
343347
GlobalV::MY_RANK = 0;
344348
elecstate.print_etot(ucell.magnet,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
349+
delete elecstate.charge;
345350
}
346351

347352
TEST_F(ElecStatePrintTest, PrintEtotColorS4)
@@ -367,4 +372,5 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS4)
367372
PARAM.input.noncolin = true;
368373
GlobalV::MY_RANK = 0;
369374
elecstate.print_etot(ucell.magnet,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
375+
delete elecstate.charge;
370376
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
etotref -673.8349337888099626
2-
etotperatomref -673.8349337888
1+
etotref -673.8349306935572258
2+
etotperatomref -673.8349306936
33
totalforceref 0.000000
4-
totalstressref 66620.402512
5-
totaltimeref 0.75
4+
totalstressref 66620.323844
5+
totaltimeref 1.34
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
INPUT_PARAMETERS
2+
suffix autotest
3+
4+
nbands 10
5+
6+
calculation scf
7+
ecutwfc 8
8+
scf_thr 1.0e-10
9+
scf_nmax 1
10+
11+
smearing_method gaussian
12+
smearing_sigma 0.02
13+
14+
mixing_type broyden
15+
mixing_beta 0.4
16+
17+
ks_solver cg
18+
basis_type pw
19+
symmetry 0
20+
nspin 2
21+
pseudo_dir ../../PP_ORB
22+
23+
pw_seed 1
24+
25+
kpar 2
26+
# out_wfc_pw 2
27+
init_wfc file
28+
init_chg wfc
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
K_POINTS
2+
0
3+
Gamma
4+
2 1 1 0 0 0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
BAND Spin up Energy(ev) Occupation Spin down Energy(ev) Occupation Kpoint = 1 (0 0 0)
2+
1 -34.6013 0.5 -33.7761 0.5
3+
2 -2.58855 0.5 -2.08974 0.5
4+
3 1.86986 0.5 2.7984 0.5
5+
4 1.91195 0.5 2.79982 0.5
6+
5 23.9461 0.5 24.2851 0.5
7+
6 42.8714 0.5 43.4213 0.5
8+
7 42.892 0.5 43.4713 0.5
9+
8 47.1737 0.5 47.5816 0.5
10+
9 55.927 0 56.4901 0
11+
10 57.1475 0 59.2227 0
12+
13+
14+
BAND Spin up Energy(ev) Occupation Spin down Energy(ev) Occupation Kpoint = 2 (0.5 0 0)
15+
1 -13.2966 0.5 -12.4566 0.5
16+
2 -4.22422 0.5 -3.61022 0.5
17+
3 5.20853 0.5 5.15653 0.5
18+
4 4.99881 0.5 6.43699 0.5
19+
5 29.4915 0.5 29.8951 0.5
20+
6 34.7709 0.5 35.236 0.5
21+
7 38.1075 0.5 38.4163 0.5
22+
8 47.7803 0.5 48.3026 0.5
23+
9 51.2238 6.10623e-15 51.6084 0
24+
10 53.4218 0 53.7871 0
25+
26+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Fe Antiferromagnetic
2+
NSPIN 2
3+
pw
4+
init magnet: up + down
5+
SG15
6+
init_wfc file
7+
init_chg wfc

0 commit comments

Comments
 (0)