@@ -148,109 +148,19 @@ void energy::perform_dos_pw(void)
148148// DOS_ispin contains not smoothed dos
149149 std::stringstream ss;
150150 ss << GlobalV::global_out_dir << " DOS" << is+1 ;
151+ std::stringstream ss1;
152+ ss1 << GlobalV::global_out_dir << " DOS" << is+1 << " _smearing.dat" ;
151153
152154 Dos::calculate_dos (
153155 is,
154156 GlobalC::kv.isk ,
155- ss.str (),
157+ ss.str (),
158+ ss1.str (),
156159 this ->dos_edelta_ev ,
157160 emax,
158161 emin,
159162 GlobalC::kv.nks , GlobalC::kv.nkstot , GlobalC::kv.wk , GlobalC::wf.wg , GlobalV::NBANDS, GlobalC::wf.ekb );
160- std::ifstream in (ss.str ().c_str ());
161- if (!in)
162- {
163- // std::cout<<"\n Can't find file : "<< name << std::endl;
164- // return 0;
165- }
166-
167- // ----------------------------------------------------------
168- // FOUND LOCAL VARIABLES :
169- // NAME : number(number of DOS points)
170- // NAME : nk(number of k point used)
171- // NAME : energy(energy range,from emin_ev to emax_ev)
172- // NAME : dos(old,count k points in the energy range)
173- // NAME : dos2(new,count k points in the energy range)
174- // ----------------------------------------------------------
175- int number=0 ;
176- int nk=0 ;
177- in >> number;
178- in >> nk;
179- double *energy = new double [number];
180- double *dos = new double [number];
181- double *dos2 = new double [number];
182- for (int i=0 ;i<number; i++)
183- {
184- energy[i] = 0.0 ;
185- dos[i] = 0.0 ;
186- dos2[i] =0.0 ;
187- }
188-
189- for (int i=0 ;i<number;i++)
190- {
191- in >> energy[i] >> dos[i];
192- }
193- if (!in.eof ())
194- {
195- // std::cout<<"\n Read Over!"<<std::endl;
196- }
197- in.close ();
198-
199- // now use Gaussian smearing to smooth the dos and write to DOS_is_smearing
200-
201- // ----------------------------------------------------------
202- // EXPLAIN : b is an empirical value.
203- // please DIY b!!
204- // ----------------------------------------------------------
205-
206- // double b = INPUT.b_coef;
207- double b = sqrt (2.0 )*bcoeff;
208- for (int i=0 ;i<number;i++)
209- {
210- double Gauss=0.0 ;
211-
212- for (int j=0 ;j<number;j++)
213- {
214- double de = energy[j] - energy[i];
215- double de2 = de * de;
216- // ----------------------------------------------------------
217- // EXPLAIN : if en
218- // ----------------------------------------------------------
219- Gauss = exp (-de2/b/b)/sqrt (3.1415926 )/b;
220- dos2[j] += dos[i]*Gauss;
221- }
222- }
223-
224- // ----------------------------------------------------------
225- // EXPLAIN : output DOS2.txt
226- // ----------------------------------------------------------
227- std::stringstream sss;
228- sss << GlobalV::global_out_dir << " DOS" << is+1 << " _smearing" << " .dat" ;
229- std::ofstream out (sss.str ().c_str ());
230- double sum2=0.0 ;
231- for (int i=0 ;i<number;i++)
232- {
233- sum2 += dos2[i];
234- // if(dos2[i]<1e-5)
235- // {
236- // dos2[i] = 0.00;
237- // }
238- out <<std::setw (20 )<<energy[i]
239- <<std::setw (20 )<<dos2[i]
240- <<std::setw (20 )<<sum2<<" \n " ;
241- }
242- out.close ();
243-
244- // ----------------------------------------------------------
245- // DELETE
246- // ----------------------------------------------------------
247- delete[] dos;
248- delete[] dos2;
249- delete[] energy;
250-
251- // std::cout<<" broden spectrum over, success : ) "<<std::endl;
252-
253- }
163+ }
254164
255165 }// out_dos=1
256166 if (this ->out_band ) // pengfei 2014-10-13
0 commit comments