Skip to content

Commit d05e1b2

Browse files
authored
Merge branch 'develop' into guess
2 parents 4bca0ec + e987240 commit d05e1b2

File tree

17 files changed

+373
-419
lines changed

17 files changed

+373
-419
lines changed

source/Makefile.Objects

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,10 @@ OBJS_ESOLVER=esolver.o\
245245
esolver_of.o\
246246
esolver_of_tool.o\
247247
esolver_of_interface.o\
248-
pw_init_globalc.o\
249248
pw_others.o\
250249

251250
OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
252251
esolver_ks_lcao_tddft.o\
253-
dpks_cal_e_delta_band.o\
254-
set_matrix_grid.o\
255252
lcao_before_scf.o\
256253
esolver_gets.o\
257254
lcao_others.o\

source/module_esolver/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ list(APPEND objects
1010
esolver_of.cpp
1111
esolver_of_interface.cpp
1212
esolver_of_tool.cpp
13-
pw_init_globalc.cpp
1413
pw_others.cpp
1514
)
1615
if(ENABLE_LCAO)
1716
list(APPEND objects
1817
esolver_ks_lcao.cpp
1918
esolver_ks_lcao_tddft.cpp
20-
dpks_cal_e_delta_band.cpp
21-
set_matrix_grid.cpp
2219
lcao_before_scf.cpp
2320
esolver_gets.cpp
2421
lcao_others.cpp

source/module_esolver/dpks_cal_e_delta_band.cpp

Lines changed: 0 additions & 69 deletions
This file was deleted.

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(const int istep, int& iter)
879879
const std::vector<std::vector<TK>>& dm
880880
= dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM()->get_DMK_vector();
881881

882-
this->dpks_cal_e_delta_band(dm);
882+
GlobalC::ld.dpks_cal_e_delta_band(dm, this->kv.get_nks());
883883
}
884884
#endif
885885

source/module_esolver/esolver_ks_lcao.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
9292
std::shared_ptr<Exx_LRI<std::complex<double>>> exx_lri_complex = nullptr;
9393
#endif
9494

95-
private:
96-
#ifdef __DEEPKS
97-
void dpks_cal_e_delta_band(const std::vector<std::vector<TK>>& dm) const;
98-
99-
void dpks_cal_projected_DM(
100-
const elecstate::DensityMatrix<TK, double>* dm) const;
101-
#endif
10295
friend class LR::ESolver_LR<double, double>;
10396
friend class LR::ESolver_LR<std::complex<double>, double>;
10497
};

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "module_base/memory.h"
1919
#include "module_base/module_device/device.h"
2020
#include "module_elecstate/elecstate_pw.h"
21+
#include "module_elecstate/elecstate_pw_sdft.h"
2122
#include "module_hamilt_general/module_vdw/vdw.h"
2223
#include "module_hamilt_pw/hamilt_pwdft/elecond.h"
2324
#include "module_hamilt_pw/hamilt_pwdft/hamilt_pw.h"
@@ -136,14 +137,29 @@ void ESolver_KS_PW<T, Device>::before_all_runners(const Input_para& inp, UnitCel
136137
// 3) initialize ElecState,
137138
if (this->pelec == nullptr)
138139
{
139-
this->pelec = new elecstate::ElecStatePW<T, Device>(this->pw_wfc,
140-
&(this->chr),
141-
&(this->kv),
142-
&ucell,
143-
&GlobalC::ppcell,
144-
this->pw_rhod,
145-
this->pw_rho,
146-
this->pw_big);
140+
if (inp.esolver_type == "sdft")
141+
{
142+
//! SDFT only supports double precision currently
143+
this->pelec = new elecstate::ElecStatePW_SDFT<std::complex<double>, Device>(this->pw_wfc,
144+
&(this->chr),
145+
&(this->kv),
146+
&ucell,
147+
&(GlobalC::ppcell),
148+
this->pw_rhod,
149+
this->pw_rho,
150+
this->pw_big);
151+
}
152+
else
153+
{
154+
this->pelec = new elecstate::ElecStatePW<T, Device>(this->pw_wfc,
155+
&(this->chr),
156+
&(this->kv),
157+
&ucell,
158+
&GlobalC::ppcell,
159+
this->pw_rhod,
160+
this->pw_rho,
161+
this->pw_big);
162+
}
147163
}
148164

149165
//! 4) inititlize the charge density.
@@ -180,8 +196,39 @@ void ESolver_KS_PW<T, Device>::before_all_runners(const Input_para& inp, UnitCel
180196
#endif
181197
&GlobalC::ppcell);
182198

183-
//! 8) setup global classes
184-
this->Init_GlobalC(inp, ucell, GlobalC::ppcell);
199+
if (this->psi != nullptr)
200+
{
201+
delete this->psi;
202+
}
203+
204+
//! init pseudopotential
205+
GlobalC::ppcell.init(ucell.ntype, &this->sf, this->pw_wfc);
206+
207+
//! initalize local pseudopotential
208+
GlobalC::ppcell.init_vloc(GlobalC::ppcell.vloc, this->pw_rhod);
209+
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
210+
211+
//! Initalize non-local pseudopotential
212+
GlobalC::ppcell.init_vnl(ucell, this->pw_rhod);
213+
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "NON-LOCAL POTENTIAL");
214+
215+
//! Allocate psi
216+
this->p_wf_init->allocate_psi(this->psi,
217+
this->kv.get_nkstot(),
218+
this->kv.get_nks(),
219+
this->kv.ngk.data(),
220+
this->pw_wfc->npwk_max,
221+
&(this->sf));
222+
223+
this->kspw_psi = PARAM.inp.device == "gpu" || PARAM.inp.precision == "single"
224+
? new psi::Psi<T, Device>(this->psi[0])
225+
: reinterpret_cast<psi::Psi<T, Device>*>(this->psi);
226+
227+
if (PARAM.inp.precision == "single")
228+
{
229+
ModuleBase::Memory::record("Psi_single", sizeof(T) * this->psi[0].size());
230+
}
231+
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT BASIS");
185232

