Skip to content

Commit 20196d3

Browse files
committed
change ucell in module_io/write_wfc_r.cpp
1 parent c3f9ba9 commit 20196d3

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
780780
//! 6) Print out electronic wave functions in real space
781781
if (PARAM.inp.out_wfc_r == 1) // Peize Lin add 2021.11.21
782782
{
783-
ModuleIO::write_psi_r_1(this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv);
783+
ModuleIO::write_psi_r_1(ucell,this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv);
784784
}
785785

786786
//! 7) Use Kubo-Greenwood method to compute conductivities

source/module_io/get_wf_lcao.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void IState_Envelope::begin(const UnitCell& ucell,
239239

240240
if (out_wfc_r)
241241
{
242-
ModuleIO::write_psi_r_1(psi_g, pw_wfc, "wfc_realspace", false, kv);
242+
ModuleIO::write_psi_r_1(ucell,psi_g, pw_wfc, "wfc_realspace", false, kv);
243243
}
244244

245245
for (int is = 0; is < nspin; ++is)
@@ -388,7 +388,7 @@ void IState_Envelope::begin(const UnitCell& ucell,
388388
}
389389
if (out_wf_r)
390390
{
391-
ModuleIO::write_psi_r_1(psi_g, pw_wfc, "wfc_realspace", false, kv);
391+
ModuleIO::write_psi_r_1(ucell,psi_g, pw_wfc, "wfc_realspace", false, kv);
392392
}
393393

394394
std::cout << " Outputting real-space wave functions in cube format..." << std::endl;

source/module_io/write_wfc_r.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ namespace ModuleIO
2323
// write ||wfc_r|| for all k-points and all bands
2424
// Input: wfc_g(ik, ib, ig)
2525
// loop order is for(z){for(y){for(x)}}
26-
void write_psi_r_1(const psi::Psi<std::complex<double>>& wfc_g,
26+
void write_psi_r_1(const UnitCell& ucell,
27+
const psi::Psi<std::complex<double>>& wfc_g,
2728
const ModulePW::PW_Basis_K* wfcpw,
2829
const std::string& folder_name,
2930
const bool& square,
@@ -66,18 +67,16 @@ void write_psi_r_1(const psi::Psi<std::complex<double>>& wfc_g,
6667
wfc_imag[ir] = wfc_r[ir].imag();
6768
}
6869
}
69-
const std::string file_name = outdir + "wfc_realspace_" + ModuleBase::GlobalFunc::TO_STRING(ik_out) + "_"
70-
+ ModuleBase::GlobalFunc::TO_STRING(ib);
70+
std::string file_name_base = outdir + "wfc_realspace_" +
71+
ModuleBase::GlobalFunc::TO_STRING(ik_out) + "_" +
72+
ModuleBase::GlobalFunc::TO_STRING(ib);
73+
const std::string file_name = square ? file_name_base : file_name_base + "_imag";
7174
#ifdef __MPI
7275
// Use write_chg_r_1 to output the real and imaginary parts of the wave function to file
7376
mpi_requests.push_back({});
74-
write_chg_r_1(wfcpw, wfc_real, file_name, mpi_requests.back());
75-
if (!square)
76-
{
77-
write_chg_r_1(wfcpw, wfc_imag, file_name + "_imag", mpi_requests.back());
78-
}
77+
write_chg_r_1(ucell,wfcpw, wfc_real, file_name, mpi_requests.back());
7978
#else
80-
write_chg_r_1(wfcpw, wfc_real, file_name);
79+
write_chg_r_1(ucell,wfcpw, wfc_real, file_name);
8180
// if (!square)
8281
// write_chg_r_1(wfc_imag, file_name + "_imag", mpi_requests.back());
8382
#endif
@@ -115,14 +114,14 @@ std::vector<std::complex<double>> cal_wfc_r(const ModulePW::PW_Basis_K* wfcpw,
115114
}
116115

117116
// Input: chg_r[ir]
118-
#ifdef __MPI
119-
void write_chg_r_1(const ModulePW::PW_Basis_K* wfcpw,
117+
void write_chg_r_1(const UnitCell& ucell,
118+
const ModulePW::PW_Basis_K* wfcpw,
120119
const std::vector<double>& chg_r,
121-
const std::string& file_name,
122-
MPI_Request& mpi_request)
123-
#else
124-
void write_chg_r_1(const ModulePW::PW_Basis_K* wfcpw, const std::vector<double>& chg_r, const std::string& file_name)
125-
#endif
120+
const std::string& file_name
121+
#ifdef __MPI
122+
,MPI_Request& mpi_request
123+
#endif
124+
)
126125
{
127126
ModuleBase::timer::tick("ModuleIO", "write_chg_r_1");
128127
std::ofstream ofs;
@@ -135,32 +134,32 @@ void write_chg_r_1(const ModulePW::PW_Basis_K* wfcpw, const std::vector<double>&
135134
ofs.open(file_name);
136135

137136
ofs << "calculated by ABACUS" << std::endl;
138-
ofs << GlobalC::ucell.lat0_angstrom << std::endl;
139-
ofs << GlobalC::ucell.latvec.e11 << " " << GlobalC::ucell.latvec.e12 << " " << GlobalC::ucell.latvec.e13
137+
ofs << ucell.lat0_angstrom << std::endl;
138+
ofs << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13
140139
<< std::endl
141-
<< GlobalC::ucell.latvec.e21 << " " << GlobalC::ucell.latvec.e22 << " " << GlobalC::ucell.latvec.e23
140+
<< ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23
142141
<< std::endl
143-
<< GlobalC::ucell.latvec.e31 << " " << GlobalC::ucell.latvec.e32 << " " << GlobalC::ucell.latvec.e33
142+
<< ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33
144143
<< std::endl;
145144

146-
for (int it = 0; it < GlobalC::ucell.ntype; ++it)
145+
for (int it = 0; it < ucell.ntype; ++it)
147146
{
148-
ofs << GlobalC::ucell.atoms[it].label << "\t";
147+
ofs << ucell.atoms[it].label << "\t";
149148
}
150149
ofs << std::endl;
151-
for (int it = 0; it < GlobalC::ucell.ntype; ++it)
150+
for (int it = 0; it < ucell.ntype; ++it)
152151
{
153-
ofs << GlobalC::ucell.atoms[it].na << "\t";
152+
ofs << ucell.atoms[it].na << "\t";
154153
}
155154
ofs << std::endl;
156155

157156
ofs << "Direct" << std::endl;
158-
for (int it = 0; it < GlobalC::ucell.ntype; ++it)
157+
for (int it = 0; it < ucell.ntype; ++it)
159158
{
160-
for (int ia = 0; ia < GlobalC::ucell.atoms[it].na; ++ia)
159+
for (int ia = 0; ia < ucell.atoms[it].na; ++ia)
161160
{
162-
ofs << GlobalC::ucell.atoms[it].taud[ia].x << " " << GlobalC::ucell.atoms[it].taud[ia].y << " "
163-
<< GlobalC::ucell.atoms[it].taud[ia].z << std::endl;
161+
ofs << ucell.atoms[it].taud[ia].x << " " << ucell.atoms[it].taud[ia].y << " "
162+
<< ucell.atoms[it].taud[ia].z << std::endl;
164163
}
165164
}
166165
ofs << std::endl;

source/module_io/write_wfc_r.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ namespace ModuleIO
2525
// write ||wfc_r|| for all k-points and all bands
2626
// Input: wfc_g[ik](ib,ig)
2727
// loop order is for(z){for(y){for(x)}}
28-
void write_psi_r_1(const psi::Psi<std::complex<double>>& wfc_g,
28+
void write_psi_r_1(const UnitCell& ucell,
29+
const psi::Psi<std::complex<double>>& wfc_g,
2930
const ModulePW::PW_Basis_K* wfcpw,
3031
const std::string& folder_name,
3132
const bool& square,
@@ -39,14 +40,14 @@ std::vector<std::complex<double>> cal_wfc_r(const ModulePW::PW_Basis_K* wfcpw,
3940
const int ib);
4041

4142
// Input: chg_r[ir]
42-
#ifdef __MPI
43-
void write_chg_r_1(const ModulePW::PW_Basis_K* wfcpw,
43+
void write_chg_r_1(const UnitCell& ucell,
44+
const ModulePW::PW_Basis_K* wfcpw,
4445
const std::vector<double>& chg_r,
45-
const std::string& file_name,
46-
MPI_Request& mpi_request);
47-
#else
48-
void write_chg_r_1(const ModulePW::PW_Basis_K* wfcpw, const std::vector<double>& chg_r, const std::string& file_name);
49-
#endif
46+
const std::string& file_name
47+
#ifdef __MPI
48+
,MPI_Request& mpi_request
49+
#endif
50+
);
5051
}
5152

5253
#endif

0 commit comments

Comments
 (0)