diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 3c1f4f8174..819627a311 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -74,6 +74,7 @@ - [mixing\_ndim](#mixing_ndim) - [mixing\_gg0](#mixing_gg0) - [mixing\_gg0\_mag](#mixing_gg0_mag) + - [mixing\_gg0\_min](#mixing_gg0_min) - [mixing\_tau](#mixing_tau) - [mixing\_dftu](#mixing_dftu) - [gamma\_only](#gamma_only) @@ -1009,6 +1010,12 @@ We recommend the following options: Note: we do not recommand to open Kerker preconditioner of magnetic density unless the system is too hard to converge. - **Default**: 0.0 +### mixing_gg0_min + +- **Type**: Real +- **Description**: the minimum kerker coefficient +- **Default**: 0.1 + ### mixing_tau - **Type**: Boolean diff --git a/source/module_base/global_variable.cpp b/source/module_base/global_variable.cpp index 2e51fa982c..9706e51a0d 100644 --- a/source/module_base/global_variable.cpp +++ b/source/module_base/global_variable.cpp @@ -251,6 +251,7 @@ int MIXING_NDIM = 8; double MIXING_GG0 = 1.00; double MIXING_BETA_MAG = 1.6; double MIXING_GG0_MAG = 1.00; +double MIXING_GG0_MIN = 0.1; bool MIXING_TAU = 0; //========================================================== diff --git a/source/module_base/global_variable.h b/source/module_base/global_variable.h index f8b7597993..2134eab8e6 100644 --- a/source/module_base/global_variable.h +++ b/source/module_base/global_variable.h @@ -280,6 +280,7 @@ extern double MIXING_GG0; extern bool MIXING_TAU; extern double MIXING_BETA_MAG; extern double MIXING_GG0_MAG; +extern double MIXING_GG0_MIN; //========================================================== // device flags added by denghui diff --git a/source/module_elecstate/module_charge/charge_mixing.cpp b/source/module_elecstate/module_charge/charge_mixing.cpp index 22b0040e3b..1d2029465d 100755 --- a/source/module_elecstate/module_charge/charge_mixing.cpp +++ b/source/module_elecstate/module_charge/charge_mixing.cpp @@ -37,6 +37,7 @@ void Charge_Mixing::set_mixing(const std::string& mixing_mode_in, GlobalV::ofs_running<<"mixing_type: "<< this->mixing_mode <mixing_beta <mixing_gg0 <rhodpw = rhodpw_in; } -// void Charge_Mixing::need_auto_set() -// { -// this->autoset = true; -// } - -// void Charge_Mixing::auto_set(const double& bandgap_in, const UnitCell& ucell_) -// { -// // auto set parameters once -// if (!this->autoset) -// { -// return; -// } -// else -// { -// this->autoset = false; -// } -// GlobalV::ofs_running << "--------------AUTO-SET---------------" << std::endl; -// // 0.8 for nspin=1 and 0.4 for others -// if (GlobalV::NSPIN == 1) -// { -// this->mixing->mixing_beta = this->mixing_beta = 0.8; -// GlobalV::ofs_running << " Autoset mixing_beta to " << this->mixing_beta << std::endl; -// } -// else -// { -// this->mixing->mixing_beta = this->mixing_beta = 0.4; -// GlobalV::MIXING_BETA_MAG = 4 * this->mixing_beta; -// GlobalV::ofs_running << " Autoset mixing_beta to " << this->mixing_beta << std::endl; -// GlobalV::ofs_running << " Autoset mixing_beta_mag to " << GlobalV::MIXING_BETA_MAG << std::endl; -// } -// GlobalV::MIXING_BETA = mixing_beta; - -// // auto set kerker mixing_gg0 = 1.0 as default -// this->mixing_gg0 = 1.0; -// GlobalV::ofs_running << " Autoset mixing_gg0 to " << this->mixing_gg0 << std::endl; -// if (GlobalV::NSPIN == 1) -// { -// GlobalV::MIXING_GG0_MAG = 0.0; -// GlobalV::ofs_running << " Autoset mixing_gg0_mag to " << GlobalV::MIXING_GG0_MAG << std::endl; -// } - -// GlobalV::ofs_running << "-------------------------------------" << std::endl; -// } - double Charge_Mixing::get_drho(Charge* chr, const double nelec) { ModuleBase::TITLE("Charge_Mixing", "get_drho"); @@ -657,7 +614,7 @@ void Charge_Mixing::Kerker_screen_recip(std::complex* drhog) for (int ig = 0; ig < this->rhopw->npw; ++ig) { double gg = this->rhopw->gg[ig]; - double filter_g = std::max(gg / (gg + gg0), 0.1 / this->mixing_beta); + double filter_g = std::max(gg / (gg + gg0), GlobalV::MIXING_GG0_MIN / this->mixing_beta); drhog[is * this->rhopw->npw + ig] *= filter_g; } } @@ -700,7 +657,7 @@ void Charge_Mixing::Kerker_screen_recip_new(std::complex* drhog) for (int ig = 0; ig < this->rhopw->npw; ++ig) { double gg = this->rhopw->gg[ig]; - double filter_g = std::max(gg / (gg + gg0), 0.1 / amin); + double filter_g = std::max(gg / (gg + gg0), GlobalV::MIXING_GG0_MIN / amin); drhog[is * this->rhopw->npw + ig] *= filter_g; } } @@ -756,7 +713,7 @@ void Charge_Mixing::Kerker_screen_real(double* drhor) // drhog[is * this->rhopw->npw + ig] *= 0; // continue; //} - double filter_g = std::max(gg / (gg + gg0), 0.1 / amin); + double filter_g = std::max(gg / (gg + gg0), GlobalV::MIXING_GG0_MIN / amin); drhog[is * this->rhopw->npw + ig] *= (1 - filter_g); } } @@ -794,7 +751,7 @@ void Charge_Mixing::Kerker_screen_real_test(double* drhor) for (int ig = 0; ig < this->rhopw->npw; ig++) { double gg = this->rhopw->gg[ig]; - double filter_g = std::max(gg / (gg + gg0), 0.1 / this->mixing_beta); + double filter_g = std::max(gg / (gg + gg0), GlobalV::MIXING_GG0_MIN / this->mixing_beta); drhog[ig] *= (1 - filter_g); } // inverse FT @@ -826,7 +783,7 @@ void Charge_Mixing::Kerker_screen_real_test(double* drhor) for (int ig = 0; ig < this->rhopw->npw; ig++) { double gg = this->rhopw->gg[ig]; - double filter_g = std::max(gg / (gg + gg0_mag), 0.1 / GlobalV::MIXING_BETA_MAG); + double filter_g = std::max(gg / (gg + gg0_mag), GlobalV::MIXING_GG0_MIN / GlobalV::MIXING_BETA_MAG); drhog_mag[ig] *= (1 - filter_g); } // inverse FT diff --git a/source/module_io/input.cpp b/source/module_io/input.cpp index cabfd49f0a..43d8b6e0b1 100644 --- a/source/module_io/input.cpp +++ b/source/module_io/input.cpp @@ -323,6 +323,7 @@ void Input::Default(void) mixing_gg0 = 1.00; // use Kerker defaultly mixing_beta_mag = -10.0; // only set when nspin == 2 mixing_gg0_mag = 0.0; // defaultly exclude Kerker from mixing magnetic density + mixing_gg0_min = 0.1; // defaultly minimum kerker coefficient mixing_tau = false; mixing_dftu = false; //---------------------------------------------------------- @@ -1391,6 +1392,10 @@ bool Input::Read(const std::string &fn) { read_value(ifs, mixing_gg0_mag); } + else if (strcmp("mixing_gg0_min", word) == 0) + { + read_value(ifs, mixing_gg0_min); + } else if (strcmp("mixing_tau", word) == 0) { read_bool(ifs, mixing_tau); @@ -3530,6 +3535,7 @@ void Input::Bcast() Parallel_Common::bcast_double(mixing_gg0); // mohan add 2014-09-27 Parallel_Common::bcast_double(mixing_beta_mag); Parallel_Common::bcast_double(mixing_gg0_mag); + Parallel_Common::bcast_double(mixing_gg0_min); Parallel_Common::bcast_bool(mixing_tau); Parallel_Common::bcast_bool(mixing_dftu); diff --git a/source/module_io/input.h b/source/module_io/input.h index eacb3e6683..53b914f415 100644 --- a/source/module_io/input.h +++ b/source/module_io/input.h @@ -233,6 +233,7 @@ class Input double mixing_gg0; // used in kerker method. mohan add 2014-09-27 double mixing_beta_mag; double mixing_gg0_mag; + double mixing_gg0_min; bool mixing_tau; // whether to mix tau in mgga bool mixing_dftu; //whether to mix locale in DFT+U diff --git a/source/module_io/input_conv.cpp b/source/module_io/input_conv.cpp index b36a3b6c56..73a057e171 100644 --- a/source/module_io/input_conv.cpp +++ b/source/module_io/input_conv.cpp @@ -751,6 +751,7 @@ void Input_Conv::Convert(void) GlobalV::MIXING_GG0 = INPUT.mixing_gg0; GlobalV::MIXING_BETA_MAG = INPUT.mixing_beta_mag; GlobalV::MIXING_GG0_MAG = INPUT.mixing_gg0_mag; + GlobalV::MIXING_GG0_MIN = INPUT.mixing_gg0_min; GlobalV::MIXING_TAU = INPUT.mixing_tau; ModuleBase::timer::tick("Input_Conv", "Convert"); diff --git a/source/module_io/parameter_pool.cpp b/source/module_io/parameter_pool.cpp index 9a2ff84e95..8d7d0ca1b9 100644 --- a/source/module_io/parameter_pool.cpp +++ b/source/module_io/parameter_pool.cpp @@ -839,6 +839,10 @@ bool input_parameters_set(std::map input_parameters { INPUT.mixing_gg0_mag = *static_cast(input_parameters["mixing_gg0_mag"].get()); } + else if (input_parameters.count("mixing_gg0_min") != 0) + { + INPUT.mixing_gg0_min = *static_cast(input_parameters["mixing_gg0_min"].get()); + } else if (input_parameters.count("mixing_tau") != 0) { INPUT.mixing_tau = *static_cast(input_parameters["mixing_tau"].get()); diff --git a/source/module_io/write_input.cpp b/source/module_io/write_input.cpp index 28fc01a1b9..89f94c411e 100644 --- a/source/module_io/write_input.cpp +++ b/source/module_io/write_input.cpp @@ -249,6 +249,7 @@ ModuleBase::GlobalFunc::OUTP(ofs, "out_bandgap", out_bandgap, "if true, print ou ModuleBase::GlobalFunc::OUTP(ofs, "mixing_gg0", mixing_gg0, "mixing parameter in kerker"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_beta_mag", mixing_beta_mag, "mixing parameter for magnetic density"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_gg0_mag", mixing_gg0_mag, "mixing parameter in kerker"); + ModuleBase::GlobalFunc::OUTP(ofs, "mixing_gg0_min", mixing_gg0_min, "the minimum kerker coefficient"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_tau", mixing_tau, "whether to mix tau in mGGA calculation"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_dftu", mixing_dftu, "whether to mix locale in DFT+U calculation");