Skip to content

Commit 6a40086

Browse files
committed
change ucell in dftu/tools
1 parent 7d49925 commit 6a40086

File tree

12 files changed

+81
-50
lines changed

12 files changed

+81
-50
lines changed

source/module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
223223
dftu = new OperatorDFTU<OperatorLCAO<TK, TR>>(this->hsk,
224224
kv->kvec_d,
225225
this->hR, // no explicit call yet
226+
ucell,
226227
this->kv->isk);
227228
}
228229
else
@@ -365,6 +366,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
365366
dftu = new OperatorDFTU<OperatorLCAO<TK, TR>>(this->hsk,
366367
kv->kvec_d,
367368
this->hR, // no explicit call yet
369+
ucell,
368370
this->kv->isk);
369371
}
370372
else

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_dftu_lcao.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void OperatorDFTU<OperatorLCAO<double, double>>::contributeHk(int ik)
2727
ModuleBase::timer::tick("OperatorDFTU", "contributeHk");
2828
// Effective potential of DFT+U is added to total Hamiltonian here; Quxin adds on 20201029
2929
std::vector<double> eff_pot(this->hsk->get_pv()->nloc);
30-
GlobalC::dftu.cal_eff_pot_mat_real(ik, &eff_pot[0], isk, this->hsk->get_sk());
30+
GlobalC::dftu.cal_eff_pot_mat_real(ik, ucell, &eff_pot[0], isk, this->hsk->get_sk());
3131
double* hk = this->hsk->get_hk();
3232

