Skip to content

Commit fd84953

Browse files
Merge pull request #50 from siravan/master
ver 2.4.3
2 parents 8f362ef + 8328f18 commit fd84953

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3455
-14
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.2"
4+
version = "2.4.3"
55

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

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To install, run
2828
plot(sol, vars=(1,3))
2929
```
3030

31-
Note that `model` is a directory of the CellMLToolkit package. You can find its path as
31+
Note that `model` is a directory of the CellMLToolkit package. You can find its path as
3232

3333
```Julia
3434
model_root = joinpath(splitdir(pathof(CellMLToolkit))[1], "..", "models")
@@ -41,7 +41,7 @@ and then
4141
prob = read_cellml(model_path, (0,100.0))
4242
```
4343

44-
# Tutorial
44+
## Tutorial
4545

4646
The models directory contains a few CellML model examples. Let's start with a simple one, the famous Lorenz equations!
4747

@@ -145,7 +145,7 @@ The rest is the same as before.
145145
plot(sol, vars=8) # 8 is the index of membrane₊V
146146
```
147147

148-
For the last example, we chose a complex model to stress the ODE solvers: [the O'Hara-Rudy left ventricular model](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1002061). This model has 49 state variables, is very stiff, and is prone to oscillation. The best solver for this model is `CVODE_BDF` from the Sundial suite.
148+
For the next example, we chose a complex model to stress the ODE solvers: [the O'Hara-Rudy left ventricular model](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1002061). This model has 49 state variables, is very stiff, and is prone to oscillation. The best solver for this model is `CVODE_BDF` from the Sundial suite.
149149

150150
```Julia
151151
using Sundials
@@ -158,3 +158,35 @@ For the last example, we chose a complex model to stress the ODE solvers: [the O
158158
```
159159

160160
![](figures/ohara_rudy.png)
161+
162+
## Multi-file Models (Import)
163+
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:
165+
166+
```julia
167+
ml = CellModel("models/noble_1962/Noble_1962.cellml")
168+
prob = ODEProblem(ml, tspan)
169+
sol = solve(prob, TRBDF2(), dtmax=0.5)
170+
```
171+
172+
Note that the syntax is exactly the same as before. However, the list of the imported files are printed during `CellModel` generation:
173+
174+
```
175+
[ Info: importing Noble62_Na_channel.cellml
176+
[ Info: importing Noble62_units.cellml
177+
[ Info: importing Noble62_K_channel.cellml
178+
[ Info: importing Noble62_units.cellml
179+
[ Info: importing Noble62_L_channel.cellml
180+
[ Info: importing Noble62_units.cellml
181+
[ Info: importing Noble62_units.cellml
182+
[ Info: importing Noble62_parameters.cellml
183+
[ Info: importing Noble62_units.cellml
184+
```
185+
186+
Same as before, we can plot the output as
187+
188+
```julia
189+
plot(sol, vars=2)
190+
```
191+
192+
![](figures/noble_1962.png)

figures/noble_1962.png

32.5 KB
Loading
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version='1.0'?>
2+
<model name="van_der_pol_model" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
3+
<component name="main">
4+
<variable initial_value="0" name="t" units="dimensionless"/>
5+
<variable initial_value="0.9" name="x" units="dimensionless"/>
6+
<variable initial_value="0.4" name="y" units="dimensionless"/>
7+
<variable initial_value="0.2645" name="A" units="dimensionless"/>
8+
<math xmlns="http://www.w3.org/1998/Math/MathML">
9+
<apply>
10+
<eq/>
11+
<apply>
12+
<diff/>
13+
<bvar>
14+
<ci>t</ci>
15+
</bvar>
16+
<ci>x</ci>
17+
</apply>
18+
<ci>y</ci>
19+
</apply>
20+
<apply>
21+
<eq/>
22+
<apply>
23+
<diff/>
24+
<bvar>
25+
<ci>t</ci>
26+
</bvar>
27+
<ci>y</ci>
28+
</apply>
29+
<apply>
30+
<plus/>
31+
<apply>
32+
<minus/>
33+
<apply>
34+
<minus/>
35+
<ci>x</ci>
36+
<apply>
37+
<power/>
38+
<ci>x</ci>
39+
<cn cellml:units="dimensionless">3</cn>
40+
</apply>
41+
</apply>
42+
<apply>
43+
<times/>
44+
<cn cellml:units="dimensionless">0.25</cn>
45+
<ci>y</ci>
46+
</apply>
47+
</apply>
48+
<apply>
49+
<times/>
50+
<ci>A</ci>
51+
<apply>
52+
<sin/>
53+
<ci>t</ci>
54+
</apply>
55+
</apply>
56+
</apply>
57+
</apply>
58+
</math>
59+
</component>
60+
</model>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<sedML level="1" version="2" xmlns="http://sed-ml.org/sed-ml/level1/version2" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
3+
<listOfSimulations>
4+
<uniformTimeCourse id="simulation1" initialTime="0" numberOfPoints="50000" outputEndTime="500" outputStartTime="0">
5+
<algorithm kisaoID="KISAO:0000019">
6+
<listOfAlgorithmParameters>
7+
<algorithmParameter kisaoID="KISAO:0000211" value="1e-07"/>
8+
<algorithmParameter kisaoID="KISAO:0000475" value="BDF"/>
9+
<algorithmParameter kisaoID="KISAO:0000481" value="true"/>
10+
<algorithmParameter kisaoID="KISAO:0000476" value="Newton"/>
11+
<algorithmParameter kisaoID="KISAO:0000477" value="Dense"/>
12+
<algorithmParameter kisaoID="KISAO:0000480" value="0"/>
13+
<algorithmParameter kisaoID="KISAO:0000415" value="500"/>
14+
<algorithmParameter kisaoID="KISAO:0000467" value="0"/>
15+
<algorithmParameter kisaoID="KISAO:0000478" value="Banded"/>
16+
<algorithmParameter kisaoID="KISAO:0000209" value="1e-07"/>
17+
<algorithmParameter kisaoID="KISAO:0000479" value="0"/>
18+
</listOfAlgorithmParameters>
19+
</algorithm>
20+
</uniformTimeCourse>
21+
</listOfSimulations>
22+
<listOfModels>
23+
<model id="model" language="urn:sedml:language:cellml.1_1" source="BlueSkyCatastrophy.cellml"/>
24+
</listOfModels>
25+
<listOfTasks>
26+
<repeatedTask id="repeatedTask" range="once" resetModel="true">
27+
<listOfRanges>
28+
<vectorRange id="once">
29+
<value> 1 </value>
30+
</vectorRange>
31+
</listOfRanges>
32+
<listOfSubTasks>
33+
<subTask order="1" task="task1"/>
34+
</listOfSubTasks>
35+
</repeatedTask>
36+
<task id="task1" modelReference="model" simulationReference="simulation1"/>
37+
</listOfTasks>
38+
<listOfDataGenerators>
39+
<dataGenerator id="xDataGenerator1_1">
40+
<listOfVariables>
41+
<variable id="xVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='t']" taskReference="repeatedTask"/>
42+
</listOfVariables>
43+
<math xmlns="http://www.w3.org/1998/Math/MathML">
44+
<ci> xVariable1_1 </ci>
45+
</math>
46+
</dataGenerator>
47+
<dataGenerator id="yDataGenerator1_1">
48+
<listOfVariables>
49+
<variable id="yVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='x']" taskReference="repeatedTask"/>
50+
</listOfVariables>
51+
<math xmlns="http://www.w3.org/1998/Math/MathML">
52+
<ci> yVariable1_1 </ci>
53+
</math>
54+
</dataGenerator>
55+
<dataGenerator id="xDataGenerator2_1">
56+
<listOfVariables>
57+
<variable id="xVariable2_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='x']" taskReference="repeatedTask"/>
58+
</listOfVariables>
59+
<math xmlns="http://www.w3.org/1998/Math/MathML">
60+
<ci> xVariable2_1 </ci>
61+
</math>
62+
</dataGenerator>
63+
<dataGenerator id="yDataGenerator2_1">
64+
<listOfVariables>
65+
<variable id="yVariable2_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='y']" taskReference="repeatedTask"/>
66+
</listOfVariables>
67+
<math xmlns="http://www.w3.org/1998/Math/MathML">
68+
<ci> yVariable2_1 </ci>
69+
</math>
70+
</dataGenerator>
71+
</listOfDataGenerators>
72+
<listOfOutputs>
73+
<plot2D id="plot1">
74+
<listOfCurves>
75+
<curve id="curve1_1" logX="false" logY="false" xDataReference="xDataGenerator1_1" yDataReference="yDataGenerator1_1"/>
76+
</listOfCurves>
77+
</plot2D>
78+
<plot2D id="plot2">
79+
<listOfCurves>
80+
<curve id="curve2_1" logX="false" logY="false" xDataReference="xDataGenerator2_1" yDataReference="yDataGenerator2_1"/>
81+
</listOfCurves>
82+
</plot2D>
83+
</listOfOutputs>
84+
</sedML>

models/noble_1962/Firstorder.cellml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version='1.0'?>
2+
<model name="first_order_model" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
3+
<component name="main">
4+
<variable initial_value="0" name="t" units="dimensionless"/>
5+
<variable initial_value="5" name="y" units="dimensionless"/>
6+
<variable initial_value="1" name="a" units="dimensionless"/>
7+
<variable initial_value="2" name="b" units="dimensionless"/>
8+
<math xmlns="http://www.w3.org/1998/Math/MathML">
9+
<apply>
10+
<eq/>
11+
<apply>
12+
<diff/>
13+
<bvar>
14+
<ci>t</ci>
15+
</bvar>
16+
<ci>y</ci>
17+
</apply>
18+
<apply>
19+
<plus/>
20+
<apply>
21+
<times/>
22+
<apply>
23+
<minus/>
24+
<ci>a</ci>
25+
</apply>
26+
<ci>y</ci>
27+
</apply>
28+
<ci>b</ci>
29+
</apply>
30+
</apply>
31+
</math>
32+
</component>
33+
</model>

models/noble_1962/Firstorder.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Exponential decay: A simple first order ODE
2+
-------------------------------------------
3+
4+
Used as the simplest example of a first order differential equation, this model consists of a `single equation <Firstorder.cellml/cellml_math>`_. One of the simulation experiments for this model described in the tutorial can be obtained by loading the `corresponding SED-ML document <Firstorder.sedml>`__ into OpenCOR and executing the simulation - which can be achived by choosing the **Launch with OpenCOR** link from the *Views Available* listing.

models/noble_1962/Firstorder.sedml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<sedML level="1" version="2" xmlns="http://sed-ml.org/sed-ml/level1/version2" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
3+
<listOfSimulations>
4+
<uniformTimeCourse id="simulation1" initialTime="0" numberOfPoints="100" outputEndTime="10" outputStartTime="0">
5+
<algorithm kisaoID="KISAO:0000019">
6+
<listOfAlgorithmParameters>
7+
<algorithmParameter kisaoID="KISAO:0000211" value="1e-07"/>
8+
<algorithmParameter kisaoID="KISAO:0000475" value="BDF"/>
9+
<algorithmParameter kisaoID="KISAO:0000481" value="true"/>
10+
<algorithmParameter kisaoID="KISAO:0000476" value="Newton"/>
11+
<algorithmParameter kisaoID="KISAO:0000477" value="Dense"/>
12+
<algorithmParameter kisaoID="KISAO:0000480" value="0"/>
13+
<algorithmParameter kisaoID="KISAO:0000415" value="500"/>
14+
<algorithmParameter kisaoID="KISAO:0000467" value="0"/>
15+
<algorithmParameter kisaoID="KISAO:0000478" value="Banded"/>
16+
<algorithmParameter kisaoID="KISAO:0000209" value="1e-07"/>
17+
<algorithmParameter kisaoID="KISAO:0000479" value="0"/>
18+
</listOfAlgorithmParameters>
19+
</algorithm>
20+
</uniformTimeCourse>
21+
</listOfSimulations>
22+
<listOfModels>
23+
<model id="model" language="urn:sedml:language:cellml.1_1" source="Firstorder.cellml"/>
24+
</listOfModels>
25+
<listOfTasks>
26+
<repeatedTask id="repeatedTask" range="once" resetModel="true">
27+
<listOfRanges>
28+
<vectorRange id="once">
29+
<value> 1 </value>
30+
</vectorRange>
31+
</listOfRanges>
32+
<listOfSubTasks>
33+
<subTask order="1" task="task1"/>
34+
</listOfSubTasks>
35+
</repeatedTask>
36+
<task id="task1" modelReference="model" simulationReference="simulation1"/>
37+
</listOfTasks>
38+
<listOfDataGenerators>
39+
<dataGenerator id="xDataGenerator1_1">
40+
<listOfVariables>
41+
<variable id="xVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='t']" taskReference="repeatedTask"/>
42+
</listOfVariables>
43+
<math xmlns="http://www.w3.org/1998/Math/MathML">
44+
<ci> xVariable1_1 </ci>
45+
</math>
46+
</dataGenerator>
47+
<dataGenerator id="yDataGenerator1_1">
48+
<listOfVariables>
49+
<variable id="yVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='y']" taskReference="repeatedTask"/>
50+
</listOfVariables>
51+
<math xmlns="http://www.w3.org/1998/Math/MathML">
52+
<ci> yVariable1_1 </ci>
53+
</math>
54+
</dataGenerator>
55+
</listOfDataGenerators>
56+
<listOfOutputs>
57+
<plot2D id="plot1">
58+
<listOfCurves>
59+
<curve id="curve1_1" logX="false" logY="false" xDataReference="xDataGenerator1_1" yDataReference="yDataGenerator1_1"/>
60+
</listOfCurves>
61+
</plot2D>
62+
</listOfOutputs>
63+
</sedML>

0 commit comments

Comments
 (0)