@@ -101,55 +101,52 @@ double ElecState::cal_delta_eband(const UnitCell& ucell) const
101101 const double * v_ofk = nullptr ;
102102 const bool v_ofk_flag = (XC_Functional::get_ked_flag ());
103103
104- if (!PARAM.inp .use_paw )
104+ for (int ir = 0 ; ir < this ->charge ->rhopw ->nrxx ; ir++)
105+ {
106+ deband_aux -= this ->charge ->rho [0 ][ir] * (v_eff[ir] - v_fixed[ir]);
107+ }
108+ if (v_ofk_flag)
105109 {
110+ v_ofk = this ->pot ->get_effective_vofk (0 );
111+ // cause in the get_effective_vofk, the func will return nullptr
112+ if (v_ofk == nullptr && this ->charge ->rhopw ->nrxx > 0 )
113+ {
114+ ModuleBase::WARNING_QUIT (" ElecState::cal_delta_eband" , " v_ofk is nullptr" );
115+ }
106116 for (int ir = 0 ; ir < this ->charge ->rhopw ->nrxx ; ir++)
107117 {
108- deband_aux -= this ->charge ->rho [0 ][ir] * (v_eff[ir] - v_fixed[ir]);
118+ deband_aux -= this ->charge ->kin_r [0 ][ir] * v_ofk[ir];
119+ }
120+ }
121+
122+ if (PARAM.inp .nspin == 2 )
123+ {
124+ v_eff = this ->pot ->get_effective_v (1 );
125+ for (int ir = 0 ; ir < this ->charge ->rhopw ->nrxx ; ir++)
126+ {
127+ deband_aux -= this ->charge ->rho [1 ][ir] * (v_eff[ir] - v_fixed[ir]);
109128 }
110129 if (v_ofk_flag)
111130 {
112- v_ofk = this ->pot ->get_effective_vofk (0 );
113- // cause in the get_effective_vofk, the func will return nullptr
131+ v_ofk = this ->pot ->get_effective_vofk (1 );
114132 if (v_ofk == nullptr && this ->charge ->rhopw ->nrxx > 0 )
115133 {
116134 ModuleBase::WARNING_QUIT (" ElecState::cal_delta_eband" , " v_ofk is nullptr" );
117135 }
118136 for (int ir = 0 ; ir < this ->charge ->rhopw ->nrxx ; ir++)
119137 {
120- deband_aux -= this ->charge ->kin_r [0 ][ir] * v_ofk[ir];
138+ deband_aux -= this ->charge ->kin_r [1 ][ir] * v_ofk[ir];
121139 }
122140 }
123-
124- if (PARAM.inp .nspin == 2 )
141+ }
142+ else if (PARAM.inp .nspin == 4 )
143+ {
144+ for (int is = 1 ; is < 4 ; is++)
125145 {
126- v_eff = this ->pot ->get_effective_v (1 );
146+ v_eff = this ->pot ->get_effective_v (is );
127147 for (int ir = 0 ; ir < this ->charge ->rhopw ->nrxx ; ir++)
128148 {
129- deband_aux -= this ->charge ->rho [1 ][ir] * (v_eff[ir] - v_fixed[ir]);
130- }
131- if (v_ofk_flag)
132- {
133- v_ofk = this ->pot ->get_effective_vofk (1 );
134- if (v_ofk == nullptr && this ->charge ->rhopw ->nrxx > 0 )
135- {
136- ModuleBase::WARNING_QUIT (" ElecState::cal_delta_eband" , " v_ofk is nullptr" );
137- }
138- for (int ir = 0 ; ir < this ->charge ->rhopw ->nrxx ; ir++)
139- {
140- deband_aux -= this ->charge ->kin_r [1 ][ir] * v_ofk[ir];
141- }
142- }
143- }
144- else if (PARAM.inp .nspin == 4 )
145- {
146- for (int is = 1 ; is < 4 ; is++)
147- {
148- v_eff = this ->pot ->get_effective_v (is);
149- for (int ir = 0 ; ir < this ->charge ->rhopw ->nrxx ; ir++)
150- {
151- deband_aux -= this ->charge ->rho [is][ir] * v_eff[ir];
152- }
149+ deband_aux -= this ->charge ->rho [is][ir] * v_eff[ir];
153150 }
154151 }
155152 }
0 commit comments