Skip to content

Commit

Permalink
Merge pull request #50 from siravan/master
Browse files Browse the repository at this point in the history
ver 2.4.3
  • Loading branch information
shahriariravanian authored Apr 18, 2021
2 parents 8f362ef + 8328f18 commit fd84953
Show file tree
Hide file tree
Showing 43 changed files with 3,455 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CellMLToolkit"
uuid = "03cb29e0-1ef4-4721-aa24-cf58a006576f"
authors = ["Shahriar Iravanian <[email protected]>"]
version = "2.4.2"
version = "2.4.3"

[deps]
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
Expand Down
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To install, run
plot(sol, vars=(1,3))
```

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

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

# Tutorial
## Tutorial

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

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

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

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

![](figures/ohara_rudy.png)

## Multi-file Models (Import)

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:

```julia
ml = CellModel("models/noble_1962/Noble_1962.cellml")
prob = ODEProblem(ml, tspan)
sol = solve(prob, TRBDF2(), dtmax=0.5)
```

Note that the syntax is exactly the same as before. However, the list of the imported files are printed during `CellModel` generation:

```
[ Info: importing Noble62_Na_channel.cellml
[ Info: importing Noble62_units.cellml
[ Info: importing Noble62_K_channel.cellml
[ Info: importing Noble62_units.cellml
[ Info: importing Noble62_L_channel.cellml
[ Info: importing Noble62_units.cellml
[ Info: importing Noble62_units.cellml
[ Info: importing Noble62_parameters.cellml
[ Info: importing Noble62_units.cellml
```

Same as before, we can plot the output as

```julia
plot(sol, vars=2)
```

![](figures/noble_1962.png)
Binary file added figures/noble_1962.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions models/noble_1962/BlueSkyCatastrophy.cellml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version='1.0'?>
<model name="van_der_pol_model" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
<component name="main">
<variable initial_value="0" name="t" units="dimensionless"/>
<variable initial_value="0.9" name="x" units="dimensionless"/>
<variable initial_value="0.4" name="y" units="dimensionless"/>
<variable initial_value="0.2645" name="A" units="dimensionless"/>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<eq/>
<apply>
<diff/>
<bvar>
<ci>t</ci>
</bvar>
<ci>x</ci>
</apply>
<ci>y</ci>
</apply>
<apply>
<eq/>
<apply>
<diff/>
<bvar>
<ci>t</ci>
</bvar>
<ci>y</ci>
</apply>
<apply>
<plus/>
<apply>
<minus/>
<apply>
<minus/>
<ci>x</ci>
<apply>
<power/>
<ci>x</ci>
<cn cellml:units="dimensionless">3</cn>
</apply>
</apply>
<apply>
<times/>
<cn cellml:units="dimensionless">0.25</cn>
<ci>y</ci>
</apply>
</apply>
<apply>
<times/>
<ci>A</ci>
<apply>
<sin/>
<ci>t</ci>
</apply>
</apply>
</apply>
</apply>
</math>
</component>
</model>
84 changes: 84 additions & 0 deletions models/noble_1962/BlueSkyCatastrophy.sedml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version='1.0' encoding='UTF-8'?>
<sedML level="1" version="2" xmlns="http://sed-ml.org/sed-ml/level1/version2" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
<listOfSimulations>
<uniformTimeCourse id="simulation1" initialTime="0" numberOfPoints="50000" outputEndTime="500" outputStartTime="0">
<algorithm kisaoID="KISAO:0000019">
<listOfAlgorithmParameters>
<algorithmParameter kisaoID="KISAO:0000211" value="1e-07"/>
<algorithmParameter kisaoID="KISAO:0000475" value="BDF"/>
<algorithmParameter kisaoID="KISAO:0000481" value="true"/>
<algorithmParameter kisaoID="KISAO:0000476" value="Newton"/>
<algorithmParameter kisaoID="KISAO:0000477" value="Dense"/>
<algorithmParameter kisaoID="KISAO:0000480" value="0"/>
<algorithmParameter kisaoID="KISAO:0000415" value="500"/>
<algorithmParameter kisaoID="KISAO:0000467" value="0"/>
<algorithmParameter kisaoID="KISAO:0000478" value="Banded"/>
<algorithmParameter kisaoID="KISAO:0000209" value="1e-07"/>
<algorithmParameter kisaoID="KISAO:0000479" value="0"/>
</listOfAlgorithmParameters>
</algorithm>
</uniformTimeCourse>
</listOfSimulations>
<listOfModels>
<model id="model" language="urn:sedml:language:cellml.1_1" source="BlueSkyCatastrophy.cellml"/>
</listOfModels>
<listOfTasks>
<repeatedTask id="repeatedTask" range="once" resetModel="true">
<listOfRanges>
<vectorRange id="once">
<value> 1 </value>
</vectorRange>
</listOfRanges>
<listOfSubTasks>
<subTask order="1" task="task1"/>
</listOfSubTasks>
</repeatedTask>
<task id="task1" modelReference="model" simulationReference="simulation1"/>
</listOfTasks>
<listOfDataGenerators>
<dataGenerator id="xDataGenerator1_1">
<listOfVariables>
<variable id="xVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='t']" taskReference="repeatedTask"/>
</listOfVariables>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> xVariable1_1 </ci>
</math>
</dataGenerator>
<dataGenerator id="yDataGenerator1_1">
<listOfVariables>
<variable id="yVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='x']" taskReference="repeatedTask"/>
</listOfVariables>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> yVariable1_1 </ci>
</math>
</dataGenerator>
<dataGenerator id="xDataGenerator2_1">
<listOfVariables>
<variable id="xVariable2_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='x']" taskReference="repeatedTask"/>
</listOfVariables>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> xVariable2_1 </ci>
</math>
</dataGenerator>
<dataGenerator id="yDataGenerator2_1">
<listOfVariables>
<variable id="yVariable2_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='y']" taskReference="repeatedTask"/>
</listOfVariables>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> yVariable2_1 </ci>
</math>
</dataGenerator>
</listOfDataGenerators>
<listOfOutputs>
<plot2D id="plot1">
<listOfCurves>
<curve id="curve1_1" logX="false" logY="false" xDataReference="xDataGenerator1_1" yDataReference="yDataGenerator1_1"/>
</listOfCurves>
</plot2D>
<plot2D id="plot2">
<listOfCurves>
<curve id="curve2_1" logX="false" logY="false" xDataReference="xDataGenerator2_1" yDataReference="yDataGenerator2_1"/>
</listOfCurves>
</plot2D>
</listOfOutputs>
</sedML>
33 changes: 33 additions & 0 deletions models/noble_1962/Firstorder.cellml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version='1.0'?>
<model name="first_order_model" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
<component name="main">
<variable initial_value="0" name="t" units="dimensionless"/>
<variable initial_value="5" name="y" units="dimensionless"/>
<variable initial_value="1" name="a" units="dimensionless"/>
<variable initial_value="2" name="b" units="dimensionless"/>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<eq/>
<apply>
<diff/>
<bvar>
<ci>t</ci>
</bvar>
<ci>y</ci>
</apply>
<apply>
<plus/>
<apply>
<times/>
<apply>
<minus/>
<ci>a</ci>
</apply>
<ci>y</ci>
</apply>
<ci>b</ci>
</apply>
</apply>
</math>
</component>
</model>
4 changes: 4 additions & 0 deletions models/noble_1962/Firstorder.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Exponential decay: A simple first order ODE
-------------------------------------------

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.
63 changes: 63 additions & 0 deletions models/noble_1962/Firstorder.sedml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version='1.0' encoding='UTF-8'?>
<sedML level="1" version="2" xmlns="http://sed-ml.org/sed-ml/level1/version2" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
<listOfSimulations>
<uniformTimeCourse id="simulation1" initialTime="0" numberOfPoints="100" outputEndTime="10" outputStartTime="0">
<algorithm kisaoID="KISAO:0000019">
<listOfAlgorithmParameters>
<algorithmParameter kisaoID="KISAO:0000211" value="1e-07"/>
<algorithmParameter kisaoID="KISAO:0000475" value="BDF"/>
<algorithmParameter kisaoID="KISAO:0000481" value="true"/>
<algorithmParameter kisaoID="KISAO:0000476" value="Newton"/>
<algorithmParameter kisaoID="KISAO:0000477" value="Dense"/>
<algorithmParameter kisaoID="KISAO:0000480" value="0"/>
<algorithmParameter kisaoID="KISAO:0000415" value="500"/>
<algorithmParameter kisaoID="KISAO:0000467" value="0"/>
<algorithmParameter kisaoID="KISAO:0000478" value="Banded"/>
<algorithmParameter kisaoID="KISAO:0000209" value="1e-07"/>
<algorithmParameter kisaoID="KISAO:0000479" value="0"/>
</listOfAlgorithmParameters>
</algorithm>
</uniformTimeCourse>
</listOfSimulations>
<listOfModels>
<model id="model" language="urn:sedml:language:cellml.1_1" source="Firstorder.cellml"/>
</listOfModels>
<listOfTasks>
<repeatedTask id="repeatedTask" range="once" resetModel="true">
<listOfRanges>
<vectorRange id="once">
<value> 1 </value>
</vectorRange>
</listOfRanges>
<listOfSubTasks>
<subTask order="1" task="task1"/>
</listOfSubTasks>
</repeatedTask>
<task id="task1" modelReference="model" simulationReference="simulation1"/>
</listOfTasks>
<listOfDataGenerators>
<dataGenerator id="xDataGenerator1_1">
<listOfVariables>
<variable id="xVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='t']" taskReference="repeatedTask"/>
</listOfVariables>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> xVariable1_1 </ci>
</math>
</dataGenerator>
<dataGenerator id="yDataGenerator1_1">
<listOfVariables>
<variable id="yVariable1_1" target="/cellml:model/cellml:component[@name='main']/cellml:variable[@name='y']" taskReference="repeatedTask"/>
</listOfVariables>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> yVariable1_1 </ci>
</math>
</dataGenerator>
</listOfDataGenerators>
<listOfOutputs>
<plot2D id="plot1">
<listOfCurves>
<curve id="curve1_1" logX="false" logY="false" xDataReference="xDataGenerator1_1" yDataReference="yDataGenerator1_1"/>
</listOfCurves>
</plot2D>
</listOfOutputs>
</sedML>
Loading

2 comments on commit fd84953

@shahriariravanian
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/34646

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.4.3 -m "<description of version>" fd8495394c6fa757c0302dc48559203a6d7c2e44
git push origin v2.4.3

Please sign in to comment.