From 634fc7caf1e94c151e27e53a6c05c4bbc5106c4f Mon Sep 17 00:00:00 2001 From: capomav Date: Wed, 6 Dec 2023 02:53:20 +0100 Subject: [PATCH] addition of cutoff parameters to bond and energy criterion --- src/core/pair_criteria/BondCriterion.hpp | 13 +++++++++++-- src/core/pair_criteria/EnergyCriterion.hpp | 9 +++++++-- src/core/pair_criteria/PairCriterion.hpp | 2 ++ .../pair_criteria/BondCriterion.hpp | 5 ++++- .../pair_criteria/EnergyCriterion.hpp | 7 +++++-- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/core/pair_criteria/BondCriterion.hpp b/src/core/pair_criteria/BondCriterion.hpp index d1bd387a1c..b4a976384e 100644 --- a/src/core/pair_criteria/BondCriterion.hpp +++ b/src/core/pair_criteria/BondCriterion.hpp @@ -28,14 +28,23 @@ namespace PairCriteria { 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; + 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; } + int 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..5fc188f422 100644 --- a/src/core/pair_criteria/EnergyCriterion.hpp +++ b/src/core/pair_criteria/EnergyCriterion.hpp @@ -46,13 +46,18 @@ 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..c611c427ca 100644 --- a/src/core/pair_criteria/PairCriterion.hpp +++ b/src/core/pair_criteria/PairCriterion.hpp @@ -41,6 +41,8 @@ class PairCriterion { const bool res = decide(p1, p2); return res; } + + virtual double cutoff(Particle const &p1, Particle const &p2) const = 0; 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..bbb4e48dcd 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..99632c2b0c 100644 --- a/src/script_interface/pair_criteria/EnergyCriterion.hpp +++ b/src/script_interface/pair_criteria/EnergyCriterion.hpp @@ -41,9 +41,12 @@ 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>