24 int substance_id,
const std::string& substance_name,
real_t diffusion_coeff,
25 real_t decay_constant,
int resolution,
26 const std::vector<real_t>& binding_coefficients,
27 const std::vector<int>& binding_substances) {
29 auto* param = sim->GetParam();
30 auto* rm = sim->GetResourceManager();
32 if (decay_constant < 0.) {
33 Log::Fatal(
"ModelInitializer::DefineSubstance",
34 "The decay constant must be > 0 (", decay_constant,
").");
36 if (param->diffusion_method ==
"euler") {
37 if (!binding_substances.empty()) {
38 if (binding_coefficients.size() != binding_substances.size()) {
39 Log::Fatal(
"ModelInitializer::DefineSubstance",
40 "The binding coefficients and substances have different",
41 " sizes (", binding_coefficients.size(),
" vs ",
42 binding_substances.size(),
").");
44 for (
auto binding_coeff : binding_coefficients) {
45 if (binding_coeff < 0.) {
46 Log::Fatal(
"ModelInitializer::DefineSubstance",
47 "The binding coefficients must be > 0 (", binding_coeff,
53 substance_id, substance_name, diffusion_coeff, decay_constant,
54 resolution, binding_coefficients, binding_substances);
56 dgrid =
new EulerGrid(substance_id, substance_name, diffusion_coeff,
57 decay_constant, resolution);
60 Log::Error(
"ModelInitializer::DefineSubstance",
"Diffusion method '",
61 param->diffusion_method,
62 "' does not exist. Defaulting to 'euler'");
63 dgrid =
new EulerGrid(substance_id, substance_name, diffusion_coeff,
64 decay_constant, resolution);
67 rm->AddContinuum(dgrid);