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
Copy file name to clipboardexpand all lines: README.md
+35-17
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,22 @@
1
1
# CellMLToolkit.jl
2
2
3
-
CellMLToolkit.jl is a Julia library that connects [CellML](http://cellml.org) models to [SciML](http://github.com/SciML), the Scientific Julia ecosystem. CellMLToolkit.jl acts as a bridge between CellML and ModelingToolkit.jl. It imports a CellML model (in XML) and emits a ModelingToolkit.jl intermediate representation (IR), which can then enter the SciML ecosystem.
3
+
[](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
[](https://github.com/SciML/ColPrac)
CellMLToolkit.jl is a Julia library that connects [CellML](https://cellml.org/) models to [SciML](http://github.com/SciML/), the Scientific Julia ecosystem. CellMLToolkit.jl acts as a bridge between CellML and ModelingToolkit.jl. It imports a CellML model (in XML) and emits a ModelingToolkit.jl intermediate representation (IR), which can then enter the SciML ecosystem.
13
+
14
+
## Tutorials and Documentation
15
+
16
+
For information on using the package,
17
+
[see the stable documentation](https://docs.sciml.ai/CellMLToolkit/stable/). Use the
18
+
[in-development documentation](https://docs.sciml.ai/CellMLToolkit/dev/) for the version of
19
+
the documentation, which contains the unreleased features.
4
20
5
21
## CellML
6
22
@@ -10,12 +26,13 @@ CellMLToolkit.jl is a Julia library that connects [CellML](http://cellml.org) mo
10
26
11
27
[SciML](http://github.com/SciML) is a collection of Julia libraries for open source scientific computing and machine learning. The centerpiece of SciML is [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl), which provides a rich set of ordinary differential equations (ODE) solvers. One major peripheral component of SciML is [ModelingToolkit.jl](https://github.com/SciML/ModelingToolkit.jl). It is a modeling framework for high-performance symbolic-numeric computation in scientific computing and scientific machine learning. The core of ModelingToolkit.jl is an IR language to code the scientific problems of interest in a high level. Automatic code generation and differentiation allow for the generation of a usable model for the other components of SciML, such as DifferentialEquations.jl.
12
28
13
-
## Install
29
+
## Installation
14
30
15
-
To install, run
31
+
To install CellMLToolkit.jl, use the Julia package manager:
16
32
17
33
```julia
18
-
] add CellMLToolkit
34
+
using Pkg
35
+
Pkg.add("CellMLToolkit")
19
36
```
20
37
21
38
## Simple Example
@@ -25,8 +42,8 @@ To install, run
25
42
26
43
ml =CellModel("models/lorenz.cellml.xml")
27
44
prob =ODEProblem(ml, (0,100.0))
28
-
sol =solve(prob, RK4())# fourth-order Runge-Kutta method
29
-
plot(sol, idxs=(1,3))# idxs keyword has superceded vars keyword
45
+
sol =solve(prob, RK4())# fourth-order Runge-Kutta method
46
+
plot(sol, idxs=(1,3))# idxs keyword has superceded vars keyword
30
47
```
31
48
32
49
Note that `model` is a directory of the CellMLToolkit package. You can find its path as
@@ -38,8 +55,8 @@ Note that `model` is a directory of the CellMLToolkit package. You can find its
@@ -59,14 +76,15 @@ The next step is to convert `ml` into an `ODEProblem`, ready to be solved.
59
76
```Julia
60
77
prob =ODEProblem(ml, (0,100.0))
61
78
```
79
+
62
80
Here, `(0,100.0)` is the `tspan` parameter, describing the integration range of the independent variable.
63
81
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
64
82
65
83
```Julia
66
84
using DifferentialEquations, Plots
67
85
68
-
sol =solve(prob, RK4())# fourth-order Runge-Kutta method
69
-
plot(sol, idxs=(1,3))# idxs keyword has superceded vars keyword
86
+
sol =solve(prob, RK4())# fourth-order Runge-Kutta method
87
+
plot(sol, idxs=(1,3))# idxs keyword has superceded vars keyword
70
88
```
71
89
72
90
As expected,
@@ -78,13 +96,13 @@ Let's look at more complicated examples. The next one is the [ten Tusscher-Noble
78
96
```Julia
79
97
ml =CellModel("models/tentusscher_noble_noble_panfilov_2004_a.cellml.xml")
80
98
prob =ODEProblem(ml, (0, 10000.0))
81
-
sol =solve(prob, TRBDF2(), dtmax=1.0)# it is a stiff system requiring an implcit solver (TRBDF2 instead of RK4)
99
+
sol =solve(prob, TRBDF2(), dtmax=1.0)# it is a stiff system requiring an implcit solver (TRBDF2 instead of RK4)
82
100
plot(sol, idxs=12)
83
101
```
84
102
85
103

86
104
87
-
We can tell which variable to plot (idxs=12, here) by looking at the output of `list_states(ml)` (see below).
105
+
We can tell which variable to plot (`idxs=12` here) by looking at the output of `list_states(ml)` (see below).
88
106
89
107
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:
90
108
@@ -128,7 +146,7 @@ Assume we want to change `IstimPeriod`. We can easily do this with the help of `
prob =ODEProblem(ml, (0, 10000.0); p=last.(params))# note that you need to pass last.(params) and not params itself to ODEProblem
132
150
```
133
151
134
152
The rest is the same as before.
@@ -157,9 +175,9 @@ For the next example, we chose a complex model to stress the ODE solvers: [the O
157
175
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:
158
176
159
177
```julia
160
-
ml =CellModel("models/noble_1962/Noble_1962.cellml")
161
-
prob =ODEProblem(ml, tspan)
162
-
sol =solve(prob, TRBDF2(), dtmax=0.5)
178
+
ml =CellModel("models/noble_1962/Noble_1962.cellml")
179
+
prob =ODEProblem(ml, tspan)
180
+
sol =solve(prob, TRBDF2(), dtmax=0.5)
163
181
```
164
182
165
183
Note that the syntax is exactly the same as before. However, the list of the imported files are printed during `CellModel` generation:
@@ -179,7 +197,7 @@ Note that the syntax is exactly the same as before. However, the list of the imp
0 commit comments