Skip to content

Commit df94f88

Browse files
authored
Refactor: remove template for get_S (#5593)
1 parent 7e9d081 commit df94f88

File tree

3 files changed

+18
-73
lines changed

3 files changed

+18
-73
lines changed

source/module_esolver/esolver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
191191
{
192192
if (PARAM.inp.calculation == "get_S")
193193
{
194-
return new ESolver_GetS<double, double>();
194+
ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for gamma_only");
195195
}
196196
else
197197
{
@@ -202,7 +202,7 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
202202
{
203203
if (PARAM.inp.calculation == "get_S")
204204
{
205-
return new ESolver_GetS<std::complex<double>, double>();
205+
return new ESolver_GetS();
206206
}
207207
else
208208
{
@@ -213,7 +213,7 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
213213
{
214214
if (PARAM.inp.calculation == "get_S")
215215
{
216-
return new ESolver_GetS<std::complex<double>, std::complex<double>>();
216+
ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for npsin=4");
217217
}
218218
else
219219
{

source/module_esolver/esolver_gets.cpp

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@
1212
namespace ModuleESolver
1313
{
1414

15-
template <typename TK, typename TR>
16-
ESolver_GetS<TK, TR>::ESolver_GetS()
15+
ESolver_GetS::ESolver_GetS()
1716
{
1817
this->classname = "ESolver_GetS";
1918
this->basisname = "LCAO";
2019
}
2120

22-
template <typename TK, typename TR>
23-
ESolver_GetS<TK, TR>::~ESolver_GetS()
21+
ESolver_GetS::~ESolver_GetS()
2422
{
2523
}
2624

27-
template <typename TK, typename TR>
28-
void ESolver_GetS<TK, TR>::before_all_runners(UnitCell& ucell, const Input_para& inp)
25+
void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& inp)
2926
{
3027
ModuleBase::TITLE("ESolver_GetS", "before_all_runners");
3128
ModuleBase::timer::tick("ESolver_GetS", "before_all_runners");
@@ -51,13 +48,13 @@ void ESolver_GetS<TK, TR>::before_all_runners(UnitCell& ucell, const Input_para&
5148
if (this->pelec == nullptr)
5249
{
5350
// TK stands for double and complex<double>?
54-
this->pelec = new elecstate::ElecStateLCAO<TK>(&(this->chr), // use which parameter?
55-
&(this->kv),
56-
this->kv.get_nks(),
57-
&(this->GG), // mohan add 2024-04-01
58-
&(this->GK), // mohan add 2024-04-01
59-
this->pw_rho,
60-
this->pw_big);
51+
this->pelec = new elecstate::ElecStateLCAO<std::complex<double>>(&(this->chr), // use which parameter?
52+
&(this->kv),
53+
this->kv.get_nks(),
54+
&(this->GG), // mohan add 2024-04-01
55+
&(this->GK), // mohan add 2024-04-01
56+
this->pw_rho,
57+
this->pw_big);
6158
}
6259

6360
// 3) init LCAO basis
@@ -76,61 +73,13 @@ void ESolver_GetS<TK, TR>::before_all_runners(UnitCell& ucell, const Input_para&
7673
// 4) initialize the density matrix
7774
// DensityMatrix is allocated here, DMK is also initialized here
7875
// DMR is not initialized here, it will be constructed in each before_scf
79-
dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->init_DM(&this->kv, &(this->pv), inp.nspin);
76+
dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)
77+
->init_DM(&this->kv, &(this->pv), inp.nspin);
8078

8179
ModuleBase::timer::tick("ESolver_GetS", "before_all_runners");
8280
}
8381

84-
template <>
85-
void ESolver_GetS<double, double>::runner(UnitCell& ucell, const int istep)
86-
{
87-
ModuleBase::TITLE("ESolver_GetS", "runner");
88-
ModuleBase::WARNING_QUIT("ESolver_GetS<double, double>::runner", "not implemented");
89-
}
90-
91-
template <>
92-
void ESolver_GetS<std::complex<double>, std::complex<double>>::runner(UnitCell& ucell, const int istep)
93-
{
94-
ModuleBase::TITLE("ESolver_GetS", "runner");
95-
ModuleBase::timer::tick("ESolver_GetS", "runner");
96-
97-
// (1) Find adjacent atoms for each atom.
98-
double search_radius = -1.0;
99-
search_radius = atom_arrange::set_sr_NL(GlobalV::ofs_running,
100-
PARAM.inp.out_level,
101-
orb_.get_rcutmax_Phi(),
102-
ucell.infoNL.get_rcutmax_Beta(),
103-
PARAM.globalv.gamma_only_local);
104-
105-
atom_arrange::search(PARAM.inp.search_pbc,
106-
GlobalV::ofs_running,
107-
GlobalC::GridD,
108-
ucell,
109-
search_radius,
110-
PARAM.inp.test_atom_input);
111-
112-
this->RA.for_2d(this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs());
113-
114-
if (this->p_hamilt == nullptr)
115-
{
116-
this->p_hamilt
117-
= new hamilt::HamiltLCAO<std::complex<double>, std::complex<double>>(&this->pv,
118-
this->kv,
119-
*(two_center_bundle_.overlap_orb),
120-
orb_.cutoffs());
121-
dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, std::complex<double>>*>(this->p_hamilt->ops)
122-
->contributeHR();
123-
}
124-
125-
const std::string fn = PARAM.globalv.global_out_dir + "SR.csr";
126-
std::cout << " The file is saved in " << fn << std::endl;
127-
ModuleIO::output_SR(pv, GlobalC::GridD, this->p_hamilt, fn);
128-
129-
ModuleBase::timer::tick("ESolver_GetS", "runner");
130-
}
131-
132-
template <>
133-
void ESolver_GetS<std::complex<double>, double>::runner(UnitCell& ucell, const int istep)
82+
void ESolver_GetS::runner(UnitCell& ucell, const int istep)
13483
{
13584
ModuleBase::TITLE("ESolver_GetS", "runner");
13685
ModuleBase::timer::tick("ESolver_GetS", "runner");
@@ -168,8 +117,4 @@ void ESolver_GetS<std::complex<double>, double>::runner(UnitCell& ucell, const i
168117
ModuleBase::timer::tick("ESolver_GetS", "runner");
169118
}
170119

171-
template class ESolver_GetS<double, double>;
172-
template class ESolver_GetS<std::complex<double>, double>;
173-
template class ESolver_GetS<std::complex<double>, std::complex<double>>;
174-
175120
} // namespace ModuleESolver

source/module_esolver/esolver_gets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace ModuleESolver
1313
{
14-
template <typename TK, typename TR>
15-
class ESolver_GetS : public ESolver_KS<TK>
14+
15+
class ESolver_GetS : public ESolver_KS<std::complex<double>>
1616
{
1717
public:
1818
ESolver_GetS();

0 commit comments

Comments
 (0)