diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 02649008c3..7c3628b9ff 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -11,7 +11,6 @@ - [kpar](#kpar) - [bndpar](#bndpar) - [latname](#latname) - - [psi\_initializer](#psi_initializer) - [init\_wfc](#init_wfc) - [init\_chg](#init_chg) - [init\_vel](#init_vel) @@ -93,6 +92,7 @@ - [scf\_os\_stop](#scf_os_stop) - [scf\_os\_thr](#scf_os_thr) - [scf\_os\_ndim](#scf_os_ndim) + - [sc\_os\_ndim](#sc_os_ndim) - [chg\_extrap](#chg_extrap) - [lspinorb](#lspinorb) - [noncolin](#noncolin) @@ -467,7 +467,7 @@ - [abs\_broadening](#abs_broadening) - [ri\_hartree\_benchmark](#ri_hartree_benchmark) - [aims\_nbasis](#aims_nbasis) - - [Reduced Density Matrix Functional Theory](#Reduced-Density-Matrix-Functional-Theory) + - [Reduced Density Matrix Functional Theory](#reduced-density-matrix-functional-theory) - [rdmft](#rdmft) - [rdmft\_power\_alpha](#rdmft_power_alpha) @@ -580,17 +580,6 @@ These variables are used to control general system parameters. - triclinic: triclinic (14) - **Default**: none -### psi_initializer - -- **Type**: Integer -- **Description**: enable the experimental feature psi_initializer, to support use numerical atomic orbitals initialize wavefunction (`basis_type pw` case). - - NOTE: this feature is not well-implemented for `nspin 4` case (closed presently), and cannot use with `calculation nscf`/`esolver_type sdft` cases. - Available options are: - - 0: disable psi_initializer - - 1: enable psi_initializer -- **Default**: 0 - ### init_wfc - **Type**: String @@ -602,8 +591,6 @@ These variables are used to control general system parameters. - atomic+random: add small random numbers on atomic pseudo-wavefunctions - file: from binary files `WAVEFUNC*.dat`, which are output by setting [out_wfc_pw](#out_wfc_pw) to `2`. - random: random numbers - - with `psi_initializer 1`, two more options are supported: - nao: from numerical atomic orbitals. If they are not enough, other wave functions are initialized with random numbers. - nao+random: add small random numbers on numerical atomic orbitals - **Default**: atomic diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 9d2dc62b48..058aff4f36 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -398,6 +398,7 @@ OBJS_PSI=psi.o\ OBJS_PSI_INITIALIZER=psi_initializer.o\ psi_initializer_random.o\ + psi_initializer_file.o\ psi_initializer_atomic.o\ psi_initializer_atomic_random.o\ psi_initializer_nao.o\ @@ -494,6 +495,7 @@ OBJS_IO=input_conv.o\ to_wannier90_lcao.o\ fR_overlap.o\ unk_overlap_pw.o\ + write_pao.o\ write_wfc_pw.o\ winput.o\ write_cube.o\ @@ -669,8 +671,6 @@ OBJS_SRCPW=H_Ewald_pw.o\ of_stress_pw.o\ symmetry_rho.o\ symmetry_rhog.o\ - wavefunc.o\ - wf_atomic.o\ psi_init.o\ elecond.o\ sto_tool.o\ diff --git a/source/module_basis/module_pw/pw_basis_k.cpp b/source/module_basis/module_pw/pw_basis_k.cpp index 079eeaf119..f670ee9bf9 100644 --- a/source/module_basis/module_pw/pw_basis_k.cpp +++ b/source/module_basis/module_pw/pw_basis_k.cpp @@ -22,7 +22,6 @@ PW_Basis_K::~PW_Basis_K() delete[] igl2isz_k; delete[] igl2ig_k; delete[] gk2; - delete[] ig2ixyz_k_; #if defined(__CUDA) || defined(__ROCM) if (this->device == "gpu") { if (this->precision == "single") { @@ -169,6 +168,7 @@ void PW_Basis_K::setupIndGk() syncmem_int_h2d_op()(gpu_ctx, cpu_ctx, this->d_igl2isz_k, this->igl2isz_k, this->npwk_max * this->nks); } #endif + this->get_ig2ixyz_k(); return; } @@ -334,8 +334,12 @@ int& PW_Basis_K::getigl2ig(const int ik, const int igl) const void PW_Basis_K::get_ig2ixyz_k() { - delete[] this->ig2ixyz_k_; - this->ig2ixyz_k_ = new int [this->npwk_max * this->nks]; + if (this->device != "gpu") + { + //only GPU need to get ig2ixyz_k + return; + } + int * ig2ixyz_k_cpu = new int [this->npwk_max * this->nks]; ModuleBase::Memory::record("PW_B_K::ig2ixyz", sizeof(int) * this->npwk_max * this->nks); assert(gamma_only == false); //We only finish non-gamma_only fft on GPU temperarily. for(int ik = 0; ik < this->nks; ++ik) @@ -348,15 +352,12 @@ void PW_Basis_K::get_ig2ixyz_k() int ixy = this->is2fftixy[is]; int iy = ixy % this->ny; int ix = ixy / this->ny; - ig2ixyz_k_[igl + ik * npwk_max] = iz + iy * nz + ix * ny * nz; + ig2ixyz_k_cpu[igl + ik * npwk_max] = iz + iy * nz + ix * ny * nz; } } -#if defined(__CUDA) || defined(__ROCM) - if (this->device == "gpu") { - resmem_int_op()(gpu_ctx, ig2ixyz_k, this->npwk_max * this->nks); - syncmem_int_h2d_op()(gpu_ctx, cpu_ctx, this->ig2ixyz_k, this->ig2ixyz_k_, this->npwk_max * this->nks); - } -#endif + resmem_int_op()(gpu_ctx, ig2ixyz_k, this->npwk_max * this->nks); + syncmem_int_h2d_op()(gpu_ctx, cpu_ctx, this->ig2ixyz_k, ig2ixyz_k_cpu, this->npwk_max * this->nks); + delete[] ig2ixyz_k_cpu; } std::vector PW_Basis_K::get_ig2ix(const int ik) const diff --git a/source/module_basis/module_pw/pw_basis_k.h b/source/module_basis/module_pw/pw_basis_k.h index 768c4df1fe..f5be09cfbd 100644 --- a/source/module_basis/module_pw/pw_basis_k.h +++ b/source/module_basis/module_pw/pw_basis_k.h @@ -71,8 +71,6 @@ class PW_Basis_K : public PW_Basis const bool xprime_in = true ); - void get_ig2ixyz_k(); - public: int nks=0;//number of k points in this pool ModuleBase::Vector3 *kvec_d=nullptr; // Direct coordinates of k points @@ -88,8 +86,7 @@ class PW_Basis_K : public PW_Basis int *igl2isz_k=nullptr, * d_igl2isz_k = nullptr; //[npwk_max*nks] map (igl,ik) to (is,iz) int *igl2ig_k=nullptr;//[npwk_max*nks] map (igl,ik) to ig - int *ig2ixyz_k=nullptr; - int *ig2ixyz_k_=nullptr; + int *ig2ixyz_k=nullptr; ///< [npw] map ig to ixyz double *gk2=nullptr; // modulus (G+K)^2 of G vectors [npwk_max*nks] @@ -108,6 +105,8 @@ class PW_Basis_K : public PW_Basis double * d_gk2 = nullptr; // modulus (G+K)^2 of G vectors [npwk_max*nks] //create igl2isz_k map array for fft void setupIndGk(); + // get ig2ixyz_k + void get_ig2ixyz_k(); //calculate G+K, it is a private function ModuleBase::Vector3 cal_GplusK_cartesian(const int ik, const int ig) const; diff --git a/source/module_basis/module_pw/test/test4-4.cpp b/source/module_basis/module_pw/test/test4-4.cpp index ce4916d57f..7eb0241318 100644 --- a/source/module_basis/module_pw/test/test4-4.cpp +++ b/source/module_basis/module_pw/test/test4-4.cpp @@ -213,13 +213,6 @@ TEST_F(PWTEST,test4_4) } } - //check getig2ixyz_k - pwtest.get_ig2ixyz_k(); - for(int igl = 0; igl < npwk ; ++igl) - { - EXPECT_GE(pwtest.ig2ixyz_k_[igl + ik * pwtest.npwk_max], 0); - } - } delete []tmp; delete [] rhor; diff --git a/source/module_cell/read_atoms.cpp b/source/module_cell/read_atoms.cpp index acf54c4e7d..26f9d86789 100644 --- a/source/module_cell/read_atoms.cpp +++ b/source/module_cell/read_atoms.cpp @@ -97,7 +97,6 @@ int UnitCell::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_running) ||(PARAM.inp.basis_type == "lcao_in_pw") ||( (PARAM.inp.basis_type == "pw") - &&(PARAM.inp.psi_initializer) &&(PARAM.inp.init_wfc.substr(0, 3) == "nao") ) || PARAM.inp.onsite_radius > 0.0 @@ -453,7 +452,7 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn } else if(PARAM.inp.basis_type == "pw") { - if ((PARAM.inp.psi_initializer)&&(PARAM.inp.init_wfc.substr(0, 3) == "nao") || PARAM.inp.onsite_radius > 0.0) + if ((PARAM.inp.init_wfc.substr(0, 3) == "nao") || PARAM.inp.onsite_radius > 0.0) { std::string orbital_file = PARAM.inp.orbital_dir + orbital_fn[it]; this->read_orb_file(it, orbital_file, ofs_running, &(atoms[it])); diff --git a/source/module_cell/unitcell.cpp b/source/module_cell/unitcell.cpp index ac1fe740ca..4aa7f868ba 100755 --- a/source/module_cell/unitcell.cpp +++ b/source/module_cell/unitcell.cpp @@ -533,8 +533,7 @@ void UnitCell::cal_nwfc(std::ofstream& log) { // Use localized basis //===================== if ((PARAM.inp.basis_type == "lcao") || (PARAM.inp.basis_type == "lcao_in_pw") - || ((PARAM.inp.basis_type == "pw") && (PARAM.inp.psi_initializer) - && (PARAM.inp.init_wfc.substr(0, 3) == "nao") + || ((PARAM.inp.basis_type == "pw") && (PARAM.inp.init_wfc.substr(0, 3) == "nao") && (PARAM.inp.esolver_type == "ksdft"))) // xiaohui add 2013-09-02 { ModuleBase::GlobalFunc::AUTO_SET("NBANDS", PARAM.inp.nbands); diff --git a/source/module_esolver/esolver_ks_lcaopw.cpp b/source/module_esolver/esolver_ks_lcaopw.cpp index 3887796046..08d1043a4a 100644 --- a/source/module_esolver/esolver_ks_lcaopw.cpp +++ b/source/module_esolver/esolver_ks_lcaopw.cpp @@ -57,6 +57,7 @@ namespace ModuleESolver template ESolver_KS_LIP::~ESolver_KS_LIP() { + delete this->psi_local; // delete Hamilt this->deallocate_hamilt(); } @@ -79,11 +80,22 @@ namespace ModuleESolver this->p_hamilt = nullptr; } } + template + void ESolver_KS_LIP::before_scf(UnitCell& ucell, const int istep) + { + ESolver_KS_PW::before_scf(ucell, istep); + this->p_psi_init->initialize_lcao_in_pw(this->psi_local, GlobalV::ofs_running); + } template void ESolver_KS_LIP::before_all_runners(UnitCell& ucell, const Input_para& inp) { ESolver_KS_PW::before_all_runners(ucell, inp); + delete this->psi_local; + this->psi_local = new psi::Psi(this->psi->get_nk(), + this->p_psi_init->psi_initer->nbands_start(), + this->psi->get_nbasis(), + this->psi->get_ngk_pointer()); #ifdef __EXX if (PARAM.inp.calculation == "scf" || PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax" @@ -94,14 +106,14 @@ namespace ModuleESolver this->exx_lip = std::unique_ptr>(new Exx_Lip(GlobalC::exx_info.info_lip, ucell.symm, &this->kv, - this->p_wf_init, + this->psi_local, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &ucell, this->pelec)); - // this->exx_lip.init(GlobalC::exx_info.info_lip, cell.symm, &this->kv, this->p_wf_init, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &cell, this->pelec); + // this->exx_lip.init(GlobalC::exx_info.info_lip, cell.symm, &this->kv, this->p_psi_init, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &cell, this->pelec); } } #endif @@ -136,18 +148,8 @@ namespace ModuleESolver hsolver::DiagoIterAssist::PW_DIAG_NMAX = PARAM.inp.pw_diag_nmax; bool skip_charge = PARAM.inp.calculation == "nscf" ? true : false; - // It is not a good choice to overload another solve function here, this will spoil the concept of - // multiple inheritance and polymorphism. But for now, we just do it in this way. - // In the future, there will be a series of class ESolver_KS_LCAO_PW, HSolver_LCAO_PW and so on. - std::weak_ptr> psig = this->p_wf_init->get_psig(); - - if (psig.expired()) - { - ModuleBase::WARNING_QUIT("ESolver_KS_PW::hamilt2density_single", "psig lifetime is expired"); - } - hsolver::HSolverLIP hsolver_lip_obj(this->pw_wfc); - hsolver_lip_obj.solve(this->p_hamilt, this->kspw_psi[0], this->pelec, psig.lock().get()[0], skip_charge,ucell.tpiba,ucell.nat); + hsolver_lip_obj.solve(this->p_hamilt, this->kspw_psi[0], this->pelec, *this->psi_local, skip_charge,ucell.tpiba,ucell.nat); // add exx #ifdef __EXX diff --git a/source/module_esolver/esolver_ks_lcaopw.h b/source/module_esolver/esolver_ks_lcaopw.h index 56276f3eb6..99f527081e 100644 --- a/source/module_esolver/esolver_ks_lcaopw.h +++ b/source/module_esolver/esolver_ks_lcaopw.h @@ -23,6 +23,8 @@ namespace ModuleESolver void before_all_runners(UnitCell& ucell, const Input_para& inp) override; void after_all_runners(UnitCell& ucell) override; + virtual void before_scf(UnitCell& ucell, const int istep) override; + protected: virtual void iter_init(UnitCell& ucell, const int istep, const int iter) override; virtual void iter_finish(UnitCell& ucell, const int istep, int& iter) override; @@ -35,6 +37,8 @@ namespace ModuleESolver virtual void allocate_hamilt(const UnitCell& ucell) override; virtual void deallocate_hamilt() override; + + psi::Psi* psi_local = nullptr; ///< psi for all local NAOs #ifdef __EXX std::unique_ptr> exx_lip; diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index f3d8a13f99..d16289d4e7 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -118,7 +118,7 @@ ESolver_KS_PW::~ESolver_KS_PW() } delete this->psi; - delete this->p_wf_init; + delete this->p_psi_init; } template @@ -189,26 +189,6 @@ void ESolver_KS_PW::before_all_runners(UnitCell& ucell, const Input_p &(this->pelec->f_en.vtxc)); } - //! 7) prepare some parameters for electronic wave functions initilization - this->p_wf_init = new psi::PSIInit(PARAM.inp.init_wfc, - PARAM.inp.ks_solver, - PARAM.inp.basis_type, - PARAM.inp.psi_initializer, - this->pw_wfc); - this->p_wf_init->prepare_init(&(this->sf), - &ucell, - 1, -#ifdef __MPI - &GlobalC::Pkpoints, - GlobalV::MY_RANK, -#endif - &this->ppcell); - - if (this->psi != nullptr) - { - delete this->psi; - this->psi = nullptr; - } //! initalize local pseudopotential this->locpp.init_vloc(ucell, this->pw_rhod); @@ -219,17 +199,19 @@ void ESolver_KS_PW::before_all_runners(UnitCell& ucell, const Input_p this->ppcell.init_vnl(ucell, this->pw_rhod); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "NON-LOCAL POTENTIAL"); - //! Allocate psi - this->p_wf_init->allocate_psi(this->psi, - this->kv.get_nkstot(), - this->kv.get_nks(), - this->kv.ngk.data(), - this->pw_wfc->npwk_max, - &this->sf, - &this->ppcell, - ucell); - - assert(this->psi != nullptr); + //! Allocate and initialize psi + this->p_psi_init = new psi::PSIInit(PARAM.inp.init_wfc, + PARAM.inp.ks_solver, + PARAM.inp.basis_type, + GlobalV::MY_RANK, + ucell, + this->sf, + GlobalC::Pkpoints, + this->ppcell, + *this->pw_wfc); + allocate_psi(this->psi, this->kv.get_nks(), this->kv.ngk.data(), PARAM.inp.nbands, this->pw_wfc->npwk_max); + this->p_psi_init->prepare_init(PARAM.inp.pw_seed); + this->kspw_psi = PARAM.inp.device == "gpu" || PARAM.inp.precision == "single" ? new psi::Psi(this->psi[0]) : reinterpret_cast*>(this->psi); @@ -267,7 +249,7 @@ void ESolver_KS_PW::before_scf(UnitCell& ucell, const int istep) this->pw_wfc->collect_local_pw(PARAM.inp.erf_ecut, PARAM.inp.erf_height, PARAM.inp.erf_sigma); - this->p_wf_init->make_table(this->kv.get_nks(), &this->sf, &this->ppcell, ucell); + this->p_psi_init->prepare_init(PARAM.inp.pw_seed); } if (ucell.ionic_position_updated) { @@ -407,29 +389,11 @@ void ESolver_KS_PW::before_scf(UnitCell& ucell, const int istep) auto* dftu = ModuleDFTU::DFTU::get_instance(); dftu->init(ucell, nullptr, this->kv.get_nks()); } - // after init_rho (in pelec->init_scf), we have rho now. - // before hamilt2density, we update Hk and initialize psi - - // before_scf function will be called everytime before scf. However, once - // atomic coordinates changed, structure factor will change, therefore all - // atomwise properties will change. So we need to reinitialize psi every - // time before scf. But for random wavefunction, we dont, because random - // wavefunction is not related to atomic coordinates. What the old strategy - // does is only to initialize for once... - if (((PARAM.inp.init_wfc == "random") && (istep == 0)) || (PARAM.inp.init_wfc != "random")) - { - this->p_wf_init->initialize_psi(this->psi, - this->kspw_psi, - this->p_hamilt, - this->ppcell, - ucell, - GlobalV::ofs_running, - this->already_initpsi); - - if (this->already_initpsi == false) - { - this->already_initpsi = true; - } + + if (!this->already_initpsi) + { + this->p_psi_init->initialize_psi(this->psi, this->kspw_psi, this->p_hamilt, GlobalV::ofs_running); + this->already_initpsi = true; } ModuleBase::timer::tick("ESolver_KS_PW", "before_scf"); diff --git a/source/module_esolver/esolver_ks_pw.h b/source/module_esolver/esolver_ks_pw.h index 3ad3aeb09c..25cf73dc77 100644 --- a/source/module_esolver/esolver_ks_pw.h +++ b/source/module_esolver/esolver_ks_pw.h @@ -53,7 +53,7 @@ class ESolver_KS_PW : public ESolver_KS psi::Psi, base_device::DEVICE_CPU>* psi = nullptr; // psi_initializer controller - psi::PSIInit* p_wf_init = nullptr; + psi::PSIInit* p_psi_init = nullptr; Device* ctx = {}; diff --git a/source/module_hsolver/diago_iter_assist.cpp b/source/module_hsolver/diago_iter_assist.cpp index bdb60ffaff..14662291c8 100644 --- a/source/module_hsolver/diago_iter_assist.cpp +++ b/source/module_hsolver/diago_iter_assist.cpp @@ -53,7 +53,7 @@ void DiagoIterAssist::diagH_subspace(const hamilt::Hamilt* const int dmax = psi.get_nbasis(); T* temp = nullptr; - bool in_place = false; + bool in_place = false; ///< if temp and evc share the same memory if (psi.get_pointer() != evc.get_pointer() && psi.get_nbands() == evc.get_nbands()) { // use memory of evc as temp temp = evc.get_pointer(); @@ -62,7 +62,6 @@ void DiagoIterAssist::diagH_subspace(const hamilt::Hamilt* else { resmem_complex_op()(ctx, temp, nstart * dmax, "DiagSub::temp"); - setmem_complex_op()(ctx, temp, 0, nstart * dmax); } { // code block to calculate hcc and scc @@ -306,8 +305,7 @@ void DiagoIterAssist::diagH_subspace_init(hamilt::Hamilt* { GlobalV::ofs_running << " Not do zgemm to get evc." << std::endl; } - else if ((PARAM.inp.basis_type == "lcao" || PARAM.inp.basis_type == "lcao_in_pw" - || (PARAM.inp.basis_type == "pw" && PARAM.inp.psi_initializer)) + else if ((PARAM.inp.basis_type == "lcao" || PARAM.inp.basis_type == "lcao_in_pw" || PARAM.inp.basis_type == "pw") && (PARAM.inp.calculation == "scf" || PARAM.inp.calculation == "md" || PARAM.inp.calculation == "relax")) // pengfei 2014-10-13 { diff --git a/source/module_hsolver/hsolver_lcaopw.cpp b/source/module_hsolver/hsolver_lcaopw.cpp index 1f3bb2c17b..059318034a 100644 --- a/source/module_hsolver/hsolver_lcaopw.cpp +++ b/source/module_hsolver/hsolver_lcaopw.cpp @@ -7,7 +7,6 @@ #include "module_elecstate/elecstate_pw.h" #include "module_hamilt_pw/hamilt_pwdft/global.h" #include "module_hamilt_pw/hamilt_pwdft/hamilt_pw.h" -#include "module_psi/wavefunc.h" #include "module_hsolver/diago_iter_assist.h" #include "module_parameter/parameter.h" diff --git a/source/module_hsolver/hsolver_pw.h b/source/module_hsolver/hsolver_pw.h index 0dee4fbdbf..5f44bc10a4 100644 --- a/source/module_hsolver/hsolver_pw.h +++ b/source/module_hsolver/hsolver_pw.h @@ -5,7 +5,6 @@ #include "module_hamilt_general/hamilt.h" #include "module_base/macros.h" #include "module_basis/module_pw/pw_basis_k.h" -#include "module_psi/wavefunc.h" namespace hsolver { diff --git a/source/module_hsolver/test/hsolver_pw_sup.h b/source/module_hsolver/test/hsolver_pw_sup.h index 56377dfaf7..fcb2862a29 100644 --- a/source/module_hsolver/test/hsolver_pw_sup.h +++ b/source/module_hsolver/test/hsolver_pw_sup.h @@ -180,40 +180,3 @@ template class DiagoIterAssist, base_device::DEVICE_CPU>; template class DiagoIterAssist, base_device::DEVICE_CPU>; } // namespace hsolver - -#include "module_psi/wavefunc.h" -namespace hamilt { - -template <> -void diago_PAO_in_pw_k2( - const base_device::DEVICE_CPU* ctx, - const int& ik, - psi::Psi, base_device::DEVICE_CPU>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - const UnitCell& ucell, - hamilt::Hamilt, base_device::DEVICE_CPU>* phm_in) { - for (int i = 0; i < wvf.size(); i++) { - wvf.get_pointer()[i] = std::complex((float)i + 1, 0); - } -} - -template <> -void diago_PAO_in_pw_k2( - const base_device::DEVICE_CPU* ctx, - const int& ik, - psi::Psi, base_device::DEVICE_CPU>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - const UnitCell& ucell, - hamilt::Hamilt, base_device::DEVICE_CPU>* phm_in) { - for (int i = 0; i < wvf.size(); i++) { - wvf.get_pointer()[i] = std::complex((double)i + 1, 0); - } -} - -}//namespace hsolver diff --git a/source/module_hsolver/test/hsolver_supplementary_mock.h b/source/module_hsolver/test/hsolver_supplementary_mock.h index 436ecd6565..e670adfe15 100644 --- a/source/module_hsolver/test/hsolver_supplementary_mock.h +++ b/source/module_hsolver/test/hsolver_supplementary_mock.h @@ -1,6 +1,5 @@ #pragma once #include "module_elecstate/elecstate_pw.h" -#include "module_psi/wavefunc.h" namespace elecstate { @@ -153,15 +152,3 @@ K_Vectors::K_Vectors() K_Vectors::~K_Vectors() { } -wavefunc::wavefunc() -{ -} -wavefunc::~wavefunc() -{ -} -WF_atomic::WF_atomic() -{ -} -WF_atomic::~WF_atomic() -{ -} diff --git a/source/module_hsolver/test/test_hsolver_sdft.cpp b/source/module_hsolver/test/test_hsolver_sdft.cpp index 76f24af4ff..3ed2593d9a 100644 --- a/source/module_hsolver/test/test_hsolver_sdft.cpp +++ b/source/module_hsolver/test/test_hsolver_sdft.cpp @@ -181,7 +181,6 @@ void Stochastic_Iter::cal_storho(const UnitCell& ucell, ModulePW::PW_Basis_K* wfc_basis) { } - template class Stochastic_Iter, base_device::DEVICE_CPU>; Charge::Charge(){}; @@ -209,7 +208,6 @@ class TestHSolverPW_SDFT : public ::testing::Test ModulePW::PW_Basis_K pwbk; Stochastic_WF> stowf; K_Vectors kv; - wavefunc wf; StoChe stoche; hamilt::HamiltSdftPW>* p_hamilt_sto = nullptr; hsolver::HSolverPW_SDFT, base_device::DEVICE_CPU> hs_d diff --git a/source/module_io/CMakeLists.txt b/source/module_io/CMakeLists.txt index e9f7d0b982..677223d844 100644 --- a/source/module_io/CMakeLists.txt +++ b/source/module_io/CMakeLists.txt @@ -20,6 +20,7 @@ list(APPEND objects restart.cpp binstream.cpp write_wfc_pw.cpp + write_pao.cpp write_cube.cpp write_elecstat_pot.cpp write_elf.cpp diff --git a/source/module_io/read_input_item_system.cpp b/source/module_io/read_input_item_system.cpp index ca80e04412..97b5875f96 100644 --- a/source/module_io/read_input_item_system.cpp +++ b/source/module_io/read_input_item_system.cpp @@ -506,18 +506,6 @@ void ReadInput::item_system() read_sync_string(input.init_wfc); this->add_item(item); } - { - Input_Item item("psi_initializer"); - item.annotation = "whether to use psi_initializer"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.basis_type == "lcao_in_pw") - { - para.input.psi_initializer = true; - } - }; - read_sync_bool(input.psi_initializer); - this->add_item(item); - } { Input_Item item("pw_seed"); item.annotation = "random seed for initializing wave functions"; diff --git a/source/module_io/test/for_testing_input_conv.h b/source/module_io/test/for_testing_input_conv.h index 7394ded26f..88b1f304e2 100644 --- a/source/module_io/test/for_testing_input_conv.h +++ b/source/module_io/test/for_testing_input_conv.h @@ -16,7 +16,6 @@ #include "module_hamilt_lcao/module_tddft/td_velocity.h" #include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h" #include "module_hamilt_pw/hamilt_pwdft/structure_factor.h" -#include "module_psi/wavefunc.h" #include "module_hsolver/hsolver_lcao.h" #include "module_io/berryphase.h" #include "module_io/restart.h" @@ -166,18 +165,6 @@ Structure_Factor::Structure_Factor() Structure_Factor::~Structure_Factor() { } -WF_atomic::WF_atomic() -{ -} -WF_atomic::~WF_atomic() -{ -} -wavefunc::wavefunc() -{ -} -wavefunc::~wavefunc() -{ -} UnitCell::UnitCell() { itia2iat.create(1, 1); diff --git a/source/module_io/test_serial/read_input_item_test.cpp b/source/module_io/test_serial/read_input_item_test.cpp index e8da3f478b..d77cd1a3e9 100644 --- a/source/module_io/test_serial/read_input_item_test.cpp +++ b/source/module_io/test_serial/read_input_item_test.cpp @@ -316,13 +316,6 @@ TEST_F(InputTest, Item_test) it->second.reset_value(it->second, param); EXPECT_EQ(param.input.init_wfc, "nao"); } - { // psi_initializer - auto it = find_label("psi_initializer", readinput.input_lists); - param.input.psi_initializer = false; - param.input.basis_type = "lcao_in_pw"; - it->second.reset_value(it->second, param); - EXPECT_EQ(param.input.psi_initializer, true); - } { // init_chg auto it = find_label("init_chg", readinput.input_lists); param.input.init_chg = "get_pchg"; diff --git a/source/module_io/to_wannier90_lcao_in_pw.cpp b/source/module_io/to_wannier90_lcao_in_pw.cpp index bf6bac22f6..44afc736fb 100644 --- a/source/module_io/to_wannier90_lcao_in_pw.cpp +++ b/source/module_io/to_wannier90_lcao_in_pw.cpp @@ -21,12 +21,12 @@ toWannier90_LCAO_IN_PW::toWannier90_LCAO_IN_PW( const std::string &wannier_spin ):toWannier90_PW(out_wannier_mmn, out_wannier_amn, out_wannier_unk, out_wannier_eig, out_wannier_wvfn_formatted, nnkpfile, wannier_spin) { - } toWannier90_LCAO_IN_PW::~toWannier90_LCAO_IN_PW() { - + delete psi_initer_; + delete psi; } void toWannier90_LCAO_IN_PW::calculate( @@ -44,14 +44,15 @@ void toWannier90_LCAO_IN_PW::calculate( Structure_Factor* sf_ptr = const_cast(&sf); ModulePW::PW_Basis_K* wfcpw_ptr = const_cast(wfcpw); - this->psi_init_ = new psi_initializer_nao, base_device::DEVICE_CPU>(); -#ifdef __MPI - this->psi_init_->initialize(sf_ptr, wfcpw_ptr, &ucell, &(GlobalC::Pkpoints), 1, nullptr, GlobalV::MY_RANK); - #else - this->psi_init_->initialize(sf_ptr, wfcpw_ptr, &(ucell), 1, nullptr); - #endif - this->psi_init_->tabulate(); - this->psi_init_->allocate(true); + delete this->psi_initer_; + this->psi_initer_ = new psi_initializer_nao>(); + this->psi_initer_->initialize(sf_ptr, wfcpw_ptr, &ucell, &(GlobalC::Pkpoints), 1, nullptr, GlobalV::MY_RANK); + this->psi_initer_->tabulate(); + delete this->psi; + const int nks_psi = (PARAM.inp.calculation == "nscf" && PARAM.inp.mem_saver == 1)? 1 : wfcpw->nks; + const int nks_psig = (PARAM.inp.basis_type == "pw")? 1 : nks_psi; + const int nbands_actual = this->psi_initer_->nbands_start(); + this->psi = new psi::Psi, base_device::DEVICE_CPU>(nks_psig, nbands_actual, wfcpw->npwk_max*PARAM.globalv.npol, wfcpw->npwk); read_nnkp(ucell,kv); if (PARAM.inp.nspin == 2) @@ -217,17 +218,15 @@ void toWannier90_LCAO_IN_PW::nao_G_expansion( ) { int npwx = wfcpw->npwk_max; - this->psi_init_->proj_ao_onkG(ik); - std::weak_ptr>> psig = this->psi_init_->share_psig(); - if(psig.expired()) { ModuleBase::WARNING_QUIT("toWannier90_LCAO_IN_PW::nao_G_expansion", "psig is expired"); -} + this->psi->fix_k(ik); + this->psi_initer_->init_psig(this->psi->get_pointer(), ik); int nbands = PARAM.globalv.nlocal; int nbasis = npwx*PARAM.globalv.npol; for (int ib = 0; ib < nbands; ib++) { for (int ig = 0; ig < nbasis; ig++) { - psi(ib, ig) = psig.lock().get()[0](ik, ib, ig); + psi(ib, ig) = this->psi->operator()(ib, ig); } } } diff --git a/source/module_io/to_wannier90_lcao_in_pw.h b/source/module_io/to_wannier90_lcao_in_pw.h index 26fe2abb92..16bccd20e3 100644 --- a/source/module_io/to_wannier90_lcao_in_pw.h +++ b/source/module_io/to_wannier90_lcao_in_pw.h @@ -70,7 +70,9 @@ class toWannier90_LCAO_IN_PW : public toWannier90_PW protected: const Parallel_Orbitals* ParaV; /// @brief psi initializer for expanding nao in planewave basis - psi_initializer, base_device::DEVICE_CPU>* psi_init_; + psi_initializer>* psi_initer_ = nullptr; + + psi::Psi, base_device::DEVICE_CPU>* psi = nullptr; /// @brief get Bloch function from LCAO wavefunction /// @param psi_in diff --git a/source/module_io/write_dos_lcao.cpp b/source/module_io/write_dos_lcao.cpp index 015c5bc1c1..14beb2830c 100644 --- a/source/module_io/write_dos_lcao.cpp +++ b/source/module_io/write_dos_lcao.cpp @@ -8,7 +8,6 @@ #include "module_base/global_function.h" #include "module_base/global_variable.h" #include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_psi/wavefunc.h" #include "write_orb_info.h" #include diff --git a/source/module_io/write_pao.cpp b/source/module_io/write_pao.cpp new file mode 100644 index 0000000000..5e1a30e79a --- /dev/null +++ b/source/module_io/write_pao.cpp @@ -0,0 +1,38 @@ +#include "write_pao.h" +#include "module_base/global_variable.h" +#include "module_parameter/parameter.h" + +#include +namespace ModuleIO +{ +void print_PAOs(const UnitCell& ucell) +{ + if (GlobalV::MY_RANK != 0) + { + return; + } + for (int it = 0; it < ucell.ntype; it++) + { + for (int icc = 0; icc < ucell.atoms[it].ncpp.nchi; icc++) + { + std::stringstream ss; + ss << PARAM.globalv.global_out_dir << ucell.atoms[it].label << "/" << ucell.atoms[it].label << "-" + << ucell.atoms[it].ncpp.els[icc] << ".ORBITAL"; + + std::ofstream ofs(ss.str().c_str()); + ofs << "Mesh " << ucell.atoms[it].ncpp.msh; + ofs << "\n" << std::setw(15) << "Radial" << std::setw(15) << "Psi" << std::setw(15) << "Rab"; + + for (int i = 0; i < ucell.atoms[it].ncpp.msh; i++) + { + ofs << "\n" + << std::setw(15) << ucell.atoms[it].ncpp.r[i] << std::setw(15) << ucell.atoms[it].ncpp.chi(icc, i) + << std::setw(15) << ucell.atoms[it].ncpp.rab[i]; + } + ofs.close(); + } + // end out put + } + return; +} +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/write_pao.h b/source/module_io/write_pao.h new file mode 100644 index 0000000000..40cee0db34 --- /dev/null +++ b/source/module_io/write_pao.h @@ -0,0 +1,10 @@ +#include "module_cell/unitcell.h" +namespace ModuleIO +{ + /** + * @brief print chi (PAO) in pseudopotential file + * + * @param ucell + */ + void print_PAOs(const UnitCell& ucell); +} \ No newline at end of file diff --git a/source/module_md/run_md.cpp b/source/module_md/run_md.cpp index b82a0c3e69..8e831e7e11 100644 --- a/source/module_md/run_md.cpp +++ b/source/module_md/run_md.cpp @@ -104,7 +104,6 @@ void md_line(UnitCell& unit_in, ModuleESolver::ESolver* p_esolver, const Paramet // because I move out the dependence on GlobalV from UnitCell::print_stru_file // so its parameter is calculated here bool need_orb = PARAM.inp.basis_type=="pw"; - need_orb = need_orb && PARAM.inp.psi_initializer; need_orb = need_orb && PARAM.inp.init_wfc.substr(0, 3)=="nao"; need_orb = need_orb || PARAM.inp.basis_type=="lcao"; need_orb = need_orb || PARAM.inp.basis_type=="lcao_in_pw"; diff --git a/source/module_parameter/input_parameter.h b/source/module_parameter/input_parameter.h index 04fc8790df..d2c27f78e1 100644 --- a/source/module_parameter/input_parameter.h +++ b/source/module_parameter/input_parameter.h @@ -45,7 +45,6 @@ struct Input_para double erf_sigma = 0.1; ///< the width of the energy step for reciprocal vectors int fft_mode = 0; ///< fftw mode 0: estimate, 1: measure, 2: patient, 3: exhaustive std::string init_wfc = "atomic"; ///< "file","atomic","random" - bool psi_initializer = false; ///< whether use psi_initializer to initialize wavefunctions int pw_seed = 0; ///< random seed for initializing wave functions std::string init_chg = "atomic"; ///< "file","atomic" bool dm_to_rho = false; ///< read density matrix from npz format and calculate charge density diff --git a/source/module_psi/CMakeLists.txt b/source/module_psi/CMakeLists.txt index 77afc701dc..a1037885f3 100644 --- a/source/module_psi/CMakeLists.txt +++ b/source/module_psi/CMakeLists.txt @@ -8,8 +8,6 @@ add_library( psi_overall_init OBJECT psi_init.cpp - wavefunc.cpp - wf_atomic.cpp ) add_library( @@ -17,6 +15,7 @@ add_library( OBJECT psi_initializer.cpp psi_initializer_random.cpp + psi_initializer_file.cpp psi_initializer_atomic.cpp psi_initializer_atomic_random.cpp psi_initializer_nao.cpp diff --git a/source/module_psi/psi_init.cpp b/source/module_psi/psi_init.cpp index 201539a54f..f5a0fa6595 100644 --- a/source/module_psi/psi_init.cpp +++ b/source/module_psi/psi_init.cpp @@ -1,12 +1,14 @@ #include "psi_init.h" #include "module_base/macros.h" +#include "module_base/memory.h" #include "module_base/timer.h" #include "module_base/tool_quit.h" #include "module_hsolver/diago_iter_assist.h" #include "module_parameter/parameter.h" #include "module_psi/psi_initializer_atomic.h" #include "module_psi/psi_initializer_atomic_random.h" +#include "module_psi/psi_initializer_file.h" #include "module_psi/psi_initializer_nao.h" #include "module_psi/psi_initializer_nao_random.h" #include "module_psi/psi_initializer_random.h" @@ -17,297 +19,189 @@ template PSIInit::PSIInit(const std::string& init_wfc_in, const std::string& ks_solver_in, const std::string& basis_type_in, - const bool& use_psiinitializer_in, - ModulePW::PW_Basis_K* pw_wfc_in) + const int& rank_in, + const UnitCell& ucell_in, + const Structure_Factor& sf_in, + const Parallel_Kpoints& parakpts_in, + const pseudopot_cell_vnl& nlpp_in, + const ModulePW::PW_Basis_K& pw_wfc_in) + : ucell(ucell_in), sf(sf_in), nlpp(nlpp_in), parakpts(parakpts_in), pw_wfc(pw_wfc_in), rank(rank_in) { this->init_wfc = init_wfc_in; this->ks_solver = ks_solver_in; this->basis_type = basis_type_in; - this->use_psiinitializer = use_psiinitializer_in; - this->pw_wfc = pw_wfc_in; } template -void PSIInit::prepare_init(Structure_Factor* p_sf, - UnitCell* p_ucell, - const int& random_seed, -#ifdef __MPI - Parallel_Kpoints* p_parak, - const int& rank, -#endif - pseudopot_cell_vnl* p_ppcell) +void PSIInit::prepare_init(const int& random_seed) { - if (!this->use_psiinitializer) - { - return; - } + // under restriction of C++11, std::unique_ptr can not be allocate via std::make_unique // use new instead, but will cause asymmetric allocation and deallocation, in literal aspect ModuleBase::timer::tick("PSIInit", "prepare_init"); - if ((this->init_wfc.substr(0, 6) == "atomic") && (p_ucell->natomwfc == 0)) + this->psi_initer.reset(); + if (this->init_wfc == "random") { - this->psi_init = std::unique_ptr>(new psi_initializer_random()); + this->psi_initer = std::unique_ptr>(new psi_initializer_random()); } - else if (this->init_wfc == "atomic") + else if (this->init_wfc == "file") { - this->psi_init = std::unique_ptr>(new psi_initializer_atomic()); + this->psi_initer = std::unique_ptr>(new psi_initializer_file()); } - else if (this->init_wfc == "random") + else if ((this->init_wfc.substr(0, 6) == "atomic") && (this->ucell.natomwfc == 0)) { - this->psi_init = std::unique_ptr>(new psi_initializer_random()); + this->psi_initer = std::unique_ptr>(new psi_initializer_random()); } - else if (this->init_wfc == "nao") + else if (this->init_wfc == "atomic" + || (this->init_wfc == "atomic+random" && this->ucell.natomwfc != PARAM.inp.nbands)) { - this->psi_init = std::unique_ptr>(new psi_initializer_nao()); + this->psi_initer = std::unique_ptr>(new psi_initializer_atomic()); } else if (this->init_wfc == "atomic+random") { - this->psi_init = std::unique_ptr>(new psi_initializer_atomic_random()); + this->psi_initer = std::unique_ptr>(new psi_initializer_atomic_random()); + } + else if (this->init_wfc == "nao") + { + this->psi_initer = std::unique_ptr>(new psi_initializer_nao()); } else if (this->init_wfc == "nao+random") { - this->psi_init = std::unique_ptr>(new psi_initializer_nao_random()); + this->psi_initer = std::unique_ptr>(new psi_initializer_nao_random()); } else { ModuleBase::WARNING_QUIT("PSIInit::prepare_init", "for new psi initializer, init_wfc type not supported"); } - //! function polymorphism is moved from constructor to function initialize. - //! Two slightly different implementation are for MPI and serial case, respectively. -#ifdef __MPI - this->psi_init->initialize(p_sf, pw_wfc, p_ucell, p_parak, random_seed, p_ppcell, rank); -#else - this->psi_init->initialize(p_sf, pw_wfc, p_ucell, random_seed, p_ppcell); -#endif + this->psi_initer->initialize(&sf, &pw_wfc, &ucell, ¶kpts, random_seed, &nlpp, rank); + this->psi_initer->tabulate(); - // always new->initialize->tabulate->allocate->proj_ao_onkG - this->psi_init->tabulate(); ModuleBase::timer::tick("PSIInit", "prepare_init"); } template -void PSIInit::allocate_psi(Psi>*& psi, - const int nkstot, - const int nks, - const int* ngk, - const int npwx, - Structure_Factor* p_sf, - pseudopot_cell_vnl* p_ppcell, - const UnitCell& ucell) +void PSIInit::initialize_psi(Psi>* psi, + psi::Psi* kspw_psi, + hamilt::Hamilt* p_hamilt, + std::ofstream& ofs_running) { - // allocate memory for std::complex datatype psi - // New psi initializer in ABACUS, Developer's note: - // Because the calling relationship between PSIInit and derived class is - // complicated, up to upcoming of ABACUS 3.4, we only implement this new psi - // initialization method for ksdft_pw, which means the routinely used dft theory. - // For other theories like stochastic DFT, we still use the old method. - - // LCAOINPW also temporarily uses PSIInit workflow, but in principle, it - // should have its own ESolver. ESolver class is for controlling workflow for each - // theory-basis combination, in the future it is also possible to seperate/decouple - // the basis (representation) with operator (hamiltonian) and solver (diagonalization). - // This feature requires feasible Linear Algebra library in-built in ABACUS, which - // is not ready yet. - if (this->use_psiinitializer) // new method - { - // psi_initializer drag initialization of pw wavefunction out of HSolver, make psi - // initialization decoupled with HSolver (diagonalization) procedure. - // However, due to EXX is hard to maintain, we still use the old method for EXX. - // LCAOINPW in version >= 3.5.0 uses this new method. - psi = this->psi_init->allocate(); - } - else // old method + if (kspw_psi->get_nbands() == 0 || GlobalV::MY_STOGROUP != 0) { - // old method explicitly requires variables such as total number of kpoints, number - // of bands, number of G-vectors, and so on. Comparatively in new method, these - // variables are imported in function called initialize. - psi = this->wf_old.allocate(nkstot, nks, ngk, npwx); - - // however, init_at_1 does not actually initialize the psi, instead, it is a - // function to calculate a interpolate table saving overlap intergral or say - // Spherical Bessel Transform of atomic orbitals. - this->wf_old.init_at_1(ucell,p_sf, &p_ppcell->tab_at); - // similarly, wfcinit not really initialize any wavefunction, instead, it initialize - // the mapping from ixy, the 1d flattened index of point on fft grid (x, y) plane, - // to the index of "stick", composed of grid points. - this->wf_old.wfcinit(psi, pw_wfc); + return; } -} - -template -void PSIInit::make_table(const int nks, - Structure_Factor* p_sf, - pseudopot_cell_vnl* p_ppcell, - const UnitCell& ucell) -{ - if (this->use_psiinitializer) + if (this->basis_type == "lcao_in_pw") { - } // do not need to do anything because the interpolate table is unchanged - else // old initialization method, used in EXX calculation - { - this->wf_old.init_after_vc(nks); // reallocate wanf2, the planewave expansion of lcao - this->wf_old.init_at_1(ucell,p_sf, &p_ppcell->tab_at); // re-calculate tab_at, the overlap matrix between atomic pswfc and jlq + return; } -} - -template -void PSIInit::initialize_psi(Psi>* psi, - psi::Psi* kspw_psi, - hamilt::Hamilt* p_hamilt, - const pseudopot_cell_vnl& nlpp, - const UnitCell& ucell, - std::ofstream& ofs_running, - const bool is_already_initpsi) -{ ModuleBase::timer::tick("PSIInit", "initialize_psi"); - if (PARAM.inp.psi_initializer) - { - // if psig is not allocated before, allocate it - if (!this->psi_init->psig_use_count()) - { - this->psi_init->allocate(/*psig_only=*/true); - } + const int nbands_start = this->psi_initer->nbands_start(); + const int nbands = psi->get_nbands(); + const int nbasis = psi->get_nbasis(); + const bool another_psi_space = (nbands_start != nbands || PARAM.inp.precision == "single"); - // loop over kpoints, make it possible to only allocate memory for psig at the only one kpt - // like (1, nbands, npwx), in which npwx is the maximal npw of all kpoints - for (int ik = 0; ik < this->pw_wfc->nks; ik++) - { - //! Fix the wavefunction to initialize at given kpoint - psi->fix_k(ik); + Psi* psi_cpu = reinterpret_cast*>(psi); + Psi* psi_device = kspw_psi; - //! Update Hamiltonian from other kpoint to the given one - p_hamilt->updateHk(ik); + if (another_psi_space) + { + psi_cpu = new Psi(1, nbands_start, nbasis, nullptr); + psi_device = PARAM.inp.device == "gpu" ? new psi::Psi(psi_cpu[0]) + : reinterpret_cast*>(psi_cpu); + } - //! Project atomic orbitals on |k+G> planewave basis, where k is wavevector of kpoint - //! and G is wavevector of the peroiodic part of the Bloch function - this->psi_init->proj_ao_onkG(ik); + // loop over kpoints, make it possible to only allocate memory for psig at the only one kpt + // like (1, nbands, npwx), in which npwx is the maximal npw of all kpoints + for (int ik = 0; ik < this->pw_wfc.nks; ik++) + { + //! Fix the wavefunction to initialize at given kpoint + psi->fix_k(ik); + kspw_psi->fix_k(ik); - //! psi_initializer manages memory of psig with shared pointer, - //! its access to use is shared here via weak pointer - //! therefore once the psi_initializer is destructed, psig will be destructed, too - //! this way, we can avoid memory leak and undefined behavior - std::weak_ptr> psig = this->psi_init->share_psig(); + //! Update Hamiltonian from other kpoint to the given one + p_hamilt->updateHk(ik); - if (psig.expired()) - { - ModuleBase::WARNING_QUIT("PSIInit::initialize_psi", "psig lifetime is expired"); - } - - //! to use psig, we need to lock it to get a shared pointer version, - //! then switch kpoint of psig to the given one - auto psig_ = psig.lock(); - // CHANGE LOG: if not lcaoinpw, the psig will only be used in psi-initialization - // so we can only allocate memory for one kpoint with the maximal number of pw - // over all kpoints, then the memory space will be always enough. Then for each - // kpoint, the psig is calculated in an overwrite manner. - const int ik_psig = (psig_->get_nk() == 1) ? 0 : ik; - psig_->fix_k(ik_psig); + //! initialize psi_cpu + this->psi_initer->init_psig(psi_cpu->get_pointer(), ik); + if (psi_device->get_pointer() != psi_cpu->get_pointer()) + { + castmem_h2d_op()(ctx, cpu_ctx, psi_device->get_pointer(), psi_cpu->get_pointer(), nbands_start * nbasis); + } - std::vector::type> etatom(psig_->get_nbands(), 0.0); + std::vector::type> etatom(nbands_start, 0.0); - // then adjust dimension from psig to psi - // either by matrix-multiplication or by copying-discarding - if (this->psi_init->method() != "random") + if (this->ks_solver == "cg") + { + if (another_psi_space) { - // lcaoinpw and pw share the same esolver. In the future, we will have different esolver - if (((this->ks_solver == "cg") || (this->ks_solver == "lapack")) && (this->basis_type == "pw")) - { - // the following function is only run serially, to be improved - hsolver::DiagoIterAssist::diagH_subspace_init(p_hamilt, - psig_->get_pointer(), - psig_->get_nbands(), - psig_->get_nbasis(), - *(kspw_psi), - etatom.data()); - continue; - } - else if ((this->ks_solver == "lapack") && (this->basis_type == "lcao_in_pw")) - { - if (ik == 0) - { - ofs_running << " START WAVEFUNCTION: LCAO_IN_PW, psi initialization skipped " << std::endl; - } - continue; - } - // else the case is davidson + // for diagH_subspace_init, psi_cpu->get_pointer() and kspw_psi->get_pointer() should be different + hsolver::DiagoIterAssist::diagH_subspace_init(p_hamilt, + psi_device->get_pointer(), + nbands_start, + nbasis, + *(kspw_psi), + etatom.data()); } else { - if (this->ks_solver == "cg") - { - hsolver::DiagoIterAssist::diagH_subspace(p_hamilt, *(psig_), *(kspw_psi), etatom.data()); - continue; - } - // else the case is davidson + // for diagH_subspace_init, psi_cpu->get_pointer() and kspw_psi->get_pointer() can be the same + hsolver::DiagoIterAssist::diagH_subspace(p_hamilt, + *psi_device, + *kspw_psi, + etatom.data(), + nbands_start); } - - // for the Davidson method, we just copy the wavefunction (partially) - for (int iband = 0; iband < kspw_psi->get_nbands(); iband++) + } + else // dav, bpcg + { + if (another_psi_space) { - for (int ibasis = 0; ibasis < kspw_psi->get_nbasis(); ibasis++) - { - (*(kspw_psi))(iband, ibasis) = (*psig_)(iband, ibasis); - } + syncmem_complex_op()(ctx, ctx, kspw_psi->get_pointer(), psi_device->get_pointer(), nbands * nbasis); } - } // end k-point loop + } + } // end k-point loop - if (this->basis_type != "lcao_in_pw") + if (another_psi_space) + { + delete psi_cpu; + if(PARAM.inp.device == "gpu") { - this->psi_init->deallocate_psig(); + delete psi_device; } } - else - { - //! note: is_already_initpsi will be false in init_after_vc when vc changes. - if (PARAM.inp.basis_type == "pw" && is_already_initpsi == false) - { - for (int ik = 0; ik < this->pw_wfc->nks; ++ik) - { - //! Update Hamiltonian from other kpoint to the given one - p_hamilt->updateHk(ik); - if (PARAM.inp.esolver_type == "sdft") - { - if (kspw_psi->get_nbands() > 0 && GlobalV::MY_STOGROUP == 0) - { - //! Fix the wavefunction to initialize at given kpoint - kspw_psi->fix_k(ik); - - /// for psi init guess!!!! - hamilt::diago_PAO_in_pw_k2(this->ctx, - ik, - *(kspw_psi), - this->pw_wfc, - &this->wf_old, - nlpp.tab_at, - nlpp.lmaxkb, - ucell, - p_hamilt); - } - } - else - { - //! Fix the wavefunction to initialize at given kpoint - kspw_psi->fix_k(ik); + ModuleBase::timer::tick("PSIInit", "initialize_psi"); +} - /// for psi init guess!!!! - hamilt::diago_PAO_in_pw_k2(this->ctx, - ik, - *(kspw_psi), - this->pw_wfc, - &this->wf_old, - nlpp.tab_at, - nlpp.lmaxkb, - ucell, - p_hamilt); - } - } - } +template +void PSIInit::initialize_lcao_in_pw(Psi* psi_local, std::ofstream& ofs_running) +{ + ofs_running << " START WAVEFUNCTION: LCAO_IN_PW, psi initialization skipped " << std::endl; + assert(this->psi_initer->method() == "nao"); + for (int ik = 0; ik < this->pw_wfc.nks; ik++) + { + psi_local->fix_k(ik); + this->psi_initer->init_psig(psi_local->get_pointer(), ik); } +} - ModuleBase::timer::tick("PSIInit", "initialize_psi"); +void allocate_psi(Psi>*& psi, const int& nks, const int* ngk, const int& nbands, const int& npwx) +{ + assert(npwx > 0); + assert(nks > 0); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "npwx", npwx); + + delete psi; + int nks2 = nks; + if (PARAM.inp.calculation == "nscf" && PARAM.inp.mem_saver == 1) + { + nks2 = 1; + } + psi = new psi::Psi>(nks2, nbands, npwx * PARAM.globalv.npol, ngk); + const size_t memory_cost = sizeof(std::complex) * nks2 * nbands * (PARAM.globalv.npol * npwx); + std::cout << " MEMORY FOR PSI (MB) : " << static_cast(memory_cost) / 1024.0 / 1024.0 << std::endl; + ModuleBase::Memory::record("Psi_PW", memory_cost); } template class PSIInit, base_device::DEVICE_CPU>; diff --git a/source/module_psi/psi_init.h b/source/module_psi/psi_init.h index 472ab4d0ff..453d27b072 100644 --- a/source/module_psi/psi_init.h +++ b/source/module_psi/psi_init.h @@ -1,7 +1,6 @@ -#ifndef W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_PW_HAMILT_PWDFT_WFINIT_H -#define W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_PW_HAMILT_PWDFT_WFINIT_H +#ifndef PSI_INIT_H +#define PSI_INIT_H #include "module_hamilt_general/hamilt.h" -#include "module_psi/wavefunc.h" #include "module_psi/psi_initializer.h" namespace psi @@ -15,35 +14,16 @@ class PSIInit PSIInit(const std::string& init_wfc_in, const std::string& ks_solver_in, const std::string& basis_type_in, - const bool& use_psiinitializer_in, - ModulePW::PW_Basis_K* pw_wfc_in); + const int& rank, + const UnitCell& ucell, + const Structure_Factor& sf, + const Parallel_Kpoints& parakpts, + const pseudopot_cell_vnl& nlpp, + const ModulePW::PW_Basis_K& pw_wfc); ~PSIInit(){}; - // prepare the wavefunction initialization - void prepare_init(Structure_Factor* p_sf, //< structure factor - UnitCell* p_ucell, //< unit cell - const int& random_seed, //< random seed -#ifdef __MPI - Parallel_Kpoints* = nullptr, //< parallel kpoints - const int& rank = 0, //< rank -#endif - pseudopot_cell_vnl* = nullptr); //< nonlocal pseudopotential - - // allocate the wavefunction - void allocate_psi(Psi>*& psi, //< psi: wavefunction - const int nkstot, //< total number of k-points for all pools - const int nks, //< number of k-points in the current pool - const int* ngk, //< number of G-vectors in the current pool - const int npwx, //< max number of plane waves of all pools - Structure_Factor* p_sf, //< structure factor - pseudopot_cell_vnl* p_ppcell, //< nonlocal pseudopotential - const UnitCell& ucell); //< unit cell - - // make interpolate table - void make_table(const int nks, - Structure_Factor* p_sf, - pseudopot_cell_vnl* p_ppcell, - const UnitCell& ucell); + ///@brief prepare the wavefunction initialization + void prepare_init(const int& random_seed); //------------------------ only for psi_initializer -------------------- /** @@ -57,35 +37,21 @@ class PSIInit void initialize_psi(Psi>* psi, psi::Psi* kspw_psi, hamilt::Hamilt* p_hamilt, - const pseudopot_cell_vnl& nlpp, - const UnitCell& ucell, - std::ofstream& ofs_running, - const bool is_already_initpsi); + std::ofstream& ofs_running); /** - * @brief get the psi_initializer + * @brief initialize NAOs in plane wave basis, only for LCAO_IN_PW * - * @return psi_initializer* */ - std::weak_ptr> get_psig() const - { - return this->psi_init->share_psig(); - } - //---------------------------------------------------------------------- + void initialize_lcao_in_pw(Psi* psi_local, std::ofstream& ofs_running); - private: - // psi_initializer* psi_init = nullptr; + // psi_initializer* psi_initer = nullptr; // change to use smart pointer to manage the memory, and avoid memory leak // while the std::make_unique() is not supported till C++14, // so use the new and std::unique_ptr to manage the memory, but this makes new-delete not symmetric - std::unique_ptr> psi_init; - - //! temporary: wave functions, this one may be deleted in future - wavefunc wf_old; - - // whether to use psi_initializer - bool use_psiinitializer = false; + std::unique_ptr> psi_initer; + private: // wavefunction initialization type std::string init_wfc = "none"; @@ -96,10 +62,32 @@ class PSIInit std::string basis_type = "none"; // pw basis - ModulePW::PW_Basis_K* pw_wfc = nullptr; + const ModulePW::PW_Basis_K& pw_wfc; + + // parallel kpoints + const Parallel_Kpoints& parakpts; - Device* ctx = {}; + // unit cell + const UnitCell& ucell; + + // structure factor + const Structure_Factor& sf; + + // nonlocal pseudopotential + const pseudopot_cell_vnl& nlpp; + + Device* ctx = {}; ///< device + base_device::DEVICE_CPU* cpu_ctx = {}; ///< CPU device + const int rank; ///< MPI rank + + //-------------------------OP-------------------------------------------- + using syncmem_complex_op = base_device::memory::synchronize_memory_op; + using castmem_h2d_op + = base_device::memory::cast_memory_op; }; +///@brief allocate the wavefunction +void allocate_psi(Psi>*& psi, const int& nks, const int* ngk, const int& nbands, const int& npwx); + } // namespace psi #endif \ No newline at end of file diff --git a/source/module_psi/psi_initializer.cpp b/source/module_psi/psi_initializer.cpp index ba1734e223..36c7624bda 100644 --- a/source/module_psi/psi_initializer.cpp +++ b/source/module_psi/psi_initializer.cpp @@ -1,8 +1,9 @@ #include "psi_initializer.h" + #include "module_base/memory.h" // basic functions support -#include "module_base/tool_quit.h" #include "module_base/timer.h" +#include "module_base/tool_quit.h" // three global variables definition #include "module_base/global_variable.h" #include "module_parameter/parameter.h" @@ -11,128 +12,28 @@ #include "module_base/parallel_reduce.h" #endif -template -psi::Psi>* psi_initializer::allocate(const bool only_psig) -{ - ModuleBase::timer::tick("psi_initializer", "allocate"); - /* - WARNING: when basis_type = "pw", the variable PARAM.globalv.nlocal will also be set, in this case, it is set to - 9 = 1 + 3 + 5, which is the maximal number of orbitals spd, I don't think it is reasonable - The way of calculating this->p_ucell_->natomwfc is, for each atom, read pswfc and for s, it is 1, for p, it is 3 - , then multiplied by the number of atoms, and then add them together. - */ - int nbands_actual = 0; - if(this->method_ == "random") - { - nbands_actual = PARAM.inp.nbands; - this->nbands_complem_ = 0; - } - else - { - if(this->method_.substr(0, 6) == "atomic") - { - nbands_actual = std::max(this->p_ucell_->natomwfc, PARAM.inp.nbands); - this->nbands_complem_ = nbands_actual - this->p_ucell_->natomwfc; - } - else if(this->method_.substr(0, 3) == "nao") - { - /* - previously PARAM.globalv.nlocal is used here, however it is wrong. PARAM.globalv.nlocal is fixed to 9*nat. - */ - int nbands_local = 0; - for(int it = 0; it < this->p_ucell_->ntype; it++) - { - for(int l = 0; l < this->p_ucell_->atoms[it].nwl + 1; l++) - { - /* EVERY ZETA FOR (2l+1) ORBS */ - const int nchi = this->p_ucell_->atoms[it].l_nchi[l]; - const int degen_l = (l == 0)? 1 : 2*l+1; - nbands_local += nchi * degen_l * PARAM.globalv.npol * this->p_ucell_->atoms[it].na; - /* - non-rotate basis, nbands_local*=2 for PARAM.globalv.npol = 2 is enough - */ - //nbands_local += this->p_ucell_->atoms[it].l_nchi[l]*(2*l+1) * PARAM.globalv.npol; - /* - rotate basis, nbands_local*=4 for p, d, f,... orbitals, and nbands_local*=2 for s orbitals - risky when NSPIN = 4, problematic psi value, needed to be checked - */ - } - } - nbands_actual = std::max(nbands_local, PARAM.inp.nbands); - this->nbands_complem_ = nbands_actual - nbands_local; - } - } - assert(this->nbands_complem_ >= 0); - - const int nks_psi = (PARAM.inp.calculation == "nscf" && this->mem_saver_ == 1)? 1 : this->pw_wfc_->nks; - const int nbasis_actual = this->pw_wfc_->npwk_max * PARAM.globalv.npol; - psi::Psi>* psi_out = nullptr; - if(!only_psig) - { - psi_out = new psi::Psi>(nks_psi, - PARAM.inp.nbands, // because no matter what, the wavefunction finally needed has PARAM.inp.nbands bands - nbasis_actual, - this->pw_wfc_->npwk); - double memory_cost_psi = sizeof(std::complex) * nks_psi * PARAM.inp.nbands - * this->pw_wfc_->npwk_max * PARAM.globalv.npol; -#ifdef __MPI - // get the correct memory cost for psi by all-reduce sum - Parallel_Reduce::reduce_all(memory_cost_psi); -#endif - // std::cout << " MEMORY FOR PSI PER PROCESSOR (MB) : " << double(memory_cost_psi)/1024.0/1024.0 << std::endl; - ModuleBase::Memory::record("Psi_PW", memory_cost_psi); - } - // psi_initializer also works for basis transformation tasks. In this case, psig needs to allocate memory for - // each kpoint, otherwise, for initializing pw wavefunction, only one kpoint's space is enough. - const int nks_psig = (PARAM.inp.basis_type == "pw")? 1 : nks_psi; - this->psig_ = std::make_shared>(nks_psig, - nbands_actual, - nbasis_actual, - this->pw_wfc_->npwk); - - double memory_cost_psig = - nks_psig * nbands_actual * this->pw_wfc_->npwk_max * PARAM.globalv.npol * sizeof(T); -#ifdef __MPI - // get the correct memory cost for psig by all-reduce sum - Parallel_Reduce::reduce_all(memory_cost_psig); -#endif - // std::cout << " MEMORY FOR AUXILLARY PSI PER PROCESSOR (MB) : " << double(memory_cost_psig)/1024.0/1024.0 << std::endl; - - GlobalV::ofs_running << "Allocate memory for psi and psig done.\n" - << "Print detailed information of dimension of psi and psig:\n" - << "psi: (" << nks_psi << ", " << PARAM.inp.nbands << ", " << nbasis_actual << ")\n" - << "psig: (" << nks_psig << ", " << nbands_actual << ", " << nbasis_actual << ")\n" - << "nks (psi) = " << nks_psi << "\n" - << "nks (psig) = " << nks_psig << "\n" - << "PARAM.inp.nbands = " << PARAM.inp.nbands << "\n" - << "nbands_actual = " << nbands_actual << "\n" - << "nbands_complem = " << this->nbands_complem_ << "\n" - << "nbasis_actual = " << nbasis_actual << "\n" - << "npwk_max = " << this->pw_wfc_->npwk_max << "\n" - << "npol = " << PARAM.globalv.npol << "\n"; - ModuleBase::Memory::record("psigPW", memory_cost_psig); - ModuleBase::timer::tick("psi_initializer", "allocate"); - return psi_out; -} - -template -void psi_initializer::random_t(T* psi, const int iw_start, const int iw_end, const int ik) +template +void psi_initializer::random_t(T* psi, const int iw_start, const int iw_end, const int ik, const int mode) { ModuleBase::timer::tick("psi_initializer", "random_t"); + assert(mode <= 1); assert(iw_start >= 0); const int ng = this->pw_wfc_->npwk[ik]; + const int npwk_max = this->pw_wfc_->npwk_max; + const int npol = PARAM.globalv.npol; - // if random seed is specified, then based on this seed to generate random wavefunction + // If random seed is specified, then generate random wavefunction satisfying that + // it can generate the same results using different number of processors. if (this->random_seed_ > 0) // qianrui add 2021-8-13 { -#ifdef __MPI // if compile with MPI, then let the seed include the kpoint information +#ifdef __MPI srand(unsigned(this->random_seed_ + this->p_parakpts_->startk_pool[GlobalV::MY_POOL] + ik)); -#else // otherwise, it is the run in serial, without the Parallel_Kpoints class +#else srand(unsigned(this->random_seed_ + ik)); #endif const int nxy = this->pw_wfc_->fftnxy; const int nz = this->pw_wfc_->nz; - const int nstnz = this->pw_wfc_->nst*nz; + const int nstnz = this->pw_wfc_->nst * nz; std::vector stickrr(nz); std::vector stickarg(nz); @@ -140,76 +41,108 @@ void psi_initializer::random_t(T* psi, const int iw_start, const int std::vector tmparg(nstnz); for (int iw = iw_start; iw < iw_end; iw++) - { + { // get the starting memory address of iw band - T* psi_slice = &(psi[iw * this->pw_wfc_->npwk_max * PARAM.globalv.npol]); - int startig = 0; - for(int ipol = 0 ; ipol < PARAM.globalv.npol ; ++ipol) + T* psi_slice = &(psi[iw * npwk_max * npol]); + for (int ipol = 0; ipol < npol; ++ipol) { // loop over all fft (x,y), but actually loop over all sticks - for(int ir = 0; ir < nxy; ir++) + for (int ir = 0; ir < nxy; ir++) { // if the stick is not on present processor, then skip - if(this->pw_wfc_->fftixy2ip[ir] < 0) { continue; } + if (this->pw_wfc_->fftixy2ip[ir] < 0) + { + continue; + } // otherwise // the following code is very time-consuming, but it can be skipped with pw_seed = 0 - if(GlobalV::RANK_IN_POOL == 0) + if (GlobalV::RANK_IN_POOL == 0) { // generate random number for (x,y) and all z, the stick will must // be filled, because length of stick can be no longer than nz // with: rr*exp(i*arg) = rr*cos(arg) + i*rr*sin(arg) - for(int iz = 0; iz < nz; iz++) + for (int iz = 0; iz < nz; iz++) { - stickrr[iz] = std::rand()/Real(RAND_MAX); // amplitude - stickarg[iz] = std::rand()/Real(RAND_MAX); // phase + stickrr[iz] = std::rand() / Real(RAND_MAX); // amplitude + stickarg[iz] = std::rand() / Real(RAND_MAX); // phase } } #ifdef __MPI // the stick-distribution is not used for non-MPI version - // then distribute the data to all processors in the pool + // then distribute the data to all processors in the pool stick_to_pool(stickrr.data(), ir, tmprr.data()); stick_to_pool(stickarg.data(), ir, tmparg.data()); #endif } // then for each g-component, initialize the wavefunction value - #pragma omp parallel for schedule(static, 4096/sizeof(T)) +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(T)) +#endif for (int ig = 0; ig < ng; ig++) { // get the correct value of "rr" and "arg" by indexing map "getigl2isz" - const double rr = tmprr[this->pw_wfc_->getigl2isz(ik, ig)]; - const double arg = ModuleBase::TWO_PI * tmparg[this->pw_wfc_->getigl2isz(ik,ig)]; - // get the |G+k|^2 - const double gk2 = this->pw_wfc_->getgk2(ik, ig); - // initialize the wavefunction value with rr/(gk2 + 1.0) * exp(i*arg) - psi_slice[ig+startig] = this->template cast_to_T(std::complex(rr*cos(arg)/(gk2 + 1.0), rr*sin(arg)/(gk2 + 1.0))); + const int isz = this->pw_wfc_->getigl2isz(ik, ig); + const double rr = tmprr[isz]; + const double arg = ModuleBase::TWO_PI * tmparg[isz]; + // initialize the wavefunction value with rr * exp(i*arg) + psi_slice[ig] = this->template cast_to_T(std::complex(rr * cos(arg), rr * sin(arg))); + } +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(T)) +#endif + for (int ig = ng; ig < npwk_max; ++ig) + { + psi_slice[ig] = static_cast(0.0); } - startig += this->pw_wfc_->npwk_max; // move to the next polarization + psi_slice += npwk_max; // move to the next polarization } } } - else // if random seed is not specified, then generate random wavefunction directly + // If random seed is not specified, then generate random wavefunction directly + // It does not guarantee the same results using different number of processors. + else { - for (int iw = iw_start ;iw < iw_end; iw++) + for (int iw = iw_start; iw < iw_end; iw++) { - T* psi_slice = &(psi[iw * this->pw_wfc_->npwk_max * PARAM.globalv.npol]); // get the memory to write directly. For nspin 4, nbasis*2 - - #pragma omp parallel for schedule(static, 4096/sizeof(T)) + T* psi_slice = &(psi[iw * npwk_max * npol]); // get the memory to write directly. For nspin 4, nbasis*2 + // donot use openmp here, because the random number generator is not thread-safe for (int ig = 0; ig < ng; ig++) { - const double rr = std::rand()/double(RAND_MAX); //qianrui add RAND_MAX - const double arg = ModuleBase::TWO_PI * std::rand()/double(RAND_MAX); + const double rr = std::rand() / double(RAND_MAX); + const double arg = ModuleBase::TWO_PI * std::rand() / double(RAND_MAX); const double gk2 = this->pw_wfc_->getgk2(ik, ig); - psi_slice[ig] = this->template cast_to_T(std::complex(rr*cos(arg)/(gk2 + 1.0), rr*sin(arg)/(gk2 + 1.0))); + psi_slice[ig] = this->template cast_to_T( + std::complex(rr * cos(arg) / (gk2 + 1.0), rr * sin(arg) / (gk2 + 1.0))); + } + if (npol == 2) + { + for (int ig = npwk_max; ig < npwk_max + ng; ig++) + { + const double rr = std::rand() / double(RAND_MAX); + const double arg = ModuleBase::TWO_PI * std::rand() / double(RAND_MAX); + const double gk2 = this->pw_wfc_->getgk2(ik, ig - npwk_max); + psi_slice[ig] = this->template cast_to_T( + std::complex(rr * cos(arg) / (gk2 + 1.0), rr * sin(arg) / (gk2 + 1.0))); + } } - if(PARAM.globalv.npol == 2) // additionally for nspin 4... + } + } + if (mode == 1) + { + for (int iw = iw_start; iw < iw_end; iw++) + { + T* psi_slice = &(psi[iw * npwk_max * npol]); + for (int ipol = 0; ipol < npol; ipol++) { - #pragma omp parallel for schedule(static, 4096/sizeof(T)) - for (int ig = this->pw_wfc_->npwk_max; ig < this->pw_wfc_->npwk_max + ng; ig++) +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(T)) +#endif + for (int ig = 0; ig < ng; ig++) { - const double rr = std::rand()/double(RAND_MAX); - const double arg = ModuleBase::TWO_PI * std::rand()/double(RAND_MAX); - const double gk2 = this->pw_wfc_->getgk2(ik, ig - this->pw_wfc_->npwk_max); - psi_slice[ig] = this->template cast_to_T(std::complex(rr*cos(arg)/(gk2 + 1.0), rr*sin(arg)/(gk2 + 1.0))); + const double gk2 = this->pw_wfc_->getgk2(ik, ig); + const Real inv_gk2 = 1.0 / (gk2 + 1.0); + psi_slice[ig] *= inv_gk2; } + psi_slice += npwk_max; } } } @@ -217,24 +150,24 @@ void psi_initializer::random_t(T* psi, const int iw_start, const int } #ifdef __MPI -template -void psi_initializer::stick_to_pool(Real* stick, const int& ir, Real* out) const -{ +template +void psi_initializer::stick_to_pool(Real* stick, const int& ir, Real* out) const +{ ModuleBase::timer::tick("psi_initializer", "stick_to_pool"); - MPI_Status ierror; + MPI_Status ierror; const int is = this->ixy2is_[ir]; - const int ip = this->pw_wfc_->fftixy2ip[ir]; + const int ip = this->pw_wfc_->fftixy2ip[ir]; const int nz = this->pw_wfc_->nz; - if(ip == 0 && GlobalV::RANK_IN_POOL ==0) - { - for(int iz=0; iz::value) { MPI_Recv(stick, nz, MPI_DOUBLE, 0, ir, POOL_WORLD, &ierror); @@ -247,13 +180,13 @@ void psi_initializer::stick_to_pool(Real* stick, const int& ir, Real* { ModuleBase::WARNING_QUIT("psi_initializer", "stick_to_pool: Real type not supported"); } - for(int iz=0; iz::value) { MPI_Send(stick, nz, MPI_DOUBLE, ip, ir, POOL_WORLD); @@ -266,23 +199,16 @@ void psi_initializer::stick_to_pool(Real* stick, const int& ir, Real* { ModuleBase::WARNING_QUIT("psi_initializer", "stick_to_pool: Real type not supported"); } - } + } - return; + return; ModuleBase::timer::tick("psi_initializer", "stick_to_pool"); } #endif // explicit instantiation -template class psi_initializer, base_device::DEVICE_CPU>; -template class psi_initializer, base_device::DEVICE_CPU>; +template class psi_initializer>; +template class psi_initializer>; // gamma point calculation -template class psi_initializer; -template class psi_initializer; -#if ((defined __CUDA) || (defined __ROCM)) -template class psi_initializer, base_device::DEVICE_GPU>; -template class psi_initializer, base_device::DEVICE_GPU>; -// gamma point calculation -template class psi_initializer; -template class psi_initializer; -#endif +template class psi_initializer; +template class psi_initializer; diff --git a/source/module_psi/psi_initializer.h b/source/module_psi/psi_initializer.h index ec1efd605e..876be12bda 100644 --- a/source/module_psi/psi_initializer.h +++ b/source/module_psi/psi_initializer.h @@ -1,22 +1,21 @@ #ifndef PSI_INITIALIZER_H #define PSI_INITIALIZER_H // data structure support -#include "module_psi/psi.h" // for psi data structure -#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h" #include "module_basis/module_pw/pw_basis_k.h" // for kpoint related data structure #include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h" +#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h" +#include "module_psi/psi.h" // for psi data structure // smart pointer for auto-memory management #include // numerical algorithm support #include "module_base/spherical_bessel_transformer.h" // for spherical bessel transform #ifdef __MPI -// MPI support #include +#endif +#include "module_base/macros.h" #include "module_base/parallel_global.h" #include "module_cell/parallel_kpoints.h" -#endif -#include "module_base/macros.h" #include /* Psi (planewave based wavefunction) initializer @@ -26,158 +25,118 @@ Institute: AI for Science Institute, BEIJING This class is used to allocate memory and give initial guess for psi therefore only double datatype is needed to be supported. Following methods are available: - 1. random: use random number to initialize psi + 1. file: use wavefunction file to initialize psi + implemented in psi_initializer_file.h + 2. random: use random number to initialize psi implemented in psi_initializer_random.h - 2. atomic: use pseudo-wavefunction in pseudopotential file to initialize psi + 3. atomic: use pseudo-wavefunction in pseudopotential file to initialize psi implemented in psi_initializer_atomic.h - 3. atomic+random: mix 'atomic' with some random numbers to initialize psi - 4. nao: use numerical orbitals to initialize psi + 4. atomic+random: mix 'atomic' with some random numbers to initialize psi + 5. nao: use numerical orbitals to initialize psi implemented in psi_initializer_nao.h - 5. nao+random: mix 'nao' with some random numbers to initialize psi + 6. nao+random: mix 'nao' with some random numbers to initialize psi To use: - WAVEFUNCTION INITIALIZATION A practical example would be in ESolver_KS_PW, because polymorphism is achieved by -pointer, while a raw pointer is risky, therefore std::unique_ptr is a better +pointer, while a raw pointer is risky, therefore std::unique_ptr is a better choice. -1. new a std::unique_ptr> with specific derived class +1. new a std::unique_ptr with specific derived class 2. initialize() to link psi_initializer with external data and methods -3. allocate() to allocate memory for psi -4. tabulate() to calculate the interpolate table -5. proj_ao_onkG() to calculate projection of atomic radial function onto planewave basis -6. share_psig() to get the shared pointer of psi, then use expire() to check if it is valid - and use with .lock() to get the shared pointer +3. tabulate() to calculate the interpolate table +4. init_psig() to calculate projection of atomic radial function onto planewave basis In summary: -new->initialize->allocate->tabulate->proj_ao_onkG->share_psig -- REPRESENTATION TRANSFORM -There is also another way to use psi_initializer, say the representation transform. -For this kind of use, see module_io/to_wannier90_lcao_in_pw, use allocate(true) instead -of allocate() to only allocate memory for psig, then use share_psig() to get value. +new->initialize->tabulate->init_psig */ -template +template class psi_initializer { - private: - using Real = typename GetTypeReal::type; - public: - // technical notes: - // Polymorphism is used to implement different methods, and achieved by pointers and virtual functions - psi_initializer() {}; - virtual ~psi_initializer() {}; - #ifdef __MPI // MPI additional implementation - /// @brief initialize the psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - Parallel_Kpoints* = nullptr, //< parallel kpoints - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential - const int& = 0) = 0; //< MPI rank - - Parallel_Kpoints* p_parakpts() const { return this->p_parakpts_; } - void set_parakpts(Parallel_Kpoints* p_parakpts) { this->p_parakpts_ = p_parakpts; } - /// @brief mapping from (ix, iy) to is - void stick_to_pool(Real* stick, //< stick - const int& ir, //< ir - Real* out) const; //< out - #else - /// @brief serial version of initialize function, link psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr) = 0; //< nonlocal pseudopotential - #endif - /// @brief CENTRAL FUNCTION: allocate memory for psi - psi::Psi>* allocate(const bool only_psig = false); //< if only allocate memory for psig + private: + using Real = typename GetTypeReal::type; + + public: + psi_initializer(){}; + virtual ~psi_initializer(){}; + /// @brief initialize the psi_initializer with external data and methods + virtual void initialize(const Structure_Factor*, //< structure factor + const ModulePW::PW_Basis_K*, //< planewave basis + const UnitCell*, //< unit cell + const Parallel_Kpoints* = nullptr, //< parallel kpoints + const int& = 1, //< random seed + const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential + const int& = 0) + = 0; //< MPI rank - void random_t(T* psi, //< [out] psi - const int iw_start, //< iw_start, starting band index - const int iw_end, //< iw_end, ending band index - const int ik); //< ik, kpoint index - virtual void random(T* psi, //< [out] psi - const int iw_start, //< iw_start, starting band index - const int iw_end, //< iw_end, ending band index - const int ik) //< ik, kpoint index - { ModuleBase::WARNING_QUIT("psi_initializer::random", "Polymorphism error"); } - /// @brief CENTRAL FUNCTION: allocate interpolate table recording overlap integral between radial function and Spherical Bessel function - virtual void allocate_table() { ModuleBase::WARNING_QUIT("psi_initializer::create_ovlp_table", "Polymorphism error"); } - /// @brief CENTRAL FUNCTION: calculate the interpolate table - virtual void tabulate() = 0; - /// @brief CENTRAL FUNCTION: calculate projection of atomic radial function onto planewave basis BASED ON THE OVERLAP TABLE - virtual void proj_ao_onkG(const int ik) = 0; + /// @brief CENTRAL FUNCTION: calculate the interpolate table if needed + virtual void tabulate() + { + return; + }; - // getter and setter - UnitCell* p_ucell() const { return this->p_ucell_; } - pseudopot_cell_vnl* p_pspot_nl() const { return this->p_pspot_nl_; } - Structure_Factor* p_sf() const { return this->sf_; } - ModulePW::PW_Basis_K* pw_wfc() const { return this->pw_wfc_; } - int random_seed() const { return this->random_seed_; } - std::vector ixy2is() const { return this->ixy2is_; } - int mem_saver() const { return this->mem_saver_; } - double random_mix() const { return this->random_mix_; } - std::string method() const { return this->method_; } - int nbands_complem() const { return this->nbands_complem_; } - // because unique_ptr is not copyable or used as rvlaue, use shared_ptr instead - // but to avoid ownership issue, use weak_ptr to share the pointer - // therefore there is no really getter to get directly the shared_ptr. - std::weak_ptr> share_psig() { return this->psig_; } - int psig_use_count() { return this->psig_.use_count(); } + /// @brief CENTRAL FUNCTION: init psi in pw basis + virtual void init_psig(T* psig, const int& ik) = 0; - void set_ucell(UnitCell* p_ucell_in) { this->p_ucell_ = p_ucell_in; } - void set_pspot_nl(pseudopot_cell_vnl* p_pspot_nl_in) { this->p_pspot_nl_ = p_pspot_nl_in; } - void set_sf(Structure_Factor* sf_in) { this->sf_ = sf_in; } - void set_pw_wfc(ModulePW::PW_Basis_K* pw_wfc_in) { this->pw_wfc_ = pw_wfc_in; } - void set_random_mix(const double random_mix_in) { this->random_mix_ = random_mix_in; } - void set_ixy2is(const std::vector& ixy2is_in) { this->ixy2is_ = ixy2is_in; } - void set_random_seed(const int random_seed_in) { this->random_seed_ = random_seed_in; } - void set_mem_saver(const int mem_saver_in) { this->mem_saver_ = mem_saver_in; } - void set_method(std::string method_in) { this->method_ = method_in; } - void set_nbands_complem(int nbands_in) { this->nbands_complem_ = nbands_in; } - void deallocate_psig() { this->psig_.reset(); } - // tool methods - // the following function is for compatibility concern, in ESolver_KS_PW the FPTYPE - // now support double, float, std::complex and std::complex - // in total four datatype. However other functions only support double. Therefore to - // cast std::complex to T and avoid compiler error, write the following functions. - template - typename std::enable_if::value, U>::type cast_to_T(const std::complex in) {return static_cast(in.real());} - template - typename std::enable_if::value, U>::type cast_to_T(const std::complex in) {return static_cast(in.real());} - template - typename std::enable_if>::value, U>::type cast_to_T(const std::complex in) {return std::complex(static_cast(in.real()), static_cast(in.imag()));} - template - typename std::enable_if>::value, U>::type cast_to_T(const std::complex in) {return std::complex(in.real(), in.imag());} + // ======================== Tool functions ======================== + // getter and setter + std::string method() const + { + return this->method_; + } + int nbands_start() const + { + return this->nbands_start_; + } + int nbands_complem() const + { + return this->nbands_complem_; + } - protected: - // interface to calculate structural factor. Because it has been created in ESolver, the best - // choice is to get a weak_ptr instead of pointer itself. However encapsulating a raw pointer - // is not a correct usage of smart pointer - Structure_Factor* sf_ = nullptr; - // interface to PW_Basis_K, stores information of |k+G> and |G>, also with methods like - // getgpluskcar... - ModulePW::PW_Basis_K* pw_wfc_ = nullptr; - // interface to UnitCell. UnitCell should be singleton and keep const for most cases. Due to - // many data are needed to read by psi_initializer, get a pointer to UnitCell instead of - // importing all information one-by-one in parameter list. - UnitCell* p_ucell_ = nullptr; - #ifdef __MPI - Parallel_Kpoints* p_parakpts_ = nullptr; - #endif - pseudopot_cell_vnl* p_pspot_nl_ = nullptr; - // shared by atomic, nao, atomic+random, nao+random - ModuleBase::SphericalBesselTransformer sbt; // useful for atomic-like methods - // shared by random, atomic+random, nao+random - int random_seed_ = 1; - // in old version it is of datatype int*, use std::vector to avoid memory leak - std::vector ixy2is_; - // refactored psig, in old version it is of datatype Psi*, use std::shared_ptr to - // avoid memory leak - std::shared_ptr> psig_; - private: - int mem_saver_ = 0; - std::string method_ = "none"; - int nbands_complem_ = 0; - double random_mix_ = 0; + template + typename std::enable_if::value, U>::type cast_to_T(const std::complex in) + { + return static_cast(in.real()); + } + template + typename std::enable_if::value, U>::type cast_to_T(const std::complex in) + { + return static_cast(in.real()); + } + template + typename std::enable_if>::value, U>::type cast_to_T( + const std::complex in) + { + return std::complex(static_cast(in.real()), static_cast(in.imag())); + } + template + typename std::enable_if>::value, U>::type cast_to_T( + const std::complex in) + { + return std::complex(in.real(), in.imag()); + } + + protected: +#ifdef __MPI // MPI additional implementation + /// @brief mapping from (ix, iy) to is + void stick_to_pool(Real* stick, //< stick + const int& ir, //< ir + Real* out) const; //< out +#endif + void random_t(T* psi, ///< [out] psi + const int iw_start, ///< iw_start, starting band index + const int iw_end, ///< iw_end, ending band index + const int ik, ///< ik, kpoint index + const int mode = 1); ///< mode, 0 for rr*exp(i*arg), 1 for rr/(1+gk2)*exp(i*arg) + const Structure_Factor* sf_ = nullptr; ///< Structure_Factor + const ModulePW::PW_Basis_K* pw_wfc_ = nullptr; ///< use |k+G>, |G>, getgpluskcar and so on in PW_Basis_K + const UnitCell* p_ucell_ = nullptr; ///< UnitCell + const Parallel_Kpoints* p_parakpts_ = nullptr; ///< Parallel_Kpoints + const pseudopot_cell_vnl* p_pspot_nl_ = nullptr; ///< pseudopot_cell_vnl + int random_seed_ = 1; ///< random seed, shared by random, atomic+random, nao+random + std::vector ixy2is_; ///< used by stick_to_pool function + int mem_saver_ = 0; ///< if save memory, only for nscf + std::string method_ = "none"; ///< method name + int nbands_complem_ = 0; ///< complement number of bands, which is nbands_start_ - ucell.natomwfc + double mixing_coef_ = 0; ///< mixing coefficient for atomic+random and nao+random + int nbands_start_ = 0; ///< starting nbands, which is no less than PARAM.inp.nbands }; #endif \ No newline at end of file diff --git a/source/module_psi/psi_initializer_atomic.cpp b/source/module_psi/psi_initializer_atomic.cpp index 0538483cad..6c86910bdb 100644 --- a/source/module_psi/psi_initializer_atomic.cpp +++ b/source/module_psi/psi_initializer_atomic.cpp @@ -2,41 +2,43 @@ #include "module_hamilt_pw/hamilt_pwdft/soc.h" // numerical algorithm support #include "module_base/math_integral.h" // for numerical integration -// numerical algorithm support #include "module_base/math_polyint.h" // for polynomial interpolation #include "module_base/math_ylmreal.h" // for real spherical harmonics +#include "module_base/math_sphbes.h" // for spherical bessel functions // basic functions support #include "module_base/tool_quit.h" #include "module_base/timer.h" -// three global variables definition +// global variables definition #include "module_base/global_variable.h" #include "module_parameter/parameter.h" +// io support +#include "module_io/write_pao.h" // free function, compared with common radial function normalization, it does not multiply r to function // due to pswfc is already multiplied by r -template -void normalize(int n_rgrid, std::vector& pswfcr, double* rab) -{ - std::vector pswfc2r2(pswfcr.size()); - std::transform(pswfcr.begin(), pswfcr.end(), pswfc2r2.begin(), [](T pswfc) { return pswfc * pswfc; }); - T norm = ModuleBase::Integral::simpson(n_rgrid, pswfc2r2.data(), rab); - norm = sqrt(norm); - std::transform(pswfcr.begin(), pswfcr.end(), pswfcr.begin(), [norm](T pswfc) { return pswfc / norm; }); -} +// template +// void normalize(int n_rgrid, std::vector& pswfcr, double* rab) +// { +// std::vector pswfc2r2(pswfcr.size()); +// std::transform(pswfcr.begin(), pswfcr.end(), pswfc2r2.begin(), [](T pswfc) { return pswfc * pswfc; }); +// T norm = ModuleBase::Integral::simpson(n_rgrid, pswfc2r2.data(), rab); +// norm = sqrt(norm); +// std::transform(pswfcr.begin(), pswfcr.end(), pswfcr.begin(), [norm](T pswfc) { return pswfc / norm; }); +// } -template -void psi_initializer_atomic::allocate_table() +template +void psi_initializer_atomic::allocate_ps_table() { // find correct dimension for ovlp_flzjlq int dim1 = this->p_ucell_->ntype; int dim2 = 0; // dim2 should be the maximum number of pseudo atomic orbitals for (int it = 0; it < this->p_ucell_->ntype; it++) { - dim2 = (this->p_ucell_->atoms[it].ncpp.nchi > dim2) ? this->p_ucell_->atoms[it].ncpp.nchi : dim2; + dim2 = std::max(dim2, this->p_ucell_->atoms[it].ncpp.nchi); } if (dim2 == 0) { - ModuleBase::WARNING_QUIT("psi_initializer_atomic::allocate_table", "there is not ANY pseudo atomic orbital read in present system, recommand other methods, quit."); + ModuleBase::WARNING_QUIT("psi_initializer_atomic::allocate_table", "there is not ANY pseudo atomic orbital read in present system, recommand other methods, quit."); } int dim3 = PARAM.globalv.nqx; // allocate memory for ovlp_flzjlq @@ -44,20 +46,19 @@ void psi_initializer_atomic::allocate_table() this->ovlp_pswfcjlq_.zero_out(); } -#ifdef __MPI -template -void psi_initializer_atomic::initialize(Structure_Factor* sf, //< structure factor - ModulePW::PW_Basis_K* pw_wfc, //< planewave basis - UnitCell* p_ucell, //< unit cell - Parallel_Kpoints* p_parakpts, //< parallel kpoints - const int& random_seed, //< random seed - pseudopot_cell_vnl* p_pspot_nl, - const int& rank) +template +void psi_initializer_atomic::initialize(const Structure_Factor* sf, //< structure factor + const ModulePW::PW_Basis_K* pw_wfc, //< planewave basis + const UnitCell* p_ucell, //< unit cell + const Parallel_Kpoints* p_parakpts, //< parallel kpoints + const int& random_seed, //< random seed + const pseudopot_cell_vnl* p_pspot_nl, + const int& rank) { ModuleBase::timer::tick("psi_initializer_atomic", "initialize"); if(p_pspot_nl == nullptr) { - ModuleBase::WARNING_QUIT("psi_initializer_atomic::initialize", + ModuleBase::WARNING_QUIT("psi_initializer_atomic::initialize", "pseudopot_cell_vnl object cannot be nullptr for atomic, quit."); } // import @@ -67,61 +68,42 @@ void psi_initializer_atomic::initialize(Structure_Factor* sf, this->p_parakpts_ = p_parakpts; this->p_pspot_nl_ = p_pspot_nl; this->random_seed_ = random_seed; + this->nbands_start_ = std::max(this->p_ucell_->natomwfc, PARAM.inp.nbands); + this->nbands_complem_ = this->nbands_start_ - this->p_ucell_->natomwfc; // allocate - this->allocate_table(); - // then for generate random number to fill in the wavefunction - this->ixy2is_.clear(); - this->ixy2is_.resize(this->pw_wfc_->fftnxy); - this->pw_wfc_->getfftixy2is(this->ixy2is_.data()); - ModuleBase::timer::tick("psi_initializer_atomic", "initialize_only_once"); -} -#else -template -void psi_initializer_atomic::initialize(Structure_Factor* sf, //< structure factor - ModulePW::PW_Basis_K* pw_wfc, //< planewave basis - UnitCell* p_ucell, //< unit cell - const int& random_seed, //< random seed - pseudopot_cell_vnl* p_pspot_nl) -{ - ModuleBase::timer::tick("psi_initializer_atomic", "initialize"); - if(p_pspot_nl == nullptr) - { - ModuleBase::WARNING_QUIT("psi_initializer_atomic::initialize", - "pseudopot_cell_vnl object cannot be nullptr for atomic, quit."); - } - // import - this->sf_ = sf; - this->pw_wfc_ = pw_wfc; - this->p_ucell_ = p_ucell; - this->p_pspot_nl_ = p_pspot_nl; - this->random_seed_ = random_seed; - // allocate - this->allocate_table(); + this->allocate_ps_table(); // then for generate random number to fill in the wavefunction this->ixy2is_.clear(); this->ixy2is_.resize(this->pw_wfc_->fftnxy); this->pw_wfc_->getfftixy2is(this->ixy2is_.data()); ModuleBase::timer::tick("psi_initializer_atomic", "initialize_only_once"); } -#endif -template -void psi_initializer_atomic::tabulate() +template +void psi_initializer_atomic::tabulate() { - ModuleBase::timer::tick("psi_initializer_atomic", "cal_ovlp_pswfcjlq"); - int maxn_rgrid = 0; - std::vector qgrid(PARAM.globalv.nqx); - for (int iq = 0; iq < PARAM.globalv.nqx; iq++) + if (PARAM.inp.use_paw) { - qgrid[iq] = PARAM.globalv.dq * iq; + return; } + ModuleBase::timer::tick("psi_initializer_atomic", "cal_ovlp_pswfcjlq"); + + GlobalV::ofs_running << "\n Make real space PAO into reciprocal space." << std::endl; + ModuleIO::print_PAOs(*this->p_ucell_); + + // Find the type of atom that has most mesh points. + int max_msh = 0; for (int it=0; itp_ucell_->ntype; it++) { - maxn_rgrid = (this->p_ucell_->atoms[it].ncpp.msh > maxn_rgrid) ? this->p_ucell_->atoms[it].ncpp.msh : maxn_rgrid; + max_msh = (this->p_ucell_->atoms[it].ncpp.msh > max_msh) ? this->p_ucell_->atoms[it].ncpp.msh : max_msh; } - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"max mesh points in Pseudopotential",maxn_rgrid); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"max mesh points in Pseudopotential",max_msh); + this->ovlp_pswfcjlq_.zero_out(); + const int startq = 0; const double pref = ModuleBase::FOUR_PI / sqrt(this->p_ucell_->omega); + std::vector aux(max_msh); + std::vector vchi(max_msh); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"dq(describe PAO in reciprocal space)",PARAM.globalv.dq); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"max q",PARAM.globalv.nqx); @@ -132,22 +114,114 @@ void psi_initializer_atomic::tabulate() GlobalV::ofs_running<<"\n number of pseudo atomic orbitals for "<label<<" is "<< atom->ncpp.nchi << std::endl; + // QE uses atom->ncpp.mesh + const int n_rgrid = (PARAM.inp.pseudo_mesh) ? atom->ncpp.mesh : atom->ncpp.msh; + std::vector chi2(n_rgrid); + for (int ic = 0; ic < atom->ncpp.nchi ;ic++) { - int n_rgrid = (PARAM.inp.pseudo_mesh)?atom->ncpp.mesh:atom->ncpp.msh; - std::vector pswfcr(n_rgrid); - for (int ir=0; irncpp.chi(ic, ir); } - normalize(n_rgrid, pswfcr, atom->ncpp.rab.data()); - if (atom->ncpp.oc[ic] >= 0.0) // reasonable occupation number, but is it always true? + // check the unit condition + for(int ir=0; irncpp.chi(ic, ir); + chi2[ir] = chi * chi; + } + double unit = 0.0; + ModuleBase::Integral::Simpson_Integral(n_rgrid, chi2.data(), atom->ncpp.rab.data(), unit); + // liuyu add 2023-10-06 + if (unit < 1e-8) { - const int l = atom->ncpp.lchi[ic]; - std::vector ovlp_pswfcjlq_q(PARAM.globalv.nqx); - this->sbt.direct(l, atom->ncpp.msh, atom->ncpp.r.data(), pswfcr.data(), PARAM.globalv.nqx, qgrid.data(), ovlp_pswfcjlq_q.data(), 1); - for (int iq = 0; iq < PARAM.globalv.nqx; iq++) + // set occupancy to a small negative number so that this wfc + // is not going to be used for starting wavefunctions + atom->ncpp.oc[ic] = -1e-8; + GlobalV::ofs_running << "WARNING: norm of atomic wavefunction # " << ic + 1 << " of atomic type " + << atom->ncpp.psd << " is zero" << std::endl; + } + + // only occupied states are normalized + if (atom->ncpp.oc[ic] < 0) + { + continue; + } + + // the US part if needed + if (atom->ncpp.tvanp) + { + int kkbeta = atom->ncpp.kkbeta; + if ((kkbeta % 2 == 0) && kkbeta > 0) { - this->ovlp_pswfcjlq_(it, ic, iq) = pref * ovlp_pswfcjlq_q[iq]; + kkbeta--; + } + std::vector norm_beta(kkbeta); + std::vector work(atom->ncpp.nbeta); + for (int ib = 0; ib < atom->ncpp.nbeta; ib++) + { + bool match = false; + if (atom->ncpp.lchi[ic] == atom->ncpp.lll[ib]) + { + if (atom->ncpp.has_so) + { + if (std::abs(atom->ncpp.jchi[ic] - atom->ncpp.jjj[ib]) < 1e-6) + { + match = true; + } + } + else + { + match = true; + } + } + if (match) + { + for (int ik = 0; ik < kkbeta; ik++) + { + norm_beta[ik] = atom->ncpp.betar(ib, ik) * atom->ncpp.chi(ic, ik); + } + ModuleBase::Integral::Simpson_Integral(kkbeta, norm_beta.data(), atom->ncpp.rab.data(), work[ib]); + } + else + { + work[ib] = 0.0; + } + } + for (int ib1 = 0; ib1 < atom->ncpp.nbeta; ib1++) + { + for (int ib2 = 0; ib2 < atom->ncpp.nbeta; ib2++) + { + unit += atom->ncpp.qqq(ib1, ib2) * work[ib1] * work[ib2]; + } + } + } // endif tvanp + + //================================= + // normalize radial wave functions + //================================= + unit = std::sqrt(unit); + if (std::abs(unit - 1.0) > 1e-6) + { + GlobalV::ofs_running << "WARNING: norm of atomic wavefunction # " << ic + 1 << " of atomic type " + << atom->ncpp.psd << " is " << unit << ", renormalized" << std::endl; + for (int ir = 0; ir < n_rgrid; ir++) + { + atom->ncpp.chi(ic, ir) /= unit; } } + + const int l = atom->ncpp.lchi[ic]; + for (int iq = startq; iq < PARAM.globalv.nqx; iq++) + { + const double q = PARAM.globalv.dq * iq; + ModuleBase::Sphbes::Spherical_Bessel(atom->ncpp.msh, atom->ncpp.r.data(), q, l, aux.data()); + for (int ir = 0; ir < atom->ncpp.msh; ir++) + { + vchi[ir] = atom->ncpp.chi(ic, ir) * aux[ir] * atom->ncpp.r[ir]; + } + + double vqint = 0.0; + ModuleBase::Integral::Simpson_Integral(atom->ncpp.msh, vchi.data(), atom->ncpp.rab.data(), vqint); + + this->ovlp_pswfcjlq_(it, ic, iq) = vqint * pref; + } } } ModuleBase::timer::tick("psi_initializer_atomic", "cal_ovlp_pswfcjlq"); @@ -161,17 +235,16 @@ std::complex phase_factor(double arg, int mode) else { return std::complex(1,0); } } -template -void psi_initializer_atomic::proj_ao_onkG(const int ik) +template +void psi_initializer_atomic::init_psig(T* psig, const int& ik) { - ModuleBase::timer::tick("psi_initializer_atomic", "proj_ao_onkG"); - const int ik_psig = (this->psig_->get_nk() == 1) ? 0 : ik; - this->psig_->fix_k(ik_psig); - //this->print_status(psi); + ModuleBase::timer::tick("psi_initializer_atomic", "init_psig"); const int npw = this->pw_wfc_->npwk[ik]; + const int npwk_max = this->pw_wfc_->npwk_max; int lmax = this->p_ucell_->lmax_ppwf; const int total_lm = (lmax + 1) * (lmax + 1); ModuleBase::matrix ylm(total_lm, npw); + ModuleBase::GlobalFunc::ZEROS(psig, PARAM.globalv.npol * this->nbands_start_ * npwk_max); std::vector> aux(npw); std::vector chiaux(npw); @@ -247,22 +320,16 @@ void psi_initializer_atomic::proj_ao_onkG(const int ik) } for(int ig = 0; ig < npw; ig++) { - (*(this->psig_))(index, - ig + this->pw_wfc_->npwk_max*is ) = - this->template cast_to_T( - lphase * cg_coeffs[is] * sk[ig] * aux[ig] * ovlp_pswfcjlg[ig] - ); + psig[(2 * index + is) * npwk_max + ig] = this->template cast_to_T( + lphase * cg_coeffs[is] * sk[ig] * aux[ig] * ovlp_pswfcjlg[ig]); } } else { - for(int ig=0; ig < npw; ig++) + for (int ig = 0; ig < npw; ig++) { - (*(this->psig_))(index, - ig + this->pw_wfc_->npwk_max*is ) = - this->template cast_to_T( - std::complex(0.0, 0.0) - ); + psig[(2 * index + is) * npwk_max + ig] + = this->template cast_to_T(std::complex(0.0, 0.0)); } } } @@ -312,11 +379,9 @@ void psi_initializer_atomic::proj_ao_onkG(const int ik) } } /* ROTATE ACCORDING TO NONCOLINEAR */ - double alpha=0.0; - double gamma=0.0; + double alpha = this->p_ucell_->atoms[it].angle1[ia]; + double gamma = -1 * this->p_ucell_->atoms[it].angle2[ia] + 0.5 * ModuleBase::PI; std::complex fup, fdw; - alpha = this->p_ucell_->atoms[it].angle1[ia]; - gamma = -1 * this->p_ucell_->atoms[it].angle2[ia] + 0.5 * ModuleBase::PI; for(int m = 0; m < 2*l+1; m++) { @@ -324,7 +389,7 @@ void psi_initializer_atomic::proj_ao_onkG(const int ik) if(index+2*l+1 > this->p_ucell_->natomwfc) { std::cout<<__FILE__<<__LINE__<<" "<p_ucell_->natomwfc<::proj_ao_onkG()","error: too many wfcs"); + //ModuleBase::WARNING_QUIT("psi_initializer_atomic::init_psig()","error: too many wfcs"); } for(int ig = 0;ig::proj_ao_onkG(const int ik) fdw = phase_factor(0.5*alpha, -1)*aux[ig]; //build the orthogonal wfc //first rotation with angle (alpha + ModuleBase::PI) around (OX) - (*(this->psig_))(index, ig) = - this->template cast_to_T(phase_factor(0.5*gamma, 0)*fup); - (*(this->psig_))(index, ig+this->pw_wfc_->npwk_max) = - this->template cast_to_T(phase_factor(-0.5*gamma, 0)*fdw); + psig[index * 2 * npwk_max + ig] + = this->template cast_to_T(phase_factor(0.5 * gamma, 0) * fup); + psig[(index * 2 + 1) * npwk_max + ig] + = this->template cast_to_T(phase_factor(-0.5 * gamma, 0) * fdw); //second rotation with angle gamma around(OZ) fup = phase_factor(0.5*(alpha + ModuleBase::PI), 1)*aux[ig]; fdw = phase_factor(0.5*(alpha + ModuleBase::PI), -1)*aux[ig]; - (*(this->psig_))(index+2*l+1, ig) = - this->template cast_to_T(phase_factor(0.5*gamma, 0)*fup); - (*(this->psig_))(index+2*l+1, ig+this->pw_wfc_->npwk_max) = - this->template cast_to_T(phase_factor(-0.5*gamma, 0)*fdw); + psig[(index + 2 * l + 1) * 2 * npwk_max + ig] + = this->template cast_to_T(phase_factor(0.5 * gamma, 0) * fup); + psig[((index + 2 * l + 1) * 2 + 1) * npwk_max + ig] + = this->template cast_to_T(phase_factor(-0.5 * gamma, 0) * fdw); } index++; } @@ -370,7 +435,7 @@ void psi_initializer_atomic::proj_ao_onkG(const int ik) if(index+2*l+1 > this->p_ucell_->natomwfc) { std::cout<<__FILE__<<__LINE__<<" "<p_ucell_->natomwfc<::proj_ao_onkG()","error: too many wfcs"); + //ModuleBase::WARNING_QUIT("psi_initializer_atomic::init_psig()","error: too many wfcs"); } for(int ig = 0;ig::proj_ao_onkG(const int ik) //first, rotation with angle alpha around(OX) for(int ig = 0; igpsig_))(index, ig) = - this->template cast_to_T( - (cos(0.5*gamman) + ModuleBase::IMAG_UNIT * sin(0.5*gamman)) * fup - ); - (*(this->psig_))(index, ig+ this->pw_wfc_->npwk_max) = - this->template cast_to_T( - (cos(0.5*gamman) - ModuleBase::IMAG_UNIT * sin(0.5*gamman)) * fdown - ); - //second rotation with angle gamma around(OZ) - fup = cos(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; - fdown = ModuleBase::IMAG_UNIT * sin(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; - (*(this->psig_))(index+2*l+1, ig) = - this->template cast_to_T( - (cos(0.5*gamman) + ModuleBase::IMAG_UNIT * sin(0.5*gamman)) * fup - ); - (*(this->psig_))(index+2*l+1, ig+ this->pw_wfc_->npwk_max) = - this->template cast_to_T( - (cos(0.5*gamman) - ModuleBase::IMAG_UNIT * sin(0.5*gamman)) * fdown - ); + fup = cos(0.5 * alpha) * aux[ig]; + fdown = ModuleBase::IMAG_UNIT * sin(0.5 * alpha) * aux[ig]; + // build the orthogonal wfc + // first rotation with angle(alpha+ModuleBase::PI) around(OX) + psig[index * 2 * npwk_max + ig] = this->template cast_to_T( + (cos(0.5 * gamman) + ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fup); + psig[(index * 2 + 1) * npwk_max + ig] = this->template cast_to_T( + (cos(0.5 * gamman) - ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fdown); + // second rotation with angle gamma around(OZ) + fup = cos(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; + fdown = ModuleBase::IMAG_UNIT * sin(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; + psig[(index + 2 * l + 1) * 2 * npwk_max + ig] = this->template cast_to_T( + (cos(0.5 * gamman) + ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fup); + psig[((index + 2 * l + 1) * 2 + 1) * npwk_max + ig] = this->template cast_to_T( + (cos(0.5 * gamman) - ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fdown); } index++; } @@ -416,10 +473,8 @@ void psi_initializer_atomic::proj_ao_onkG(const int ik) const int lm = l * l + m; for (int ig = 0; ig < npw; ig++) { - (*(this->psig_))(index, ig) = - this->template cast_to_T( - lphase * sk [ig] * ylm(lm, ig) * ovlp_pswfcjlg[ig] - ); + psig[index * npwk_max + ig] + = this->template cast_to_T(lphase * sk[ig] * ylm(lm, ig) * ovlp_pswfcjlg[ig]); } index++; } @@ -432,20 +487,13 @@ void psi_initializer_atomic::proj_ao_onkG(const int ik) /* complement the rest of bands if there are */ if(this->nbands_complem() > 0) { - this->random_t(this->psig_->get_pointer(), index, this->psig_->get_nbands(), ik); + this->random_t(psig, index, this->nbands_start_, ik); } - ModuleBase::timer::tick("psi_initializer_atomic", "proj_ao_onkG"); + ModuleBase::timer::tick("psi_initializer_atomic", "init_psig"); } -template class psi_initializer_atomic, base_device::DEVICE_CPU>; -template class psi_initializer_atomic, base_device::DEVICE_CPU>; -// gamma point calculation -template class psi_initializer_atomic; -template class psi_initializer_atomic; -#if ((defined __CUDA) || (defined __ROCM)) -template class psi_initializer_atomic, base_device::DEVICE_GPU>; -template class psi_initializer_atomic, base_device::DEVICE_GPU>; +template class psi_initializer_atomic>; +template class psi_initializer_atomic>; // gamma point calculation -template class psi_initializer_atomic; -template class psi_initializer_atomic; -#endif +template class psi_initializer_atomic; +template class psi_initializer_atomic; diff --git a/source/module_psi/psi_initializer_atomic.h b/source/module_psi/psi_initializer_atomic.h index 0bb13b604b..ef475dc7e2 100644 --- a/source/module_psi/psi_initializer_atomic.h +++ b/source/module_psi/psi_initializer_atomic.h @@ -1,45 +1,39 @@ #ifndef PSI_INITIALIZER_ATOMIC_H #define PSI_INITIALIZER_ATOMIC_H -#include "psi_initializer.h" #include "module_base/realarray.h" +#include "psi_initializer.h" /* Psi (planewave based wavefunction) initializer: atomic */ -template -class psi_initializer_atomic : public psi_initializer +template +class psi_initializer_atomic : public psi_initializer { - private: - using Real = typename GetTypeReal::type; - public: - psi_initializer_atomic() {this->set_method("atomic");} - ~psi_initializer_atomic() {}; + private: + using Real = typename GetTypeReal::type; + + public: + psi_initializer_atomic() + { + this->method_ = "atomic"; + } + ~psi_initializer_atomic(){}; - #ifdef __MPI // MPI additional implementation - /// @brief initialize the psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - Parallel_Kpoints*, //< parallel kpoints - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential - const int& = 0) override; //< MPI rank - #else - /// @brief serial version of initialize function, link psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr) override;//< nonlocal pseudopotential - #endif - virtual void allocate_table() override; - virtual void tabulate() override; - virtual void proj_ao_onkG(const int ik) override; - // additional getter - std::vector pseudopot_files() const { return pseudopot_files_; } + /// @brief initialize the psi_initializer with external data and methods + virtual void initialize(const Structure_Factor*, //< structure factor + const ModulePW::PW_Basis_K*, //< planewave basis + const UnitCell*, //< unit cell + const Parallel_Kpoints*, //< parallel kpoints + const int& = 1, //< random seed + const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential + const int& = 0) override; //< MPI rank + virtual void tabulate() override; + virtual void init_psig(T* psig, const int& ik) override; - private: - std::vector pseudopot_files_; - ModuleBase::realArray ovlp_pswfcjlq_; + protected: + // allocate memory for overlap table + void allocate_ps_table(); + std::vector pseudopot_files_; + ModuleBase::realArray ovlp_pswfcjlq_; }; #endif \ No newline at end of file diff --git a/source/module_psi/psi_initializer_atomic_random.cpp b/source/module_psi/psi_initializer_atomic_random.cpp index b502e95d72..b97e6fe5d9 100644 --- a/source/module_psi/psi_initializer_atomic_random.cpp +++ b/source/module_psi/psi_initializer_atomic_random.cpp @@ -1,57 +1,40 @@ #include "psi_initializer_atomic_random.h" -#ifdef __MPI -template -void psi_initializer_atomic_random::initialize(Structure_Factor* sf, //< structure factor - ModulePW::PW_Basis_K* pw_wfc, //< planewave basis - UnitCell* p_ucell, //< unit cell - Parallel_Kpoints* p_parakpts, //< parallel kpoints - const int& random_seed, //< random seed - pseudopot_cell_vnl* p_pspot_nl, - const int& rank) -{ - psi_initializer_atomic::initialize(sf, pw_wfc, p_ucell, p_parakpts, random_seed, p_pspot_nl, rank); -} -#else -template -void psi_initializer_atomic_random::initialize(Structure_Factor* sf, //< structure factor - ModulePW::PW_Basis_K* pw_wfc, //< planewave basis - UnitCell* p_ucell, //< unit cell - const int& random_seed, //< random seed - pseudopot_cell_vnl* p_pspot_nl) +#include "module_parameter/parameter.h" + +template +void psi_initializer_atomic_random::initialize(const Structure_Factor* sf, //< structure factor + const ModulePW::PW_Basis_K* pw_wfc, //< planewave basis + const UnitCell* p_ucell, //< unit cell + const Parallel_Kpoints* p_parakpts, //< parallel kpoints + const int& random_seed, //< random seed + const pseudopot_cell_vnl* p_pspot_nl, + const int& rank) { - psi_initializer_atomic::initialize(sf, pw_wfc, p_ucell, random_seed, p_pspot_nl); + psi_initializer_atomic::initialize(sf, pw_wfc, p_ucell, p_parakpts, random_seed, p_pspot_nl, rank); } -#endif -template -void psi_initializer_atomic_random::proj_ao_onkG(const int ik) +template +void psi_initializer_atomic_random::init_psig(T* psig, const int& ik) { - double rm = this->random_mix(); - const int ik_psig = (this->psig_->get_nk() == 1) ? 0 : ik; - this->psig_->fix_k(ik_psig); - psi_initializer_atomic::proj_ao_onkG(ik); - psi::Psi psi_random(1, this->psig_->get_nbands(), this->psig_->get_nbasis(), nullptr); + double rm = this->mixing_coef_; + psi_initializer_atomic::init_psig(psig, ik); + const int npol = PARAM.globalv.npol; + const int nbasis = this->pw_wfc_->npwk_max * npol; + psi::Psi psi_random(1, this->nbands_start_, nbasis, nullptr); psi_random.fix_k(0); - this->random_t(psi_random.get_pointer(), 0, psi_random.get_nbands(), ik); - for(int iband = 0; iband < this->psig_->get_nbands(); iband++) + this->random_t(psi_random.get_pointer(), 0, this->nbands_start_, ik, 0); + for (int iband = 0; iband < this->nbands_start_; iband++) { - for(int ibasis = 0; ibasis < this->psig_->get_nbasis(); ibasis++) + for (int ibasis = 0; ibasis < nbasis; ibasis++) { - (*(this->psig_))(iband, ibasis) = ((Real)(1-rm))*(*(this->psig_))(iband, ibasis) + ((Real)rm)*psi_random(iband, ibasis); + psig[iband * nbasis + ibasis] *= (T(1.0) + Real(rm) * psi_random(iband, ibasis)); } } } -template class psi_initializer_atomic_random, base_device::DEVICE_CPU>; -template class psi_initializer_atomic_random, base_device::DEVICE_CPU>; -// gamma point calculation -template class psi_initializer_atomic_random; -template class psi_initializer_atomic_random; -#if ((defined __CUDA) || (defined __ROCM)) -template class psi_initializer_atomic_random, base_device::DEVICE_GPU>; -template class psi_initializer_atomic_random, base_device::DEVICE_GPU>; +template class psi_initializer_atomic_random>; +template class psi_initializer_atomic_random>; // gamma point calculation -template class psi_initializer_atomic_random; -template class psi_initializer_atomic_random; -#endif +template class psi_initializer_atomic_random; +template class psi_initializer_atomic_random; \ No newline at end of file diff --git a/source/module_psi/psi_initializer_atomic_random.h b/source/module_psi/psi_initializer_atomic_random.h index 88b2bcfb93..1ee2353310 100644 --- a/source/module_psi/psi_initializer_atomic_random.h +++ b/source/module_psi/psi_initializer_atomic_random.h @@ -1,42 +1,37 @@ #ifndef PSI_INITIALIZER_ATOMIC_RANDOM_H #define PSI_INITIALIZER_ATOMIC_RANDOM_H -#include "psi_initializer_atomic.h" -#include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h" #include "module_cell/parallel_kpoints.h" +#include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h" +#include "psi_initializer_atomic.h" /* Psi (planewave based wavefunction) initializer: atomic+random */ -template -class psi_initializer_atomic_random : public psi_initializer_atomic +template +class psi_initializer_atomic_random : public psi_initializer_atomic { - private: - using Real = typename GetTypeReal::type; - public: - psi_initializer_atomic_random() {this->set_method("atomic+random"); this->set_random_mix(0.05);} - ~psi_initializer_atomic_random() {}; + private: + using Real = typename GetTypeReal::type; + + public: + psi_initializer_atomic_random() + { + this->method_ = "atomic+random"; + this->mixing_coef_ = 0.05; + } + ~psi_initializer_atomic_random(){}; + + /// @brief initialize the psi_initializer with external data and methods + virtual void initialize(const Structure_Factor*, //< structure factor + const ModulePW::PW_Basis_K*, //< planewave basis + const UnitCell*, //< unit cell + const Parallel_Kpoints*, //< parallel kpoints + const int& = 1, //< random seed + const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential + const int& = 0) override; //< MPI rank - #ifdef __MPI // MPI additional implementation - /// @brief initialize the psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - Parallel_Kpoints*, //< parallel kpoints - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential - const int& = 0) override; //< MPI rank - #else - /// @brief serial version of initialize function, link psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr) override;//< nonlocal pseudopotential - #endif + virtual void init_psig(T* psig, const int& ik) override; - virtual void proj_ao_onkG(const int ik) override; - virtual void tabulate() override {psi_initializer_atomic::tabulate();}; - - private: + private: }; #endif \ No newline at end of file diff --git a/source/module_psi/psi_initializer_file.cpp b/source/module_psi/psi_initializer_file.cpp new file mode 100644 index 0000000000..a1871672f9 --- /dev/null +++ b/source/module_psi/psi_initializer_file.cpp @@ -0,0 +1,51 @@ +#include "psi_initializer_file.h" + +#include "module_base/timer.h" +#include "module_cell/klist.h" +#include "module_io/read_wfc_pw.h" +#include "module_parameter/parameter.h" +template +void psi_initializer_file::initialize(const Structure_Factor* sf, + const ModulePW::PW_Basis_K* pw_wfc, + const UnitCell* p_ucell, + const Parallel_Kpoints* p_parakpts, + const int& random_seed, + const pseudopot_cell_vnl* p_pspot_nl, + const int& rank) +{ + this->pw_wfc_ = pw_wfc; + this->p_ucell_ = p_ucell; + this->p_parakpts_ = p_parakpts; + this->random_seed_ = random_seed; + this->p_pspot_nl_ = p_pspot_nl; + this->nbands_start_ = PARAM.inp.nbands; + this->nbands_complem_ = 0; +} + +template +void psi_initializer_file::init_psig(T* psig, const int& ik) +{ + ModuleBase::timer::tick("psi_initializer_file", "init_psig"); + const int npol = PARAM.globalv.npol; + const int nbasis = this->pw_wfc_->npwk_max * npol; + const int pre_nk = PARAM.inp.nspin == 2 ? 2 : 1; + const int nkstot = this->p_parakpts_->nkstot_np * pre_nk; + ModuleBase::ComplexMatrix wfcatom(this->nbands_start_, nbasis); + std::stringstream filename; + int ik_tot = K_Vectors::get_ik_global(ik, nkstot); + filename << PARAM.globalv.global_readin_dir << "WAVEFUNC" << ik_tot + 1 << ".dat"; + ModuleIO::read_wfc_pw(filename.str(), this->pw_wfc_, ik, nkstot, wfcatom); + + assert(this->nbands_start_ <= wfcatom.nr); + for (int ib = 0; ib < this->nbands_start_; ib++) + { + for (int ig = 0; ig < nbasis; ig++) + { + psig[ib * nbasis + ig] = this->template cast_to_T(wfcatom(ib, ig)); + } + } + ModuleBase::timer::tick("psi_initializer_file", "init_psig"); +} + +template class psi_initializer_file>; +template class psi_initializer_file>; \ No newline at end of file diff --git a/source/module_psi/psi_initializer_file.h b/source/module_psi/psi_initializer_file.h new file mode 100644 index 0000000000..e4e527b4f7 --- /dev/null +++ b/source/module_psi/psi_initializer_file.h @@ -0,0 +1,36 @@ +#ifndef PSI_INITIALIZER_FILE_H +#define PSI_INITIALIZER_FILE_H + +#include "psi_initializer.h" + +/* +Psi (planewave based wavefunction) initializer: random method +*/ +template +class psi_initializer_file : public psi_initializer +{ + private: + using Real = typename GetTypeReal::type; + + public: + psi_initializer_file() + { + this->method_ = "file"; + }; + ~psi_initializer_file(){}; + + /// @brief initialize the psi_initializer with external data and methods + virtual void initialize(const Structure_Factor*, //< structure factor + const ModulePW::PW_Basis_K*, //< planewave basis + const UnitCell*, //< unit cell + const Parallel_Kpoints*, //< parallel kpoints + const int& = 1, //< random seed + const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential + const int& = 0) override; //< MPI rank + + /// @brief calculate and output planewave wavefunction + /// @param ik kpoint index + /// @return initialized planewave wavefunction (psi::Psi>*) + virtual void init_psig(T* psig, const int& ik) override; +}; +#endif \ No newline at end of file diff --git a/source/module_psi/psi_initializer_nao.cpp b/source/module_psi/psi_initializer_nao.cpp index f9b446b03d..de71457c73 100644 --- a/source/module_psi/psi_initializer_nao.cpp +++ b/source/module_psi/psi_initializer_nao.cpp @@ -16,13 +16,13 @@ #include "module_base/parallel_common.h" #include "module_base/parallel_reduce.h" #endif -#include "module_parameter/parameter.h" #include "module_io/orb_io.h" +#include "module_parameter/parameter.h" // GlobalV::NQX and GlobalV::DQ are here #include "module_parameter/parameter.h" -#include #include +#include /* I don't know why some variables are distributed while others not... for example the orbital_files... @@ -42,8 +42,8 @@ void normalize(const std::vector& r, std::vector& flz) std::transform(flz.begin(), flz.end(), flz.begin(), [norm](double flz) { return flz / norm; }); } -template -void psi_initializer_nao::read_external_orbs(std::string* orbital_files, const int& rank) +template +void psi_initializer_nao::read_external_orbs(const std::string* orbital_files, const int& rank) { ModuleBase::timer::tick("psi_initializer_nao", "read_external_orbs"); @@ -56,7 +56,7 @@ void psi_initializer_nao::read_external_orbs(std::string* orbital_fil if (rank == 0) { #endif - std::copy(orbital_files, orbital_files + this->p_ucell_->ntype, this->orbital_files_.begin()); + std::copy(orbital_files, orbital_files + this->p_ucell_->ntype, this->orbital_files_.begin()); #ifdef __MPI } Parallel_Common::bcast_string(this->orbital_files_.data(), this->p_ucell_->ntype); @@ -75,15 +75,14 @@ void psi_initializer_nao::read_external_orbs(std::string* orbital_fil #endif if (!is_open) { - GlobalV::ofs_warning << "psi_initializer_nao::read_orbital_files: cannot open orbital file: " - << this->orbital_files_[it] << std::endl; - ModuleBase::WARNING_QUIT("psi_initializer_nao::read_orbital_files", - "cannot open orbital file."); + GlobalV::ofs_warning << "psi_initializer_nao::read_orbital_files: cannot open orbital file: " + << this->orbital_files_[it] << std::endl; + ModuleBase::WARNING_QUIT("psi_initializer_nao::read_orbital_files", "cannot open orbital file."); } else { - GlobalV::ofs_running << "psi_initializer_nao::read_orbital_files: reading orbital file: " - << this->orbital_files_[it] << std::endl; + GlobalV::ofs_running << "psi_initializer_nao::read_orbital_files: reading orbital file: " + << this->orbital_files_[it] << std::endl; } std::string elem; // garbage value, will discard double ecut; // garbage value, will discard @@ -111,9 +110,7 @@ void psi_initializer_nao::read_external_orbs(std::string* orbital_fil }); // chi_ this->chi_[it].resize(nchi); - std::for_each(this->chi_[it].begin(), this->chi_[it].end(), [nr](std::vector& chi) { - chi.resize(nr); - }); + std::for_each(this->chi_[it].begin(), this->chi_[it].end(), [nr](std::vector& chi) { chi.resize(nr); }); for (int ichi = 0; ichi < nchi; ichi++) { std::copy(radials[ichi].begin(), radials[ichi].end(), this->chi_[it][ichi].begin()); @@ -122,12 +119,12 @@ void psi_initializer_nao::read_external_orbs(std::string* orbital_fil ModuleBase::timer::tick("psi_initializer_nao", "read_external_orbs"); } -template -void psi_initializer_nao::allocate_table() +template +void psi_initializer_nao::allocate_ao_table() { // find correct dimension for ovlp_flzjlq int ntype = this->p_ucell_->ntype; - int lmaxmax = 0; // lmaxmax + int lmaxmax = 0; // lmaxmax int nzeta_max = 0; // dim3 should be the maximum number of zeta for each atomtype for (int it = 0; it < this->p_ucell_->ntype; it++) { @@ -142,25 +139,24 @@ void psi_initializer_nao::allocate_table() } if (nzeta_max == 0) { - ModuleBase::WARNING_QUIT("psi_initializer_nao::psi_initializer_nao", + ModuleBase::WARNING_QUIT("psi_initializer_nao::psi_initializer_nao", "there is not ANY numerical atomic orbital read in present system, quit."); } // allocate a map (it, l, izeta) -> i, should allocate memory of ntype * lmax * nzeta_max this->projmap_.create(ntype, lmaxmax + 1, nzeta_max); } -#ifdef __MPI -template -void psi_initializer_nao::initialize(Structure_Factor* sf, - ModulePW::PW_Basis_K* pw_wfc, - UnitCell* p_ucell, - Parallel_Kpoints* p_parakpts, - const int& random_seed, - pseudopot_cell_vnl* p_pspot_nl, - const int& rank) +template +void psi_initializer_nao::initialize(const Structure_Factor* sf, + const ModulePW::PW_Basis_K* pw_wfc, + const UnitCell* p_ucell, + const Parallel_Kpoints* p_parakpts, + const int& random_seed, + const pseudopot_cell_vnl* p_pspot_nl, + const int& rank) { ModuleBase::timer::tick("psi_initializer_nao", "initialize_mpi"); - + // import this->sf_ = sf; this->pw_wfc_ = pw_wfc; @@ -168,48 +164,43 @@ void psi_initializer_nao::initialize(Structure_Factor* sf, this->p_parakpts_ = p_parakpts; this->p_pspot_nl_ = p_pspot_nl; this->random_seed_ = random_seed; - + // allocate - this->allocate_table(); + this->allocate_ao_table(); this->read_external_orbs(this->p_ucell_->orbital_fn.data(), rank); // then for generate random number to fill in the wavefunction this->ixy2is_.clear(); this->ixy2is_.resize(this->pw_wfc_->fftnxy); this->pw_wfc_->getfftixy2is(this->ixy2is_.data()); - ModuleBase::timer::tick("psi_initializer_nao", "initialize_mpi"); -} -#else -template -void psi_initializer_nao::initialize(Structure_Factor* sf, - ModulePW::PW_Basis_K* pw_wfc, - UnitCell* p_ucell, - const int& random_seed, - pseudopot_cell_vnl* p_pspot_nl) -{ - ModuleBase::timer::tick("psi_initializer_nao", "initialize_serial"); - - // import - this->sf_ = sf; - this->pw_wfc_ = pw_wfc; - this->p_ucell_ = p_ucell; - this->p_pspot_nl_ = p_pspot_nl; - this->random_seed_ = random_seed; - - // allocate - this->allocate_table(); - this->read_external_orbs(this->p_ucell_->orbital_fn.data(), 0); - // then for generate random number to fill in the wavefunction - this->ixy2is_.clear(); - this->ixy2is_.resize(this->pw_wfc_->fftnxy); - this->pw_wfc_->getfftixy2is(this->ixy2is_.data()); - ModuleBase::timer::tick("psi_initializer_nao", "initialize_serial"); + int nbands_local = 0; + for (int it = 0; it < this->p_ucell_->ntype; it++) + { + for (int l = 0; l < this->p_ucell_->atoms[it].nwl + 1; l++) + { + /* EVERY ZETA FOR (2l+1) ORBS */ + const int nchi = this->p_ucell_->atoms[it].l_nchi[l]; + const int degen_l = (l == 0) ? 1 : 2 * l + 1; + nbands_local += nchi * degen_l * PARAM.globalv.npol * this->p_ucell_->atoms[it].na; + /* + non-rotate basis, nbands_local*=2 for PARAM.globalv.npol = 2 is enough + */ + // nbands_local += this->p_ucell_->atoms[it].l_nchi[l]*(2*l+1) * PARAM.globalv.npol; + /* + rotate basis, nbands_local*=4 for p, d, f,... orbitals, and nbands_local*=2 for s orbitals + risky when NSPIN = 4, problematic psi value, needed to be checked + */ + } + } + this->nbands_start_ = std::max(nbands_local, PARAM.inp.nbands); + this->nbands_complem_ = this->nbands_start_ - nbands_local; + + ModuleBase::timer::tick("psi_initializer_nao", "initialize_mpi"); } -#endif -template -void psi_initializer_nao::tabulate() +template +void psi_initializer_nao::tabulate() { ModuleBase::timer::tick("psi_initializer_nao", "tabulate"); @@ -219,9 +210,11 @@ void psi_initializer_nao::tabulate() std::for_each(qgrid.begin(), qgrid.end(), [this](double& q) { q = q * PARAM.globalv.dq; }); // only when needed, allocate memory for cubspl_ - if (this->cubspl_.get()) { this->cubspl_.reset(); } - this->cubspl_ = std::unique_ptr( - new ModuleBase::CubicSpline(qgrid.size(), qgrid.data())); + if (this->cubspl_.get()) + { + this->cubspl_.reset(); + } + this->cubspl_ = std::unique_ptr(new ModuleBase::CubicSpline(qgrid.size(), qgrid.data())); // calculate the total number of radials and call reserve to allocate memory int nchi = 0; @@ -234,7 +227,7 @@ void psi_initializer_nao::tabulate() } this->cubspl_->reserve(nchi); ModuleBase::SphericalBesselTransformer sbt_(true); // bool: enable cache - + // tabulate the spherical bessel transform of numerical orbital function std::vector Jlfq(PARAM.globalv.nqx, 0.0); int i = 0; @@ -261,22 +254,22 @@ void psi_initializer_nao::tabulate() ModuleBase::timer::tick("psi_initializer_nao", "tabulate"); } -template -void psi_initializer_nao::proj_ao_onkG(const int ik) +template +void psi_initializer_nao::init_psig(T* psig, const int& ik) { ModuleBase::timer::tick("psi_initializer_nao", "initialize"); assert(ik >= 0); - const int ik_psig = (this->psig_->get_nk() == 1) ? 0 : ik; - this->psig_->fix_k(ik_psig); const int npw = this->pw_wfc_->npwk[ik]; + const int npwk_max = this->pw_wfc_->npwk_max; const int total_lm = (this->p_ucell_->lmax + 1) * (this->p_ucell_->lmax + 1); ModuleBase::matrix ylm(total_lm, npw); + ModuleBase::GlobalFunc::ZEROS(psig, PARAM.globalv.npol * this->nbands_start_ * npwk_max); std::vector> aux(npw); std::vector qnorm(npw); std::vector> q(npw); - - #pragma omp parallel for schedule(static, 4096 / sizeof(double)) + +#pragma omp parallel for schedule(static, 4096 / sizeof(double)) for (int ig = 0; ig < npw; ig++) { q[ig] = this->pw_wfc_->getgpluskcar(ik, ig); @@ -335,32 +328,30 @@ void psi_initializer_nao::proj_ao_onkG(const int ik) for (int m = 0; m < 2 * L + 1; m++) { const int lm = L * L + m; - #pragma omp parallel for +#pragma omp parallel for for (int ig = 0; ig < npw; ig++) { aux[ig] = sk[ig] * ylm(lm, ig) * Jlfq[ig]; } - #pragma omp parallel for +#pragma omp parallel for for (int ig = 0; ig < npw; ig++) { fup = cos(0.5 * alpha) * aux[ig]; fdown = ModuleBase::IMAG_UNIT * sin(0.5 * alpha) * aux[ig]; // build the orthogonal wfc // first rotation with angle (alpha + ModuleBase::PI) around (OX) - (*(this->psig_))(ibasis, ig) = this->template cast_to_T( + psig[ibasis * 2 * npwk_max + ig] = this->template cast_to_T( (cos(0.5 * gamma) + ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fup); - (*(this->psig_))(ibasis, ig + this->pw_wfc_->npwk_max) - = this->template cast_to_T( - (cos(0.5 * gamma) - ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fdown); + psig[(ibasis * 2 + 1) * npwk_max + ig] = this->template cast_to_T( + (cos(0.5 * gamma) - ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fdown); // second rotation with angle gamma around(OZ) fup = cos(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; fdown = ModuleBase::IMAG_UNIT * sin(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; - (*(this->psig_))(ibasis + 2 * L + 1, ig) = this->template cast_to_T( + psig[(ibasis + 2 * L + 1) * 2 * npwk_max + ig] = this->template cast_to_T( (cos(0.5 * gamma) + ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fup); - (*(this->psig_))(ibasis + 2 * L + 1, ig + this->pw_wfc_->npwk_max) - = this->template cast_to_T( - (cos(0.5 * gamma) - ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fdown); + psig[((ibasis + 2 * L + 1) * 2 + 1) * npwk_max + ig] = this->template cast_to_T( + (cos(0.5 * gamma) - ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fdown); } ibasis++; } @@ -374,11 +365,10 @@ void psi_initializer_nao::proj_ao_onkG(const int ik) for (int m = 0; m < 2 * L + 1; m++) { const int lm = L * L + m; - #pragma omp parallel for +#pragma omp parallel for for (int ig = 0; ig < npw; ig++) { - (*(this->psig_))(ibasis, ig) - = this->template cast_to_T(lphase * sk[ig] * ylm(lm, ig) * Jlfq[ig]); + psig[ibasis * npwk_max + ig] = this->template cast_to_T(lphase * sk[ig] * ylm(lm, ig) * Jlfq[ig]); } ++ibasis; } @@ -392,20 +382,13 @@ void psi_initializer_nao::proj_ao_onkG(const int ik) /* complement the rest of bands if there are */ if (this->nbands_complem() > 0) { - this->random_t(this->psig_->get_pointer(), ibasis, this->psig_->get_nbands(), ik); + this->random_t(psig, ibasis, this->nbands_start_, ik); } ModuleBase::timer::tick("psi_initializer_nao", "initialize"); } -template class psi_initializer_nao, base_device::DEVICE_CPU>; -template class psi_initializer_nao, base_device::DEVICE_CPU>; +template class psi_initializer_nao>; +template class psi_initializer_nao>; // gamma point calculation -template class psi_initializer_nao; -template class psi_initializer_nao; -#if ((defined __CUDA) || (defined __ROCM)) -template class psi_initializer_nao, base_device::DEVICE_GPU>; -template class psi_initializer_nao, base_device::DEVICE_GPU>; -// gamma point calculation -template class psi_initializer_nao; -template class psi_initializer_nao; -#endif +template class psi_initializer_nao; +template class psi_initializer_nao; diff --git a/source/module_psi/psi_initializer_nao.h b/source/module_psi/psi_initializer_nao.h index b7643d38d7..324e201df1 100644 --- a/source/module_psi/psi_initializer_nao.h +++ b/source/module_psi/psi_initializer_nao.h @@ -1,69 +1,103 @@ #ifndef PSI_INITIALIZER_NAO_H #define PSI_INITIALIZER_NAO_H -#include "psi_initializer.h" -#include "module_base/realarray.h" #include "module_base/cubic_spline.h" +#include "module_base/realarray.h" +#include "psi_initializer.h" + #include /* Psi (planewave based wavefunction) initializer: numerical atomic orbital method */ -template -class psi_initializer_nao : public psi_initializer +template +class psi_initializer_nao : public psi_initializer { - private: - using Real = typename GetTypeReal::type; - public: - psi_initializer_nao() {this->set_method("nao");}; - ~psi_initializer_nao() {}; + private: + using Real = typename GetTypeReal::type; + + public: + psi_initializer_nao() + { + this->method_ = "nao"; + }; + ~psi_initializer_nao(){}; - virtual void proj_ao_onkG(const int ik) override; + virtual void init_psig(T* psig, const int& ik) override; - #ifdef __MPI // MPI additional implementation - /// @brief initialize the psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - Parallel_Kpoints*, //< parallel kpoints - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential - const int& = 0) override; //< MPI rank - #else - /// @brief serial version of initialize function, link psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr) override;//< nonlocal pseudopotential - #endif + /// @brief initialize the psi_initializer with external data and methods + virtual void initialize(const Structure_Factor*, //< structure factor + const ModulePW::PW_Basis_K*, //< planewave basis + const UnitCell*, //< unit cell + const Parallel_Kpoints*, //< parallel kpoints + const int& = 1, //< random seed + const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential + const int& = 0) override; //< MPI rank - void read_external_orbs(std::string* orbital_files, const int& rank); - virtual void allocate_table() override; - virtual void tabulate() override; - - std::vector external_orbs() const { return orbital_files_; } - std::vector> nr() const { return nr_; } - std::vector nr(const int& itype) const { return nr_[itype]; } - int nr(const int& itype, const int& ichi) const { return nr_[itype][ichi]; } - std::vector>> chi() const { return chi_; } - std::vector> chi(const int& itype) const { return chi_[itype]; } - std::vector chi(const int& itype, const int& ichi) const { return chi_[itype][ichi]; } - double chi(const int& itype, const int& ichi, const int& ir) const { return chi_[itype][ichi][ir]; } - std::vector>> rgrid() const { return rgrid_; } - std::vector> rgrid(const int& itype) const { return rgrid_[itype]; } - std::vector rgrid(const int& itype, const int& ichi) const { return rgrid_[itype][ichi]; } - double rgrid(const int& itype, const int& ichi, const int& ir) const { return rgrid_[itype][ichi][ir]; } + void read_external_orbs(const std::string* orbital_files, const int& rank); + virtual void tabulate() override; + std::vector external_orbs() const + { + return orbital_files_; + } + std::vector> nr() const + { + return nr_; + } + std::vector nr(const int& itype) const + { + return nr_[itype]; + } + int nr(const int& itype, const int& ichi) const + { + return nr_[itype][ichi]; + } + std::vector>> chi() const + { + return chi_; + } + std::vector> chi(const int& itype) const + { + return chi_[itype]; + } + std::vector chi(const int& itype, const int& ichi) const + { + return chi_[itype][ichi]; + } + double chi(const int& itype, const int& ichi, const int& ir) const + { + return chi_[itype][ichi][ir]; + } + std::vector>> rgrid() const + { + return rgrid_; + } + std::vector> rgrid(const int& itype) const + { + return rgrid_[itype]; + } + std::vector rgrid(const int& itype, const int& ichi) const + { + return rgrid_[itype][ichi]; + } + double rgrid(const int& itype, const int& ichi, const int& ir) const + { + return rgrid_[itype][ichi][ir]; + } - private: - std::vector orbital_files_; - /// @brief cubic spline for interpolation - std::unique_ptr cubspl_; - /// @brief radial map, [itype][l][izeta] -> i - ModuleBase::realArray projmap_; - /// @brief number of realspace grids per type per chi, [itype][ichi] - std::vector> nr_; - /// @brief data of numerical atomic orbital per type per chi per position, [itype][ichi][ir] - std::vector>> chi_; - /// @brief r of numerical atomic orbital per type per chi per position, [itype][ichi][ir] - std::vector>> rgrid_; + protected: + /// @brief allocate memory for overlap table + void allocate_ao_table(); + std::vector orbital_files_; + /// @brief cubic spline for interpolation + std::unique_ptr cubspl_; + /// @brief radial map, [itype][l][izeta] -> i + ModuleBase::realArray projmap_; + /// @brief number of realspace grids per type per chi, [itype][ichi] + std::vector> nr_; + /// @brief data of numerical atomic orbital per type per chi per position, [itype][ichi][ir] + std::vector>> chi_; + /// @brief r of numerical atomic orbital per type per chi per position, [itype][ichi][ir] + std::vector>> rgrid_; + /// @brief useful for atomic-like methods + ModuleBase::SphericalBesselTransformer sbt; }; #endif \ No newline at end of file diff --git a/source/module_psi/psi_initializer_nao_random.cpp b/source/module_psi/psi_initializer_nao_random.cpp index 15f376fcd5..ef0811fd9d 100644 --- a/source/module_psi/psi_initializer_nao_random.cpp +++ b/source/module_psi/psi_initializer_nao_random.cpp @@ -1,57 +1,40 @@ #include "psi_initializer_nao_random.h" -#ifdef __MPI -template -void psi_initializer_nao_random::initialize(Structure_Factor* sf, - ModulePW::PW_Basis_K* pw_wfc, - UnitCell* p_ucell, - Parallel_Kpoints* p_parakpts, - const int& random_seed, - pseudopot_cell_vnl* p_pspot_nl, - const int& rank) -{ - psi_initializer_nao::initialize(sf, pw_wfc, p_ucell, p_parakpts, random_seed, p_pspot_nl, rank); -} -#else -template -void psi_initializer_nao_random::initialize(Structure_Factor* sf, - ModulePW::PW_Basis_K* pw_wfc, - UnitCell* p_ucell, - const int& random_seed, - pseudopot_cell_vnl* p_pspot_nl) +#include "module_parameter/parameter.h" + +template +void psi_initializer_nao_random::initialize(const Structure_Factor* sf, + const ModulePW::PW_Basis_K* pw_wfc, + const UnitCell* p_ucell, + const Parallel_Kpoints* p_parakpts, + const int& random_seed, + const pseudopot_cell_vnl* p_pspot_nl, + const int& rank) { - psi_initializer_nao::initialize(sf, pw_wfc, p_ucell, random_seed, p_pspot_nl); + psi_initializer_nao::initialize(sf, pw_wfc, p_ucell, p_parakpts, random_seed, p_pspot_nl, rank); } -#endif -template -void psi_initializer_nao_random::proj_ao_onkG(const int ik) +template +void psi_initializer_nao_random::init_psig(T* psig, const int& ik) { - double rm = this->random_mix(); - const int ik_psig = (this->psig_->get_nk() == 1) ? 0 : ik; - this->psig_->fix_k(ik_psig); - psi_initializer_nao::proj_ao_onkG(ik); - psi::Psi psi_random(1, this->psig_->get_nbands(), this->psig_->get_nbasis(), nullptr); + double rm = this->mixing_coef_; + psi_initializer_nao::init_psig(psig, ik); + const int npol = PARAM.globalv.npol; + const int nbasis = this->pw_wfc_->npwk_max * npol; + psi::Psi psi_random(1, this->nbands_start_, nbasis, nullptr); psi_random.fix_k(0); - this->random_t(psi_random.get_pointer(), 0, psi_random.get_nbands(), ik); - for(int iband = 0; iband < this->psig_->get_nbands(); iband++) + this->random_t(psi_random.get_pointer(), 0, this->nbands_start_, ik, 0); + for (int iband = 0; iband < this->nbands_start_; iband++) { - for(int ibasis = 0; ibasis < this->psig_->get_nbasis(); ibasis++) + for (int ibasis = 0; ibasis < nbasis; ibasis++) { - (*(this->psig_))(iband, ibasis) = ((Real)(1-rm))*(*(this->psig_))(iband, ibasis) + ((Real)rm)*psi_random(iband, ibasis); + psig[iband * nbasis + ibasis] *= (T(1.0) + Real(rm) * psi_random(iband, ibasis)); } } } -template class psi_initializer_nao_random, base_device::DEVICE_CPU>; -template class psi_initializer_nao_random, base_device::DEVICE_CPU>; -// gamma point calculation -template class psi_initializer_nao_random; -template class psi_initializer_nao_random; -#if ((defined __CUDA) || (defined __ROCM)) -template class psi_initializer_nao_random, base_device::DEVICE_GPU>; -template class psi_initializer_nao_random, base_device::DEVICE_GPU>; +template class psi_initializer_nao_random>; +template class psi_initializer_nao_random>; // gamma point calculation -template class psi_initializer_nao_random; -template class psi_initializer_nao_random; -#endif \ No newline at end of file +template class psi_initializer_nao_random; +template class psi_initializer_nao_random; \ No newline at end of file diff --git a/source/module_psi/psi_initializer_nao_random.h b/source/module_psi/psi_initializer_nao_random.h index 8fd6edb4c6..acbdb76945 100644 --- a/source/module_psi/psi_initializer_nao_random.h +++ b/source/module_psi/psi_initializer_nao_random.h @@ -1,40 +1,35 @@ #ifndef PSI_INITIALIZER_NAO_RANDOM_H #define PSI_INITIALIZER_NAO_RANDOM_H -#include "psi_initializer_nao.h" -#include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h" #include "module_cell/parallel_kpoints.h" +#include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h" +#include "psi_initializer_nao.h" /* Psi (planewave based wavefunction) initializer: numerical atomic orbital + random method */ -template -class psi_initializer_nao_random : public psi_initializer_nao +template +class psi_initializer_nao_random : public psi_initializer_nao { - private: - using Real = typename GetTypeReal::type; - public: - psi_initializer_nao_random() {this->set_method("nao+random"); this->set_random_mix(0.05);}; - ~psi_initializer_nao_random() {}; + private: + using Real = typename GetTypeReal::type; + + public: + psi_initializer_nao_random() + { + this->method_ = "nao+random"; + this->mixing_coef_ = 0.05; + }; + ~psi_initializer_nao_random(){}; - #ifdef __MPI // MPI additional implementation - /// @brief initialize the psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - Parallel_Kpoints*, //< parallel kpoints - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential - const int& = 0) override; //< MPI rank - #else - /// @brief serial version of initialize function, link psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr) override;//< nonlocal pseudopotential - #endif + /// @brief initialize the psi_initializer with external data and methods + virtual void initialize(const Structure_Factor*, //< structure factor + const ModulePW::PW_Basis_K*, //< planewave basis + const UnitCell*, //< unit cell + const Parallel_Kpoints*, //< parallel kpoints + const int& = 1, //< random seed + const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential + const int& = 0) override; //< MPI rank - virtual void proj_ao_onkG(const int ik) override; - virtual void tabulate() override {psi_initializer_nao::tabulate();}; + virtual void init_psig(T* psig, const int& ik) override; }; #endif \ No newline at end of file diff --git a/source/module_psi/psi_initializer_random.cpp b/source/module_psi/psi_initializer_random.cpp index fcabca18fc..56497d5c7b 100644 --- a/source/module_psi/psi_initializer_random.cpp +++ b/source/module_psi/psi_initializer_random.cpp @@ -3,19 +3,18 @@ #include #endif #include "module_base/parallel_global.h" -#include "module_cell/parallel_kpoints.h" -// basic functions support #include "module_base/timer.h" +#include "module_cell/parallel_kpoints.h" +#include "module_parameter/parameter.h" -#ifdef __MPI -template -void psi_initializer_random::initialize(Structure_Factor* sf, - ModulePW::PW_Basis_K* pw_wfc, - UnitCell* p_ucell, - Parallel_Kpoints* p_parakpts, - const int& random_seed, - pseudopot_cell_vnl* p_pspot_nl, - const int& rank) +template +void psi_initializer_random::initialize(const Structure_Factor* sf, + const ModulePW::PW_Basis_K* pw_wfc, + const UnitCell* p_ucell, + const Parallel_Kpoints* p_parakpts, + const int& random_seed, + const pseudopot_cell_vnl* p_pspot_nl, + const int& rank) { this->pw_wfc_ = pw_wfc; this->p_ucell_ = p_ucell; @@ -25,55 +24,20 @@ void psi_initializer_random::initialize(Structure_Factor* sf, this->ixy2is_.clear(); this->ixy2is_.resize(this->pw_wfc_->fftnxy); this->pw_wfc_->getfftixy2is(this->ixy2is_.data()); + this->nbands_start_ = PARAM.inp.nbands; + this->nbands_complem_ = 0; } -#else -template -void psi_initializer_random::initialize(Structure_Factor* sf, - ModulePW::PW_Basis_K* pw_wfc, - UnitCell* p_ucell, - const int& random_seed, - pseudopot_cell_vnl* p_pspot_nl) -{ - this->pw_wfc_ = pw_wfc; - this->p_ucell_ = p_ucell; - this->random_seed_ = random_seed; - this->p_pspot_nl_ = p_pspot_nl; - this->ixy2is_.clear(); - this->ixy2is_.resize(this->pw_wfc_->fftnxy); - this->pw_wfc_->getfftixy2is(this->ixy2is_.data()); -} -#endif -template -void psi_initializer_random::random(T* psi, - const int iw_start, - const int iw_end, - const int ik) -{ - ModuleBase::timer::tick("psi_initializer_random", "random"); - this->random_t(psi, iw_start, iw_end, ik); - ModuleBase::timer::tick("psi_initializer_random", "random"); -} - -template -void psi_initializer_random::proj_ao_onkG(const int ik) +template +void psi_initializer_random::init_psig(T* psig, const int& ik) { ModuleBase::timer::tick("psi_initializer_random", "initialize"); - const int ik_psig = (this->psig_->get_nk() == 1) ? 0 : ik; - this->psig_->fix_k(ik_psig); - this->random(this->psig_->get_pointer(), 0, this->psig_->get_nbands(), ik); + this->random_t(psig, 0, this->nbands_start_, ik); ModuleBase::timer::tick("psi_initializer_random", "initialize"); } -template class psi_initializer_random, base_device::DEVICE_CPU>; -template class psi_initializer_random, base_device::DEVICE_CPU>; -// gamma point calculation -template class psi_initializer_random; -template class psi_initializer_random; -#if ((defined __CUDA) || (defined __ROCM)) -template class psi_initializer_random, base_device::DEVICE_GPU>; -template class psi_initializer_random, base_device::DEVICE_GPU>; +template class psi_initializer_random>; +template class psi_initializer_random>; // gamma point calculation -template class psi_initializer_random; -template class psi_initializer_random; -#endif \ No newline at end of file +template class psi_initializer_random; +template class psi_initializer_random; \ No newline at end of file diff --git a/source/module_psi/psi_initializer_random.h b/source/module_psi/psi_initializer_random.h index 39707a303c..9285bd9bcf 100644 --- a/source/module_psi/psi_initializer_random.h +++ b/source/module_psi/psi_initializer_random.h @@ -1,46 +1,35 @@ #ifndef PSI_INITIALIZER_RANDOM_H #define PSI_INITIALIZER_RANDOM_H -#include "psi_initializer.h" #include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h" +#include "psi_initializer.h" /* Psi (planewave based wavefunction) initializer: random method */ -template -class psi_initializer_random : public psi_initializer +template +class psi_initializer_random : public psi_initializer { - private: - using Real = typename GetTypeReal::type; - public: - psi_initializer_random() {this->set_method("random");}; - ~psi_initializer_random() {}; - /// @brief write random number to psi in certain range specified by ik, iw_start, iw_end - void random(T* psi, //< psi - const int iw_start, //< iw_start, starting band index of present kpoint - const int iw_end, //< iw_end, ending band index of present kpoint - const int ik) override; //< ik, kpoint index - /// @brief calculate and output planewave wavefunction - /// @param ik kpoint index - /// @return initialized planewave wavefunction (psi::Psi>*) - virtual void proj_ao_onkG(const int ik) override; - #ifdef __MPI // MPI additional implementation - /// @brief initialize the psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - Parallel_Kpoints*, //< parallel kpoints - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential - const int& = 0) override; //< MPI rank - #else - /// @brief serial version of initialize function, link psi_initializer with external data and methods - virtual void initialize(Structure_Factor*, //< structure factor - ModulePW::PW_Basis_K*, //< planewave basis - UnitCell*, //< unit cell - const int& = 1, //< random seed - pseudopot_cell_vnl* = nullptr) override ; //< nonlocal pseudopotential - #endif - virtual void tabulate() override {}; + private: + using Real = typename GetTypeReal::type; + + public: + psi_initializer_random() + { + this->method_ = "random"; + }; + ~psi_initializer_random(){}; + /// @brief calculate and output planewave wavefunction + /// @param ik kpoint index + /// @return initialized planewave wavefunction (psi::Psi>*) + virtual void init_psig(T* psig, const int& ik) override; + /// @brief initialize the psi_initializer with external data and methods + virtual void initialize(const Structure_Factor*, //< structure factor + const ModulePW::PW_Basis_K*, //< planewave basis + const UnitCell*, //< unit cell + const Parallel_Kpoints*, //< parallel kpoints + const int& = 1, //< random seed + const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential + const int& = 0) override; //< MPI rank }; #endif \ No newline at end of file diff --git a/source/module_psi/test/CMakeLists.txt b/source/module_psi/test/CMakeLists.txt index 08ef34ded7..979143dc28 100644 --- a/source/module_psi/test/CMakeLists.txt +++ b/source/module_psi/test/CMakeLists.txt @@ -17,6 +17,9 @@ AddTest( ../../module_cell/parallel_kpoints.cpp ../../module_cell/test/support/mock_unitcell.cpp ../../module_io/orb_io.cpp + ../../module_io/write_pao.cpp + ../../module_io/read_wfc_pw.cpp + ../../module_io/binstream.cpp ) endif() diff --git a/source/module_psi/test/psi_initializer_unit_test.cpp b/source/module_psi/test/psi_initializer_unit_test.cpp index b42e5cb5b4..0cf1f6060f 100644 --- a/source/module_psi/test/psi_initializer_unit_test.cpp +++ b/source/module_psi/test/psi_initializer_unit_test.cpp @@ -9,6 +9,7 @@ #include "../psi_initializer_nao_random.h" #include "../psi_initializer_random.h" #include "module_hamilt_pw/hamilt_pwdft/VL_in_pw.h" +#include "module_cell/klist.h" /* ========================= @@ -89,18 +90,21 @@ std::complex* Structure_Factor::get_sk(int ik, int it, int ia, ModulePW: return sk; } +int K_Vectors::get_ik_global(const int& ik, const int& nkstot) +{ + return ik; +} + class PsiIntializerUnitTest : public ::testing::Test { public: Structure_Factor* p_sf = nullptr; ModulePW::PW_Basis_K* p_pw_wfc = nullptr; UnitCell* p_ucell = nullptr; pseudopot_cell_vnl* p_pspot_vnl = nullptr; - #ifdef __MPI Parallel_Kpoints* p_parakpts = nullptr; - #endif int random_seed = 1; - psi_initializer, base_device::DEVICE_CPU>* psi_init; + psi_initializer>* psi_init; private: protected: @@ -111,9 +115,7 @@ class PsiIntializerUnitTest : public ::testing::Test { this->p_pw_wfc = new ModulePW::PW_Basis_K(); this->p_ucell = new UnitCell(); this->p_pspot_vnl = new pseudopot_cell_vnl(); - #ifdef __MPI this->p_parakpts = new Parallel_Kpoints(); - #endif // mock PARAM.input.nbands = 1; PARAM.input.nspin = 1; @@ -130,6 +132,7 @@ class PsiIntializerUnitTest : public ::testing::Test { this->p_ucell->a2 = {0.0, 10.0, 0.0}; this->p_ucell->a3 = {0.0, 0.0, 10.0}; this->p_ucell->lat0 = 1.0; + this->p_ucell->omega = 1000.0; this->p_ucell->latvec.e11 = 10.0; this->p_ucell->latvec.e12 = 0.0; this->p_ucell->latvec.e13 = 0.0; this->p_ucell->latvec.e21 = 0.0; this->p_ucell->latvec.e22 = 10.0; this->p_ucell->latvec.e23 = 0.0; this->p_ucell->latvec.e31 = 0.0; this->p_ucell->latvec.e32 = 0.0; this->p_ucell->latvec.e33 = 10.0; @@ -139,14 +142,14 @@ class PsiIntializerUnitTest : public ::testing::Test { this->p_ucell->tpiba = 2.0 * M_PI / this->p_ucell->lat0; this->p_ucell->tpiba2 = this->p_ucell->tpiba * this->p_ucell->tpiba; // atom - if(this->p_ucell->atom_label != nullptr) { delete[] this->p_ucell->atom_label; -} + delete[] this->p_ucell->atom_label; this->p_ucell->atom_label = new std::string[1]; this->p_ucell->atom_label[0] = "Si"; // atom properties this->p_ucell->nat = 1; this->p_ucell->ntype = 1; this->p_ucell->atoms = new Atom[1]; + this->p_ucell->set_atom_flag = true; this->p_ucell->atoms[0].label = "Si"; this->p_ucell->atoms[0].mass = 28.0855; this->p_ucell->atoms[0].na = 1; @@ -163,19 +166,20 @@ class PsiIntializerUnitTest : public ::testing::Test { this->p_ucell->pseudo_fn[0] = "Si_NCSR_ONCVPSP_v0.5_dojo.upf"; this->p_ucell->natomwfc = 4; this->p_ucell->atoms[0].ncpp.nchi = 2; - this->p_ucell->atoms[0].ncpp.mesh = 10; - this->p_ucell->atoms[0].ncpp.msh = 10; + this->p_ucell->atoms[0].ncpp.els = std::vector(2, ""); + this->p_ucell->atoms[0].ncpp.mesh = 11; + this->p_ucell->atoms[0].ncpp.msh = 11; this->p_ucell->atoms[0].ncpp.lmax = 2; //if(this->p_ucell->atoms[0].ncpp.rab != nullptr) delete[] this->p_ucell->atoms[0].ncpp.rab; - this->p_ucell->atoms[0].ncpp.rab = std::vector(10, 0.0); - for(int i = 0; i < 10; ++i) { this->p_ucell->atoms[0].ncpp.rab[i] = 0.01; + this->p_ucell->atoms[0].ncpp.rab = std::vector(11, 0.0); + for(int i = 0; i < 11; ++i) { this->p_ucell->atoms[0].ncpp.rab[i] = 0.01; } //if(this->p_ucell->atoms[0].ncpp.r != nullptr) delete[] this->p_ucell->atoms[0].ncpp.r; - this->p_ucell->atoms[0].ncpp.r = std::vector(10, 0.0); - for(int i = 0; i < 10; ++i) { this->p_ucell->atoms[0].ncpp.r[i] = 0.01*i; + this->p_ucell->atoms[0].ncpp.r = std::vector(11, 0.0); + for(int i = 0; i < 11; ++i) { this->p_ucell->atoms[0].ncpp.r[i] = 0.01*i; } - this->p_ucell->atoms[0].ncpp.chi.create(2, 10); - for(int i = 0; i < 2; ++i) { for(int j = 0; j < 10; ++j) { this->p_ucell->atoms[0].ncpp.chi(i, j) = 0.01; + this->p_ucell->atoms[0].ncpp.chi.create(2, 11); + for(int i = 0; i < 2; ++i) { for(int j = 0; j < 11; ++j) { this->p_ucell->atoms[0].ncpp.chi(i, j) = 0.01; } } //if(this->p_ucell->atoms[0].ncpp.lchi != nullptr) delete[] this->p_ucell->atoms[0].ncpp.lchi; @@ -256,53 +260,50 @@ class PsiIntializerUnitTest : public ::testing::Test { this->p_pw_wfc->kvec_d = new ModuleBase::Vector3[1]; this->p_pw_wfc->kvec_d[0] = {0.0, 0.0, 0.0}; - this->p_pspot_vnl->lmaxkb = 0; + this->p_pspot_vnl->lmaxkb = 1; - #ifdef __MPI this->p_parakpts->startk_pool.resize(1); this->p_parakpts->startk_pool[0] = 0; - #endif } void TearDown() override { + delete this->psi_init; delete this->p_sf; delete this->p_pw_wfc; delete this->p_ucell; delete this->p_pspot_vnl; - #ifdef __MPI delete this->p_parakpts; - #endif - } + } }; TEST_F(PsiIntializerUnitTest, ConstructorRandom) { - this->psi_init = new psi_initializer_random, base_device::DEVICE_CPU>(); + this->psi_init = new psi_initializer_random>(); EXPECT_EQ("random", this->psi_init->method()); } TEST_F(PsiIntializerUnitTest, ConstructorAtomic) { - this->psi_init = new psi_initializer_atomic, base_device::DEVICE_CPU>(); + this->psi_init = new psi_initializer_atomic>(); EXPECT_EQ("atomic", this->psi_init->method()); } TEST_F(PsiIntializerUnitTest, ConstructorAtomicRandom) { - this->psi_init = new psi_initializer_atomic_random, base_device::DEVICE_CPU>(); + this->psi_init = new psi_initializer_atomic_random>(); EXPECT_EQ("atomic+random", this->psi_init->method()); } TEST_F(PsiIntializerUnitTest, ConstructorNao) { - this->psi_init = new psi_initializer_nao, base_device::DEVICE_CPU>(); + this->psi_init = new psi_initializer_nao>(); EXPECT_EQ("nao", this->psi_init->method()); } TEST_F(PsiIntializerUnitTest, ConstructorNaoRandom) { - this->psi_init = new psi_initializer_nao_random, base_device::DEVICE_CPU>(); + this->psi_init = new psi_initializer_nao_random>(); EXPECT_EQ("nao+random", this->psi_init->method()); } TEST_F(PsiIntializerUnitTest, CastToT) { - this->psi_init = new psi_initializer_random, base_device::DEVICE_CPU>(); + this->psi_init = new psi_initializer_random>(); std::complex cd = {1.0, 2.0}; std::complex cf = {1.0, 2.0}; double d = 1.0; @@ -313,165 +314,9 @@ TEST_F(PsiIntializerUnitTest, CastToT) { EXPECT_EQ(this->psi_init->template cast_to_T(cd), f); } -TEST_F(PsiIntializerUnitTest, AllocateRandom) { - PARAM.input.init_wfc = "random"; - this->psi_init = new psi_initializer_random, base_device::DEVICE_CPU>(); -#ifdef __MPI - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->p_parakpts, - this->random_seed, - this->p_pspot_vnl, - GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif - this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - EXPECT_EQ(0, this->psi_init->nbands_complem()); - EXPECT_EQ(1, psi->get_nk()); - EXPECT_EQ(1, psi->get_nbands()); - EXPECT_EQ(1, psi->get_nbasis()); - auto psig = this->psi_init->share_psig().lock(); - EXPECT_EQ(1, psig->get_nk()); - EXPECT_EQ(1, psig->get_nbands()); - EXPECT_EQ(1, psig->get_nbasis()); - delete psi; -} - -TEST_F(PsiIntializerUnitTest, AllocateAtomic) { - PARAM.input.init_wfc = "atomic"; - this->psi_init = new psi_initializer_atomic, base_device::DEVICE_CPU>(); -#ifdef __MPI - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->p_parakpts, - this->random_seed, - this->p_pspot_vnl, - GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif - this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - EXPECT_EQ(0, this->psi_init->nbands_complem()); - EXPECT_EQ(1, psi->get_nk()); - EXPECT_EQ(1, psi->get_nbands()); - EXPECT_EQ(1, psi->get_nbasis()); - auto psig = this->psi_init->share_psig().lock(); - EXPECT_EQ(1, psig->get_nk()); - EXPECT_EQ(4, psig->get_nbands()); - EXPECT_EQ(1, psig->get_nbasis()); - delete psi; -} - -TEST_F(PsiIntializerUnitTest, AllocateAtomicRandom) { - PARAM.input.init_wfc = "atomic+random"; - this->psi_init = new psi_initializer_atomic_random, base_device::DEVICE_CPU>(); -#ifdef __MPI - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->p_parakpts, - this->random_seed, - this->p_pspot_vnl, - GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif - this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - EXPECT_EQ(0, this->psi_init->nbands_complem()); - EXPECT_EQ(1, psi->get_nk()); - EXPECT_EQ(1, psi->get_nbands()); - EXPECT_EQ(1, psi->get_nbasis()); - auto psig = this->psi_init->share_psig().lock(); - EXPECT_EQ(1, psig->get_nk()); - EXPECT_EQ(4, psig->get_nbands()); - EXPECT_EQ(1, psig->get_nbasis()); - delete psi; -} - -TEST_F(PsiIntializerUnitTest, AllocateNao) { - PARAM.input.init_wfc = "nao"; - this->psi_init = new psi_initializer_nao, base_device::DEVICE_CPU>(); -#ifdef __MPI - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->p_parakpts, - this->random_seed, - this->p_pspot_vnl, - GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif - this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - EXPECT_EQ(0, this->psi_init->nbands_complem()); - EXPECT_EQ(1, psi->get_nk()); - EXPECT_EQ(1, psi->get_nbands()); - EXPECT_EQ(1, psi->get_nbasis()); - auto psig = this->psi_init->share_psig().lock(); - EXPECT_EQ(1, psig->get_nk()); - EXPECT_EQ(13, psig->get_nbands()); - EXPECT_EQ(1, psig->get_nbasis()); - delete psi; -} - -TEST_F(PsiIntializerUnitTest, AllocateNaoRandom) { - PARAM.input.init_wfc = "nao+random"; - this->psi_init = new psi_initializer_nao_random, base_device::DEVICE_CPU>(); -#ifdef __MPI - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->p_parakpts, - this->random_seed, - this->p_pspot_vnl, - GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif - this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - EXPECT_EQ(0, this->psi_init->nbands_complem()); - EXPECT_EQ(1, psi->get_nk()); - EXPECT_EQ(1, psi->get_nbands()); - EXPECT_EQ(1, psi->get_nbasis()); - auto psig = this->psi_init->share_psig().lock(); - EXPECT_EQ(1, psig->get_nk()); - EXPECT_EQ(13, psig->get_nbands()); - EXPECT_EQ(1, psig->get_nbasis()); - delete psi; -} - TEST_F(PsiIntializerUnitTest, CalPsigRandom) { PARAM.input.init_wfc = "random"; - this->psi_init = new psi_initializer_random, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_random>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -479,24 +324,18 @@ TEST_F(PsiIntializerUnitTest, CalPsigRandom) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); - EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); + EXPECT_NEAR(-0.66187696761064307, psi->operator()(0,0,0).real(), 1e-4); delete psi; } TEST_F(PsiIntializerUnitTest, CalPsigAtomic) { PARAM.input.init_wfc = "atomic"; - this->psi_init = new psi_initializer_atomic, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_atomic>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -504,16 +343,11 @@ TEST_F(PsiIntializerUnitTest, CalPsigAtomic) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); delete psi; } @@ -524,8 +358,7 @@ TEST_F(PsiIntializerUnitTest, CalPsigAtomicSoc) { PARAM.sys.npol = 2; this->p_ucell->atoms[0].ncpp.has_so = false; this->p_ucell->natomwfc *= 2; - this->psi_init = new psi_initializer_atomic, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_atomic>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -533,16 +366,11 @@ TEST_F(PsiIntializerUnitTest, CalPsigAtomicSoc) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); PARAM.input.nspin = 1; PARAM.sys.npol = 1; @@ -557,8 +385,7 @@ TEST_F(PsiIntializerUnitTest, CalPsigAtomicSocHasSo) { PARAM.sys.npol = 2; this->p_ucell->atoms[0].ncpp.has_so = true; this->p_ucell->natomwfc *= 2; - this->psi_init = new psi_initializer_atomic, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_atomic>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -566,16 +393,11 @@ TEST_F(PsiIntializerUnitTest, CalPsigAtomicSocHasSo) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); PARAM.input.nspin = 1; PARAM.sys.npol = 1; @@ -586,8 +408,7 @@ TEST_F(PsiIntializerUnitTest, CalPsigAtomicSocHasSo) { TEST_F(PsiIntializerUnitTest, CalPsigAtomicRandom) { PARAM.input.init_wfc = "atomic+random"; - this->psi_init = new psi_initializer_atomic_random, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_atomic_random>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -595,24 +416,18 @@ TEST_F(PsiIntializerUnitTest, CalPsigAtomicRandom) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); delete psi; } TEST_F(PsiIntializerUnitTest, CalPsigNao) { PARAM.input.init_wfc = "nao"; - this->psi_init = new psi_initializer_nao, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_nao>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -620,24 +435,18 @@ TEST_F(PsiIntializerUnitTest, CalPsigNao) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); delete psi; } TEST_F(PsiIntializerUnitTest, CalPsigNaoRandom) { PARAM.input.init_wfc = "nao+random"; - this->psi_init = new psi_initializer_nao_random, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_nao_random>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -645,16 +454,11 @@ TEST_F(PsiIntializerUnitTest, CalPsigNaoRandom) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); delete psi; } @@ -666,8 +470,7 @@ TEST_F(PsiIntializerUnitTest, CalPsigNaoSoc) { this->p_ucell->atoms[0].ncpp.has_so = false; PARAM.sys.domag = false; PARAM.sys.domag_z = false; - this->psi_init = new psi_initializer_nao, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_nao>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -675,16 +478,11 @@ TEST_F(PsiIntializerUnitTest, CalPsigNaoSoc) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); delete psi; } @@ -696,8 +494,7 @@ TEST_F(PsiIntializerUnitTest, CalPsigNaoSocHasSo) { this->p_ucell->atoms[0].ncpp.has_so = true; PARAM.sys.domag = false; PARAM.sys.domag_z = false; - this->psi_init = new psi_initializer_nao, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_nao>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -705,16 +502,11 @@ TEST_F(PsiIntializerUnitTest, CalPsigNaoSocHasSo) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); delete psi; } @@ -726,8 +518,7 @@ TEST_F(PsiIntializerUnitTest, CalPsigNaoSocHasSoDOMAG) { this->p_ucell->atoms[0].ncpp.has_so = true; PARAM.sys.domag = true; PARAM.sys.domag_z = false; - this->psi_init = new psi_initializer_nao, base_device::DEVICE_CPU>(); -#ifdef __MPI + this->psi_init = new psi_initializer_nao>(); this->psi_init->initialize(this->p_sf, this->p_pw_wfc, this->p_ucell, @@ -735,16 +526,11 @@ TEST_F(PsiIntializerUnitTest, CalPsigNaoSocHasSoDOMAG) { this->random_seed, this->p_pspot_vnl, GlobalV::MY_RANK); - #else - this->psi_init->initialize(this->p_sf, - this->p_pw_wfc, - this->p_ucell, - this->random_seed, - this->p_pspot_vnl); - #endif this->psi_init->tabulate(); // always: new, initialize, tabulate, allocate, proj_ao_onkG - psi::Psi>* psi = this->psi_init->allocate(); - this->psi_init->proj_ao_onkG(0); + const int nbands_start = this->psi_init->nbands_start(); + const int nbasis = this->p_pw_wfc->npwk_max * PARAM.globalv.npol; + psi::Psi>* psi = new psi::Psi>(1, nbands_start, nbasis, nullptr); + this->psi_init->init_psig(psi->get_pointer(), 0); EXPECT_NEAR(0, psi->operator()(0,0,0).real(), 1e-12); delete psi; } diff --git a/source/module_psi/wavefunc.cpp b/source/module_psi/wavefunc.cpp deleted file mode 100644 index 31bdad80dd..0000000000 --- a/source/module_psi/wavefunc.cpp +++ /dev/null @@ -1,513 +0,0 @@ -#include "wavefunc.h" - -#include "module_base/memory.h" -#include "module_base/timer.h" -#include "module_hamilt_lcao/hamilt_lcaodft/wavefunc_in_pw.h" -#include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_hamilt_pw/hamilt_pwdft/hamilt_pw.h" -#include "module_hsolver/diago_iter_assist.h" -#include "module_hsolver/kernels/math_kernel_op.h" -#include "module_io/read_wfc_pw.h" -#include "module_io/winput.h" -#include "module_parameter/parameter.h" -#include "module_psi/psi.h" - -wavefunc::wavefunc() -{ -} - -wavefunc::~wavefunc() -{ - if (PARAM.inp.test_deconstructor) - { - std::cout << " ~wavefunc()" << std::endl; - } - if (this->irindex != nullptr) - { - delete[] this->irindex; - this->irindex = nullptr; - } -} - -psi::Psi>* wavefunc::allocate(const int nkstot, const int nks, const int* ngk, const int npwx_in) -{ - ModuleBase::TITLE("wavefunc", "allocate"); - - this->npwx = npwx_in; - this->nkstot = nkstot; - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "npwx", npwx); - - assert(npwx > 0); - assert(nks > 0); - - // allocate for kinetic energy - - // if use spin orbital, do not double nks but double allocate evc and wanf2. - int prefactor = 1; - if (PARAM.inp.nspin == 4) - { - prefactor = PARAM.globalv.npol; // added by zhengdy-soc - } - - const int nks2 = nks; - - psi::Psi>* psi_out = nullptr; - if (PARAM.inp.calculation == "nscf" && PARAM.inp.mem_saver == 1) - { - // initial psi rather than evc - psi_out = new psi::Psi>(1, PARAM.inp.nbands, npwx * PARAM.globalv.npol, ngk); - if (PARAM.inp.basis_type == "lcao_in_pw") - { - wanf2[0].create(PARAM.globalv.nlocal, npwx * PARAM.globalv.npol); - - // WARNING: put the sizeof() be the first to avoid the overflow of the multiplication of int - const size_t memory_cost - = sizeof(std::complex) * PARAM.globalv.nlocal * (PARAM.globalv.npol * npwx); - - std::cout << " Memory for wanf2 (MB): " << static_cast(memory_cost) / 1024.0 / 1024.0 << std::endl; - ModuleBase::Memory::record("WF::wanf2", memory_cost); - } - - // WARNING: put the sizeof() be the first to avoid the overflow of the multiplication of int - const size_t memory_cost = sizeof(std::complex) * PARAM.inp.nbands * (PARAM.globalv.npol * npwx); - - std::cout << " MEMORY FOR PSI (MB) : " << static_cast(memory_cost) / 1024.0 / 1024.0 << std::endl; - ModuleBase::Memory::record("Psi_PW", memory_cost); - } - else if (PARAM.inp.basis_type != "pw") - { - if ((PARAM.inp.basis_type == "lcao" || PARAM.inp.basis_type == "lcao_in_pw") || winput::out_spillage == 2) - { // for lcao_in_pw - if (this->wanf2 != nullptr) - { - delete[] this->wanf2; - } - this->wanf2 = new ModuleBase::ComplexMatrix[nks2]; - - for (int ik = 0; ik < nks2; ik++) - { - this->wanf2[ik].create(PARAM.globalv.nlocal, npwx * PARAM.globalv.npol); - } - - // WARNING: put the sizeof() be the first to avoid the overflow of the multiplication of int - const size_t memory_cost - = sizeof(std::complex) * nks2 * PARAM.globalv.nlocal * (npwx * PARAM.globalv.npol); - - std::cout << " Memory for wanf2 (MB): " << static_cast(memory_cost) / 1024.0 / 1024.0 << std::endl; - ModuleBase::Memory::record("WF::wanf2", memory_cost); - } - } - else - { - // initial psi rather than evc - psi_out = new psi::Psi>(nks2, PARAM.inp.nbands, npwx * PARAM.globalv.npol, ngk); - - // WARNING: put the sizeof() be the first to avoid the overflow of the multiplication of int - const size_t memory_cost = sizeof(std::complex) * nks2 * PARAM.inp.nbands * (PARAM.globalv.npol * npwx); - - std::cout << " MEMORY FOR PSI (MB) : " << static_cast(memory_cost) / 1024.0 / 1024.0 << std::endl; - ModuleBase::Memory::record("Psi_PW", memory_cost); - } - return psi_out; - - // showMemStats(); -} - -//=================================================================== -// This routine computes an estimate of the start_ wavefunctions -// from superposition of atomic wavefunctions or random wave functions. -//=================================================================== -void wavefunc::wfcinit(psi::Psi>* psi_in, ModulePW::PW_Basis_K* wfc_basis) -{ - ModuleBase::TITLE("wavefunc", "wfcinit"); - ModuleBase::timer::tick("wavefunc", "wfcinit"); - if (PARAM.inp.basis_type == "pw") - { - if (this->irindex != nullptr) - { - delete[] this->irindex; - } - this->irindex = new int[wfc_basis->fftnxy]; - wfc_basis->getfftixy2is(this->irindex); -#if defined(__CUDA) || defined(__ROCM) - if (PARAM.inp.device == "gpu") - { - wfc_basis->get_ig2ixyz_k(); - } -#endif - } - ModuleBase::timer::tick("wavefunc", "wfcinit"); - return; -} - -int wavefunc::get_starting_nw(const int natomwfc) const -{ - if (PARAM.inp.init_wfc == "file") - { - return PARAM.inp.nbands; - } - else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") - { - if (natomwfc >= PARAM.inp.nbands) - { - if (PARAM.inp.test_wf) - { - GlobalV::ofs_running << " Start wave functions are all pseudo atomic wave functions." << std::endl; - } - } - else - { - if (PARAM.inp.test_wf) - { - GlobalV::ofs_running << " Start wave functions are atomic + " - << PARAM.inp.nbands - natomwfc << " random wave functions." - << std::endl; - } - } - return std::max(natomwfc, PARAM.inp.nbands); - } - else if (PARAM.inp.init_wfc == "random") - { - if (PARAM.inp.test_wf) - { - GlobalV::ofs_running << " Start wave functions are all random." << std::endl; - } - return PARAM.inp.nbands; - } - else - { - throw std::runtime_error("wavefunc::get_starting_nw. Don't know what to do! Please Check source code! " - + ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line " - + ModuleBase::GlobalFunc::TO_STRING(__LINE__)); // Peize Lin change 2019-05-01 - // ModuleBase::WARNING_QUIT("get_starting_nw","Don't know what to do! Please Check source code!"); - } -} - -namespace hamilt -{ - -template <> -void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx, - const int& ik, - psi::Psi, base_device::DEVICE_CPU>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - const UnitCell& ucell, - hamilt::Hamilt, base_device::DEVICE_CPU>* phm_in) -{ - // TODO float func -} - -template <> -void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx, - const int& ik, - psi::Psi, base_device::DEVICE_CPU>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - const UnitCell& ucell, - hamilt::Hamilt, base_device::DEVICE_CPU>* phm_in) -{ - ModuleBase::TITLE("wavefunc", "diago_PAO_in_pw_k2"); - - const int nbasis = wvf.get_nbasis(); - const int nbands = wvf.get_nbands(); - const int current_nbasis = wfc_basis->npwk[ik]; - - if (PARAM.inp.init_wfc == "file") - { - ModuleBase::ComplexMatrix wfcatom(nbands, nbasis); - std::stringstream filename; - int ik_tot = K_Vectors::get_ik_global(ik, p_wf->nkstot); - filename << PARAM.globalv.global_readin_dir << "WAVEFUNC" << ik_tot + 1 << ".dat"; - ModuleIO::read_wfc_pw(filename.str(), wfc_basis, ik, p_wf->nkstot, wfcatom); - - if (PARAM.inp.ks_solver == "cg") - { - std::vector etfile(nbands, 0.0); - if (phm_in != nullptr) - { - hsolver::DiagoIterAssist>::diagH_subspace_init(phm_in, - wfcatom.c, - wfcatom.nr, - wfcatom.nc, - wvf, - etfile.data()); - return; - } - else - { - ModuleBase::WARNING_QUIT("wavefunc", "Hamiltonian does not exist!"); - } - } - - assert(nbands <= wfcatom.nr); - for (int ib = 0; ib < nbands; ib++) - { - for (int ig = 0; ig < nbasis; ig++) - { - wvf(ib, ig) = wfcatom(ib, ig); - } - } - } - else if (PARAM.inp.init_wfc == "random" - || (PARAM.inp.init_wfc.substr(0, 6) == "atomic" && ucell.natomwfc == 0)) - { - p_wf->random(wvf.get_pointer(), 0, nbands, ik, wfc_basis); - - if (PARAM.inp.ks_solver == "cg") - { - std::vector etrandom(nbands, 0.0); - - if (phm_in != nullptr) - { - hsolver::DiagoIterAssist>::diagH_subspace(phm_in, wvf, wvf, etrandom.data()); - return; - } - else - { - ModuleBase::WARNING_QUIT("wavefunc", "Hamiltonian does not exist!"); - } - } - } - else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") - { - const int starting_nw = p_wf->get_starting_nw(ucell.natomwfc); - if (starting_nw == 0) - { - return; - } - assert(starting_nw > 0); - - ModuleBase::ComplexMatrix wfcatom(starting_nw, nbasis); - - if (PARAM.inp.test_wf) - { - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "starting_nw", starting_nw); - } - - p_wf->atomic_wfc(ucell, - ik, - current_nbasis, - lmaxkb, - wfc_basis, - wfcatom, - tab_at, - PARAM.globalv.nqx, - PARAM.globalv.dq); - - if (PARAM.inp.init_wfc == "atomic+random" - && starting_nw == ucell.natomwfc) // added by qianrui 2021-5-16 - { - p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis); - } - - //==================================================== - // If not enough atomic wfc are available, complete - // with random wfcs - //==================================================== - p_wf->random(wfcatom.c, ucell.natomwfc, nbands, ik, wfc_basis); - - // (7) Diago with cg method. - // if(GlobalV::DIAGO_TYPE == "cg") xiaohui modify 2013-09-02 - if (PARAM.inp.ks_solver == "cg") // xiaohui add 2013-09-02 - { - std::vector etatom(starting_nw, 0.0); - if (phm_in != nullptr) - { - hsolver::DiagoIterAssist>::diagH_subspace_init(phm_in, - wfcatom.c, - wfcatom.nr, - wfcatom.nc, - wvf, - etatom.data()); - return; - } - else - { - ModuleBase::WARNING_QUIT("wavefunc", "Hamiltonian does not exist!"); - } - } - - assert(nbands <= wfcatom.nr); - for (int ib = 0; ib < nbands; ib++) - { - for (int ig = 0; ig < nbasis; ig++) - { - wvf(ib, ig) = wfcatom(ib, ig); - } - } - } -} - -#if ((defined __CUDA) || (defined __ROCM)) - -template <> -void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, - const int& ik, - psi::Psi, base_device::DEVICE_GPU>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - const UnitCell& ucell, - hamilt::Hamilt, base_device::DEVICE_GPU>* phm_in) -{ - // TODO float -} - -template <> -void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, - const int& ik, - psi::Psi, base_device::DEVICE_GPU>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - const UnitCell& ucell, - hamilt::Hamilt, base_device::DEVICE_GPU>* phm_in) -{ - ModuleBase::TITLE("wavefunc", "diago_PAO_in_pw_k2"); - - const int nbasis = wvf.get_nbasis(); - const int nbands = wvf.get_nbands(); - const int current_nbasis = wfc_basis->npwk[ik]; - int starting_nw = nbands; - - ModuleBase::ComplexMatrix wfcatom(nbands, nbasis); - if (PARAM.inp.init_wfc == "file") - { - std::stringstream filename; - int ik_tot = K_Vectors::get_ik_global(ik, p_wf->nkstot); - filename << PARAM.globalv.global_readin_dir << "WAVEFUNC" << ik_tot + 1 << ".dat"; - ModuleIO::read_wfc_pw(filename.str(), wfc_basis, ik, p_wf->nkstot, wfcatom); - } - - starting_nw = p_wf->get_starting_nw(ucell.natomwfc); - if (starting_nw == 0) - return; - assert(starting_nw > 0); - wfcatom.create(starting_nw, nbasis); // added by zhengdy-soc - if (PARAM.inp.test_wf) - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "starting_nw", starting_nw); - if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") - { - p_wf->atomic_wfc(ucell, - ik, - current_nbasis, - lmaxkb, - wfc_basis, - wfcatom, - tab_at, - PARAM.globalv.nqx, - PARAM.globalv.dq); - if (PARAM.inp.init_wfc == "atomic+random" - && starting_nw == ucell.natomwfc) // added by qianrui 2021-5-16 - { - p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis); - } - - //==================================================== - // If not enough atomic wfc are available, complete - // with random wfcs - //==================================================== - p_wf->random(wfcatom.c, ucell.natomwfc, nbands, ik, wfc_basis); - } - else if (PARAM.inp.init_wfc == "random") - { - p_wf->random(wfcatom.c, 0, nbands, ik, wfc_basis); - } - - std::complex* z_wfcatom = nullptr; - if (PARAM.inp.ks_solver != "bpcg") - { - // store wfcatom on the GPU - resmem_zd_op()(gpu_ctx, z_wfcatom, wfcatom.nr * wfcatom.nc); - syncmem_z2z_h2d_op()(gpu_ctx, cpu_ctx, z_wfcatom, wfcatom.c, wfcatom.nr * wfcatom.nc); - } - if (PARAM.inp.ks_solver == "cg") // xiaohui add 2013-09-02 - { - // (7) Diago with cg method. - if (phm_in != nullptr) - { - std::vector etatom(starting_nw, 0.0); - hsolver::DiagoIterAssist, base_device::DEVICE_GPU>::diagH_subspace_init(phm_in, - z_wfcatom, - wfcatom.nr, - wfcatom.nc, - wvf, - etatom.data()); - } - else - { - // this diagonalization method is obsoleted now - // GlobalC::hm.diagH_subspace(ik ,starting_nw, nbands, wfcatom, wfcatom, etatom.data()); - } - } - else if (PARAM.inp.ks_solver == "dav" || PARAM.inp.ks_solver == "dav_subspace") - { - assert(nbands <= wfcatom.nr); - // replace by haozhihan 2022-11-23 - hsolver::matrixSetToAnother, base_device::DEVICE_GPU>()(gpu_ctx, - nbands, - z_wfcatom, - wfcatom.nc, - &wvf(0, 0), - nbasis); - } - else if (PARAM.inp.ks_solver == "bpcg") - { - syncmem_z2z_h2d_op()(gpu_ctx, cpu_ctx, &wvf(0, 0), wfcatom.c, wfcatom.nr * wfcatom.nc); - } - - if (PARAM.inp.ks_solver != "bpcg") - { - delmem_zd_op()(gpu_ctx, z_wfcatom); - } -} - -#endif - -} // namespace hamilt - -// LiuXh add a new function here, -// 20180515 -void wavefunc::init_after_vc(const int nks) -{ - ModuleBase::TITLE("wavefunc", "init"); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "npwx", this->npwx); - - assert(this->npwx > 0); - assert(nks > 0); - assert(PARAM.inp.nbands > 0); - - const int nks2 = nks; - const int nbasis = this->npwx * PARAM.globalv.npol; - - if ((PARAM.inp.basis_type == "lcao" || PARAM.inp.basis_type == "lcao_in_pw") || winput::out_spillage == 2) - { - if (wanf2 != nullptr) - { - delete[] wanf2; - } - this->wanf2 = new ModuleBase::ComplexMatrix[nks2]; - for (int ik = 0; ik < nks2; ik++) - { - this->wanf2[ik].create(PARAM.globalv.nlocal, nbasis); - } - } - - if (PARAM.inp.test_wf) - { - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "psi allocation", "Done"); - if (PARAM.inp.basis_type == "lcao" || PARAM.inp.basis_type == "lcao_in_pw") - { - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "wanf2 allocation", "Done"); - } - } - - return; -} diff --git a/source/module_psi/wavefunc.h b/source/module_psi/wavefunc.h deleted file mode 100644 index 2c3c21fb08..0000000000 --- a/source/module_psi/wavefunc.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef WAVEFUNC_H -#define WAVEFUNC_H - -#include "module_base/complexmatrix.h" -#include "module_base/global_function.h" -#include "module_base/global_variable.h" -#include "module_base/matrix.h" -#include "module_hamilt_general/hamilt.h" -#include "module_psi/wf_atomic.h" - -class wavefunc : public WF_atomic -{ - public: - wavefunc(); - ~wavefunc(); - - // allocate memory - psi::Psi>* allocate(const int nkstot, const int nks, const int* ngk, const int npwx); - - int nkstot = 0; // total number of k-points for all pools - - void wfcinit(psi::Psi>* psi_in, ModulePW::PW_Basis_K* wfc_basis); - - int get_starting_nw(const int natomwfc) const; - - void init_after_vc(const int nks); // LiuXh 20180515 -}; - -namespace hamilt -{ - -void diago_PAO_in_pw_k2(const int& ik, - psi::Psi>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - hamilt::Hamilt>* phm_in = nullptr); -void diago_PAO_in_pw_k2(const int& ik, - psi::Psi>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - hamilt::Hamilt>* phm_in = nullptr); -void diago_PAO_in_pw_k2(const int& ik, - ModuleBase::ComplexMatrix& wvf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - wavefunc* p_wf); - -template -void diago_PAO_in_pw_k2(const Device* ctx, - const int& ik, - psi::Psi, Device>& wvf, - ModulePW::PW_Basis_K* wfc_basis, - wavefunc* p_wf, - const ModuleBase::realArray& tab_at, - const int& lmaxkb, - const UnitCell& ucell, - hamilt::Hamilt, Device>* phm_in = nullptr); -} // namespace hamilt - -#endif // wavefunc diff --git a/source/module_psi/wf_atomic.cpp b/source/module_psi/wf_atomic.cpp deleted file mode 100644 index 8a3b0d62a6..0000000000 --- a/source/module_psi/wf_atomic.cpp +++ /dev/null @@ -1,839 +0,0 @@ -#include "wf_atomic.h" - -#include "module_base/math_integral.h" -#include "module_base/math_polyint.h" -#include "module_base/math_sphbes.h" -#include "module_base/math_ylmreal.h" -#include "module_base/timer.h" -#include "module_base/tool_quit.h" -#include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_hamilt_pw/hamilt_pwdft/soc.h" -#include "module_parameter/parameter.h" - -#include - -WF_atomic::WF_atomic() -{ -} - -WF_atomic::~WF_atomic() -{ - if (PARAM.inp.test_deconstructor) - { - std::cout << " ~WF_atomic()" << std::endl; - } - if (this->wanf2 != nullptr) - { - delete[] wanf2; - } - if (this->psi != nullptr) - { - delete psi; - } -} - -void WF_atomic::init_at_1(const UnitCell& ucell, - Structure_Factor* sf_in, - ModuleBase::realArray* tab_at) -{ - if (PARAM.inp.use_paw) - { - return; - } - if (PARAM.inp.test_wf) - { - ModuleBase::TITLE("WF_atomic", "init_at_1"); - } - ModuleBase::timer::tick("WF_atomic", "init_at_1"); - this->psf = sf_in; - GlobalV::ofs_running << "\n Make real space PAO into reciprocal space." << std::endl; - - this->print_PAOs(ucell); - - //---------------------------------------------------------- - // EXPLAIN : Find the type of atom that has most mesh points. - //---------------------------------------------------------- - int ndm = 0; - for (int it = 0; it < ucell.ntype; it++) - { - ndm = (ucell.atoms[it].ncpp.msh > ndm) ? ucell.atoms[it].ncpp.msh : ndm; - } - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "max mesh points in Pseudopotential", ndm); - - // needed to normalize atomic wfcs (not a bad idea in general and - // necessary to compute correctly lda+U projections) - tab_at->zero_out(); - //---------------------------------------------------------- - // EXPLAIN : If use gauss orbitals to represent aotmic - // orbitals (controlled by parameters) - // - // USE GLOBAL CLASS VARIABLES : - // NAME : ucell.atoms.nchi - // NAME : ucell.atoms.msh(number of mesh points) - // NAME : ucell.atoms.r - //---------------------------------------------------------- - const int startq = 0; - const double pref = ModuleBase::FOUR_PI / sqrt(ucell.omega); - double* aux = new double[ndm]; - double* vchi = new double[ndm]; - - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "dq(describe PAO in reciprocal space)", PARAM.globalv.dq); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "max q", PARAM.globalv.nqx); - - for (int it = 0; it < ucell.ntype; it++) - { - Atom* atom = &ucell.atoms[it]; - - GlobalV::ofs_running << "\n number of pseudo atomic orbitals for " << atom->label << " is " << atom->ncpp.nchi - << std::endl; - - for (int ic = 0; ic < atom->ncpp.nchi; ic++) - { - // std::cout << "\n T=" << it << " ic=" << ic << std::endl; - int nmesh; - if (PARAM.inp.pseudo_mesh) - { - nmesh = atom->ncpp.mesh; - } - else - { - nmesh = atom->ncpp.msh; - } - - // check the unit condition - double* inner_part = new double[nmesh]; - for (int ir = 0; ir < nmesh; ir++) - { - inner_part[ir] = atom->ncpp.chi(ic, ir) * atom->ncpp.chi(ic, ir); - } - double unit = 0.0; - ModuleBase::Integral::Simpson_Integral(nmesh, inner_part, atom->ncpp.rab.data(), unit); - delete[] inner_part; - - // liuyu add 2023-10-06 - if (unit < 1e-8) - { - // set occupancy to a small negative number so that this wfc - // is not going to be used for starting wavefunctions - atom->ncpp.oc[ic] = -1e-8; - GlobalV::ofs_running << "WARNING: norm of atomic wavefunction # " << ic + 1 << " of atomic type " - << atom->ncpp.psd << " is zero" << std::endl; - } - // only occupied states are normalized - if (atom->ncpp.oc[ic] < 0) - { - continue; - } - // the US part if needed - if (atom->ncpp.tvanp) - { - int kkbeta = atom->ncpp.kkbeta; - if ((kkbeta % 2 == 0) && kkbeta > 0) - { - kkbeta--; - } - double* norm_beta = new double[kkbeta]; - double* work = new double[atom->ncpp.nbeta]; - for (int ib = 0; ib < atom->ncpp.nbeta; ib++) - { - bool match = false; - if (atom->ncpp.lchi[ic] == atom->ncpp.lll[ib]) - { - if (atom->ncpp.has_so) - { - if (std::abs(atom->ncpp.jchi[ic] - atom->ncpp.jjj[ib]) < 1e-6) - { - match = true; - } - } - else - { - match = true; - } - } - if (match) - { - for (int ik = 0; ik < kkbeta; ik++) - { - norm_beta[ik] = atom->ncpp.betar(ib, ik) * atom->ncpp.chi(ic, ik); - } - ModuleBase::Integral::Simpson_Integral(kkbeta, norm_beta, atom->ncpp.rab.data(), work[ib]); - } - else - { - work[ib] = 0.0; - } - } - for (int ib1 = 0; ib1 < atom->ncpp.nbeta; ib1++) - { - for (int ib2 = 0; ib2 < atom->ncpp.nbeta; ib2++) - { - unit += atom->ncpp.qqq(ib1, ib2) * work[ib1] * work[ib2]; - } - } - delete[] norm_beta; - delete[] work; - } // endif tvanp - - //================================= - // normalize radial wave functions - //================================= - unit = std::sqrt(unit); - if (std::abs(unit - 1.0) > 1e-6) - { - GlobalV::ofs_running << "WARNING: norm of atomic wavefunction # " << ic + 1 << " of atomic type " - << atom->ncpp.psd << " is " << unit << ", renormalized" << std::endl; - for (int ir = 0; ir < nmesh; ir++) - { - atom->ncpp.chi(ic, ir) /= unit; - } - } - - if (atom->ncpp.oc[ic] >= 0.0) - { - const int l = atom->ncpp.lchi[ic]; - for (int iq = startq; iq < PARAM.globalv.nqx; iq++) - { - const double q = PARAM.globalv.dq * iq; - ModuleBase::Sphbes::Spherical_Bessel(atom->ncpp.msh, atom->ncpp.r.data(), q, l, aux); - for (int ir = 0; ir < atom->ncpp.msh; ir++) - { - vchi[ir] = atom->ncpp.chi(ic, ir) * aux[ir] * atom->ncpp.r[ir]; - } - - double vqint = 0.0; - ModuleBase::Integral::Simpson_Integral(atom->ncpp.msh, vchi, atom->ncpp.rab.data(), vqint); - - tab_at->operator()(it, ic, iq) = vqint * pref; - // if( it == 0 && ic == 0 ) - // { - // - // for (ir = 0;ir < ucell.atoms[it].msh;ir++) - // GlobalV::ofs_running << std::setprecision(20) << "\n vchi(" << ir << ")=" << - // vchi[ir]; GlobalV::ofs_running<<"\n aux[0] = "< 3) - { - ModuleBase::TITLE("WF_atomic", "atomic_wfc"); - } - ModuleBase::timer::tick("WF_atomic", "atomic_wfc"); - //========================================================= - // This routine computes the superposition of atomic - // WF_atomictions for a given k-point. - //========================================================= - const int total_lm = (ucell.lmax_ppwf + 1) * (ucell.lmax_ppwf + 1); - ModuleBase::matrix ylm(total_lm, np); - std::complex* aux = new std::complex[np]; - double* chiaux = nullptr; - - ModuleBase::Vector3* gk = new ModuleBase::Vector3[np]; - for (int ig = 0; ig < np; ig++) - { - gk[ig] = wfc_basis->getgpluskcar(ik, ig); - } - // ylm = spherical harmonics functions - ModuleBase::YlmReal::Ylm_Real(total_lm, np, gk, ylm); - int index = 0; - //--------------------------------------------------------- - // Calculate G space 3D wave functions - //--------------------------------------------------------- - double* flq = new double[np]; - for (int it = 0; it < ucell.ntype; it++) - { - for (int ia = 0; ia < ucell.atoms[it].na; ia++) - { - // std::cout << "\n it = " << it << " ia = " << ia << std::endl; - std::complex* sk = this->psf->get_sk(ik, it, ia, wfc_basis); - //------------------------------------------------------- - // Calculate G space 3D wave functions - //------------------------------------------------------- - for (int iw = 0; iw < ucell.atoms[it].ncpp.nchi; iw++) - { - if (ucell.atoms[it].ncpp.oc[iw] >= 0.0) - { - const int l = ucell.atoms[it].ncpp.lchi[iw]; - std::complex lphase = pow(ModuleBase::NEG_IMAG_UNIT, l); - //----------------------------------------------------- - // the factor i^l MUST BE PRESENT in order to produce - // WF_atomictions for k=0 that are real in real space - //----------------------------------------------------- - - //--------------------------------------------------------- - // flq = radial fourier transform of atomic orbitals chi - //--------------------------------------------------------- - for (int ig = 0; ig < np; ig++) - { - flq[ig] = ModuleBase::PolyInt::Polynomial_Interpolation(table_q, - it, - iw, - table_dimension, - dq, - gk[ig].norm() * ucell.tpiba); - } - - if (PARAM.inp.nspin == 4) - { - if (ucell.atoms[it].ncpp.has_so) - { - Soc soc; - soc.rot_ylm(l + 1); - const double j = ucell.atoms[it].ncpp.jchi[iw]; - if (!(PARAM.globalv.domag || PARAM.globalv.domag_z)) - { // atomic_wfc_so - double fact[2]; - for (int m = -l - 1; m < l + 1; m++) - { - fact[0] = soc.spinor(l, j, m, 0); - fact[1] = soc.spinor(l, j, m, 1); - if (fabs(fact[0]) > 1e-8 || fabs(fact[1]) > 1e-8) - { - for (int is = 0; is < 2; is++) - { - if (fabs(fact[is]) > 1e-8) - { - const int ind = lmaxkb + soc.sph_ind(l, j, m, is); - ModuleBase::GlobalFunc::ZEROS(aux, np); - for (int n1 = 0; n1 < 2 * l + 1; n1++) - { - const int lm = l * l + n1; - if (std::abs(soc.rotylm(n1, ind)) > 1e-8) - { - for (int ig = 0; ig < np; ig++) - { - aux[ig] += soc.rotylm(n1, ind) * ylm(lm, ig); - } - } - } - for (int ig = 0; ig < np; ig++) - { - wfcatom(index, ig + this->npwx * is) - = lphase * fact[is] * sk[ig] * aux[ig] * flq[ig]; - } - } - else - { - for (int ig = 0; ig < np; ig++) - { - wfcatom(index, ig + this->npwx * is) - = std::complex(0.0, 0.0); - } - } - } // is - index++; - } // if - } // m - } // if - else - { // atomic_wfc_so_mag - - double alpha, gamma; - std::complex fup, fdown; - int nc; - // This routine creates two functions only in the case j=l+1/2 or exit in the other case - if (fabs(j - l + 0.5) < 1e-4) - { - continue; - } - delete[] chiaux; - chiaux = new double[np]; - // Find the functions j= l- 1/2 - if (l == 0) - { - for (int ig = 0; ig < np; ig++) - { - chiaux[ig] = flq[ig]; - } - } - else - { - for (int ib = 0; ib < ucell.atoms[it].ncpp.nchi; ib++) - { - if ((ucell.atoms[it].ncpp.lchi[ib] == l) - && (fabs(ucell.atoms[it].ncpp.jchi[ib] - l + 0.5) < 1e-4)) - { - nc = ib; - break; - } - } - for (int ig = 0; ig < np; ig++) - { // Average the two functions - chiaux[ig] = l - * ModuleBase::PolyInt::Polynomial_Interpolation( - table_q, - it, - nc, - table_dimension, - dq, - gk[ig].norm() * ucell.tpiba); - - chiaux[ig] += flq[ig] * (l + 1.0); - chiaux[ig] *= 1 / (2.0 * l + 1.0); - } - } - // and construct the starting wavefunctions as in the noncollinear case. - // alpha = ucell.magnet.angle1_[it]; - // gamma = -1 * ucell.magnet.angle2_[it] + 0.5 * ModuleBase::PI; - alpha = ucell.atoms[it].angle1[ia]; - gamma = -1 * ucell.atoms[it].angle2[ia] + 0.5 * ModuleBase::PI; - - for (int m = 0; m < 2 * l + 1; m++) - { - const int lm = l * l + m; - if (index + 2 * l + 1 > ucell.natomwfc) - { - ModuleBase::WARNING_QUIT("GlobalC::wf.atomic_wfc()", "error: too many wfcs"); - } - for (int ig = 0; ig < np; ig++) - { - aux[ig] = sk[ig] * ylm(lm, ig) * chiaux[ig]; - } - // rotate wfc as needed - // first rotation with angle alpha around (OX) - for (int ig = 0; ig < np; ig++) - { - fup = cos(0.5 * alpha) * aux[ig]; - fdown = ModuleBase::IMAG_UNIT * sin(0.5 * alpha) * aux[ig]; - // build the orthogonal wfc - // first rotation with angle (alpha + ModuleBase::PI) around (OX) - wfcatom(index, ig) - = (cos(0.5 * gamma) + ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fup; - wfcatom(index, ig + this->npwx) - = (cos(0.5 * gamma) - ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fdown; - // second rotation with angle gamma around(OZ) - fup = cos(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; - fdown = ModuleBase::IMAG_UNIT * sin(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; - wfcatom(index + 2 * l + 1, ig) - = (cos(0.5 * gamma) + ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fup; - wfcatom(index + 2 * l + 1, ig + this->npwx) - = (cos(0.5 * gamma) - ModuleBase::IMAG_UNIT * sin(0.5 * gamma)) * fdown; - } - index++; - } - index += 2 * l + 1; - } - } - else - { // atomic_wfc_nc - double alpha, gamman; - std::complex fup, fdown; - // alpha = ucell.magnet.angle1_[it]; - // gamman = -ucell.magnet.angle2_[it] + 0.5*ModuleBase::PI; - alpha = ucell.atoms[it].angle1[ia]; - gamman = -1 * ucell.atoms[it].angle2[ia] + 0.5 * ModuleBase::PI; - for (int m = 0; m < 2 * l + 1; m++) - { - const int lm = l * l + m; - if (index + 2 * l + 1 > ucell.natomwfc) - { - ModuleBase::WARNING_QUIT("GlobalC::wf.atomic_wfc()", "error: too many wfcs"); - } - for (int ig = 0; ig < np; ig++) - { - aux[ig] = sk[ig] * ylm(lm, ig) * flq[ig]; - } - // rotate function - // first, rotation with angle alpha around(OX) - for (int ig = 0; ig < np; ig++) - { - fup = cos(0.5 * alpha) * aux[ig]; - fdown = ModuleBase::IMAG_UNIT * sin(0.5 * alpha) * aux[ig]; - // build the orthogonal wfc - // first rotation with angle(alpha+ModuleBase::PI) around(OX) - wfcatom(index, ig) - = (cos(0.5 * gamman) + ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fup; - wfcatom(index, ig + this->npwx) - = (cos(0.5 * gamman) - ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fdown; - // second rotation with angle gamma around(OZ) - fup = cos(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; - fdown = ModuleBase::IMAG_UNIT * sin(0.5 * (alpha + ModuleBase::PI)) * aux[ig]; - wfcatom(index + 2 * l + 1, ig) - = (cos(0.5 * gamman) + ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fup; - wfcatom(index + 2 * l + 1, ig + this->npwx) - = (cos(0.5 * gamman) - ModuleBase::IMAG_UNIT * sin(0.5 * gamman)) * fdown; - } - index++; - } - index += 2 * l + 1; - } - // index++; - } - else - { // LSDA and nomagnet case - - for (int m = 0; m < 2 * l + 1; m++) - { - const int lm = l * l + m; - for (int ig = 0; ig < np; ig++) - { - wfcatom(index, ig) = lphase * sk[ig] * ylm(lm, ig) * flq[ig]; - // very useful for debug, don't delete this - // if(i==24 && index==0){ - // std::cout << "\n wfcatom(" << index<<","<irindex[ir]; - const int ip = wfc_basis->fftixy2ip[ir]; - const int nz = wfc_basis->nz; - - if (ip == 0 && GlobalV::RANK_IN_POOL == 0) - { - for (int iz = 0; iz < nz; iz++) - { - out[is * nz + iz] = stick[iz]; - } - } - else if (ip == GlobalV::RANK_IN_POOL) - { - MPI_Recv(stick, nz, MPI_FLOAT, 0, ir, POOL_WORLD, &ierror); - for (int iz = 0; iz < nz; iz++) - { - out[is * nz + iz] = stick[iz]; - } - } - else if (GlobalV::RANK_IN_POOL == 0) - { - MPI_Send(stick, nz, MPI_FLOAT, ip, ir, POOL_WORLD); - } - - return; -} -void WF_atomic::stick_to_pool(double* stick, const int& ir, double* out, const ModulePW::PW_Basis_K* wfc_basis) const -{ - MPI_Status ierror; - const int is = this->irindex[ir]; - const int ip = wfc_basis->fftixy2ip[ir]; - const int nz = wfc_basis->nz; - - if (ip == 0 && GlobalV::RANK_IN_POOL == 0) - { - for (int iz = 0; iz < nz; iz++) - { - out[is * nz + iz] = stick[iz]; - } - } - else if (ip == GlobalV::RANK_IN_POOL) - { - MPI_Recv(stick, nz, MPI_DOUBLE, 0, ir, POOL_WORLD, &ierror); - for (int iz = 0; iz < nz; iz++) - { - out[is * nz + iz] = stick[iz]; - } - } - else if (GlobalV::RANK_IN_POOL == 0) - { - MPI_Send(stick, nz, MPI_DOUBLE, ip, ir, POOL_WORLD); - } - - return; -} -#endif - -void WF_atomic::random(std::complex* psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis) -{ - this->random_t(psi, iw_start, iw_end, ik, wfc_basis); -} - -void WF_atomic::random(std::complex* psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis) -{ - this->random_t(psi, iw_start, iw_end, ik, wfc_basis); -} - -template -void WF_atomic::random_t(std::complex* psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis) -{ - assert(iw_start >= 0); - const int ng = wfc_basis->npwk[ik]; -#ifdef __MPI - // #if ((defined __CUDA) || (defined __ROCM)) - // if(INPUT.pw_seed > 0)//qianrui add 2021-8-13 - // { - // srand(unsigned(INPUT.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); - // } - // #else - if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 - { - srand(unsigned(PARAM.inp.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); - const int nxy = wfc_basis->fftnxy; - const int nz = wfc_basis->nz; - const int nstnz = wfc_basis->nst * nz; - - FPTYPE* stickrr = new FPTYPE[nz]; - FPTYPE* stickarg = new FPTYPE[nz]; - FPTYPE* tmprr = new FPTYPE[nstnz]; - FPTYPE* tmparg = new FPTYPE[nstnz]; - for (int iw = iw_start; iw < iw_end; iw++) - { - std::complex* ppsi = &(psi[iw * this->npwx * PARAM.globalv.npol]); - int startig = 0; - for (int ipol = 0; ipol < PARAM.globalv.npol; ++ipol) - { - - for (int ir = 0; ir < nxy; ir++) - { - if (wfc_basis->fftixy2ip[ir] < 0) - { - continue; - } - if (GlobalV::RANK_IN_POOL == 0) - { - for (int iz = 0; iz < nz; iz++) - { - stickrr[iz] = std::rand() / FPTYPE(RAND_MAX); - stickarg[iz] = std::rand() / FPTYPE(RAND_MAX); - } - } - stick_to_pool(stickrr, ir, tmprr, wfc_basis); - stick_to_pool(stickarg, ir, tmparg, wfc_basis); - } - - for (int ig = 0; ig < ng; ig++) - { - const FPTYPE rr = tmprr[wfc_basis->getigl2isz(ik, ig)]; - const FPTYPE arg = ModuleBase::TWO_PI * tmparg[wfc_basis->getigl2isz(ik, ig)]; - const FPTYPE gk2 = wfc_basis->getgk2(ik, ig); - ppsi[ig + startig] = std::complex(rr * cos(arg), rr * sin(arg)) / FPTYPE(gk2 + 1.0); - } - for (int ig = ng; ig < npwx; ++ig) - { - ppsi[ig + startig] = std::complex(0.0, 0.0); - } - startig += npwx; - } - } - delete[] stickrr; - delete[] stickarg; - delete[] tmprr; - delete[] tmparg; - } - else - { -// #endif -#else // !__MPI - if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 - { - srand(unsigned(PARAM.inp.pw_seed + ik)); - } -#endif // __MPI - for (int iw = iw_start; iw < iw_end; iw++) - { - std::complex* ppsi = &(psi[iw * this->npwx * PARAM.globalv.npol]); - for (int ig = 0; ig < ng; ig++) - { - const FPTYPE rr = std::rand() / FPTYPE(RAND_MAX); // qianrui add RAND_MAX - const FPTYPE arg = ModuleBase::TWO_PI * std::rand() / FPTYPE(RAND_MAX); - const FPTYPE gk2 = wfc_basis->getgk2(ik, ig); - ppsi[ig] = std::complex(rr * cos(arg), rr * sin(arg)) / FPTYPE(gk2 + 1.0); - } - if (PARAM.globalv.npol == 2) - { - for (int ig = this->npwx; ig < this->npwx + ng; ig++) - { - const FPTYPE rr = std::rand() / FPTYPE(RAND_MAX); - const FPTYPE arg = ModuleBase::TWO_PI * std::rand() / FPTYPE(RAND_MAX); - const FPTYPE gk2 = wfc_basis->getgk2(ik, ig - this->npwx); - ppsi[ig] = std::complex(rr * cos(arg), rr * sin(arg)) / FPTYPE(gk2 + 1.0); - } - } - } -#ifdef __MPI - // #if ((!defined __CUDA) && (!defined __ROCM)) - } -// #endif // ((!defined __CUDA) && (!defined __ROCM)) -#endif // __MPI -} - -void WF_atomic::atomicrandom(ModuleBase::ComplexMatrix& psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis) const -{ - assert(iw_start >= 0); - assert(psi.nr >= iw_end); - const int ng = wfc_basis->npwk[ik]; -#ifdef __MPI - if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 - { - srand(unsigned(PARAM.inp.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); - const int nxy = wfc_basis->fftnxy; - const int nz = wfc_basis->nz; - const int nstnz = wfc_basis->nst * nz; - - double* stickrr = new double[nz]; - double* stickarg = new double[nz]; - double* tmprr = new double[nstnz]; - double* tmparg = new double[nstnz]; - for (int iw = iw_start; iw < iw_end; iw++) - { - int startig = 0; - for (int ipol = 0; ipol < PARAM.globalv.npol; ++ipol) - { - for (int ir = 0; ir < nxy; ir++) - { - if (wfc_basis->fftixy2ip[ir] < 0) - { - continue; - } - if (GlobalV::RANK_IN_POOL == 0) - { - for (int iz = 0; iz < nz; iz++) - { - stickrr[iz] = std::rand() / double(RAND_MAX); - stickarg[iz] = std::rand() / double(RAND_MAX); - } - } - stick_to_pool(stickrr, ir, tmprr, wfc_basis); - stick_to_pool(stickarg, ir, tmparg, wfc_basis); - } - - for (int ig = 0; ig < ng; ig++) - { - const double rr = tmprr[wfc_basis->ig2isz[ig]]; - const double arg = ModuleBase::TWO_PI * tmparg[wfc_basis->ig2isz[ig]]; - psi(iw, startig + ig) *= (1.0 + 0.05 * std::complex(rr * cos(arg), rr * sin(arg))); - } - for (int ig = ng; ig < npwx; ++ig) - { - psi(iw, startig + ig) = std::complex(0.0, 0.0); - } - startig += npwx; - } - } - delete[] stickrr; - delete[] stickarg; - delete[] tmprr; - delete[] tmparg; - } - else - { -#else - if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 - { - srand(unsigned(PARAM.inp.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); - } -#endif - double rr, arg; - for (int iw = iw_start; iw < iw_end; iw++) - { - int startig = 0; - for (int ip = 0; ip < PARAM.globalv.npol; ++ip) - { - for (int ig = 0; ig < npw; ++ig) - { - rr = rand() / double(RAND_MAX); - arg = ModuleBase::TWO_PI * rand() / double(RAND_MAX); - psi(iw, startig + ig) *= (1.0 + 0.05 * std::complex(rr * cos(arg), rr * sin(arg))); - } - startig += npwx; - } - } -#ifdef __MPI - } -#endif - - return; -} diff --git a/source/module_psi/wf_atomic.h b/source/module_psi/wf_atomic.h deleted file mode 100644 index 24f86cb797..0000000000 --- a/source/module_psi/wf_atomic.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef WF_ATOMIC_H -#define WF_ATOMIC_H - -#include "module_base/complexmatrix.h" -#include "module_base/global_function.h" -#include "module_base/global_variable.h" -#include "module_base/realarray.h" -#include "module_basis/module_pw/pw_basis_k.h" -#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h" -#include "module_psi/psi.h" - -class WF_atomic -{ - public: - WF_atomic(); - ~WF_atomic(); - - int npwx; - int npw; - - // ModuleBase::IntArray igk; -#ifdef __CUDA - double* d_g2kin; -#endif - - ModuleBase::realArray table_local; // mohan add 2009-09-10 - - // temporary psi for new code - psi::Psi>* psi = nullptr; - - ModuleBase::ComplexMatrix* wanf2 = nullptr; // wannier functions in the PW basis - - /** - * @brief init a table with the radial Fourier transform of the atomic WF_atomictions - * @param sf_in [out] the structure factor - * @param tab_at [out] atomic table - */ - void init_at_1(const UnitCell& ucell, - Structure_Factor* sf_in, - ModuleBase::realArray* tab_at); - - void print_PAOs(const UnitCell& ucell) const; - - public: // template change to public, will be refactor later. added by zhengdy 20230302 - int* irindex = nullptr; - - void atomic_wfc(const UnitCell& ucell, - const int& ik, - const int& np, - const int& lmaxkb, - const ModulePW::PW_Basis_K* wfc_basis, - ModuleBase::ComplexMatrix& wfcatom, - const ModuleBase::realArray& table_q, - const int& table_dimension, - const double& dq) const; - - //================================== - // Calculate random wave functions - // as trial wave functions - //================================== - void atomicrandom(ModuleBase::ComplexMatrix& psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis) const; - - void random(std::complex* psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis); - - void random(std::complex* psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis); - - template - void random_t(std::complex* psi, - const int iw_start, - const int iw_end, - const int ik, - const ModulePW::PW_Basis_K* wfc_basis); - -#ifdef __MPI - void stick_to_pool(double* stick, const int& ir, double* out, const ModulePW::PW_Basis_K* wfc_basis) const; - void stick_to_pool(float* stick, const int& ir, float* out, const ModulePW::PW_Basis_K* wfc_basis) const; -#endif - - private: - Structure_Factor* psf; -}; - -#endif diff --git a/source/module_relax/relax_driver.cpp b/source/module_relax/relax_driver.cpp index 19fff5cc08..9cb67e6090 100644 --- a/source/module_relax/relax_driver.cpp +++ b/source/module_relax/relax_driver.cpp @@ -95,7 +95,6 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver, UnitCell& uce // because I move out the dependence on GlobalV from UnitCell::print_stru_file // so its parameter is calculated here bool need_orb = PARAM.inp.basis_type == "pw"; - need_orb = need_orb && PARAM.inp.psi_initializer; need_orb = need_orb && PARAM.inp.init_wfc.substr(0, 3) == "nao"; need_orb = need_orb || PARAM.inp.basis_type == "lcao"; need_orb = need_orb || PARAM.inp.basis_type == "lcao_in_pw"; diff --git a/source/module_ri/exx_lip.h b/source/module_ri/exx_lip.h index 307f58ab9f..9f19560c10 100644 --- a/source/module_ri/exx_lip.h +++ b/source/module_ri/exx_lip.h @@ -38,8 +38,7 @@ class Exx_Lip Exx_Lip(const Exx_Info::Exx_Info_Lip& info_in, const ModuleSymmetry::Symmetry& symm, K_Vectors* kv_ptr_in, - // wavefunc* wf_ptr_in, - psi::PSIInit* wf_ptr_in, + psi::Psi* psi_local_in, psi::Psi* kspw_psi_ptr_in, const ModulePW::PW_Basis_K* wfc_basis_in, const ModulePW::PW_Basis* rho_basis_in, @@ -79,7 +78,7 @@ class Exx_Lip K_Vectors* kv_ptr = nullptr; // wavefunc* wf_ptr; psi::Psi* kspw_psi_ptr = nullptr; ///< PW wavefunction - psi::PSIInit* wf_ptr = nullptr; + psi::Psi* psi_local = nullptr; ///< NAOs in PW ModuleBase::matrix wf_wg; /// @brief LCAO wavefunction, the eigenvectors from lapack diagonalization diff --git a/source/module_ri/exx_lip.hpp b/source/module_ri/exx_lip.hpp index bd94316027..6be31a26b4 100644 --- a/source/module_ri/exx_lip.hpp +++ b/source/module_ri/exx_lip.hpp @@ -13,7 +13,6 @@ #include "module_base/vector3.h" #include "module_hamilt_pw/hamilt_pwdft/global.h" #include "module_cell/klist.h" -#include "module_psi/wavefunc.h" #include "module_hamilt_lcao/hamilt_lcaodft/wavefunc_in_pw.h" #include "module_base/lapack_connector.h" #include "module_base/parallel_global.h" @@ -84,9 +83,8 @@ template Exx_Lip::Exx_Lip(const Exx_Info::Exx_Info_Lip& info_in, const ModuleSymmetry::Symmetry& symm, K_Vectors* kv_ptr_in, - psi::PSIInit* wf_ptr_in, + psi::Psi* psi_local_in, psi::Psi* kspw_psi_ptr_in, - // wavefunc* wf_ptr_in, const ModulePW::PW_Basis_K* wfc_basis_in, const ModulePW::PW_Basis* rho_basis_in, const Structure_Factor& sf, @@ -99,7 +97,7 @@ Exx_Lip::Exx_Lip(const Exx_Info::Exx_Info_Lip& info_in, this->k_pack = new k_package; this->k_pack->kv_ptr = kv_ptr_in; - this->k_pack->wf_ptr = wf_ptr_in; + this->k_pack->psi_local = psi_local_in; this->k_pack->pelec = pelec_in; this->k_pack->kspw_psi_ptr = kspw_psi_ptr_in; this->wfc_basis = wfc_basis_in; @@ -184,7 +182,7 @@ Exx_Lip::~Exx_Lip() else if (PARAM.inp.init_chg == "file") { delete this->q_pack->kv_ptr; this->q_pack->kv_ptr = nullptr; - delete this->q_pack->wf_ptr; this->q_pack->wf_ptr = nullptr; + // delete this->q_pack->wf_ptr; this->q_pack->wf_ptr = nullptr; // delete[] this->q_pack->hvec_array; this->q_pack->hvec_array=nullptr; delete this->q_pack; this->q_pack = nullptr; } @@ -216,7 +214,7 @@ void Exx_Lip::phi_cal(k_package* kq_pack, const int ikq) for (int iw = 0; iw < PARAM.globalv.nlocal; ++iw) { // this->wfc_basis->recip2real(&kq_pack->wf_ptr->wanf2[ikq](iw,0), porter.data(), ikq); - this->wfc_basis->recip2real(&(kq_pack->wf_ptr->get_psig().lock()->operator()(ikq, iw, 0)), porter.data(), ikq); + this->wfc_basis->recip2real(&(kq_pack->psi_local->operator()(ikq, iw, 0)), porter.data(), ikq); int ir = 0; for (int ix = 0; ix < this->rho_basis->nx; ++ix) { diff --git a/tests/integrate/101_PW_15_paw/INPUT b/tests/integrate/101_PW_15_paw/INPUT index 1b781668cf..9ed72bc46d 100644 --- a/tests/integrate/101_PW_15_paw/INPUT +++ b/tests/integrate/101_PW_15_paw/INPUT @@ -6,6 +6,7 @@ calculation scf nbands 6 symmetry 1 pseudo_dir ../../PP_ORB +pw_seed 1 #Parameters (2.Iteration) ecutwfc 20 diff --git a/tests/integrate/101_PW_15_paw/result.ref b/tests/integrate/101_PW_15_paw/result.ref index 6e55ce18ce..a8ed21890d 100644 --- a/tests/integrate/101_PW_15_paw/result.ref +++ b/tests/integrate/101_PW_15_paw/result.ref @@ -1,7 +1,7 @@ -etotref -200.9126364848390267 -etotperatomref -100.4563182424 -totalforceref 3.246238 +etotref -200.9125302160785509 +etotperatomref -100.4562651080 +totalforceref 3.245812 pointgroupref C_1h spacegroupref C_2h nksibzref 1 -totaltimeref 1.17 +totaltimeref 1.44 diff --git a/tests/integrate/101_PW_Coulomb/INPUT b/tests/integrate/101_PW_Coulomb/INPUT index fd6a76683b..73a8b785d0 100644 --- a/tests/integrate/101_PW_Coulomb/INPUT +++ b/tests/integrate/101_PW_Coulomb/INPUT @@ -7,6 +7,7 @@ cal_force 1 nbands 4 pseudo_dir ../../PP_ORB +pw_seed 1 #Parameters (2.Iteration) ecutwfc 40 diff --git a/tests/integrate/101_PW_Coulomb/result.ref b/tests/integrate/101_PW_Coulomb/result.ref index 5736e8d696..e72a05e485 100644 --- a/tests/integrate/101_PW_Coulomb/result.ref +++ b/tests/integrate/101_PW_Coulomb/result.ref @@ -1,5 +1,5 @@ -etotref 5.0394354547993414 -etotperatomref 2.5197177274 -totalforceref 1618.324880 -totalstressref 64343.921765 -totaltimeref 0.35 +etotref 5.0394354550884302 +etotperatomref 2.5197177275 +totalforceref 1618.325000 +totalstressref 64343.912363 +totaltimeref 0.25 diff --git a/tests/integrate/101_PW_blps_pseudopots/INPUT b/tests/integrate/101_PW_blps_pseudopots/INPUT index decaeb9d91..39cdf2647c 100644 --- a/tests/integrate/101_PW_blps_pseudopots/INPUT +++ b/tests/integrate/101_PW_blps_pseudopots/INPUT @@ -6,6 +6,7 @@ calculation scf nbands 6 symmetry 1 pseudo_dir ../../PP_ORB +pw_seed 1 pseudo_rcut 16 #Parameters (2.Iteration) diff --git a/tests/integrate/101_PW_blps_pseudopots/result.ref b/tests/integrate/101_PW_blps_pseudopots/result.ref index eeb7fc8228..e04e4b13af 100644 --- a/tests/integrate/101_PW_blps_pseudopots/result.ref +++ b/tests/integrate/101_PW_blps_pseudopots/result.ref @@ -1,6 +1,6 @@ -etotref -215.9168025283933 -etotperatomref -107.9584012642 +etotref -215.9168029760272 +etotperatomref -107.9584014880 pointgroupref T_d spacegroupref O_h nksibzref 3 -totaltimeref 0.53 +totaltimeref 0.52 diff --git a/tests/integrate/101_PW_upf201_uspp_NaCl/INPUT b/tests/integrate/101_PW_upf201_uspp_NaCl/INPUT index 5794a9e888..3911666d20 100644 --- a/tests/integrate/101_PW_upf201_uspp_NaCl/INPUT +++ b/tests/integrate/101_PW_upf201_uspp_NaCl/INPUT @@ -6,6 +6,7 @@ nbands 12 symmetry 1 latname fcc pseudo_dir ../../PP_ORB +pw_seed 1 #Parameters (2.Iteration) ecutwfc 20 diff --git a/tests/integrate/101_PW_upf201_uspp_NaCl/result.ref b/tests/integrate/101_PW_upf201_uspp_NaCl/result.ref index 65691b7928..6896763a6c 100644 --- a/tests/integrate/101_PW_upf201_uspp_NaCl/result.ref +++ b/tests/integrate/101_PW_upf201_uspp_NaCl/result.ref @@ -1,8 +1,8 @@ -etotref -1675.0621003321411990 -etotperatomref -837.5310501661 -totalforceref 9.445308 -totalstressref 1646.071377 +etotref -1675.0621003323110472 +etotperatomref -837.5310501662 +totalforceref 9.445612 +totalstressref 1646.076135 pointgroupref C_2v spacegroupref C_2v nksibzref 5 -totaltimeref 1.95 +totaltimeref 2.26 diff --git a/tests/integrate/101_PW_upf201_uspp_ncpp/INPUT b/tests/integrate/101_PW_upf201_uspp_ncpp/INPUT index 5264007cf5..26cfb32602 100644 --- a/tests/integrate/101_PW_upf201_uspp_ncpp/INPUT +++ b/tests/integrate/101_PW_upf201_uspp_ncpp/INPUT @@ -5,6 +5,7 @@ calculation scf symmetry 0 latname fcc pseudo_dir ../../PP_ORB +pw_seed 1 #Parameters (2.Iteration) ecutwfc 20 diff --git a/tests/integrate/101_PW_upf201_uspp_ncpp/result.ref b/tests/integrate/101_PW_upf201_uspp_ncpp/result.ref index 106e20bba3..8714b0e3f3 100644 --- a/tests/integrate/101_PW_upf201_uspp_ncpp/result.ref +++ b/tests/integrate/101_PW_upf201_uspp_ncpp/result.ref @@ -1,5 +1,5 @@ -etotref -426.8936030043360006 -etotperatomref -213.4468015022 -totalforceref 0.623688 -totalstressref 8822.968757 -totaltimeref 0.97 +etotref -426.8936030036630882 +etotperatomref -213.4468015018 +totalforceref 0.623668 +totalstressref 8822.969339 +totaltimeref 1.56 diff --git a/tests/integrate/102_PW_BPCG/INPUT b/tests/integrate/102_PW_BPCG/INPUT index d1a30d8f10..d02092bb4a 100644 --- a/tests/integrate/102_PW_BPCG/INPUT +++ b/tests/integrate/102_PW_BPCG/INPUT @@ -2,11 +2,11 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 gamma_only 0 calculation scf symmetry 1 -relax_nmax 1 out_level ie smearing_method gaussian smearing_sigma 0.02 @@ -14,7 +14,7 @@ smearing_sigma 0.02 #Parameters (3.PW) ecutwfc 40 scf_thr 1e-7 -scf_nmax 100 +scf_nmax 20 #Parameters (LCAO) basis_type pw diff --git a/tests/integrate/102_PW_BPCG/result.ref b/tests/integrate/102_PW_BPCG/result.ref index b94b93bfc2..e702dfbb6b 100644 --- a/tests/integrate/102_PW_BPCG/result.ref +++ b/tests/integrate/102_PW_BPCG/result.ref @@ -1,8 +1,8 @@ -etotref -4869.7470519163989593 -etotperatomref -2434.8735259582 -totalforceref 5.198676 -totalstressref 37241.091710 +etotref -4869.74705201 +etotperatomref -2434.87352600 +totalforceref 5.19483000 +totalstressref 37241.44843500 pointgroupref C_1 spacegroupref C_1 nksibzref 8 -totaltimeref 8.48 +totaltimeref 10.37 diff --git a/tests/integrate/102_PW_BPCG_GPU/result.ref b/tests/integrate/102_PW_BPCG_GPU/result.ref index db3463bc99..41371e10fd 100644 --- a/tests/integrate/102_PW_BPCG_GPU/result.ref +++ b/tests/integrate/102_PW_BPCG_GPU/result.ref @@ -1,8 +1,8 @@ -etotref -4869.74705201 -etotperatomref -2434.87352600 -totalforceref 5.19483200 -totalstressref 37241.45338000 +etotref -4869.7470518350019120 +etotperatomref -2434.8735259175 +totalforceref 5.207670 +totalstressref 37241.465646 pointgroupref C_1 spacegroupref C_1 nksibzref 8 -totaltimeref +1.32321 +totaltimeref 4.25 diff --git a/tests/integrate/102_PW_CG_GPU/result.ref b/tests/integrate/102_PW_CG_GPU/result.ref index db3463bc99..a41d4958d6 100644 --- a/tests/integrate/102_PW_CG_GPU/result.ref +++ b/tests/integrate/102_PW_CG_GPU/result.ref @@ -1,8 +1,8 @@ -etotref -4869.74705201 -etotperatomref -2434.87352600 -totalforceref 5.19483200 -totalstressref 37241.45338000 +etotref -4869.7470519303351466 +etotperatomref -2434.8735259652 +totalforceref 5.195370 +totalstressref 37242.031490 pointgroupref C_1 spacegroupref C_1 nksibzref 8 -totaltimeref +1.32321 +totaltimeref 4.13 diff --git a/tests/integrate/102_PW_DA_davidson_GPU/result.ref b/tests/integrate/102_PW_DA_davidson_GPU/result.ref index db3463bc99..5c69f05f9a 100644 --- a/tests/integrate/102_PW_DA_davidson_GPU/result.ref +++ b/tests/integrate/102_PW_DA_davidson_GPU/result.ref @@ -1,8 +1,8 @@ -etotref -4869.74705201 -etotperatomref -2434.87352600 -totalforceref 5.19483200 -totalstressref 37241.45338000 +etotref -4869.7470518365098542 +etotperatomref -2434.8735259183 +totalforceref 5.200640 +totalstressref 37241.467259 pointgroupref C_1 spacegroupref C_1 nksibzref 8 -totaltimeref +1.32321 +totaltimeref 4.79 diff --git a/tests/integrate/102_PW_PINT_RKS/INPUT b/tests/integrate/102_PW_PINT_RKS/INPUT index 285ec0a5fa..2e1c3bc2b8 100644 --- a/tests/integrate/102_PW_PINT_RKS/INPUT +++ b/tests/integrate/102_PW_PINT_RKS/INPUT @@ -3,6 +3,7 @@ INPUT_PARAMETERS suffix autotest pseudo_dir ../../../tests/PP_ORB orbital_dir ../../../tests/PP_ORB +pw_seed 1 nbands 16 #Parameters (Accuracy) ecutwfc 50 @@ -11,7 +12,6 @@ scf_nmax 20 basis_type pw gamma_only 1 -psi_initializer 1 init_wfc nao smearing_method gauss diff --git a/tests/integrate/102_PW_PINT_RKS/result.ref b/tests/integrate/102_PW_PINT_RKS/result.ref index 889ddac358..4a6a18fd41 100644 --- a/tests/integrate/102_PW_PINT_RKS/result.ref +++ b/tests/integrate/102_PW_PINT_RKS/result.ref @@ -1,3 +1,3 @@ -etotref -198.3545030347299303 +etotref -198.3545030348518878 etotperatomref -99.1772515174 -totaltimeref 1.71 +totaltimeref 0.81 diff --git a/tests/integrate/102_PW_PINT_UKS/INPUT b/tests/integrate/102_PW_PINT_UKS/INPUT index ac01b6efed..0608d5122f 100644 --- a/tests/integrate/102_PW_PINT_UKS/INPUT +++ b/tests/integrate/102_PW_PINT_UKS/INPUT @@ -21,6 +21,6 @@ gamma_only 1 nspin 2 pseudo_dir ../../../tests/PP_ORB orbital_dir ../../../tests/PP_ORB +pw_seed 1 -psi_initializer 1 init_wfc nao diff --git a/tests/integrate/102_PW_PINT_UKS/result.ref b/tests/integrate/102_PW_PINT_UKS/result.ref index 7bd1b9f13e..476cf3e367 100644 --- a/tests/integrate/102_PW_PINT_UKS/result.ref +++ b/tests/integrate/102_PW_PINT_UKS/result.ref @@ -1,3 +1,3 @@ -etotref -6147.55311190 -etotperatomref -3073.77655595 -totaltimeref 16.68 +etotref -6147.553111898429 +etotperatomref -3073.7765559492 +totaltimeref 14.32 diff --git a/tests/integrate/103_PW_15_CF_CS_S1_smallg/result.ref b/tests/integrate/103_PW_15_CF_CS_S1_smallg/result.ref index 763308cf0b..9ecfeb65f6 100644 --- a/tests/integrate/103_PW_15_CF_CS_S1_smallg/result.ref +++ b/tests/integrate/103_PW_15_CF_CS_S1_smallg/result.ref @@ -1,8 +1,8 @@ -etotref -378.4158765482854960 +etotref -378.4158765483138041 etotperatomref -126.1386255161 -totalforceref 1005.225100 -totalstressref 2123.397615 +totalforceref 1005.224987 +totalstressref 2123.397579 pointgroupref C_2v spacegroupref C_2v nksibzref 1 -totaltimeref 0.56 +totaltimeref 0.92 diff --git a/tests/integrate/104_PW_NC_magnetic/INPUT b/tests/integrate/104_PW_NC_magnetic/INPUT index c01847313f..d7f2a90ff4 100644 --- a/tests/integrate/104_PW_NC_magnetic/INPUT +++ b/tests/integrate/104_PW_NC_magnetic/INPUT @@ -30,3 +30,4 @@ cal_force 1 cal_stress 1 pseudo_dir ../../PP_ORB orbital_dir ../../PP_ORB +pw_seed 1 diff --git a/tests/integrate/104_PW_NC_magnetic/result.ref b/tests/integrate/104_PW_NC_magnetic/result.ref index 20a4ba84de..1a48e90fbc 100644 --- a/tests/integrate/104_PW_NC_magnetic/result.ref +++ b/tests/integrate/104_PW_NC_magnetic/result.ref @@ -1,5 +1,5 @@ -etotref -6156.9375288900891974 -etotperatomref -3078.4687644450 -totalforceref 2.221910 -totalstressref 76009.325784 -totaltimeref 13.66 +etotref -6156.9375283069703073 +etotperatomref -3078.4687641535 +totalforceref 2.263336 +totalstressref 76007.281586 +totaltimeref 15.08 diff --git a/tests/integrate/107_PW_outWfcR/result.ref b/tests/integrate/107_PW_outWfcR/result.ref index bcc279a0a9..738750b22d 100644 --- a/tests/integrate/107_PW_outWfcR/result.ref +++ b/tests/integrate/107_PW_outWfcR/result.ref @@ -1,12 +1,12 @@ -etotref -197.1405644417786 +etotref -197.1405644417789 etotperatomref -98.5702822209 variance_wfc_r_0_0 0.31340 variance_wfc_r_0_1 1.71055 -variance_wfc_r_0_2 2.39603 -variance_wfc_r_0_3 1.66608 +variance_wfc_r_0_2 2.39604 +variance_wfc_r_0_3 1.66607 variance_wfc_r_0_4 1.05190 variance_wfc_r_0_5 1.29386 pointgroupref T_d spacegroupref O_h nksibzref 1 -totaltimeref 0.29 +totaltimeref 0.40 diff --git a/tests/integrate/108_PW_RE/INPUT b/tests/integrate/108_PW_RE/INPUT index d57d243047..299e14507f 100644 --- a/tests/integrate/108_PW_RE/INPUT +++ b/tests/integrate/108_PW_RE/INPUT @@ -23,5 +23,6 @@ mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 pseudo_dir ../../PP_ORB +pw_seed 1 relax_new 0 diff --git a/tests/integrate/108_PW_RE/result.ref b/tests/integrate/108_PW_RE/result.ref index e353898a86..44c8251895 100644 --- a/tests/integrate/108_PW_RE/result.ref +++ b/tests/integrate/108_PW_RE/result.ref @@ -1,5 +1,5 @@ -etotref -211.5153914724669448 -etotperatomref -105.7576957362 -totalforceref 5.168934 -totalstressref 801.226929 -totaltimeref 2.09 +etotref -211.5153914447757018 +etotperatomref -105.7576957224 +totalforceref 5.171154 +totalstressref 801.333346 +totaltimeref 1.86 diff --git a/tests/integrate/108_PW_RE_MB/INPUT b/tests/integrate/108_PW_RE_MB/INPUT index b83dea68c6..a55bf6fa4c 100644 --- a/tests/integrate/108_PW_RE_MB/INPUT +++ b/tests/integrate/108_PW_RE_MB/INPUT @@ -6,6 +6,7 @@ calculation relax nbands 8 symmetry 1 pseudo_dir ../../PP_ORB +pw_seed 1 #Parameters (2.Iteration) ecutwfc 20 diff --git a/tests/integrate/108_PW_RE_MB/result.ref b/tests/integrate/108_PW_RE_MB/result.ref index 01ba42f52f..da0dd3136d 100644 --- a/tests/integrate/108_PW_RE_MB/result.ref +++ b/tests/integrate/108_PW_RE_MB/result.ref @@ -1,7 +1,7 @@ -etotref -211.6198578541167024 -etotperatomref -105.8099289271 -totalforceref 6.582600 +etotref -211.6198578532441843 +etotperatomref -105.8099289266 +totalforceref 6.582678 pointgroupref C_3v spacegroupref D_3d nksibzref 4 -totaltimeref 1.30 +totaltimeref 1.19 diff --git a/tests/integrate/108_PW_RE_PINT_RKS/INPUT b/tests/integrate/108_PW_RE_PINT_RKS/INPUT index 7e80d6f83c..d8bdd8ff2d 100644 --- a/tests/integrate/108_PW_RE_PINT_RKS/INPUT +++ b/tests/integrate/108_PW_RE_PINT_RKS/INPUT @@ -22,5 +22,5 @@ out_stru 1 chg_extrap second-order #atomic; first-order; second-order; dm:coefficients of SIA pseudo_dir ../../../tests/PP_ORB orbital_dir ../../../tests/PP_ORB -psi_initializer 1 +pw_seed 1 init_wfc nao diff --git a/tests/integrate/108_PW_RE_PINT_RKS/result.ref b/tests/integrate/108_PW_RE_PINT_RKS/result.ref index 2bc7d3f797..4936601ace 100644 --- a/tests/integrate/108_PW_RE_PINT_RKS/result.ref +++ b/tests/integrate/108_PW_RE_PINT_RKS/result.ref @@ -1,5 +1,5 @@ -etotref -253.6810827448143186 -etotperatomref -63.4202706862 -totalforceref 0.078204 -totalstressref 2.142930 -totaltimeref 6.65 \ No newline at end of file +etotref -253.6810826648282671 +etotperatomref -63.4202706662 +totalforceref 0.078418 +totalstressref 2.159478 +totaltimeref 5.48 diff --git a/tests/integrate/109_PW_CR_fix_a/INPUT b/tests/integrate/109_PW_CR_fix_a/INPUT index cd52204c96..bf5421b3bc 100644 --- a/tests/integrate/109_PW_CR_fix_a/INPUT +++ b/tests/integrate/109_PW_CR_fix_a/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 calculation cell-relax diff --git a/tests/integrate/109_PW_CR_fix_a/result.ref b/tests/integrate/109_PW_CR_fix_a/result.ref index 9ec99b7188..8db47b0fc9 100644 --- a/tests/integrate/109_PW_CR_fix_a/result.ref +++ b/tests/integrate/109_PW_CR_fix_a/result.ref @@ -1,5 +1,5 @@ -etotref -211.8234658740580585 -etotperatomref -105.9117329370 -totalforceref 0.058856 -totalstressref 348.179087 -totaltimeref 2.14 +etotref -211.8234658590234574 +etotperatomref -105.9117329295 +totalforceref 0.058886 +totalstressref 348.169515 +totaltimeref 1.63 diff --git a/tests/integrate/109_PW_CR_fix_ab/INPUT b/tests/integrate/109_PW_CR_fix_ab/INPUT index 4d9b90c73c..edb8c154eb 100644 --- a/tests/integrate/109_PW_CR_fix_ab/INPUT +++ b/tests/integrate/109_PW_CR_fix_ab/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 calculation cell-relax diff --git a/tests/integrate/109_PW_CR_fix_ab/result.ref b/tests/integrate/109_PW_CR_fix_ab/result.ref index 559a78771d..9581f93b7a 100644 --- a/tests/integrate/109_PW_CR_fix_ab/result.ref +++ b/tests/integrate/109_PW_CR_fix_ab/result.ref @@ -1,5 +1,5 @@ -etotref -211.8218194781752857 -etotperatomref -105.9109097391 -totalforceref 0.083478 -totalstressref 352.057066 -totaltimeref 2.16 +etotref -211.8218194786840058 +etotperatomref -105.9109097393 +totalforceref 0.083326 +totalstressref 352.065828 +totaltimeref 1.66 diff --git a/tests/integrate/109_PW_CR_fix_abc/INPUT b/tests/integrate/109_PW_CR_fix_abc/INPUT index e858f70d25..c8e05d9392 100644 --- a/tests/integrate/109_PW_CR_fix_abc/INPUT +++ b/tests/integrate/109_PW_CR_fix_abc/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 calculation cell-relax diff --git a/tests/integrate/109_PW_CR_fix_abc/result.ref b/tests/integrate/109_PW_CR_fix_abc/result.ref index aeee6a11be..aa7c43b6c7 100644 --- a/tests/integrate/109_PW_CR_fix_abc/result.ref +++ b/tests/integrate/109_PW_CR_fix_abc/result.ref @@ -1,5 +1,5 @@ -etotref -211.8179023741537037 -etotperatomref -105.9089511871 +etotref -211.8179023689464486 +etotperatomref -105.9089511845 totalforceref 0.000000 -totalstressref 350.996103 -totaltimeref 0.84 +totalstressref 350.991183 +totaltimeref 0.61 diff --git a/tests/integrate/109_PW_CR_fix_ac/INPUT b/tests/integrate/109_PW_CR_fix_ac/INPUT index d765b5784a..18c4d51efb 100644 --- a/tests/integrate/109_PW_CR_fix_ac/INPUT +++ b/tests/integrate/109_PW_CR_fix_ac/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 calculation cell-relax diff --git a/tests/integrate/109_PW_CR_fix_ac/result.ref b/tests/integrate/109_PW_CR_fix_ac/result.ref index 876b4d1dee..21f1bc6b53 100644 --- a/tests/integrate/109_PW_CR_fix_ac/result.ref +++ b/tests/integrate/109_PW_CR_fix_ac/result.ref @@ -1,5 +1,5 @@ -etotref -211.8218194666160343 -etotperatomref -105.9109097333 -totalforceref 0.083410 -totalstressref 352.064644 -totaltimeref 2.02 +etotref -211.8218194443972493 +etotperatomref -105.9109097222 +totalforceref 0.083578 +totalstressref 352.046235 +totaltimeref 1.61 diff --git a/tests/integrate/109_PW_CR_fix_b/INPUT b/tests/integrate/109_PW_CR_fix_b/INPUT index 39d2fdde1e..f1022b2611 100644 --- a/tests/integrate/109_PW_CR_fix_b/INPUT +++ b/tests/integrate/109_PW_CR_fix_b/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 calculation cell-relax diff --git a/tests/integrate/109_PW_CR_fix_b/result.ref b/tests/integrate/109_PW_CR_fix_b/result.ref index 792b6c7a5c..7b8b8a23e3 100644 --- a/tests/integrate/109_PW_CR_fix_b/result.ref +++ b/tests/integrate/109_PW_CR_fix_b/result.ref @@ -1,5 +1,5 @@ -etotref -211.8234659295733309 -etotperatomref -105.9117329648 -totalforceref 0.058958 -totalstressref 348.158801 -totaltimeref 1.62 +etotref -211.8234658682507643 +etotperatomref -105.9117329341 +totalforceref 0.059004 +totalstressref 348.162455 +totaltimeref 1.61 diff --git a/tests/integrate/109_PW_CR_fix_bc/INPUT b/tests/integrate/109_PW_CR_fix_bc/INPUT index db2fbe29ed..48cef8e62d 100644 --- a/tests/integrate/109_PW_CR_fix_bc/INPUT +++ b/tests/integrate/109_PW_CR_fix_bc/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 calculation cell-relax diff --git a/tests/integrate/109_PW_CR_fix_bc/result.ref b/tests/integrate/109_PW_CR_fix_bc/result.ref index 40d1408cf5..fc151d6ab2 100644 --- a/tests/integrate/109_PW_CR_fix_bc/result.ref +++ b/tests/integrate/109_PW_CR_fix_bc/result.ref @@ -1,5 +1,5 @@ -etotref -211.8218195450340318 -etotperatomref -105.9109097725 -totalforceref 0.083524 -totalstressref 352.052855 -totaltimeref 1.64 +etotref -211.8218194597949946 +etotperatomref -105.9109097299 +totalforceref 0.083428 +totalstressref 352.069308 +totaltimeref 1.65 diff --git a/tests/integrate/109_PW_CR_fix_c/INPUT b/tests/integrate/109_PW_CR_fix_c/INPUT index 8afb54dc27..5626335f68 100644 --- a/tests/integrate/109_PW_CR_fix_c/INPUT +++ b/tests/integrate/109_PW_CR_fix_c/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 calculation cell-relax diff --git a/tests/integrate/109_PW_CR_fix_c/result.ref b/tests/integrate/109_PW_CR_fix_c/result.ref index bb8b5d3a6b..53415565f5 100644 --- a/tests/integrate/109_PW_CR_fix_c/result.ref +++ b/tests/integrate/109_PW_CR_fix_c/result.ref @@ -1,5 +1,5 @@ -etotref -211.8234659218114757 -etotperatomref -105.9117329609 -totalforceref 0.058920 -totalstressref 348.164891 -totaltimeref 1.86 +etotref -211.8234658446594381 +etotperatomref -105.9117329223 +totalforceref 0.058676 +totalstressref 348.189070 +totaltimeref 1.62 diff --git a/tests/integrate/111_PW_S2_elec_add/INPUT b/tests/integrate/111_PW_S2_elec_add/INPUT index ac40a3f48a..4590bf72d7 100644 --- a/tests/integrate/111_PW_S2_elec_add/INPUT +++ b/tests/integrate/111_PW_S2_elec_add/INPUT @@ -6,6 +6,7 @@ calculation scf nbands 8 symmetry 1 pseudo_dir ../../PP_ORB +pw_seed 1 nspin 2 nelec 9 diff --git a/tests/integrate/111_PW_S2_elec_add/result.ref b/tests/integrate/111_PW_S2_elec_add/result.ref index 90d179c87b..1996031e14 100644 --- a/tests/integrate/111_PW_S2_elec_add/result.ref +++ b/tests/integrate/111_PW_S2_elec_add/result.ref @@ -1,8 +1,8 @@ -etotref -203.7835585403613265 -etotperatomref -101.8917792702 -totalforceref 6.407578 -totalstressref 2607.200329 +etotref -203.7835604263923130 +etotperatomref -101.8917802132 +totalforceref 6.405916 +totalstressref 2607.722816 pointgroupref C_1h spacegroupref C_2h nksibzref 6 -totaltimeref 2.05 +totaltimeref 2.12 diff --git a/tests/integrate/111_PW_elec_add/INPUT b/tests/integrate/111_PW_elec_add/INPUT index 2f81e5f65a..5391f2b2ed 100644 --- a/tests/integrate/111_PW_elec_add/INPUT +++ b/tests/integrate/111_PW_elec_add/INPUT @@ -6,6 +6,7 @@ calculation scf nbands 8 symmetry 1 pseudo_dir ../../PP_ORB +pw_seed 1 nelec 9 #Parameters (2.Iteration) diff --git a/tests/integrate/111_PW_elec_add/result.ref b/tests/integrate/111_PW_elec_add/result.ref index 2b44e8988b..f68551de85 100644 --- a/tests/integrate/111_PW_elec_add/result.ref +++ b/tests/integrate/111_PW_elec_add/result.ref @@ -1,8 +1,8 @@ -etotref -204.0633597014406462 -etotperatomref -102.0316798507 -totalforceref 6.753356 -totalstressref 2329.021296 +etotref -204.0633597015687144 +etotperatomref -102.0316798508 +totalforceref 6.753432 +totalstressref 2329.023312 pointgroupref C_1h spacegroupref C_2h nksibzref 6 -totaltimeref 1.13 +totaltimeref 1.02 diff --git a/tests/integrate/111_PW_elec_minus/INPUT b/tests/integrate/111_PW_elec_minus/INPUT index 9461bd1e6f..6cfe39d668 100644 --- a/tests/integrate/111_PW_elec_minus/INPUT +++ b/tests/integrate/111_PW_elec_minus/INPUT @@ -6,6 +6,7 @@ calculation scf nbands 8 symmetry 1 pseudo_dir ../../PP_ORB +pw_seed 1 nelec 10 #Parameters (2.Iteration) diff --git a/tests/integrate/111_PW_elec_minus/result.ref b/tests/integrate/111_PW_elec_minus/result.ref index b7245d04dc..ce0ba58223 100644 --- a/tests/integrate/111_PW_elec_minus/result.ref +++ b/tests/integrate/111_PW_elec_minus/result.ref @@ -1,8 +1,8 @@ -etotref -1828.3296385199917040 +etotref -1828.3296385199816996 etotperatomref -1828.3296385200 totalforceref 0.000000 -totalstressref 19914.853368 +totalstressref 19914.857568 pointgroupref O_h spacegroupref O_h nksibzref 3 -totaltimeref 0.81 +totaltimeref 0.71 diff --git a/tests/integrate/115_PW_sol_H2/INPUT b/tests/integrate/115_PW_sol_H2/INPUT index c8401155e0..c2ef3d4335 100644 --- a/tests/integrate/115_PW_sol_H2/INPUT +++ b/tests/integrate/115_PW_sol_H2/INPUT @@ -2,6 +2,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB +pw_seed 1 nbands 2 calculation scf diff --git a/tests/integrate/115_PW_sol_H2/result.ref b/tests/integrate/115_PW_sol_H2/result.ref index 447d1c17fe..1171796606 100644 --- a/tests/integrate/115_PW_sol_H2/result.ref +++ b/tests/integrate/115_PW_sol_H2/result.ref @@ -1,5 +1,5 @@ -etotref -31.89428145200292 -etotperatomref -15.9471407260 -esolelref -0.8065655036 -esolcavref 0.0238597190 -totaltimeref 6.27 +etotref -31.89428054070554 +etotperatomref -15.9471402704 +esolelref -0.8065636756 +esolcavref 0.0238598134 +totaltimeref 6.93 diff --git a/tests/integrate/116_PW_scan_Si2_nspin2/INPUT b/tests/integrate/116_PW_scan_Si2_nspin2/INPUT index 4a01cdf40a..42dacc7dc7 100644 --- a/tests/integrate/116_PW_scan_Si2_nspin2/INPUT +++ b/tests/integrate/116_PW_scan_Si2_nspin2/INPUT @@ -4,6 +4,7 @@ suffix autotest calculation scf pseudo_dir ../../PP_ORB +pw_seed 1 #Parameters (2.Iteration) ecutwfc 50 diff --git a/tests/integrate/116_PW_scan_Si2_nspin2/result.ref b/tests/integrate/116_PW_scan_Si2_nspin2/result.ref index 870be24fe0..2a7271254b 100644 --- a/tests/integrate/116_PW_scan_Si2_nspin2/result.ref +++ b/tests/integrate/116_PW_scan_Si2_nspin2/result.ref @@ -1,5 +1,5 @@ -etotref -204.0503734808325760 -etotperatomref -102.0251867404 -totalforceref 8.822482 -totalstressref 1890.239765 -totaltimeref 8.60 +etotref -204.0503454284882991 +etotperatomref -102.0251727142 +totalforceref 8.812444 +totalstressref 1892.297049 +totaltimeref 8.04 diff --git a/tests/integrate/120_PW_KP_MD_NPT/INPUT b/tests/integrate/120_PW_KP_MD_NPT/INPUT index 9b9f0cabc5..cbfc39af19 100644 --- a/tests/integrate/120_PW_KP_MD_NPT/INPUT +++ b/tests/integrate/120_PW_KP_MD_NPT/INPUT @@ -3,6 +3,7 @@ INPUT_PARAMETERS suffix autotest calculation md pseudo_dir ../../PP_ORB +pw_seed 1 nbands 8 #Parameters (Accuracy) diff --git a/tests/integrate/120_PW_KP_MD_NPT/result.ref b/tests/integrate/120_PW_KP_MD_NPT/result.ref index 647577fa91..82d0530587 100644 --- a/tests/integrate/120_PW_KP_MD_NPT/result.ref +++ b/tests/integrate/120_PW_KP_MD_NPT/result.ref @@ -1,5 +1,5 @@ -etotref -211.8631208364939 -etotperatomref -105.9315604182 -totalforceref 1.536996 -totalstressref 372.373979 -totaltimeref 4.50 +etotref -211.8631210788584 +etotperatomref -105.9315605394 +totalforceref 1.536972 +totalstressref 372.372173 +totaltimeref 3.24 diff --git a/tests/integrate/121_PW_kspacing/INPUT b/tests/integrate/121_PW_kspacing/INPUT index 5d8b43850b..cb9ee63eb9 100644 --- a/tests/integrate/121_PW_kspacing/INPUT +++ b/tests/integrate/121_PW_kspacing/INPUT @@ -17,3 +17,4 @@ smearing_sigma 0.020000 kspacing 0.6 pseudo_dir ../../PP_ORB +pw_seed 1 diff --git a/tests/integrate/121_PW_kspacing/result.ref b/tests/integrate/121_PW_kspacing/result.ref index 383d4b6b65..b1de8f7cab 100644 --- a/tests/integrate/121_PW_kspacing/result.ref +++ b/tests/integrate/121_PW_kspacing/result.ref @@ -1,6 +1,6 @@ -etotref -31.02022530858069 -etotperatomref -15.5101126543 +etotref -31.02022535682493 +etotperatomref -15.5101126784 pointgroupref D_2h spacegroupref D_2h nksibzref 4 -totaltimeref 1.53 +totaltimeref 3.04 diff --git a/tests/integrate/150_PW_15_CR_VDW3/INPUT b/tests/integrate/150_PW_15_CR_VDW3/INPUT index fd89158b41..de91d6509f 100644 --- a/tests/integrate/150_PW_15_CR_VDW3/INPUT +++ b/tests/integrate/150_PW_15_CR_VDW3/INPUT @@ -20,4 +20,5 @@ cal_force 1 cal_stress 1 pseudo_dir ../../PP_ORB orbital_dir ../../PP_ORB +pw_seed 1 dft_functional pbe diff --git a/tests/integrate/150_PW_15_CR_VDW3/result.ref b/tests/integrate/150_PW_15_CR_VDW3/result.ref index 2d886cb2eb..c24a690ccd 100644 --- a/tests/integrate/150_PW_15_CR_VDW3/result.ref +++ b/tests/integrate/150_PW_15_CR_VDW3/result.ref @@ -1,5 +1,5 @@ -etotref -4009.5594228310337712 -etotperatomref -2004.7797114155 -totalforceref 0.848110 -totalstressref 5110.530810 -totaltimeref 3.01 +etotref -4009.5594228450277114 +etotperatomref -2004.7797114225 +totalforceref 0.855650 +totalstressref 5110.532262 +totaltimeref 2.16 diff --git a/tests/integrate/170_PW_MD_1O/INPUT b/tests/integrate/170_PW_MD_1O/INPUT index 7cdcde35fe..c20bce745e 100644 --- a/tests/integrate/170_PW_MD_1O/INPUT +++ b/tests/integrate/170_PW_MD_1O/INPUT @@ -28,3 +28,4 @@ md_tfirst 10 md_tfreq 0.1 init_vel 1 pseudo_dir ../../PP_ORB +pw_seed 1 diff --git a/tests/integrate/170_PW_MD_1O/result.ref b/tests/integrate/170_PW_MD_1O/result.ref index bb54a4f9b9..2030799ade 100644 --- a/tests/integrate/170_PW_MD_1O/result.ref +++ b/tests/integrate/170_PW_MD_1O/result.ref @@ -1,5 +1,5 @@ -etotref -211.8019666057243 -etotperatomref -105.9009833029 -totalforceref 0.492486 -totalstressref 390.965638 -totaltimeref 2.18 +etotref -211.8019662309841 +etotperatomref -105.9009831155 +totalforceref 0.492524 +totalstressref 390.967300 +totaltimeref 2.24 diff --git a/tests/integrate/170_PW_MD_2O/INPUT b/tests/integrate/170_PW_MD_2O/INPUT index f49e82d94d..bcde3a9ca6 100644 --- a/tests/integrate/170_PW_MD_2O/INPUT +++ b/tests/integrate/170_PW_MD_2O/INPUT @@ -27,3 +27,4 @@ md_tfirst 10 md_tfreq 0.1 init_vel 1 pseudo_dir ../../PP_ORB +pw_seed 1 diff --git a/tests/integrate/170_PW_MD_2O/result.ref b/tests/integrate/170_PW_MD_2O/result.ref index 4e2b174060..b4989eb10c 100644 --- a/tests/integrate/170_PW_MD_2O/result.ref +++ b/tests/integrate/170_PW_MD_2O/result.ref @@ -1,5 +1,5 @@ -etotref -211.8019666370744 -etotperatomref -105.9009833185 -totalforceref 0.492994 -totalstressref 391.028183 -totaltimeref 2.64 +etotref -211.8019662597274 +etotperatomref -105.9009831299 +totalforceref 0.493126 +totalstressref 391.031724 +totaltimeref 2.17 diff --git a/tests/integrate/185_PW_SDFT_10D10S_METHD2/INPUT b/tests/integrate/185_PW_SDFT_10D10S_METHD2/INPUT index b9f496060f..f720f7b1e8 100644 --- a/tests/integrate/185_PW_SDFT_10D10S_METHD2/INPUT +++ b/tests/integrate/185_PW_SDFT_10D10S_METHD2/INPUT @@ -7,6 +7,7 @@ method_sto 2 symmetry 0 pseudo_dir ../../PP_ORB +pw_seed 1 nbands 10 nbands_sto 10 diff --git a/tests/integrate/185_PW_SDFT_10D10S_METHD2/result.ref b/tests/integrate/185_PW_SDFT_10D10S_METHD2/result.ref index 41a698449d..38a37307a2 100644 --- a/tests/integrate/185_PW_SDFT_10D10S_METHD2/result.ref +++ b/tests/integrate/185_PW_SDFT_10D10S_METHD2/result.ref @@ -1,5 +1,5 @@ -etotref -323.9154771903686765 -etotperatomref -161.9577385952 -totalforceref 1.045366 -totalstressref 1751.682853 -totaltimeref 4.66 +etotref -323.9131688405863088 +etotperatomref -161.9565844203 +totalforceref 1.005036 +totalstressref 1751.558330 +totaltimeref 3.40 diff --git a/tests/integrate/186_PW_SDOS_10D10S/INPUT b/tests/integrate/186_PW_SDOS_10D10S/INPUT index 838e2c143b..3e5e9202bb 100644 --- a/tests/integrate/186_PW_SDOS_10D10S/INPUT +++ b/tests/integrate/186_PW_SDOS_10D10S/INPUT @@ -12,6 +12,7 @@ emax_sto 0 emin_sto 0 seed_sto 20000 pseudo_dir ../../PP_ORB +pw_seed 1 symmetry 1 kpar 1 bndpar 2 diff --git a/tests/integrate/186_PW_SDOS_10D10S/result.ref b/tests/integrate/186_PW_SDOS_10D10S/result.ref index 125c9eff02..fefe59e88d 100644 --- a/tests/integrate/186_PW_SDOS_10D10S/result.ref +++ b/tests/integrate/186_PW_SDOS_10D10S/result.ref @@ -1,7 +1,7 @@ -etotref -150.3033102880244 -etotperatomref -150.3033102880 -totaldosref 94.3636 +etotref -150.3032299594572 +etotperatomref -150.3032299595 +totaldosref 94.3632 pointgroupref O_h spacegroupref O_h nksibzref 2 -totaltimeref 7.91 +totaltimeref 2.95 diff --git a/tests/integrate/186_PW_SKG_10D10S/INPUT b/tests/integrate/186_PW_SKG_10D10S/INPUT index 6c664a6fc5..7659e98ff6 100644 --- a/tests/integrate/186_PW_SKG_10D10S/INPUT +++ b/tests/integrate/186_PW_SKG_10D10S/INPUT @@ -12,6 +12,7 @@ emax_sto 0 emin_sto 0 seed_sto 20000 pseudo_dir ../../PP_ORB +pw_seed 1 symmetry 1 kpar 2 bndpar 2 diff --git a/tests/integrate/186_PW_SKG_10D10S/refOnsager.txt b/tests/integrate/186_PW_SKG_10D10S/refOnsager.txt index ec603a8402..01ecdf0207 100644 --- a/tests/integrate/186_PW_SKG_10D10S/refOnsager.txt +++ b/tests/integrate/186_PW_SKG_10D10S/refOnsager.txt @@ -58,7 +58,7 @@ 1.13 542590 840.193 -1.13341e+07 3.16352e+08 1.15 542342 839.594 -1.13307e+07 3.16258e+08 1.17 542089 838.984 -1.13271e+07 3.16163e+08 - 1.19 541831 838.365 -1.13235e+07 3.16067e+08 + 1.19 541832 838.365 -1.13235e+07 3.16067e+08 1.21 541570 837.735 -1.13199e+07 3.15968e+08 1.23 541304 837.096 -1.13162e+07 3.15868e+08 1.25 541034 836.447 -1.13124e+07 3.15767e+08 @@ -161,7 +161,7 @@ 3.19 494837 731.737 -1.06308e+07 2.97704e+08 3.21 494162 730.294 -1.06203e+07 2.9743e+08 3.23 493484 728.846 -1.06098e+07 2.97154e+08 - 3.25 492801 727.391 -1.05992e+07 2.96877e+08 + 3.25 492801 727.392 -1.05992e+07 2.96877e+08 3.27 492115 725.931 -1.05886e+07 2.96597e+08 3.29 491425 724.466 -1.05778e+07 2.96316e+08 3.31 490731 722.994 -1.0567e+07 2.96033e+08 @@ -222,7 +222,7 @@ 4.41 447011 634.846 -9.85877e+06 2.77574e+08 4.43 446121 633.139 -9.84381e+06 2.77186e+08 4.45 445228 631.43 -9.82878e+06 2.76796e+08 - 4.47 444332 629.718 -9.81368e+06 2.76403e+08 + 4.47 444332 629.718 -9.81368e+06 2.76404e+08 4.49 443432 628.003 -9.7985e+06 2.76009e+08 4.51 442530 626.285 -9.78325e+06 2.75613e+08 4.53 441624 624.565 -9.76793e+06 2.75216e+08 @@ -233,7 +233,7 @@ 4.63 437051 615.929 -9.69022e+06 2.73198e+08 4.65 436127 614.194 -9.67446e+06 2.72789e+08 4.67 435201 612.458 -9.65862e+06 2.72378e+08 - 4.69 434271 610.719 -9.64272e+06 2.71965e+08 + 4.69 434271 610.719 -9.64272e+06 2.71966e+08 4.71 433339 608.979 -9.62674e+06 2.71551e+08 4.73 432403 607.236 -9.61069e+06 2.71134e+08 4.75 431465 605.491 -9.59456e+06 2.70716e+08 @@ -293,12 +293,12 @@ 5.83 376963 509.573 -8.62106e+06 2.45435e+08 5.85 375892 507.789 -8.60124e+06 2.44919e+08 5.87 374821 506.004 -8.58137e+06 2.44402e+08 - 5.89 373747 504.22 -8.56143e+06 2.43883e+08 + 5.89 373747 504.221 -8.56143e+06 2.43883e+08 5.91 372671 502.437 -8.54143e+06 2.43362e+08 5.93 371594 500.655 -8.52138e+06 2.4284e+08 5.95 370515 498.873 -8.50127e+06 2.42316e+08 5.97 369435 497.091 -8.48109e+06 2.41791e+08 - 5.99 368352 495.311 -8.46086e+06 2.41264e+08 + 5.99 368352 495.311 -8.46087e+06 2.41264e+08 6.01 367268 493.531 -8.44058e+06 2.40735e+08 6.03 366183 491.752 -8.42024e+06 2.40205e+08 6.05 365096 489.974 -8.39984e+06 2.39673e+08 @@ -359,12 +359,12 @@ 7.15 303571 394.51 -7.20317e+06 2.08291e+08 7.17 302435 392.835 -7.18031e+06 2.07687e+08 7.19 301299 391.162 -7.15743e+06 2.07082e+08 - 7.21 300163 389.492 -7.13451e+06 2.06477e+08 + 7.21 300163 389.492 -7.13452e+06 2.06477e+08 7.23 299026 387.825 -7.11157e+06 2.0587e+08 7.25 297890 386.161 -7.0886e+06 2.05263e+08 7.27 296754 384.5 -7.06561e+06 2.04654e+08 7.29 295618 382.841 -7.04259e+06 2.04045e+08 - 7.31 294481 381.185 -7.01954e+06 2.03435e+08 + 7.31 294481 381.186 -7.01954e+06 2.03435e+08 7.33 293345 379.533 -6.99647e+06 2.02824e+08 7.35 292209 377.883 -6.97337e+06 2.02212e+08 7.37 291074 376.237 -6.95025e+06 2.016e+08 @@ -397,7 +397,7 @@ 7.91 260571 333.003 -6.31939e+06 1.84804e+08 7.93 259452 331.45 -6.29587e+06 1.84175e+08 7.95 258333 329.902 -6.27234e+06 1.83545e+08 - 7.97 257215 328.356 -6.24881e+06 1.82915e+08 + 7.97 257215 328.357 -6.24881e+06 1.82915e+08 7.99 256098 326.815 -6.22527e+06 1.82285e+08 8.01 254983 325.278 -6.20173e+06 1.81654e+08 8.03 253868 323.744 -6.17819e+06 1.81023e+08 @@ -421,7 +421,7 @@ 8.39 234027 296.811 -5.75483e+06 1.69632e+08 8.41 232938 295.354 -5.73138e+06 1.68998e+08 8.43 231852 293.901 -5.70793e+06 1.68365e+08 - 8.45 230767 292.451 -5.6845e+06 1.67732e+08 + 8.45 230767 292.452 -5.6845e+06 1.67732e+08 8.47 229683 291.007 -5.66108e+06 1.67098e+08 8.49 228602 289.566 -5.63768e+06 1.66465e+08 8.51 227522 288.13 -5.61429e+06 1.65832e+08 @@ -523,7 +523,7 @@ 10.43 135754 172.401 -3.53331e+06 1.08295e+08 10.45 134953 171.444 -3.51427e+06 1.07755e+08 10.47 134157 170.492 -3.49531e+06 1.07218e+08 - 10.49 133364 169.545 -3.47642e+06 1.06682e+08 + 10.49 133364 169.546 -3.47642e+06 1.06682e+08 10.51 132575 168.604 -3.4576e+06 1.06148e+08 10.53 131789 167.668 -3.43885e+06 1.05615e+08 10.55 131008 166.738 -3.42017e+06 1.05085e+08 @@ -557,7 +557,7 @@ 11.11 110674 142.865 -2.92786e+06 9.099e+07 11.13 110004 142.09 -2.91141e+06 9.05153e+07 11.15 109338 141.321 -2.89504e+06 9.00426e+07 - 11.17 108676 140.557 -2.87875e+06 8.95719e+07 + 11.17 108676 140.557 -2.87876e+06 8.95719e+07 11.19 108017 139.798 -2.86255e+06 8.91034e+07 11.21 107363 139.045 -2.84643e+06 8.86369e+07 11.23 106713 138.297 -2.83038e+06 8.81725e+07 @@ -594,7 +594,7 @@ 11.85 88496.2 117.734 -2.37408e+06 7.48426e+07 11.87 87970.8 117.154 -2.3607e+06 7.44477e+07 11.89 87449.3 116.579 -2.3474e+06 7.40551e+07 - 11.91 86931.5 116.01 -2.33418e+06 7.36647e+07 + 11.91 86931.5 116.01 -2.33419e+06 7.36647e+07 11.93 86417.7 115.445 -2.32105e+06 7.32766e+07 11.95 85907.6 114.885 -2.30801e+06 7.28906e+07 11.97 85401.4 114.331 -2.29504e+06 7.25069e+07 @@ -608,7 +608,7 @@ 12.13 81487.9 110.075 -2.19434e+06 6.95179e+07 12.15 81015.6 109.566 -2.18213e+06 6.91544e+07 12.17 80547.1 109.061 -2.17e+06 6.8793e+07 - 12.19 80082.3 108.561 -2.15795e+06 6.8434e+07 + 12.19 80082.4 108.561 -2.15795e+06 6.8434e+07 12.21 79621.3 108.067 -2.14599e+06 6.80771e+07 12.23 79163.9 107.577 -2.13411e+06 6.77225e+07 12.25 78710.3 107.092 -2.12231e+06 6.73701e+07 @@ -625,7 +625,7 @@ 12.47 73961.4 102.073 -1.99795e+06 6.3641e+07 12.49 73551.3 101.645 -1.98713e+06 6.33153e+07 12.51 73144.8 101.222 -1.97639e+06 6.29918e+07 - 12.53 72741.8 100.804 -1.96574e+06 6.26706e+07 + 12.53 72741.9 100.804 -1.96574e+06 6.26706e+07 12.55 72342.4 100.39 -1.95516e+06 6.23515e+07 12.57 71946.5 99.9806 -1.94467e+06 6.20346e+07 12.59 71554.2 99.5758 -1.93425e+06 6.17199e+07 @@ -651,7 +651,7 @@ 12.99 64423.8 92.4112 -1.74244e+06 5.58812e+07 13.01 64102.1 92.0978 -1.73365e+06 5.56116e+07 13.03 63783.6 91.7885 -1.72494e+06 5.53441e+07 - 13.05 63468.2 91.4832 -1.71631e+06 5.50787e+07 + 13.05 63468.3 91.4832 -1.71631e+06 5.50787e+07 13.07 63156.1 91.182 -1.70774e+06 5.48154e+07 13.09 62847.1 90.8848 -1.69926e+06 5.45542e+07 13.11 62541.3 90.5917 -1.69084e+06 5.4295e+07 @@ -673,16 +673,16 @@ 13.43 58062.2 86.4238 -1.56599e+06 5.04234e+07 13.45 57807.3 86.1946 -1.55878e+06 5.01983e+07 13.47 57555.3 85.969 -1.55164e+06 4.9975e+07 - 13.49 57306 85.7468 -1.54457e+06 4.97537e+07 + 13.49 57306.1 85.7469 -1.54457e+06 4.97538e+07 13.51 57059.7 85.5282 -1.53756e+06 4.95344e+07 13.53 56816.1 85.3129 -1.53062e+06 4.93169e+07 13.55 56575.2 85.1011 -1.52375e+06 4.91013e+07 13.57 56337.2 84.8926 -1.51695e+06 4.88876e+07 13.59 56101.9 84.6875 -1.5102e+06 4.86758e+07 13.61 55869.3 84.4857 -1.50353e+06 4.84659e+07 - 13.63 55639.4 84.2872 -1.49692e+06 4.82578e+07 + 13.63 55639.4 84.2873 -1.49692e+06 4.82578e+07 13.65 55412.2 84.092 -1.49038e+06 4.80516e+07 - 13.67 55187.7 83.9 -1.48389e+06 4.78472e+07 + 13.67 55187.7 83.9001 -1.48389e+06 4.78472e+07 13.69 54965.8 83.7113 -1.47748e+06 4.76447e+07 13.71 54746.6 83.5257 -1.47113e+06 4.7444e+07 13.73 54530 83.3432 -1.46484e+06 4.72451e+07 @@ -696,12 +696,12 @@ 13.89 52889.2 81.9936 -1.41676e+06 4.57184e+07 13.91 52695.3 81.8382 -1.41102e+06 4.55355e+07 13.93 52503.9 81.6857 -1.40534e+06 4.53543e+07 - 13.95 52314.9 81.5359 -1.39972e+06 4.51748e+07 + 13.95 52314.9 81.536 -1.39972e+06 4.51748e+07 13.97 52128.3 81.389 -1.39417e+06 4.4997e+07 13.99 51944 81.2449 -1.38866e+06 4.48209e+07 14.01 51762.2 81.1035 -1.38322e+06 4.46465e+07 14.03 51582.7 80.9648 -1.37784e+06 4.44738e+07 - 14.05 51405.5 80.8287 -1.37251e+06 4.43027e+07 + 14.05 51405.5 80.8288 -1.37251e+06 4.43027e+07 14.07 51230.6 80.6954 -1.36724e+06 4.41333e+07 14.09 51058 80.5646 -1.36203e+06 4.39655e+07 14.11 50887.7 80.4365 -1.35687e+06 4.37994e+07 @@ -714,16 +714,16 @@ 14.25 49757.6 79.6095 -1.3223e+06 4.26814e+07 14.27 49604.8 79.501 -1.31757e+06 4.25279e+07 14.29 49454.1 79.3949 -1.3129e+06 4.2376e+07 - 14.31 49305.5 79.291 -1.30828e+06 4.22257e+07 + 14.31 49305.5 79.2911 -1.30828e+06 4.22257e+07 14.33 49158.9 79.1895 -1.30371e+06 4.20769e+07 - 14.35 49014.4 79.0901 -1.2992e+06 4.19295e+07 + 14.35 49014.4 79.0902 -1.2992e+06 4.19295e+07 14.37 48872 78.993 -1.29473e+06 4.17837e+07 14.39 48731.5 78.8981 -1.29032e+06 4.16394e+07 14.41 48593.1 78.8053 -1.28595e+06 4.14965e+07 14.43 48456.6 78.7147 -1.28164e+06 4.13552e+07 - 14.45 48322.1 78.6261 -1.27737e+06 4.12152e+07 + 14.45 48322.1 78.6262 -1.27737e+06 4.12152e+07 14.47 48189.6 78.5397 -1.27316e+06 4.10768e+07 - 14.49 48058.9 78.4552 -1.26899e+06 4.09397e+07 + 14.49 48058.9 78.4553 -1.26899e+06 4.09397e+07 14.51 47930.2 78.3728 -1.26487e+06 4.08041e+07 14.53 47803.3 78.2924 -1.2608e+06 4.06699e+07 14.55 47678.3 78.2139 -1.25677e+06 4.05371e+07 @@ -743,10 +743,10 @@ 14.83 46114.5 77.3059 -1.20517e+06 3.88195e+07 14.85 46015.4 77.2535 -1.2018e+06 3.87065e+07 14.87 45917.9 77.2027 -1.19848e+06 3.85947e+07 - 14.89 45821.9 77.1534 -1.1952e+06 3.84842e+07 + 14.89 45821.9 77.1535 -1.1952e+06 3.84842e+07 14.91 45727.4 77.1056 -1.19196e+06 3.83748e+07 14.93 45634.5 77.0593 -1.18876e+06 3.82667e+07 - 14.95 45543.1 77.0143 -1.1856e+06 3.81598e+07 + 14.95 45543.1 77.0144 -1.1856e+06 3.81598e+07 14.97 45453.2 76.9708 -1.18248e+06 3.8054e+07 14.99 45364.8 76.9287 -1.17939e+06 3.79494e+07 15.01 45277.8 76.8879 -1.17635e+06 3.78459e+07 @@ -755,17 +755,17 @@ 15.07 45025.5 76.7734 -1.16743e+06 3.75425e+07 15.09 44944.2 76.7378 -1.16454e+06 3.74436e+07 15.11 44864.3 76.7034 -1.16168e+06 3.73458e+07 - 15.13 44785.7 76.6702 -1.15885e+06 3.72491e+07 + 15.13 44785.7 76.6703 -1.15885e+06 3.72491e+07 15.15 44708.5 76.6383 -1.15606e+06 3.71534e+07 - 15.17 44632.6 76.6074 -1.15331e+06 3.70589e+07 + 15.17 44632.6 76.6075 -1.15331e+06 3.70589e+07 15.19 44558 76.5778 -1.15059e+06 3.69654e+07 15.21 44484.7 76.5492 -1.14791e+06 3.6873e+07 - 15.23 44412.7 76.5217 -1.14526e+06 3.67816e+07 - 15.25 44341.9 76.4953 -1.14264e+06 3.66912e+07 + 15.23 44412.7 76.5218 -1.14526e+06 3.67816e+07 + 15.25 44341.9 76.4954 -1.14264e+06 3.66912e+07 15.27 44272.4 76.47 -1.14006e+06 3.66019e+07 15.29 44204.1 76.4457 -1.13751e+06 3.65136e+07 15.31 44137 76.4224 -1.13499e+06 3.64263e+07 - 15.33 44071 76.4 -1.13251e+06 3.63399e+07 + 15.33 44071.1 76.4 -1.13251e+06 3.63399e+07 15.35 44006.3 76.3787 -1.13005e+06 3.62546e+07 15.37 43942.8 76.3582 -1.12763e+06 3.61702e+07 15.39 43880.3 76.3387 -1.12524e+06 3.60868e+07 @@ -804,10 +804,10 @@ 16.05 42362.9 76.077 -1.06158e+06 3.38094e+07 16.07 42330.5 76.0769 -1.06005e+06 3.37529e+07 16.09 42298.8 76.0771 -1.05854e+06 3.36971e+07 - 16.11 42267.6 76.0775 -1.05704e+06 3.36419e+07 + 16.11 42267.6 76.0776 -1.05704e+06 3.36419e+07 16.13 42237.1 76.0782 -1.05557e+06 3.35872e+07 16.15 42207.2 76.0791 -1.05411e+06 3.35332e+07 - 16.17 42177.9 76.0802 -1.05267e+06 3.34798e+07 + 16.17 42177.9 76.0802 -1.05267e+06 3.34799e+07 16.19 42149.1 76.0814 -1.05125e+06 3.3427e+07 16.21 42120.9 76.0828 -1.04985e+06 3.33748e+07 16.23 42093.3 76.0844 -1.04847e+06 3.33232e+07 @@ -815,7 +815,7 @@ 16.27 42039.7 76.0879 -1.04575e+06 3.32216e+07 16.29 42013.6 76.0899 -1.04442e+06 3.31716e+07 16.31 41988.1 76.0919 -1.04311e+06 3.31221e+07 - 16.33 41963 76.094 -1.04181e+06 3.30732e+07 + 16.33 41963.1 76.094 -1.04181e+06 3.30732e+07 16.35 41938.5 76.0961 -1.04052e+06 3.30249e+07 16.37 41914.4 76.0983 -1.03926e+06 3.2977e+07 16.39 41890.8 76.1006 -1.038e+06 3.29297e+07 @@ -825,16 +825,16 @@ 16.47 41800.6 76.1095 -1.03315e+06 3.27453e+07 16.49 41779.2 76.1117 -1.03197e+06 3.27004e+07 16.51 41758.1 76.1139 -1.0308e+06 3.2656e+07 - 16.53 41737.3 76.1159 -1.02965e+06 3.2612e+07 + 16.53 41737.3 76.116 -1.02965e+06 3.2612e+07 16.55 41717 76.1179 -1.02852e+06 3.25685e+07 16.57 41697 76.1199 -1.02739e+06 3.25254e+07 16.59 41677.4 76.1217 -1.02628e+06 3.24828e+07 16.61 41658.1 76.1234 -1.02518e+06 3.24406e+07 - 16.63 41639.1 76.1249 -1.0241e+06 3.23988e+07 + 16.63 41639.2 76.1249 -1.0241e+06 3.23988e+07 16.65 41620.5 76.1263 -1.02303e+06 3.23574e+07 16.67 41602.2 76.1276 -1.02196e+06 3.23165e+07 16.69 41584.2 76.1287 -1.02092e+06 3.22759e+07 - 16.71 41566.5 76.1296 -1.01988e+06 3.22358e+07 + 16.71 41566.5 76.1297 -1.01988e+06 3.22358e+07 16.73 41549 76.1304 -1.01885e+06 3.2196e+07 16.75 41531.9 76.1309 -1.01784e+06 3.21567e+07 16.77 41515 76.1313 -1.01683e+06 3.21177e+07 @@ -842,7 +842,7 @@ 16.81 41481.9 76.1312 -1.01486e+06 3.20408e+07 16.83 41465.7 76.1308 -1.01389e+06 3.20029e+07 16.85 41449.8 76.1302 -1.01293e+06 3.19653e+07 - 16.87 41434.1 76.1293 -1.01198e+06 3.19281e+07 + 16.87 41434.1 76.1293 -1.01198e+06 3.19282e+07 16.89 41418.6 76.1281 -1.01103e+06 3.18913e+07 16.91 41403.3 76.1266 -1.0101e+06 3.18548e+07 16.93 41388.2 76.1248 -1.00918e+06 3.18186e+07 @@ -862,7 +862,7 @@ 17.21 41192.3 76.0623 -997138 3.13432e+07 17.23 41179.2 76.0548 -996334 3.13112e+07 17.25 41166.1 76.0468 -995536 3.12796e+07 - 17.27 41153 76.0383 -994744 3.12481e+07 + 17.27 41153 76.0384 -994745 3.12481e+07 17.29 41140.1 76.0294 -993959 3.12169e+07 17.31 41127.1 76.02 -993180 3.11859e+07 17.33 41114.3 76.0101 -992407 3.11551e+07 @@ -871,21 +871,21 @@ 17.39 41075.8 75.9773 -990120 3.10641e+07 17.41 41063 75.9654 -989369 3.10342e+07 17.43 41050.3 75.9529 -988623 3.10045e+07 - 17.45 41037.5 75.9398 -987882 3.09749e+07 + 17.45 41037.5 75.9399 -987882 3.09749e+07 17.47 41024.7 75.9263 -987146 3.09456e+07 17.49 41012 75.9121 -986415 3.09165e+07 - 17.51 40999.2 75.8974 -985688 3.08875e+07 + 17.51 40999.2 75.8975 -985688 3.08875e+07 17.53 40986.4 75.8822 -984966 3.08587e+07 - 17.55 40973.6 75.8663 -984248 3.08301e+07 + 17.55 40973.6 75.8664 -984248 3.08301e+07 17.57 40960.8 75.8499 -983534 3.08017e+07 17.59 40947.9 75.8329 -982824 3.07734e+07 17.61 40935 75.8153 -982119 3.07453e+07 17.63 40922 75.7971 -981417 3.07174e+07 17.65 40909 75.7783 -980719 3.06896e+07 17.67 40896 75.7589 -980025 3.0662e+07 - 17.69 40882.8 75.7388 -979334 3.06345e+07 + 17.69 40882.9 75.7388 -979334 3.06345e+07 17.71 40869.7 75.7182 -978646 3.06072e+07 - 17.73 40856.4 75.6968 -977962 3.058e+07 + 17.73 40856.4 75.6969 -977962 3.058e+07 17.75 40843.1 75.6749 -977281 3.05529e+07 17.77 40829.7 75.6523 -976603 3.0526e+07 17.79 40816.2 75.6291 -975928 3.04993e+07 @@ -894,7 +894,7 @@ 17.85 40775.3 75.5554 -973920 3.04197e+07 17.87 40761.4 75.5295 -973256 3.03934e+07 17.89 40747.5 75.503 -972594 3.03673e+07 - 17.91 40733.4 75.4757 -971935 3.03412e+07 + 17.91 40733.4 75.4758 -971935 3.03412e+07 17.93 40719.3 75.4478 -971278 3.03153e+07 17.95 40705 75.4192 -970623 3.02895e+07 17.97 40690.6 75.3899 -969970 3.02637e+07 @@ -909,7 +909,7 @@ 18.15 40555.2 75.0944 -964176 3.00366e+07 18.17 40539.4 75.058 -963539 3.00118e+07 18.19 40523.5 75.0208 -962904 2.99871e+07 - 18.21 40507.4 74.9829 -962270 2.99624e+07 + 18.21 40507.4 74.9829 -962270 2.99625e+07 18.23 40491.2 74.9442 -961638 2.99379e+07 18.25 40474.8 74.9049 -961006 2.99134e+07 18.27 40458.2 74.8647 -960375 2.9889e+07 @@ -947,7 +947,7 @@ 18.91 39830.3 73.18 -940382 2.91347e+07 18.93 39807.4 73.1147 -939756 2.91117e+07 18.95 39784.2 73.0487 -939129 2.90888e+07 - 18.97 39760.8 72.9819 -938502 2.90659e+07 + 18.97 39760.8 72.982 -938502 2.90659e+07 18.99 39737.2 72.9144 -937874 2.9043e+07 19.01 39713.4 72.8461 -937246 2.90201e+07 19.03 39689.4 72.7771 -936617 2.89973e+07 @@ -963,13 +963,13 @@ 19.23 39437.2 72.0458 -930298 2.87702e+07 19.25 39410.8 71.9687 -929663 2.87476e+07 19.27 39384.2 71.8908 -929026 2.8725e+07 - 19.29 39357.4 71.8122 -928389 2.87024e+07 + 19.29 39357.4 71.8122 -928389 2.87025e+07 19.31 39330.3 71.7328 -927752 2.86799e+07 19.33 39303.1 71.6528 -927114 2.86574e+07 19.35 39275.6 71.572 -926475 2.86349e+07 19.37 39247.9 71.4906 -925835 2.86124e+07 19.39 39220 71.4084 -925194 2.85899e+07 - 19.41 39191.9 71.3255 -924553 2.85674e+07 + 19.41 39191.9 71.3256 -924553 2.85674e+07 19.43 39163.6 71.242 -923911 2.8545e+07 19.45 39135 71.1577 -923269 2.85226e+07 19.47 39106.3 71.0728 -922625 2.85002e+07 @@ -987,14 +987,14 @@ 19.71 38744.9 70.001 -914845 2.82327e+07 19.73 38713.5 69.9075 -914191 2.82105e+07 19.75 38681.8 69.8133 -913537 2.81883e+07 - 19.77 38649.9 69.7185 -912882 2.81662e+07 + 19.77 38649.9 69.7185 -912883 2.81662e+07 19.79 38617.9 69.6231 -912227 2.81441e+07 19.81 38585.6 69.527 -911571 2.8122e+07 19.83 38553.2 69.4304 -910913 2.80999e+07 19.85 38520.5 69.3331 -910256 2.80778e+07 - 19.87 38487.6 69.2352 -909597 2.80558e+07 + 19.87 38487.6 69.2353 -909597 2.80558e+07 19.89 38454.6 69.1368 -908938 2.80337e+07 - 19.91 38421.3 69.0377 -908278 2.80117e+07 + 19.91 38421.3 69.0378 -908278 2.80117e+07 19.93 38387.9 68.9381 -907617 2.79897e+07 19.95 38354.3 68.8379 -906955 2.79678e+07 19.97 38320.4 68.7371 -906293 2.79458e+07 diff --git a/tests/integrate/186_PW_SKG_10D10S/result.ref b/tests/integrate/186_PW_SKG_10D10S/result.ref index eba9f432e9..109ca84176 100644 --- a/tests/integrate/186_PW_SKG_10D10S/result.ref +++ b/tests/integrate/186_PW_SKG_10D10S/result.ref @@ -1,7 +1,7 @@ -etotref -150.5555663868826 -etotperatomref -150.5555663869 +etotref -150.5555764070538 +etotperatomref -150.5555764071 CompareH_Failed 0 pointgroupref O_h spacegroupref O_h nksibzref 3 -totaltimeref 3.67 +totaltimeref 3.51 diff --git a/tests/integrate/186_PW_SNLKG_10D10S/INPUT b/tests/integrate/186_PW_SNLKG_10D10S/INPUT index 440e0ad9e1..0c5e85cc6d 100644 --- a/tests/integrate/186_PW_SNLKG_10D10S/INPUT +++ b/tests/integrate/186_PW_SNLKG_10D10S/INPUT @@ -12,6 +12,7 @@ emax_sto 0 emin_sto 0 seed_sto 20000 pseudo_dir ../../PP_ORB +pw_seed 1 symmetry 1 kpar 1 bndpar 2 diff --git a/tests/integrate/186_PW_SNLKG_10D10S/result.ref b/tests/integrate/186_PW_SNLKG_10D10S/result.ref index 8d31951039..8d14d3d147 100644 --- a/tests/integrate/186_PW_SNLKG_10D10S/result.ref +++ b/tests/integrate/186_PW_SNLKG_10D10S/result.ref @@ -1,7 +1,7 @@ -etotref -150.4783166823345 -etotperatomref -150.4783166823 +etotref -150.4782967068114 +etotperatomref -150.4782967068 CompareH_Failed 0 pointgroupref O_h spacegroupref O_h nksibzref 3 -totaltimeref 5.91 +totaltimeref 6.04 diff --git a/tests/integrate/187_PW_MD_SDFT_ALL_GPU/result.ref b/tests/integrate/187_PW_MD_SDFT_ALL_GPU/result.ref index ef2e7fcc80..3286d3a478 100644 --- a/tests/integrate/187_PW_MD_SDFT_ALL_GPU/result.ref +++ b/tests/integrate/187_PW_MD_SDFT_ALL_GPU/result.ref @@ -1,5 +1,5 @@ -etotref -228.9492279657028 -etotperatomref -114.4746139829 +etotref -228.94922797 +etotperatomref -114.47461398 totalforceref 0.510260 -totalstressref 42801.474893 -totaltimeref 7.82 +totalstressref 42801.475682 +totaltimeref 4.89 diff --git a/tests/integrate/187_PW_SDFT_ALL_GPU/result.ref b/tests/integrate/187_PW_SDFT_ALL_GPU/result.ref index dd61868257..3e011155c8 100644 --- a/tests/integrate/187_PW_SDFT_ALL_GPU/result.ref +++ b/tests/integrate/187_PW_SDFT_ALL_GPU/result.ref @@ -1,5 +1,5 @@ -etotref -105.2612355454176907 +etotref -105.2612355454177191 etotperatomref -52.6306177727 totalforceref 197.906706 totalstressref 254537.682905 -totaltimeref 20.82 +totaltimeref 11.36 diff --git a/tests/integrate/187_PW_SDFT_MALL_GPU/result.ref b/tests/integrate/187_PW_SDFT_MALL_GPU/result.ref index dafd960f93..2137525518 100644 --- a/tests/integrate/187_PW_SDFT_MALL_GPU/result.ref +++ b/tests/integrate/187_PW_SDFT_MALL_GPU/result.ref @@ -1,5 +1,5 @@ -etotref -96.9361115889958853 -etotperatomref -48.4680557945 -totalforceref 248.975546 -totalstressref 230454.805813 -totaltimeref 5.17 +etotref -96.9361114247635811 +etotperatomref -48.4680557124 +totalforceref 248.974900 +totalstressref 230455.686659 +totaltimeref 3.58 diff --git a/tests/integrate/803_PW_LT_bcc/result.ref b/tests/integrate/803_PW_LT_bcc/result.ref index 8eb600d972..815ac3a9b1 100644 --- a/tests/integrate/803_PW_LT_bcc/result.ref +++ b/tests/integrate/803_PW_LT_bcc/result.ref @@ -1,5 +1,5 @@ -etotref -30.6144125397493490 -etotperatomref -15.3072062699 -totalforceref 7.577254 -totalstressref 84.023704 -totaltimeref 0.47 +etotref -30.6144125394732107 +etotperatomref -15.3072062697 +totalforceref 7.577494 +totalstressref 84.029412 +totaltimeref 0.30 diff --git a/tests/integrate/804_PW_LT_hexagonal/INPUT b/tests/integrate/804_PW_LT_hexagonal/INPUT index 7a77e4da6c..516af3d7bd 100644 --- a/tests/integrate/804_PW_LT_hexagonal/INPUT +++ b/tests/integrate/804_PW_LT_hexagonal/INPUT @@ -6,6 +6,7 @@ nbands 4 stru_file STRU kpoint_file KPT pseudo_dir ../../PP_ORB +pw_seed 1 calculation scf latname hexagonal #Parameters (PW) diff --git a/tests/integrate/804_PW_LT_hexagonal/result.ref b/tests/integrate/804_PW_LT_hexagonal/result.ref index 81b894bebf..1bc0312b17 100644 --- a/tests/integrate/804_PW_LT_hexagonal/result.ref +++ b/tests/integrate/804_PW_LT_hexagonal/result.ref @@ -1,5 +1,5 @@ -etotref -30.3807460311781909 -etotperatomref -15.1903730156 -totalforceref 6.625358 -totalstressref 20.693987 -totaltimeref +etotref -30.3807460309569350 +etotperatomref -15.1903730155 +totalforceref 6.625336 +totalstressref 20.693367 +totaltimeref 0.48 diff --git a/tests/integrate/805_PW_LT_trigonal/INPUT b/tests/integrate/805_PW_LT_trigonal/INPUT index ebea0ab067..f164763edd 100644 --- a/tests/integrate/805_PW_LT_trigonal/INPUT +++ b/tests/integrate/805_PW_LT_trigonal/INPUT @@ -6,6 +6,7 @@ nbands 4 stru_file STRU kpoint_file KPT pseudo_dir ../../PP_ORB +pw_seed 1 calculation scf latname trigonal #Parameters (PW) diff --git a/tests/integrate/805_PW_LT_trigonal/result.ref b/tests/integrate/805_PW_LT_trigonal/result.ref index ec83b1dcf3..1d1a85cf84 100644 --- a/tests/integrate/805_PW_LT_trigonal/result.ref +++ b/tests/integrate/805_PW_LT_trigonal/result.ref @@ -1,5 +1,5 @@ -etotref -30.4287469281882679 -etotperatomref -15.2143734641 -totalforceref 6.858422 -totalstressref 49.777651 -totaltimeref +etotref -30.4287469280466389 +etotperatomref -15.2143734640 +totalforceref 6.858328 +totalstressref 49.778124 +totaltimeref 0.33 diff --git a/tests/integrate/806_PW_LT_st/INPUT b/tests/integrate/806_PW_LT_st/INPUT index 8ea2430624..7d8a087c0e 100644 --- a/tests/integrate/806_PW_LT_st/INPUT +++ b/tests/integrate/806_PW_LT_st/INPUT @@ -6,6 +6,7 @@ nbands 4 stru_file STRU kpoint_file KPT pseudo_dir ../../PP_ORB +pw_seed 1 calculation scf latname st #Parameters (PW) diff --git a/tests/integrate/806_PW_LT_st/result.ref b/tests/integrate/806_PW_LT_st/result.ref index 19870913e7..36887b50de 100644 --- a/tests/integrate/806_PW_LT_st/result.ref +++ b/tests/integrate/806_PW_LT_st/result.ref @@ -1,5 +1,5 @@ -etotref -30.3802655002955753 -etotperatomref -15.1901327501 -totalforceref 6.562134 -totalstressref 16.940605 -totaltimeref 0.76 +etotref -30.3802655003663062 +etotperatomref -15.1901327502 +totalforceref 6.562132 +totalstressref 16.940520 +totaltimeref 0.46 diff --git a/tests/integrate/807_PW_LT_bct/INPUT b/tests/integrate/807_PW_LT_bct/INPUT index eafbff73b3..b7a0aff06d 100644 --- a/tests/integrate/807_PW_LT_bct/INPUT +++ b/tests/integrate/807_PW_LT_bct/INPUT @@ -6,6 +6,7 @@ nbands 4 stru_file STRU kpoint_file KPT pseudo_dir ../../PP_ORB +pw_seed 1 calculation scf latname bct #Parameters (PW) diff --git a/tests/integrate/807_PW_LT_bct/result.ref b/tests/integrate/807_PW_LT_bct/result.ref index bfe8ccf6a2..f0e14be972 100644 --- a/tests/integrate/807_PW_LT_bct/result.ref +++ b/tests/integrate/807_PW_LT_bct/result.ref @@ -1,5 +1,5 @@ -etotref -30.3907901447520565 +etotref -30.3907901447582454 etotperatomref -15.1953950724 -totalforceref 6.596184 -totalstressref 33.626103 -totaltimeref 0.76 +totalforceref 6.596212 +totalstressref 33.626146 +totaltimeref 0.59 diff --git a/tests/integrate/809_PW_LT_baco/INPUT b/tests/integrate/809_PW_LT_baco/INPUT index c13ba6d1d7..71684a8dbc 100644 --- a/tests/integrate/809_PW_LT_baco/INPUT +++ b/tests/integrate/809_PW_LT_baco/INPUT @@ -6,6 +6,7 @@ nbands 4 stru_file STRU kpoint_file KPT pseudo_dir ../../PP_ORB +pw_seed 1 calculation scf latname baco #Parameters (PW) diff --git a/tests/integrate/809_PW_LT_baco/result.ref b/tests/integrate/809_PW_LT_baco/result.ref index e1b175677a..f106fb1c14 100644 --- a/tests/integrate/809_PW_LT_baco/result.ref +++ b/tests/integrate/809_PW_LT_baco/result.ref @@ -1,5 +1,5 @@ -etotref -30.4370645449022525 -etotperatomref -15.2185322725 -totalforceref 6.794566 -totalstressref 26.221358 -totaltimeref +etotref -30.4370645448345769 +etotperatomref -15.2185322724 +totalforceref 6.794504 +totalstressref 26.220981 +totaltimeref 0.68 diff --git a/tests/integrate/811_PW_LT_bco/INPUT b/tests/integrate/811_PW_LT_bco/INPUT index 001c694b60..a21eea6871 100644 --- a/tests/integrate/811_PW_LT_bco/INPUT +++ b/tests/integrate/811_PW_LT_bco/INPUT @@ -6,6 +6,7 @@ nbands 4 stru_file STRU kpoint_file KPT pseudo_dir ../../PP_ORB +pw_seed 1 calculation scf latname bco #Parameters (PW) diff --git a/tests/integrate/811_PW_LT_bco/result.ref b/tests/integrate/811_PW_LT_bco/result.ref index 79b0dff0ac..53c778cb0c 100644 --- a/tests/integrate/811_PW_LT_bco/result.ref +++ b/tests/integrate/811_PW_LT_bco/result.ref @@ -1,5 +1,5 @@ -etotref -30.3664499596159985 +etotref -30.3664499595127850 etotperatomref -15.1832249798 -totalforceref 6.543724 -totalstressref 21.508902 -totaltimeref +0.11373 +totalforceref 6.543818 +totalstressref 21.509776 +totaltimeref 0.62