1#ifndef __ACETATE_MODEL_HPP__
2#define __ACETATE_MODEL_HPP__
4#include "Kokkos_Assert.hpp"
5#include "Kokkos_Core_fwd.hpp"
6#include "Kokkos_Macros.hpp"
7#include "common/common.hpp"
8#include "common/traits.hpp"
9#include "mc/macros.hpp"
10#include "models/utils.hpp"
12#include <mc/prng/prng_extension.hpp>
13#include <mc/traits.hpp>
33 inline constexpr double m_o2 = 32.0;
47 e_surplus(
double m_cmol_sub,
double gamma_sub,
double y_x)
56 y_o2_ox(
double m_cmol_sub,
double gamma_sub,
double y_x)
63 y_ac_fer(
double m_cmol_sub,
double gamma_sub,
double y_x)
118 static constexpr std::string_view
name =
"acetate";
122 static constexpr std::size_t
n_c = 3;
202 "i_go: y_x too high, negative O2 or CO2");
206 "i_ao: y_x too high, negative O2 or CO2");
208 "i_fe: y_x too high, cannot grow and excrete as much acetate "
209 "as the pure overflow");
260 std::size_t position_index,
263 KOKKOS_INLINE_FUNCTION
static void
280 KOKKOS_INLINE_FUNCTION
static double
286 static std::array<std::string_view, Self::n_var>
290 "length",
"l_max",
"a_p",
"a_max",
"a_e",
"a_go",
291 "a_fe",
"a_ao",
"phi_s",
"phi_o2",
"phi_a",
295 static std::array<std::string_view, Self::n_c>
298 return {
"glucose",
"O2",
"acetate" };
304 KOKKOS_INLINE_FUNCTION
void
310 MODEL_CONSTANT
auto a_max_dist
314 static constexpr auto ld =
l_dist;
316 auto gen = random_pool.get_state();
321 random_pool.free_state(gen);
337 constexpr auto zero =
static_cast<FloatType>(0);
344 r[
i_go] = Kokkos::min(s_ox_max, nu_p /
y_x_go);
349 r[
i_ov] = Kokkos::max(s_ox_max - r[
i_go], zero);
355 r[
i_ao] = Kokkos::min(Kokkos::min(phi[
Ac], o2_res /
y_o2_ao),
356 Kokkos::max(nu_p - nu, zero) /
y_x_ao);
361 r[
i_fe] = Kokkos::min(s_res, Kokkos::max(nu_p - nu, zero) /
y_x_fe);
364 KOKKOS_ASSERT(r[
i_go] >= zero);
365 KOKKOS_ASSERT(r[
i_fe] >= zero);
366 KOKKOS_ASSERT(r[
i_ov] >= zero);
367 KOKKOS_ASSERT(r[
i_ao] >= zero);
368 KOKKOS_ASSERT(nu >= zero && nu <= nu_p *
static_cast<FloatType>(1.001));
386 const std::size_t position_index,
389 const auto c_s = GET_CLAMPED_CONCENTRATION_CAST(
FloatType,
S);
390 const auto c_o2 = GET_CLAMPED_CONCENTRATION_CAST(
FloatType,
O2);
391 const auto c_ac = GET_CLAMPED_CONCENTRATION_CAST(
FloatType,
Ac);
405 phi[
S] = phi_s_max_p * c_s / (c_s +
k_s);
406 phi[
O2] = Kokkos::min(phi_o2_max_p * c_o2 / (c_o2 +
k_o), share * c_o2);
407 phi[
Ac] = Kokkos::min(phi_ac_max_p * c_ac / (c_ac +
k_a), share * c_ac);
447 KOKKOS_INLINE_FUNCTION
void
455 ComputeSpace::array_layout,
456 Kokkos::MemoryTraits<Kokkos::MemoryTraitsFlags::Restrict>>
457 buffer_e = buffer_arr;
460 const FloatType new_current_length = current_l / 2.F;
464 for (
auto i = binf; i < bsup; ++i)
466 COPY_PROPERTY_TO(i, idx2, buffer_e);
486 auto gen = random_pool.get_state();
487 const double sigma = 0.2;
489 = Kokkos::log(
static_cast<double>(a_target)) - sigma * sigma / 2;
494 const auto gen1 = Kokkos::clamp(
495 static_cast<FloatType>(dist.draw(gen)), ap_min, a_max_i);
496 const auto gen2 = Kokkos::clamp(
497 static_cast<FloatType>(dist.draw(gen)), ap_min, a_max_i);
500 const FloatType lmax1 = local_l.draw(gen);
501 const FloatType lmax2 = local_l.draw(gen);
508 random_pool.free_state(gen);
Status
Definition alias.hpp:125
gen_pool_type< Kokkos::DefaultExecutionSpace > pool_type
Definition alias.hpp:100
KernelConcentrationType LocalConcentration
Definition alias.hpp:173
Kokkos::View< F *[Nc], ComputeSpace::array_layout, ComputeSpace, Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > > ParticlesContribs
Definition alias.hpp:66
Kokkos::View< F *[Nd], ComputeSpace::array_layout, ComputeSpace, Kokkos::MemoryTraits< Kokkos::MemoryTraitsFlags::Restrict > > ParticlesModel
Definition alias.hpp:52
Compile time elemental closure of the reactions of Models::Acetate.
Definition acetate.hpp:32
constexpr double e_surplus(double m_cmol_sub, double gamma_sub, double y_x)
Definition acetate.hpp:47
constexpr double gamma_biomass
4 + 1.8 - 1.0 - 0.6
Definition acetate.hpp:41
constexpr double m_o2
[g/mol]
Definition acetate.hpp:33
constexpr double y_o2_ox(double m_cmol_sub, double gamma_sub, double y_x)
Definition acetate.hpp:56
constexpr double m_cmol_biomass
CH1.8O0.5N0.2 [g/Cmol].
Definition acetate.hpp:36
constexpr double m_cmol_glucose
C6H12O6, 180/6 [g/Cmol].
Definition acetate.hpp:34
constexpr double m_cmol_acetate
C2H4O2, 60/2 [g/Cmol].
Definition acetate.hpp:35
constexpr double y_ac_fer(double m_cmol_sub, double gamma_sub, double y_x)
sub -> X + Ac + CO2 (+H2O) : gAc per g of substrate
Definition acetate.hpp:63
constexpr double gamma_acetate
(2*4 + 4 - 2*2)/2
Definition acetate.hpp:40
constexpr double gamma_glucose
Degree of reduction per C-mole.
Definition acetate.hpp:39
Models definition.
Definition acetate.hpp:18
KOKKOS_INLINE_FUNCTION MC::Status check_div(const T l, const T lc)
Definition utils.hpp:64
KOKKOS_INLINE_FUNCTION consteval F c_linear_density(F rho, F d)
Definition utils.hpp:94
Represents a LogNormal (Gaussian) probability distribution.
Definition prng_extension.hpp:525
Represents a TruncatedNormal (Gaussian) probability distribution.
Definition prng_extension.hpp:354
Acetate model with explicit oxygen limitation.
Definition acetate.hpp:91
Acetate Self
Definition acetate.hpp:93
species_index
Species indices, O2 has to stay at index 1 (gas/liquid transfer)
Definition acetate.hpp:135
@ O2
Definition acetate.hpp:137
@ Ac
Definition acetate.hpp:138
@ S
Definition acetate.hpp:136
@ N_N
Definition acetate.hpp:139
MODEL_CONSTANT FloatType k_s
Monod affinity constants [kg/m^3].
Definition acetate.hpp:163
MODEL_CONSTANT FloatType phi_s_max
Definition acetate.hpp:221
MODEL_CONSTANT FloatType f_pos
One explicit step removes at most 1/f_pos of the local concentration.
Definition acetate.hpp:228
MODEL_CONSTANT auto l_dist
Definition acetate.hpp:247
std::nullopt_t Config
Definition acetate.hpp:95
MODEL_CONSTANT FloatType x_c_max
Definition acetate.hpp:226
MODEL_CONSTANT FloatType y_x_go
gX/gS
Definition acetate.hpp:170
MODEL_CONSTANT FloatType d_t_floor
Only there so that d_t = 0 does not divide by zero.
Definition acetate.hpp:230
MODEL_CONSTANT FloatType l_max_m
Definition acetate.hpp:156
MC::ParticlesContribs< Self::n_c, Self::FloatType > SelfContribs
Definition acetate.hpp:124
static std::array< std::string_view, Self::n_var > names()
Definition acetate.hpp:287
MODEL_CONSTANT FloatType a_p_min
Definition acetate.hpp:235
MODEL_CONSTANT FloatType k_a
Definition acetate.hpp:166
MODEL_CONSTANT FloatType f_o2_max
Definition acetate.hpp:217
MC::ParticlesModel< Self::n_var, Self::FloatType > SelfParticle
Definition acetate.hpp:119
static std::array< std::string_view, Self::n_c > species()
Definition acetate.hpp:296
MODEL_CONSTANT FloatType y_x_ov
overflow does not grow
Definition acetate.hpp:172
MODEL_CONSTANT FloatType l_min_m
Definition acetate.hpp:157
MODEL_CONSTANT FloatType f_ac_max
Acetate uptake capacity relative to the glucose one.
Definition acetate.hpp:219
MODEL_CONSTANT FloatType k_o
Anane et. al 2017 (Biochem. Eng. J).
Definition acetate.hpp:165
Kokkos::Array< FloatType, N_N > uptake_rates
Definition acetate.hpp:153
MODEL_CONSTANT FloatType y_o2_ao
gO2/gAc
Definition acetate.hpp:181
MODEL_CONSTANT FloatType y_x_fe
gX/gS
Definition acetate.hpp:171
reaction_index
Reaction indices.
Definition acetate.hpp:144
@ N_R
Definition acetate.hpp:149
@ i_fe
Definition acetate.hpp:146
@ i_go
Definition acetate.hpp:145
@ i_ov
Definition acetate.hpp:147
@ i_ao
Definition acetate.hpp:148
static constexpr std::size_t n_var
Definition acetate.hpp:116
static KOKKOS_INLINE_FUNCTION MC::Status update(const MC::pool_type &random_pool, FloatType d_t, std::size_t idx, const SelfParticle &arr, const SelfContribs &arr_contribs, std::size_t position_index, const MC::LocalConcentration &c)
Definition acetate.hpp:381
MODEL_CONSTANT FloatType a_max_m
Definition acetate.hpp:155
particle_var
Definition acetate.hpp:98
@ phi_s
Definition acetate.hpp:109
@ length
Definition acetate.hpp:99
@ a_e
Definition acetate.hpp:104
@ phi_o2
Definition acetate.hpp:110
@ a_fe
Definition acetate.hpp:106
@ phi_a
Definition acetate.hpp:111
@ l_max
Definition acetate.hpp:100
@ __COUNT__
Definition acetate.hpp:112
@ a_go
Definition acetate.hpp:105
@ a_ao
Definition acetate.hpp:107
@ a_max
Definition acetate.hpp:102
@ a_p
Definition acetate.hpp:101
Kokkos::Array< FloatType, N_R > reaction_rates
Definition acetate.hpp:152
float FloatType
Definition acetate.hpp:94
MODEL_CONSTANT FloatType lin_density
Definition acetate.hpp:160
std::true_type uniform_weight
Definition acetate.hpp:92
static KOKKOS_INLINE_FUNCTION double mass(std::size_t idx, const SelfParticle &arr)
Definition acetate.hpp:281
MODEL_CONSTANT FloatType y_o2_go
gO2/gS, 0.384
Definition acetate.hpp:176
MODEL_CONSTANT FloatType a_p_recovery
Definition acetate.hpp:241
static constexpr std::size_t n_c
Liquid species: glucose, dioxygen, acetate.
Definition acetate.hpp:122
MODEL_CONSTANT auto l_max_dist
Definition acetate.hpp:244
static constexpr std::string_view name
Definition acetate.hpp:118
MODEL_CONSTANT FloatType d_m
Definition acetate.hpp:158
static KOKKOS_INLINE_FUNCTION void init(const MC::pool_type &random_pool, std::size_t idx, const SelfParticle &arr)
Definition acetate.hpp:305
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 acetate.hpp:448
static KOKKOS_INLINE_FUNCTION reaction_rates metabolism(const uptake_rates &phi, FloatType nu_p, FloatType &nu)
Distribute the available uptake fluxes over the four reactions.
Definition acetate.hpp:333
MODEL_CONSTANT FloatType y_ac_fe
gAc/gS produced by fermentation, 0.808
Definition acetate.hpp:187
MODEL_CONSTANT FloatType y_ac_ov
gAc/gS produced by overflow. C6H12O6 -> 3 C2H4O2 balances as is, so 1
Definition acetate.hpp:192
MODEL_CONSTANT FloatType y_x_ao
gX/gAc
Definition acetate.hpp:173