Skip to content

Commit

Permalink
fix interactive path diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
Naikless committed Oct 29, 2023
1 parent 104245f commit 8e2637c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 65 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dependencies:
- seaborn
- coolprop
- scikits.odes
- python-graphviz
97 changes: 32 additions & 65 deletions reactors/interactive_path_diagram.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 16,
"metadata": {
"tags": []
},
Expand All @@ -20,7 +20,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Using Cantera version: 2.6.0a4\n"
"Using Cantera version: 2.6.0\n"
]
}
],
Expand All @@ -29,6 +29,7 @@
"from ipywidgets import widgets, interact\n",
"import cantera as ct\n",
"import numpy as np\n",
"import graphviz\n",
"\n",
"%matplotlib inline\n",
"%config InlineBackend.figure_formats = [\"svg\"]\n",
Expand All @@ -50,7 +51,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"metadata": {
"tags": []
},
Expand All @@ -73,13 +74,13 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"gas.TPX = 1550.0, 6.5 * ct.one_atm, \"CH4:3.29, C2H6:0.21, O2:7 , Ar:89.5\""
"gas.TPX = 1550.0, 30 * ct.one_atm, f\"C2H4:{28.5/3*0.8}, O2:28.5 , N2:{100-28.5}\""
]
},
{
Expand All @@ -91,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 7,
"metadata": {
"tags": []
},
Expand All @@ -109,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {
"tags": []
},
Expand All @@ -130,7 +131,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {
"tags": []
},
Expand Down Expand Up @@ -158,18 +159,18 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e73efe770a6a424aab889d76a70ea2d4",
"model_id": "e9eb8420e3d1441d8dacca916d65ccea",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=100, description='plot_step', max=1510, step=10), FloatSlider(value=0.1,…"
"interactive(children=(IntSlider(value=100, description='plot_step', max=1730, step=10), FloatSlider(value=0.1,…"
]
},
"metadata": {},
Expand Down Expand Up @@ -200,12 +201,8 @@
" diagram.threshold = threshold\n",
"\n",
" diagram.show_details = details\n",
" dot_file = \"reaction_paths.dot\"\n",
" png_file = \"reaction_paths.png\"\n",
" diagram.write_dot(dot_file)\n",
" subprocess.run(f\"dot {dot_file} -Tpng -o{png_file} -Gdpi=100\".split())\n",
" img = Image(filename=png_file)\n",
" display(img)"
" graph = graphviz.Source(diagram.get_dot())\n",
" display(graph)"
]
},
{
Expand All @@ -218,7 +215,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"tags": []
},
Expand All @@ -240,7 +237,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"tags": []
},
Expand Down Expand Up @@ -274,24 +271,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f389251a70744d52b493b85eae3e909f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.01, description='annotation_cutoff', max=4.0, min=0.01), Output()), …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"@interact(\n",
" annotation_cutoff=widgets.FloatSlider(value=1e-2, min=1e-2, max=4, steps=10),\n",
Expand Down Expand Up @@ -348,7 +330,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {
"tags": []
},
Expand All @@ -374,24 +356,9 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8a6a58db99d7422790a30e3f448189c2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatLogSlider(value=1e-05, description='annotation_cutoff', max=-4.0, min=-5.0), Output…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"@interact(\n",
" annotation_cutoff=widgets.FloatLogSlider(\n",
Expand Down Expand Up @@ -437,7 +404,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.8.12"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down Expand Up @@ -528,9 +495,9 @@
"description": "annotation_cutoff",
"layout": "IPY_MODEL_b31e0f2f2acb403b83a084fb18495310",
"max": 0.0001,
"min": 1e-06,
"min": 0.000001,
"step": 0.1,
"value": 1e-06
"value": 0.000001
}
},
"11d4490fa73f470fa12134bdbe95172f": {
Expand Down Expand Up @@ -791,9 +758,9 @@
"description": "annotation_cutoff",
"layout": "IPY_MODEL_cebcfa314a17448385e00d23be4e1132",
"max": 0.0001,
"min": 1e-06,
"min": 0.000001,
"step": 0.1,
"value": 1e-06
"value": 0.000001
}
},
"549874ce98c54398bdb34b108c543913": {
Expand Down Expand Up @@ -941,9 +908,9 @@
"description": "annotation_cutoff",
"layout": "IPY_MODEL_410cc700779545278ab29d6bdb515078",
"max": 0.0001,
"min": 1e-06,
"min": 0.000001,
"step": 0.1,
"value": 1e-06
"value": 0.000001
}
},
"6c48772d2156460e98f2d2e53d19ce7d": {
Expand All @@ -956,9 +923,9 @@
"description": "annotation_cutoff",
"layout": "IPY_MODEL_d46402fffd6243a58b1eab788b948adc",
"max": 0.1,
"min": 1e-05,
"min": 0.00001,
"step": 0.1,
"value": 1e-05
"value": 0.00001
}
},
"6db5fd30b2f7461ca1cc5547b1330a98": {
Expand Down Expand Up @@ -1527,9 +1494,9 @@
"description": "annotation_cutoff",
"layout": "IPY_MODEL_466f3c1486704068ac57d20e554de8cf",
"max": 0.1,
"min": 1e-05,
"min": 0.00001,
"step": 0.1,
"value": 1e-05
"value": 0.00001
}
},
"ce95d34031c1420abab17b1f372f6edc": {
Expand Down

0 comments on commit 8e2637c

Please sign in to comment.