Skip to content

Commit 59f8ddc

Browse files
committed
fix(dftu): resolve conflict between yukawa_potential and uramping
1. Add check_value callback to yukawa_potential to error out when both yukawa_potential and uramping are enabled simultaneously 2. Skip uramping_update() when Yukawa is enabled (U calculated directly from charge density every iteration) 3. Return true from u_converged() when Yukawa is enabled (U is self-consistently calculated, no ramping convergence needed)
1 parent b5ff54c commit 59f8ddc

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

source/source_io/module_parameter/read_input_item_exx_dftu.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,16 @@ void ReadInput::item_dftu()
766766
item.default_value = "False";
767767
item.unit = "";
768768
item.availability = "";
769+
item.check_value = [](const Input_Item& item, const Parameter& para) {
770+
if (!item.is_read()) { return; }
771+
if (para.inp.yukawa_potential && para.globalv.uramping > 0.01)
772+
{
773+
ModuleBase::WARNING_QUIT("ReadInput",
774+
"yukawa_potential and uramping cannot be used together. "
775+
"yukawa_potential calculates U directly from charge density every iteration, "
776+
"while uramping gradually increases U from 0. Please set only one of them.");
777+
}
778+
};
769779
read_sync_bool(input.yukawa_potential);
770780
this->add_item(item);
771781
}

source/source_lcao/module_dftu/dftu.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ void Plus_U::cal_energy_correction(const UnitCell& ucell,
393393

394394
void Plus_U::uramping_update()
395395
{
396+
// Yukawa calculates U directly every iteration, no need for ramping
397+
if (Yukawa) {
398+
return;
399+
}
396400
// if uramping < 0.1, use the original U
397401
if (this->uramping < 0.01) {
398402
return;
@@ -413,6 +417,10 @@ void Plus_U::uramping_update()
413417

414418
bool Plus_U::u_converged()
415419
{
420+
// Yukawa calculates U directly every iteration, always considered converged
421+
if (Yukawa) {
422+
return true;
423+
}
416424
for (int i = 0; i < this->U0.size(); i++)
417425
{
418426
if (this->U[i] != this->U0[i])

0 commit comments

Comments
 (0)