Skip to content

Commit 71ca225

Browse files
committed
fix : init matrix in write_electric_pot function
1 parent ca42c57 commit 71ca225

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

source/src_io/write_pot.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,12 @@ void Potential::write_elecstat_pot(const std::string &fn, const std::string &fn_
268268
//==========================================
269269
for (int ir = 0;ir < GlobalC::pw.nrxx;ir++)
270270
{
271-
v_elecstat[ir] = Porter[ir].real() + this->vltot[ir] + v_efield(0, ir);
271+
v_elecstat[ir] = Porter[ir].real() + this->vltot[ir];
272+
273+
if (GlobalV::EFIELD && GlobalV::DIPOLE)
274+
{
275+
v_elecstat[ir] += v_efield(0, ir);
276+
}
272277
}
273278

274279
//-------------------------------------------

source/src_pw/forces.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ void Forces::init(ModuleBase::matrix& force)
7676
{
7777
force_e.create(GlobalC::ucell.nat, 3);
7878
Efield::compute_force(GlobalC::ucell, force_e);
79+
if(GlobalV::TEST_FORCE)
80+
{
81+
Forces::print("EFIELD FORCE (Ry/Bohr)", force_e);
82+
}
7983
}
8084

8185
//impose total force = 0

0 commit comments

Comments
 (0)