11#include " hamilt_pw.h"
22
3- #include " source_io/module_parameter/parameter.h"
4- #include " source_base/global_function.h"
5- #include " source_base/global_variable.h"
6- #include " source_base/parallel_reduce.h"
7-
8- #include " op_pw_veff.h"
93#include " op_pw_ekin.h"
4+ #include " op_pw_exx.h"
105#include " op_pw_meta.h"
116#include " op_pw_nl.h"
127#include " op_pw_proj.h"
13- #include " op_pw_exx.h"
8+ #include " op_pw_veff.h"
9+ #include " source_base/global_function.h"
10+ #include " source_base/global_variable.h"
11+ #include " source_base/parallel_reduce.h"
1412#include " source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info
13+ #include " source_io/module_parameter/parameter.h"
1514
1615namespace hamilt
1716{
@@ -22,7 +21,8 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
2221 K_Vectors* pkv,
2322 pseudopot_cell_vnl* nlpp,
2423 Plus_U* p_dftu, // mohan add 2025-11-06
25- const UnitCell* ucell): ucell(ucell)
24+ const UnitCell* ucell)
25+ : ucell(ucell)
2626{
2727 this ->classname = " HamiltPW" ;
2828 this ->ppcell = nlpp;
@@ -39,7 +39,7 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
3939 // Operator<double>* ekinetic = new Ekinetic<OperatorLCAO<double>>
4040 Operator<T, Device>* ekinetic
4141 = new Ekinetic<OperatorPW<T, Device>>(tpiba2, gk2, wfc_basis->nks , wfc_basis->npwk_max );
42- if (this ->ops == nullptr )
42+ if (this ->ops == nullptr )
4343 {
4444 this ->ops = ekinetic;
4545 }
@@ -59,7 +59,7 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
5959 {
6060 pot_register_in.push_back (" hartree" );
6161 }
62- // no variable can choose xc, maybe it is necessary
62+ // no variable can choose xc, maybe it is necessary
6363 pot_register_in.push_back (" xc" );
6464 if (PARAM .inp .imp_sol )
6565 {
@@ -78,20 +78,21 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
7878 pot_register_in.push_back (" ml_exx" );
7979 }
8080 // DFT-1/2
81- if (PARAM .inp .dfthalf_type == 1 ) {
81+ if (PARAM .inp .dfthalf_type == 1 )
82+ {
8283 pot_register_in.push_back (" dfthalf" );
8384 }
84- // only Potential is not empty, Veff and Meta are available
85- if (pot_register_in.size ()> 0 )
85+ // only Potential is not empty, Veff and Meta are available
86+ if (pot_register_in.size () > 0 )
8687 {
87- // register Potential by gathered operator
88+ // register Potential by gathered operator
8889 pot_in->pot_register (pot_register_in);
8990 Operator<T, Device>* veff = new Veff<OperatorPW<T, Device>>(isk,
9091 pot_in->get_veff_smooth_data <Real>(),
9192 pot_in->get_veff_smooth ().nr ,
9293 pot_in->get_veff_smooth ().nc ,
9394 wfc_basis);
94- if (this ->ops == nullptr )
95+ if (this ->ops == nullptr )
9596 {
9697 this ->ops = veff;
9798 }
@@ -110,9 +111,8 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
110111 }
111112 if (PARAM .inp .vnl_in_h )
112113 {
113- Operator<T, Device>* nonlocal
114- = new Nonlocal<OperatorPW<T, Device>>(isk, this ->ppcell , ucell, wfc_basis);
115- if (this ->ops == nullptr )
114+ Operator<T, Device>* nonlocal = new Nonlocal<OperatorPW<T, Device>>(isk, this ->ppcell , ucell, wfc_basis);
115+ if (this ->ops == nullptr )
116116 {
117117 this ->ops = nonlocal;
118118 }
@@ -121,11 +121,13 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
121121 this ->ops ->add (nonlocal);
122122 }
123123 }
124- if (PARAM .inp .sc_mag_switch || PARAM .inp .dft_plus_u )
124+ if (PARAM .inp .sc_mag_switch || PARAM .inp .dft_plus_u )
125125 {
126- Operator<T, Device>* onsite_proj
127- = new OnsiteProj<OperatorPW<T, Device>>(isk, ucell, p_dftu,
128- PARAM .inp .sc_mag_switch , (PARAM .inp .dft_plus_u >0 ));
126+ Operator<T, Device>* onsite_proj = new OnsiteProj<OperatorPW<T, Device>>(isk,
127+ ucell,
128+ p_dftu,
129+ PARAM .inp .sc_mag_switch ,
130+ (PARAM .inp .dft_plus_u > 0 ));
129131 this ->ops ->add (onsite_proj);
130132 }
131133 if (GlobalC::exx_info.info_global .cal_exx )
@@ -144,97 +146,21 @@ HamiltPW<T, Device>::HamiltPW(elecstate::Potential* pot_in,
144146 return ;
145147}
146148
147- template <typename T, typename Device>
149+ template <typename T, typename Device>
148150HamiltPW<T, Device>::~HamiltPW ()
149151{
150- if (this ->ops != nullptr )
152+ if (this ->ops != nullptr )
151153 {
152154 delete this ->ops ;
153155 }
154156}
155157
156- template <typename T, typename Device>
158+ template <typename T, typename Device>
157159void HamiltPW<T, Device>::updateHk(const int ik)
158160{
159- ModuleBase::TITLE (" HamiltPW" ," updateHk" );
161+ ModuleBase::TITLE (" HamiltPW" , " updateHk" );
160162 this ->ops ->init (ik);
161- ModuleBase::TITLE (" HamiltPW" ," updateHk" );
162- }
163-
164- template <typename T, typename Device>
165- template <typename T_in, typename Device_in>
166- HamiltPW<T, Device>::HamiltPW(const HamiltPW<T_in, Device_in> *hamilt)
167- {
168- this ->classname = hamilt->classname ;
169- this ->ppcell = hamilt->ppcell ;
170- this ->qq_nt = hamilt->qq_nt ;
171- this ->qq_so = hamilt->qq_so ;
172- this ->vkb = hamilt->vkb ;
173- OperatorPW<std::complex <T_in>, Device_in> * node =
174- reinterpret_cast <OperatorPW<std::complex <T_in>, Device_in> *>(hamilt->ops );
175-
176- while (node != nullptr ) {
177- if (node->classname == " Ekinetic" ) {
178- Operator<T, Device>* ekinetic =
179- new Ekinetic<OperatorPW<T, Device>>(
180- reinterpret_cast <const Ekinetic<OperatorPW<T_in, Device_in>>*>(node));
181- if (this ->ops == nullptr ) {
182- this ->ops = ekinetic;
183- }
184- else {
185- this ->ops ->add (ekinetic);
186- }
187- // this->ops = reinterpret_cast<Operator<T, Device>*>(node);
188- }
189- else if (node->classname == " Nonlocal" ) {
190- Operator<T, Device>* nonlocal =
191- new Nonlocal<OperatorPW<T, Device>>(
192- reinterpret_cast <const Nonlocal<OperatorPW<T_in, Device_in>>*>(node));
193- if (this ->ops == nullptr ) {
194- this ->ops = nonlocal;
195- }
196- else {
197- this ->ops ->add (nonlocal);
198- }
199- }
200- else if (node->classname == " Veff" ) {
201- Operator<T, Device>* veff =
202- new Veff<OperatorPW<T, Device>>(
203- reinterpret_cast <const Veff<OperatorPW<T_in, Device_in>>*>(node));
204- if (this ->ops == nullptr ) {
205- this ->ops = veff;
206- }
207- else {
208- this ->ops ->add (veff);
209- }
210- }
211- else if (node->classname == " Meta" ) {
212- Operator<T, Device>* meta =
213- new Meta<OperatorPW<T, Device>>(
214- reinterpret_cast <const Meta<OperatorPW<T_in, Device_in>>*>(node));
215- if (this ->ops == nullptr ) {
216- this ->ops = meta;
217- }
218- else {
219- this ->ops ->add (meta);
220- }
221- }
222- else if (node->classname == " OnsiteProj" ) {
223- Operator<T, Device>* onsite_proj =
224- new OnsiteProj<OperatorPW<T, Device>>(
225- reinterpret_cast <const OnsiteProj<OperatorPW<T_in, Device_in>>*>(node));
226- if (this ->ops == nullptr ) {
227- this ->ops = onsite_proj;
228- }
229- else {
230- this ->ops ->add (onsite_proj);
231- }
232- }
233- else {
234- ModuleBase::WARNING_QUIT (" HamiltPW" , " Unrecognized Operator type!" );
235- }
236- node = reinterpret_cast <OperatorPW<std::complex <T_in>, Device_in> *>(node->next_op );
237- }
163+ ModuleBase::TITLE (" HamiltPW" , " updateHk" );
238164}
239165
240166// This routine applies the S matrix to m wavefunctions psi and puts
@@ -390,8 +316,8 @@ void HamiltPW<T, Device>::sPsi(const T* psi_in, // psi
390316 }
391317}
392318
393- template <typename T, typename Device>
394- void HamiltPW<T, Device>::set_exx_helper(Exx_Helper<T, Device> & exx_helper)
319+ template <typename T, typename Device>
320+ void HamiltPW<T, Device>::set_exx_helper(Exx_Helper<T, Device>& exx_helper)
395321{
396322 auto op = this ->ops ;
397323 while (op != nullptr )
@@ -400,7 +326,6 @@ void HamiltPW<T, Device>::set_exx_helper(Exx_Helper<T, Device> &exx_helper)
400326 {
401327 exx_helper.op_exx = reinterpret_cast <OperatorEXXPW<T, Device>*>(op);
402328 exx_helper.set_op ();
403-
404329 }
405330 op = op->next_op ;
406331 }
0 commit comments