88
99template <typename T, typename Device>
1010void pw::setup_pot (const int istep,
11- UnitCell& ucell, // unitcell
12- const K_Vectors &kv, // kpoints
11+ UnitCell& ucell, // unitcell
12+ const K_Vectors &kv, // kpoints
1313 Structure_Factor &sf, // structure factors
14- elecstate::ElecState *pelec, // pointer of electrons
15- const Parallel_Grid ¶_grid, // parallel of FFT grids
16- const Charge &chr, // charge density
17- pseudopot_cell_vl &locpp, // local pseudopotentials
18- pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
14+ elecstate::ElecState *pelec, // pointer of electrons
15+ const Parallel_Grid ¶_grid, // parallel of FFT grids
16+ const Charge &chr, // charge density
17+ pseudopot_cell_vl &locpp, // local pseudopotentials
18+ pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
1919 Plus_U &dftu, // mohan add 2025-11-06
20- VSep* vsep_cell, // U-1/2 method
21- psi::Psi<T, Device>* kspw_psi, // electronic wave functions
22- hamilt::Hamilt<T, Device> * p_hamilt, // hamiltonian
23- ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
24- const ModulePW::PW_Basis *pw_rhod, // pw for rhod
25- const Input_para& inp) // input parameters
20+ VSep* vsep_cell, // U-1/2 method
21+ psi::Psi<T, Device>* kspw_psi, // electronic wave functions
22+ hamilt::HamiltBase * p_hamilt, // hamiltonian
23+ ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
24+ const ModulePW::PW_Basis *pw_rhod, // pw for rhod
25+ const Input_para& inp) // input parameters
2626{
2727 ModuleBase::TITLE (" pw" , " setup_pot" );
2828
@@ -41,48 +41,48 @@ void pw::setup_pot(const int istep,
4141 pelec->init_scf (ucell, para_grid, sf.strucFac ,
4242 locpp.numeric , ucell.symm , (void *)pw_wfc);
4343
44- // ----------------------------------------------------------
45- // ! 2) Symmetrize the charge density (rho)
46- // ----------------------------------------------------------
47-
48- // ! Symmetry_rho should behind init_scf, because charge should be
49- // ! initialized first. liuyu comment: Symmetry_rho should be
50- // ! located between init_rho and v_of_rho?
51- Symmetry_rho srho;
52- for (int is = 0 ; is < inp.nspin ; is++)
53- {
54- srho.begin (is, chr, pw_rhod, ucell.symm );
55- }
56-
57- // ----------------------------------------------------------
58- // ! 3) Calculate the effective potential with rho
59- // ----------------------------------------------------------
60- // ! liuyu move here 2023-10-09
61- // ! D in uspp need vloc, thus behind init_scf()
62- // ! calculate the effective coefficient matrix
63- // ! for non-local pseudopotential projectors
64- ModuleBase::matrix veff = pelec->pot ->get_eff_v ();
65-
66- ppcell.cal_effective_D (veff, pw_rhod, ucell);
67-
68- // ----------------------------------------------------------
69- // ! 4) Onsite projectors
70- // ----------------------------------------------------------
71- if (PARAM.inp .onsite_radius > 0 )
72- {
73- auto * onsite_p = projectors::OnsiteProjector<double , Device>::get_instance ();
74- onsite_p->init (PARAM.inp .orbital_dir ,
75- &ucell,
76- *(kspw_psi),
77- kv,
78- *(pw_wfc),
79- sf,
80- PARAM.inp .onsite_radius ,
81- PARAM.globalv .nqx ,
82- PARAM.globalv .dq ,
83- pelec->wg ,
84- pelec->ekb );
85- }
44+ // ----------------------------------------------------------
45+ // ! 2) Symmetrize the charge density (rho)
46+ // ----------------------------------------------------------
47+
48+ // ! Symmetry_rho should behind init_scf, because charge should be
49+ // ! initialized first. liuyu comment: Symmetry_rho should be
50+ // ! located between init_rho and v_of_rho?
51+ Symmetry_rho srho;
52+ for (int is = 0 ; is < inp.nspin ; is++)
53+ {
54+ srho.begin (is, chr, pw_rhod, ucell.symm );
55+ }
56+
57+ // ----------------------------------------------------------
58+ // ! 3) Calculate the effective potential with rho
59+ // ----------------------------------------------------------
60+ // ! liuyu move here 2023-10-09
61+ // ! D in uspp need vloc, thus behind init_scf()
62+ // ! calculate the effective coefficient matrix
63+ // ! for non-local pseudopotential projectors
64+ ModuleBase::matrix veff = pelec->pot ->get_eff_v ();
65+
66+ ppcell.cal_effective_D (veff, pw_rhod, ucell);
67+
68+ // ----------------------------------------------------------
69+ // ! 4) Onsite projectors
70+ // ----------------------------------------------------------
71+ if (PARAM.inp .onsite_radius > 0 )
72+ {
73+ auto * onsite_p = projectors::OnsiteProjector<double , Device>::get_instance ();
74+ onsite_p->init (PARAM.inp .orbital_dir ,
75+ &ucell,
76+ *(kspw_psi),
77+ kv,
78+ *(pw_wfc),
79+ sf,
80+ PARAM.inp .onsite_radius ,
81+ PARAM.globalv .nqx ,
82+ PARAM.globalv .dq ,
83+ pelec->wg ,
84+ pelec->ekb );
85+ }
8686
8787 // ----------------------------------------------------------
8888 // ! 5) Spin-constrained algorithms
@@ -126,77 +126,77 @@ void pw::setup_pot(const int istep,
126126
127127template void pw::setup_pot<std::complex <float >, base_device::DEVICE_CPU>(
128128 const int istep, // ionic step
129- UnitCell& ucell, // unitcell
130- const K_Vectors &kv, // kpoints
129+ UnitCell& ucell, // unitcell
130+ const K_Vectors &kv, // kpoints
131131 Structure_Factor &sf, // structure factors
132- elecstate::ElecState *pelec, // pointer of electrons
133- const Parallel_Grid ¶_grid, // parallel of FFT grids
134- const Charge &chr, // charge density
135- pseudopot_cell_vl &locpp, // local pseudopotentials
136- pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
132+ elecstate::ElecState *pelec, // pointer of electrons
133+ const Parallel_Grid ¶_grid, // parallel of FFT grids
134+ const Charge &chr, // charge density
135+ pseudopot_cell_vl &locpp, // local pseudopotentials
136+ pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
137137 Plus_U &dftu, // mohan add 2025-11-06
138- VSep* vsep_cell, // U-1/2 method
139- psi::Psi<std::complex <float >, base_device::DEVICE_CPU>* kspw_psi, // electronic wave functions
140- hamilt::Hamilt<std:: complex < float >, base_device::DEVICE_CPU> * p_hamilt, // hamiltonian
141- ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
142- const ModulePW::PW_Basis *pw_rhod, // pw for rhod
143- const Input_para& inp); // input parameters
138+ VSep* vsep_cell, // U-1/2 method
139+ psi::Psi<std::complex <float >, base_device::DEVICE_CPU>* kspw_psi, // electronic wave functions
140+ hamilt::HamiltBase * p_hamilt, // hamiltonian
141+ ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
142+ const ModulePW::PW_Basis *pw_rhod, // pw for rhod
143+ const Input_para& inp); // input parameters
144144
145145
146146template void pw::setup_pot<std::complex <double >, base_device::DEVICE_CPU>(
147147 const int istep, // ionic step
148- UnitCell& ucell, // unitcell
149- const K_Vectors &kv, // kpoints
148+ UnitCell& ucell, // unitcell
149+ const K_Vectors &kv, // kpoints
150150 Structure_Factor &sf, // structure factors
151- elecstate::ElecState *pelec, // pointer of electrons
152- const Parallel_Grid ¶_grid, // parallel of FFT grids
153- const Charge &chr, // charge density
154- pseudopot_cell_vl &locpp, // local pseudopotentials
155- pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
151+ elecstate::ElecState *pelec, // pointer of electrons
152+ const Parallel_Grid ¶_grid, // parallel of FFT grids
153+ const Charge &chr, // charge density
154+ pseudopot_cell_vl &locpp, // local pseudopotentials
155+ pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
156156 Plus_U &dftu, // mohan add 2025-11-06
157- VSep* vsep_cell, // U-1/2 method
158- psi::Psi<std::complex <double >, base_device::DEVICE_CPU>* kspw_psi, // electronic wave functions
159- hamilt::Hamilt<std:: complex < double >, base_device::DEVICE_CPU> * p_hamilt, // hamiltonian
160- ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
161- const ModulePW::PW_Basis *pw_rhod, // pw for rhod
162- const Input_para& inp); // input parameters
157+ VSep* vsep_cell, // U-1/2 method
158+ psi::Psi<std::complex <double >, base_device::DEVICE_CPU>* kspw_psi, // electronic wave functions
159+ hamilt::HamiltBase * p_hamilt, // hamiltonian
160+ ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
161+ const ModulePW::PW_Basis *pw_rhod, // pw for rhod
162+ const Input_para& inp); // input parameters
163163
164164#if ((defined __CUDA) || (defined __ROCM))
165165
166166template void pw::setup_pot<std::complex <float >, base_device::DEVICE_GPU>(
167167 const int istep, // ionic step
168- UnitCell& ucell, // unitcell
169- const K_Vectors &kv, // kpoints
168+ UnitCell& ucell, // unitcell
169+ const K_Vectors &kv, // kpoints
170170 Structure_Factor &sf, // structure factors
171- elecstate::ElecState *pelec, // pointer of electrons
172- const Parallel_Grid ¶_grid, // parallel of FFT grids
173- const Charge &chr, // charge density
174- pseudopot_cell_vl &locpp, // local pseudopotentials
175- pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
171+ elecstate::ElecState *pelec, // pointer of electrons
172+ const Parallel_Grid ¶_grid, // parallel of FFT grids
173+ const Charge &chr, // charge density
174+ pseudopot_cell_vl &locpp, // local pseudopotentials
175+ pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
176176 Plus_U &dftu, // mohan add 2025-11-06
177- VSep* vsep_cell, // U-1/2 method
178- psi::Psi<std::complex <float >, base_device::DEVICE_GPU>* kspw_psi, // electronic wave functions
179- hamilt::Hamilt<std:: complex < float >, base_device::DEVICE_GPU> * p_hamilt, // hamiltonian
180- ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
181- const ModulePW::PW_Basis *pw_rhod, // pw for rhod
182- const Input_para& inp); // input parameters
177+ VSep* vsep_cell, // U-1/2 method
178+ psi::Psi<std::complex <float >, base_device::DEVICE_GPU>* kspw_psi, // electronic wave functions
179+ hamilt::HamiltBase * p_hamilt, // hamiltonian
180+ ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
181+ const ModulePW::PW_Basis *pw_rhod, // pw for rhod
182+ const Input_para& inp); // input parameters
183183
184184template void pw::setup_pot<std::complex <double >, base_device::DEVICE_GPU>(
185185 const int istep, // ionic step
186- UnitCell& ucell, // unitcell
187- const K_Vectors &kv, // kpoints
186+ UnitCell& ucell, // unitcell
187+ const K_Vectors &kv, // kpoints
188188 Structure_Factor &sf, // structure factors
189- elecstate::ElecState *pelec, // pointer of electrons
190- const Parallel_Grid ¶_grid, // parallel of FFT grids
191- const Charge &chr, // charge density
192- pseudopot_cell_vl &locpp, // local pseudopotentials
193- pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
189+ elecstate::ElecState *pelec, // pointer of electrons
190+ const Parallel_Grid ¶_grid, // parallel of FFT grids
191+ const Charge &chr, // charge density
192+ pseudopot_cell_vl &locpp, // local pseudopotentials
193+ pseudopot_cell_vnl &ppcell, // non-local pseudopotentials
194194 Plus_U &dftu, // mohan add 2025-11-06
195- VSep* vsep_cell, // U-1/2 method
196- psi::Psi<std::complex <double >, base_device::DEVICE_GPU>* kspw_psi, // electronic wave functions
197- hamilt::Hamilt<std:: complex < double >, base_device::DEVICE_GPU> * p_hamilt, // hamiltonian
198- ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
199- const ModulePW::PW_Basis *pw_rhod, // pw for rhod
200- const Input_para& inp); // input parameters
195+ VSep* vsep_cell, // U-1/2 method
196+ psi::Psi<std::complex <double >, base_device::DEVICE_GPU>* kspw_psi, // electronic wave functions
197+ hamilt::HamiltBase * p_hamilt, // hamiltonian
198+ ModulePW::PW_Basis_K *pw_wfc, // pw for wfc
199+ const ModulePW::PW_Basis *pw_rhod, // pw for rhod
200+ const Input_para& inp); // input parameters
201201
202202#endif
0 commit comments