Skip to content

Commit 804201c

Browse files
Merge pull request #51 from siravan/master
ver 2.4.4
2 parents fd84953 + 9a63a92 commit 804201c

33 files changed

+23
-2308
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CellMLToolkit"
22
uuid = "03cb29e0-1ef4-4721-aa24-cf58a006576f"
33
authors = ["Shahriar Iravanian <siravan@svtsim.com>"]
4-
version = "2.4.3"
4+
version = "2.4.4"
55

66
[deps]
77
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"

README.md

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ To install, run
2323
```Julia
2424
using CellMLToolkit, OrdinaryDiffEq, Plots
2525

26-
prob = read_cellml("models/lorenz.cellml.xml", (0,100.0))
26+
ml = CellModel("models/lorenz.cellml.xml")
27+
prob = ODEProblem(ml, (0,100.0))
2728
sol = solve(prob)
2829
plot(sol, vars=(1,3))
2930
```
@@ -38,22 +39,28 @@ and then
3839

3940
```julia
4041
model_path = joinpath(model_root, "lorenz.cellml.xml")
41-
prob = read_cellml(model_path, (0,100.0))
42+
ml = CellModel(model_path)
4243
```
4344

4445
## Tutorial
4546

46-
The models directory contains a few CellML model examples. Let's start with a simple one, the famous Lorenz equations!
47+
The models directory contains a few CellML model examples. Let's start with a simple one, the famous Lorenz equations.
4748

4849
```Julia
4950
using CellMLToolkit
5051

51-
prob = read_cellml("models/lorenz.cellml.xml", (0,100.0))
52+
ml = CellModel("models/lorenz.cellml.xml")
5253
```
5354

54-
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
5764

5865
```Julia
5966
using DifferentialEquations, Plots
@@ -69,31 +76,17 @@ As expected,
6976
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.
7077

7178
```Julia
72-
prob = read_cellml("models/tentusscher_noble_noble_panfilov_2004_a.cellml.xml", (0, 10000.0))
79+
ml = CellModel("models/tentusscher_noble_noble_panfilov_2004_a.cellml.xml")
80+
prob = ODEProblem(ml, (0, 10000.0))
7381
sol = solve(prob, TRBDF2(), dtmax=1.0)
7482
plot(sol, vars=12)
7583
```
7684

7785
![](figures/ten.png)
7886

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).
9588

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:
9790

9891
```Julia
9992
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
161154

162155
## Multi-file Models (Import)
163156

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:
165158

166159
```julia
167160
ml = CellModel("models/noble_1962/Noble_1962.cellml")

models/noble_1962/BlueSkyCatastrophy.cellml

Lines changed: 0 additions & 60 deletions
This file was deleted.

models/noble_1962/BlueSkyCatastrophy.sedml

Lines changed: 0 additions & 84 deletions
This file was deleted.

models/noble_1962/Firstorder.cellml

Lines changed: 0 additions & 33 deletions
This file was deleted.

models/noble_1962/Firstorder.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

models/noble_1962/Firstorder.sedml

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)