Skip to content

Commit af3955d

Browse files
committed
fix some bugs
1 parent 28ce5d6 commit af3955d

File tree

3 files changed

+49
-33
lines changed

3 files changed

+49
-33
lines changed

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "source_estate/cal_ux.h"
44
#include "source_estate/elecstate_pw.h"
55
#include "source_estate/elecstate_pw_sdft.h"
6-
#include "source_estate/elecstate_tools.h"
76
#include "source_estate/module_charge/symmetry_rho.h"
87

98
#include "source_hsolver/diago_iter_assist.h"
@@ -89,7 +88,7 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
8988
ESolver_KS<T, Device>::before_all_runners(ucell, inp);
9089

9190
//! setup and allocation for pelec, charge density, potentials, etc.
92-
elecstate::setup_estate_pw(ucell, this->kv, this->sf, this->pelec, this->chr,
91+
elecstate::setup_estate_pw<T, Device>(ucell, this->kv, this->sf, this->pelec, this->chr,
9392
this->locpp, this->ppcell, this->vsep_cell, this->pw_wfc, this->pw_rho,
9493
this->pw_rhod, this->pw_big, this->solvent, inp);
9594

@@ -542,7 +541,7 @@ void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
542541
this->kspw_psi, this->__kspw_psi, this->sf,
543542
this->ppcell, this->solvent, this->ctx, this->Pgrid, PARAM.inp);
544543

545-
elecstate::teardown_estate_pw(this->pelec, this->vsep_cell);
544+
elecstate::teardown_estate_pw<T, Device>(this->pelec, this->vsep_cell);
546545
}
547546

548547
template class ESolver_KS_PW<std::complex<float>, base_device::DEVICE_CPU>;

source/source_estate/setup_estate_pw.cpp

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#include "source_estate/setup_estate_pw.h"
2+
#include "source_estate/elecstate_pw.h" // init of pelec
3+
#include "source_estate/elecstate_pw_sdft.h" // init of pelec for sdft
4+
#include "source_estate/elecstate_tools.h" // occupations
25

