1#ifndef __BIO__UTILS_HPP__
2#define __BIO__UTILS_HPP__
4#include "Kokkos_Macros.hpp"
5#include <Kokkos_Core.hpp>
6#include <Kokkos_MathematicalConstants.hpp>
7#include <Kokkos_Random.hpp>
8#include <common/traits.hpp>
10#include <mc/macros.hpp>
11#include <mc/prng/prng.hpp>
20 KOKKOS_INLINE_FUNCTION T
22 const std::size_t position_index,
23 const std::size_t species_index)
25 return static_cast<T
>(Kokkos::max(
26 static_cast<typename MC::LocalConcentration::non_const_value_type
>(0),
27 GET_CONCENTRATION(species_index)));
30#define GET_CLAMPED_CONCENTRATION_CAST(__T__, __species_index__) \
31 get_clamped_concentration_cast<__T__>(c, position_index, __species_index__)
33#define GET_CLAMPED_CONCENTRATION(__species_index__) \
34 get_clamped_concentration_cast<MC::LocalConcentration::const_value_type>( \
35 c, position_index, __species_index__)
44 template <FloatingPo
intType F>
47 F glucose_to_biomass_yield = 0.5)
50 return (dl * density) / glucose_to_biomass_yield;
53 template <FloatingPo
intType T>
54 KOKKOS_INLINE_FUNCTION Kokkos::pair<T, T>
57 const auto a1 = a * p;
58 const auto a2 = (
static_cast<T
>(1) - p) * a;
59 return Kokkos::pair(a1, a2);
62 template <FloatingPo
intType T>
74 template <FloatingPo
intType T>
constexpr T
glucose =
static_cast<T
>(180);
75 template <FloatingPo
intType T>
constexpr T
dioxygen =
static_cast<T
>(32);
76 template <FloatingPo
intType T>
constexpr T
acetate =
static_cast<T
>(59);
78 constexpr double co2 = 44;
89 [[deprecated]]
constexpr double X = 113.1e-3;
92 template <FloatingPo
intType F>
93 KOKKOS_INLINE_FUNCTION
consteval F
96 return rho * F(Kokkos::numbers::pi) * d * d / F(4.);
101 KOKKOS_INLINE_FUNCTION
bool
110 auto generator = random_pool.get_state();
111 const double x = generator.drand(0., 1.);
112 random_pool.free_state(generator);
119 KOKKOS_INLINE_FUNCTION
double
122 return (lenght <= threshold)
124 : (lenght - threshold) / (upper_bound - threshold);
127 KOKKOS_INLINE_FUNCTION
constexpr float
134 const auto z = x < xmax ? std::pow(x / (xmax - x), alpha) : 1.;
140 KOKKOS_INLINE_FUNCTION
bool
143 return Kokkos::abs(val - val2) < tolerance;
146 KOKKOS_INLINE_FUNCTION
constexpr bool
149 return (-tol < x) && (x < tol);
152 template <
typename... Args>
153 KOKKOS_INLINE_FUNCTION
double
156 return (Kokkos::min)({ args... });
159 KOKKOS_INLINE_FUNCTION
double
Status
Definition alias.hpp:125
@ Division
Definition alias.hpp:127
@ Idle
Definition alias.hpp:126
gen_pool_type< Kokkos::DefaultExecutionSpace > pool_type
Definition alias.hpp:100
KernelConcentrationType LocalConcentration
Definition alias.hpp:170
KOKKOS_INLINE_FUNCTION double threshold_linear(double lenght, double threshold, double upper_bound)
Definition utils.hpp:120
KOKKOS_INLINE_FUNCTION constexpr float logistic(float x, float xmax, float alpha)
Definition utils.hpp:128
constexpr T acetate
Definition utils.hpp:76
constexpr T glucose
Definition utils.hpp:74
constexpr T dioxygen
Definition utils.hpp:75
constexpr double co2
Definition utils.hpp:78
constexpr double acetate
Definition utils.hpp:85
constexpr double co2
Definition utils.hpp:87
constexpr double X
Definition utils.hpp:89
constexpr double glucose
Definition utils.hpp:82
constexpr double dioxygen
Definition utils.hpp:83
Models definition.
Definition config_loader.hpp:9
KOKKOS_INLINE_FUNCTION bool check_probability_division(double d_t, double gamma, MC::pool_type random_pool)
Definition utils.hpp:102
KOKKOS_INLINE_FUNCTION T get_clamped_concentration_cast(const MC::LocalConcentration &c, const std::size_t position_index, const std::size_t species_index)
Definition utils.hpp:21
KOKKOS_INLINE_FUNCTION Kokkos::pair< T, T > g_partition(T a, T p)
Definition utils.hpp:55
KOKKOS_INLINE_FUNCTION double min_var()
Definition utils.hpp:160
KOKKOS_INLINE_FUNCTION constexpr bool almost_zero(double x, double tol=1e-8)
Definition utils.hpp:147
KOKKOS_INLINE_FUNCTION MC::Status check_div(const T l, const T lc)
Definition utils.hpp:64
KOKKOS_INLINE_FUNCTION bool almost_equal(double val, double val2, double tolerance=1e-8)
Definition utils.hpp:141
static F consteval _get_phi_s_max(F density, F dl, F glucose_to_biomass_yield=0.5)
Definition utils.hpp:45
KOKKOS_INLINE_FUNCTION consteval F c_linear_density(F rho, F d)
Definition utils.hpp:94
static constexpr double tau_division_proba
Definition utils.hpp:99