Skip to content

Commit 077be37

Browse files
committed
add template for cal_tau
1 parent 9015156 commit 077be37

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

source/module_elecstate/elecstate_lcao.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void ElecStateLCAO<std::complex<double>>::psiToRho(const psi::Psi<std::complex<d
6565

6666
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
6767
{
68-
this->cal_tau(psi);
68+
elecstate::cal_tau_k(gint_k, this->charge);
6969
}
7070

7171
this->charge->renormalize_rho();
@@ -100,7 +100,7 @@ void ElecStateLCAO<double>::psiToRho(const psi::Psi<double>& psi)
100100

101101
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
102102
{
103-
this->cal_tau(psi);
103+
elecstate::lcao_cal_tau_gamma(gint_gamma, this->charge);
104104
}
105105

106106
this->charge->renormalize_rho();

source/module_elecstate/elecstate_lcao_cal_tau.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace elecstate
66
{
77

88
// calculate the kinetic energy density tau, multi-k case
9-
void cal_tau_k(Gint_k& gint_k,
9+
void lcao_cal_tau_k(Gint_k* gint_k,
1010
Charge* charge)
1111
{
1212
ModuleBase::timer::tick("ElecStateLCAO", "cal_tau");
@@ -23,8 +23,8 @@ void cal_tau_k(Gint_k& gint_k,
2323
}
2424

2525
// calculate the kinetic energy density tau, gamma-only case
26-
void cal_tau_gamma(Gint_Gamma& gint_gamma,
27-
Charge& charge)
26+
void lcao_cal_tau_gamma(Gint_Gamma* gint_gamma,
27+
Charge* charge)
2828
{
2929
ModuleBase::timer::tick("ElecStateLCAO", "cal_tau");
3030

@@ -38,4 +38,20 @@ void cal_tau_gamma(Gint_Gamma& gint_gamma,
3838
ModuleBase::timer::tick("ElecStateLCAO", "cal_tau");
3939
return;
4040
}
41-
}
41+
template <double>
42+
void lcao_cal_tau(Gint_Gamma* gint_gamma,
43+
Gint_k* gint_k,
44+
Charge* charge)
45+
{
46+
lcao_cal_tau_gamma(gint_gamma, charge);
47+
}
48+
template <complex<double>>
49+
void lcao_cal_tau(Gint_Gamma* gint_gamma,
50+
Gint_k* gint_k,
51+
Charge* charge,
52+
const std::complex<double>* flag)
53+
{
54+
lcao_cal_tau_k(gint_k, charge);
55+
}
56+
57+
} // namespace elecstate

source/module_elecstate/elecstate_lcao_cal_tau.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
namespace elecstate
55
{
66

7-
void cal_tau_k(Gint_k& gint_k,
8-
Charge& charge);
7+
void lcao_cal_tau_k(Gint_k* gint_k,
8+
Charge* charge);
99

10-
void cal_tau_gamma(Gint_Gamma& gint_gamma,
11-
Charge& charge);
10+
void lcao_cal_tau_gamma(Gint_Gamma* gint_gamma,
11+
Charge* charge);
12+
13+
template <typename T>
14+
void lcao_cal_tau(Gint_Gamma* gint_gamma,
15+
Gint_k* gint_k,
16+
Charge* charge);
1217

1318
}
1419
#endif

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,9 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
927927
// 1) calculate the kinetic energy density tau, sunliang 2024-09-18
928928
if (PARAM.inp.out_elf[0] > 0)
929929
{
930-
assert(this->psi != nullptr);
931-
this->pelec->cal_tau(*(this->psi));
930+
elecstate::lcao_cal_tau<double>(this->GK,
931+
this->GG,
932+
this->pelec->charge);
932933
}
933934

934935
//! 2) call after_scf() of ESolver_KS

0 commit comments

Comments
 (0)