Skip to content

Commit 4f4a050

Browse files
refactor: remove the useless variables and functions in unkOverlap_lcao (#4569)
* refactor: remove the useless variables and functions in unkOverlap_lcao * remove loc in berryphase * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 88ce35c commit 4f4a050

File tree

5 files changed

+38
-300
lines changed

5 files changed

+38
-300
lines changed

source/module_esolver/esolver_ks_lcao_elec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ void ESolver_KS_LCAO<TK, TR>::nscf(void) {
723723
// add by jingan
724724
if (berryphase::berry_phase_flag
725725
&& ModuleSymmetry::Symmetry::symm_flag != 1) {
726-
berryphase bp(this->LOC);
726+
berryphase bp(this->orb_con.ParaV);
727727
bp.lcao_init(this->kv,
728728
this->GridT); // additional step before calling
729729
// macroscopic_polarization (why capitalize

source/module_io/berryphase.cpp

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ berryphase::berryphase()
1111
}
1212

1313
#ifdef __LCAO
14-
berryphase::berryphase(Local_Orbital_Charge& loc_in) : loc(&loc_in)
14+
berryphase::berryphase(const Parallel_Orbitals& paraV_in) : paraV(paraV_in)
1515
{
1616
GDIR = INPUT.gdir;
1717
}
@@ -43,7 +43,7 @@ void berryphase::get_occupation_bands()
4343
void berryphase::lcao_init(const K_Vectors& kv, const Grid_Technique& grid_tech)
4444
{
4545
ModuleBase::TITLE("berryphase", "lcao_init");
46-
lcao_method.init(grid_tech, this->loc->wfc_k_grid, kv.get_nkstot());
46+
lcao_method.init(grid_tech, kv.get_nkstot());
4747
lcao_method.cal_R_number();
4848
lcao_method.cal_orb_overlap();
4949
return;
@@ -89,8 +89,10 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)
8989
for (int ix = 0; ix < mp_x; ix++)
9090
{
9191
k_index[string_index][ix] = ix + iy * mp_x + iz * mp_x * mp_y;
92-
if (ix == (mp_x - 1))
93-
k_index[string_index][ix + 1] = k_index[string_index][0];
92+
if (ix == (mp_x - 1)) {
93+
k_index[string_index][ix + 1]
94+
= k_index[string_index][0];
95+
}
9496
}
9597
}
9698
}
@@ -137,8 +139,10 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)
137139
for (int iy = 0; iy < mp_y; iy++)
138140
{
139141
k_index[string_index][iy] = ix + iy * mp_x + iz * mp_x * mp_y;
140-
if (iy == (mp_y - 1))
141-
k_index[string_index][iy + 1] = k_index[string_index][0];
142+
if (iy == (mp_y - 1)) {
143+
k_index[string_index][iy + 1]
144+
= k_index[string_index][0];
145+
}
142146
}
143147
}
144148
}
@@ -185,8 +189,10 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)
185189
for (int iz = 0; iz < mp_z; iz++)
186190
{
187191
k_index[string_index][iz] = ix + iy * mp_x + iz * mp_x * mp_y;
188-
if (iz == (mp_z - 1))
189-
k_index[string_index][iz + 1] = k_index[string_index][0];
192+
if (iz == (mp_z - 1)) {
193+
k_index[string_index][iz + 1]
194+
= k_index[string_index][0];
195+
}
190196
}
191197
}
192198
}
@@ -303,9 +309,15 @@ double berryphase::stringPhase(int index_str,
303309
}
304310

305311
mat(nb, mb) = pw_method.unkdotp_soc_G0(rhopw, wfcpw, ik_1, ik_2, nb, mb, psi_in, G);
312+
} else {
313+
mat(nb, mb) = pw_method.unkdotp_soc_G(wfcpw,
314+
ik_1,
315+
ik_2,
316+
nb,
317+
mb,
318+
npwx,
319+
psi_in);
306320
}
307-
else
308-
mat(nb, mb) = pw_method.unkdotp_soc_G(wfcpw, ik_1, ik_2, nb, mb, npwx, psi_in);
309321
}
310322

311323
} // nb
@@ -318,10 +330,11 @@ double berryphase::stringPhase(int index_str,
318330
LapackConnector::zgetrf(nbands, nbands, mat, nbands, ipiv.data(), &info);
319331
for (int ib = 0; ib < nbands; ib++)
320332
{
321-
if (ipiv[ib] != (ib + 1))
333+
if (ipiv[ib] != (ib + 1)) {
322334
det = -det * mat(ib, ib);
323-
else
335+
} else {
324336
det = det * mat(ib, ib);
337+
}
325338
}
326339

327340
zeta = zeta * det;
@@ -334,7 +347,7 @@ double berryphase::stringPhase(int index_str,
334347
if (GlobalV::NSPIN != 4)
335348
{
336349
// std::complex<double> my_det = lcao_method.det_berryphase(ik_1,ik_2,dk,nbands);
337-
zeta = zeta * lcao_method.det_berryphase(ik_1, ik_2, dk, nbands, *this->loc->ParaV, psi_in, kv);
350+
zeta = zeta * lcao_method.det_berryphase(ik_1, ik_2, dk, nbands, this->paraV, psi_in, kv);
338351
// test by jingan
339352
// GlobalV::ofs_running << "methon 1: det = " << my_det << std::endl;
340353
// test by jingan
@@ -401,8 +414,9 @@ void berryphase::Berry_Phase(int nbands,
401414
for (int istring = 0; istring < total_string; istring++)
402415
{
403416
wistring[istring] = 1.0 / total_string;
404-
if (GlobalV::NSPIN == 2)
417+
if (GlobalV::NSPIN == 2) {
405418
wistring[istring] = wistring[istring] * 2;
419+
}
406420
}
407421

408422
for (int istring = 0; istring < total_string; istring++)
@@ -561,10 +575,11 @@ void berryphase::Macroscopic_polarization(const int npwx,
561575

562576
// calculate Macroscopic polarization modulus because berry phase
563577
int modulus = 0;
564-
if ((!lodd) && (GlobalV::NSPIN == 1))
578+
if ((!lodd) && (GlobalV::NSPIN == 1)) {
565579
modulus = 2;
566-
else
580+
} else {
567581
modulus = 1;
582+
}
568583

569584
// test by jingan
570585
// GlobalV::ofs_running << "ion polarization end" << std::endl;

source/module_io/berryphase.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
#include "module_basis/module_pw/pw_basis_k.h"
99
#include "module_cell/klist.h"
1010
#include "module_psi/psi.h"
11+
#include "module_basis/module_ao/parallel_orbitals.h"
1112

1213
class berryphase
1314
{
1415

1516
public:
1617
berryphase(); // for pw-line
1718
#ifdef __LCAO
18-
berryphase(Local_Orbital_Charge& loc_in); // for lcao-line
19+
berryphase(const Parallel_Orbitals& paraV_in); // for lcao-line
1920
#endif
2021
~berryphase();
2122

@@ -24,7 +25,7 @@ class berryphase
2425
unkOverlap_pw pw_method;
2526
#ifdef __LCAO
2627
unkOverlap_lcao lcao_method;
27-
Local_Orbital_Charge* loc;
28+
Parallel_Orbitals paraV;
2829
#endif
2930

3031
int total_string;

0 commit comments

Comments
 (0)