36
template <typename T, typename Device>
47
void elecstate::setup_estate_pw(UnitCell& ucell, // unitcell
5-
const K_Vectors &kv, // kpoints
8+
K_Vectors &kv, // kpoints
69
Structure_Factor &sf, // structure factors
710
elecstate::ElecState *pelec, // pointer of electrons
8-
const Charge &chr, // charge density
11+
Charge &chr, // charge density
912
pseudopot_cell_vl &locpp, // local pseudopotentials
1013
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
1114
VSep* vsep_cell, // U-1/2 method
1215
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
13-
const ModulePW::PW_Basis *pw_rho, // pw for rho
14-
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
15-
const ModulePW::PW_Basis_Big* pw_big, // pw for big grid
16+
ModulePW::PW_Basis *pw_rho, // pw for rho
17+
ModulePW::PW_Basis *pw_rhod, // pw for rhod
18+
ModulePW::PW_Basis_Big* pw_big, // pw for big grid
1619
surchem &solvent, // solvent
1720
const Input_para& inp) // input parameters
1821
{
@@ -81,6 +84,7 @@ void elecstate::setup_estate_pw(UnitCell& ucell, // unitcell
8184
}
8285

8386

87+
template <typename T, typename Device>
8488
void elecstate::teardown_estate_pw(elecstate::ElecState *pelec, VSep* vsep_cell)
8589
{
8690
ModuleBase::TITLE("elecstate", "teardown_estate_pw");
@@ -100,70 +104,82 @@ void elecstate::teardown_estate_pw(elecstate::ElecState *pelec, VSep* vsep_cell)
100104

101105
template void elecstate::setup_estate_pw<std::complex<float>, base_device::DEVICE_CPU>(
102106
UnitCell& ucell, // unitcell
103-
const K_Vectors &kv, // kpoints
107+
K_Vectors &kv, // kpoints
104108
Structure_Factor &sf, // structure factors
105109
elecstate::ElecState *pelec, // pointer of electrons
106-
const Charge &chr, // charge density
110+
Charge &chr, // charge density
107111
pseudopot_cell_vl &locpp, // local pseudopotentials
108112
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
109113
VSep* vsep_cell, // U-1/2 method
110114
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
111-
const ModulePW::PW_Basis *pw_rho, // pw for rho
112-
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
113-
const ModulePW::PW_Basis_Big* pw_big, // pw for big grid
115+
ModulePW::PW_Basis *pw_rho, // pw for rho
116+
ModulePW::PW_Basis *pw_rhod, // pw for rhod
117+
ModulePW::PW_Basis_Big* pw_big, // pw for big grid
114118
surchem &solvent, // solvent
115119
const Input_para& inp); // input parameters
116120

117121
template void elecstate::setup_estate_pw<std::complex<double>, base_device::DEVICE_CPU>(
118122
UnitCell& ucell, // unitcell
119-
const K_Vectors &kv, // kpoints
123+
K_Vectors &kv, // kpoints
120124
Structure_Factor &sf, // structure factors
121125
elecstate::ElecState *pelec, // pointer of electrons
122-
const Charge &chr, // charge density
126+
Charge &chr, // charge density
123127
pseudopot_cell_vl &locpp, // local pseudopotentials
124128
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
125129
VSep* vsep_cell, // U-1/2 method
126130
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
127-
const ModulePW::PW_Basis *pw_rho, // pw for rho
128-
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
129-
const ModulePW::PW_Basis_Big* pw_big, // pw for big grid
131+
ModulePW::PW_Basis *pw_rho, // pw for rho
132+
ModulePW::PW_Basis *pw_rhod, // pw for rhod
133+
ModulePW::PW_Basis_Big* pw_big, // pw for big grid
130134
surchem &solvent, // solvent
131135
const Input_para& inp); // input parameters
132136

133137

138+
template void elecstate::teardown_estate_pw<std::complex<float>, base_device::DEVICE_CPU>(
139+
elecstate::ElecState *pelec, VSep* vsep_cell);
140+
141+
template void elecstate::teardown_estate_pw<std::complex<double>, base_device::DEVICE_CPU>(
142+
elecstate::ElecState *pelec, VSep* vsep_cell);
143+
134144

135145
#if ((defined __CUDA) || (defined __ROCM))
136146

137147
template void elecstate::setup_estate_pw<std::complex<float>, base_device::DEVICE_GPU>(
138148
UnitCell& ucell, // unitcell
139-
const K_Vectors &kv, // kpoints
149+
K_Vectors &kv, // kpoints
140150
Structure_Factor &sf, // structure factors
141151
elecstate::ElecState *pelec, // pointer of electrons
142-
const Charge &chr, // charge density
152+
Charge &chr, // charge density
143153
pseudopot_cell_vl &locpp, // local pseudopotentials
144154
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
145155
VSep* vsep_cell, // U-1/2 method
146156
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
147-
const ModulePW::PW_Basis *pw_rho, // pw for rho
148-
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
149-
const ModulePW::PW_Basis_Big* pw_big, // pw for big grid
157+
ModulePW::PW_Basis *pw_rho, // pw for rho
158+
ModulePW::PW_Basis *pw_rhod, // pw for rhod
159+
ModulePW::PW_Basis_Big* pw_big, // pw for big grid
150160
surchem &solvent, // solvent
151161
const Input_para& inp); // input parameters
152162

153163
template void elecstate::setup_estate_pw<std::complex<double>, base_device::DEVICE_GPU>(
154164
UnitCell& ucell, // unitcell
155-
const K_Vectors &kv, // kpoints
165+
K_Vectors &kv, // kpoints
156166
Structure_Factor &sf, // structure factors
157167
elecstate::ElecState *pelec, // pointer of electrons
158-
const Charge &chr, // charge density
168+
Charge &chr, // charge density
159169
pseudopot_cell_vl &locpp, // local pseudopotentials
160170
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
161171
VSep* vsep_cell, // U-1/2 method
162172
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
163-
const ModulePW::PW_Basis *pw_rho, // pw for rho
164-
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
165-
const ModulePW::PW_Basis_Big* pw_big, // pw for big grid
173+
ModulePW::PW_Basis *pw_rho, // pw for rho
174+
ModulePW::PW_Basis *pw_rhod, // pw for rhod
175+
ModulePW::PW_Basis_Big* pw_big, // pw for big grid
166176
surchem &solvent, // solvent
167177
const Input_para& inp); // input parameters
168178

179+
template void elecstate::teardown_estate_pw<std::complex<float>, base_device::DEVICE_GPU>(
180+
elecstate::ElecState *pelec, VSep* vsep_cell);
181+
182+
template void elecstate::teardown_estate_pw<std::complex<double>, base_device::DEVICE_GPU>(
183+
elecstate::ElecState *pelec, VSep* vsep_cell);
184+
169185
#endif

source/source_estate/setup_estate_pw.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ namespace elecstate
1414

1515
template <typename T, typename Device>
1616
void setup_estate_pw(UnitCell& ucell, // unitcell
17-
const K_Vectors &kv, // kpoints
17+
K_Vectors &kv, // kpoints
1818
Structure_Factor &sf, // structure factors
1919
elecstate::ElecState *pelec, // pointer of electrons
20-
const Charge &chr, // charge density
20+
Charge &chr, // charge density
2121
pseudopot_cell_vl &locpp, // local pseudopotentials
2222
pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
2323
VSep* vsep_cell, // U-1/2 method
2424
ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
25-
const ModulePW::PW_Basis *pw_rho, // pw for rho
26-
const ModulePW::PW_Basis *pw_rhod, // pw for rhod
27-
const ModulePW::PW_Basis_Big* pw_big, // pw for big grid
25+
ModulePW::PW_Basis *pw_rho, // pw for rho
26+
ModulePW::PW_Basis *pw_rhod, // pw for rhod
27+
ModulePW::PW_Basis_Big* pw_big, // pw for big grid
2828
surchem &solvent, // solvent
2929
const Input_para& inp); // input parameters
3030

31+
template <typename T, typename Device>
3132
void teardown_estate_pw(elecstate::ElecState *pelec, VSep* vsep_cell);
3233

3334
}

0 commit comments

Comments
 (0)