1#ifndef __BIO__UTILS_HPP__
2#define __BIO__UTILS_HPP__
4#include "Kokkos_MathematicalConstants.hpp"
5#include "common/traits.hpp"
6#include <Kokkos_Core.hpp>
7#include <Kokkos_Random.hpp>
8#include <mc/prng/prng.hpp>
21 template <FloatingPo
intType T>
constexpr T
glucose =
static_cast<T
>(180);
22 template <FloatingPo
intType T>
constexpr T
dioxygen =
static_cast<T
>(32);
23 template <FloatingPo
intType T>
constexpr T
acetate =
static_cast<T
>(59);
25 constexpr double co2 = 44;
36 [[deprecated]]
constexpr double X = 113.1e-3;
39 template <FloatingPo
intType F> KOKKOS_INLINE_FUNCTION
consteval F
c_linear_density(F rho, F d)
41 return rho * F(Kokkos::numbers::pi) * d * d / F(4.);
46 KOKKOS_INLINE_FUNCTION
bool
53 auto generator = random_pool.get_state();
54 const double x = generator.drand(0., 1.);
55 random_pool.free_state(generator);
60 namespace GammaDivision
62 KOKKOS_INLINE_FUNCTION
double
65 return (lenght <= threshold) ? 0 : (lenght - threshold) / (upper_bound - threshold);
68 KOKKOS_INLINE_FUNCTION
constexpr float logistic(
float x,
float xmax,
float alpha)
75 const auto z = x < xmax ? std::pow(x / (xmax - x), alpha) : 1.;
81 KOKKOS_INLINE_FUNCTION
bool almost_equal(
double val,
double val2,
double tolerance = 1e-8)
83 return Kokkos::abs(val - val2) < tolerance;
86 template <
typename... Args> KOKKOS_INLINE_FUNCTION
double min_var(Args... args)
88 return (Kokkos::min)({args...});
90 template <> KOKKOS_INLINE_FUNCTION
double min_var()
Kokkos::Random_XorShift1024_Pool< Kokkos::DefaultExecutionSpace > pool_type
Definition prng.hpp:17
KOKKOS_INLINE_FUNCTION double threshold_linear(double lenght, double threshold, double upper_bound)
Definition utils.hpp:63
KOKKOS_INLINE_FUNCTION constexpr float logistic(float x, float xmax, float alpha)
Definition utils.hpp:68
constexpr T acetate
Definition utils.hpp:23
constexpr T glucose
Definition utils.hpp:21
constexpr T dioxygen
Definition utils.hpp:22
constexpr double co2
Definition utils.hpp:25
constexpr double acetate
Definition utils.hpp:32
constexpr double co2
Definition utils.hpp:34
constexpr double X
Definition utils.hpp:36
constexpr double glucose
Definition utils.hpp:29
constexpr double dioxygen
Definition utils.hpp:30
Models definition.
Definition simple_model.hpp:12
KOKKOS_INLINE_FUNCTION bool check_probability_division(double d_t, double gamma, MC::KPRNG::pool_type random_pool)
Definition utils.hpp:47
KOKKOS_INLINE_FUNCTION double min_var()
Definition utils.hpp:90
KOKKOS_INLINE_FUNCTION bool almost_equal(double val, double val2, double tolerance=1e-8)
Definition utils.hpp:81
KOKKOS_INLINE_FUNCTION consteval F c_linear_density(F rho, F d)
Definition utils.hpp:39
static constexpr double tau_division_proba
Definition utils.hpp:44