diff --git a/Project.toml b/Project.toml index 57b789c..f32d807 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CellMLToolkit" uuid = "03cb29e0-1ef4-4721-aa24-cf58a006576f" authors = ["Shahriar Iravanian "] -version = "2.4.2" +version = "2.4.3" [deps] EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" diff --git a/README.md b/README.md index e8eeb8d..11fd29c 100644 --- a/README.md +++ b/README.md @@ -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") @@ -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! @@ -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 @@ -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) diff --git a/figures/noble_1962.png b/figures/noble_1962.png new file mode 100644 index 0000000..b4da826 Binary files /dev/null and b/figures/noble_1962.png differ diff --git a/models/noble_1962/BlueSkyCatastrophy.cellml b/models/noble_1962/BlueSkyCatastrophy.cellml new file mode 100644 index 0000000..28c2c5f --- /dev/null +++ b/models/noble_1962/BlueSkyCatastrophy.cellml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + t + + x + + y + + + + + + + t + + y + + + + + + + + x + + + x + 3 + + + + + 0.25 + y + + + + + A + + + t + + + + + + + diff --git a/models/noble_1962/BlueSkyCatastrophy.sedml b/models/noble_1962/BlueSkyCatastrophy.sedml new file mode 100644 index 0000000..a33268d --- /dev/null +++ b/models/noble_1962/BlueSkyCatastrophy.sedml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/Firstorder.cellml b/models/noble_1962/Firstorder.cellml new file mode 100644 index 0000000..a9767eb --- /dev/null +++ b/models/noble_1962/Firstorder.cellml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + t + + y + + + + + + + + a + + y + + b + + + + + diff --git a/models/noble_1962/Firstorder.rst b/models/noble_1962/Firstorder.rst new file mode 100644 index 0000000..c44a095 --- /dev/null +++ b/models/noble_1962/Firstorder.rst @@ -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 `_. One of the simulation experiments for this model described in the tutorial can be obtained by loading the `corresponding SED-ML document `__ into OpenCOR and executing the simulation - which can be achived by choosing the **Launch with OpenCOR** link from the *Views Available* listing. \ No newline at end of file diff --git a/models/noble_1962/Firstorder.sedml b/models/noble_1962/Firstorder.sedml new file mode 100644 index 0000000..17f1995 --- /dev/null +++ b/models/noble_1962/Firstorder.sedml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + + + + diff --git a/models/noble_1962/HH.cellml b/models/noble_1962/HH.cellml new file mode 100644 index 0000000..6fa85c3 --- /dev/null +++ b/models/noble_1962/HH.cellml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + i_Stim + + + 200 + + + + + t + 1 + + + + t + 1.2 + + + + + 0 + + + + + + i_Tot + + + i_Stim + i_Na + i_K + i_L + + + + + + + + t + + V + + + + + + i_Tot + + Cm + + + + + diff --git a/models/noble_1962/HH.sedml b/models/noble_1962/HH.sedml new file mode 100644 index 0000000..e5942bd --- /dev/null +++ b/models/noble_1962/HH.sedml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + xVariable3_1 + + + + + + + + yVariable3_1 + + + + + + + + xVariable4_1 + + + + + + + + yVariable4_1 + + + + + + + + xVariable5_1 + + + + + + + + yVariable5_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/Noble62_K_channel.cellml b/models/noble_1962/Noble62_K_channel.cellml new file mode 100644 index 0000000..2f27c3b --- /dev/null +++ b/models/noble_1962/Noble62_K_channel.cellml @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + E_K + + + RTF + + + + + Ko + Ki + + + + + + + g_K1 + + + + + 1.2 + + + + + + + + + V + 90 + + + 50 + + + + + + 0.015 + + + + + + + V + 90 + + 60 + + + + + + + + g_K2 + + + 1.2 + + + n + 4 + + + + + + i_K + + + + + g_K1 + g_K2 + + + + V + E_K + + + + + + + + + + + + + + + alpha_n + + + + + + + 0.0001 + + + + V + 50 + + + + + + + + + + + + + V + 50 + + + 10 + + + 1 + + + + + + beta_n + + + 0.0020 + + + + + + + + + V + 90 + + + 80 + + + + + + + + + + t + + n + + + + + + alpha_n + + + 1 + n + + + + + beta_n + n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/Noble62_L_channel.cellml b/models/noble_1962/Noble62_L_channel.cellml new file mode 100644 index 0000000..7788076 --- /dev/null +++ b/models/noble_1962/Noble62_L_channel.cellml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + i_L + + + g_L + + + V + E_L + + + + + + + diff --git a/models/noble_1962/Noble62_Na_channel.cellml b/models/noble_1962/Noble62_Na_channel.cellml new file mode 100644 index 0000000..acd0a00 --- /dev/null +++ b/models/noble_1962/Noble62_Na_channel.cellml @@ -0,0 +1,301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + E_Na + + + RTF + + + + + Nao + Nai + + + + + + + g_Na + + + + + m + 3 + + h + g_Na_max + + + + + i_Na + + + + + g_Na + 0.14 + + + + V + E_Na + + + + + + + + + + + + + + + alpha_m + + + + + + + 0.10 + + + + V + 48 + + + + + + + + + + + + + V + 48 + + + 15 + + + 1 + + + + + + beta_m + + + + + 0.12 + + + V + 8 + + + + + + + + + + + V + 8 + + 5 + + + 1 + + + + + + + + + t + + m + + + + + + alpha_m + + + 1 + m + + + + + beta_m + m + + + + + + + + + + + + + + + alpha_h + + + 0.17 + + + + + + + + + V + 90 + + + 20 + + + + + + + beta_h + + + 1.00 + + + 1 + + + + + + + + + V + 42 + + + 10 + + + + + + + + + + + t + + h + + + + + + alpha_h + + + 1 + h + + + + + beta_h + h + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/Noble62_parameters.cellml b/models/noble_1962/Noble62_parameters.cellml new file mode 100644 index 0000000..fbe1a1f --- /dev/null +++ b/models/noble_1962/Noble62_parameters.cellml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/models/noble_1962/Noble62_units.cellml b/models/noble_1962/Noble62_units.cellml new file mode 100644 index 0000000..ddd47f5 --- /dev/null +++ b/models/noble_1962/Noble62_units.cellml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/Noble_1962.cellml b/models/noble_1962/Noble_1962.cellml new file mode 100644 index 0000000..6e4fd9d --- /dev/null +++ b/models/noble_1962/Noble_1962.cellml @@ -0,0 +1,484 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + + V + + + + + + + + i_Na + i_K + i_L + + + Cm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Catherine Lloyd + + + Journal of Physiology + + + D + Noble + + + 1962-01-01 + + + 14480151 + + + + + + + + + A Modification of the Hodgkin-Huxley Equations Applicable to Purkinje Fibre Action and Pace-Maker Potentials + 160 + 317 + + + + + + + 352 + + + + + + This is the CellML description of Noble's 1962 mathematical model of Purkinje fibre action and pace-maker potentials. The equations formulated by Hodgkin and Huxley (1952) to describe the electrical activity of squid nerve have been modified to describe the action and pace-maker potentials of the Purkinje fibres of the heart. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/Noble_1962.sedml b/models/noble_1962/Noble_1962.sedml new file mode 100644 index 0000000..621e6f1 --- /dev/null +++ b/models/noble_1962/Noble_1962.sedml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + xVariable2_2 + + + + + + + + yVariable2_2 + + + + + + + + xVariable3_1 + + + + + + + + yVariable3_1 + + + + + + + + xVariable4_1 + + + + + + + + yVariable4_1 + + + + + + + + xVariable4_2 + + + + + + + + yVariable4_2 + + + + + + + + xVariable5_1 + + + + + + + + yVariable5_1 + + + + + + + + xVariable5_2 + + + + + + + + yVariable5_2 + + + + + + + + xVariable6_1 + + + + + + + + yVariable6_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/README.rst b/models/noble_1962/README.rst new file mode 100644 index 0000000..0f9a6ad --- /dev/null +++ b/models/noble_1962/README.rst @@ -0,0 +1,46 @@ +Models for the Tutorial on CellML, OpenCOR & the Physiome Model Repository +========================================================================== + +In this workspace we have the model and simulation experiment descriptions for the examples used in the tutorial on CellML, OpenCOR & the Physiome Model Repository created by Peter Hunter. The latest version of the tutorial itself is available at: http://tutorial-on-cellml-opencor-and-pmr.readthedocs.org/. This tutorial is also utilised as part of the `Computational Physiology `_ module of the `MedTech CoRE `_ `Doctoral Training Program `_. + +While the tutorial often leads the reader through creating these models from the beginning, here we provide the complete models and associated simulation experiments. As expected from the title of the tutorial, the models themselves are encoded in the `CellML `_ format. The simulation experiments are encoded in the `SED-ML `_ format and where possible we link directly to them to enable the user to simply launch them directly in `OpenCOR `_ from the repository (and also from within the tutorial documentation). + +.. contents:: + :backlinks: top + +Van der Pol oscillator +---------------------- + +Used in the *Create and run a simple CellML model: editing and simulation* section of the tutorial, the classical `Van der Pol oscillator `_ is the first model described in the tutorial. The simulation experiment for this model described in the tutorial can be obtained by loading the `corresponding SED-ML document `__ into OpenCOR and executing the simulation. The results of which are shown below. + +.. image:: screenshots/vanderpol.png + :width: 85% + :alt: Screenshot illustrating the results of executing the Van der Pol simulation experiment in OpenCOR. + +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 `_. One of the simulation experiments for this model described in the tutorial can be obtained by loading the `corresponding SED-ML document `__ into OpenCOR and executing the simulation. + +The Lorenz attractor +-------------------- + +The `Lorenz attractor `__ model is used in the tutorial as both an example of interesting dynamics and an illustration of the encoding of a third order differential equation as `three first order equations `__ in CellML. The figure below illustrates the results obtain by loading the `corresponding SED-ML document `__ into OpenCOR and executing the simulation. + +.. image:: screenshots/lorenz.png + :width: 85% + :alt: Screenshot illustrating the results of executing the Lorenz attractor simulation experiment in OpenCOR. + +Gating kinetics explained +------------------------- + +The *A model of ion channel gating and current: Introducing CellML units* section in the tutorial introduces the concept of units in CellML models, and along the way provides an explanation of gating kinetics that are common when investigating ion channel behaviour (at least those channels which are voltage senstitive). As such, `this model `__ provides a neat little toy for investigating the formulation of traditional ion channel models. Once again, the `corresponding SED-ML document `__ is available to help get the reader started. + +The Hodgkin & Huxley potassium and sodium channels +-------------------------------------------------- + +In the tutorial, the Hodgkin & Huxley `potassium channel `__ and `sodium channel `__ are used as the examples illustrating core CellML concepts. As these models get more complex, they are also a great example demonstrating the utility of providing SED-ML alongside the model, as shown with the results presented in the figure below. + +.. image:: screenshots/potassium_channel.png + :width: 85% + :alt: Screenshot illustrating the results of executing this potassium simulation experiment in OpenCOR. diff --git a/models/noble_1962/SimpleFirstOrderEqn.cellml b/models/noble_1962/SimpleFirstOrderEqn.cellml new file mode 100644 index 0000000..55a94da --- /dev/null +++ b/models/noble_1962/SimpleFirstOrderEqn.cellml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + + y + + + + + + alpha_y + + + 1 + y + + + + + beta_y + y + + + + + + i_y + + + g_y + + + y + gamma + + + + V + E_y + + + + + + diff --git a/models/noble_1962/SimpleFirstOrderEqn.rst b/models/noble_1962/SimpleFirstOrderEqn.rst new file mode 100644 index 0000000..9a0f615 --- /dev/null +++ b/models/noble_1962/SimpleFirstOrderEqn.rst @@ -0,0 +1,14 @@ +Gating kinetics explained +------------------------- + +The *A model of ion channel gating and current: Introducing CellML units* section in the tutorial introduces the concept of units in CellML models, and along the way provides an explanation of gating kinetics that are common when investigating ion channel behaviour (at least those channels which are voltage senstitive). As such, `this model `__ provides a neat little toy for investigating the formulation of traditional ion channel models. + +Once again, the `corresponding SED-ML document `__ is available to help get the reader started. The results of this simulation are shown in the figure below. + +.. figure:: screenshots/simplefirstordereqn.png + :figwidth: 85% + :alt: Screenshot illustrating the results of executing this first order equation simulation experiment in OpenCOR. + + A screenshot illustrating the results when the associated SED-ML document is loaded into OpenCOR and the simulation executed. + + This can be reproduced directly from the repository by choosing the **Launch with OpenCOR** link from the *Views Available*. \ No newline at end of file diff --git a/models/noble_1962/SimpleFirstOrderEqn.sedml b/models/noble_1962/SimpleFirstOrderEqn.sedml new file mode 100644 index 0000000..6c14019 --- /dev/null +++ b/models/noble_1962/SimpleFirstOrderEqn.sedml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/leakage_ion_channel.cellml b/models/noble_1962/leakage_ion_channel.cellml new file mode 100644 index 0000000..3203af4 --- /dev/null +++ b/models/noble_1962/leakage_ion_channel.cellml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + + V + + 1 + + + + + + + + + + + + i_L + + + g_L + + + V + E_L + + + + + + + + + + diff --git a/models/noble_1962/lorenz.cellml b/models/noble_1962/lorenz.cellml new file mode 100644 index 0000000..1128c13 --- /dev/null +++ b/models/noble_1962/lorenz.cellml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + t + + x + + + + sigma + + + y + x + + + + + + + + + t + + y + + + + + + x + + + rho + z + + + y + + + + + + + + t + + z + + + + + + x + y + + + + beta + z + + + + + + diff --git a/models/noble_1962/lorenz.rst b/models/noble_1962/lorenz.rst new file mode 100644 index 0000000..4388098 --- /dev/null +++ b/models/noble_1962/lorenz.rst @@ -0,0 +1,12 @@ +The Lorenz attractor +-------------------- + +The `Lorenz attractor `__ model is used as both an example of interesting dynamics and an illustration of the encoding of a third order differential equation as `three first order equations `__ in CellML. The figure below illustrates the results obtain by loading the `corresponding SED-ML document `__ into OpenCOR and executing the simulation. + +.. figure:: screenshots/lorenz.png + :figwidth: 85% + :alt: Screenshot illustrating the results of executing the Lorenz attractor simulation experiment in OpenCOR. + + A screenshot illustrating the results when the associated SED-ML document is loaded into OpenCOR and the simulation executed. + + This can be reproduced directly from the repository by choosing the **Launch with OpenCOR** link from the *Views Available*. \ No newline at end of file diff --git a/models/noble_1962/lorenz.sedml b/models/noble_1962/lorenz.sedml new file mode 100644 index 0000000..52c9782 --- /dev/null +++ b/models/noble_1962/lorenz.sedml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + xVariable3_1 + + + + + + + + yVariable3_1 + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/potassium_ion_channel.cellml b/models/noble_1962/potassium_ion_channel.cellml new file mode 100644 index 0000000..b4a52c7 --- /dev/null +++ b/models/noble_1962/potassium_ion_channel.cellml @@ -0,0 +1,258 @@ + + + + + + HH potassium ion channel model + + + + + keyword + + + protein module + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + V + + + + + 85.0 + + + + + + t + 5 + + + + t + 15 + + + + + 0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + E_K + + + RTF + + + + + Ko + Ki + + + + + + + K_conductance + + + g_K + + + n + 4 + + + + + + i_K + + + K_conductance + + + V + E_K + + + + + + + + + + + + + + + alpha_n + + + + + 0.01 + + + V + 10 + + + + + + + + + + + V + 10 + + 10 + + + 1 + + + + + + beta_n + + + 0.125 + + + + + V + 80 + + + + + + + + + + t + + n + + + + + + alpha_n + + + 1 + n + + + + + beta_n + n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/potassium_ion_channel.rst b/models/noble_1962/potassium_ion_channel.rst new file mode 100644 index 0000000..04e00ff --- /dev/null +++ b/models/noble_1962/potassium_ion_channel.rst @@ -0,0 +1,12 @@ +The HH potassium channel +------------------------ + +In the tutorial, the `Hodgkin & Huxley potassium channel `__ is used as the example illustrating the core concepts of components and connections in CellML. It is also a great example demonstrating the utility of `providing SED-ML alongside the model `__, as shown with the results presented in the figure below. + +.. figure:: screenshots/potassium_channel.png + :figwidth: 85% + :alt: Screenshot illustrating the results of executing this potassium simulation experiment in OpenCOR. + + A screenshot illustrating the results when the associated SED-ML document is loaded into OpenCOR and the simulation executed. + + This can be reproduced directly from the repository by choosing the **Launch with OpenCOR** link from the *Views Available*. \ No newline at end of file diff --git a/models/noble_1962/potassium_ion_channel.sedml b/models/noble_1962/potassium_ion_channel.sedml new file mode 100644 index 0000000..8e9a7ad --- /dev/null +++ b/models/noble_1962/potassium_ion_channel.sedml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + xVariable3_1 + + + + + + + + yVariable3_1 + + + + + + + + xVariable4_1 + + + + + + + + yVariable4_1 + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/screenshots/lorenz.png b/models/noble_1962/screenshots/lorenz.png new file mode 100644 index 0000000..b9fa2ad Binary files /dev/null and b/models/noble_1962/screenshots/lorenz.png differ diff --git a/models/noble_1962/screenshots/potassium_channel.png b/models/noble_1962/screenshots/potassium_channel.png new file mode 100644 index 0000000..7ea9d64 Binary files /dev/null and b/models/noble_1962/screenshots/potassium_channel.png differ diff --git a/models/noble_1962/screenshots/simplefirstordereqn.png b/models/noble_1962/screenshots/simplefirstordereqn.png new file mode 100644 index 0000000..a44d8dd Binary files /dev/null and b/models/noble_1962/screenshots/simplefirstordereqn.png differ diff --git a/models/noble_1962/screenshots/sodium_channel.png b/models/noble_1962/screenshots/sodium_channel.png new file mode 100644 index 0000000..5540d0a Binary files /dev/null and b/models/noble_1962/screenshots/sodium_channel.png differ diff --git a/models/noble_1962/screenshots/vanderpol.png b/models/noble_1962/screenshots/vanderpol.png new file mode 100644 index 0000000..a21ea5f Binary files /dev/null and b/models/noble_1962/screenshots/vanderpol.png differ diff --git a/models/noble_1962/sodium_ion_channel.cellml b/models/noble_1962/sodium_ion_channel.cellml new file mode 100644 index 0000000..e442865 --- /dev/null +++ b/models/noble_1962/sodium_ion_channel.cellml @@ -0,0 +1,328 @@ + + + + + + HH sodium ion channel model + + + + + keyword + + + protein module + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + V + + + 0.0 + + + + + t + 5 + + + + t + 15 + + + + + + + 85.0 + + + + + + + + + + + + + + + + + + + + + + + + + + Na_conductance + + + g_Na + + + m + 3 + + h + + + + + i_Na + + + Na_conductance + + + V + E_Na + + + + + + + + + + + + + + + alpha_m + + + + + + + 0.1 + + + + V + 50 + + + + + + + + + + + + + V + 50 + + + 10 + + + 1 + + + + + + beta_m + + + 4 + + + + + + + + + V + 75 + + + 18 + + + + + + + + + + t + + m + + + + + + alpha_m + + + 1 + m + + + + + beta_m + m + + + + + + + + + + + + + + + alpha_h + + + 0.07 + + + + + + + + + V + 75 + + + 20 + + + + + + + beta_h + + + 1 + + + + + + + + + + + V + 45 + + + 10 + + + 1 + + + + + + + + + t + + h + + + + + + alpha_h + + + 1 + h + + + + + beta_h + h + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/sodium_ion_channel.rst b/models/noble_1962/sodium_ion_channel.rst new file mode 100644 index 0000000..963e485 --- /dev/null +++ b/models/noble_1962/sodium_ion_channel.rst @@ -0,0 +1,12 @@ +The HH sodium channel +--------------------- + +In the tutorial, the `Hodgkin & Huxley sodium channel `__ is used as the example illustrating the core concepts of encapsulation and interfaces in CellML. It is also a great example demonstrating the utility of `providing SED-ML alongside the model `__, as shown with the results presented in the figure below. + +.. figure:: screenshots/sodium_channel.png + :figwidth: 85% + :alt: Screenshot illustrating the results of executing this sodium simulation experiment in OpenCOR. + + A screenshot illustrating the results when the associated SED-ML document is loaded into OpenCOR and the simulation executed. + + This can be reproduced directly from the repository by choosing the **Launch with OpenCOR** link from the *Views Available*. \ No newline at end of file diff --git a/models/noble_1962/sodium_ion_channel.sedml b/models/noble_1962/sodium_ion_channel.sedml new file mode 100644 index 0000000..8ee1588 --- /dev/null +++ b/models/noble_1962/sodium_ion_channel.sedml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + xVariable3_1 + + + + + + + + yVariable3_1 + + + + + + + + xVariable4_1 + + + + + + + + yVariable4_1 + + + + + + + + xVariable5_1 + + + + + + + + yVariable5_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/models/noble_1962/vanderpol.cellml b/models/noble_1962/vanderpol.cellml new file mode 100644 index 0000000..70d112a --- /dev/null +++ b/models/noble_1962/vanderpol.cellml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + t + + x + + y + + + + + + + t + + y + + + + + + mu + + + 1 + + + x + 2 + + + y + + x + + + + + diff --git a/models/noble_1962/vanderpol.rst b/models/noble_1962/vanderpol.rst new file mode 100644 index 0000000..cf4a160 --- /dev/null +++ b/models/noble_1962/vanderpol.rst @@ -0,0 +1,12 @@ +Van der Pol oscillator +---------------------- + +Used in the *Create and run a simple CellML model: editing and simulation* section of the tutorial, the classical `Van der Pol oscillator `_ is the first model described in the tutorial. The simulation experiment for this model described in the tutorial can be obtained by loading the `corresponding SED-ML document `_ into OpenCOR and executing the simulation. The results of which are shown below. A rendering of the mathematical model itself is available `here `_. + +.. figure:: screenshots/vanderpol.png + :figwidth: 85% + :alt: Screenshot illustrating the results of executing the Van der Pol simulation experiment in OpenCOR. + + A screenshot illustrating the results when the associated SED-ML document is loaded into OpenCOR and the simulation executed. + + This can be reproduced directly from the repository by choosing the **Launch with OpenCOR** link from the *Views Available*. \ No newline at end of file diff --git a/models/noble_1962/vanderpol.sedml b/models/noble_1962/vanderpol.sedml new file mode 100644 index 0000000..d726bac --- /dev/null +++ b/models/noble_1962/vanderpol.sedml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + xVariable1_1 + + + + + + + + yVariable1_1 + + + + + + + + xVariable2_1 + + + + + + + + yVariable2_1 + + + + + + + + xVariable3_1 + + + + + + + + yVariable3_1 + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CellMLToolkit.jl b/src/CellMLToolkit.jl index d50ca6e..f0479d6 100644 --- a/src/CellMLToolkit.jl +++ b/src/CellMLToolkit.jl @@ -7,10 +7,6 @@ using SymbolicUtils: FnType, Sym, operation, arguments using EzXML using Memoize -# include("utils.jl") -# export curl_exposures - -# include("cellml.jl") include("structures.jl") include("accessors.jl") include("components.jl") diff --git a/src/components.jl b/src/components.jl index 9afdb8e..36ea7f1 100644 --- a/src/components.jl +++ b/src/components.jl @@ -4,6 +4,9 @@ const cellml_ns(xml::EzXML.Document) = namespace(root(xml)) const cellml_ns(node::EzXML.Node) = namespace(node) const mathml_ns = "http://www.w3.org/1998/Math/MathML" +# create_var(x) = Num(Sym{Real}(Symbol(x))).val # Num(Variable(Symbol(x))).val +# create_var(x, iv) = Num(Sym{Symbolics.FnType{Tuple{Any},Real}}(Symbol(x)))(iv).val # Num(Variable{Symbolics.FnType{Tuple{Any},Real}}(Symbol(x)))(iv).val + create_var(x) = Num(Variable(Symbol(x))).val create_var(x, iv) = Num(Variable{Symbolics.FnType{Tuple{Any},Real}}(Symbol(x)))(iv).val @@ -12,16 +15,28 @@ function create_param(x) ModelingToolkit.toparam(p) end +# function create_var(x) +# @variables v +# ModelingToolkit.rename(v.val, Symbol(x)) +# end +# +# function create_var(x, iv) +# @variables v(iv) +# ModelingToolkit.rename(v.val, Symbol(x)) +# end +# +# function create_param(x) +# @parameters p +# ModelingToolkit.rename(p.val, Symbol(x)) +# end + to_symbol(x::Symbol) = x to_symbol(x::AbstractString) = Symbol(x) to_symbol(x::EzXML.Node) = Symbol(x["name"]) to_symbol(comp::Component) = comp.name """ - find_iv finds the unique independent variable - - Note: We assume iv is stable and use Currying to cache the result. - However, doc is potentially mutable. Be careful! + find_iv finds the unique independent variable """ find_iv(doc::Document) = infer_iv(doc)[:β] @@ -260,7 +275,7 @@ end comp in the name of the component class is the output of classify_variables """ -function process_component(doc::Document, comp, class) +function process_component(doc::Document, comp, class) math = list_component_math(comp) pre_sub = pre_substitution(doc, comp, class) diff --git a/test/noble_1962.jl b/test/noble_1962.jl new file mode 100644 index 0000000..5fdd818 --- /dev/null +++ b/test/noble_1962.jl @@ -0,0 +1,10 @@ +path = @__DIR__ +ml = CellModel(path * "/../models/noble_1962/Noble_1962.cellml") + +prob = ODEProblem(ml, (0,10000.0)) +sol1 = solve(prob, Euler(), dt=0.01, saveat=1.0) +sol2 = solve(prob, TRBDF2(), dtmax=0.5, saveat=1.0) +V1 = map(x -> x[2], sol1.u) +V2 = map(x -> x[2], sol2.u) +err = sum(abs.(V1 .- V2)) / length(V1) +@test err < 1.0 diff --git a/test/runtests.jl b/test/runtests.jl index 60456c2..dc7ac5e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,4 +5,5 @@ using ModelingToolkit @testset "CellMLToolkit.jl" begin @testset "beeler.jl" begin include("beeler.jl") end -end \ No newline at end of file + @testset "noble_1962.jl" begin include("noble_1962.jl") end +end