diff --git a/source/module_io/read_input_item_elec_stru.cpp b/source/module_io/read_input_item_elec_stru.cpp index bca79a6097..196ab540ee 100644 --- a/source/module_io/read_input_item_elec_stru.cpp +++ b/source/module_io/read_input_item_elec_stru.cpp @@ -469,8 +469,7 @@ void ReadInput::item_elec_stru() GlobalV::ofs_warning << " WARNING : gamma_only has not been implemented for pw yet" << std::endl; GlobalV::ofs_warning << "gamma_only is not supported in the pw model" << std::endl; GlobalV::ofs_warning << " the INPUT parameter gamma_only has been reset to 0" << std::endl; - GlobalV::ofs_warning << " and a new KPT is generated with " - "gamma point as the only k point"<< std::endl; + GlobalV::ofs_warning << " and a new KPT is generated with gamma point as the only k point"<< std::endl; GlobalV::ofs_warning << " Auto generating k-points file: " << para.input.kpoint_file << std::endl; std::ofstream ofs(para.input.kpoint_file.c_str()); ofs << "K_POINTS" << std::endl; @@ -479,6 +478,13 @@ void ReadInput::item_elec_stru() ofs << "1 1 1 0 0 0" << std::endl; ofs.close(); } + if (para.input.basis_type == "lcao" && para.input.gamma_only) + { + if (para.input.nspin == 4) + { + ModuleBase::WARNING_QUIT("NOTICE", "nspin=4(soc or noncollinear-spin) does not support gamma only calculation"); + } + } }; this->add_item(item); } diff --git a/source/module_io/read_set_globalv.cpp b/source/module_io/read_set_globalv.cpp index b9a4dc00da..868ca02c36 100644 --- a/source/module_io/read_set_globalv.cpp +++ b/source/module_io/read_set_globalv.cpp @@ -63,6 +63,7 @@ void ReadInput::set_globalv(Parameter& para) { para.sys.deepks_setorb = true; } + /// set the noncolin and lspinorb from nspin switch (para.input.nspin) { case 4: diff --git a/source/module_io/test_serial/read_input_item_test.cpp b/source/module_io/test_serial/read_input_item_test.cpp index 9f7c6abe89..16f84911e1 100644 --- a/source/module_io/test_serial/read_input_item_test.cpp +++ b/source/module_io/test_serial/read_input_item_test.cpp @@ -820,6 +820,14 @@ TEST_F(InputTest, Item_test) ifs.close(); EXPECT_EQ(line, "K_POINTS"); + param.input.basis_type = "lcao"; + param.input.gamma_only = true; + param.input.nspin = 4; + testing::internal::CaptureStdout(); + EXPECT_EXIT(it->second.reset_value(it->second, param), ::testing::ExitedWithCode(0), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + } { // out_mat_r auto it = find_label("out_mat_r", readinput.input_lists);