1#ifndef FLIPPY_SIM_UTILS_H
2#define FLIPPY_SIM_UTILS_H
11 [[maybe_unused]] [[nodiscard]]
static Real sphere_vol(Real R){
return (4._r/3._r)* PI *R*R*R;}
12 [[maybe_unused]] [[nodiscard]]
static Real sphere_area(Real R){
return 4._r * PI *R*R;}
14 [[maybe_unused]] [[nodiscard]]
static Real linear_adaptation(Real x, Real x_init, Real x_fin,
15 Real val_init, Real val_fin)
17 if (x <= x_init) {
return val_init; }
18 if (x > x_fin) {
return val_fin; }
20 return val_init + (val_fin-val_init)/(x_fin-x_init)*(x-x_init);
23 [[maybe_unused]] [[nodiscard]]
static Index steps_for_fixed_speed_adaptation(Real x_init, Real val_init, Real val_fin, Real delta_val)
25 return static_cast<Index
>(std::ceil((val_fin-val_init)/delta_val + x_init));
30 Real l_min = min_allowed_distance_between_bead_centers;
31 Real n =
static_cast<Real
>(sub_triangulation_iteration_count);
33 return l_min / (2_r * std::sin(std::asin(1_r / (2_r * std::sin(2_r * PI / 5_r ))) / (n + 1_r)));
40 Real p_accum_{
static_cast<Real
>(0.f)};
41 Real p_count_{
static_cast<Real
>(1.f)};
43 Real prob(std::optional<Real> e_diff, Real kBT){
return (e_diff.has_value()?std::min(std::exp(e_diff.value()/kBT),1_r):0_r); }
47 : d0_(initial_displacement), delta_d_(displacement_adaptation_step_size), p_target_(p_target) { }
49 Real new_displacement_magnitude(){
50 Real p = p_accum_/p_count_;
51 p_accum_ =
static_cast<Real
>(0.f);
52 p_count_ =
static_cast<Real
>(1.f);
53 Real dp = p - p_target_;
54 d0_ = d0_ + 0.5f*dp*delta_d_*d0_;
58 std::uniform_real_distribution<Real> new_displ_distr(){
59 Real linear_displ = new_displacement_magnitude();
60 return std::uniform_real_distribution<Real>(-linear_displ, linear_displ);
63 void probability_aggregator(std::optional<Real> e_diff, Real kBt){
64 p_accum_ += prob(e_diff, kBt);
65 p_count_ +=
static_cast<Real
>(1.);
68 void reset_target_acceptance_probability(Real p_target){ p_target_ = p_target; }
69 [[nodiscard]] Real target_acceptance_probability()
const {
return p_target_; }
107 const Real A = node.
area;
108 const Real e =
static_cast<Real
>(0.5)*A*K.
norm_square();
113 [[maybe_unused]] [[nodiscard]]
static Real changed_neighborhood_bending_energy(Node
const& node,
115 std::vector<Index>
const& changed_neighborhood) {
125 [[maybe_unused]]
static Real cot_between_vectors(vec3<Real>
const& v1, vec3<Real>
const& v2)
127 return v1.dot(v2)/(v1.cross(v2).norm());
This file contains the fp::Node and fp::Nodes classes, data structures that represent a single node o...
Definition sim_utils.hpp:36
Internal implementation of a 3D vector.
Definition vec3.hpp:43
Real norm_square() const
Returns the square of the norm of the vector.
Definition vec3.hpp:175
This file contains the concepts that are costomly defined for the flippy class templates.
Definition custom_concepts.hpp:8
static Real min_radius_with_non_overlapping_beads(Real min_allowed_distance_between_bead_centers, Index sub_triangulation_iteration_count)
N_node=12+30*n+20*n*(n-1)/2 where n is the same as sub_triangulation_iteration_count.
Definition sim_utils.hpp:29
static Real node_curvature_squared(Node const &node)
Definition sim_utils.hpp:74
static Real node_unit_bending_energy(Node const &node)
Definition sim_utils.hpp:93
A data structure containing all geometric and topological information associated with a node.
Definition Nodes.hpp:30
Real area
Voronoi area associated with the node.
Definition Nodes.hpp:45
vec3< Real > curvature_vec
Curvature vector of the node.
Definition Nodes.hpp:71
Data structure containing all nodes of the Triangulation.
Definition Nodes.hpp:225
Header file containing the definition and implementation a 3 dimensional vector class,...