1#ifndef __TWOMETA_MODEL_NB_HPP__
2#define __TWOMETA_MODEL_NB_HPP__
4#include <common/traits.hpp>
5#include <mc/macros.hpp>
6#include <mc/prng/prng_extension.hpp>
7#include <mc/traits.hpp>
8#include <models/uptake_dyn.hpp>
9#include <models/utils.hpp>
24 age = INDEX_FROM_ENUM(Uptakeparticle_var::COUNT),
40 static constexpr std::string_view
name =
"two_mode_nb";
98 KOKKOS_INLINE_FUNCTION
static double
104 static std::vector<std::string_view>
107 return {
"age",
"length",
"nu1",
"nu2",
"nu_eff_1",
"nu_eff_2",
108 "a_p1",
"a_p2",
"a_p3",
"phi_o2",
"phi_g",
"phi_pts" };
111 static std::vector<std::size_t>
120 INDEX_FROM_ENUM(Uptakeparticle_var::ap_1),
121 INDEX_FROM_ENUM(Uptakeparticle_var::ap_2),
122 INDEX_FROM_ENUM(Uptakeparticle_var::ap_3),
128 static KOKKOS_INLINE_FUNCTION
void
131 Kokkos::printf(
"[Model]: PRENINIT:BEGIN\r\n");
147 KOKKOS_INLINE_FUNCTION
static void
154 KOKKOS_INLINE_FUNCTION
static void
156 std::size_t position,
164 KOKKOS_INLINE_FUNCTION
void
177 constexpr auto nu_1_initial_dist
179 mu_nu_dist, mu_nu_dist / 7., 0.,
static_cast<double>(
nu_max_kg_s));
181 auto gen = random_pool.get_state();
182 auto l = length_dist.draw(gen);
187 random_pool.free_state(gen);
208 const auto o = Kokkos::max(
static_cast<FloatType>(concentrations(1)), 0.F);
217 const auto s_1_star = (1.F /
y_sx_1 * nu_1_star);
219 const auto phi_s_residual_1_star = Kokkos::max(phi_s - s_1_star, 0.F);
220 KOKKOS_ASSERT(phi_s_residual_1_star >= 0.F);
222 const auto nu_2_star =
y_sx_2 * phi_s_residual_1_star;
229 nu_eff_1 = Kokkos::min(nu_1_star, nu_1);
232 const auto phi_s_residual_1 = Kokkos::max(phi_s - s_1, 0.F);
241 const auto s_overflow = phi_s - s_growth;
255 + (s_overflow > 0. ?
y_sa * (s_overflow) : 0);
258 nu_1 += d_t * ((nu_1_star - nu_1) /
tau_1);
260 nu_2 += d_t * ((nu_2_star - nu_2) /
tau_2);
272 KOKKOS_INLINE_FUNCTION
void
288 = new_current_length;
297 auto gen = random_pool.get_state();
300 = new_current_length + local_ac.draw(gen);
306 gen, nu_1_o, nu_1_o * half, 0.F, 1.F);
313 gen, nu_2_o, nu_2_o * half, 0.F, 1.F);
317 = new_current_length + local_ac.draw(gen);
318 random_pool.free_state(gen);
329 return { .begin = begin, .end = end };
Model that can export properties.
Definition traits.hpp:166
Kokkos::Subview< KernelConcentrationType, int, decltype(Kokkos::ALL)> LocalConcentration
Definition alias.hpp:95
decltype(Kokkos::Experimental::create_scatter_view( kernelContribution())) ContributionView
Definition alias.hpp:88
Status
Definition alias.hpp:58
@ Division
Definition alias.hpp:60
@ Idle
Definition alias.hpp:59
gen_pool_type< Kokkos::DefaultExecutionSpace > pool_type
Definition alias.hpp:39
Kokkos::View< F *[Nd], Kokkos::LayoutRight > ParticlesModel
Definition alias.hpp:19
constexpr T glucose
Definition utils.hpp:29
constexpr T dioxygen
Definition utils.hpp:30
Models definition.
Definition config_loader.hpp:9
KOKKOS_INLINE_FUNCTION consteval F c_linear_density(F rho, F d)
Definition utils.hpp:49
Represents a TruncatedNormal (Gaussian) probability distribution.
Definition prng_extension.hpp:354
static KOKKOS_INLINE_FUNCTION F draw_from(Kokkos::Random_XorShift1024< DeviceType > &gen, F mu, F sigma, F lower, F upper)
Definition prng_extension.hpp:380
static KOKKOS_INLINE_FUNCTION void init(const MC::pool_type &random_pool, std::size_t idx, const SelfParticle &arr)
Definition uptake_dyn.hpp:109
static KOKKOS_INLINE_FUNCTION FloatType uptake_step(FloatType phi_max, FloatType d_t, std::size_t idx, const SelfParticle &arr, const MC::LocalConcentration &c, FloatType *r_phi_pts=nullptr, FloatType *r_phi_perm=nullptr)
Definition uptake_dyn.hpp:175
static KOKKOS_INLINE_FUNCTION void division(const MC::pool_type &random_pool, std::size_t idx, std::size_t idx2, const SelfParticle &arr, const SelfParticle &buffer_arr)
Definition uptake_dyn.hpp:223