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

Implement override_cutoff_check property for vs. #4623

Merged
merged 2 commits into from
Dec 7, 2022
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
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