From 07f9ac4818d16678913b05f1ef64df83bea3df7f Mon Sep 17 00:00:00 2001 From: Yu Liu <77716030+YuLiu98@users.noreply.github.com> Date: Tue, 18 Feb 2025 20:33:47 +0800 Subject: [PATCH] Refactor: update assignment logic of ecutwfc and ecutrho (#5907) --- docs/advanced/input_files/input-main.md | 1 + source/module_io/read_input_item_system.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index b75eb7024b..55cc64f220 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -771,6 +771,7 @@ These variables are used to control the plane wave related parameters. - **Type**: Real - **Description**: Energy cutoff for plane wave functions, the unit is **Rydberg**. Note that even for localized orbitals basis, you still need to setup an energy cutoff for this system. Because our local pseudopotential parts and the related force are calculated from plane wave basis set, etc. Also, because our orbitals are generated by matching localized orbitals to a chosen set of wave functions from a certain energy cutoff, this set of localize orbitals is most accurate under this same plane wave energy cutoff. +> `ecutwfc` and `ecutrho` can be set simultaneously. Besides, if only one parameter is set, abacus will automatically set another parameter based on the 4-time relationship. If both parameters are not set, the default values will be employed. - **Default**: 50 Ry (PW basis), 100 Ry (LCAO basis) ### ecutrho diff --git a/source/module_io/read_input_item_system.cpp b/source/module_io/read_input_item_system.cpp index bf88ee08b6..847d4b2e74 100644 --- a/source/module_io/read_input_item_system.cpp +++ b/source/module_io/read_input_item_system.cpp @@ -285,8 +285,13 @@ void ReadInput::item_system() item.annotation = "energy cutoff for wave functions"; read_sync_double(input.ecutwfc); item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.ecutwfc == 0){ // 0 means no input value - if (para.input.basis_type == "lcao") + if (para.input.ecutwfc == 0) + { // 0 means no input value + if (para.input.ecutrho > 0) + { + para.input.ecutwfc = para.input.ecutrho / 4.0; + } + else if (para.input.basis_type == "lcao") { para.input.ecutwfc = 100; } @@ -324,6 +329,10 @@ void ReadInput::item_system() { ModuleBase::WARNING_QUIT("ReadInput", "ecutrho/ecutwfc must >= 4"); } + if (para.sys.double_grid == true && para.input.basis_type == "lcao") + { + ModuleBase::WARNING_QUIT("ReadInput", "ecutrho/ecutwfc must = 4 for lcao calculation"); + } }; this->add_item(item); }