-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbiocro_simulation.h
More file actions
71 lines (64 loc) · 2.33 KB
/
biocro_simulation.h
File metadata and controls
71 lines (64 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef BIOCRO_SIMULATION_H
#define BIOCRO_SIMULATION_H
#include <memory> // for unique_ptr, shared_ptr
#include "state_map.h" // for state_map, state_vector_map
#include "module_creator.h" // for mc_vector
#include "dynamical_system.h"
#include "ode_solver.h"
#include "ode_solver_library/ode_solver_factory.h"
// Class that represents a BioCro simulation
class biocro_simulation
{
public:
biocro_simulation(
// parameters passed to dynamical_system constructor
state_map const& initial_values,
state_map const& parameters,
state_vector_map const& drivers,
mc_vector const& direct_mcs,
mc_vector const& differential_mcs,
// parameters passed to ode_solver_factory::create
std::string ode_solver_name,
double output_step_size,
double adaptive_rel_error_tol,
double adaptive_abs_error_tol,
int adaptive_max_steps)
{
// Create the system
sys = std::shared_ptr<dynamical_system>(
new dynamical_system(initial_values, parameters,
drivers, direct_mcs,
differential_mcs));
// Create the ode_solver that will be used to solve the system
system_solver =
std::unique_ptr<ode_solver>(
ode_solver_factory::create(
ode_solver_name,
output_step_size,
adaptive_rel_error_tol,
adaptive_abs_error_tol,
adaptive_max_steps));
}
state_vector_map run_simulation()
{
return system_solver->integrate(sys);
}
std::string generate_report() const
{
std::string report;
report += "\nSystem startup information:\n" +
sys->generate_startup_report() +
"\nODE solver description:\n" +
system_solver->generate_info_report() +
"\n\nThe ODE solver reports the following:\n" +
system_solver->generate_integrate_report() +
"\nThe dynamical system reports the following:\n" +
sys->generate_usage_report() +
"\n\n";
return report;
}
private:
std::shared_ptr<dynamical_system> sys;
std::unique_ptr<ode_solver> system_solver;
};
#endif