diff --git a/source/module_esolver/esolver.cpp b/source/module_esolver/esolver.cpp index d865cfdbb2..0352492a3a 100644 --- a/source/module_esolver/esolver.cpp +++ b/source/module_esolver/esolver.cpp @@ -186,39 +186,29 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell) } } else if (esolver_type == "ksdft_lcao") - { - if (PARAM.globalv.gamma_only_local) - { - if (PARAM.inp.calculation == "get_S") + { + if (PARAM.inp.calculation == "get_S") + { + if (PARAM.globalv.gamma_only_local) { ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for gamma_only"); } else { - return new ESolver_KS_LCAO(); + return new ESolver_GetS(); } } + if (PARAM.globalv.gamma_only_local) + { + return new ESolver_KS_LCAO(); + } else if (PARAM.inp.nspin < 4) { - if (PARAM.inp.calculation == "get_S") - { - return new ESolver_GetS(); - } - else - { - return new ESolver_KS_LCAO, double>(); - } + return new ESolver_KS_LCAO, double>(); } else { - if (PARAM.inp.calculation == "get_S") - { - ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for npsin=4"); - } - else - { - return new ESolver_KS_LCAO, std::complex>(); - } + return new ESolver_KS_LCAO, std::complex>(); } } else if (esolver_type == "ksdft_lcao_tddft") diff --git a/source/module_esolver/esolver_gets.cpp b/source/module_esolver/esolver_gets.cpp index 059b58cd4a..71ebc67ba0 100644 --- a/source/module_esolver/esolver_gets.cpp +++ b/source/module_esolver/esolver_gets.cpp @@ -103,11 +103,24 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep) if (this->p_hamilt == nullptr) { - this->p_hamilt = new hamilt::HamiltLCAO, double>(&this->pv, - this->kv, - *(two_center_bundle_.overlap_orb), - orb_.cutoffs()); - dynamic_cast, double>*>(this->p_hamilt->ops)->contributeHR(); + if (PARAM.inp.nspin == 4) + { + this->p_hamilt + = new hamilt::HamiltLCAO, std::complex>(&this->pv, + this->kv, + *(two_center_bundle_.overlap_orb), + orb_.cutoffs()); + dynamic_cast, std::complex>*>(this->p_hamilt->ops) + ->contributeHR(); + } + else + { + this->p_hamilt = new hamilt::HamiltLCAO, double>(&this->pv, + this->kv, + *(two_center_bundle_.overlap_orb), + orb_.cutoffs()); + dynamic_cast, double>*>(this->p_hamilt->ops)->contributeHR(); + } } const std::string fn = PARAM.globalv.global_out_dir + "SR.csr"; diff --git a/source/module_io/write_HS_R.cpp b/source/module_io/write_HS_R.cpp index 0ea348e079..590f95fb78 100644 --- a/source/module_io/write_HS_R.cpp +++ b/source/module_io/write_HS_R.cpp @@ -171,14 +171,28 @@ void ModuleIO::output_SR(Parallel_Orbitals& pv, const int istep = 0; - ModuleIO::save_sparse(HS_Arrays.SR_sparse, - HS_Arrays.all_R_coor, - sparse_thr, - binary, - SR_filename, - pv, - "S", - istep); + if (PARAM.inp.nspin == 4) + { + ModuleIO::save_sparse(HS_Arrays.SR_soc_sparse, + HS_Arrays.all_R_coor, + sparse_thr, + binary, + SR_filename, + pv, + "S", + istep); + } + else + { + ModuleIO::save_sparse(HS_Arrays.SR_sparse, + HS_Arrays.all_R_coor, + sparse_thr, + binary, + SR_filename, + pv, + "S", + istep); + } sparse_format::destroy_HS_R_sparse(HS_Arrays);