Skip to content

Commit 2389aa6

Browse files
committed
add esolver_gets
1 parent 5bcbf23 commit 2389aa6

File tree

3 files changed

+62
-26
lines changed

3 files changed

+62
-26
lines changed

source/module_esolver/esolver.cpp

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#include "module_base/module_device/device.h"
66
#include "module_parameter/parameter.h"
77
#ifdef __LCAO
8-
#include "esolver_ks_lcaopw.h"
8+
#include "esolver_gets.h"
99
#include "esolver_ks_lcao.h"
1010
#include "esolver_ks_lcao_tddft.h"
11+
#include "esolver_ks_lcaopw.h"
1112
#include "module_lr/esolver_lrtd_lcao.h"
1213
extern "C"
1314
{
@@ -188,18 +189,39 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
188189
{
189190
if (PARAM.globalv.gamma_only_local)
190191
{
191-
return new ESolver_KS_LCAO<double, double>();
192-
}
193-
else if (PARAM.inp.nspin < 4)
194-
{
195-
return new ESolver_KS_LCAO<std::complex<double>, double>();
196-
}
197-
else
198-
{
199-
return new ESolver_KS_LCAO<std::complex<double>, std::complex<double>>();
200-
}
201-
}
202-
else if (esolver_type == "ksdft_lcao_tddft")
192+
if (PARAM.inp.calculation == "get_S")
193+
{
194+
return new ESolver_GetS<double, double>();
195+
}
196+
else
197+
{
198+
return new ESolver_KS_LCAO<double, double>();
199+
}
200+
}
201+
else if (PARAM.inp.nspin < 4)
202+
{
203+
if (PARAM.inp.calculation == "get_S")
204+
{
205+
return new ESolver_GetS<std::complex<double>, double>();
206+
}
207+
else
208+
{
209+
return new ESolver_KS_LCAO<std::complex<double>, double>();
210+
}
211+
}
212+
else
213+
{
214+
if (PARAM.inp.calculation == "get_S")
215+
{
216+
return new ESolver_GetS<std::complex<double>, std::complex<double>>();
217+
}
218+
else
219+
{
220+
return new ESolver_KS_LCAO<std::complex<double>, std::complex<double>>();
221+
}
222+
}
223+
}
224+
else if (esolver_type == "ksdft_lcao_tddft")
203225
{
204226
return new ESolver_KS_LCAO_TDDFT();
205227
}

source/module_esolver/esolver_gets.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ void ESolver_GetS<std::complex<double>, std::complex<double>>::runner(const int
122122
->contributeHR();
123123
}
124124

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+
125129
ModuleBase::timer::tick("ESolver_GetS", "runner");
126130
}
127131

@@ -157,22 +161,15 @@ void ESolver_GetS<std::complex<double>, double>::runner(const int istep, UnitCel
157161
dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, double>*>(this->p_hamilt->ops)->contributeHR();
158162
}
159163

160-
ModuleBase::timer::tick("ESolver_GetS", "runner");
161-
}
162-
163-
template <typename TK, typename TR>
164-
void ESolver_GetS<TK, TR>::after_all_runners()
165-
{
166-
ModuleBase::TITLE("ESolver_GetS", "after_all_runners");
167-
ModuleBase::timer::tick("ESolver_GetS", "after_all_runners");
168-
169164
const std::string fn = PARAM.globalv.global_out_dir + "SR.csr";
170-
171165
std::cout << " The file is saved in " << fn << std::endl;
172-
173166
ModuleIO::output_SR(pv, GlobalC::GridD, this->p_hamilt, fn);
174167

175-
ModuleBase::timer::tick("ESolver_GetS", "after_all_runners");
168+
ModuleBase::timer::tick("ESolver_GetS", "runner");
176169
}
177170

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+
178175
} // namespace ModuleESolver

source/module_esolver/esolver_gets.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "module_basis/module_nao/two_center_bundle.h"
55
#include "module_cell/unitcell.h"
66
#include "module_esolver/esolver_ks.h"
7+
#include "module_hamilt_lcao/module_gint/gint_gamma.h"
8+
#include "module_hamilt_lcao/module_gint/gint_k.h"
79

810
#include <memory>
911

@@ -18,17 +20,32 @@ class ESolver_GetS : public ESolver_KS<TK>
1820

1921
void before_all_runners(const Input_para& inp, UnitCell& ucell) override;
2022

21-
void after_all_runners() override;
23+
void after_all_runners() {};
2224

2325
void runner(const int istep, UnitCell& ucell) override;
2426

27+
//! calculate total energy of a given system
28+
double cal_energy() {};
29+
30+
//! calcualte forces for the atoms in the given cell
31+
void cal_force(ModuleBase::matrix& force) {};
32+
33+
//! calcualte stress of given cell
34+
void cal_stress(ModuleBase::matrix& stress) {};
35+
2536
protected:
2637
// we will get rid of this class soon, don't use it, mohan 2024-03-28
2738
Record_adj RA;
2839

2940
// 2d block - cyclic distribution info
3041
Parallel_Orbitals pv;
3142

43+
// used for k-dependent grid integration.
44+
Gint_k GK;
45+
46+
// used for gamma only algorithms.
47+
Gint_Gamma GG;
48+
3249
TwoCenterBundle two_center_bundle_;
3350

3451
// // temporary introduced during removing GlobalC::ORB

0 commit comments

Comments
 (0)