Skip to content

Commit 7e13f15

Browse files
committed
update DOS related testing codes
1 parent e0efe32 commit 7e13f15

File tree

12 files changed

+92
-48
lines changed

12 files changed

+92
-48
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/relax/pw_output/INPUT

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
INPUT_PARAMETERS
2+
#Parameters (General)
3+
suffix autotest
4+
5+
nbands 8
6+
calculation cell-relax
7+
ecutwfc 10
8+
scf_nmax 20
9+
10+
basis_type pw
11+
relax_nmax 5
12+
13+
cal_stress 1
14+
stress_thr 1e-6
15+
cal_force 1
16+
force_thr_ev 1.0e-3
17+
18+
ks_solver cg
19+
mixing_type broyden
20+
mixing_beta 0.7
21+
22+
relax_new 0
23+
24+
pseudo_dir ../../../tests/PP_ORB
25+
orbital_dir ../../../tests/PP_ORB
26+
27+
nspin 2
28+
29+
out_chg 1
30+
out_pot 1
31+
out_wfc_pw 1
32+
out_dos 1
33+
out_band 1
34+
out_stru 1
35+
out_app_flag 0
36+
37+
out_interval 1

examples/relax/pw_output/KPT

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 2 2 0 0 0

examples/relax/pw_output/STRU

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ATOMIC_SPECIES
2+
Si 1.000 Si_ONCV_PBE-1.0.upf #Element, Mass, Pseudopotential
3+
4+
NUMERICAL_ORBITAL
5+
Si_gga_8au_60Ry_2s2p1d.orb
6+
7+
LATTICE_CONSTANT
8+
10.21 #Lattice constant
9+
10+
LATTICE_VECTORS
11+
0.0 0.5 0.5 #Lattice vector 1
12+
0.5 0.0 0.5 #Lattice vector 2
13+
0.5 0.5 0.0 #Lattice vector 3
14+
15+
ATOMIC_POSITIONS
16+
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
17+
Si #Name of element
18+
0.0 #Magnetic for this element.
19+
2 #Number of atoms
20+
0.00 0.00 0.00 0 0 0 #x,y,z, move_x, move_y, move_z
21+
0.25 0.25 0.25 0 0 0

source/module_io/cal_dos.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,16 @@ bool ModuleIO::cal_dos(const int& is, // index for spin
224224
}
225225
}
226226

227+
// mohan add 2025-06-08
228+
const double dos_thr = 1.0e-12;
227229
double sum2 = 0.0;
228230

229231
for (int i = 0; i < dos.size(); i++)
230232
{
233+
if(dos_smear[i]<dos_thr)
234+
{
235+
dos_smear[i]=0.0;
236+
}
231237
sum2 += dos_smear[i] * de_ev;
232238

233239
ofs_dos << std::setw(15) << ene[i]

source/module_io/test/cal_dos_test.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DosTest : public ::testing::Test
2929
TEST_F(DosTest,Dos)
3030
{
3131
//is,fa,de_ev,emax_ev,emin_ev,bcoeff,nks,nkstot,nbands
32-
DosPrepare dosp = DosPrepare(0,"DOS1.dat","DOS1_smear.dat",0.005,18,-6,0.07,36,36,8);
32+
DosPrepare dosp = DosPrepare(0,"doss1_pw.txt",0.005,18,-6,0.07,36,36,8);
3333
dosp.set_isk();
3434
dosp.read_wk();
3535
dosp.read_istate_info();
@@ -53,30 +53,24 @@ TEST_F(DosTest,Dos)
5353
{
5454
#endif
5555
std::ifstream ifs;
56-
ifs.open("DOS1_smear.dat");
56+
ifs.open(dosp.fa.c_str());
5757
std::string str((std::istreambuf_iterator<char>(ifs)),std::istreambuf_iterator<char>());
5858
EXPECT_THAT(str, testing::HasSubstr("4801 # number of points"));
59-
EXPECT_THAT(str, testing::HasSubstr(" -5.53 0.0241031 0.000772634"));
60-
EXPECT_THAT(str, testing::HasSubstr(" 17.19 0.0952359 15.9976"));
59+
EXPECT_THAT(str, testing::HasSubstr(" -5.39 0.03125 0.03125 0.178099 0.0160702"));
60+
EXPECT_THAT(str, testing::HasSubstr(" 3.07 0.1875 5.46875 1.07003 5.37765"));
6161
ifs.close();
62-
remove("DOS1_smear.dat");
63-
64-
ifs.open("DOS1.dat");
65-
std::string str1((std::istreambuf_iterator<char>(ifs)),std::istreambuf_iterator<char>());
66-
EXPECT_THAT(str1, testing::HasSubstr("4801 # number of points"));
67-
EXPECT_THAT(str1, testing::HasSubstr(" -5.39 0.03125 0.03125"));
68-
EXPECT_THAT(str1, testing::HasSubstr(" -1.25 0.1875 1.90625"));
69-
ifs.close();
70-
remove("DOS1.dat");
62+
remove("doss1_pw.txt");
7163
#ifdef __MPI
7264
}
7365
#endif
7466
}
7567

68+
69+
7670
TEST_F(DosTest,DosW1)
7771
{
7872
//is,fa,de_ev,emax_ev,emin_ev,bcoeff,nks,nkstot,nbands
79-
DosPrepare dosp = DosPrepare(0,"DOS1.dat","DOS1_smear.dat",-0.005,18,-6,0.07,36,36,8);
73+
DosPrepare dosp = DosPrepare(0,"doss1_pw.txt",-0.005,18,-6,0.07,36,36,8);
8074
dosp.set_isk();
8175
dosp.read_wk();
8276
dosp.read_istate_info();
@@ -107,17 +101,17 @@ TEST_F(DosTest,DosW1)
107101
EXPECT_THAT(str, testing::HasSubstr("ModuleIO::cal_dos warning : de <= 0"));
108102
ifs.close();
109103
remove("warning1.log");
110-
remove("DOS1_smear.dat");
111-
remove("DOS1.dat");
104+
remove("doss1_pw.txt");
112105
#ifdef __MPI
113106
}
114107
#endif
115108
}
116109

