From ea3b23493677df2fb19e0d9591c0f0ec6aa178f8 Mon Sep 17 00:00:00 2001 From: Weiqing Zhou Date: Tue, 16 Dec 2025 11:34:37 +0800 Subject: [PATCH] add a warningquit if magnetism is larger than charge --- source/source_estate/module_charge/charge_mixing_rho.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/source_estate/module_charge/charge_mixing_rho.cpp b/source/source_estate/module_charge/charge_mixing_rho.cpp index 38cd679f94..ec95cab963 100644 --- a/source/source_estate/module_charge/charge_mixing_rho.cpp +++ b/source/source_estate/module_charge/charge_mixing_rho.cpp @@ -98,6 +98,10 @@ void Charge_Mixing::mix_rho_recip(Charge* chr) { chr->rhog[0][ig] = 0.5 * (rhog_mag[ig] + rhog_mag[ig+npw]); chr->rhog[1][ig] = 0.5 * (rhog_mag[ig] - rhog_mag[ig+npw]); + if (chr->rhog[1][ig] < 0.0) + { + ModuleBase::WARNING_QUIT("Charge_Mixing", "Magnetism is larger than Charge at some grid, please try a smaller mixing_beta_mag!"); + } } // delete delete[] rhog_mag; @@ -391,6 +395,10 @@ void Charge_Mixing::mix_rho_real(Charge* chr) { 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]); + if (chr->rho[1][ir] < 0.0) + { + ModuleBase::WARNING_QUIT("Charge_Mixing", "Magnetism is larger than Charge at some grid, please try a smaller mixing_beta_mag!"); + } } // delete delete[] rho_mag;