@@ -118,6 +118,35 @@ TEST_F(BFGSTest, DetermineStepScaling)
118118 EXPECT_NEAR (dpos[1 ][2 ], 0.05 , 1e-12 );
119119}
120120
121+ TEST_F (BFGSTest, UpdateUsesAbsoluteDisplacementThreshold)
122+ {
123+ UnitCell ucell;
124+ ucell.ntype = 1 ;
125+ ucell.nat = 1 ;
126+ ucell.lat0 = 1.0 ;
127+ ucell.latvec .Identity ();
128+ ucell.atoms = new Atom[ucell.ntype ];
129+ ucell.atoms [0 ].na = 1 ;
130+ ucell.atoms [0 ].mbl = std::vector<ModuleBase::Vector3<int >>(1 , {1 , 1 , 1 });
131+ ucell.iat2it = new int [ucell.nat ];
132+ ucell.iat2ia = new int [ucell.nat ];
133+ ucell.iat2it [0 ] = 0 ;
134+ ucell.iat2ia [0 ] = 0 ;
135+
136+ bfgs.allocate (ucell.nat );
137+ bfgs.sign = false ;
138+ bfgs.pos_taud [0 ].x = -1.0e-6 ;
139+ bfgs.force0 = {0.0 , 0.0 , 0.0 };
140+
141+ std::vector<double > pos = {0.0 , 0.0 , 0.0 };
142+ std::vector<double > force = {1.0 , 0.0 , 0.0 };
143+ const double initial_h00 = bfgs.H [0 ][0 ];
144+
145+ bfgs.Update (pos, force, bfgs.H , ucell);
146+
147+ EXPECT_NE (bfgs.H [0 ][0 ], initial_h00);
148+ }
149+
121150// Test GetPos and GetPostaud without creating extra helper class
122151TEST_F (BFGSTest, GetPosAndPostaud)
123152{
@@ -245,4 +274,4 @@ TEST_F(BFGSTest, RelaxStepBasic)
245274 // Check that positions are updated (not equal to initial)
246275 EXPECT_NEAR (bfgs.pos [0 ][0 ], 0.0 , 1e-12 );
247276 EXPECT_NE (bfgs.pos [1 ][0 ], 1.0 );
248- }
277+ }
0 commit comments