Skip to content

Commit 26bab5b

Browse files
use max(0,rho) instead of warningquit
1 parent 402ea89 commit 26bab5b

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

source/source_estate/module_charge/charge_mixing_rho.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,8 @@ void Charge_Mixing::mix_rho_recip(Charge* chr)
9696
}
9797
for (int ig = 0; ig < npw; ig++)
9898
{
99-
chr->rhog[0][ig] = 0.5 * (rhog_mag[ig] + rhog_mag[ig+npw]);
100-
chr->rhog[1][ig] = 0.5 * (rhog_mag[ig] - rhog_mag[ig+npw]);
101-
if (chr->rhog[1][ig] < 0.0)
102-
{
103-
ModuleBase::WARNING_QUIT("Charge_Mixing", "Magnetism is larger than Charge at some grid, please try a smaller mixing_beta_mag!");
104-
}
99+
chr->rhog[0][ig] = max(0.0, 0.5 * (rhog_mag[ig] + rhog_mag[ig+npw]));
100+
chr->rhog[1][ig] = max(0.0, 0.5 * (rhog_mag[ig] - rhog_mag[ig+npw]));
105101
}
106102
// delete
107103
delete[] rhog_mag;
@@ -393,12 +389,8 @@ void Charge_Mixing::mix_rho_real(Charge* chr)
393389
}
394390
for (int ir = 0; ir < nrxx; ir++)
395391
{
396-
chr->rho[0][ir] = 0.5 * (rho_mag[ir] + rho_mag[ir+nrxx]);
397-
chr->rho[1][ir] = 0.5 * (rho_mag[ir] - rho_mag[ir+nrxx]);
398-
if (chr->rho[1][ir] < 0.0)
399-
{
400-
ModuleBase::WARNING_QUIT("Charge_Mixing", "Magnetism is larger than Charge at some grid, please try a smaller mixing_beta_mag!");
401-
}
392+
chr->rho[0][ir] = max(0.0, 0.5 * (rho_mag[ir] + rho_mag[ir+nrxx]));
393+
chr->rho[1][ir] = max(0.0, 0.5 * (rho_mag[ir] - rho_mag[ir+nrxx]));
402394
}
403395
// delete
404396
delete[] rho_mag;

0 commit comments

Comments
 (0)