Skip to content

Commit ef0d0e6

Browse files
committed
Refactor class Charge to template
1 parent 8ec123c commit ef0d0e6

File tree

121 files changed

+496
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+496
-409
lines changed

source/source_esolver/esolver_double_xc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ESolver_DoubleXC : public ESolver_KS_LCAO<TK, TR>
3636
LCAO_domain::Setup_DM<TK> dmat_base;
3737

3838
//! Electorn charge density
39-
Charge chr_base;
39+
Charge<double> chr_base;
4040
};
4141
} // namespace ModuleESolver
4242
#endif

source/source_esolver/esolver_fp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ESolver_FP: public ESolver
5454
K_Vectors kv;
5555

5656
//! Electorn charge density
57-
Charge chr;
57+
Charge<double> chr;
5858

5959
//! pw_rho: Plane-wave basis set for charge density
6060
//! pw_rhod: same as pw_rho for NCPP. Here 'd' stands for 'dense',

source/source_esolver/esolver_of.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void ESolver_OF::before_opt(const int istep, UnitCell& ucell)
217217
}
218218

219219
delete this->ptemp_rho_;
220-
this->ptemp_rho_ = new Charge();
220+
this->ptemp_rho_ = new Charge<double>();
221221
this->ptemp_rho_->set_rhopw(this->pw_rho);
222222
const bool kin_den = this->ptemp_rho_->kin_density(); // mohan add 20251202
223223
this->ptemp_rho_->allocate(PARAM.inp.nspin, kin_den);
@@ -250,7 +250,7 @@ void ESolver_OF::before_opt(const int istep, UnitCell& ucell)
250250
for (int ibs = 0; ibs < this->pw_rho->nrxx; ++ibs)
251251
{
252252
// Here we initialize rho to be uniform,
253-
// because the rho got by pot.init_pot -> Charge::atomic_rho may contain minus elements.
253+
// because the rho got by pot.init_pot -> Charge<double>::atomic_rho may contain minus elements.
254254
this->chr.rho[is][ibs] = this->nelec_[is] / ucell.omega;
255255
this->pphi_[is][ibs] = sqrt(this->chr.rho[is][ibs]);
256256
}

source/source_esolver/esolver_of.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ESolver_OF : public ESolver_FP
6262
int tn_spin_flag_ = -1; // spin flag used in cal_potential, which will be called by opt_tn
6363
int max_dcsrch_ = 200; // max no. of line search
6464
int flag_ = -1; // flag of TN
65-
Charge* ptemp_rho_ = nullptr; // used in line search
65+
Charge<double>* ptemp_rho_ = nullptr; // used in line search
6666
psi::Psi<double>* psi_ = nullptr; // sqrt(rho)
6767

6868
// ----------------- used for convergence check -------------------
@@ -90,7 +90,7 @@ class ESolver_OF : public ESolver_FP
9090
std::function<void(double*, double*)> bound_cal_potential_;
9191
void cal_potential_wrapper(double* ptemp_phi, double* rdLdphi);
9292
void cal_potential(double* ptemp_phi, double* rdLdphi, UnitCell& ucell);
93-
void cal_dEdtheta(double** ptemp_phi, Charge* temp_rho, UnitCell& ucell, double* ptheta, double* rdEdtheta);
93+
void cal_dEdtheta(double** ptemp_phi, Charge<double>* temp_rho, UnitCell& ucell, double* ptheta, double* rdEdtheta);
9494
double cal_mu(double* pphi, double* pdEdphi, double nelec);
9595

9696
// --------------------- determine the optimization direction -------

