11#include " esolver_ks.h"
2- #include " pw_setup.h" // setup plane wave
32
43#include " source_base/timer.h"
54#include " source_base/global_variable.h"
2524
2625#include " source_estate/update_pot.h" // mohan add 20251016
2726#include " source_estate/module_charge/chgmixing.h" // mohan add 20251018
27+ #include " source_pw/module_pwdft/setup_pwwfc.h" // mohan add 20251018
2828
2929namespace ModuleESolver
3030{
@@ -40,10 +40,12 @@ ESolver_KS<T, Device>::~ESolver_KS()
4040 // do not add any codes in this deconstructor funcion
4141 // ****************************************************
4242 delete this ->psi ;
43- delete this ->pw_wfc ;
4443 delete this ->p_hamilt ;
4544 delete this ->p_chgmix ;
4645 this ->ppcell .release_memory ();
46+
47+ // mohan add 2025-10-18, should be put int clean() function
48+ pw::teardown_pwwfc (this ->pw_wfc );
4749}
4850
4951
@@ -65,69 +67,47 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
6567 this ->niter = maxniter;
6668 this ->drho = 0.0 ;
6769
68- std::string fft_device = inp.device ;
69-
70- // ! 3) setup pw_wfc
71- // currently LCAO doesn't support GPU acceleration of FFT
72- if (inp.basis_type == " lcao" )
73- {
74- fft_device = " cpu" ;
75- }
76- std::string fft_precision = inp.precision ;
77- #ifdef __ENABLE_FLOAT_FFTW
78- if (inp.cal_cond && inp.esolver_type == " sdft" )
79- {
80- fft_precision = " mixing" ;
81- }
82- #endif
83-
84- pw_wfc = new ModulePW::PW_Basis_K_Big (fft_device, fft_precision);
85-
86- // for LCAO calculations, we need to set bx, by, and bz
87- ModulePW::PW_Basis_K_Big* tmp = static_cast <ModulePW::PW_Basis_K_Big*>(pw_wfc);
88- tmp->setbxyz (inp.bx , inp.by , inp.bz );
70+ // cell_factor
71+ this ->ppcell .cell_factor = inp.cell_factor ;
8972
90- // ! 4 ) setup charge mixing
73+ // ! 3 ) setup charge mixing
9174 p_chgmix = new Charge_Mixing ();
9275 p_chgmix->set_rhopw (this ->pw_rho , this ->pw_rhod );
9376
94- // cell_factor
95- this ->ppcell .cell_factor = inp.cell_factor ;
96-
9777 ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " SETUP UNITCELL" );
9878
99- // ! 5 ) setup Exc for the first element '0', because all elements have same exc
79+ // ! 4 ) setup Exc for the first element '0', because all elements have same exc
10080 XC_Functional::set_xc_type (ucell.atoms [0 ].ncpp .xc_func );
10181
102- // ! 6 ) setup the charge mixing parameters
82+ // ! 5 ) setup the charge mixing parameters
10383 p_chgmix->set_mixing (inp.mixing_mode , inp.mixing_beta , inp.mixing_ndim ,
10484 inp.mixing_gg0 , inp.mixing_tau , inp.mixing_beta_mag , inp.mixing_gg0_mag ,
10585 inp.mixing_gg0_min , inp.mixing_angle , inp.mixing_dmr , ucell.omega , ucell.tpiba );
10686
10787 p_chgmix->init_mixing ();
10888
109- // ! 7 ) symmetry analysis should be performed every time the cell is changed
89+ // ! 6 ) symmetry analysis should be performed every time the cell is changed
11090 if (ModuleSymmetry::Symmetry::symm_flag == 1 )
11191 {
11292 ucell.symm .analy_sys (ucell.lat , ucell.st , ucell.atoms , GlobalV::ofs_running);
11393 ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " SYMMETRY" );
11494 }
11595
116- // ! 8 ) Setup the k points according to symmetry.
96+ // ! 7 ) Setup the k points according to symmetry.
11797 this ->kv .set (ucell,ucell.symm , inp.kpoint_file , inp.nspin , ucell.G , ucell.latvec , GlobalV::ofs_running);
11898 ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " INIT K-POINTS" );
11999
120- // ! 9 ) print information
100+ // ! 8 ) print information
121101 ModuleIO::print_parameters (ucell, this ->kv , inp);
122102
123- // ! 10 ) setup plane wave for electronic wave functions
124- ModuleESolver::pw_setup (inp, ucell, *this ->pw_rho , this ->kv , * this ->pw_wfc );
103+ // ! 9 ) setup plane wave for electronic wave functions
104+ pw::setup_pwwfc (inp, ucell, *this ->pw_rho , this ->kv , this ->pw_wfc );
125105
126- // ! 11 ) parallel of FFT grid
106+ // ! 10 ) parallel of FFT grid
127107 Pgrid.init (this ->pw_rhod ->nx , this ->pw_rhod ->ny , this ->pw_rhod ->nz ,
128108 this ->pw_rhod ->nplane , this ->pw_rhod ->nrxx , pw_big->nbz , pw_big->bz );
129109
130- // ! 12 ) calculate the structure factor
110+ // ! 11 ) calculate the structure factor
131111 this ->sf .setup_structure_factor (&ucell, Pgrid, this ->pw_rhod );
132112}
133113
0 commit comments