1 #ifndef SIMPT_DEFAULT_DELTA_HAMILTONIAN_DHELPER_H_INCLUDED
2 #define SIMPT_DEFAULT_DELTA_HAMILTONIAN_DHELPER_H_INCLUDED
35 namespace DeltaHamiltonian {
49 const std::array<double, 3>& old_axis,
const std::array<double, 3>& new_axis)
52 const auto old_a = Normalize(old_axis);
53 const auto new_a = Normalize(new_axis);
54 const array<double, 3> orth_alignment {{-1.0, 0.0, 0.0}};
55 const double alignment_old = InnerProduct(old_a, orth_alignment);
56 const double alignment_new = InnerProduct(new_a, orth_alignment);
58 return (alignment_old - alignment_new);
67 const array<double, 3>& nb1_p,
const array<double, 3>& nb2_p,
68 const array<double, 3>& now_p,
const array<double, 3>& mov_p)
70 auto t1 = Geom::CircumCircle(nb1_p[0], nb1_p[1], now_p[0], now_p[1], nb2_p[0], nb2_p[1]);
71 double const r1 = get<2>(t1);
72 auto t2 = Geom::CircumCircle(nb1_p[0], nb1_p[1], mov_p[0], mov_p[1], nb2_p[0], nb2_p[1]);
73 double const r2 = get<2>(t2);
74 assert(r1 > 0.0 && r2 > 0.0 &&
"Circumcenter radius singular!");
76 return pow((1.0 / r2 - 1.0 / r1), 2);
83 const Cell* cell,
Node* n,
const std::list<Wall*>& node_owning_walls,
double stiffness,
84 const std::array<double, 3>& nb1_p,
const std::array<double, 3>& nb2_p,
85 const std::array<double, 3>& now_p,
const std::array<double, 3>& mov_p)
88 for (
auto& wall : node_owning_walls) {
90 const auto& c1 = wall->GetC1();
91 const auto& c2 = wall->GetC2();
92 if (c1 == cell || c2 == cell) {
94 const bool check = (cell == c1 || cell->IsBoundaryPolygon());
95 const auto wall_beg = check ? wall->GetN1() : wall->GetN2();
96 const auto wall_end = check ? wall->GetN2() : wall->GetN1();
97 const auto stiff = (c1->IsBoundaryPolygon() || c2->IsBoundaryPolygon()) ? stiffness * wall->GetStrength() : 1.0 * wall->GetStrength();
98 const auto rest_l = wall->GetRestLength();
99 const auto old_l = wall->GetLength();
101 double new_l = old_l;
102 new_l += (n != wall_beg) ? Norm(mov_p - nb1_p) - Norm(now_p - nb1_p) : 0.0;
103 new_l += (n != wall_end) ? Norm(nb2_p - mov_p) - Norm(nb2_p - now_p) : 0.0;
104 contrib += stiff * (pow(new_l - rest_l, 2) - pow(old_l - rest_l, 2)) / (2.0 * rest_l);
114 #endif // end-of-include-guard
A cell contains walls and nodes.
Combo header for circular iterator.
Namespace for components of the Default model group.
Namespace for the core simulator.
Helper function for writing DeltaHamiltonians.
Extending std with arithmetic for std::array.
static double AlignmentTerm(const std::array< double, 3 > &old_axis, const std::array< double, 3 > &new_axis)
Alignment term.
static double ElasticWallTerm(const Cell *cell, Node *n, const std::list< Wall * > &node_owning_walls, double stiffness, const std::array< double, 3 > &nb1_p, const std::array< double, 3 > &nb2_p, const std::array< double, 3 > &now_p, const std::array< double, 3 > &mov_p)
Elastic wall term.
static double BendingTerm(const array< double, 3 > &nb1_p, const array< double, 3 > &nb2_p, const array< double, 3 > &now_p, const array< double, 3 > &mov_p)
Bending term.