Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/module_cell/read_stru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions source/module_cell/read_stru.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 28 additions & 1 deletion source/module_cell/test/unitcell_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;it<ucell->ntype;it++)
{
for(int ia=0; ia<ucell->atoms[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"];
Expand Down
Loading