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

WIP - Cluster Analysis #4840

Open
wants to merge 5 commits into
base: python
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions src/core/pair_criteria/BondCriterion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions src/core/pair_criteria/EnergyCriterion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/core/pair_criteria/PairCriterion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class PairCriterion {
const bool res = decide(p1, p2);
return res;
}

virtual ~PairCriterion() = default;
};
} // namespace PairCriteria
Expand Down
5 changes: 4 additions & 1 deletion src/script_interface/pair_criteria/BondCriterion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class BondCriterion : public PairCriterion {
add_parameters(
{{"bond_type",
[this](Variant const &v) { m_c->set_bond_type(get_value<int>(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<int>(v2)); },
[this]() { return m_c->get_cut_off(); }}});
}

std::shared_ptr<::PairCriteria::PairCriterion>
Expand Down
9 changes: 7 additions & 2 deletions src/script_interface/pair_criteria/EnergyCriterion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(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<double>(v2));
},
[this]() { return m_c->get_e_cut_off(); }}});
}

std::shared_ptr<::PairCriteria::PairCriterion>
Expand Down
Loading