Skip to content

Commit a41f749

Browse files
committed
change dftu_tools of ucell
1 parent 733afaa commit a41f749

File tree

3 files changed

+48
-38
lines changed

3 files changed

+48
-38
lines changed

source/module_hamilt_lcao/module_dftu/dftu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void DFTU::init(UnitCell& cell, // unitcell class
5959
{
6060
orb_cutoff_ = orb->cutoffs();
6161
}
62+
ucell = &cell;
6263
#endif
6364

6465
// needs reconstructions in future

source/module_hamilt_lcao/module_dftu/dftu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ class DFTU
300300
void set_dmr(const elecstate::DensityMatrix<std::complex<double>, double>* dm_in_dftu_cd);
301301

302302
private:
303+
const UnitCell* ucell = nullptr;
303304
const elecstate::DensityMatrix<double, double>* dm_in_dftu_d = nullptr;
304305
const elecstate::DensityMatrix<std::complex<double>, double>* dm_in_dftu_cd = nullptr;
305306
#endif

source/module_hamilt_lcao/module_dftu/dftu_tools.cpp

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,51 @@ void DFTU::cal_VU_pot_mat_complex(const int spin, const bool newlocale, std::com
1212
ModuleBase::TITLE("DFTU", "cal_VU_pot_mat_complex");
1313
ModuleBase::GlobalFunc::ZEROS(VU, this->paraV->nloc);
1414

15-
for (int it = 0; it < GlobalC::ucell.ntype; ++it)
15+
for (int it = 0; it < this->ucell->ntype; ++it)
1616
{
17-
if (PARAM.inp.orbital_corr[it] == -1) {
17+
if (PARAM.inp.orbital_corr[it] == -1)
18+
{
1819
continue;
19-
}
20-
for (int ia = 0; ia < GlobalC::ucell.atoms[it].na; ia++)
20+
}
21+
for (int ia = 0; ia < this->ucell->atoms[it].na; ia++)
2122
{
22-
const int iat = GlobalC::ucell.itia2iat(it, ia);
23-
for (int L = 0; L <= GlobalC::ucell.atoms[it].nwl; L++)
23+
const int iat = this->ucell->itia2iat(it, ia);
24+
for (int L = 0; L <= this->ucell->atoms[it].nwl; L++)
2425
{
25-
if (L != PARAM.inp.orbital_corr[it]) {
26+
if (L != PARAM.inp.orbital_corr[it])
27+
{
2628
continue;
27-
}
29+
}
2830

29-
for (int n = 0; n < GlobalC::ucell.atoms[it].l_nchi[L]; n++)
31+
for (int n = 0; n < this->ucell->atoms[it].l_nchi[L]; n++)
3032
{
31-
if (n != 0) {
33+
if (n != 0)
34+
{
3235
continue;
33-
}
36+
}
3437

3538
for (int m1 = 0; m1 < 2 * L + 1; m1++)
3639
{
3740
for (int ipol1 = 0; ipol1 < PARAM.globalv.npol; ipol1++)
3841
{
3942
const int mu = this->paraV->global2local_row(this->iatlnmipol2iwt[iat][L][n][m1][ipol1]);
40-
if (mu < 0) {
43+
if (mu < 0)
44+
{
4145
continue;
42-
}
46+
}
4347

4448
for (int m2 = 0; m2 < 2 * L + 1; m2++)
4549
{
4650
for (int ipol2 = 0; ipol2 < PARAM.globalv.npol; ipol2++)
4751
{
4852
const int nu
4953
= this->paraV->global2local_col(this->iatlnmipol2iwt[iat][L][n][m2][ipol2]);
50-
if (nu < 0) {
54+
if (nu < 0)
55+
{
5156
continue;
52-
}
53-
57+
}
5458
int m1_all = m1 + (2 * L + 1) * ipol1;
5559
int m2_all = m2 + (2 * L + 1) * ipol2;
56-
5760
double val = get_onebody_eff_pot(it, iat, L, n, spin, m1_all, m2_all, newlocale);
5861
VU[nu * this->paraV->nrow + mu] = std::complex<double>(val, 0.0);
5962
} // ipol2
@@ -73,43 +76,47 @@ void DFTU::cal_VU_pot_mat_real(const int spin, const bool newlocale, double* VU)
7376
ModuleBase::TITLE("DFTU", "cal_VU_pot_mat_real");
7477
ModuleBase::GlobalFunc::ZEROS(VU, this->paraV->nloc);
7578

76-
for (int it = 0; it < GlobalC::ucell.ntype; ++it)
79+
for (int it = 0; it < this->ucell->ntype; ++it)
7780
{
78-
if (PARAM.inp.orbital_corr[it] == -1) {
81+
if (PARAM.inp.orbital_corr[it] == -1)
82+
{
7983
continue;
80-
}
81-
for (int ia = 0; ia < GlobalC::ucell.atoms[it].na; ia++)
84+
}
85+
for (int ia = 0; ia < this->ucell->atoms[it].na; ia++)
8286
{
83-
const int iat = GlobalC::ucell.itia2iat(it, ia);
84-
for (int L = 0; L <= GlobalC::ucell.atoms[it].nwl; L++)
87+
const int iat = this->ucell->itia2iat(it, ia);
88+
for (int L = 0; L <= this->ucell->atoms[it].nwl; L++)
8589
{
86-
if (L != PARAM.inp.orbital_corr[it]) {
90+
if (L != PARAM.inp.orbital_corr[it])
91+
{
8792
continue;
88-
}
93+
}
8994

90-
for (int n = 0; n < GlobalC::ucell.atoms[it].l_nchi[L]; n++)
95+
for (int n = 0; n < this->ucell->atoms[it].l_nchi[L]; n++)
9196
{
92-
if (n != 0) {
97+
if (n != 0)
98+
{
9399
continue;
94-
}
95-
100+
}
96101
for (int m1 = 0; m1 < 2 * L + 1; m1++)
97102
{
98103
for (int ipol1 = 0; ipol1 < PARAM.globalv.npol; ipol1++)
99104
{
100105
const int mu = this->paraV->global2local_row(this->iatlnmipol2iwt[iat][L][n][m1][ipol1]);
101-
if (mu < 0) {
106+
if (mu < 0)
107+
{
102108
continue;
103-
}
109+
}
104110
for (int m2 = 0; m2 < 2 * L + 1; m2++)
105111
{
106112
for (int ipol2 = 0; ipol2 < PARAM.globalv.npol; ipol2++)
107113
{
108114
const int nu
109115
= this->paraV->global2local_col(this->iatlnmipol2iwt[iat][L][n][m2][ipol2]);
110-
if (nu < 0) {
116+
if (nu < 0)
117+
{
111118
continue;
112-
}
119+
}
113120

114121
int m1_all = m1 + (2 * L + 1) * ipol1;
115122
int m2_all = m2 + (2 * L + 1) * ipol2;
@@ -157,20 +164,21 @@ double DFTU::get_onebody_eff_pot(const int T,
157164
{
158165
if (Yukawa)
159166
{
160-
if (m0 == m1) {
167+
if (m0 == m1)
168+
{
161169
VU = (this->U_Yukawa[T][L][N] - this->J_Yukawa[T][L][N])
162170
* (0.5 - this->locale[iat][L][N][spin](m0, m1));
163171
} else {
164172
VU = -(this->U_Yukawa[T][L][N] - this->J_Yukawa[T][L][N]) * this->locale[iat][L][N][spin](m0, m1);
165-
}
173+
}
166174
}
167175
else
168176
{
169177
if (m0 == m1) {
170178
VU = (this->U[T]) * (0.5 - this->locale[iat][L][N][spin](m0, m1));
171179
} else {
172180
VU = -(this->U[T]) * this->locale[iat][L][N][spin](m0, m1);
173-
}
181+
}
174182
}
175183
}
176184
else
@@ -183,15 +191,15 @@ double DFTU::get_onebody_eff_pot(const int T,
183191
} else {
184192
VU = -(this->U_Yukawa[T][L][N] - this->J_Yukawa[T][L][N])
185193
* this->locale_save[iat][L][N][spin](m0, m1);
186-
}
194+
}
187195
}
188196
else
189197
{
190198
if (m0 == m1) {
191199
VU = (this->U[T]) * (0.5 - this->locale_save[iat][L][N][spin](m0, m1));
192200
} else {
193201
VU = -(this->U[T]) * this->locale_save[iat][L][N][spin](m0, m1);
194-
}
202+
}
195203
}
196204
}
197205

0 commit comments

Comments
 (0)