Skip to content

Commit f37dd62

Browse files
committed
add ctrl_runner_lcao, but cannot run
1 parent ca5bf78 commit f37dd62

File tree

4 files changed

+215
-110
lines changed

4 files changed

+215
-110
lines changed

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 25 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -377,103 +377,34 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
377377

378378
const int nspin0 = (PARAM.inp.nspin == 2) ? 2 : 1;
379379

380-
// 1) write projected band structure
381-
if (PARAM.inp.out_proj_band)
382-
{
383-
ModuleIO::write_proj_band_lcao(this->psi, this->pv, this->pelec, this->kv, ucell, this->p_hamilt);
384-
}
385-
386-
// 2) out ldos
387-
if (PARAM.inp.out_ldos[0])
388-
{
389-
ModuleIO::Cal_ldos<TK>::cal_ldos_lcao(reinterpret_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec),
390-
this->psi[0],
391-
this->Pgrid,
392-
ucell);
393-
}
394-
395-
// 3) print out exchange-correlation potential
396-
if (PARAM.inp.out_mat_xc)
397-
{
398-
ModuleIO::write_Vxc<TK, TR>(PARAM.inp.nspin,
399-
PARAM.globalv.nlocal,
400-
GlobalV::DRANK,
401-
&this->pv,
402-
*this->psi,
403-
ucell,
404-
this->sf,
405-
this->solvent,
406-
*this->pw_rho,
407-
*this->pw_rhod,
408-
this->locpp.vloc,
409-
this->chr,
410-
this->GG,
411-
this->GK,
412-
this->kv,
413-
orb_.cutoffs(),
414-
this->pelec->wg,
415-
this->gd
416-
#ifdef __EXX
417-
,
418-
this->exd ? &this->exd->get_Hexxs() : nullptr,
419-
this->exc ? &this->exc->get_Hexxs() : nullptr
420-
#endif
421-
);
422-
}
423-
424-
if (PARAM.inp.out_mat_xc2)
425-
{
426-
ModuleIO::write_Vxc_R<TK, TR>(PARAM.inp.nspin,
427-
&this->pv,
428-
ucell,
429-
this->sf,
430-
this->solvent,
431-
*this->pw_rho,
432-
*this->pw_rhod,
433-
this->locpp.vloc,
434-
this->chr,
435-
this->GG,
436-
this->GK,
437-
this->kv,
438-
orb_.cutoffs(),
439-
this->gd
440-
#ifdef __EXX
441-
,
442-
this->exd ? &this->exd->get_Hexxs() : nullptr,
443-
this->exc ? &this->exc->get_Hexxs() : nullptr
380+
auto* estate = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec);
381+
auto* hamilt_lcao = dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt);
382+
383+
if(!estate)
384+
{
385+
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::after_all_runners","pelec does not exist");
386+
}
387+
388+
if(!hamilt_lcao)
389+
{
390+
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::after_all_runners","p_hamilt does not exist");
391+
}
392+
393+
ModuleIO::ctrl_runner_lcao<TK, TR>(ucell,
394+
PARAM.inp, this->kv, estate, this->pv,
395+
this->gd, this->psi, hamilt_lcao,
396+
this->two_center_bundle_, this->GK,
397+
this->orb_, this->pw_wfc, this->pw_rho,
398+
this->GridT, this->pw_big, this->sf,
399+
this->rdmft_solver,
400+
#ifdef __MLALGO
401+
this->ld,
444402
#endif
445-
);
446-
}
447-
448-
// write eband terms
449-
if (PARAM.inp.out_eband_terms)
450-
{
451-
ModuleIO::write_eband_terms<TK, TR>(PARAM.inp.nspin,
452-
PARAM.globalv.nlocal,
453-
GlobalV::DRANK,
454-
&this->pv,
455-
*this->psi,
456-
ucell,
457-
this->sf,
458-
this->solvent,
459-
*this->pw_rho,
460-
*this->pw_rhod,
461-
this->locpp.vloc,
462-
this->chr,
463-
this->GG,
464-
this->GK,
465-
this->kv,
466-
this->pelec->wg,
467-
this->gd,
468-
orb_.cutoffs(),
469-
this->two_center_bundle_
470403
#ifdef __EXX
471-
,
472-
this->exd ? &this->exd->get_Hexxs() : nullptr,
473-
this->exc ? &this->exc->get_Hexxs() : nullptr
404+
*this->exd,
405+
*this->exc,
474406
#endif
475-
);
476-
}
407+
istep);
477408

