BioCMAMC-ST
simple_model.hpp
1
// #ifndef __SIMPLE_MODEL_HPP__
2
// #define __SIMPLE_MODEL_HPP__
3
4
// #include "common/traits.hpp"
5
// #include "models/uptake_dyn.hpp"
6
// #include "models/utils.hpp"
7
// #include <mc/prng/prng_extension.hpp>
8
// #include <mc/traits.hpp>
9
// #include <models/uptake.hpp>
10
// #include <optional>
11
// #include <string_view>
12
13
// namespace Models
14
// {
15
// template <FloatingPointType F>
16
// static F consteval get_phi_s_max(F density, F dl)
17
// {
18
// // dl and density must be same unit, dl*density -> mass and y is mass
19
// yield return (dl * density) * 0.5;
20
// }
21
// struct SimpleModel
22
// {
23
// using uniform_weight = std::true_type; // Using type alias
24
// using Self = SimpleModel;
25
// using FloatType = float;
26
// using Config = std::nullopt_t;
27
28
// enum class particle_var : int
29
// {
30
// length = INDEX_FROM_ENUM(Uptakeparticle_var::COUNT),
31
// age,
32
// phi_s,
33
// t_div,
34
// COUNT
35
// };
36
37
// static constexpr std::size_t n_var =
38
// INDEX_FROM_ENUM(particle_var::COUNT); static constexpr std::string_view
39
// name = "simple"; using SelfParticle = MC::ParticlesModel<Self::n_var,
40
// Self::FloatType>;
41
42
// MODEL_CONSTANT FloatType l_max_m = 5e-6; // m
43
// MODEL_CONSTANT FloatType l_c_m = 3e-6; // m
44
// MODEL_CONSTANT FloatType d_m = 0.6e-6; // m
45
// MODEL_CONSTANT FloatType l_min_m = 0.9e-6; // m
46
// MODEL_CONSTANT FloatType lin_density
47
// = c_linear_density(static_cast<FloatType>(1000), d_m);
48
49
// MODEL_CONSTANT FloatType phi_s_max
50
// = get_phi_s_max<FloatType>(lin_density, 8 * 2e-10); // kgS/s
51
52
// MODEL_CONSTANT FloatType phi_perm_max = phi_s_max / 40.; // kgS/
53
54
// MODEL_CONSTANT FloatType frequency_division = 1. / 1000; // Hz
55
56
// KOKKOS_INLINE_FUNCTION static void init(const MC::pool_type& random_pool,
57
// std::size_t idx,
58
// const SelfParticle& arr);
59
60
// KOKKOS_INLINE_FUNCTION static MC::Status
61
// update(const MC::pool_type& random_pool,
62
// FloatType d_t,
63
// std::size_t idx,
64
// const SelfParticle& arr,
65
// const MC::LocalConcentration& c);
66
67
// KOKKOS_INLINE_FUNCTION static void
68
// division(const MC::pool_type& random_pool,
69
// std::size_t idx,
70
// std::size_t idx2,
71
// const SelfParticle& arr,
72
// const SelfParticle& buffer_arr);
73
74
// KOKKOS_INLINE_FUNCTION static void
75
// contribution(std::size_t idx,
76
// std::size_t position,
77
// double weight,
78
// const SelfParticle& arr,
79
// const MC::ContributionView& contributions);
80
81
// KOKKOS_INLINE_FUNCTION static double
82
// mass(std::size_t idx, const SelfParticle& arr)
83
// {
84
// return GET_PROPERTY(SimpleModel::particle_var::length) * lin_density;
85
// }
86
87
// // inline constexpr static std::array<std::string_view, n_var> names()
88
// // {
89
// // constexpr std::size_t ln_var = n_var - Uptake<SimpleModel>::n_var;
90
// // constexpr auto _names = concat_arrays<Uptake<SimpleModel>::n_var,
91
// // ln_var>(
92
// // Uptake<SimpleModel>::names(), {"length", "age", "phi_s",
93
// "t_div"});
94
95
// // return _names;
96
// // }
97
// };
98
99
// CHECK_MODEL(SimpleModel)
100
101
// KOKKOS_INLINE_FUNCTION void
102
// SimpleModel::init([[maybe_unused]] const MC::pool_type& random_pool,
103
// std::size_t idx,
104
// const SelfParticle& arr)
105
// {
106
// MODEL_CONSTANT auto division_time_d
107
// = MC::Distributions::TruncatedNormal<FloatType>(
108
// 500,
109
// 500. / 2.,
110
// 10,
111
// 1200); //-Kokkos::log(random_number) / frequency_division;
112
// MODEL_CONSTANT auto l_distribution
113
// = MC::Distributions::TruncatedNormal<FloatType>(
114
// l_min_m, l_min_m / 5., l_min_m * 0.5, l_max_m);
115
// auto gen = random_pool.get_state();
116
// arr(idx, static_cast<int>(particle_var::length)) =
117
// l_distribution.draw(gen); GET_PROPERTY(SimpleModel::particle_var::t_div)
118
// = division_time_d.draw(gen); random_pool.free_state(gen); arr(idx,
119
// static_cast<int>(particle_var::age)) = 0; arr(idx,
120
// static_cast<int>(particle_var::phi_s)) = 0;
121
122
// Uptake<UptakeDefault<typename Self::FloatType>, SimpleModel>::init(
123
// random_pool, idx, arr);
124
// }
125
126
// KOKKOS_INLINE_FUNCTION MC::Status
127
// SimpleModel::update([[maybe_unused]] const MC::pool_type& random_pool,
128
// FloatType d_t,
129
// std::size_t idx,
130
// const SelfParticle& arr,
131
// const MC::LocalConcentration& c)
132
// {
133
134
// const auto phi_s
135
// = Uptake<UptakeDefault<typename Self::FloatType>,
136
// SimpleModel>::uptake_step(phi_s_max, d_t, idx, arr, c);
137
138
// GET_PROPERTY(SimpleModel::particle_var::age) += d_t;
139
// GET_PROPERTY(SimpleModel::particle_var::phi_s) = phi_s;
140
141
// return (GET_PROPERTY(SimpleModel::particle_var::t_div)
142
// <= GET_PROPERTY(SimpleModel::particle_var::age))
143
// ? MC::Status::Division
144
// : MC::Status::Idle;
145
// }
146
147
// KOKKOS_INLINE_FUNCTION void
148
// SimpleModel::division(const MC::pool_type& random_pool,
149
// std::size_t idx,
150
// std::size_t idx2,
151
// const SelfParticle& arr,
152
// const SelfParticle& buffer_arr)
153
// {
154
155
// const FloatType new_current_length
156
// = arr(idx, static_cast<int>(particle_var::length))
157
// / static_cast<FloatType>(2.);
158
// buffer_arr(idx2, static_cast<int>(particle_var::length))
159
// = new_current_length;
160
// arr(idx, static_cast<int>(particle_var::length)) = new_current_length;
161
162
// arr(idx, static_cast<int>(particle_var::age)) = 0;
163
// buffer_arr(idx2, static_cast<int>(particle_var::age)) = 0;
164
165
// // auto gen = random_pool.get_state();
166
// // GET_PROPERTY_FROM(idx2, buffer_arr, SimpleModel::particle_var::t_div)
167
// =
168
// // division_time_d.draw(gen);
169
// // GET_PROPERTY(SimpleModel::particle_var::t_div) =
170
// // division_time_d.draw(gen); random_pool.free_state(gen);
171
172
// Uptake<UptakeDefault<typename Self::FloatType>, SimpleModel>::division(
173
// random_pool, idx, idx2, arr, buffer_arr);
174
// }
175
176
// KOKKOS_INLINE_FUNCTION void
177
// SimpleModel::contribution([[maybe_unused]] std::size_t idx,
178
// std::size_t position,
179
// double weight,
180
// [[maybe_unused]] const SelfParticle& arr,
181
// const MC::ContributionView& contributions)
182
// {
183
// auto access = contributions.access();
184
// access(position, 0)
185
// += -weight * GET_PROPERTY(SimpleModel::particle_var::phi_s); //
186
// NOLINT
187
// }
188
189
// } // namespace Models
190
191
// #endif
apps
libs
models
public
models
simple_model.hpp
Generated by
1.14.0