|
| 1 | +#include "esolver_dm2rho.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_elecstate/read_pseudo.h" |
| 7 | +#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h" |
| 8 | +#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h" |
| 9 | +#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h" |
| 10 | +#include "module_io/cube_io.h" |
| 11 | +#include "module_io/io_npz.h" |
| 12 | +#include "module_io/print_info.h" |
| 13 | + |
| 14 | +namespace ModuleESolver |
| 15 | +{ |
| 16 | + |
| 17 | +template <typename TK, typename TR> |
| 18 | +ESolver_DM2rho<TK, TR>::ESolver_DM2rho() |
| 19 | +{ |
| 20 | + this->classname = "ESolver_DM2rho"; |
| 21 | + this->basisname = "LCAO"; |
| 22 | +} |
| 23 | + |
| 24 | +template <typename TK, typename TR> |
| 25 | +ESolver_DM2rho<TK, TR>::~ESolver_DM2rho() |
| 26 | +{ |
| 27 | +} |
| 28 | + |
| 29 | +template <typename TK, typename TR> |
| 30 | +void ESolver_DM2rho<TK, TR>::before_all_runners(UnitCell& ucell, const Input_para& inp) |
| 31 | +{ |
| 32 | + ModuleBase::TITLE("ESolver_DM2rho", "before_all_runners"); |
| 33 | + ModuleBase::timer::tick("ESolver_DM2rho", "before_all_runners"); |
| 34 | + |
| 35 | + ESolver_KS_LCAO<TK, TR>::before_all_runners(ucell, inp); |
| 36 | + |
| 37 | + ModuleBase::timer::tick("ESolver_DM2rho", "before_all_runners"); |
| 38 | +} |
| 39 | + |
| 40 | +template <typename TK, typename TR> |
| 41 | +void ESolver_DM2rho<TK, TR>::runner(UnitCell& ucell, const int istep) |
| 42 | +{ |
| 43 | + ModuleBase::TITLE("ESolver_DM2rho", "runner"); |
| 44 | + ModuleBase::timer::tick("ESolver_DM2rho", "runner"); |
| 45 | + |
| 46 | + ESolver_KS_LCAO<TK, TR>::before_scf(ucell, istep); |
| 47 | + |
| 48 | + // file name of DM |
| 49 | + std::string zipname = "output_DM0.npz"; |
| 50 | + elecstate::DensityMatrix<TK, double>* dm = dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(); |
| 51 | + |
| 52 | + // read DM from file |
| 53 | + ModuleIO::read_mat_npz(&(this->pv), ucell, zipname, *(dm->get_DMR_pointer(1))); |
| 54 | + |
| 55 | + // if nspin=2, need extra reading |
| 56 | + if (PARAM.inp.nspin == 2) |
| 57 | + { |
| 58 | + zipname = "output_DM1.npz"; |
| 59 | + ModuleIO::read_mat_npz(&(this->pv), ucell, zipname, *(dm->get_DMR_pointer(2))); |
| 60 | + } |
| 61 | + |
| 62 | + this->pelec->psiToRho(*this->psi); |
| 63 | + |
| 64 | + int nspin0 = PARAM.inp.nspin == 2 ? 2 : 1; |
| 65 | + |
| 66 | + for (int is = 0; is < nspin0; is++) |
| 67 | + { |
| 68 | + std::string fn = PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_CHG.cube"; |
| 69 | + |
| 70 | + // write electron density |
| 71 | + ModuleIO::write_vdata_palgrid(this->Pgrid, |
| 72 | + this->chr.rho[is], |
| 73 | + is, |
| 74 | + PARAM.inp.nspin, |
| 75 | + istep, |
| 76 | + fn, |
| 77 | + this->pelec->eferm.get_efval(is), |
| 78 | + &(ucell), |
| 79 | + 3, |
| 80 | + 1); |
| 81 | + } |
| 82 | + |
| 83 | + ModuleBase::timer::tick("ESolver_DM2rho", "runner"); |
| 84 | +} |
| 85 | + |
| 86 | +template <typename TK, typename TR> |
| 87 | +void ESolver_DM2rho<TK, TR>::after_all_runners(UnitCell& ucell) |
| 88 | +{ |
| 89 | + ModuleBase::TITLE("ESolver_DM2rho", "after_all_runners"); |
| 90 | + ModuleBase::timer::tick("ESolver_DM2rho", "after_all_runners"); |
| 91 | + |
| 92 | + ESolver_KS_LCAO<TK, TR>::after_all_runners(ucell); |
| 93 | + |
| 94 | + ModuleBase::timer::tick("ESolver_DM2rho", "after_all_runners"); |
| 95 | +}; |
| 96 | + |
| 97 | +template class ESolver_DM2rho<std::complex<double>, double>; |
| 98 | +template class ESolver_DM2rho<std::complex<double>, std::complex<double>>; |
| 99 | + |
| 100 | +} // namespace ModuleESolver |
0 commit comments