Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslandsgesell committed Jun 13, 2019
1 parent 72708fb commit 0f63a4a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
11 changes: 11 additions & 0 deletions src/core/actor/Mmm1dgpuForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "EspressoSystemInterface.hpp"
#include "communication.hpp"
#include "forces.hpp"
#include "energy.hpp"
#include "grid.hpp"

#ifdef MMM1D_GPU
Expand All @@ -30,4 +31,14 @@ void Mmm1dgpuForce::check_periodicity() {
}
}

void Mmm1dgpuForce::activate(){
forceActors.push_back(this);
energyActors.push_back(this);
}

void Mmm1dgpuForce::deactivate(){
forceActors.remove(this);
energyActors.remove(this);
}

#endif
2 changes: 2 additions & 0 deletions src/core/actor/Mmm1dgpuForce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Mmm1dgpuForce : public Actor {
void set_params(mmm1dgpu_real _boxz, mmm1dgpu_real _coulomb_prefactor,
mmm1dgpu_real _maxPWerror, mmm1dgpu_real _far_switch_radius,
int _bessel_cutoff, bool manual = false);
void activate();
void deactivate();

private:
// CUDA parameters
Expand Down
3 changes: 3 additions & 0 deletions src/python/espressomd/electrostatics.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,6 @@ IF ELECTROSTATICS and MMM1D_GPU:
float force_benchmark(SystemInterface & s);

void check_periodicity();
void activate();
void deactivate();

4 changes: 4 additions & 0 deletions src/python/espressomd/electrostatics.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ IF ELECTROSTATICS and MMM1D_GPU:
self.thisptr = new Mmm1dgpuForce(dereference(self.interface), 0.0, default_params["maxPWerror"])
self.interface.update()
self.interface.requestRGpu()
dereference(self.thisptr).activate()

def __dealloc__(self):
del self.thisptr
Expand Down Expand Up @@ -633,6 +634,9 @@ IF ELECTROSTATICS and MMM1D_GPU:
if self._params["tune"]:
self._tune()
self._set_params_in_es_core()

def _deactivate_method(self):
dereference(self.thisptr).deactivate()

IF ELECTROSTATICS:
cdef class MMM2D(ElectrostaticInteraction):
Expand Down
20 changes: 3 additions & 17 deletions testsuite/python/mmm1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ class ElectrostaticInteractionsTests(object):
allowed_error = 1e-4

def setUp(self):
mmm1d = self.MMM1D(prefactor=1.0, maxPWerror=1e-20)
for i in range(self.num_particles):
self.system.part.add(
pos=[self.pos_x_target[i],
self.pos_y_target[i],
self.pos_z_target[i]],
q=self.q_target[i])
self.system.actors.add(self.mmm1d)
self.system.actors.add(mmm1d)
self.system.integrator.run(steps=0)

def tearDown(self):
Expand Down Expand Up @@ -106,26 +107,11 @@ def test_with_analytical_result(self):

@utx.skipIfMissingFeatures(["ELECTROSTATICS", "PARTIAL_PERIODIC", "MMM1D_GPU"])
class MMM1D_GPU_Test(ElectrostaticInteractionsTests, ut.TestCase):
from espressomd.electrostatics import MMM1DGPU
# mmm1d = MMM1DGPU(
# prefactor=1.0,
# maxPWerror=1e-4,
# far_switch_radius=6,
# bessel_cutoff=3,
# tune=False)
mmm1d = MMM1DGPU(prefactor=1.0, maxPWerror=1e-20)

from espressomd.electrostatics import MMM1D

@utx.skipIfMissingFeatures(["ELECTROSTATICS", "PARTIAL_PERIODIC"])
class MMM1D_Test(ElectrostaticInteractionsTests, ut.TestCase):
from espressomd.electrostatics import MMM1D
# mmm1d = MMM1D(
# prefactor=1.0,
# maxPWerror=1e-4,
# far_switch_radius=6,
# bessel_cutoff=3,
# tune=False)
mmm1d = MMM1D(prefactor=1, maxPWerror=1e-20)

if __name__ == "__main__":
ut.main()

0 comments on commit 0f63a4a

Please sign in to comment.