diff --git a/src/core/pair_criteria/BondCriterion.hpp b/src/core/pair_criteria/BondCriterion.hpp index d1bd387a1c..aeab54e4c6 100644 --- a/src/core/pair_criteria/BondCriterion.hpp +++ b/src/core/pair_criteria/BondCriterion.hpp @@ -22,20 +22,31 @@ #include "pair_criteria/PairCriterion.hpp" #include "BondList.hpp" +#include "BoxGeometry.hpp" +#include "system/System.hpp" namespace PairCriteria { /** @brief True if a bond of given type exists between two particles. */ class BondCriterion : public PairCriterion { public: bool decide(Particle const &p1, Particle const &p2) const override { - return pair_bond_exists_on(p1.bonds(), p2.id(), m_bond_type) || - pair_bond_exists_on(p2.bonds(), p1.id(), m_bond_type); + + auto const &box_geo = *System::get_system().box_geo; + auto const d = box_geo.get_mi_vector(p1.pos(), p2.pos()).norm(); + + return (pair_bond_exists_on(p1.bonds(), p2.id(), m_bond_type) || + pair_bond_exists_on(p2.bonds(), p1.id(), m_bond_type)) && + d <= m_cut_off; } int get_bond_type() { return m_bond_type; } void set_bond_type(int t) { m_bond_type = t; } + double get_cut_off() { return m_cut_off; } + void set_cut_off(double c) { m_cut_off = c; } + private: int m_bond_type; + double m_cut_off; }; } // namespace PairCriteria diff --git a/src/core/pair_criteria/EnergyCriterion.hpp b/src/core/pair_criteria/EnergyCriterion.hpp index e81a59dd66..a98fb8c788 100644 --- a/src/core/pair_criteria/EnergyCriterion.hpp +++ b/src/core/pair_criteria/EnergyCriterion.hpp @@ -46,13 +46,16 @@ class EnergyCriterion : public PairCriterion { auto const energy = calc_non_bonded_pair_energy( p1, p2, ia_params, d, d.norm(), get_ptr(coulomb_kernel)); - return energy >= m_cut_off; + return energy >= e_cut_off && d.norm() <= m_cut_off; } double get_cut_off() { return m_cut_off; } void set_cut_off(double c) { m_cut_off = c; } + double get_e_cut_off() { return e_cut_off; } + void set_e_cut_off(double e) { e_cut_off = e; } + private: - double m_cut_off; + double m_cut_off, e_cut_off; System::System const &m_system; }; } // namespace PairCriteria diff --git a/src/core/pair_criteria/PairCriterion.hpp b/src/core/pair_criteria/PairCriterion.hpp index c5ac88bdf7..d2f575b992 100644 --- a/src/core/pair_criteria/PairCriterion.hpp +++ b/src/core/pair_criteria/PairCriterion.hpp @@ -41,6 +41,7 @@ class PairCriterion { const bool res = decide(p1, p2); return res; } + virtual ~PairCriterion() = default; }; } // namespace PairCriteria diff --git a/src/script_interface/pair_criteria/BondCriterion.hpp b/src/script_interface/pair_criteria/BondCriterion.hpp index b59e9303d5..f98289431b 100644 --- a/src/script_interface/pair_criteria/BondCriterion.hpp +++ b/src/script_interface/pair_criteria/BondCriterion.hpp @@ -40,7 +40,10 @@ class BondCriterion : public PairCriterion { add_parameters( {{"bond_type", [this](Variant const &v) { m_c->set_bond_type(get_value(v)); }, - [this]() { return m_c->get_bond_type(); }}}); + [this]() { return m_c->get_bond_type(); }}, + {"cut_off", + [this](Variant const &v2) { m_c->set_cut_off(get_value(v2)); }, + [this]() { return m_c->get_cut_off(); }}}); } std::shared_ptr<::PairCriteria::PairCriterion> diff --git a/src/script_interface/pair_criteria/EnergyCriterion.hpp b/src/script_interface/pair_criteria/EnergyCriterion.hpp index e5ec358270..8994d13ef8 100644 --- a/src/script_interface/pair_criteria/EnergyCriterion.hpp +++ b/src/script_interface/pair_criteria/EnergyCriterion.hpp @@ -41,9 +41,14 @@ class EnergyCriterion : public PairCriterion { : m_c(std::make_shared<::PairCriteria::EnergyCriterion>( ::System::get_system())) { add_parameters( - {{"cut_off", + {{"d_cut_off", [this](Variant const &v) { m_c->set_cut_off(get_value(v)); }, - [this]() { return m_c->get_cut_off(); }}}); + [this]() { return m_c->get_cut_off(); }}, + {"e_cut_off", + [this](Variant const &v2) { + m_c->set_e_cut_off(get_value(v2)); + }, + [this]() { return m_c->get_e_cut_off(); }}}); } std::shared_ptr<::PairCriteria::PairCriterion>