186233
//! 9) setup occupations
187234
if (PARAM.inp.ocp)

source/module_esolver/esolver_ks_pw.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class ESolver_KS_PW : public ESolver_KS<T, Device>
4646

4747
virtual void hamilt2density_single(const int istep, const int iter, const double ethr) override;
4848

49-
// temporary, this will be removed in the future;
50-
// Init Global class
51-
void Init_GlobalC(const Input_para& inp, UnitCell& ucell, pseudopot_cell_vnl& ppcell);
52-
5349
virtual void allocate_hamilt();
5450
virtual void deallocate_hamilt();
5551

source/module_esolver/esolver_sdft_pw.cpp

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -50,51 +50,9 @@ void ESolver_SDFT_PW<T, Device>::before_all_runners(const Input_para& inp, UnitC
5050
this->method_sto = inp.method_sto;
5151

5252
// 2) run "before_all_runners" in ESolver_KS
53-
ESolver_KS<T, Device>::before_all_runners(inp, ucell);
54-
55-
// 3) initialize the pointer for electronic states of SDFT
56-
this->pelec = new elecstate::ElecStatePW_SDFT<T, Device>(this->pw_wfc,
57-
&(this->chr),
58-
&(this->kv),
59-
&ucell,
60-
&(GlobalC::ppcell),
61-
this->pw_rhod,
62-
this->pw_rho,
63-
this->pw_big);
64-
65-
// 4) inititlize the charge density.
66-
this->pelec->charge->allocate(PARAM.inp.nspin);
67-
this->pelec->omega = ucell.omega;
68-
69-
// 5) initialize the potential.
70-
if (this->pelec->pot == nullptr)
71-
{
72-
this->pelec->pot = new elecstate::Potential(this->pw_rhod,
73-
this->pw_rho,
74-
&ucell,
75-
&(GlobalC::ppcell.vloc),
76-
&(this->sf),
77-
&(this->pelec->f_en.etxc),
78-
&(this->pelec->f_en.vtxc));
79-
}
80-
81-
// 6) prepare some parameters for electronic wave functions initilization
82-
this->p_wf_init = new psi::PSIInit<T, Device>(PARAM.inp.init_wfc,
83-
PARAM.inp.ks_solver,
84-
PARAM.inp.basis_type,
85-
PARAM.inp.psi_initializer,
86-
&this->wf,
87-
this->pw_wfc);
88-
// 7) set occupatio, redundant?
89-
if (PARAM.inp.ocp)
90-
{
91-
this->pelec->fixed_weights(PARAM.inp.ocp_kb, PARAM.inp.nbands, PARAM.inp.nelec);
92-
}
93-
94-
// 8) initialize the global classes
95-
this->Init_GlobalC(inp, ucell, GlobalC::ppcell); // temporary
53+
ESolver_KS_PW<T, Device>::before_all_runners(inp, ucell);
9654

97-
// 9) initialize the stochastic wave functions
55+
// 3) initialize the stochastic wave functions
9856
this->stowf.init(&this->kv, this->pw_wfc->npwk_max);
9957
if (inp.nbands_sto != 0)
10058
{
@@ -117,7 +75,7 @@ void ESolver_SDFT_PW<T, Device>::before_all_runners(const Input_para& inp, UnitC
11775
}
11876
this->stowf.sync_chi0();
11977

120-
// 10) allocate spaces for \sqrt(f(H))|chi> and |\tilde{chi}>
78+
// 4) allocate spaces for \sqrt(f(H))|chi> and |\tilde{chi}>
12179
size_t size = stowf.chi0->size();
12280
this->stowf.shchi
12381
= new psi::Psi<T, Device>(this->kv.get_nks(), this->stowf.nchip_max, this->wf.npwx, this->kv.ngk.data());

0 commit comments

Comments
 (0)