Skip to content

Commit d210045

Browse files
Update README.md
README is updated to reflect changes in the OrdinaryDiffEq interface.
1 parent 528188d commit d210045

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

README.md

+35-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# CellMLToolkit.jl
22

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+
[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
4+
[![Global Docs](https://img.shields.io/badge/docs-SciML-blue.svg)](https://docs.sciml.ai/CellMLToolkit/stable/)
5+
6+
[![codecov](https://codecov.io/gh/SciML/CellMLToolkit.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/CellMLToolkit.jl)
7+
[![Build Status](https://github.com/SciML/CellMLToolkit.jl/workflows/CI/badge.svg)](https://github.com/SciML/CellMLToolkit.jl/actions?query=workflow%3ACI)
8+
9+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
10+
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
11+
12+
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.
420

521
## CellML
622

@@ -10,12 +26,13 @@ CellMLToolkit.jl is a Julia library that connects [CellML](http://cellml.org) mo
1026

1127
[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.
1228

13-
## Install
29+
## Installation
1430

15-
To install, run
31+
To install CellMLToolkit.jl, use the Julia package manager:
1632

1733
```julia
18-
] add CellMLToolkit
34+
using Pkg
35+
Pkg.add("CellMLToolkit")
1936
```
2037

2138
## Simple Example
@@ -25,8 +42,8 @@ To install, run
2542

2643
ml = CellModel("models/lorenz.cellml.xml")
2744
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
3047
```
3148

3249
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
3855
and then
3956

4057
```julia
41-
model_path = joinpath(model_root, "lorenz.cellml.xml")
42-
ml = CellModel(model_path)
58+
model_path = joinpath(model_root, "lorenz.cellml.xml")
59+
ml = CellModel(model_path)
4360
```
4461

4562
## Tutorial
@@ -59,14 +76,15 @@ The next step is to convert `ml` into an `ODEProblem`, ready to be solved.
5976
```Julia
6077
prob = ODEProblem(ml, (0,100.0))
6178
```
79+
6280
Here, `(0,100.0)` is the `tspan` parameter, describing the integration range of the independent variable.
6381
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
6482

6583
```Julia
6684
using DifferentialEquations, Plots
6785

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
7088
```
7189

7290
As expected,
@@ -78,13 +96,13 @@ Let's look at more complicated examples. The next one is the [ten Tusscher-Noble
7896
```Julia
7997
ml = CellModel("models/tentusscher_noble_noble_panfilov_2004_a.cellml.xml")
8098
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)
82100
plot(sol, idxs=12)
83101
```
84102

85103
![](figures/ten.png)
86104

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

89107
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:
90108

@@ -128,7 +146,7 @@ Assume we want to change `IstimPeriod`. We can easily do this with the help of `
128146
```Julia
129147
params = list_params(ml)
130148
update_list!(params, :stimulus_protocol₊IstimPeriod, 250.0)
131-
prob = ODEProblem(ml, (0, 10000.0); p=last.(params))
149+
prob = ODEProblem(ml, (0, 10000.0); p=last.(params)) # note that you need to pass last.(params) and not params itself to ODEProblem
132150
```
133151

134152
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
157175
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:
158176

159177
```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)
163181
```
164182

165183
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
179197
Same as before, we can plot the output as
180198

181199
```julia
182-
plot(sol, idxs=2)
200+
plot(sol, idxs = 2)
183201
```
184202

185203
![](figures/noble_1962.png)

0 commit comments

Comments
 (0)