Skip to content

Commit 632b1c6

Browse files
committed
update esolver_ks_pw, add setup_pot
1 parent 5d2fc35 commit 632b1c6

File tree

6 files changed

+40
-29
lines changed

6 files changed

+40
-29
lines changed

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
255255
//----------------------------------------------------------
256256
// 4) setup potentials (local, non-local, sc, +U, DFT-1/2)
257257
//----------------------------------------------------------
258-
setup_pot(istep, ucell, this->kv, this->sf, this->pelec, this->Pgrid,
258+
pw::setup_pot(istep, ucell, this->kv, this->sf, this->pelec, this->Pgrid,
259259
this->chr, this->locpp, this->ppcell, this->vsep_cell,
260-
this->kspw_psi, this->pw_wfc, this->pw_rhod, PARAM.inp);
260+
this->kspw_psi, this->p_hamilt, this->pw_wfc, this->pw_rhod, PARAM.inp);
261261

262262
//----------------------------------------------------------
263263
//! 5) Initialize wave functions

source/source_lcao/module_deltaspin/init_sc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void spinconstrain::SpinConstrain<FPTYPE>::init_sc(double sc_thr_in,
1111
const UnitCell& ucell,
1212
Parallel_Orbitals* ParaV_in,
1313
int nspin_in,
14-
K_Vectors& kv_in,
14+
const K_Vectors& kv_in,
1515
void* p_hamilt_in,
1616
void* psi_in,
1717
elecstate::ElecState* pelec_in,
@@ -34,4 +34,4 @@ void spinconstrain::SpinConstrain<FPTYPE>::init_sc(double sc_thr_in,
3434
}
3535

3636
template class spinconstrain::SpinConstrain<std::complex<double>>;
37-
template class spinconstrain::SpinConstrain<double>;
37+
template class spinconstrain::SpinConstrain<double>;

source/source_lcao/module_deltaspin/spin_constrain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ double SpinConstrain<FPTYPE>::get_sc_drop_thr()
487487
}
488488

489489
template <typename FPTYPE>
490-
void SpinConstrain<FPTYPE>::set_solver_parameters(K_Vectors& kv_in,
490+
void SpinConstrain<FPTYPE>::set_solver_parameters(const K_Vectors& kv_in,
491491
void* p_hamilt_in,
492492
void* psi_in,
493493
elecstate::ElecState* pelec_in)
@@ -603,4 +603,4 @@ void SpinConstrain<FPTYPE>::print_Mag_Force(std::ofstream& ofs_running)
603603
template class SpinConstrain<std::complex<double>>;
604604
template class SpinConstrain<double>;
605605

606-
} // namespace spinconstrain
606+
} // namespace spinconstrain

