@@ -93,8 +93,7 @@ void ModuleIO::prepare_dos(std::ofstream& ofs_running,
9393}
9494
9595bool ModuleIO::cal_dos (const int & is, // index for spin
96- const std::string& file_dos, // file address for DOS
97- const std::string& file_smear, // file address for DOS_smearing
96+ const std::string& fn, // file name for DOS
9897 const double & de_ev, // delta energy in ev
9998 const double & emax_ev, // maximal energy in eV
10099 const double & emin_ev, // minimal energy in ev.
@@ -115,15 +114,16 @@ bool ModuleIO::cal_dos(const int& is, // index for spin
115114
116115 if (GlobalV::MY_RANK == 0 )
117116 {
118- ofs_dos.open (file_dos.c_str ());
119- ofs_smear.open (file_smear.c_str ());
117+ ofs_dos.open (fn.c_str ());
120118 }
121119
122120 std::vector<double > dos;
123121 std::vector<double > ene;
122+ std::vector<double > sum_elec;
124123 std::vector<double > dos_smear; // dos_smearing
125124 dos.clear ();
126125 ene.clear ();
126+ sum_elec.clear ();
127127 dos_smear.clear ();
128128
129129#ifdef __MPI
@@ -154,25 +154,22 @@ bool ModuleIO::cal_dos(const int& is, // index for spin
154154 ofs_dos << npoints << " # number of points" << std::endl;
155155 ofs_dos << " #" << std::setw (14 ) << " energy"
156156 << std::setw (15 ) << " elec_states"
157+ << std::setw (15 ) << " sum_states"
158+ << std::setw (15 ) << " states_smear"
157159 << std::setw (15 ) << " sum_states" << std::endl;
158-
159- ofs_smear << npoints << " # number of points" << std::endl;
160- ofs_smear << " #" << std::setw (14 ) << " energy"
161- << std::setw (15 ) << " states_smear"
162- << std::setw (15 ) << " sum_states" << std::endl;
163160 }
164161
165162 std::vector<double > e_mod (npoints, 0.0 );
166163
167164 double sum = 0.0 ;
168- double e_new = emin_ev;
165+ double curr_energy = emin_ev;
169166 double e_old = 0.0 ;
170167
171- while (e_new < emax_ev)
168+ while (curr_energy < emax_ev)
172169 {
173170 double nstates = 0.0 ;
174- e_old = e_new ;
175- e_new += de_ev;
171+ e_old = curr_energy ;
172+ curr_energy += de_ev;
176173
177174 // nks is the number of k-points in the 'pool'
178175 for (int ik = 0 ; ik < nks; ik++)
@@ -183,9 +180,9 @@ bool ModuleIO::cal_dos(const int& is, // index for spin
183180 // band index
184181 for (int ib = 0 ; ib < nbands; ib++)
185182 {
186- // compare et and e_old(e_new ) in ev unit.
183+ // compare et and e_old(curr_energy ) in ev unit.
187184 if (ekb (ik, ib) * ModuleBase::Ry_to_eV >= e_old
188- && ekb (ik, ib) * ModuleBase::Ry_to_eV < e_new )
185+ && ekb (ik, ib) * ModuleBase::Ry_to_eV < curr_energy )
189186 {
190187 nstates += wk[ik] * nkstot;
191188 }
@@ -202,12 +199,9 @@ bool ModuleIO::cal_dos(const int& is, // index for spin
202199 sum += nstates;
203200 if (GlobalV::MY_RANK == 0 )
204201 {
205- ofs_dos << std::setw (15 ) << e_new
206- << std::setw (15 ) << nstates
207- << std::setw (15 ) << sum
208- << std::endl;
209202 dos.push_back (nstates);
210- ene.push_back (e_new);
203+ ene.push_back (curr_energy);
204+ sum_elec.push_back (sum);
211205 }
212206 }
213207
@@ -236,7 +230,9 @@ bool ModuleIO::cal_dos(const int& is, // index for spin
236230 {
237231 sum2 += dos_smear[i] * de_ev;
238232
239- ofs_smear << std::setw (15 ) << ene[i]
233+ ofs_dos << std::setw (15 ) << ene[i]
234+ << std::setw (15 ) << dos[i]
235+ << std::setw (15 ) << sum_elec[i]
240236 << std::setw (15 ) << dos_smear[i]
241237 << std::setw (15 ) << sum2 << std::endl;
242238 }
@@ -245,7 +241,6 @@ bool ModuleIO::cal_dos(const int& is, // index for spin
245241 if (GlobalV::MY_RANK == 0 )
246242 {
247243 ofs_dos.close ();
248- ofs_smear.close ();
249244 }
250245
251246 ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Number of bands" , nbands);
0 commit comments