Skip to content

Commit 2182aca

Browse files
authored
Refactor wavefunction initialization in lcao_others (deepmodeling#6887)
1 parent 60f5aac commit 2182aca

1 file changed

Lines changed: 42 additions & 87 deletions

File tree

source/source_esolver/lcao_others.cpp

Lines changed: 42 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
#include "source_lcao/hamilt_lcao.h"
2-
#include "source_lcao/module_dftu/dftu.h"
31
#include "source_esolver/esolver_ks_lcao.h"
42
#include "source_estate/cal_ux.h"
53
#include "source_estate/module_charge/symmetry_rho.h"
4+
#include "source_lcao/hamilt_lcao.h"
5+
#include "source_lcao/module_dftu/dftu.h"
66
#include "source_pw/module_pwdft/global.h"
77
//
8+
#include "source_base/formatter.h"
9+
#include "source_base/timer.h"
10+
#include "source_cell/module_neighbor/sltk_atom_arrange.h"
11+
#include "source_cell/module_neighbor/sltk_grid_driver.h"
12+
#include "source_estate/elecstate_lcao.h"
13+
#include "source_estate/module_dm/cal_dm_psi.h"
814
#include "source_io/berryphase.h"
915
#include "source_io/get_pchg_lcao.h"
1016
#include "source_io/get_wf_lcao.h"
11-
#include "source_io/write_HS_R.h"
1217
#include "source_io/module_parameter/parameter.h"
13-
#include "source_base/timer.h"
14-
#include "source_cell/module_neighbor/sltk_atom_arrange.h"
15-
#include "source_cell/module_neighbor/sltk_grid_driver.h"
18+
#include "source_io/read_wfc_nao.h"
19+
#include "source_io/write_HS_R.h"
20+
#include "source_io/write_elecstat_pot.h"
1621
#include "source_lcao/LCAO_domain.h"
22+
#include "source_lcao/module_deltaspin/spin_constrain.h"
1723
#include "source_lcao/module_operator_lcao/op_exx_lcao.h"
1824
#include "source_lcao/module_operator_lcao/operator_lcao.h"
19-
#include "source_lcao/module_deltaspin/spin_constrain.h"
20-
#include "source_io/read_wfc_nao.h"
21-
#include "source_io/write_elecstat_pot.h"
22-
#include "source_base/formatter.h"
23-
#include "source_estate/elecstate_lcao.h"
24-
#include "source_estate/module_dm/cal_dm_psi.h"
2525

2626
#ifdef __EXX
2727
#include "source_io/restart_exx_csr.h"
@@ -90,23 +90,21 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
9090
PARAM.inp.test_atom_input);
9191

9292
// (3) Periodic condition search for each grid.
93-
gint_info_.reset(
94-
new ModuleGint::GintInfo(
95-
this->pw_big->nbx,
96-
this->pw_big->nby,
97-
this->pw_big->nbz,
98-
this->pw_rho->nx,
99-
this->pw_rho->ny,
100-
this->pw_rho->nz,
101-
0,
102-
0,
103-
this->pw_big->nbzp_start,
104-
this->pw_big->nbx,
105-
this->pw_big->nby,
106-
this->pw_big->nbzp,
107-
orb_.Phi,
108-
ucell,
109-
this->gd));
93+
gint_info_.reset(new ModuleGint::GintInfo(this->pw_big->nbx,
94+
this->pw_big->nby,
95+
this->pw_big->nbz,
96+
this->pw_rho->nx,
97+
this->pw_rho->ny,
98+
this->pw_rho->nz,
99+
0,
100+
0,
101+
this->pw_big->nbzp_start,
102+
this->pw_big->nbx,
103+
this->pw_big->nby,
104+
this->pw_big->nbzp,
105+
orb_.Phi,
106+
ucell,
107+
this->gd));
110108
ModuleGint::Gint::set_gint_info(gint_info_.get());
111109

112110
// (2)For each atom, calculate the adjacent atoms in different cells
@@ -121,49 +119,8 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
121119
// this information is used to calculate
122120
// the force.
123121

124-
// init psi
125-
if (this->psi == nullptr)
126-
{
127-
int nsk = 0;
128-
int ncol = 0;
129-
if (PARAM.globalv.gamma_only_local)
130-
{
131-
nsk = PARAM.inp.nspin;
132-
ncol = this->pv.ncol_bands;
133-
if (PARAM.inp.ks_solver == "genelpa" || PARAM.inp.ks_solver == "elpa" || PARAM.inp.ks_solver == "lapack"
134-
|| PARAM.inp.ks_solver == "pexsi" || PARAM.inp.ks_solver == "cusolver"
135-
|| PARAM.inp.ks_solver == "cusolvermp")
136-
{
137-
ncol = this->pv.ncol;
138-
}
139-
}
140-
else
141-
{
142-
nsk = this->kv.get_nks();
143-
#ifdef __MPI
144-
ncol = this->pv.ncol_bands;
145-
#else
146-
ncol = PARAM.inp.nbands;
147-
#endif
148-
}
149-
this->psi = new psi::Psi<TK>(nsk, ncol, this->pv.nrow, this->kv.ngk, true);
150-
}
151-
152-
// init wfc from file
153-
if (istep == 0 && PARAM.inp.init_wfc == "file")
154-
{
155-
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir,
156-
this->pv,
157-
*(this->psi),
158-
this->pelec->ekb,
159-
this->pelec->wg,
160-
this->pelec->klist->ik2iktot,
161-
this->pelec->klist->get_nkstot(),
162-
PARAM.inp.nspin))
163-
{
164-
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::others", "read wfc nao failed");
165-
}
166-
}
122+
// init psi deleted by taoni 2026-01-23
123+
// don't need to since initialized in LCAO_domain::set_psi_occ_dm_chg in before_all_runners
167124

168125
// init Hamiltonian
169126
if (this->p_hamilt != nullptr)
@@ -173,21 +130,19 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
173130
}
174131
if (this->p_hamilt == nullptr)
175132
{
176-
this->p_hamilt = new hamilt::HamiltLCAO<TK, TR>(
177-
ucell,
178-
this->gd,
179-
&this->pv,
180-
this->pelec->pot,
181-
this->kv,
182-
two_center_bundle_,
183-
orb_,
184-
this->dmat.dm,
185-
&this->dftu,
186-
this->deepks,
187-
istep,
188-
this->exx_nao);
189-
}
190-
133+
this->p_hamilt = new hamilt::HamiltLCAO<TK, TR>(ucell,
134+
this->gd,
135+
&this->pv,
136+
this->pelec->pot,
137+
this->kv,
138+
two_center_bundle_,
139+
orb_,
140+
this->dmat.dm,
141+
&this->dftu,
142+
this->deepks,
143+
istep,
144+
this->exx_nao);
145+
}
191146

192147
// for each ionic step, the overlap <phi|alpha> must be rebuilt
193148
// since it depends on ionic positions

0 commit comments

Comments
 (0)