@@ -38,7 +38,8 @@ toWannier90_LCAO::~toWannier90_LCAO()
3838{
3939}
4040
41- void toWannier90_LCAO::calculate (const ModuleBase::matrix& ekb,
41+ void toWannier90_LCAO::calculate (const UnitCell& ucell,
42+ const ModuleBase::matrix& ekb,
4243 const K_Vectors& kv,
4344 const psi::Psi<std::complex <double >>& psi,
4445 const Parallel_Orbitals* pv)
@@ -74,11 +75,11 @@ void toWannier90_LCAO::calculate(const ModuleBase::matrix& ekb,
7475
7576 std::map<size_t , std::map<size_t , std::map<size_t , size_t >>> temp_orb_index;
7677 int count = 0 ;
77- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
78+ for (int it = 0 ; it < ucell.ntype ; it++)
7879 {
79- for (int iL = 0 ; iL < GlobalC:: ucell.atoms [it].nwl + 1 ; iL++)
80+ for (int iL = 0 ; iL < ucell.atoms [it].nwl + 1 ; iL++)
8081 {
81- for (int iN = 0 ; iN < GlobalC:: ucell.atoms [it].l_nchi [iL]; iN++)
82+ for (int iN = 0 ; iN < ucell.atoms [it].l_nchi [iL]; iN++)
8283 {
8384 temp_orb_index[it][iL][iN] = count;
8485 count++;
@@ -87,13 +88,13 @@ void toWannier90_LCAO::calculate(const ModuleBase::matrix& ekb,
8788 }
8889
8990 int iw = 0 ;
90- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
91+ for (int it = 0 ; it < ucell.ntype ; it++)
9192 {
92- for (int ia = 0 ; ia < GlobalC:: ucell.atoms [it].na ; ia++)
93+ for (int ia = 0 ; ia < ucell.atoms [it].na ; ia++)
9394 {
94- for (int iL = 0 ; iL < GlobalC:: ucell.atoms [it].nwl + 1 ; iL++)
95+ for (int iL = 0 ; iL < ucell.atoms [it].nwl + 1 ; iL++)
9596 {
96- for (int iN = 0 ; iN < GlobalC:: ucell.atoms [it].l_nchi [iL]; iN++)
97+ for (int iN = 0 ; iN < ucell.atoms [it].l_nchi [iL]; iN++)
9798 {
9899 for (int im = 0 ; im < (2 * iL + 1 ); im++)
99100 {
@@ -111,10 +112,10 @@ void toWannier90_LCAO::calculate(const ModuleBase::matrix& ekb,
111112 }
112113 }
113114
114- initialize_orb_table ();
115+ initialize_orb_table (ucell );
115116 produce_basis_orb ();
116- set_R_coor ();
117- count_delta_k (kv);
117+ set_R_coor (ucell );
118+ count_delta_k (ucell, kv);
118119 }
119120
120121 if (out_wannier_eig)
@@ -137,16 +138,16 @@ void toWannier90_LCAO::calculate(const ModuleBase::matrix& ekb,
137138 return exp_idkr;
138139 };
139140
140- FR[i].set_parameters (fr_ptr[i], &GlobalC:: ucell, &orb_, &GlobalC::GridD, ParaV, 140 , 110 );
141+ FR[i].set_parameters (fr_ptr[i], &ucell, &orb_, &GlobalC::GridD, ParaV, 140 , 110 );
141142 FR[i].calculate_FR ();
142143 }
143144
144- cal_Mmn (kv, psi);
145+ cal_Mmn (ucell, kv, psi);
145146 }
146147
147148 if (out_wannier_amn)
148149 {
149- cal_Amn (kv, psi);
150+ cal_Amn (ucell, kv, psi);
150151 }
151152
152153 if (out_wannier_unk)
@@ -155,7 +156,7 @@ void toWannier90_LCAO::calculate(const ModuleBase::matrix& ekb,
155156 }
156157}
157158
158- void toWannier90_LCAO::cal_Mmn (const K_Vectors& kv, const psi::Psi<std::complex <double >>& psi)
159+ void toWannier90_LCAO::cal_Mmn (const UnitCell& ucell, const K_Vectors& kv, const psi::Psi<std::complex <double >>& psi)
159160{
160161 // write .mmn file
161162 std::ofstream mmn_file;
@@ -180,7 +181,7 @@ void toWannier90_LCAO::cal_Mmn(const K_Vectors& kv, const psi::Psi<std::complex<
180181
181182 int cal_ik = ik + start_k_index;
182183 int cal_ikb = ikb + start_k_index;
183- unkdotkb (kv, psi, cal_ik, cal_ikb, phase_G, Mmn);
184+ unkdotkb (ucell, kv, psi, cal_ik, cal_ikb, phase_G, Mmn);
184185
185186 if (GlobalV::MY_RANK == 0 )
186187 {
@@ -209,11 +210,11 @@ void toWannier90_LCAO::cal_Mmn(const K_Vectors& kv, const psi::Psi<std::complex<
209210}
210211}
211212
212- void toWannier90_LCAO::cal_Amn (const K_Vectors& kv, const psi::Psi<std::complex <double >>& psi)
213+ void toWannier90_LCAO::cal_Amn (const UnitCell& ucell, const K_Vectors& kv, const psi::Psi<std::complex <double >>& psi)
213214{
214215 produce_trial_in_lcao ();
215216 construct_overlap_table_project ();
216- cal_orbA_overlap_R ();
217+ cal_orbA_overlap_R (ucell );
217218
218219 // write .amn file
219220 std::ofstream Amn_file;
@@ -261,7 +262,7 @@ void toWannier90_LCAO::out_unk(const psi::Psi<std::complex<double>>& psi)
261262{
262263}
263264
264- void toWannier90_LCAO::initialize_orb_table ()
265+ void toWannier90_LCAO::initialize_orb_table (const UnitCell& ucell )
265266{
266267 int Lmax_used = 0 ;
267268 int Lmax = 0 ;
@@ -276,7 +277,7 @@ void toWannier90_LCAO::initialize_orb_table()
276277 for (int it = 0 ; it < ntype; it++)
277278 {
278279 lmax_orb = std::max (lmax_orb, orb_.Phi [it].getLmax ());
279- lmax_beta = std::max (lmax_beta, GlobalC:: ucell.infoNL .Beta [it].getLmax ());
280+ lmax_beta = std::max (lmax_beta, ucell.infoNL .Beta [it].getLmax ());
280281 }
281282 const double dr = orb_.get_dR ();
282283 const double dk = orb_.get_dk ();
@@ -302,7 +303,7 @@ void toWannier90_LCAO::initialize_orb_table()
302303#endif
303304}
304305
305- void toWannier90_LCAO::set_R_coor ()
306+ void toWannier90_LCAO::set_R_coor (const UnitCell& ucell )
306307{
307308 int R_minX = int (GlobalC::GridD.getD_minX ());
308309 int R_minY = int (GlobalC::GridD.getD_minY ());
@@ -323,14 +324,14 @@ void toWannier90_LCAO::set_R_coor()
323324 for (int iz = 0 ; iz < R_z; iz++)
324325 {
325326 ModuleBase::Vector3<double > tmpR (ix + R_minX, iy + R_minY, iz + R_minZ);
326- R_coor_car[count] = tmpR * GlobalC:: ucell.latvec ;
327+ R_coor_car[count] = tmpR * ucell.latvec ;
327328 count++;
328329 }
329330 }
330331 }
331332}
332333
333- void toWannier90_LCAO::count_delta_k (const K_Vectors& kv)
334+ void toWannier90_LCAO::count_delta_k (const UnitCell& ucell, const K_Vectors& kv)
334335{
335336 std::set<Coordinate_3D> delta_k_all_tmp;
336337 for (int ik = 0 ; ik < cal_num_kpts; ik++)
@@ -344,8 +345,8 @@ void toWannier90_LCAO::count_delta_k(const K_Vectors& kv)
344345 int cal_ikb = ikb + start_k_index;
345346
346347 ModuleBase::Vector3<double > ik_car = kv.kvec_c [ik];
347- ModuleBase::Vector3<double > ikb_car = kv.kvec_c [ikb] + G * GlobalC:: ucell.G ;
348- Abfs::Vector3_Order<double > dk = (ikb_car - ik_car) * GlobalC:: ucell.tpiba ;
348+ ModuleBase::Vector3<double > ikb_car = kv.kvec_c [ikb] + G * ucell.G ;
349+ Abfs::Vector3_Order<double > dk = (ikb_car - ik_car) * ucell.tpiba ;
349350 Coordinate_3D temp_dk (dk.x , dk.y , dk.z );
350351 delta_k_all_tmp.insert (temp_dk);
351352 }
@@ -362,7 +363,8 @@ void toWannier90_LCAO::count_delta_k(const K_Vectors& kv)
362363 }
363364}
364365
365- void toWannier90_LCAO::unkdotkb (const K_Vectors& kv,
366+ void toWannier90_LCAO::unkdotkb (const UnitCell& ucell,
367+ const K_Vectors& kv,
366368 const psi::Psi<std::complex <double >>& psi_in,
367369 const int & ik,
368370 const int & ikb,
@@ -379,8 +381,8 @@ void toWannier90_LCAO::unkdotkb(const K_Vectors& kv,
379381
380382 int R_num = R_coor_car.size ();
381383 ModuleBase::Vector3<double > ik_car = kv.kvec_c [ik];
382- ModuleBase::Vector3<double > ikb_car = kv.kvec_c [ikb] + G * GlobalC:: ucell.G ;
383- Abfs::Vector3_Order<double > dk = (ikb_car - ik_car) * GlobalC:: ucell.tpiba ;
384+ ModuleBase::Vector3<double > ikb_car = kv.kvec_c [ikb] + G * ucell.G ;
385+ Abfs::Vector3_Order<double > dk = (ikb_car - ik_car) * ucell.tpiba ;
384386 Coordinate_3D temp_dk (dk.x , dk.y , dk.z );
385387 int delta_k_index = delta_k_all_index[temp_dk];
386388
@@ -401,7 +403,7 @@ void toWannier90_LCAO::unkdotkb(const K_Vectors& kv,
401403 auto & matrix = tmp_FR_container->get_atom_pair (iap).get_HR_values (iR);
402404 const ModuleBase::Vector3<int > r_index = tmp_FR_container->get_atom_pair (iap).get_R_index (iR);
403405 ModuleBase::Vector3<double > dR
404- = ModuleBase::Vector3<double >(r_index.x , r_index.y , r_index.z ) * GlobalC:: ucell.latvec ;
406+ = ModuleBase::Vector3<double >(r_index.x , r_index.y , r_index.z ) * ucell.latvec ;
405407 double phase = ikb_car * dR * ModuleBase::TWO_PI;
406408 std::complex <double > kRn_phase = std::exp (ModuleBase::IMAG_UNIT * phase);
407409 for (int i = 0 ; i < row_size; ++i)
@@ -741,7 +743,7 @@ void toWannier90_LCAO::construct_overlap_table_project()
741743 }
742744}
743745
744- void toWannier90_LCAO::cal_orbA_overlap_R ()
746+ void toWannier90_LCAO::cal_orbA_overlap_R (const UnitCell& ucell )
745747{
746748 int row = this ->ParaV ->get_row_size ();
747749 int R_num = R_coor_car.size ();
@@ -781,8 +783,8 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
781783 {
782784 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
783785 ModuleBase::Vector3<double > orb_center
784- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
785- ModuleBase::Vector3<double > project_orb_center = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
786+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
787+ ModuleBase::Vector3<double > project_orb_center = R_centre[wannier_index] * ucell.lat0 ;
786788
787789 double overlap_o
788790 = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (orb_center,
@@ -808,8 +810,8 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
808810 {
809811 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
810812 ModuleBase::Vector3<double > orb_center
811- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
812- ModuleBase::Vector3<double > project_orb_center = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
813+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
814+ ModuleBase::Vector3<double > project_orb_center = R_centre[wannier_index] * ucell.lat0 ;
813815
814816 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
815817 orb_center,
@@ -838,9 +840,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
838840 {
839841 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
840842 ModuleBase::Vector3<double > orb_center
841- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
843+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
842844 ModuleBase::Vector3<double > project_orb_center
843- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
845+ = R_centre[wannier_index] * ucell.lat0 ;
844846
845847 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
846848 orb_center,
@@ -863,9 +865,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
863865 {
864866 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
865867 ModuleBase::Vector3<double > orb_center
866- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
868+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
867869 ModuleBase::Vector3<double > project_orb_center
868- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
870+ = R_centre[wannier_index] * ucell.lat0 ;
869871
870872 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
871873 orb_center,
@@ -906,8 +908,8 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
906908 {
907909 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
908910 ModuleBase::Vector3<double > orb_center
909- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
910- ModuleBase::Vector3<double > project_orb_center = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
911+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
912+ ModuleBase::Vector3<double > project_orb_center = R_centre[wannier_index] * ucell.lat0 ;
911913
912914 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
913915 orb_center,
@@ -947,9 +949,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
947949 {
948950 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
949951 ModuleBase::Vector3<double > orb_center
950- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
952+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
951953 ModuleBase::Vector3<double > project_orb_center
952- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
954+ = R_centre[wannier_index] * ucell.lat0 ;
953955
954956 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
955957 orb_center,
@@ -972,9 +974,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
972974 {
973975 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
974976 ModuleBase::Vector3<double > orb_center
975- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
977+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
976978 ModuleBase::Vector3<double > project_orb_center
977- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
979+ = R_centre[wannier_index] * ucell.lat0 ;
978980
979981 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
980982 orb_center,
@@ -998,9 +1000,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
9981000 {
9991001 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
10001002 ModuleBase::Vector3<double > orb_center
1001- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
1003+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
10021004 ModuleBase::Vector3<double > project_orb_center
1003- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
1005+ = R_centre[wannier_index] * ucell.lat0 ;
10041006
10051007 double overlap_pz = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index]
10061008 .at (1 )
@@ -1030,9 +1032,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
10301032 {
10311033 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
10321034 ModuleBase::Vector3<double > orb_center
1033- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
1035+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
10341036 ModuleBase::Vector3<double > project_orb_center
1035- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
1037+ = R_centre[wannier_index] * ucell.lat0 ;
10361038
10371039 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
10381040 orb_center,
@@ -1067,9 +1069,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
10671069 {
10681070 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
10691071 ModuleBase::Vector3<double > orb_center
1070- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
1072+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
10711073 ModuleBase::Vector3<double > project_orb_center
1072- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
1074+ = R_centre[wannier_index] * ucell.lat0 ;
10731075
10741076 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
10751077 orb_center,
@@ -1101,9 +1103,9 @@ void toWannier90_LCAO::cal_orbA_overlap_R()
11011103 {
11021104 ModuleBase::Vector3<double > R_car = R_coor_car[iR];
11031105 ModuleBase::Vector3<double > orb_center
1104- = (GlobalC:: ucell.atoms [it1].tau [ia1] + R_car) * GlobalC:: ucell.lat0 ;
1106+ = (ucell.atoms [it1].tau [ia1] + R_car) * ucell.lat0 ;
11051107 ModuleBase::Vector3<double > project_orb_center
1106- = R_centre[wannier_index] * GlobalC:: ucell.lat0 ;
1108+ = R_centre[wannier_index] * ucell.lat0 ;
11071109
11081110 double overlap_s = center2_orb11_A[iw2iorb[orb_index_row]][wannier_index].at (0 ).cal_overlap (
11091111 orb_center,
0 commit comments