Skip to content

Commit

Permalink
Fix: charge allocate in ofdft
Browse files Browse the repository at this point in the history
  • Loading branch information
YuLiu98 committed Aug 13, 2024
1 parent 34fbc26 commit c414c17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
8 changes: 0 additions & 8 deletions source/module_elecstate/module_charge/charge_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ void Charge_Extra::extrapolate_charge(
}

sf->setup_structure_factor(&ucell, chr->rhopw);
// ModuleBase::OMP_PARALLEL([&](int num_threads, int thread_id) {
// int irbeg, irlen;
// ModuleBase::BLOCK_TASK_DIST_1D(num_threads, thread_id, chr->rhopw->nrxx, 512, irbeg, irlen);
// for (int is = 0; is < GlobalV::NSPIN; is++)
// {
// ModuleBase::GlobalFunc::ZEROS(rho_atom[is] + irbeg, irlen);
// }
// });
chr->atomic_rho(GlobalV::NSPIN, ucell.omega, rho_atom, sf->strucFac, ucell);
#ifdef _OPENMP
#pragma omp parallel for collapse(2) schedule(static, 512)
Expand Down
9 changes: 5 additions & 4 deletions source/module_esolver/esolver_of_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ namespace ModuleESolver
*/
void ESolver_OF::init_elecstate(UnitCell& ucell)
{
delete this->pelec;
this->pelec = new elecstate::ElecState((Charge*)(&chr), this->pw_rho, pw_big);

this->pelec->charge->allocate(GlobalV::NSPIN);
if (this->pelec == nullptr)
{
this->pelec = new elecstate::ElecState((Charge*)(&chr), this->pw_rho, pw_big);
this->pelec->charge->allocate(GlobalV::NSPIN);
}
this->pelec->omega = ucell.omega;

delete this->pelec->pot;
Expand Down
8 changes: 4 additions & 4 deletions tests/integrate/907_OF_LPS/result.ref
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
etotref -55.9081453813626368
etotperatomref -55.9081453814
etotref -55.9081453850859873
etotperatomref -55.9081453851
totalforceref 0.000000
totalstressref 282.735417
totalstressref 282.762243
pointgroupref O_h
spacegroupref O_h
nksibzref 1
totaltimeref 0.54
totaltimeref 0.61

0 comments on commit c414c17

Please sign in to comment.