@@ -38,7 +38,22 @@ class IonsMoveCGTest : public ::testing::Test
3838 {
3939 // Clean up after each test
4040 }
41-
41+ void setupucell (UnitCell& ucell)
42+ {
43+ for (int it = 0 ; it < ucell.ntype ; it++)
44+ {
45+ Atom* atom = &ucell.atoms [it];
46+ for (int ia = 0 ; ia < atom->na ; ia++)
47+ {
48+ for (int ik = 0 ; ik < 3 ; ++ik)
49+ {
50+ atom->tau [ia][ik] = 1 ;
51+ atom->mbl [ia][ik] = 1 ;
52+ }
53+ }
54+ }
55+ ucell.lat .GT .Zero ();
56+ }
4257 Ions_Move_CG im_cg;
4358};
4459
@@ -82,6 +97,7 @@ TEST_F(IonsMoveCGTest, TestStartConverged)
8297 Ions_Move_Basic::istep = 1 ;
8398 Ions_Move_Basic::converged = true ;
8499 UnitCell ucell;
100+ setupucell (ucell);
85101 ModuleBase::matrix force (2 , 3 );
86102 double etot = 0.0 ;
87103
@@ -118,6 +134,7 @@ TEST_F(IonsMoveCGTest, TestStartSd)
118134 Ions_Move_Basic::relax_method = " cg_bfgs" ;
119135 Ions_Move_CG::RELAX_CG_THR = 100.0 ;
120136 UnitCell ucell;
137+ setupucell (ucell);
121138 ModuleBase::matrix force (2 , 3 );
122139 force (0 , 0 ) = 0.01 ;
123140 double etot = 0.0 ;
@@ -151,6 +168,7 @@ TEST_F(IonsMoveCGTest, TestStartTrialGoto)
151168 Ions_Move_Basic::istep = 1 ;
152169 Ions_Move_Basic::converged = false ;
153170 UnitCell ucell;
171+ setupucell (ucell);
154172 ModuleBase::matrix force (2 , 3 );
155173 force (0 , 0 ) = 0.1 ;
156174 double etot = 0.0 ;
@@ -189,6 +207,7 @@ TEST_F(IonsMoveCGTest, TestStartTrial)
189207 Ions_Move_Basic::istep = 1 ;
190208 Ions_Move_Basic::converged = false ;
191209 UnitCell ucell;
210+ setupucell (ucell);
192211 ModuleBase::matrix force (2 , 3 );
193212 force (0 , 0 ) = 0.01 ;
194213 double etot = 0.0 ;
@@ -226,6 +245,7 @@ TEST_F(IonsMoveCGTest, TestStartNoTrialGotoCase1)
226245 Ions_Move_Basic::istep = 1 ;
227246 Ions_Move_Basic::converged = false ;
228247 UnitCell ucell;
248+ setupucell (ucell);
229249 ModuleBase::matrix force (2 , 3 );
230250 force (0 , 0 ) = 0.1 ;
231251 double etot = 0.0 ;
@@ -265,6 +285,7 @@ TEST_F(IonsMoveCGTest, TestStartNoTrialGotoCase2)
265285 Ions_Move_Basic::istep = 1 ;
266286 Ions_Move_Basic::converged = false ;
267287 UnitCell ucell;
288+ setupucell (ucell);
268289 ModuleBase::matrix force (2 , 3 );
269290 force (0 , 0 ) = 0.01 ;
270291 double etot = 0.0 ;
@@ -303,6 +324,7 @@ TEST_F(IonsMoveCGTest, TestStartNoTrial)
303324 Ions_Move_Basic::istep = 1 ;
304325 Ions_Move_Basic::converged = false ;
305326 UnitCell ucell;
327+ setupucell (ucell);
306328 ModuleBase::matrix force (2 , 3 );
307329 force (0 , 0 ) = 0.01 ;
308330 double etot = 0.0 ;
0 commit comments