Skip to content

Commit f438e2e

Browse files
committed
finish updating esolver
1 parent 98240e6 commit f438e2e

File tree

3 files changed

+85
-22
lines changed

3 files changed

+85
-22
lines changed

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
#include "source_io/ctrl_runner_lcao.h" // use ctrl_runner_lcao()
1818
#include "source_io/ctrl_iter_lcao.h" // use ctrl_iter_lcao()
1919
#include "source_io/ctrl_scf_lcao.h" // use ctrl_scf_lcao()
20-
#include "source_psi/setup_psi.h" // mohan add 20251019
21-
#include "source_io/read_wfc_nao.h"
2220
#include "source_io/print_info.h"
2321
#include "source_lcao/rho_tau_lcao.h" // mohan add 20251024
22+
#include "source_lcao/LCAO_set.h" // mohan add 20251111
2423

2524
namespace ModuleESolver
2625
{
@@ -74,9 +73,12 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
7473
return;
7574
}
7675

77-
LCAO_domain::set_psi_occ_dm_chg();
76+
LCAO_domain::set_psi_occ_dm_chg<TK>(this->kv, this->psi, this->pv, this->pelec,
77+
this->dmat, this->chr, inp);
7878

79-
LCAO_domain::set_pot();
79+
LCAO_domain::set_pot<TK>(ucell, this->kv, this->sf, *this->pw_rho, *this->pw_rhod,
80+
this->pelec, this->orb_, this->pv, this->locpp, this->dftu,
81+
this->solvent, this->exx_nao, this->deepks, inp);
8082

8183
//! if kpar is not divisible by nks, print a warning
8284
ModuleIO::print_kpar(this->kv.get_nks(), PARAM.globalv.kpar_lcao);

source/source_lcao/LCAO_set.cpp

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#include "source_lcao/LCAO_set_pot.h"
1+
#include "source_lcao/LCAO_set.h"
22
#include "source_io/module_parameter/parameter.h"
3+
#include "source_psi/setup_psi.h" // use Setup_Psi
4+
#include "source_io/read_wfc_nao.h" // use read_wfc_nao
5+
#include "source_estate/elecstate_tools.h" // use fixed_weights
36

