Commit fe7d09f2 authored by ese ovie's avatar ese ovie Committed by Gauthier Quesnel
Browse files

examples: add qss1 seir model

parent 226818bd
......@@ -302,6 +302,230 @@ example_qss_negative_lif(simulation& sim, F f) noexcept
return status::success;
}
template<int QssLevel, typename F>
status
example_qss_seir_lineaire(simulation& sim, F f) noexcept
{
bool success = sim.can_alloc(10) && sim.can_connect(12);
irt_return_if_fail(success, status::simulation_not_enough_model);
auto& sum_a = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_a.default_input_coeffs[0] = -0.005;
sum_a.default_input_coeffs[1] = -0.4;
auto& sum_b = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_b.default_input_coeffs[0] = -0.135;
sum_b.default_input_coeffs[1] = 0.1;
auto& product_a = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_b = sim.alloc<abstract_multiplier<QssLevel>>();
auto& integrator_a = sim.alloc<abstract_integrator<QssLevel>>();
integrator_a.default_X = 10.0;
integrator_a.default_dQ = 0.01;
auto& integrator_b = sim.alloc<abstract_integrator<QssLevel>>();
integrator_b.default_X = 15.0;
integrator_b.default_dQ = 0.01;
auto& integrator_c = sim.alloc<abstract_integrator<QssLevel>>();
integrator_c.default_X = 10.0;
integrator_c.default_dQ = 0.01;
auto& integrator_d = sim.alloc<abstract_integrator<QssLevel>>();
integrator_d.default_X = 18.0;
integrator_d.default_dQ = 0.01;
auto& constant_a = sim.alloc<constant>();
constant_a.default_value = -0.005;
auto& constant_b = sim.alloc<constant>();
constant_b.default_value = -0.135;
sim.connect(constant_a, 0, product_a, 0);
sim.connect(constant_b, 0, product_b, 0);
sim.connect(sum_a, 0, integrator_c, 0);
sim.connect(sum_b, 0, integrator_d, 0);
sim.connect(integrator_b, 0, sum_a, 0);
sim.connect(integrator_c, 0, sum_a, 1);
sim.connect(integrator_c, 0, sum_b, 0);
sim.connect(integrator_d, 0, sum_b, 1);
sim.connect(integrator_a, 0, product_a, 1);
sim.connect(integrator_b, 0, product_b, 1);
sim.connect(product_a, 0, sum_a, 1);
sim.connect(product_b, 0, sum_b, 1);
f(sim.get_id(integrator_a));
f(sim.get_id(integrator_b));
f(sim.get_id(integrator_c));
f(sim.get_id(integrator_d));
f(sim.get_id(product_a));
f(sim.get_id(product_b));
f(sim.get_id(sum_a));
f(sim.get_id(sum_b));
f(sim.get_id(constant_a));
f(sim.get_id(constant_b));
return status::success;
}
template<int QssLevel, typename F>
status
example_qss_seir_nonlineaire(simulation& sim, F f) noexcept
{
bool success = sim.can_alloc(27) && sim.can_connect(32);
irt_return_if_fail(success, status::simulation_not_enough_model);
auto& sum_a = sim.alloc<abstract_wsum<QssLevel, 3>>();
sum_a.default_input_coeffs[0] = 0.5;
sum_a.default_input_coeffs[1] = 1.0;
sum_a.default_input_coeffs[2] = 1.0;
auto& sum_b = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_b.default_input_coeffs[0] = 1.0;
sum_b.default_input_coeffs[1] = 1.0;
auto& sum_c = sim.alloc<abstract_wsum<QssLevel, 3>>();
sum_c.default_input_coeffs[0] = 1.5;
sum_c.default_input_coeffs[1] = 0.698;
sum_c.default_input_coeffs[2] = 0.387;
auto& sum_d = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_d.default_input_coeffs[0] = 1.0;
sum_d.default_input_coeffs[1] = 1.5;
auto& product_a = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_b = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_c = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_d = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_e = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_f = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_g = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_h = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_i = sim.alloc<abstract_multiplier<QssLevel>>();
auto& integrator_a = sim.alloc<abstract_integrator<QssLevel>>();
integrator_a.default_X = 10.0;
integrator_a.default_dQ = 0.01;
auto& integrator_b = sim.alloc<abstract_integrator<QssLevel>>();
integrator_b.default_X = 12.0;
integrator_b.default_dQ = 0.01;
auto& integrator_c = sim.alloc<abstract_integrator<QssLevel>>();
integrator_c.default_X = 13.50;
integrator_c.default_dQ = 0.01;
auto& integrator_d = sim.alloc<abstract_integrator<QssLevel>>();
integrator_d.default_X = 15.0;
integrator_d.default_dQ = 0.01;
// The values used here are from Singh et al., 2017
auto& constant_a = sim.alloc<constant>();
constant_a.default_value = 0.005;
auto& constant_b = sim.alloc<constant>();
constant_b.default_value = -0.0057;
auto& constant_c = sim.alloc<constant>();
constant_c.default_value = -0.005;
auto& constant_d = sim.alloc<constant>();
constant_d.default_value = 0.0057;
auto& constant_e = sim.alloc<constant>();
constant_e.default_value = -0.135;
auto& constant_f = sim.alloc<constant>();
constant_f.default_value = 0.135;
auto& constant_g = sim.alloc<constant>();
constant_g.default_value = -0.072;
auto& constant_h = sim.alloc<constant>();
constant_h.default_value = 0.005;
auto& constant_i = sim.alloc<constant>();
constant_i.default_value = 0.067;
auto& constant_j = sim.alloc<constant>();
constant_j.default_value = -0.005;
sim.connect(constant_a, 0, sum_a, 0);
sim.connect(constant_h, 0, sum_c, 2);
sim.connect(constant_b, 0, product_a, 0);
sim.connect(constant_c, 0, product_b, 0);
sim.connect(constant_d, 0, product_c, 0);
sim.connect(constant_e, 0, product_d, 0);
sim.connect(constant_f, 0, product_e, 0);
sim.connect(constant_g, 0, product_f, 0);
sim.connect(constant_h, 0, product_g, 0);
sim.connect(constant_i, 0, product_h, 0);
sim.connect(product_i, 0, product_a, 1);
sim.connect(product_i, 0, product_c, 1);
sim.connect(sum_a, 0, integrator_a, 0);
sim.connect(sum_b, 0, integrator_b, 0);
sim.connect(sum_c, 0, integrator_c, 0);
sim.connect(sum_d, 0, integrator_d, 0);
sim.connect(product_a, 0, sum_a, 1);
sim.connect(product_b, 0, sum_a, 2);
sim.connect(product_c, 0, sum_b, 0);
sim.connect(product_d, 0, sum_b, 1);
sim.connect(product_e, 0, sum_c, 0);
sim.connect(product_f, 0, sum_c, 1);
sim.connect(product_g, 0, sum_d, 0);
sim.connect(product_h, 0, sum_d, 1);
sim.connect(integrator_a, 0, product_b, 1);
sim.connect(integrator_b, 0, product_d, 1);
sim.connect(integrator_b, 0, product_e, 1);
sim.connect(integrator_c, 0, product_f, 1);
sim.connect(integrator_c, 0, product_g, 1);
sim.connect(integrator_d, 0, product_h, 1);
sim.connect(integrator_a, 0, product_i, 0);
sim.connect(integrator_c, 0, product_i, 1);
f(sim.get_id(integrator_a));
f(sim.get_id(integrator_b));
f(sim.get_id(integrator_c));
f(sim.get_id(integrator_d));
f(sim.get_id(product_a));
f(sim.get_id(product_b));
f(sim.get_id(product_c));
f(sim.get_id(product_d));
f(sim.get_id(product_e));
f(sim.get_id(product_f));
f(sim.get_id(product_g));
f(sim.get_id(product_h));
f(sim.get_id(product_i));
f(sim.get_id(sum_a));
f(sim.get_id(sum_b));
f(sim.get_id(sum_c));
f(sim.get_id(sum_d));
f(sim.get_id(constant_a));
f(sim.get_id(constant_b));
f(sim.get_id(constant_c));
f(sim.get_id(constant_d));
f(sim.get_id(constant_e));
f(sim.get_id(constant_f));
f(sim.get_id(constant_g));
f(sim.get_id(constant_h));
f(sim.get_id(constant_i));
f(sim.get_id(constant_j));
return status::success;
}
} // namespace irritator
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment