Skip to content

Commit 6387181

Browse files
committed
change ucell in module_io/unk_overlap_lcao.cpp
1 parent 141c7ad commit 6387181

File tree

5 files changed

+97
-85
lines changed

5 files changed

+97
-85
lines changed

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,8 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12641264
{
12651265
std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Berry phase calculation");
12661266
berryphase bp(&(this->pv));
1267-
bp.lcao_init(this->kv,
1267+
bp.lcao_init(ucell,
1268+
this->kv,
12681269
this->GridT,
12691270
orb_); // additional step before calling
12701271
// macroscopic_polarization (why capitalize

source/module_io/berryphase.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ void berryphase::get_occupation_bands()
4040
}
4141

4242
#ifdef __LCAO
43-
void berryphase::lcao_init(const K_Vectors& kv, const Grid_Technique& grid_tech, const LCAO_Orbitals& orb)
43+
void berryphase::lcao_init(const UnitCell& ucell, const K_Vectors& kv, const Grid_Technique& grid_tech, const LCAO_Orbitals& orb)
4444
{
4545
ModuleBase::TITLE("berryphase", "lcao_init");
46-
lcao_method.init(grid_tech, kv.get_nkstot(), orb);
47-
lcao_method.cal_R_number();
48-
lcao_method.cal_orb_overlap();
46+
lcao_method.init(ucell,grid_tech, kv.get_nkstot(), orb);
47+
lcao_method.cal_R_number(ucell);
48+
lcao_method.cal_orb_overlap(ucell);
4949
return;
5050
}
5151
#endif
@@ -232,7 +232,8 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)
232232
}
233233

234234
#include "../module_base/complexmatrix.h"
235-
double berryphase::stringPhase(int index_str,
235+
double berryphase::stringPhase(const UnitCell& ucell,
236+
int index_str,
236237
int nbands,
237238
const int npwx,
238239
const psi::Psi<std::complex<double>>* psi_in,
@@ -347,7 +348,7 @@ double berryphase::stringPhase(int index_str,
347348
if (PARAM.inp.nspin != 4)
348349
{
349350
// std::complex<double> my_det = lcao_method.det_berryphase(ik_1,ik_2,dk,nbands);
350-
zeta = zeta * lcao_method.det_berryphase(ik_1, ik_2, dk, nbands, *(this->paraV), psi_in, kv);
351+
zeta = zeta * lcao_method.det_berryphase(ucell,ik_1, ik_2, dk, nbands, *(this->paraV), psi_in, kv);
351352
// test by jingan
352353
// GlobalV::ofs_running << "methon 1: det = " << my_det << std::endl;
353354
// test by jingan
@@ -392,7 +393,8 @@ double berryphase::stringPhase(int index_str,
392393
return log(zeta).imag();
393394
}
394395

395-
void berryphase::Berry_Phase(int nbands,
396+
void berryphase::Berry_Phase(const UnitCell& ucell,
397+
int nbands,
396398
double& pdl_elec_tot,
397399
int& mod_elec_tot,
398400
const int npwx,
@@ -421,7 +423,7 @@ void berryphase::Berry_Phase(int nbands,
421423

422424
for (int istring = 0; istring < total_string; istring++)
423425
{
424-
phik[istring] = stringPhase(istring, nbands, npwx, psi_in, rhopw, wfcpw, kv);
426+
phik[istring] = stringPhase(ucell,istring, nbands, npwx, psi_in, rhopw, wfcpw, kv);
425427
// transfer phase to complex number
426428
cphik[istring] = std::complex<double>(cos(phik[istring]), sin(phik[istring]));
427429
cave = cave + std::complex<double>(wistring[istring], 0.0) * cphik[istring];
@@ -595,7 +597,7 @@ void berryphase::Macroscopic_polarization(const UnitCell& ucell,
595597
set_kpoints(kv, direction);
596598
double pdl_elec_tot = 0.0;
597599
int mod_elec_tot = 0;
598-
Berry_Phase(occ_nbands, pdl_elec_tot, mod_elec_tot, npwx, psi_in, rhopw, wfcpw, kv);
600+
Berry_Phase(ucell,occ_nbands, pdl_elec_tot, mod_elec_tot, npwx, psi_in, rhopw, wfcpw, kv);
599601

600602
const double rmod = ucell.a1.norm() * ucell.lat0;
601603
const double unit1 = rmod;
@@ -641,7 +643,7 @@ void berryphase::Macroscopic_polarization(const UnitCell& ucell,
641643
set_kpoints(kv, direction);
642644
double pdl_elec_tot = 0.0;
643645
int mod_elec_tot = 0;
644-
Berry_Phase(occ_nbands, pdl_elec_tot, mod_elec_tot, npwx, psi_in, rhopw, wfcpw, kv);
646+
Berry_Phase(ucell,occ_nbands, pdl_elec_tot, mod_elec_tot, npwx, psi_in, rhopw, wfcpw, kv);
645647

646648
const double rmod = ucell.a2.norm() * ucell.lat0;
647649
const double unit1 = rmod;
@@ -687,7 +689,7 @@ void berryphase::Macroscopic_polarization(const UnitCell& ucell,
687689
set_kpoints(kv, direction);
688690
double pdl_elec_tot = 0.0;
689691
int mod_elec_tot = 0;
690-
Berry_Phase(occ_nbands, pdl_elec_tot, mod_elec_tot, npwx, psi_in, rhopw, wfcpw, kv);
692+
Berry_Phase(ucell,occ_nbands, pdl_elec_tot, mod_elec_tot, npwx, psi_in, rhopw, wfcpw, kv);
691693

692694
const double rmod = ucell.a3.norm() * ucell.lat0;
693695
const double unit1 = rmod;

source/module_io/berryphase.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ class berryphase
3737

3838
void get_occupation_bands();
3939
#ifdef __LCAO
40-
void lcao_init(const K_Vectors& kv, const Grid_Technique& grid_tech, const LCAO_Orbitals& orb);
40+
void lcao_init(const UnitCell& ucell, const K_Vectors& kv, const Grid_Technique& grid_tech, const LCAO_Orbitals& orb);
4141
#endif
4242
void set_kpoints(const K_Vectors& kv, const int direction);
4343

44-
double stringPhase(int index_str,
44+
double stringPhase(const UnitCell& ucell,
45+
int index_str,
4546
int nbands,
4647
const int npwx,
4748
const psi::Psi<std::complex<double>>* psi_in,
4849
const ModulePW::PW_Basis* rhopw,
4950
const ModulePW::PW_Basis_K* wfcpw,
5051
const K_Vectors& kv);
5152

52-
void Berry_Phase(int nbands,
53+
void Berry_Phase(const UnitCell& ucell,
54+
int nbands,
5355
double& pdl_elec_tot,
5456
int& mod_elec_tot,
5557
const int npwx,

0 commit comments

Comments
 (0)