Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a Lorenz CellML and SED-ML files, as well as a corresponding Py…
…thon script and Jupyter notebook. The idea of the Python script will be to test all of our Python wrappers.
- Loading branch information
Showing
4 changed files
with
523 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import OpenCOR as oc" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"s = oc.openSimulation('../sedml/lorenz/lorenz.sedml')\n", | ||
"s" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"s.run()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"r = s.results()\n", | ||
"r" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"states = r.states()\n", | ||
"states" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"x = states['main/x'].values()\n", | ||
"y = states['main/y'].values()\n", | ||
"z = states['main/z'].values()\n", | ||
"x,y,z" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline\n", | ||
"from mpl_toolkits import mplot3d\n", | ||
"import matplotlib.pyplot as plt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plt.axes(projection='3d').plot3D(x, y, z)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "OpenCOR", | ||
"language": "python", | ||
"name": "opencor" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Open our Lorenz SED-ML document | ||
|
||
import os | ||
import OpenCOR as oc | ||
|
||
s = oc.openSimulation(os.path.dirname(__file__) + '/../sedml/lorenz/lorenz.sedml') | ||
|
||
print('---------------------------------------') | ||
print('Simulation:') | ||
print(s) | ||
|
||
# Run our Lorenz simulation | ||
|
||
s.run() | ||
|
||
# Retrieve our simulation results | ||
|
||
r = s.results() | ||
|
||
print('---------------------------------------') | ||
print('Results:') | ||
print(r) | ||
|
||
# Retrieve our states | ||
|
||
states = r.states() | ||
|
||
print('---------------------------------------') | ||
print('States:') | ||
print(states) | ||
|
||
# Retrieve the values for our states | ||
|
||
x = states['main/x'].values() | ||
y = states['main/y'].values() | ||
z = states['main/z'].values() | ||
|
||
print('---------------------------------------') | ||
print('x, y and z:') | ||
print(x, y, z) | ||
|
||
# Generate a 3D plot for our states | ||
|
||
from mpl_toolkits import mplot3d | ||
import matplotlib.pyplot as plt | ||
|
||
plt.axes(projection='3d').plot3D(x, y, z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version='1.0'?> | ||
<model name="Lorenz" xmlns="http://www.cellml.org/cellml/1.0#" xmlns:cellml="http://www.cellml.org/cellml/1.0#"> | ||
<component name="main"> | ||
<variable initial_value="0" name="t" units="dimensionless"/> | ||
<variable initial_value="1" name="x" units="dimensionless"/> | ||
<variable initial_value="1" name="y" units="dimensionless"/> | ||
<variable initial_value="1" name="z" units="dimensionless"/> | ||
<variable initial_value="10" name="sigma" units="dimensionless"/> | ||
<variable initial_value="28" name="rho" units="dimensionless"/> | ||
<variable initial_value="2.66667" name="beta" units="dimensionless"/> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<apply> | ||
<eq/> | ||
<apply> | ||
<diff/> | ||
<bvar> | ||
<ci>t</ci> | ||
</bvar> | ||
<ci>x</ci> | ||
</apply> | ||
<apply> | ||
<times/> | ||
<ci>sigma</ci> | ||
<apply> | ||
<minus/> | ||
<ci>y</ci> | ||
<ci>x</ci> | ||
</apply> | ||
</apply> | ||
</apply> | ||
<apply> | ||
<eq/> | ||
<apply> | ||
<diff/> | ||
<bvar> | ||
<ci>t</ci> | ||
</bvar> | ||
<ci>y</ci> | ||
</apply> | ||
<apply> | ||
<minus/> | ||
<apply> | ||
<times/> | ||
<ci>x</ci> | ||
<apply> | ||
<minus/> | ||
<ci>rho</ci> | ||
<ci>z</ci> | ||
</apply> | ||
</apply> | ||
<ci>y</ci> | ||
</apply> | ||
</apply> | ||
<apply> | ||
<eq/> | ||
<apply> | ||
<diff/> | ||
<bvar> | ||
<ci>t</ci> | ||
</bvar> | ||
<ci>z</ci> | ||
</apply> | ||
<apply> | ||
<minus/> | ||
<apply> | ||
<times/> | ||
<ci>x</ci> | ||
<ci>y</ci> | ||
</apply> | ||
<apply> | ||
<times/> | ||
<ci>beta</ci> | ||
<ci>z</ci> | ||
</apply> | ||
</apply> | ||
</apply> | ||
</math> | ||
</component> | ||
</model> |
Oops, something went wrong.