@@ -53,61 +53,37 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
5353 {
5454 std::stringstream ssc;
5555 ssc << PARAM.globalv .global_readin_dir << " SPIN" << is + 1 << " _CHG.cube" ;
56- double & ef_tmp = eferm_iout.get_ef (is);
57- if (ModuleIO::read_cube (
58- #ifdef __MPI
59- & (GlobalC::Pgrid),
60- #endif
56+ if (ModuleIO::read_vdata_palgrid (GlobalC::Pgrid,
6157 (PARAM.inp .esolver_type == " sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
62- is,
6358 GlobalV::ofs_running,
64- PARAM.inp .nspin ,
6559 ssc.str (),
6660 this ->rho [is],
67- this ->rhopw ->nx ,
68- this ->rhopw ->ny ,
69- this ->rhopw ->nz ,
70- ef_tmp,
71- & (GlobalC::ucell),
72- this ->prenspin ))
61+ GlobalC::ucell.nat ))
7362 {
7463 GlobalV::ofs_running << " Read in the charge density: " << ssc.str () << std::endl;
7564 }
76- else if (is > 0 )
65+ else if (is > 0 ) // nspin=2 or 4
7766 {
78- if (prenspin == 1 )
67+ if (is == 1 ) // failed at the second spin
7968 {
80- GlobalV::ofs_running << " Didn't read in the charge density but autoset it for spin " << is + 1
81- << std::endl;
82- for (int ir = 0 ; ir < this ->rhopw ->nrxx ; ir++)
83- {
84- this ->rho [is][ir] = 0.0 ;
85- }
69+ std::cout << " Incomplete charge density file!" << std::endl;
70+ read_error = true ;
71+ break ;
8672 }
87- //
88- else if (prenspin == 2 )
89- { // read up and down , then rearrange them.
90- if (is == 1 )
91- {
92- std::cout << " Incomplete charge density file!" << std::endl;
93- read_error = true ;
94- break ;
95- }
96- else if (is == 2 )
97- {
98- GlobalV::ofs_running << " Didn't read in the charge density but would rearrange it later. "
99- << std::endl;
100- }
101- else if (is == 3 )
73+ else if (is == 2 ) // read 2 files when nspin=4
74+ {
75+ GlobalV::ofs_running << " Didn't read in the charge density but would rearrange it later. "
76+ << std::endl;
77+ }
78+ else if (is == 3 ) // read 2 files when nspin=4
79+ {
80+ GlobalV::ofs_running << " rearrange charge density " << std::endl;
81+ for (int ir = 0 ; ir < this ->rhopw ->nrxx ; ir++)
10282 {
103- GlobalV::ofs_running << " rearrange charge density " << std::endl;
104- for (int ir = 0 ; ir < this ->rhopw ->nrxx ; ir++)
105- {
106- this ->rho [3 ][ir] = this ->rho [0 ][ir] - this ->rho [1 ][ir];
107- this ->rho [0 ][ir] = this ->rho [0 ][ir] + this ->rho [1 ][ir];
108- this ->rho [1 ][ir] = 0.0 ;
109- this ->rho [2 ][ir] = 0.0 ;
110- }
83+ this ->rho [3 ][ir] = this ->rho [0 ][ir] - this ->rho [1 ][ir];
84+ this ->rho [0 ][ir] = this ->rho [0 ][ir] + this ->rho [1 ][ir];
85+ this ->rho [1 ][ir] = 0.0 ;
86+ this ->rho [2 ][ir] = 0.0 ;
11187 }
11288 }
11389 }
@@ -127,22 +103,12 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
127103 GlobalV::ofs_running << " try to read kinetic energy density from file : " << ssc.str ()
128104 << std::endl;
129105 // mohan update 2012-02-10, sunliang update 2023-03-09
130- if (ModuleIO::read_cube (
131- #ifdef __MPI
132- & (GlobalC::Pgrid),
133- #endif
106+ if (ModuleIO::read_vdata_palgrid (GlobalC::Pgrid,
134107 (PARAM.inp .esolver_type == " sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
135- is,
136108 GlobalV::ofs_running,
137- PARAM.inp .nspin ,
138109 ssc.str (),
139110 this ->kin_r [is],
140- this ->rhopw ->nx ,
141- this ->rhopw ->ny ,
142- this ->rhopw ->nz ,
143- eferm_iout.ef ,
144- & (GlobalC::ucell),
145- this ->prenspin ))
111+ GlobalC::ucell.nat ))
146112 {
147113 GlobalV::ofs_running << " Read in the kinetic energy density: " << ssc.str () << std::endl;
148114 }
0 commit comments