source/source_lcao/module_deltaspin/spin_constrain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SpinConstrain
3636
const UnitCell& ucell,
3737
Parallel_Orbitals* ParaV_in,
3838
int nspin_in,
39-
K_Vectors& kv_in,
39+
const K_Vectors& kv_in,
4040
void* p_hamilt_in,
4141
void* psi_in,
4242
elecstate::ElecState* pelec_in,
@@ -201,7 +201,7 @@ class SpinConstrain
201201
/// @brief set orbital parallel info
202202
void set_ParaV(Parallel_Orbitals* ParaV_in);
203203
/// @brief set parameters for solver
204-
void set_solver_parameters(K_Vectors& kv_in,
204+
void set_solver_parameters(const K_Vectors& kv_in,
205205
void* p_hamilt_in,
206206
void* psi_in,
207207
elecstate::ElecState* pelec_in);

source/source_pw/module_pwdft/setup_pot.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "source_pw/module_pwdft/VSep_in_pw.h"
88

99
template <typename T, typename Device>
10-
void setup_pot(const int istep,
10+
void pw::setup_pot(const int istep,
1111
UnitCell& ucell, // unitcell
1212
const K_Vectors &kv, // kpoints
1313
Structure_Factor &sf, // structure factors
@@ -18,7 +18,8 @@ void setup_pot(const int istep,
1818
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
1919
VSep* vsep_cell, // U-1/2 method
2020
psi::Psi<T, Device>* kspw_psi, // electronic wave functions
21-
const ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
21+
hamilt::Hamilt<T, Device>* p_hamilt, // hamiltonian
22+
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
2223
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
2324
const Input_para& inp) // input parameters
2425
{
@@ -28,7 +29,7 @@ void setup_pot(const int istep,
2829
pelec->init_scf(istep,
2930
ucell,
3031
para_grid,
31-
sf,
32+
sf.strucFac,
3233
locpp.numeric,
3334
ucell.symm,
3435
(void*)pw_wfc);
@@ -66,14 +67,14 @@ void setup_pot(const int istep,
6667
onsite_p->init(PARAM.inp.orbital_dir,
6768
&ucell,
6869
*(kspw_psi),
69-
this->kv,
70+
kv,
7071
*(pw_wfc),
71-
this->sf,
72+
sf,
7273
PARAM.inp.onsite_radius,
7374
PARAM.globalv.nqx,
7475
PARAM.globalv.dq,
75-
this->pelec->wg,
76-
this->pelec->ekb);
76+
pelec->wg,
77+
pelec->ekb);
7778
}
7879

7980
//----------------------------------------------------------
@@ -92,11 +93,11 @@ void setup_pot(const int istep,
9293
ucell,
9394
nullptr,
9495
PARAM.inp.nspin,
95-
this->kv,
96-
this->p_hamilt,
97-
this->kspw_psi,
98-
this->pelec,
99-
this->pw_wfc);
96+
kv,
97+
p_hamilt,
98+
kspw_psi,
99+
pelec,
100+
pw_wfc);
100101
}
101102

102103
//----------------------------------------------------------
@@ -105,7 +106,7 @@ void setup_pot(const int istep,
105106
if (PARAM.inp.dft_plus_u)
106107
{
107108
auto* dftu = ModuleDFTU::DFTU::get_instance();
108-
dftu->init(ucell, nullptr, this->kv.get_nks());
109+
dftu->init(ucell, nullptr, kv.get_nks());
109110
}
110111

111112
//----------------------------------------------------------
@@ -114,13 +115,13 @@ void setup_pot(const int istep,
114115
//----------------------------------------------------------
115116
if (PARAM.inp.dfthalf_type > 0)
116117
{
117-
this->vsep_cell->generate_vsep_r(this->pw_rhod[0], this->sf.strucFac, ucell.sep_cell);
118+
vsep_cell->generate_vsep_r(pw_rhod[0], sf.strucFac, ucell.sep_cell);
118119
}
119120

120121
return;
121122
}
122123

123-
template void setup_pot<std::complex<float>, base_device::DEVICE_CPU>(
124+
template void pw::setup_pot<std::complex<float>, base_device::DEVICE_CPU>(
124125
const int istep, // ionic step
125126
UnitCell& ucell, // unitcell
126127
const K_Vectors &kv, // kpoints
@@ -131,13 +132,14 @@ template void setup_pot<std::complex<float>, base_device::DEVICE_CPU>(
131132
pseudopot_cell_vl &locpp, // local pseudopotentials
132133
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
133134
VSep* vsep_cell, // U-1/2 method
134-
psi::Psi<std::complex<float>, base_devcie::DEVICE_CPU>* kspw_psi, // electronic wave functions
135-
const ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
135+
psi::Psi<std::complex<float>, base_device::DEVICE_CPU>* kspw_psi, // electronic wave functions
136+
hamilt::Hamilt<std::complex<float>, base_device::DEVICE_CPU>* p_hamilt, // hamiltonian
137+
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
136138
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
137139
const Input_para& inp); // input parameters
138140

139141

140-
template void setup_pot<std::complex<double>, base_device::DEVICE_CPU>(
142+
template void pw::setup_pot<std::complex<double>, base_device::DEVICE_CPU>(
141143
const int istep, // ionic step
142144
UnitCell& ucell, // unitcell
143145
const K_Vectors &kv, // kpoints
@@ -148,7 +150,8 @@ template void setup_pot<std::complex<double>, base_device::DEVICE_CPU>(
148150
pseudopot_cell_vl &locpp, // local pseudopotentials
149151
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
150152
VSep* vsep_cell, // U-1/2 method
151-
psi::Psi<std::complex<double>, base_devcie::DEVICE_CPU>* kspw_psi, // electronic wave functions
152-
const ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
153+
psi::Psi<std::complex<double>, base_device::DEVICE_CPU>* kspw_psi, // electronic wave functions
154+
hamilt::Hamilt<std::complex<double>, base_device::DEVICE_CPU>* p_hamilt, // hamiltonian
155+
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
153156
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
154157
const Input_para& inp); // input parameters

source/source_pw/module_pwdft/setup_pot.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#ifndef SETUP_POT_H
22
#define SETUP_POT_H
33

4+
#include "source_base/module_device/device.h" // use Device
45
#include "source_cell/unitcell.h"
56
#include "source_cell/klist.h"
67
#include "source_pw/module_pwdft/structure_factor.h"
78
#include "source_estate/elecstate.h"
89
#include "source_pw/module_pwdft/VL_in_pw.h"
10+
#include "source_hamilt/hamilt.h"
11+
12+
namespace pw
13+
{
914

1015
template <typename T, typename Device>
1116
void setup_pot(const int istep,
@@ -19,10 +24,13 @@ void setup_pot(const int istep,
1924
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
2025
VSep* vsep_cell, // U-1/2 method
2126
psi::Psi<T, Device>* kspw_psi, // electronic wave functions
22-
const ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
27+
hamilt::Hamilt<T, Device>* p_hamilt, // hamiltonian
28+
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
2329
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
2430
const Input_para& inp); // input parameters
2531

32+
}
33+
2634

2735

2836
#endif

0 commit comments

Comments
 (0)