478409
ModuleBase::timer::tick("ESolver_KS_LCAO", "after_all_runners");
479410
}

source/source_esolver/lcao_after_scf.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,12 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep, const
5555
if (out_flag)
5656
{
5757
ModuleIO::ctrl_scf_lcao<TK, TR>(ucell,
58-
PARAM.inp,
59-
this->kv,
60-
estate,
61-
this->pv,
62-
this->gd,
63-
this->psi,
64-
hamilt_lcao,
65-
this->two_center_bundle_,
66-
this->GK,
67-
this->orb_,
68-
this->pw_wfc,
69-
this->pw_rho,
70-
this->GridT,
71-
this->pw_big,
72-
this->sf,
73-
this->rdmft_solver,
58+
PARAM.inp, this->kv, estate, this->pv,
59+
this->gd, this->psi, hamilt_lcao,
60+
this->two_center_bundle_, this->GK,
61+
this->orb_, this->pw_wfc, this->pw_rho,
62+
this->GridT, this->pw_big, this->sf,
63+
this->rdmft_solver,
7464
#ifdef __MLALGO
7565
this->ld,
7666
#endif
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#include "source_io/ctrl_runner_lcao.h" // use ctrl_runner_lcao()
2+
3+
#include "source_estate/elecstate_lcao.h" // use elecstate::ElecState
4+
#include "source_lcao/hamilt_lcao.h" // use hamilt::HamiltLCAO<TK, TR>
5+
6+
// functions
7+
#ifdef __EXX
8+
#include "source_lcao/module_ri/Exx_LRI_interface.h" // use EXX codes
9+
#include "source_lcao/module_ri/RPA_LRI.h" // use RPA code
10+
#endif
11+
12+
namespace ModuleIO
13+
{
14+
15+
template <typename TK, typename TR>
16+
void ctrl_runner_lcao(UnitCell& ucell, // unitcell
17+
Input_para &inp, // input
18+
K_Vectors &kv, // k-point
19+
elecstate::ElecStateLCAO<TK>* pelec,// electronic info
20+
Parallel_Orbitals &pv, // orbital info
21+
Parallel_Grid &pgrid, // grid info
22+
Grid_Driver &gd, // search for adjacent atoms
23+
psi::Psi<TK>* psi, // wave function
24+
Charge &chr, // charge density
25+
hamilt::HamiltLCAO<TK, TR>* p_hamilt, // hamiltonian
26+
TwoCenterBundle &two_center_bundle, // use two-center integration
27+
Gint_Gamma &gg, // gint for Gamma-only
28+
Gint_k &gk, // gint for multi k-points
29+
LCAO_Orbitals &orb, // LCAO orbitals
30+
ModulePW::PW_Basis* pw_rho, // charge density
31+
ModulePW::PW_Basis* pw_rhod, // dense charge density
32+
Structure_Factor &sf, // structure factor
33+
ModuleBase::matrix &vloc, // local pseudopotential
34+
#ifdef __EXX
35+
Exx_LRI_Interface<TK, double>& exd,
36+
Exx_LRI_Interface<TK, std::complex<double>>& exc,
37+
#endif
38+
surchem &solvent) // solvent model
39+
{
40+
ModuleBase::TITLE("ModuleIO", "ctrl_runner_lcao");
41+
ModuleBase::timer::tick("ModuleIO", "ctrl_runner_lcao");
42+
43+
// 1) write projected band structure
44+
if (inp.out_proj_band)
45+
{
46+
ModuleIO::write_proj_band_lcao(psi, pv, pelec, kv, ucell, p_hamilt);
47+
}
48+
49+
// 2) out ldos
50+
if (inp.out_ldos[0])
51+
{
52+
ModuleIO::Cal_ldos<TK>::cal_ldos_lcao(estate, psi[0], pgrid, ucell);
53+
}
54+
55+
// 3) print out exchange-correlation potential
56+
if (inp.out_mat_xc)
57+
{
58+
ModuleIO::write_Vxc<TK, TR>(inp.nspin,
59+
PARAM.globalv.nlocal,
60+
GlobalV::DRANK,
61+
&pv,
62+
*psi,
63+
ucell,
64+
sf,
65+
solvent,
66+
*pw_rho,
67+
*pw_rhod,
68+
vloc,
69+
chr,
70+
gg,
71+
gk,
72+
kv,
73+
orb.cutoffs(),
74+
pelec->wg,
75+
gd
76+
#ifdef __EXX
77+
,
78+
exd ? &exd->get_Hexxs() : nullptr,
79+
exc ? &exc->get_Hexxs() : nullptr
80+
#endif
81+
);
82+
}
83+
84+
if (inp.out_mat_xc2)
85+
{
86+
ModuleIO::write_Vxc_R<TK, TR>(inp.nspin,
87+
&pv,
88+
ucell,
89+
sf,
90+
solvent,
91+
*pw_rho,
92+
*pw_rhod,
93+
vloc,
94+
chr,
95+
gg,
96+
gk,
97+
kv,
98+
orb.cutoffs(),
99+
gd
100+
#ifdef __EXX
101+
,
102+
exd ? &exd->get_Hexxs() : nullptr,
103+
exc ? &exc->get_Hexxs() : nullptr
104+
#endif
105+
);
106+
}
107+
108+
109+
// write eband terms
110+
if (inp.out_eband_terms)
111+
{
112+
ModuleIO::write_eband_terms<TK, TR>(inp.nspin,
113+
PARAM.globalv.nlocal,
114+
GlobalV::DRANK,
115+
&pv,
116+
*psi,
117+
ucell,
118+
sf,
119+
solvent,
120+
*pw_rho,
121+
*pw_rhod,
122+
vloc,
123+
chr,
124+
gg,
125+
gk,
126+
kv,
127+
pelec->wg,
128+
gd,
129+
orb_.cutoffs(),
130+
two_center_bundle_
131+
#ifdef __EXX
132+
,
133+
exd ? &exd->get_Hexxs() : nullptr,
134+
exc ? &exc->get_Hexxs() : nullptr
135+
#endif
136+
);
137+
}
138+
139+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifndef CTRL_RUNNER_LCAO_H
2+
#define CTRL_RUNNER_LCAO_H
3+
4+
#include "source_cell/unitcell.h" // use UnitCell
5+
#include "source_cell/klist.h" // use K_Vectors
6+
#include "source_estate/elecstate_lcao.h" // use elecstate::ElecStateLCAO<TK>
7+
#include "source_psi/psi.h" // use Psi<TK>
8+
#include "source_lcao/hamilt_lcao.h" // use hamilt::HamiltLCAO<TK, TR>
9+
#include "source_basis/module_nao/two_center_bundle.h" // use TwoCenterBundle
10+
#include "source_lcao/module_gint/gint_k.h" // use Gint_k
11+
#ifdef __EXX
12+
#include "source_lcao/module_ri/Exx_LRI_interface.h" // use EXX codes
13+
#endif
14+
15+
namespace ModuleIO
16+
{
17+
18+
template <typename TK, typename TR>
19+
void ctrl_runner_lcao(UnitCell& ucell, // unitcell
20+
Input_para &inp, // input
21+
K_Vectors &kv, // k-point
22+
elecstate::ElecStateLCAO<TK>* pelec,// electronic info
23+
Parallel_Orbitals &pv, // orbital info
24+
Parallel_Grid &pgrid, // grid info
25+
Grid_Driver &gd, // search for adjacent atoms
26+
psi::Psi<TK>* psi, // wave function
27+
Charge &chr, // charge density
28+
hamilt::HamiltLCAO<TK, TR>* p_hamilt, // hamiltonian
29+
TwoCenterBundle &two_center_bundle, // use two-center integration
30+
Gint_Gamma &gg, // gint for Gamma-only
31+
Gint_k &gk, // gint for multi k-points
32+
LCAO_Orbitals &orb, // LCAO orbitals
33+
ModulePW::PW_Basis* pw_rho, // charge density
34+
ModulePW::PW_Basis* pw_rhod, // dense charge density
35+
Structure_Factor &sf, // structure factor
36+
ModuleBase::matrix &vloc, // local pseudopotential
37+
#ifdef __EXX
38+
Exx_LRI_Interface<TK, double>& exd,
39+
Exx_LRI_Interface<TK, std::complex<double>>& exc,
40+
#endif
41+
surchem &solvent); // solvent model
42+
43+
}
44+
45+
#endif

0 commit comments

Comments
 (0)