Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recalc cutoff on skin change #3003

4 changes: 2 additions & 2 deletions src/core/electrostatics_magnetostatics/coulomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ double cutoff(const Utils::Vector3d &box_l) {
switch (coulomb.method) {
case COULOMB_MMM1D:
return std::numeric_limits<double>::infinity();
case COULOMB_MMM2D:
return std::numeric_limits<double>::min();
#ifdef P3M
case COULOMB_ELC_P3M:
return std::max(elc_params.space_layer, p3m.params.r_cut_iL * box_l[0]);
case COULOMB_MMM2D:
return layer_h - skin;
case COULOMB_P3M_GPU:
case COULOMB_P3M:
/* do not use precalculated r_cut here, might not be set yet */
Expand Down
1 change: 1 addition & 0 deletions testsuite/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ python_test(FILE time_series.py MAX_NUM_PROC 1)
python_test(FILE linear_momentum.py)
python_test(FILE linear_momentum_lb.py MAX_NUM_PROC 2 LABELS gpu)
python_test(FILE mmm1d.py MAX_NUM_PROC 2 LABELS gpu)
python_test(FILE mmm2d_setup.py MAX_NUM_PROC 2)

if(PY_H5PY)
python_test(FILE h5md.py MAX_NUM_PROC 2)
Expand Down
51 changes: 51 additions & 0 deletions testsuite/python/mmm2d_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (C) 2010-2018 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest as ut
import unittest_decorators as utx
import espressomd
import espressomd.electrostatics


@utx.skipIfMissingFeatures(["ELECTROSTATICS"])
class MMM2D_setup(ut.TestCase):
system = espressomd.System(box_l=[10.0, 10.0, 10.0])
system.time_step = 0.01

def test_nonzero_maxcut(self):

self.system.cell_system.set_layered(
n_layers=20, use_verlet_lists=False)

self.system.periodicity = [1, 1, 0]

self.system.part.add(pos=(1.0, 1.0, 1.0), q=1)
self.system.part.add(pos=(9.0, 9.0, 9.0), q=-1)

# No interaction so far: max_cut == 0
self.assertTrue(self.system.cell_system.get_state()["max_cut"] == 0)

mmm2d = espressomd.electrostatics.MMM2D(prefactor=1.0, maxPWerror=1e-3)
self.system.actors.add(mmm2d)

# MMM2D alters max_cut to small eps
self.assertTrue(self.system.cell_system.get_state()["max_cut"] != 0)

# Test integration
self.system.integrator.run(0)

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