You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, `prob` is an `ODEProblem` ready for integration. Here, `(0,100.0)` is the `tspan` parameter, describing the integration range of the independent variable.
55
-
In addition to the model equations, the initial conditions and parameters are also read from the XML file and are available as `prob.u0` and `prob.p`, respectively.
56
-
We can solve and visualize `prob` as
55
+
Now, `ml` is a `CellModel` structure that contains both a list of the loaded XML files and their components (accessible as `ml.doc`) and a ModelingToolkit `ODESystem` that defines variables and dynamics and can be accessed as `getsys(ml)`.
56
+
57
+
The next step is to convert `ml` into an `ODEProblem`, ready to be solved.
58
+
59
+
```Julia
60
+
prob =ODEProblem(ml, (0,100.0))
61
+
```
62
+
Here, `(0,100.0)` is the `tspan` parameter, describing the integration range of the independent variable.
63
+
In addition to the model equations, the initial conditions and parameters are also read from the XML file(s) and are available as `prob.u0` and `prob.ps`, respectively. We can solve and visualize `prob` as
57
64
58
65
```Julia
59
66
using DifferentialEquations, Plots
@@ -69,31 +76,17 @@ As expected,
69
76
Let's look at more complicated examples. The next one is the [ten Tusscher-Noble-Noble-Panfilov human left ventricular action potential model](https://journals.physiology.org/doi/full/10.1152/ajpheart.00794.2003). This is a mid-range electrophysiology model with 17 states variables and relatively good numerical stability.
ml =CellModel("models/tentusscher_noble_noble_panfilov_2004_a.cellml.xml")
80
+
prob =ODEProblem(ml, (0, 10000.0))
73
81
sol =solve(prob, TRBDF2(), dtmax=1.0)
74
82
plot(sol, vars=12)
75
83
```
76
84
77
85

78
86
79
-
We can tell which variable to plot (vars=12, here) by looking at the output of 'list_states' (see below).
80
-
81
-
Instead of directly generating an `ODEProblem` by calling `read_cellml`, we can use a two-step process with more control by first calling `CellModel` factory function:
82
-
83
-
```Julia
84
-
ml =CellModel("models/tentusscher_noble_noble_panfilov_2004_a.cellml.xml")
85
-
```
86
-
87
-
`CellModel` is a light wrapper around an `ODESystem`. We can access the underlying `ODESystem` as `getsys(ml)` and the model XML as `getxml(ml)` (as an [EzXML](https://github.com/JuliaIO/EzXML.jl) tree). We can then generate an `ODEProblem` as
88
-
89
-
```Julia
90
-
tspan = (0, 10000)
91
-
prob =ODEProblem(ml, tspan)
92
-
sol =solve(prob, TRBDF2(), dtmax=1.0)
93
-
plot(sol, vars=1)
94
-
```
87
+
We can tell which variable to plot (vars=12, here) by looking at the output of `list_states(ml)` (see below).
95
88
96
-
One benefit of going through `CellModel` instead of direct `ODEProblem` generation is the ability to modify initial values and parameters. Let's look at the Beeler-Reuter model with 8 state variables:
89
+
Let's see how we can modify the initial values and parameters. We will use the Beeler-Reuter model with 8 state variables as an example:
97
90
98
91
```Julia
99
92
ml =CellModel("models/beeler_reuter_1977.cellml.xml")
@@ -161,7 +154,7 @@ For the next example, we chose a complex model to stress the ODE solvers: [the O
161
154
162
155
## Multi-file Models (Import)
163
156
164
-
CellML specification allows for multi-file models. In these models, the top level CellML XML file imports components from other CellML files, which in turn may import from other files. CellMLToolkit supports this functionality. It assumes that *the top-level file and all the imported files reside in the same directory*. `models/noble_1962` contained one such example:
157
+
CellML specification allows for models spanning multiple XML files. In these models, the top level CellML XML file imports components from other CellML files, which in turn may import from other files. CellMLToolkit supports this functionality. It assumes that *the top-level file and all the imported files reside in the same directory*. `models/noble_1962` contained one such example:
165
158
166
159
```julia
167
160
ml =CellModel("models/noble_1962/Noble_1962.cellml")
0 commit comments