|
| 1 | +#include "module_io/ctrl_output_fp.h" // use ctrl_output_fp() |
| 2 | + |
| 3 | +namespace ModuleIO |
| 4 | +{ |
| 5 | + |
| 6 | +template <typename TK, typename TR> |
| 7 | +void ctrl_output_fp(UnitCell& ucell, |
| 8 | + elecstate::ElecStateLCAO<TK>* pelec, |
| 9 | + const int istep) |
| 10 | +{ |
| 11 | + ModuleBase::TITLE("ModuleIO", "ctrl_output_fp"); |
| 12 | + ModuleBase::timer::tick("ModuleIO", "ctrl_output_fp"); |
| 13 | + |
| 14 | + const bool out_app_flag = PARAM.inp.out_app_flag; |
| 15 | + const bool gamma_only = PARAM.globalv.gamma_only_local; |
| 16 | + const int nspin = PARAM.inp.nspin; |
| 17 | + const std::string global_out_dir = PARAM.globalv.global_out_dir; |
| 18 | + |
| 19 | + // 1) write charge density |
| 20 | + if (PARAM.inp.out_chg[0] > 0) |
| 21 | + { |
| 22 | + for (int is = 0; is < PARAM.inp.nspin; is++) |
| 23 | + { |
| 24 | + this->pw_rhod->real2recip(this->chr.rho_save[is], this->chr.rhog_save[is]); |
| 25 | + std::string fn =PARAM.globalv.global_out_dir + "/chgs" + std::to_string(is + 1) + ".cube"; |
| 26 | + ModuleIO::write_vdata_palgrid(Pgrid, |
| 27 | + this->chr.rho_save[is], |
| 28 | + is, |
| 29 | + PARAM.inp.nspin, |
| 30 | + istep, |
| 31 | + fn, |
| 32 | + this->pelec->eferm.get_efval(is), |
| 33 | + &(ucell), |
| 34 | + PARAM.inp.out_chg[1], |
| 35 | + 1); |
| 36 | + |
| 37 | + if (XC_Functional::get_ked_flag()) |
| 38 | + { |
| 39 | + fn =PARAM.globalv.global_out_dir + "/taus" + std::to_string(is + 1) + ".cube"; |
| 40 | + ModuleIO::write_vdata_palgrid(Pgrid, |
| 41 | + this->chr.kin_r_save[is], |
| 42 | + is, |
| 43 | + PARAM.inp.nspin, |
| 44 | + istep, |
| 45 | + fn, |
| 46 | + this->pelec->eferm.get_efval(is), |
| 47 | + &(ucell)); |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + |
| 53 | + // 2) write potential |
| 54 | + if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) |
| 55 | + { |
| 56 | + for (int is = 0; is < PARAM.inp.nspin; is++) |
| 57 | + { |
| 58 | + std::string fn =PARAM.globalv.global_out_dir + "/pots" + std::to_string(is + 1) + ".cube"; |
| 59 | + |
| 60 | + ModuleIO::write_vdata_palgrid(Pgrid, |
| 61 | + this->pelec->pot->get_effective_v(is), |
| 62 | + is, |
| 63 | + PARAM.inp.nspin, |
| 64 | + istep, |
| 65 | + fn, |
| 66 | + 0.0, // efermi |
| 67 | + &(ucell), |
| 68 | + 3, // precision |
| 69 | + 0); // out_fermi |
| 70 | + } |
| 71 | + } |
| 72 | + else if (PARAM.inp.out_pot == 2) |
| 73 | + { |
| 74 | + std::string fn =PARAM.globalv.global_out_dir + "/pot_es.cube"; |
| 75 | + ModuleIO::write_elecstat_pot( |
| 76 | +#ifdef __MPI |
| 77 | + this->pw_big->bz, |
| 78 | + this->pw_big->nbz, |
| 79 | +#endif |
| 80 | + fn, |
| 81 | + istep, |
| 82 | + this->pw_rhod, |
| 83 | + &this->chr, |
| 84 | + &(ucell), |
| 85 | + this->pelec->pot->get_fixed_v(), |
| 86 | + this->solvent); |
| 87 | + } |
| 88 | + |
| 89 | + |
| 90 | + // 3) write ELF |
| 91 | + if (PARAM.inp.out_elf[0] > 0) |
| 92 | + { |
| 93 | + this->chr.cal_elf = true; |
| 94 | + Symmetry_rho srho; |
| 95 | + for (int is = 0; is < PARAM.inp.nspin; is++) |
| 96 | + { |
| 97 | + srho.begin(is, this->chr, this->pw_rhod, ucell.symm); |
| 98 | + } |
| 99 | + |
| 100 | + std::string out_dir =PARAM.globalv.global_out_dir; |
| 101 | + ModuleIO::write_elf( |
| 102 | +#ifdef __MPI |
| 103 | + this->pw_big->bz, |
| 104 | + this->pw_big->nbz, |
| 105 | +#endif |
| 106 | + out_dir, |
| 107 | + istep, |
| 108 | + PARAM.inp.nspin, |
| 109 | + this->chr.rho, |
| 110 | + this->chr.kin_r, |
| 111 | + this->pw_rhod, |
| 112 | + this->Pgrid, |
| 113 | + &(ucell), |
| 114 | + PARAM.inp.out_elf[1]); |
| 115 | + } |
| 116 | + |
| 117 | + ModuleBase::timer::tick("ModuleIO", "ctrl_output_fp"); |
| 118 | +} |
| 119 | + |
| 120 | +} // End ModuleIO |
| 121 | + |
| 122 | + |
| 123 | +// For gamma only |
| 124 | +template void ModuleIO::ctrl_output_lcao<double, double>(UnitCell& ucell, |
| 125 | + const int istep); |
| 126 | + |
| 127 | +// For multiple k-points |
| 128 | +template void ModuleIO::ctrl_output_lcao<std::complex<double>, double>(UnitCell& ucell, |
| 129 | + const int istep); |
| 130 | + |
| 131 | +template void ModuleIO::ctrl_output_lcao<std::complex<double>, std::complex<double>>(UnitCell& ucell, |
| 132 | + const int istep); |
| 133 | + |
0 commit comments