Skip to content

Commit 60efe2d

Browse files
committed
modify logic of elecstate_energy.cpp
1 parent e6ecce4 commit 60efe2d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

source/module_elecstate/elecstate_energy.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ double ElecState::cal_delta_eband(const UnitCell& ucell) const
137137
{
138138
v_ofk = this->pot->get_effective_vofk(0);
139139
// cause in the get_effective_vofk, the func will return nullptr
140-
if(v_ofk!=nullptr)
140+
if(v_ofk==nullptr && this->charge->rhopw->nrxx>0)
141141
{
142-
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
143-
{
144-
deband_aux -= this->charge->kin_r[0][ir] * v_ofk[ir];
145-
}
142+
ModuleBase::WARNING_QUIT("ElecState::cal_delta_eband","v_ofk is nullptr");
143+
}
144+
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
145+
{
146+
deband_aux -= this->charge->kin_r[0][ir] * v_ofk[ir];
146147
}
147148
}
148149

@@ -156,12 +157,13 @@ double ElecState::cal_delta_eband(const UnitCell& ucell) const
156157
if (v_ofk_flag)
157158
{
158159
v_ofk = this->pot->get_effective_vofk(1);
159-
if(v_ofk!=nullptr)
160+
if(v_ofk==nullptr && this->charge->rhopw->nrxx>0)
161+
{
162+
ModuleBase::WARNING_QUIT("ElecState::cal_delta_eband","v_ofk is nullptr");
163+
}
164+
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
160165
{
161-
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
162-
{
163-
deband_aux -= this->charge->kin_r[1][ir] * v_ofk[ir];
164-
}
166+
deband_aux -= this->charge->kin_r[1][ir] * v_ofk[ir];
165167
}
166168
}
167169
}

0 commit comments

Comments
 (0)