Skip to content

Commit

Permalink
Implement override_cutoff_check property for vs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkreissl committed Dec 7, 2022
1 parent 1970f48 commit bfb7657
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 bfb7657

Please sign in to comment.