From abc5b2cf06fa17bbf45561fab485a44d8c2b245b Mon Sep 17 00:00:00 2001 From: Niclas Garan Date: Sun, 29 Oct 2023 01:43:36 +0200 Subject: [PATCH] fix interactive path diagram --- environment.yml | 1 + reactors/interactive_path_diagram.ipynb | 95 ++++++++----------------- 2 files changed, 32 insertions(+), 64 deletions(-) diff --git a/environment.yml b/environment.yml index 188c811..6ed4bc1 100644 --- a/environment.yml +++ b/environment.yml @@ -11,3 +11,4 @@ dependencies: - seaborn - coolprop - scikits.odes + - python-graphviz diff --git a/reactors/interactive_path_diagram.ipynb b/reactors/interactive_path_diagram.ipynb index 624f816..c579fb7 100644 --- a/reactors/interactive_path_diagram.ipynb +++ b/reactors/interactive_path_diagram.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 16, "metadata": { "tags": [] }, @@ -20,7 +20,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Using Cantera version: 2.6.0a4\n" + "Using Cantera version: 2.6.0\n" ] } ], @@ -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", @@ -50,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": { "tags": [] }, @@ -73,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "metadata": { "tags": [] }, @@ -91,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "metadata": { "tags": [] }, @@ -109,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 8, "metadata": { "tags": [] }, @@ -130,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "metadata": { "tags": [] }, @@ -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": {}, @@ -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)" ] }, { @@ -218,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": { "tags": [] }, @@ -240,7 +237,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": { "tags": [] }, @@ -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", @@ -348,7 +330,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": { "tags": [] }, @@ -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", @@ -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": { @@ -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": { @@ -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": { @@ -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": { @@ -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": { @@ -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": {