Skip to content

Commit

Permalink
Fix: warn not to set nupdown in deltaspin calcualtion (#3765)
Browse files Browse the repository at this point in the history
* Fix: warning setting nupdown in deltaspin calcualtion

* add unit test
  • Loading branch information
hongriTianqi committed Mar 25, 2024
1 parent 6784cae commit 91ed1df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/module_io/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4287,6 +4287,10 @@ void Input::Check(void)
{
ModuleBase::WARNING_QUIT("INPUT", "sccut must > 0");
}
if (nupdown > 0.0)
{
ModuleBase::WARNING_QUIT("INPUT", "nupdown should not be set when sc_mag_switch > 0");
}
}
if(qo_switch)
{
Expand Down
7 changes: 7 additions & 0 deletions source/module_io/test/input_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,13 @@ TEST_F(InputTest, Check)
output = testing::internal::GetCapturedStdout();
EXPECT_THAT(output,testing::HasSubstr("sc_scf_nmin must >= 2"));
INPUT.sc_scf_nmin = 2;
// warning 10 of Deltaspin
INPUT.nupdown = 4;
testing::internal::CaptureStdout();
EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), "");
output = testing::internal::GetCapturedStdout();
EXPECT_THAT(output,testing::HasSubstr("nupdown should not be set when sc_mag_switch > 0"));
INPUT.nupdown = 0;
// restore to default values
INPUT.nspin = 1;
INPUT.sc_file = "none";
Expand Down

0 comments on commit 91ed1df

Please sign in to comment.