From 5ccb292b026fc11bcd276dd402437c827b825a14 Mon Sep 17 00:00:00 2001 From: jinzx10 Date: Fri, 18 Oct 2024 20:08:08 +0800 Subject: [PATCH] set two_fermi to false for nspin == 1 and add extra checks (#5305) --- source/module_io/read_input_item_elec_stru.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/module_io/read_input_item_elec_stru.cpp b/source/module_io/read_input_item_elec_stru.cpp index f7b861157e..bca79a6097 100644 --- a/source/module_io/read_input_item_elec_stru.cpp +++ b/source/module_io/read_input_item_elec_stru.cpp @@ -235,7 +235,18 @@ void ReadInput::item_elec_stru() para.input.nupdown = doublevalue; para.sys.two_fermi = true; }; - + item.reset_value = [](const Input_Item&, Parameter& para) { + if (para.input.nspin == 1) + { + para.sys.two_fermi = false; + } + }; + item.check_value = [](const Input_Item&, const Parameter& para) { + if (para.input.nspin == 1 && para.input.nupdown != 0.0) + { + ModuleBase::WARNING_QUIT("ReadInput", "nupdown mustn't have a non-zero value for spin-unpolarized calculations."); + } + }; sync_double(input.nupdown); this->add_item(item); }