|
| 1 | +//======================= |
| 2 | +// AUTHOR : Peize Lin |
| 3 | +// DATE : 2025-10-01 |
| 4 | +//======================= |
| 5 | + |
| 6 | +#include "pot_xc_fdm.h" |
| 7 | +#include "source_hamilt/module_xc/xc_functional.h" |
| 8 | + |
| 9 | +namespace elecstate |
| 10 | +{ |
| 11 | + |
| 12 | +PotXC_FDM::PotXC_FDM( |
| 13 | + const ModulePW::PW_Basis* rho_basis_in, |
| 14 | + const Charge*const chg_0_in, |
| 15 | + const UnitCell*const ucell) |
| 16 | + : chg_0(chg_0_in) |
| 17 | +{ |
| 18 | + this->rho_basis_ = rho_basis_in; |
| 19 | + this->dynamic_mode = true; |
| 20 | + this->fixed_mode = false; |
| 21 | + |
| 22 | + const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v_0 |
| 23 | + = XC_Functional::v_xc(this->chg_0->nrxx, this->chg_0, ucell); |
| 24 | + this->v_xc_0 = std::get<2>(etxc_vtxc_v_0); |
| 25 | +} |
| 26 | + |
| 27 | +void PotXC_FDM::cal_v_eff( |
| 28 | + const Charge*const chg_1, |
| 29 | + const UnitCell*const ucell, |
| 30 | + ModuleBase::matrix& v_eff) |
| 31 | +{ |
| 32 | + ModuleBase::TITLE("PotXC_FDM", "cal_veff"); |
| 33 | + ModuleBase::timer::tick("PotXC_FDM", "cal_veff"); |
| 34 | + |
| 35 | + assert(this->chg_0->nrxx == chg_1->nrxx); |
| 36 | + assert(this->chg_0->nspin == chg_1->nspin); |
| 37 | + |
| 38 | + Charge chg_01; |
| 39 | + chg_01.set_rhopw(chg_1->rhopw); |
| 40 | + chg_01.allocate(chg_1->nspin, chg_01.kin_density()); |
| 41 | + |
| 42 | + for(int ir=0; ir<chg_01.nrxx; ++ir) |
| 43 | + { |
| 44 | + for(int is=0; is<chg_01.nspin; ++is) |
| 45 | + { chg_01.rho[is][ir] = chg_0->rho[is][ir] + chg_1->rho[is][ir]; } |
| 46 | + chg_01.rho_core[ir] = chg_0->rho_core[ir] + chg_1->rho_core[ir]; |
| 47 | + } |
| 48 | + |
| 49 | + const std::tuple<double, double, ModuleBase::matrix> etxc_vtxc_v_01 |
| 50 | + = XC_Functional::v_xc(chg_01.nrxx, &chg_01, ucell); |
| 51 | + const ModuleBase::matrix &v_xc_01 = std::get<2>(etxc_vtxc_v_01); |
| 52 | + |
| 53 | + v_eff += v_xc_01 - this->v_xc_0; |
| 54 | + |
| 55 | + ModuleBase::timer::tick("PotXC_FDM", "cal_veff"); |
| 56 | +} |
| 57 | + |
| 58 | +} // namespace elecstate |
| 59 | + |
0 commit comments