Skip to content

Commit

Permalink
Implement override_cutoff_check property for vs. (#4623)
Browse files Browse the repository at this point in the history
Under specific circumstances one might have to override the cutoff check for virtual sites.

E.g. on `n>1` cores, when using the hybrid decomposition scheme to simulate a large virtual sites rigid object such as a large raspberry particle, the `min_global_cut` necessary to set up said object becomes quite large. Say the raspberry is surrounded by lots of small particles, e.g. a polymer suspension, which are put in the regular child decomposition of the `HybridDecomposition` cell system, the resulting minimum cell size of the regular cell decomposition is limited by this large `min_global_cut` -- even if the raspberry central particle resides in the N-square child decomposition, where it already interacts with all particles making the `min_global_cut` requirement superfluous. However, one forfeits the possible computational advantage of the hybrid decomposition.
  • Loading branch information
kodiakhq[bot] authored Dec 7, 2022
2 parents 2536505 + 8fbf4b6 commit 2e3acb3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/sphinx/particles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ Please note:
you need to set the system's :attr:`~espressomd.system.System.min_global_cut`
attribute to this largest distance.
An error is generated when this requirement is not met.
Under very specific circumstances it may be desirable to disable this check,
e.g. when using certain setups with the hybrid decomposition scheme.
You can do so by setting the virtual sites property ``override_cutoff_check = True``.
However, only consider this if you are absolutely sure of what you are doing.

- If the virtual sites represent actual particles carrying a mass, the
inertia tensor of the non-virtual particle in the center of mass
Expand Down
3 changes: 2 additions & 1 deletion src/core/virtual_sites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ calculate_vs_relate_to_params(Particle const &p_current,
// than minimum global cutoff. If so, warn user.
auto const dist = d.norm();
auto const min_global_cut = get_min_global_cut();
if (dist > min_global_cut && n_nodes > 1) {
if (dist > min_global_cut && n_nodes > 1 &&
not virtual_sites()->get_override_cutoff_check()) {
runtimeErrorMsg()
<< "Warning: The distance between virtual and non-virtual particle ("
<< dist << ") is larger than the minimum global cutoff ("
Expand Down
6 changes: 6 additions & 0 deletions src/core/virtual_sites/VirtualSites.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ class VirtualSites {
m_have_quaternion = have_quaternion;
}
bool have_quaternions() const { return m_have_quaternion; }
/** @brief Enable/disable override for the vs cutoff check */
void set_override_cutoff_check(const bool &override_cutoff_check) {
m_override_cutoff_check = override_cutoff_check;
}
bool get_override_cutoff_check() const { return m_override_cutoff_check; }

private:
bool m_have_quaternion = false;
bool m_override_cutoff_check = false;
};

#endif
Expand Down
7 changes: 6 additions & 1 deletion src/script_interface/virtual_sites/VirtualSites.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ class VirtualSites : public AutoParameters<VirtualSites> {
[this](const Variant &v) {
virtual_sites()->set_have_quaternion(get_value<bool>(v));
},
[this]() { return virtual_sites()->have_quaternions(); }}});
[this]() { return virtual_sites()->have_quaternions(); }},
{"override_cutoff_check",
[this](const Variant &v) {
virtual_sites()->set_override_cutoff_check(get_value<bool>(v));
},
[this]() { return virtual_sites()->get_override_cutoff_check(); }}});
}
/** Vs implementation we are wrapping */
virtual std::shared_ptr<::VirtualSites> virtual_sites() = 0;
Expand Down
3 changes: 3 additions & 0 deletions testsuite/python/virtual_sites_relative.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def test_vs_exceptions(self):
if system.cell_system.get_state()["n_nodes"] > 1:
with self.assertRaisesRegex(Exception, r"The distance between virtual and non-virtual particle \([0-9\.]+\) is larger than the minimum global cutoff"):
p2.vs_auto_relate_to(p1)
# If overridden this check should not raise an exception
system.virtual_sites.override_cutoff_check = True
p2.vs_auto_relate_to(p1)

def test_pos_vel_forces(self):
system = self.system
Expand Down

0 comments on commit 2e3acb3

Please sign in to comment.