Skip to content

Commit d091cad

Browse files
committed
change ucell in module_ri/rpa_lri.cpp
1 parent 0107eb5 commit d091cad

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

source/module_ri/RPA_LRI.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ template <typename T, typename Tdata> class RPA_LRI
4949
const psi::Psi<T>& psi,
5050
const elecstate::ElecState* pelec);
5151
void out_eigen_vector(const Parallel_Orbitals& parav, const psi::Psi<T>& psi);
52-
void out_struc();
52+
void out_struc(const ModuleBase::Matrix3& latvec, const ModuleBase::Matrix3& G);
5353
void out_bands(const elecstate::ElecState *pelec);
5454

55-
void out_Cs();
56-
void out_coulomb_k();
55+
void out_Cs(const UnitCell &ucell);
56+
void out_coulomb_k(const UnitCell &ucell);
5757
// void print_matrix(char *desc, const ModuleBase::matrix &mat);
5858
// void print_complex_matrix(char *desc, const ModuleBase::ComplexMatrix &mat);
5959
// void init(const MPI_Comm &mpi_comm_in);

source/module_ri/RPA_LRI.hpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ void RPA_LRI<T, Tdata>::out_for_RPA(const UnitCell& ucell,
128128
ModuleBase::TITLE("DFT_RPA_interface", "out_for_RPA");
129129
this->out_bands(pelec);
130130
this->out_eigen_vector(parav, psi);
131-
this->out_struc();
131+
this->out_struc(ucell.latvec, ucell.G);
132132

133133
this->cal_rpa_cv(ucell);
134134
std::cout << "rpa_pca_threshold: " << this->info.pca_threshold << std::endl;
135135
std::cout << "rpa_ccp_rmesh_times: " << this->info.ccp_rmesh_times << std::endl;
136136
std::cout << "rpa_lcao_exx(Ha): " << std::fixed << std::setprecision(15) << exx_lri_rpa.Eexx / 2.0 << std::endl;
137-
this->out_Cs();
138-
this->out_coulomb_k();
137+
this->out_Cs(ucell);
138+
this->out_coulomb_k(ucell);
139139

140140
std::cout << "etxc(Ha): " << std::fixed << std::setprecision(15) << pelec->f_en.etxc / 2.0 << std::endl;
141141
std::cout << "etot(Ha): " << std::fixed << std::setprecision(15) << pelec->f_en.etot / 2.0 << std::endl;
@@ -212,7 +212,7 @@ void RPA_LRI<T, Tdata>::out_eigen_vector(const Parallel_Orbitals& parav, const p
212212
}
213213

214214
template <typename T, typename Tdata>
215-
void RPA_LRI<T, Tdata>::out_struc()
215+
void RPA_LRI<T, Tdata>::out_struc(const ModuleBase::Matrix3& latvec, const ModuleBase::Matrix3& G)
216216
{
217217
if (GlobalV::MY_RANK != 0)
218218
{
@@ -221,8 +221,8 @@ void RPA_LRI<T, Tdata>::out_struc()
221221
ModuleBase::TITLE("DFT_RPA_interface", "out_struc");
222222
double TWOPI_Bohr2A = ModuleBase::TWO_PI * ModuleBase::BOHR_TO_A;
223223
const int nks_tot = PARAM.inp.nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
224-
ModuleBase::Matrix3 lat = GlobalC::ucell.latvec / ModuleBase::BOHR_TO_A;
225-
ModuleBase::Matrix3 G = GlobalC::ucell.G * TWOPI_Bohr2A;
224+
ModuleBase::Matrix3 lat = latvec / ModuleBase::BOHR_TO_A;
225+
ModuleBase::Matrix3 G_RPA = G * TWOPI_Bohr2A;
226226
std::stringstream ss;
227227
ss << "stru_out";
228228
std::ofstream ofs;
@@ -231,9 +231,9 @@ void RPA_LRI<T, Tdata>::out_struc()
231231
ofs << lat.e21 << std::setw(15) << lat.e22 << std::setw(15) << lat.e23 << std::endl;
232232
ofs << lat.e31 << std::setw(15) << lat.e32 << std::setw(15) << lat.e33 << std::endl;
233233

234-
ofs << G.e11 << std::setw(15) << G.e12 << std::setw(15) << G.e13 << std::endl;
235-
ofs << G.e21 << std::setw(15) << G.e22 << std::setw(15) << G.e23 << std::endl;
236-
ofs << G.e31 << std::setw(15) << G.e32 << std::setw(15) << G.e33 << std::endl;
234+
ofs << G_RPA.e11 << std::setw(15) << G_RPA.e12 << std::setw(15) << G_RPA.e13 << std::endl;
235+
ofs << G_RPA.e21 << std::setw(15) << G_RPA.e22 << std::setw(15) << G_RPA.e23 << std::endl;
236+
ofs << G_RPA.e31 << std::setw(15) << G_RPA.e32 << std::setw(15) << G_RPA.e33 << std::endl;
237237

238238
ofs << p_kv->nmp[0] << std::setw(6) << p_kv->nmp[1] << std::setw(6) << p_kv->nmp[2] << std::setw(6) << std::endl;
239239

@@ -286,23 +286,23 @@ void RPA_LRI<T, Tdata>::out_bands(const elecstate::ElecState* pelec)
286286
}
287287

288288
template <typename T, typename Tdata>
289-
void RPA_LRI<T, Tdata>::out_Cs()
289+
void RPA_LRI<T, Tdata>::out_Cs(const UnitCell& ucell)
290290
{
291291
std::stringstream ss;
292292
ss << "Cs_data_" << GlobalV::MY_RANK << ".txt";
293293
std::ofstream ofs;
294294
ofs.open(ss.str().c_str(), std::ios::out);
295-
ofs << GlobalC::ucell.nat << " " << 0 << std::endl;
295+
ofs << ucell.nat << " " << 0 << std::endl;
296296
for (auto& Ip: this->Cs_period)
297297
{
298298
size_t I = Ip.first;
299-
size_t i_num = GlobalC::ucell.atoms[GlobalC::ucell.iat2it[I]].nw;
299+
size_t i_num = ucell.atoms[ucell.iat2it[I]].nw;
300300
for (auto& JPp: Ip.second)
301301
{
302302
size_t J = JPp.first.first;
303303
auto R = JPp.first.second;
304304
auto& tmp_Cs = JPp.second;
305-
size_t j_num = GlobalC::ucell.atoms[GlobalC::ucell.iat2it[J]].nw;
305+
size_t j_num = ucell.atoms[ucell.iat2it[J]].nw;
306306

307307
ofs << I + 1 << " " << J + 1 << " " << R[0] << " " << R[1] << " " << R[2] << " " << i_num
308308
<< std::endl;
@@ -324,14 +324,14 @@ void RPA_LRI<T, Tdata>::out_Cs()
324324
}
325325

326326
template <typename T, typename Tdata>
327-
void RPA_LRI<T, Tdata>::out_coulomb_k()
327+
void RPA_LRI<T, Tdata>::out_coulomb_k(const UnitCell &ucell)
328328
{
329329
int all_mu = 0;
330-
vector<int> mu_shift(GlobalC::ucell.nat);
331-
for (int I = 0; I != GlobalC::ucell.nat; I++)
330+
vector<int> mu_shift(ucell.nat);
331+
for (int I = 0; I != ucell.nat; I++)
332332
{
333333
mu_shift[I] = all_mu;
334-
all_mu += exx_lri_rpa.cv.get_index_abfs_size(GlobalC::ucell.iat2it[I]);
334+
all_mu += exx_lri_rpa.cv.get_index_abfs_size(ucell.iat2it[I]);
335335
}
336336
const int nks_tot = PARAM.inp.nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
337337
std::stringstream ss;
@@ -344,7 +344,7 @@ void RPA_LRI<T, Tdata>::out_coulomb_k()
344344
for (auto& Ip: this->Vs_period)
345345
{
346346
auto I = Ip.first;
347-
size_t mu_num = exx_lri_rpa.cv.get_index_abfs_size(GlobalC::ucell.iat2it[I]);
347+
size_t mu_num = exx_lri_rpa.cv.get_index_abfs_size(ucell.iat2it[I]);
348348

349349
for (int ik = 0; ik != nks_tot; ik++)
350350
{
@@ -360,7 +360,7 @@ void RPA_LRI<T, Tdata>::out_coulomb_k()
360360
}
361361
RI::Tensor<std::complex<double>> tmp_VR = RI::Global_Func::convert<std::complex<double>>(JPp.second);
362362

363-
const double arg = 1 * (p_kv->kvec_c[ik] * (RI_Util::array3_to_Vector3(R) * GlobalC::ucell.latvec))
363+
const double arg = 1 * (p_kv->kvec_c[ik] * (RI_Util::array3_to_Vector3(R) * ucell.latvec))
364364
* ModuleBase::TWO_PI; // latvec
365365
const std::complex<double> kphase = std::complex<double>(cos(arg), sin(arg));
366366
if (Vq_k_IJ[J].empty())
@@ -373,7 +373,7 @@ void RPA_LRI<T, Tdata>::out_coulomb_k()
373373
{
374374
auto iJ = vq_Jp.first;
375375
auto& vq_J = vq_Jp.second;
376-
size_t nu_num = exx_lri_rpa.cv.get_index_abfs_size(GlobalC::ucell.iat2it[iJ]);
376+
size_t nu_num = exx_lri_rpa.cv.get_index_abfs_size(ucell.iat2it[iJ]);
377377
ofs << all_mu << " " << mu_shift[I] + 1 << " " << mu_shift[I] + mu_num << " " << mu_shift[iJ] + 1
378378
<< " " << mu_shift[iJ] + nu_num << std::endl;
379379
ofs << ik + 1 << " " << p_kv->wk[ik] / 2.0 * PARAM.inp.nspin << std::endl;

0 commit comments

Comments
 (0)