|
| 1 | +#include "esolver_gets.h" |
| 2 | + |
| 3 | +#include "module_base/timer.h" |
| 4 | +#include "module_cell/module_neighbor/sltk_atom_arrange.h" |
| 5 | +#include "module_elecstate/elecstate_lcao.h" |
| 6 | +#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h" |
| 7 | +#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h" |
| 8 | +#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h" |
| 9 | +#include "module_io/print_info.h" |
| 10 | +#include "module_io/write_HS_R.h" |
| 11 | + |
| 12 | +namespace ModuleESolver |
| 13 | +{ |
| 14 | + |
| 15 | +template <typename TK, typename TR> |
| 16 | +ESolver_GetS<TK, TR>::ESolver_GetS() |
| 17 | +{ |
| 18 | + this->classname = "ESolver_GetS"; |
| 19 | + this->basisname = "LCAO"; |
| 20 | +} |
| 21 | + |
| 22 | +template <typename TK, typename TR> |
| 23 | +ESolver_GetS<TK, TR>::~ESolver_GetS() |
| 24 | +{ |
| 25 | +} |
| 26 | + |
| 27 | +template <typename TK, typename TR> |
| 28 | +void ESolver_GetS<TK, TR>::before_all_runners(const Input_para& inp, UnitCell& ucell) |
| 29 | +{ |
| 30 | + ModuleBase::TITLE("ESolver_GetS", "before_all_runners"); |
| 31 | + ModuleBase::timer::tick("ESolver_GetS", "before_all_runners"); |
| 32 | + |
| 33 | + // 1.1) read pseudopotentials |
| 34 | + ucell.read_pseudo(GlobalV::ofs_running); |
| 35 | + |
| 36 | + // 1.2) symmetrize things |
| 37 | + if (ModuleSymmetry::Symmetry::symm_flag == 1) |
| 38 | + { |
| 39 | + ucell.symm.analy_sys(ucell.lat, ucell.st, ucell.atoms, GlobalV::ofs_running); |
| 40 | + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SYMMETRY"); |
| 41 | + } |
| 42 | + |
| 43 | + // 1.3) Setup k-points according to symmetry. |
| 44 | + this->kv.set(ucell.symm, inp.kpoint_file, inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); |
| 45 | + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); |
| 46 | + |
| 47 | + ModuleIO::setup_parameters(ucell, this->kv); |
| 48 | + |
| 49 | + // 2) init ElecState |
| 50 | + // autoset nbands in ElecState, it should before basis_init (for Psi 2d division) |
| 51 | + if (this->pelec == nullptr) |
| 52 | + { |
| 53 | + // TK stands for double and complex<double>? |
| 54 | + this->pelec = new elecstate::ElecStateLCAO<TK>(&(this->chr), // use which parameter? |
| 55 | + &(this->kv), |
| 56 | + this->kv.get_nks(), |
| 57 | + &(this->GG), // mohan add 2024-04-01 |
| 58 | + &(this->GK), // mohan add 2024-04-01 |
| 59 | + this->pw_rho, |
| 60 | + this->pw_big); |
| 61 | + } |
| 62 | + |
| 63 | + // 3) init LCAO basis |
| 64 | + // reading the localized orbitals/projectors |
| 65 | + // construct the interpolation tables. |
| 66 | + LCAO_domain::init_basis_lcao(this->pv, |
| 67 | + inp.onsite_radius, |
| 68 | + inp.lcao_ecut, |
| 69 | + inp.lcao_dk, |
| 70 | + inp.lcao_dr, |
| 71 | + inp.lcao_rmax, |
| 72 | + ucell, |
| 73 | + two_center_bundle_, |
| 74 | + orb_); |
| 75 | + |
| 76 | + // 4) initialize the density matrix |
| 77 | + // DensityMatrix is allocated here, DMK is also initialized here |
| 78 | + // DMR is not initialized here, it will be constructed in each before_scf |
| 79 | + dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->init_DM(&this->kv, &(this->pv), inp.nspin); |
| 80 | + |
| 81 | + ModuleBase::timer::tick("ESolver_GetS", "before_all_runners"); |
| 82 | +} |
| 83 | + |
| 84 | +template <> |
| 85 | +void ESolver_GetS<double, double>::runner(const int istep, UnitCell& ucell) |
| 86 | +{ |
| 87 | + ModuleBase::TITLE("ESolver_GetS", "runner"); |
| 88 | + ModuleBase::WARNING_QUIT("ESolver_GetS<double, double>::runner", "not implemented"); |
| 89 | +} |
| 90 | + |
| 91 | +template <> |
| 92 | +void ESolver_GetS<std::complex<double>, std::complex<double>>::runner(const int istep, UnitCell& ucell) |
| 93 | +{ |
| 94 | + ModuleBase::TITLE("ESolver_GetS", "runner"); |
| 95 | + ModuleBase::timer::tick("ESolver_GetS", "runner"); |
| 96 | + |
| 97 | + // (1) Find adjacent atoms for each atom. |
| 98 | + double search_radius = -1.0; |
| 99 | + search_radius = atom_arrange::set_sr_NL(GlobalV::ofs_running, |
| 100 | + PARAM.inp.out_level, |
| 101 | + orb_.get_rcutmax_Phi(), |
| 102 | + ucell.infoNL.get_rcutmax_Beta(), |
| 103 | + PARAM.globalv.gamma_only_local); |
| 104 | + |
| 105 | + atom_arrange::search(PARAM.inp.search_pbc, |
| 106 | + GlobalV::ofs_running, |
| 107 | + GlobalC::GridD, |
| 108 | + ucell, |
| 109 | + search_radius, |
| 110 | + PARAM.inp.test_atom_input); |
| 111 | + |
| 112 | + this->RA.for_2d(this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs()); |
| 113 | + |
| 114 | + if (this->p_hamilt == nullptr) |
| 115 | + { |
| 116 | + this->p_hamilt |
| 117 | + = new hamilt::HamiltLCAO<std::complex<double>, std::complex<double>>(&this->pv, |
| 118 | + this->kv, |
| 119 | + *(two_center_bundle_.overlap_orb), |
| 120 | + orb_.cutoffs()); |
| 121 | + dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, std::complex<double>>*>(this->p_hamilt->ops) |
| 122 | + ->contributeHR(); |
| 123 | + } |
| 124 | + |
| 125 | + const std::string fn = PARAM.globalv.global_out_dir + "SR.csr"; |
| 126 | + std::cout << " The file is saved in " << fn << std::endl; |
| 127 | + ModuleIO::output_SR(pv, GlobalC::GridD, this->p_hamilt, fn); |
| 128 | + |
| 129 | + ModuleBase::timer::tick("ESolver_GetS", "runner"); |
| 130 | +} |
| 131 | + |
| 132 | +template <> |
| 133 | +void ESolver_GetS<std::complex<double>, double>::runner(const int istep, UnitCell& ucell) |
| 134 | +{ |
| 135 | + ModuleBase::TITLE("ESolver_GetS", "runner"); |
| 136 | + ModuleBase::timer::tick("ESolver_GetS", "runner"); |
| 137 | + |
| 138 | + // (1) Find adjacent atoms for each atom. |
| 139 | + double search_radius = -1.0; |
| 140 | + search_radius = atom_arrange::set_sr_NL(GlobalV::ofs_running, |
| 141 | + PARAM.inp.out_level, |
| 142 | + orb_.get_rcutmax_Phi(), |
| 143 | + ucell.infoNL.get_rcutmax_Beta(), |
| 144 | + PARAM.globalv.gamma_only_local); |
| 145 | + |
| 146 | + atom_arrange::search(PARAM.inp.search_pbc, |
| 147 | + GlobalV::ofs_running, |
| 148 | + GlobalC::GridD, |
| 149 | + ucell, |
| 150 | + search_radius, |
| 151 | + PARAM.inp.test_atom_input); |
| 152 | + |
| 153 | + this->RA.for_2d(this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs()); |
| 154 | + |
| 155 | + if (this->p_hamilt == nullptr) |
| 156 | + { |
| 157 | + this->p_hamilt = new hamilt::HamiltLCAO<std::complex<double>, double>(&this->pv, |
| 158 | + this->kv, |
| 159 | + *(two_center_bundle_.overlap_orb), |
| 160 | + orb_.cutoffs()); |
| 161 | + dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, double>*>(this->p_hamilt->ops)->contributeHR(); |
| 162 | + } |
| 163 | + |
| 164 | + const std::string fn = PARAM.globalv.global_out_dir + "SR.csr"; |
| 165 | + std::cout << " The file is saved in " << fn << std::endl; |
| 166 | + ModuleIO::output_SR(pv, GlobalC::GridD, this->p_hamilt, fn); |
| 167 | + |
| 168 | + ModuleBase::timer::tick("ESolver_GetS", "runner"); |
| 169 | +} |
| 170 | + |
| 171 | +template class ESolver_GetS<double, double>; |
| 172 | +template class ESolver_GetS<std::complex<double>, double>; |
| 173 | +template class ESolver_GetS<std::complex<double>, std::complex<double>>; |
| 174 | + |
| 175 | +} // namespace ModuleESolver |
0 commit comments