110+
117111
TEST_F(DosTest,DosW2)
118112
{
119113
//is,fa,de_ev,emax_ev,emin_ev,bcoeff,nks,nkstot,nbands
120-
DosPrepare dosp = DosPrepare(0,"DOS1.dat","DOS1_smear.dat",0.005,-6,18,0.07,36,36,8);
114+
DosPrepare dosp = DosPrepare(0,"doss1_pw.txt",0.005,-6,18,0.07,36,36,8);
121115
dosp.set_isk();
122116
dosp.read_wk();
123117
dosp.read_istate_info();
@@ -147,8 +141,7 @@ TEST_F(DosTest,DosW2)
147141
EXPECT_THAT(str, testing::HasSubstr("ModuleIO::cal_dos warning : emax_ev < emin_ev"));
148142
ifs.close();
149143
remove("warning2.log");
150-
remove("DOS1_smear.dat");
151-
remove("DOS1.dat");
144+
remove("doss1_pw.txt");
152145
#ifdef __MPI
153146
}
154147
#endif

source/module_io/test/dos_test.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ class DosPrepare
1010
public:
1111
DosPrepare(int is_in,
1212
std::string fa_in,
13-
std::string fa1_in,
1413
double de_ev_in,
1514
double emax_ev_in,
1615
double emin_ev_in,
1716
double bcoeff_in,
1817
int nks_in,
1918
int nkstot_in,
2019
int nbands_in):
21-
is(is_in),fa(fa_in),fa1(fa1_in),
20+
is(is_in),fa(fa_in),
2221
de_ev(de_ev_in),emax_ev(emax_ev_in),
2322
emin_ev(emin_ev_in),bcoeff(bcoeff_in),
2423
nks(nks_in),nkstot(nkstot_in),nbands(nbands_in){}
2524

2625
int is;
2726
std::string fa;
28-
std::string fa1;
2927
double de_ev;
3028
double emax_ev;
3129
double emin_ev;

source/module_io/test/support/INPUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ relax_method cg #bfgs; sd; cg; cg_bfgs;
121121
relax_new TRUE #whether to use the new relaxation method
122122
relax_scale_force 0.5 #controls the size of the first CG step if relax_new is true
123123
out_level ie #ie(for electrons); i(for ions);
124-
out_dm 0 #>0 output density matrix
124+
out_dmk 0 #>0 output density matrix DM(k)
125125
deepks_out_labels 0 #>0 compute descriptor for deepks
126126
deepks_scf 0 #>0 add V_delta to Hamiltonian
127127
deepks_bandgap 0 #>0 for bandgap label

0 commit comments

Comments
 (0)