@@ -39,7 +39,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
3939 bool read_error = false ;
4040 if (PARAM.inp .init_chg == " file" || PARAM.inp .init_chg == " auto" )
4141 {
42- GlobalV::ofs_running << " try to read charge from file : " << std::endl;
42+ GlobalV::ofs_running << " try to read charge from file" << std::endl;
4343
4444 // try to read charge from binary file first, which is the same as QE
4545 // liuyu 2023-12-05
@@ -99,22 +99,43 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
9999 break ;
100100 }
101101 }
102+ }
103+
104+ if (XC_Functional::get_func_type () == 3 || XC_Functional::get_func_type () == 5 )
105+ {
106+ GlobalV::ofs_running << " try to read kinetic energy density from file" << std::endl;
107+ // try to read charge from binary file first, which is the same as QE
108+ std::vector<std::complex <double >> kin_g_space (PARAM.inp .nspin * this ->ngmc , {0.0 , 0.0 });
109+ std::vector<std::complex <double >*> kin_g;
110+ for (int is = 0 ; is < PARAM.inp .nspin ; is++)
111+ {
112+ kin_g.push_back (kin_g_space.data () + is * this ->ngmc );
113+ }
102114
103- if (XC_Functional::get_func_type () == 3 || XC_Functional::get_func_type () == 5 )
115+ std::stringstream binary;
116+ binary << PARAM.globalv .global_readin_dir << PARAM.inp .suffix + " -TAU-DENSITY.restart" ;
117+ if (ModuleIO::read_rhog (binary.str (), rhopw, kin_g.data ()))
118+ {
119+ GlobalV::ofs_running << " Read in the kinetic energy density: " << binary.str () << std::endl;
120+ for (int is = 0 ; is < PARAM.inp .nspin ; ++is)
121+ {
122+ rhopw->recip2real (kin_g[is], this ->kin_r [is]);
123+ }
124+ }
125+ else
104126 {
105127 for (int is = 0 ; is < PARAM.inp .nspin ; is++)
106128 {
107129 std::stringstream ssc;
108130 ssc << PARAM.globalv .global_readin_dir << " SPIN" << is + 1 << " _TAU.cube" ;
109- GlobalV::ofs_running << " try to read kinetic energy density from file : " << ssc.str ()
110- << std::endl;
111131 // mohan update 2012-02-10, sunliang update 2023-03-09
112- if (ModuleIO::read_vdata_palgrid (pgrid,
113- (PARAM.inp .esolver_type == " sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
114- GlobalV::ofs_running,
115- ssc.str (),
116- this ->kin_r [is],
117- ucell.nat ))
132+ if (ModuleIO::read_vdata_palgrid (
133+ pgrid,
134+ (PARAM.inp .esolver_type == " sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
135+ GlobalV::ofs_running,
136+ ssc.str (),
137+ this ->kin_r [is],
138+ ucell.nat ))
118139 {
119140 GlobalV::ofs_running << " Read in the kinetic energy density: " << ssc.str () << std::endl;
120141 }
0 commit comments