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

Fixed soft sphere cutoff calculation #2505

Merged
merged 4 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions maintainer/configs/maxset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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/nonbonded_interactions/nonbonded_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 @@ -303,8 +305,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 @@ -417,6 +419,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
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,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 @@ -474,6 +471,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 @@ -155,6 +155,7 @@ cdef extern from "nonbonded_interactions/nonbonded_interaction_data.hpp":
cdef IA_parameters * get_ia_param_safe(int i, int j)
cdef string ia_params_get_state()
cdef void ia_params_set_state(string)
cdef void reset_ia_params()

cdef extern from "bonded_interactions/bonded_interaction_data.hpp":
cdef void make_bond_type_exist(int type)
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 @@ -1820,6 +1820,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 @@ -476,7 +476,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