Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/module_base/global_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

//==========================================================
Expand Down
1 change: 1 addition & 0 deletions source/module_base/global_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 6 additions & 49 deletions source/module_elecstate/module_charge/charge_mixing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void Charge_Mixing::set_mixing(const std::string& mixing_mode_in,
GlobalV::ofs_running<<"mixing_type: "<< this->mixing_mode <<std::endl;
GlobalV::ofs_running<<"mixing_beta: "<< this->mixing_beta <<std::endl;
GlobalV::ofs_running<<"mixing_gg0: "<< this->mixing_gg0 <<std::endl;
GlobalV::ofs_running<<"mixing_gg0_min: "<< GlobalV::MIXING_GG0_MIN <<std::endl;
if (GlobalV::NSPIN==2)
{
GlobalV::ofs_running<<"mixing_beta_mag: "<< GlobalV::MIXING_BETA_MAG <<std::endl;
Expand Down Expand Up @@ -98,50 +99,6 @@ void Charge_Mixing::set_rhopw(ModulePW::PW_Basis* rhopw_in, ModulePW::PW_Basis*
this->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");
Expand Down Expand Up @@ -657,7 +614,7 @@ void Charge_Mixing::Kerker_screen_recip(std::complex<double>* 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;
}
}
Expand Down Expand Up @@ -700,7 +657,7 @@ void Charge_Mixing::Kerker_screen_recip_new(std::complex<double>* 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;
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions source/module_io/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
//----------------------------------------------------------
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions source/module_io/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/module_io/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions source/module_io/parameter_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,10 @@ bool input_parameters_set(std::map<std::string, InputParameter> input_parameters
{
INPUT.mixing_gg0_mag = *static_cast<double*>(input_parameters["mixing_gg0_mag"].get());
}
else if (input_parameters.count("mixing_gg0_min") != 0)
{
INPUT.mixing_gg0_min = *static_cast<double*>(input_parameters["mixing_gg0_min"].get());
}
else if (input_parameters.count("mixing_tau") != 0)
{
INPUT.mixing_tau = *static_cast<bool*>(input_parameters["mixing_tau"].get());
Expand Down
1 change: 1 addition & 0 deletions source/module_io/write_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down