diff --git a/source/module_cell/read_stru.cpp b/source/module_cell/read_stru.cpp index 51af080611..a312cba744 100644 --- a/source/module_cell/read_stru.cpp +++ b/source/module_cell/read_stru.cpp @@ -5,8 +5,8 @@ namespace unitcell { bool check_tau(const Atom* atoms, - const int ntype, - const int lat0) + const int& ntype, + const double& lat0) { ModuleBase::TITLE("UnitCell","check_tau"); ModuleBase::timer::tick("UnitCell","check_tau"); diff --git a/source/module_cell/read_stru.h b/source/module_cell/read_stru.h index 3827666966..cff2a0c331 100644 --- a/source/module_cell/read_stru.h +++ b/source/module_cell/read_stru.h @@ -6,8 +6,8 @@ namespace unitcell { bool check_tau(const Atom* atoms, - const int ntype, - const int lat0); + const int& ntype, + const double& lat0); bool read_atom_species(std::ifstream& ifa, std::ofstream& ofs_running, diff --git a/source/module_cell/test/unitcell_test.cpp b/source/module_cell/test/unitcell_test.cpp index 2a783630dc..3e93a7b44f 100644 --- a/source/module_cell/test/unitcell_test.cpp +++ b/source/module_cell/test/unitcell_test.cpp @@ -753,7 +753,7 @@ TEST_F(UcellTest, CheckDTau) } } -TEST_F(UcellTest, CheckTau) +TEST_F(UcellTest, CheckTauFalse) { UcellTestPrepare utp = UcellTestLib["C1H2-CheckTau"]; PARAM.input.relax_new = utp.relax_new; @@ -769,6 +769,33 @@ TEST_F(UcellTest, CheckTau) remove("checktau_warning"); } +TEST_F(UcellTest, CheckTauTrue) +{ + UcellTestPrepare utp = UcellTestLib["C1H2-CheckTau"]; + PARAM.input.relax_new = utp.relax_new; + ucell = utp.SetUcellInfo(); + GlobalV::ofs_warning.open("checktau_warning"); + int atom=0; + //cause the ucell->lat0 is 0.5,if the type of the check_tau has + //an int type,it will set to zero,and it will not pass the unittest + ucell->lat0=0.5; + ucell->nat=3; + for (int it=0;itntype;it++) + { + for(int ia=0; iaatoms[it].na; ++ia) + { + + for (int i=0;i<3;i++) + { + ucell->atoms[it].tau[ia][i]=((atom+i)/(ucell->nat*3.0)); + } + atom+=3; + } + } + EXPECT_EQ(unitcell::check_tau(ucell->atoms ,ucell->ntype, ucell->lat0),true); + GlobalV::ofs_warning.close(); +} + TEST_F(UcellTest, SelectiveDynamics) { UcellTestPrepare utp = UcellTestLib["C1H2-SD"];