Skip to content

Commit

Permalink
Merge pull request espressomd#2505 from fweik/wca
Browse files Browse the repository at this point in the history
Fixed soft sphere cutoff calculation
  • Loading branch information
fweik authored and RudolfWeeber committed Mar 12, 2019
1 parent 463ef46 commit 14c0c18
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions maintainer/configs/maxset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define SOFT_SPHERE
#define INTER_RF
#define OVERLAPPED
#define WCA

#ifdef P3M
#define THOLE
Expand Down
11 changes: 9 additions & 2 deletions src/core/interaction_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@
#include <boost/archive/binary_oarchive.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/range/algorithm/fill.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>

#include <cstdlib>
#include <cstring>

Expand Down Expand Up @@ -375,8 +377,8 @@ static void recalc_maximal_cutoff_nonbonded() {
#endif

#ifdef SOFT_SPHERE
if (max_cut_current < data->soft_cut)
max_cut_current = data->soft_cut;
if (max_cut_current < (data->soft_cut + data->soft_offset))
max_cut_current = (data->soft_cut + data->soft_offset);
#endif

#ifdef AFFINITY
Expand Down Expand Up @@ -484,6 +486,11 @@ void realloc_ia_params(int nsize) {
std::swap(ia_params, new_params);
}

void reset_ia_params() {
boost::fill(ia_params, IA_parameters{});
mpi_bcast_all_ia_params();
}

bool is_new_particle_type(int type) {
if ((type + 1) <= max_seen_particle_type)
return false;
Expand Down
8 changes: 5 additions & 3 deletions src/core/interaction_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,6 @@ extern double dipolar_cutoff;
(through ghosts). */
extern double min_global_cut;

/** Switch for nonbonded interaction exclusion */
extern int ia_excl;

/************************************************
* exported functions
************************************************/
Expand Down Expand Up @@ -826,6 +823,11 @@ void realloc_ia_params(int nsize);
value is used in the verlet pair list algorithm. */
void recalc_maximal_cutoff();

/**
* @brief Reset all interaction parameters to their defaults.
*/
void reset_ia_params();

/** check whether all force calculation routines are properly initialized. */
int interactions_sanity_checks();

Expand Down
1 change: 1 addition & 0 deletions src/python/espressomd/interactions.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ cdef extern from "interaction_data.hpp":
cdef void make_bond_type_exist(int type)
cdef string ia_params_get_state()
cdef void ia_params_set_state(string)
cdef void reset_ia_params()

cdef extern from "lj.hpp":
cdef int lennard_jones_set_params(int part_type_a, int part_type_b,
Expand Down
7 changes: 7 additions & 0 deletions src/python/espressomd/interactions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,13 @@ cdef class NonBondedInteractions(object):
cdef string state = core_state
ia_params_set_state(state)

def reset(self):
"""
Reset all interaction parameters to their default
values.
"""

reset_ia_params()

cdef class BondedInteraction(object):
"""Base class for bonded interactions.
Expand Down
3 changes: 1 addition & 2 deletions testsuite/python/interactions_non-bonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def setUp(self):
self.system.part.add(id=1, pos=self.start_pos, type=0)

def tearDown(self):

self.system.non_bonded_inter.reset()
self.system.part.clear()

# Required, since assertAlmostEqual does NOT check significant places
Expand Down Expand Up @@ -436,7 +436,6 @@ def test_buckingham(self):
@ut.skipIf(not espressomd.has_features("SOFT_SPHERE"),
"Features not available, skipping test!")
def test_soft_sphere(self):

ss_a = 1.92
ss_n = 3.03
ss_cut = 1.123
Expand Down

0 comments on commit 14c0c18

Please sign in to comment.