Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addition of cutoff parameters to bond and energy criterion
Browse files Browse the repository at this point in the history
capomav committed Dec 6, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 38a5338 commit 634fc7c
Showing 5 changed files with 29 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/core/pair_criteria/BondCriterion.hpp
Original file line number Diff line number Diff line change
@@ -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

9 changes: 7 additions & 2 deletions src/core/pair_criteria/EnergyCriterion.hpp
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/core/pair_criteria/PairCriterion.hpp
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion src/script_interface/pair_criteria/BondCriterion.hpp
Original file line number Diff line number Diff line change
@@ -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>
7 changes: 5 additions & 2 deletions src/script_interface/pair_criteria/EnergyCriterion.hpp
Original file line number Diff line number Diff line change
@@ -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<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>

0 comments on commit 634fc7c

Please sign in to comment.