1+ #include < gtest/gtest.h>
2+ #include " ORB_unittest.h"
3+
4+ // Test whether the 2-center-int results
5+ // and its derivative from two clases are equal.
6+ // - ORB_gen_table::snap_psipsi(job=0) and Center2_Orb::Orb11::cal_overlap
7+ // - ORB_gen_table::snap_psipsi(job=1) and Center2_Orb::Orb11::cal_grad_overlap
8+ TEST_F (test_orb, equal_test)
9+ {
10+
11+ this ->set_center2orbs ();
12+ // equal test
13+ // orb
14+ double olm_0[1 ] = { 0 };
15+ double olm_1[3 ] = { 0 ,0 ,0 };
16+ // center2orb
17+ double clm_0 = 0 ;
18+ ModuleBase::Vector3<double > clm_1;
19+
20+ // test parameters
21+ const double rmax = 5 ; // Ry
22+ srand ((unsigned )time (NULL ));
23+ ModuleBase::Vector3<double > R1 (0 , 0 , 0 );
24+ ModuleBase::Vector3<double > R2 (randr (rmax), randr (rmax), randr (rmax));
25+ std::cout << " random R2=(" << R2.x << " ," << R2.y << " ," << R2.z << " )" << std::endl;
26+ ModuleBase::Vector3<double > dR = ModuleBase::Vector3<double >(0.001 , 0.001 , 0.001 );
27+ // 4. calculate overlap and grad_overlap by both methods
28+ int T1 = 0 ;
29+
30+ for (int T2 = 0 ;T2 < ORB.get_ntype ();++T2)
31+ {
32+ for (int L1 = 0 ;L1 < ORB.Phi [T1].getLmax ();++L1)
33+ {
34+ for (int N1 = 0 ;N1 < ORB.Phi [T1].getNchi (L1);++N1)
35+ {
36+ for (int L2 = 0 ;L2 < ORB.Phi [T2].getLmax ();++L2)
37+ {
38+ for (int N2 = 0 ;N2 < ORB.Phi [T2].getNchi (L2);++N2)
39+ {
40+ for (int m1 = 0 ;m1 < 2 * L1 + 1 ;++m1)
41+ {
42+ for (int m2 = 0 ;m2 < 2 * L2 + 1 ;++m2)
43+ {
44+ OGT.snap_psipsi (
45+ ORB, olm_0, 0 , ' S' ,
46+ R1, T1, L1, m1, N1,
47+ R2, T2, L2, m2, N2,
48+ 1 , NULL );
49+ OGT.snap_psipsi (
50+ ORB, olm_1, 1 , ' S' ,
51+ R1, T1, L1, m1, N1,
52+ R2, T2, L2, m2, N2,
53+ 1 , NULL );
54+ // std::cout << this->mock_center2_orb11[T1][T2][L1][N1][L2][N2]->cal_overlap(R1, R2, m1, m2);
55+ clm_0 =
56+ test_center2_orb11[T1][T2][L1][N1][L2][N2]->cal_overlap (R1, R2, m1, m2);
57+ clm_1 =
58+ test_center2_orb11[T1][T2][L1][N1][L2][N2]->cal_grad_overlap (R1, R2, m1, m2);
59+ EXPECT_NEAR (olm_0[0 ], clm_0, 1e-10 );
60+ EXPECT_NEAR (olm_1[0 ], clm_1.x , 1e-10 );
61+ EXPECT_NEAR (olm_1[1 ], clm_1.y , 1e-10 );
62+ EXPECT_NEAR (olm_1[2 ], clm_1.z , 1e-10 );
63+ ModuleBase::GlobalFunc::ZEROS (olm_1, 3 );
64+ }
65+ }
66+ }
67+
68+ }
69+ }
70+ }
71+ }
72+ }
0 commit comments