source/source_esolver/esolver_of_tool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void ESolver_OF::init_elecstate(UnitCell& ucell)
1919
{
2020
if (this->pelec == nullptr)
2121
{
22-
this->pelec = new elecstate::ElecState((Charge*)(&chr), this->pw_rho, pw_big);
22+
this->pelec = new elecstate::ElecState((Charge<double>*)(&chr), this->pw_rho, pw_big);
2323
}
2424

2525
delete this->pelec->pot;
@@ -84,7 +84,7 @@ void ESolver_OF::allocate_array()
8484

8585
// initialize chemical potential, step length, ...
8686
delete this->ptemp_rho_;
87-
this->ptemp_rho_ = new Charge();
87+
this->ptemp_rho_ = new Charge<double>();
8888
this->ptemp_rho_->set_rhopw(this->pw_rho);
8989
const bool kin_den = this->ptemp_rho_->kin_density(); // mohan add 20251202
9090
this->ptemp_rho_->allocate(PARAM.inp.nspin, kin_den);
@@ -173,7 +173,7 @@ void ESolver_OF::cal_potential(double* ptemp_phi, double* rdLdphi, UnitCell& uce
173173
* @param [in] ptheta
174174
* @param [out] rdEdtheta dE/dTheta
175175
*/
176-
void ESolver_OF::cal_dEdtheta(double** ptemp_phi, Charge* temp_rho, UnitCell& ucell, double* ptheta, double* rdEdtheta)
176+
void ESolver_OF::cal_dEdtheta(double** ptemp_phi, Charge<double>* temp_rho, UnitCell& ucell, double* ptheta, double* rdEdtheta)
177177
{
178178
double* dphi_dtheta = new double[this->pw_rho->nrxx];
179179

source/source_estate/elecstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void ElecState::init_scf(const UnitCell& ucell,
4545
}
4646

4747

48-
void ElecState::init_ks(Charge* chr_in, // pointer for class Charge
48+
void ElecState::init_ks(Charge<double>* chr_in, // pointer for class Charge<double>
4949
const K_Vectors* klist_in,
5050
int nk_in,
5151
const ModulePW::PW_Basis_Big* bigpw_in)

source/source_estate/elecstate.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ElecState
1717
ElecState()
1818
{
1919
}
20-
ElecState(Charge* chr_in, ModulePW::PW_Basis* rhopw_in, ModulePW::PW_Basis_Big* bigpw_in)
20+
ElecState(Charge<double>* chr_in, ModulePW::PW_Basis* rhopw_in, ModulePW::PW_Basis_Big* bigpw_in)
2121
{
2222
this->charge = chr_in;
2323
this->charge->set_rhopw(rhopw_in);
@@ -32,7 +32,7 @@ class ElecState
3232
this->pot = nullptr;
3333
}
3434
}
35-
void init_ks(Charge* chr_in, // pointer for class Charge
35+
void init_ks(Charge<double>* chr_in, // pointer for class Charge<double>
3636
const K_Vectors* klist_in,
3737
int nk_in, // number of k points
3838
const ModulePW::PW_Basis_Big* bigpw_in);
@@ -112,7 +112,7 @@ class ElecState
112112

113113
int iter = 0; ///< scf iteration
114114
Potential* pot = nullptr; ///< pointer to potential
115-
Charge* charge = nullptr; ///< pointer to charge density
115+
Charge<double>* charge = nullptr; ///< pointer to charge density
116116
const K_Vectors* klist = nullptr; ///< pointer to k points lists
117117
const ModulePW::PW_Basis_Big* bigpw = nullptr; ///< bigpw will be removed later
118118

source/source_estate/elecstate_lcao.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ElecStateLCAO : public ElecState
1515
ElecStateLCAO()
1616
{
1717
} // will be called by ElecStateLCAO_TDDFT
18-
ElecStateLCAO(Charge* chr_in,
18+
ElecStateLCAO(Charge<double>* chr_in,
1919
const K_Vectors* klist_in,
2020
int nks_in,
2121
ModulePW::PW_Basis_Big* bigpw_in)

source/source_estate/elecstate_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace elecstate {
1313

1414
template <typename T, typename Device>
1515
ElecStatePW<T, Device>::ElecStatePW(ModulePW::PW_Basis_K* wfc_basis_in,
16-
Charge* chr_in,
16+
Charge<double>* chr_in,
1717
K_Vectors* pkv_in,
1818
UnitCell* ucell_in,
1919
pseudopot_cell_vnl* ppcell_in,

source/source_estate/elecstate_pw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ElecStatePW : public ElecState
2020

2121
public:
2222
ElecStatePW(ModulePW::PW_Basis_K* wfc_basis_in,
23-
Charge* chr_in,
23+
Charge<double>* chr_in,
2424
K_Vectors* pkv_in,
2525
UnitCell* ucell_in,
2626
pseudopot_cell_vnl* ppcell_in,

0 commit comments

Comments
 (0)