diff --git a/source/source_estate/module_charge/charge_mixing_rho.cpp b/source/source_estate/module_charge/charge_mixing_rho.cpp index 38cd679f94..4e7a4a970c 100644 --- a/source/source_estate/module_charge/charge_mixing_rho.cpp +++ b/source/source_estate/module_charge/charge_mixing_rho.cpp @@ -389,8 +389,8 @@ void Charge_Mixing::mix_rho_real(Charge* chr) } for (int ir = 0; ir < nrxx; ir++) { - chr->rho[0][ir] = 0.5 * (rho_mag[ir] + rho_mag[ir+nrxx]); - chr->rho[1][ir] = 0.5 * (rho_mag[ir] - rho_mag[ir+nrxx]); + chr->rho[0][ir] = std::max(0.0, 0.5 * (rho_mag[ir] + rho_mag[ir+nrxx])); + chr->rho[1][ir] = std::max(0.0, 0.5 * (rho_mag[ir] - rho_mag[ir+nrxx])); } // delete delete[] rho_mag;