11#include " gtest/gtest.h"
2+ #include < iomanip>
23#define private public
34#include " module_parameter/parameter.h"
45#undef private
@@ -27,13 +28,13 @@ class Test_SETGRAD : public testing::Test
2728 force_in.create (nat,3 );
2829 stress_in.create (3 ,3 );
2930
30- force_in (0 ,0 ) = 1 ; force_in (0 ,1 ) = 2 ; force_in (0 ,2 )= 3 ;
31- force_in (1 ,0 ) = 4 ; force_in (1 ,1 ) = 5 ; force_in (1 ,2 )= 6 ;
32- force_in (2 ,0 ) = 7 ; force_in (2 ,1 ) = 8 ; force_in (2 ,2 )= 9 ;
31+ force_in (0 ,0 ) = 0. 1 ; force_in (0 ,1 ) = 0.1 ; force_in (0 ,2 )= 0.1 ;
32+ force_in (1 ,0 ) = 0 ; force_in (1 ,1 ) = 0.1 ; force_in (1 ,2 )= 0.1 ;
33+ force_in (2 ,0 ) = 0 ; force_in (2 ,1 ) = 0 ; force_in (2 ,2 )= 0.1 ;
3334
34- stress_in (0 ,0 ) = 1 ; stress_in (0 ,1 ) = 2 ; stress_in (0 ,2 )= 3 ;
35- stress_in (1 ,0 ) = 4 ; stress_in (1 ,1 ) = 5 ; stress_in (1 ,2 )= 6 ;
36- stress_in (2 ,0 ) = 7 ; stress_in (2 ,1 ) = 8 ; stress_in (2 ,2 )= 9 ;
35+ stress_in (0 ,0 ) = 1 ; stress_in (0 ,1 ) = 1 ; stress_in (0 ,2 )= 1 ;
36+ stress_in (1 ,0 ) = 0 ; stress_in (1 ,1 ) = 1 ; stress_in (1 ,2 )= 1 ;
37+ stress_in (2 ,0 ) = 0 ; stress_in (2 ,1 ) = 0 ; stress_in (2 ,2 )= 1 ;
3738
3839 ucell.ntype = 1 ;
3940 ucell.nat = nat;
@@ -46,6 +47,8 @@ class Test_SETGRAD : public testing::Test
4647 ucell.iat2ia = new int [nat];
4748 ucell.atoms [0 ].mbl .resize (nat);
4849 ucell.atoms [0 ].taud .resize (nat);
50+ ucell.atoms [0 ].tau .resize (nat);
51+ ucell.atoms [0 ].dis .resize (nat);
4952 ucell.lc = new int [3 ];
5053
5154 ucell.iat2it [0 ] = 0 ;
@@ -136,14 +139,25 @@ TEST_F(Test_SETGRAD, relax_new)
136139{
137140 std::vector<double > result_ref =
138141 {
139- 0 ,0 ,0.1709672056 ,0 ,0.2849453427 ,0 ,0.3989234797 ,0 ,0 ,1.005319517 ,
140- 0.01063903455 ,0.01595855183 ,0.0212780691 ,1.026597586 ,0.03191710366 ,
141- 0.03723662093 ,0.04255613821 ,1.047875655 ,1.059181731 ,0 ,0 ,0 ,1.059181731 ,
142- 0 ,0 ,0 ,1.059181731 ,1.034363264 ,0.01301504537 ,0.01952256806 ,
143- 0.02603009074 ,1.060393355 ,0.03904513611 ,0.0455526588 ,0.05206018148 ,
144- 1.086423445 ,1 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,1
142+ 0 , 0 , 0.24293434145 ,
143+ 0 , 0.242934341453 , 0 ,
144+ 0 , 0 , 0 ,
145+ // paramter for taud
146+ 1.2267616333 ,0.2267616333 ,0.22676163333 ,
147+ 0 , 1.2267616333 ,0.2267616333 ,
148+ 0 , 0 , 1.22676163333 ,
149+ // paramter for fisrt time after relaxation
150+ 1.3677603495 , 0 , 0 ,
151+ 0 , 1.36776034956 , 0 ,
152+ 0 , 0 , 1.36776034956 ,
153+ // paramter for second time after relaxation
154+ 1.3677603495 ,0.3633367476 ,0.36333674766 ,
155+ 0 , 1.3677603495 ,0.36333674766 ,
156+ 0 , 0 , 1.3677603495 ,
157+ // paramter for third time after relaxation
158+ 1 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,1
159+ // paramter for fourth time after relaxation
145160 };
146-
147161 for (int i=0 ;i<result.size ();i++)
148162 {
149163 EXPECT_NEAR (result[i],result_ref[i],1e-8 );
@@ -258,6 +272,7 @@ class Test_RELAX : public testing::Test
258272 ucell.atoms [i].mbl .resize (na);
259273 ucell.atoms [i].taud .resize (na);
260274 ucell.atoms [i].tau .resize (na);
275+ ucell.atoms [i].dis .resize (na);
261276 for (int j=0 ;j<na;j++)
262277 {
263278 ucell.atoms [i].mbl [j] = {1 ,1 ,1 };
@@ -291,7 +306,6 @@ TEST_F(Test_RELAX, relax_new)
291306 int size = 1584 ;
292307 double tmp;
293308 std::ifstream result_ref (" ./support/result_ref.txt" );
294-
295309 for (int i=0 ;i<size;i++)
296310 {
297311 result_ref >> tmp;
0 commit comments