Skip to content

Commit 6213fdf

Browse files
committed
Add function get_local_pp_energy into ElecState to calculatet the energy contributed by local pseudopotential.
1 parent c749f72 commit 6213fdf

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

source/module_elecstate/elecstate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class ElecState
155155
}
156156

157157
double get_dftu_energy();
158+
double get_local_pp_energy();
158159

159160
#ifdef __DEEPKS
160161
double get_deepks_E_delta();

source/module_elecstate/elecstate_energy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ void ElecState::cal_energies(const int type)
311311
this->f_en.edftu = get_dftu_energy();
312312
}
313313

314+
this->f_en.eion_elec = get_local_pp_energy();
315+
314316
#ifdef __DEEPKS
315317
// energy from deepks
316318
if (PARAM.inp.deepks_scf)

source/module_elecstate/elecstate_energy_terms.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ double ElecState::get_dftu_energy()
3939
return GlobalC::dftu.get_energy();
4040
}
4141

42+
double ElecState::get_local_pp_energy()
43+
{
44+
double local_pseudopot_energy = 0.; // electron-ion interaction energy
45+
for (int is = 0; is < PARAM.inp.nspin; ++is)
46+
{
47+
local_pseudopot_energy += BlasConnector::dot(this->charge->rhopw->nrxx, this->pot->get_fixed_v(), 1, this->charge->rho[is], 1)
48+
* this->charge->rhopw->omega / this->charge->rhopw->nxyz;
49+
}
50+
Parallel_Reduce::reduce_all(local_pseudopot_energy);
51+
return local_pseudopot_energy;
52+
}
53+
4254
#ifdef __DEEPKS
4355
double ElecState::get_deepks_E_delta()
4456
{

source/module_esolver/esolver_ks.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,6 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
672672
dkin = p_chgmix->get_dkin(pelec->charge, PARAM.inp.nelec);
673673
}
674674

675-
double pseudopot_energy = 0.; // electron-ion interaction energy
676-
for (int is = 0; is < PARAM.inp.nspin; ++is)
677-
{
678-
pseudopot_energy += BlasConnector::dot(this->pw_rho->nrxx, this->pelec->pot->get_fixed_v(), 1, pelec->charge->rho[is], 1)
679-
* ucell.omega / this->pw_rho->nxyz;
680-
}
681-
Parallel_Reduce::reduce_all(pseudopot_energy);
682-
this->pelec->f_en.eion_elec = pseudopot_energy;
683675
this->pelec->print_etot(ucell.magnet,this->conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, diag_ethr);
684676

685677
// Json, need to be moved to somewhere else

0 commit comments

Comments
 (0)