@@ -17,7 +17,12 @@ K_Vectors::K_Vectors()
1717K_Vectors::~K_Vectors ()
1818{
1919}
20-
20+ UnitCell::UnitCell (){}
21+ UnitCell::~UnitCell (){}
22+ Magnetism::Magnetism (){}
23+ Magnetism::~Magnetism (){}
24+ InfoNonlocal::InfoNonlocal (){}
25+ InfoNonlocal::~InfoNonlocal (){}
2126/* **************************************************************
2227 * mock functions
2328 ****************************************************************/
@@ -89,6 +94,7 @@ class ElecStatePrintTest : public ::testing::Test
8994 std::ifstream ifs;
9095 std::ofstream ofs;
9196 K_Vectors* p_klist;
97+ UnitCell ucell;
9298 void SetUp ()
9399 {
94100 p_klist = new K_Vectors;
@@ -112,6 +118,11 @@ class ElecStatePrintTest : public ::testing::Test
112118 elecstate.wg (0 , 1 ) = 0.2 ;
113119 elecstate.wg (1 , 0 ) = 0.3 ;
114120 elecstate.wg (1 , 1 ) = 0.4 ;
121+ ucell.magnet .tot_magnetization = 1.1 ;
122+ ucell.magnet .abs_magnetization = 2.2 ;
123+ ucell.magnet .tot_magnetization_nc [0 ] = 3.3 ;
124+ ucell.magnet .tot_magnetization_nc [1 ] = 4.4 ;
125+ ucell.magnet .tot_magnetization_nc [2 ] = 5.5 ;
115126 }
116127 void TearDown ()
117128 {
@@ -247,15 +258,15 @@ TEST_F(ElecStatePrintTest, PrintEtot)
247258 for (int i = 0 ; i < vdw_methods.size (); i++)
248259 {
249260 PARAM.input .vdw_method = vdw_methods[i];
250- elecstate.print_etot (converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, false );
261+ elecstate.print_etot (ucell, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, false );
251262 }
252263 // iteration of different ks_solver
253264 std::vector<std::string> ks_solvers = {" cg" , " lapack" , " genelpa" , " dav" , " scalapack_gvx" , " cusolver" };
254265 for (int i = 0 ; i < ks_solvers.size (); i++)
255266 {
256267 elecstate::tmp_ks_solver = ks_solvers[i];
257268 testing::internal::CaptureStdout ();
258- elecstate.print_etot (converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
269+ elecstate.print_etot (ucell, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
259270 output = testing::internal::GetCapturedStdout ();
260271 if (elecstate::tmp_ks_solver == " cg" )
261272 {
@@ -323,7 +334,7 @@ TEST_F(ElecStatePrintTest, PrintEtot2)
323334 PARAM.input .basis_type = " pw" ;
324335 PARAM.input .scf_nmax = 100 ;
325336
326- elecstate.print_etot (converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
337+ elecstate.print_etot (ucell, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
327338 GlobalV::ofs_running.close ();
328339 ifs.open (" test.dat" , std::ios::in);
329340 std::string str ((std::istreambuf_iterator<char >(ifs)), std::istreambuf_iterator<char >());
@@ -359,7 +370,7 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS2)
359370 PARAM.input .out_bandgap = true ;
360371 PARAM.input .nspin = 2 ;
361372 GlobalV::MY_RANK = 0 ;
362- elecstate.print_etot (converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
373+ elecstate.print_etot (ucell, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
363374}
364375
365376TEST_F (ElecStatePrintTest, PrintEtotColorS4)
@@ -384,5 +395,5 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS4)
384395 PARAM.input .nspin = 4 ;
385396 PARAM.input .noncolin = true ;
386397 GlobalV::MY_RANK = 0 ;
387- elecstate.print_etot (converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
398+ elecstate.print_etot (ucell, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
388399}
0 commit comments