Skip to content

Commit 2319777

Browse files
committed
change ucell in module_io/to_wannier90.cpp
1 parent 99d62be commit 2319777

File tree

7 files changed

+35
-32
lines changed

7 files changed

+35
-32
lines changed

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep)
584584
PARAM.inp.nnkpfile,
585585
PARAM.inp.wannier_spin);
586586
wan.set_tpiba_omega(ucell.tpiba, ucell.omega);
587-
wan.calculate(this->pelec->ekb, this->pw_wfc, this->pw_big, this->kv, this->psi);
587+
wan.calculate(ucell,this->pelec->ekb, this->pw_wfc, this->pw_big, this->kv, this->psi);
588588
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Wannier functions calculation");
589589
}
590590

source/module_io/to_wannier90.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ void toWannier90::calculate()
7070
{
7171
}
7272

73-
void toWannier90::read_nnkp(const K_Vectors& kv)
73+
void toWannier90::read_nnkp(const UnitCell& ucell, const K_Vectors& kv)
7474
{
7575
// read *.nnkp file
7676
GlobalV::ofs_running << "reading the " << wannier_file_name << ".nnkp file." << std::endl;
7777

7878
bool read_success = false;
7979
if (GlobalV::MY_RANK == 0)
8080
{
81-
read_success = try_read_nnkp(kv);
81+
read_success = try_read_nnkp(ucell,kv);
8282
}
8383

8484
#ifdef __MPI
@@ -87,7 +87,7 @@ void toWannier90::read_nnkp(const K_Vectors& kv)
8787

8888
if (GlobalV::MY_RANK != 0 && read_success)
8989
{
90-
read_success = try_read_nnkp(kv);
90+
read_success = try_read_nnkp(ucell,kv);
9191
}
9292

9393
#ifdef __MPI
@@ -129,7 +129,7 @@ void toWannier90::cal_Mmn()
129129
{
130130
}
131131

132-
bool toWannier90::try_read_nnkp(const K_Vectors& kv)
132+
bool toWannier90::try_read_nnkp(const UnitCell& ucell, const K_Vectors& kv)
133133
{
134134
std::ifstream nnkp_read(nnkpfile.c_str(), std::ios::in);
135135

@@ -144,17 +144,17 @@ bool toWannier90::try_read_nnkp(const K_Vectors& kv)
144144
nnkp_read >> real_lattice_nnkp.e11 >> real_lattice_nnkp.e12 >> real_lattice_nnkp.e13 >> real_lattice_nnkp.e21
145145
>> real_lattice_nnkp.e22 >> real_lattice_nnkp.e23 >> real_lattice_nnkp.e31 >> real_lattice_nnkp.e32
146146
>> real_lattice_nnkp.e33;
147-
real_lattice_nnkp = real_lattice_nnkp / GlobalC::ucell.lat0_angstrom;
148-
149-
if (std::abs(real_lattice_nnkp.e11 - GlobalC::ucell.latvec.e11) > 1.0e-4
150-
|| std::abs(real_lattice_nnkp.e12 - GlobalC::ucell.latvec.e12) > 1.0e-4
151-
|| std::abs(real_lattice_nnkp.e13 - GlobalC::ucell.latvec.e13) > 1.0e-4
152-
|| std::abs(real_lattice_nnkp.e21 - GlobalC::ucell.latvec.e21) > 1.0e-4
153-
|| std::abs(real_lattice_nnkp.e22 - GlobalC::ucell.latvec.e22) > 1.0e-4
154-
|| std::abs(real_lattice_nnkp.e23 - GlobalC::ucell.latvec.e23) > 1.0e-4
155-
|| std::abs(real_lattice_nnkp.e31 - GlobalC::ucell.latvec.e31) > 1.0e-4
156-
|| std::abs(real_lattice_nnkp.e32 - GlobalC::ucell.latvec.e32) > 1.0e-4
157-
|| std::abs(real_lattice_nnkp.e33 - GlobalC::ucell.latvec.e33) > 1.0e-4)
147+
real_lattice_nnkp = real_lattice_nnkp / ucell.lat0_angstrom;
148+
149+
if (std::abs(real_lattice_nnkp.e11 - ucell.latvec.e11) > 1.0e-4
150+
|| std::abs(real_lattice_nnkp.e12 - ucell.latvec.e12) > 1.0e-4
151+
|| std::abs(real_lattice_nnkp.e13 - ucell.latvec.e13) > 1.0e-4
152+
|| std::abs(real_lattice_nnkp.e21 - ucell.latvec.e21) > 1.0e-4
153+
|| std::abs(real_lattice_nnkp.e22 - ucell.latvec.e22) > 1.0e-4
154+
|| std::abs(real_lattice_nnkp.e23 - ucell.latvec.e23) > 1.0e-4
155+
|| std::abs(real_lattice_nnkp.e31 - ucell.latvec.e31) > 1.0e-4
156+
|| std::abs(real_lattice_nnkp.e32 - ucell.latvec.e32) > 1.0e-4
157+
|| std::abs(real_lattice_nnkp.e33 - ucell.latvec.e33) > 1.0e-4)
158158
{
159159
ModuleBase::WARNING_QUIT("toWannier90::read_nnkp", "Error real_lattice in *.nnkp file");
160160
}
@@ -170,18 +170,18 @@ bool toWannier90::try_read_nnkp(const K_Vectors& kv)
170170
nnkp_read >> recip_lattice_nnkp.e11 >> recip_lattice_nnkp.e12 >> recip_lattice_nnkp.e13
171171
>> recip_lattice_nnkp.e21 >> recip_lattice_nnkp.e22 >> recip_lattice_nnkp.e23 >> recip_lattice_nnkp.e31
172172
>> recip_lattice_nnkp.e32 >> recip_lattice_nnkp.e33;
173-
const double tpiba_angstrom = ModuleBase::TWO_PI / GlobalC::ucell.lat0_angstrom;
173+
const double tpiba_angstrom = ModuleBase::TWO_PI / ucell.lat0_angstrom;
174174
recip_lattice_nnkp = recip_lattice_nnkp / tpiba_angstrom;
175175

176-
if (std::abs(recip_lattice_nnkp.e11 - GlobalC::ucell.G.e11) > 1.0e-4
177-
|| std::abs(recip_lattice_nnkp.e12 - GlobalC::ucell.G.e12) > 1.0e-4
178-
|| std::abs(recip_lattice_nnkp.e13 - GlobalC::ucell.G.e13) > 1.0e-4
179-
|| std::abs(recip_lattice_nnkp.e21 - GlobalC::ucell.G.e21) > 1.0e-4
180-
|| std::abs(recip_lattice_nnkp.e22 - GlobalC::ucell.G.e22) > 1.0e-4
181-
|| std::abs(recip_lattice_nnkp.e23 - GlobalC::ucell.G.e23) > 1.0e-4
182-
|| std::abs(recip_lattice_nnkp.e31 - GlobalC::ucell.G.e31) > 1.0e-4
183-
|| std::abs(recip_lattice_nnkp.e32 - GlobalC::ucell.G.e32) > 1.0e-4
184-
|| std::abs(recip_lattice_nnkp.e33 - GlobalC::ucell.G.e33) > 1.0e-4)
176+
if (std::abs(recip_lattice_nnkp.e11 - ucell.G.e11) > 1.0e-4
177+
|| std::abs(recip_lattice_nnkp.e12 - ucell.G.e12) > 1.0e-4
178+
|| std::abs(recip_lattice_nnkp.e13 - ucell.G.e13) > 1.0e-4
179+
|| std::abs(recip_lattice_nnkp.e21 - ucell.G.e21) > 1.0e-4
180+
|| std::abs(recip_lattice_nnkp.e22 - ucell.G.e22) > 1.0e-4
181+
|| std::abs(recip_lattice_nnkp.e23 - ucell.G.e23) > 1.0e-4
182+
|| std::abs(recip_lattice_nnkp.e31 - ucell.G.e31) > 1.0e-4
183+
|| std::abs(recip_lattice_nnkp.e32 - ucell.G.e32) > 1.0e-4
184+
|| std::abs(recip_lattice_nnkp.e33 - ucell.G.e33) > 1.0e-4)
185185
{
186186
ModuleBase::WARNING_QUIT("toWannier90::read_nnkp", "Error recip_lattice in *.nnkp file");
187187
}
@@ -313,7 +313,7 @@ bool toWannier90::try_read_nnkp(const K_Vectors& kv)
313313

314314
for (int i = 0; i < num_wannier; i++)
315315
{
316-
R_centre[i] = R_centre[i] * GlobalC::ucell.latvec;
316+
R_centre[i] = R_centre[i] * ucell.latvec;
317317
m[i] = m[i] - 1;
318318
}
319319

source/module_io/to_wannier90.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class toWannier90
3737
~toWannier90();
3838

3939
void calculate();
40-
void read_nnkp(const K_Vectors& kv);
40+
void read_nnkp(const UnitCell& ucell, const K_Vectors& kv);
4141

4242
void out_eig(const ModuleBase::matrix& ekb);
4343
void cal_Amn();
4444
void cal_Mmn();
4545
void out_unk();
4646

4747
protected:
48-
bool try_read_nnkp(const K_Vectors& kv);
48+
bool try_read_nnkp(const UnitCell& ucell, const K_Vectors& kv);
4949

5050
// Parameters related to k point
5151
int num_kpts;

source/module_io/to_wannier90_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void toWannier90_LCAO::calculate(const UnitCell& ucell,
4646
{
4747
this->ParaV = pv;
4848

49-
read_nnkp(kv);
49+
read_nnkp(ucell,kv);
5050

5151
if (PARAM.inp.nspin == 2)
5252
{

source/module_io/to_wannier90_lcao_in_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void toWannier90_LCAO_IN_PW::calculate(
5252
#endif
5353
this->psi_init_->tabulate();
5454
this->psi_init_->allocate(true);
55-
read_nnkp(kv);
55+
read_nnkp(ucell,kv);
5656

5757
if (PARAM.inp.nspin == 2)
5858
{

source/module_io/to_wannier90_pw.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ toWannier90_PW::~toWannier90_PW()
2828
}
2929

3030
void toWannier90_PW::calculate(
31+
const UnitCell& ucell,
3132
const ModuleBase::matrix& ekb,
3233
const ModulePW::PW_Basis_K* wfcpw,
3334
const ModulePW::PW_Basis_Big* bigpw,
3435
const K_Vectors& kv,
3536
const psi::Psi<std::complex<double>>* psi
3637
)
3738
{
38-
read_nnkp(kv);
39+
read_nnkp(ucell,kv);
3940

4041
if (PARAM.inp.nspin == 2)
4142
{

source/module_io/to_wannier90_pw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class toWannier90_PW : public toWannier90
3434
~toWannier90_PW();
3535

3636
void calculate(
37+
const UnitCell& ucell,
3738
const ModuleBase::matrix& ekb,
3839
const ModulePW::PW_Basis_K* wfcpw,
3940
const ModulePW::PW_Basis_Big* bigpw,
@@ -42,6 +43,7 @@ class toWannier90_PW : public toWannier90
4243
);
4344

4445
void calculate(
46+
const UnitCell& ucell,
4547
const ModuleBase::matrix& ekb,
4648
const ModulePW::PW_Basis_K* wfcpw,
4749
const ModulePW::PW_Basis_Big* bigpw,

0 commit comments

Comments
 (0)