1010#include " source_cell/unitcell.h"
1111#include " source_cell/magnetism.h"
1212#undef private
13- #include " source_base/mathzone.h"
1413#include " source_base/parallel_global.h"
1514#include " source_base/global_variable.h"
1615#include " source_pw/module_dfpt/dfpt_pw_data.h"
1716#include " source_pw/module_pwdft/dftu_base.h"
17+ #include " dfpt_stru_fixture.h"
1818
1919// ctor/dtor stubs for the cell/spepot link closures live in the shared
2020// dfpt_test_mocks.cpp compiled into every DFPT test binary.
3535 * - per-(q, irrep) SCF ledger (B4: sunk from DFPT_IrrepData)
3636 */
3737
38- // abbreviated from module_symmetry/test/symm_test.cpp and klist_test.cpp
39- struct atomtype_
40- {
41- std::string atomname;
42- std::vector<std::vector<double >> coordinate;
43- };
44-
45- struct stru_
46- {
47- int ibrav;
48- std::string point_group; // Schoenflies symbol
49- std::string point_group_hm; // Hermann-Mauguin notation.
50- std::string space_group;
51- std::vector<double > cell;
52- std::vector<atomtype_> all_type;
53- };
54-
55- std::vector<stru_> stru_lib{stru_{1 ,
56- " O_h" ,
57- " m-3m" ,
58- " Pm-3m" ,
59- std::vector<double >{1 ., 0 ., 0 ., 0 ., 1 ., 0 ., 0 ., 0 ., 1 .},
60- std::vector<atomtype_>{atomtype_{" C" ,
61- std::vector<std::vector<double >>{
62- {0 ., 0 ., 0 .},
63- }}}}};
64-
65- class DFPT_PW_DataTest : public testing ::Test
38+ class DFPT_PW_DataTest : public DFPTStruTestFixture
6639{
6740 protected:
6841 ModuleCell::QList qlist;
@@ -72,63 +45,6 @@ class DFPT_PW_DataTest : public testing::Test
7245 std::ofstream ofs_running;
7346 std::string output;
7447
75- UnitCell ucell;
76- void construct_ucell (stru_& stru)
77- {
78- std::vector<atomtype_> coord = stru.all_type ;
79- ucell.a1 = ModuleBase::Vector3<double >(stru.cell [0 ], stru.cell [1 ], stru.cell [2 ]);
80- ucell.a2 = ModuleBase::Vector3<double >(stru.cell [3 ], stru.cell [4 ], stru.cell [5 ]);
81- ucell.a3 = ModuleBase::Vector3<double >(stru.cell [6 ], stru.cell [7 ], stru.cell [8 ]);
82- ucell.ntype = stru.all_type .size ();
83- ucell.atoms = new Atom[ucell.ntype ];
84- ucell.nat = 0 ;
85- ucell.latvec .e11 = ucell.a1 .x ;
86- ucell.latvec .e12 = ucell.a1 .y ;
87- ucell.latvec .e13 = ucell.a1 .z ;
88- ucell.latvec .e21 = ucell.a2 .x ;
89- ucell.latvec .e22 = ucell.a2 .y ;
90- ucell.latvec .e23 = ucell.a2 .z ;
91- ucell.latvec .e31 = ucell.a3 .x ;
92- ucell.latvec .e32 = ucell.a3 .y ;
93- ucell.latvec .e33 = ucell.a3 .z ;
94- ucell.GT = ucell.latvec .Inverse ();
95- ucell.G = ucell.GT .Transpose ();
96- ucell.lat0 = 1.8897261254578281 ;
97- for (int i = 0 ; i < coord.size (); i++)
98- {
99- ucell.atoms [i].label = coord[i].atomname ;
100- ucell.atoms [i].na = coord[i].coordinate .size ();
101- ucell.atoms [i].tau .resize (ucell.atoms [i].na );
102- ucell.atoms [i].taud .resize (ucell.atoms [i].na );
103- for (int j = 0 ; j < ucell.atoms [i].na ; ++j)
104- {
105- std::vector<double > this_atom = coord[i].coordinate [j];
106- ucell.atoms [i].tau [j] = ModuleBase::Vector3<double >(this_atom[0 ], this_atom[1 ], this_atom[2 ]);
107- ModuleBase::Mathzone::Cartesian_to_Direct (ucell.atoms [i].tau [j].x ,
108- ucell.atoms [i].tau [j].y ,
109- ucell.atoms [i].tau [j].z ,
110- ucell.a1 .x ,
111- ucell.a1 .y ,
112- ucell.a1 .z ,
113- ucell.a2 .x ,
114- ucell.a2 .y ,
115- ucell.a2 .z ,
116- ucell.a3 .x ,
117- ucell.a3 .y ,
118- ucell.a3 .z ,
119- ucell.atoms [i].taud [j].x ,
120- ucell.atoms [i].taud [j].y ,
121- ucell.atoms [i].taud [j].z );
122- }
123- ucell.nat += ucell.atoms [i].na ;
124- }
125- }
126-
127- void ClearUcell ()
128- {
129- delete[] ucell.atoms ;
130- }
131-
13248 // build a reduced 2x2x2 q-mesh (4 irreducible q-points for O_h)
13349 void init_qlist ()
13450 {
0 commit comments