47
template <typename TK>
58
void LCAO_domain::set_psi_occ_dm_chg(
@@ -11,6 +14,7 @@ void LCAO_domain::set_psi_occ_dm_chg(
1114
Charge &chr, // charge density
1215
const Input_para &inp) // input parameters
1316
{
17+
1418
//! 1) init electronic wave function psi
1519
Setup_Psi<TK>::allocate_psi(psi, kv, pv, inp);
1620

@@ -29,7 +33,7 @@ void LCAO_domain::set_psi_occ_dm_chg(
2933
if (inp.ocp && inp.esolver_type != "tddft")
3034
{
3135
elecstate::fixed_weights(inp.ocp_kb, inp.nbands, inp.nelec,
32-
kv, pelec->wg, pelec->skip_weights);
36+
&kv, pelec->wg, pelec->skip_weights);
3337
}
3438

3539
//! 4) init DMK, but DMR is constructed in before_scf()
@@ -42,32 +46,33 @@ void LCAO_domain::set_psi_occ_dm_chg(
4246
}
4347

4448

45-
49+
template <typename TK>
4650
void LCAO_domain::set_pot(
47-
const K_Vectors &kv,
48-
const Structure_Factor& sf,
51+
UnitCell &ucell, // not const because of dftu
52+
K_Vectors &kv, // not const due to exx
53+
Structure_Factor& sf, // will be modified in potential
4954
const ModulePW::PW_Basis &pw_rho,
5055
const ModulePW::PW_Basis &pw_rhod,
5156
elecstate::ElecState* pelec,
5257
const LCAO_Orbitals& orb,
53-
const Parallel_Orbitals &pv,
58+
Parallel_Orbitals &pv, // not const due to deepks
5459
pseudopot_cell_vl &locpp,
5560
Plus_U &dftu,
5661
surchem& solvent,
57-
Exx_NAO<T> &exx_nao,
58-
Setup_DeePKS<T> &deepks,
62+
Exx_NAO<TK> &exx_nao,
63+
Setup_DeePKS<TK> &deepks,
5964
const Input_para &inp)
6065
{
6166
//! 1) init local pseudopotentials
62-
locpp.init_vloc(ucell, pw_rho);
67+
locpp.init_vloc(ucell, &pw_rho);
6368
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
6469

6570
//! 2) init potentials
6671
if (pelec->pot == nullptr)
6772
{
6873
// where is the pot deleted?
6974
pelec->pot = new elecstate::Potential(&pw_rhod, &pw_rho,
70-
&ucell, &(locpp.vloc), &(sf), &(solvent),
75+
&ucell, &locpp.vloc, &sf, &solvent,
7176
&(pelec->f_en.etxc), &(pelec->f_en.vtxc));
7277
}
7378

@@ -87,3 +92,53 @@ void LCAO_domain::set_pot(
8792
}
8893

8994

95+
96+
template void LCAO_domain::set_psi_occ_dm_chg<double>(
97+
const K_Vectors &kv, // k-points
98+
psi::Psi<double>* psi, // coefficients of NAO basis
99+
const Parallel_Orbitals &pv, // parallel scheme of NAO basis
100+
elecstate::ElecState* pelec, // eigen values and weights
101+
LCAO_domain::Setup_DM<double> &dmat, // density matrix
102+
Charge &chr, // charge density
103+
const Input_para &inp);
104+
105+
template void LCAO_domain::set_psi_occ_dm_chg<std::complex<double>>(
106+
const K_Vectors &kv, // k-points
107+
psi::Psi<std::complex<double>>* psi, // coefficients of NAO basis
108+
const Parallel_Orbitals &pv, // parallel scheme of NAO basis
109+
elecstate::ElecState* pelec, // eigen values and weights
110+
LCAO_domain::Setup_DM<std::complex<double>> &dmat, // density matrix
111+
Charge &chr, // charge density
112+
const Input_para &inp);
113+
114+
template void LCAO_domain::set_pot<double>(
115+
UnitCell &ucell,
116+
K_Vectors &kv,
117+
Structure_Factor& sf,
118+
const ModulePW::PW_Basis &pw_rho,
119+
const ModulePW::PW_Basis &pw_rhod,
120+
elecstate::ElecState* pelec,
121+
const LCAO_Orbitals& orb,
122+
Parallel_Orbitals &pv,
123+
pseudopot_cell_vl &locpp,
124+
Plus_U &dftu,
125+
surchem& solvent,
126+
Exx_NAO<double> &exx_nao,
127+
Setup_DeePKS<double> &deepks,
128+
const Input_para &inp);
129+
130+
template void LCAO_domain::set_pot<std::complex<double>>(
131+
UnitCell &ucell,
132+
K_Vectors &kv,
133+
Structure_Factor& sf,
134+
const ModulePW::PW_Basis &pw_rho,
135+
const ModulePW::PW_Basis &pw_rhod,
136+
elecstate::ElecState* pelec,
137+
const LCAO_Orbitals& orb,
138+
Parallel_Orbitals &pv,
139+
pseudopot_cell_vl &locpp,
140+
Plus_U &dftu,
141+
surchem& solvent,
142+
Exx_NAO<std::complex<double>> &exx_nao,
143+
Setup_DeePKS<std::complex<double>> &deepks,
144+
const Input_para &inp);

source/source_lcao/LCAO_set.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef LCAO_SET_H
22
#define LCAO_SET_H
33

4+
#include "source_cell/unitcell.h"
45
#include "source_cell/klist.h"
56
#include "source_psi/psi.h"
67
#include "source_estate/elecstate.h"
@@ -14,39 +15,44 @@
1415
#include "source_lcao/setup_exx.h"
1516
#include "source_lcao/setup_deepks.h"
1617

18+
namespace LCAO_domain
19+
{
20+
1721
/**
1822
* @brief set up wave functions, occupation numbers,
1923
* density matrix and charge density
2024
*/
2125
template <typename TK>
22-
void LCAO_domain::set_psi_occ_dm_chg(
26+
void set_psi_occ_dm_chg(
2327
const K_Vectors &kv, // k-points
2428
psi::Psi<TK>* psi, // coefficients of NAO basis
2529
const Parallel_Orbitals &pv, // parallel scheme of NAO basis
2630
elecstate::ElecState* pelec, // eigen values and weights
2731
LCAO_domain::Setup_DM<TK> &dmat, // density matrix
2832
Charge &chr, // charge density
29-
const Input_para& inp) // input parameters
33+
const Input_para& inp); // input parameters
3034

3135
/**
3236
* @brief set up potentials, including local pseudopotentials,
3337
* +U potential, solvent potential, exx potential and deepks potential
3438
*/
3539
template <typename TK>
36-
void LCAO_domain::set_pot(
37-
const K_Vectors &kv,
38-
const Structure_Factor& sf,
40+
void set_pot(
41+
UnitCell &ucell,
42+
K_Vectors &kv,
43+
Structure_Factor& sf,
3944
const ModulePW::PW_Basis &pw_rho,
4045
const ModulePW::PW_Basis &pw_rhod,
4146
elecstate::ElecState* pelec,
4247
const LCAO_Orbitals& orb,
43-
const Parallel_Orbitals &pv,
48+
Parallel_Orbitals &pv,
4449
pseudopot_cell_vl &locpp,
4550
Plus_U &dftu,
4651
surchem& solvent,
47-
Exx_NAO<T> &exx_nao,
48-
Setup_DeePKS<T> &deepks,
52+
Exx_NAO<TK> &exx_nao,
53+
Setup_DeePKS<TK> &deepks,
4954
const Input_para &inp);
5055

56+
} // end namespace
5157

5258
#endif

0 commit comments

Comments
 (0)