3333
for (int irc = 0; irc < this->hsk->get_pv()->nloc; irc++)
@@ -45,7 +45,7 @@ void OperatorDFTU<OperatorLCAO<std::complex<double>, double>>::contributeHk(int
4545
ModuleBase::timer::tick("OperatorDFTU", "contributeHk");
4646
// Effective potential of DFT+U is added to total Hamiltonian here; Quxin adds on 20201029
4747
std::vector<std::complex<double>> eff_pot(this->hsk->get_pv()->nloc);
48-
GlobalC::dftu.cal_eff_pot_mat_complex(ik, &eff_pot[0], isk, this->hsk->get_sk());
48+
GlobalC::dftu.cal_eff_pot_mat_complex(ik, ucell,&eff_pot[0], isk, this->hsk->get_sk());
4949
std::complex<double>* hk = this->hsk->get_hk();
5050

5151
for (int irc = 0; irc < this->hsk->get_pv()->nloc; irc++)
@@ -63,7 +63,7 @@ void OperatorDFTU<OperatorLCAO<std::complex<double>, std::complex<double>>>::con
6363
ModuleBase::timer::tick("OperatorDFTU", "contributeHk");
6464
// Effective potential of DFT+U is added to total Hamiltonian here; Quxin adds on 20201029
6565
std::vector<std::complex<double>> eff_pot(this->hsk->get_pv()->nloc);
66-
GlobalC::dftu.cal_eff_pot_mat_complex(ik, &eff_pot[0], isk, this->hsk->get_sk());
66+
GlobalC::dftu.cal_eff_pot_mat_complex(ik, ucell,&eff_pot[0], isk, this->hsk->get_sk());
6767

6868
std::complex<double>* hk = this->hsk->get_hk();
6969
for (int irc = 0; irc < this->hsk->get_pv()->nloc; irc++)

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_dftu_lcao.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ class OperatorDFTU<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
2323
OperatorDFTU<OperatorLCAO<TK, TR>>(HS_Matrix_K<TK>* hsk_in,
2424
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
2525
hamilt::HContainer<TR>* hR_in,
26+
const UnitCell& ucell_in,
2627
const std::vector<int>& isk_in)
27-
: isk(isk_in), OperatorLCAO<TK, TR>(hsk_in, kvec_d_in, hR_in)
28+
: ucell(ucell_in),isk(isk_in), OperatorLCAO<TK, TR>(hsk_in, kvec_d_in, hR_in)
2829
{
2930
this->cal_type = calculation_type::lcao_dftu;
3031
}
@@ -35,6 +36,8 @@ class OperatorDFTU<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
3536

3637
private:
3738

39+
const UnitCell& ucell;
40+
3841
bool HR_fixed_done = false;
3942

4043
const std::vector<int>& isk;

source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ void sparse_format::cal_HSR(const UnitCell& ucell,
7777
if (PARAM.inp.dft_plus_u == 2) {
7878
if (nspin == 1 || nspin == 2) {
7979
cal_HR_dftu(pv,
80+
ucell,
8081
HS_Arrays.all_R_coor,
8182
HS_Arrays.SR_sparse,
8283
HS_Arrays.HR_sparse,
8384
current_spin,
8485
sparse_thr);
8586
} else if (nspin == 4) {
8687
cal_HR_dftu_soc(pv,
88+
ucell,
8789
HS_Arrays.all_R_coor,
8890
HS_Arrays.SR_soc_sparse,
8991
HS_Arrays.HR_soc_sparse,

source/module_hamilt_lcao/hamilt_lcaodft/spar_u.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
void sparse_format::cal_HR_dftu(
99
const Parallel_Orbitals &pv,
10+
const UnitCell& ucell,
1011
std::set<Abfs::Vector3_Order<int>> &all_R_coor,
1112
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, double>>> &SR_sparse,
1213
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, double>>> *HR_sparse,
@@ -74,7 +75,7 @@ void sparse_format::cal_HR_dftu(
7475
}
7576
}
7677

77-
GlobalC::dftu.cal_eff_pot_mat_R_double(current_spin, SR_tmp, HR_tmp);
78+
GlobalC::dftu.cal_eff_pot_mat_R_double(current_spin, ucell,SR_tmp, HR_tmp);
7879

7980
for (int i = 0; i < PARAM.globalv.nlocal; ++i)
8081
{
@@ -129,6 +130,7 @@ void sparse_format::cal_HR_dftu(
129130

130131
void sparse_format::cal_HR_dftu_soc(
131132
const Parallel_Orbitals &pv,
133+
const UnitCell &ucell,
132134
std::set<Abfs::Vector3_Order<int>> &all_R_coor,
133135
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, std::complex<double>>>> &SR_soc_sparse,
134136
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, std::complex<double>>>> &HR_soc_sparse,
@@ -194,7 +196,7 @@ void sparse_format::cal_HR_dftu_soc(
194196
}
195197
}
196198

197-
GlobalC::dftu.cal_eff_pot_mat_R_complex_double(current_spin, SR_soc_tmp, HR_soc_tmp);
199+
GlobalC::dftu.cal_eff_pot_mat_R_complex_double(current_spin, ucell, SR_soc_tmp, HR_soc_tmp);
198200

199201
for (int i = 0; i < PARAM.globalv.nlocal; ++i)
200202
{

source/module_hamilt_lcao/hamilt_lcaodft/spar_u.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace sparse_format
1212

1313
void cal_HR_dftu(
1414
const Parallel_Orbitals &pv,
15+
const UnitCell &ucell,
1516
std::set<Abfs::Vector3_Order<int>> &all_R_coor,
1617
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, double>>> &SR_sparse,
1718
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, double>>> *HR_sparse,
@@ -20,6 +21,7 @@ namespace sparse_format
2021

2122
void cal_HR_dftu_soc(
2223
const Parallel_Orbitals &pv,
24+
const UnitCell &ucell,
2325
std::set<Abfs::Vector3_Order<int>> &all_R_coor,
2426
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, std::complex<double>>>> &SR_soc_sparse,
2527
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, std::complex<double>>>> &HR_soc_sparse,

source/module_hamilt_lcao/module_dftu/dftu.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ class DFTU
7777
// For calculating contribution to Hamiltonian matrices
7878
//=============================================================
7979
public:
80-
void cal_eff_pot_mat_complex(const int ik, std::complex<double>* eff_pot, const std::vector<int>& isk, const std::complex<double>* sk);
81-
void cal_eff_pot_mat_real(const int ik, double* eff_pot, const std::vector<int>& isk, const double* sk);
82-
void cal_eff_pot_mat_R_double(const int ispin, double* SR, double* HR);
83-
void cal_eff_pot_mat_R_complex_double(const int ispin, std::complex<double>* SR, std::complex<double>* HR);
80+
void cal_eff_pot_mat_complex(const int ik, const UnitCell& ucell, std::complex<double>* eff_pot, const std::vector<int>& isk, const std::complex<double>* sk);
81+
void cal_eff_pot_mat_real(const int ik, const UnitCell& ucell, double* eff_pot, const std::vector<int>& isk, const double* sk);
82+
void cal_eff_pot_mat_R_double(const int ispin,const UnitCell& ucell, double* SR, double* HR);
83+
void cal_eff_pot_mat_R_complex_double(const int ispin, const UnitCell& ucell, std::complex<double>* SR, std::complex<double>* HR);
8484

8585
//=============================================================
8686
// In dftu_occup.cpp
@@ -122,8 +122,14 @@ class DFTU
122122
// for both Hamiltonian and force/stress
123123
//=============================================================
124124

125-
void cal_VU_pot_mat_complex(const int spin, const bool newlocale, std::complex<double>* VU);
126-
void cal_VU_pot_mat_real(const int spin, const bool newlocale, double* VU);
125+
void cal_VU_pot_mat_complex(const int spin,
126+
const bool newlocale,
127+
const UnitCell& ucell,
128+
std::complex<double>* VU);
129+
void cal_VU_pot_mat_real(const int spin,
130+
const bool newlocale,
131+
const UnitCell& ucell,
132+
double* VU);
127133

128134
double get_onebody_eff_pot(const int T,
129135
const int iat,

source/module_hamilt_lcao/module_dftu/dftu_force.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void DFTU::force_stress(const UnitCell& ucell,
110110

111111
double* VU = new double[pv.nloc];
112112

113-
this->cal_VU_pot_mat_real(spin, false, VU);
113+
this->cal_VU_pot_mat_real(spin, false, ucell, VU);
114114

115115
const std::vector<std::vector<double>>& dmk
116116
= dynamic_cast<const elecstate::ElecStateLCAO<double>*>(pelec)->get_DM()->get_DMK_vector();
@@ -174,7 +174,7 @@ void DFTU::force_stress(const UnitCell& ucell,
174174

175175
std::complex<double>* VU = new std::complex<double>[pv.nloc];
176176

177-
this->cal_VU_pot_mat_complex(spin, false, VU);
177+
this->cal_VU_pot_mat_complex(spin, false, ucell, VU);
178178

179179
const std::vector<std::vector<std::complex<double>>>& dmk
180180
= dynamic_cast<const elecstate::ElecStateLCAO<std::complex<double>>*>(pelec)

source/module_hamilt_lcao/module_dftu/dftu_hamilt.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
namespace ModuleDFTU
88
{
99

10-
void DFTU::cal_eff_pot_mat_complex(const int ik, std::complex<double>* eff_pot, const std::vector<int>& isk, const std::complex<double>* sk)
10+
void DFTU::cal_eff_pot_mat_complex(const int ik,
11+
const UnitCell& ucell,
12+
std::complex<double>* eff_pot,
13+
const std::vector<int>& isk,
14+
const std::complex<double>* sk)
1115
{
1216
ModuleBase::TITLE("DFTU", "cal_eff_pot_mat");
1317
ModuleBase::timer::tick("DFTU", "cal_eff_pot_mat");
@@ -31,7 +35,7 @@ void DFTU::cal_eff_pot_mat_complex(const int ik, std::complex<double>* eff_pot,
3135
const std::complex<double> zero = 0.0;
3236

3337
std::vector<std::complex<double>> VU(this->paraV->nloc);
34-
this->cal_VU_pot_mat_complex(spin, true, &VU[0]);
38+
this->cal_VU_pot_mat_complex(spin, true, ucell,&VU[0]);
3539

3640
#ifdef __MPI
3741
pzgemm_(&transN, &transN,
@@ -58,7 +62,11 @@ void DFTU::cal_eff_pot_mat_complex(const int ik, std::complex<double>* eff_pot,
5862
return;
5963
}
6064

61-
void DFTU::cal_eff_pot_mat_real(const int ik, double* eff_pot, const std::vector<int>& isk, const double* sk)
65+
void DFTU::cal_eff_pot_mat_real(const int ik,
66+
const UnitCell& ucell,
67+
double* eff_pot,
68+
const std::vector<int>& isk,
69+
const double* sk)
6270
{
6371
ModuleBase::TITLE("DFTU", "cal_eff_pot_mat");
6472
ModuleBase::timer::tick("DFTU", "cal_eff_pot_mat");
@@ -80,7 +88,7 @@ void DFTU::cal_eff_pot_mat_real(const int ik, double* eff_pot, const std::vector
8088
double alpha = 1.0, beta = 0.0, half = 0.5, one = 1.0;
8189

8290
std::vector<double> VU(this->paraV->nloc);
83-
this->cal_VU_pot_mat_real(spin, 1, &VU[0]);
91+
this->cal_VU_pot_mat_real(spin, 1, ucell, &VU[0]);
8492

8593
#ifdef __MPI
8694
pdgemm_(&transN, &transN,
@@ -107,14 +115,14 @@ void DFTU::cal_eff_pot_mat_real(const int ik, double* eff_pot, const std::vector
107115
return;
108116
}
109117

110-
void DFTU::cal_eff_pot_mat_R_double(const int ispin, double* SR, double* HR)
118+
void DFTU::cal_eff_pot_mat_R_double(const int ispin, const UnitCell& ucell,double* SR, double* HR)
111119
{
112120
const char transN = 'N', transT = 'T';
113121
const int one_int = 1;
114122
const double alpha = 1.0, beta = 0.0, one = 1.0, half = 0.5;
115123

116124
std::vector<double> VU(this->paraV->nloc);
117-
this->cal_VU_pot_mat_real(ispin, 1, &VU[0]);
125+
this->cal_VU_pot_mat_real(ispin, 1, ucell, &VU[0]);
118126

119127
#ifdef __MPI
120128
pdgemm_(&transN, &transN,
@@ -137,14 +145,14 @@ void DFTU::cal_eff_pot_mat_R_double(const int ispin, double* SR, double* HR)
137145
return;
138146
}
139147

140-
void DFTU::cal_eff_pot_mat_R_complex_double(const int ispin, std::complex<double>* SR, std::complex<double>* HR)
148+
void DFTU::cal_eff_pot_mat_R_complex_double(const int ispin, const UnitCell& ucell, std::complex<double>* SR, std::complex<double>* HR)
141149
{
142150
const char transN = 'N', transT = 'T';
143151
const int one_int = 1;
144152
const std::complex<double> zero = 0.0, one = 1.0, half = 0.5;
145153

146154
std::vector<std::complex<double>> VU(this->paraV->nloc);
147-
this->cal_VU_pot_mat_complex(ispin, 1, &VU[0]);
155+
this->cal_VU_pot_mat_complex(ispin, 1, ucell, &VU[0]);
148156

149157
#ifdef __MPI
150158
pzgemm_(&transN, &transN,

0 commit comments

Comments
 (0)