Skip to content

Commit 55c5afb

Browse files
A-006mohanchen
andauthored
change the gamma_only_lcao when nspin=4 (#5322)
Co-authored-by: Mohan Chen <[email protected]>
1 parent f039250 commit 55c5afb

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

source/module_io/read_input_item_elec_stru.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,7 @@ void ReadInput::item_elec_stru()
469469
GlobalV::ofs_warning << " WARNING : gamma_only has not been implemented for pw yet" << std::endl;
470470
GlobalV::ofs_warning << "gamma_only is not supported in the pw model" << std::endl;
471471
GlobalV::ofs_warning << " the INPUT parameter gamma_only has been reset to 0" << std::endl;
472-
GlobalV::ofs_warning << " and a new KPT is generated with "
473-
"gamma point as the only k point"<< std::endl;
472+
GlobalV::ofs_warning << " and a new KPT is generated with gamma point as the only k point"<< std::endl;
474473
GlobalV::ofs_warning << " Auto generating k-points file: " << para.input.kpoint_file << std::endl;
475474
std::ofstream ofs(para.input.kpoint_file.c_str());
476475
ofs << "K_POINTS" << std::endl;
@@ -479,6 +478,13 @@ void ReadInput::item_elec_stru()
479478
ofs << "1 1 1 0 0 0" << std::endl;
480479
ofs.close();
481480
}
481+
if (para.input.basis_type == "lcao" && para.input.gamma_only)
482+
{
483+
if (para.input.nspin == 4)
484+
{
485+
ModuleBase::WARNING_QUIT("NOTICE", "nspin=4(soc or noncollinear-spin) does not support gamma only calculation");
486+
}
487+
}
482488
};
483489
this->add_item(item);
484490
}

source/module_io/read_set_globalv.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void ReadInput::set_globalv(Parameter& para)
6363
{
6464
para.sys.deepks_setorb = true;
6565
}
66+
/// set the noncolin and lspinorb from nspin
6667
switch (para.input.nspin)
6768
{
6869
case 4:

source/module_io/test_serial/read_input_item_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,14 @@ TEST_F(InputTest, Item_test)
820820
ifs.close();
821821
EXPECT_EQ(line, "K_POINTS");
822822

823+
param.input.basis_type = "lcao";
824+
param.input.gamma_only = true;
825+
param.input.nspin = 4;
826+
testing::internal::CaptureStdout();
827+
EXPECT_EXIT(it->second.reset_value(it->second, param), ::testing::ExitedWithCode(0), "");
828+
output = testing::internal::GetCapturedStdout();
829+
EXPECT_THAT(output, testing::HasSubstr("NOTICE"));
830+
823831
}
824832
{ // out_mat_r
825833
auto it = find_label("out_mat_r", readinput.input_lists);

0 commit comments

Comments
 (0)