From d7dee2e5799c5a11f844e8bc37fc55ba3c691119 Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Tue, 19 Mar 2019 11:43:25 -0400 Subject: [PATCH] Update Notebooks for more recent Cantera version Use 2.5.0a2 (git hash 471041a2) to run the examples. Update some formatting in comments and docstrings. Move imports to the top of Notebooks. Set the matplotlib magic before importing matplotlib. Fix deprecation warnings from Pandas about argmax and set_value. --- ...lame_speed_with_sensitivity_analysis.ipynb | 498 ++++--- flames/twin_premixed_flame_axisymmetric.ipynb | 529 ++++---- python_tutorial.ipynb | 724 +++++----- reactors/NonIdealShockTube.ipynb | 1200 ++++++++++++++--- .../batch_reactor_ignition_delay_NTC.ipynb | 225 ++-- reactors/stirred_reactor.ipynb | 322 +++-- thermo/flame_temperature.ipynb | 75 +- thermo/heating_value.ipynb | 16 +- 8 files changed, 2197 insertions(+), 1392 deletions(-) diff --git a/flames/flame_speed_with_sensitivity_analysis.ipynb b/flames/flame_speed_with_sensitivity_analysis.ipynb index 6c05f6a..4edec9d 100644 --- a/flames/flame_speed_with_sensitivity_analysis.ipynb +++ b/flames/flame_speed_with_sensitivity_analysis.ipynb @@ -35,15 +35,13 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Running Cantera Version: 2.3.0a3\n" + "Running Cantera Version: 2.5.0a2\n" ] } ], @@ -57,6 +55,32 @@ "print(\"Running Cantera Version: \" + str(ct.__version__))" ] }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# Import plotting modules and define plotting preference\n", + "%matplotlib notebook\n", + "import matplotlib.pylab as plt\n", + "\n", + "plt.rcParams['axes.labelsize'] = 14\n", + "plt.rcParams['xtick.labelsize'] = 12\n", + "plt.rcParams['ytick.labelsize'] = 12\n", + "plt.rcParams['legend.fontsize'] = 10\n", + "plt.rcParams['figure.figsize'] = (8,6)\n", + "\n", + "# Get the best of both ggplot and seaborn\n", + "plt.style.use('ggplot')\n", + "plt.style.use('seaborn-deep')\n", + "\n", + "plt.rcParams['figure.autolayout'] = True\n", + "\n", + "# Import Pandas for DataFrames\n", + "import pandas as pd" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -66,10 +90,8 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, + "execution_count": 3, + "metadata": {}, "outputs": [], "source": [ "#Inlet Temperature in Kelvin and Inlet Pressure in Pascals\n", @@ -95,10 +117,8 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, + "execution_count": 4, + "metadata": {}, "outputs": [], "source": [ "# Domain width in metres\n", @@ -123,10 +143,8 @@ }, { "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, + "execution_count": 5, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -137,18 +155,80 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 2.136e-05 5.446\n", + "Take 10 timesteps 2.136e-05 5.452\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0003649 4.417\n", + "Take 10 timesteps 0.0003649 4.427\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 4.871e-05 5.791\n", + "Take 10 timesteps 2.435e-05 6.061\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 2.601e-05 5.905\n", + "Take 10 timesteps 3.468e-05 5.63\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0009998 4.303\n", + "Take 10 timesteps 0.001333 4.122\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [9] point grid(s).\n", + "Expanding domain to accomodate flame thickness. New width: 0.028 m\n", + "##############################################################################\n", + "Refining grid in flame.\n", + " New points inserted after grid points 0 1 2 3 4 5 6 \n", + " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 N2O NCO NH NO NO2 O O2 OH T u \n", + "##############################################################################\n", + "\n", + "*********** Solving on 16 point grid with energy equation enabled ************\n", + "\n", + "..............................................................................\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 2.136e-05 5.751\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 4.055e-05 5.58\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 2.887e-05 5.947\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 2.055e-05 6.11\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 0.0001756 5.504\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 1.172e-05 6.764\n", + "Attempt Newton solution of steady-state problem... success.\n", + "\n", + "Problem solved on [16] point grid(s).\n", + "Expanding domain to accomodate flame thickness. New width: 0.056 m\n", + "##############################################################################\n", + "Refining grid in flame.\n", + " New points inserted after grid points 3 4 5 6 7 8 9 \n", + " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 N2O NCO NH NH2 NO NO2 O O2 OH T u \n", + "##############################################################################\n", + "\n", + "*********** Solving on 23 point grid with energy equation enabled ************\n", + "\n", + "..............................................................................\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 1.424e-05 6.312\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 3.604e-05 5.689\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 1.283e-05 6.137\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 0.0001096 5.738\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 2.601e-05 6.05\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 6.943e-06 6.869\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 7.909e-05 5.845\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 6.256e-06 6.571\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 0.0001069 5.566\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 7.61e-05 5.798\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 2.709e-05 5.646\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 0.0006942 4.499\n", + "Attempt Newton solution of steady-state problem... success.\n", + "\n", + "Problem solved on [23] point grid(s).\n", "\n", "..............................................................................\n", "grid refinement disabled.\n", @@ -158,101 +238,105 @@ "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [9] point grid(s).\n", + "Problem solved on [23] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 0 1 2 3 4 5 6 \n", - " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 N2O NCO NH NO NO2 O O2 OH T u \n", + " New points inserted after grid points 6 7 8 9 10 11 12 13 \n", + " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 N2O NCO NH NH2 NO NO2 O O2 OH T u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001709 5.099\n", - "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0003649 4.857\n", - "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 7.306e-05 5.011\n", + "Take 10 timesteps 0.0001709 5.006\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [16] point grid(s).\n", + "Problem solved on [31] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 3 4 5 6 7 8 9 10 \n", - " to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNN HCNO HCO HNCO HO2 N N2 N2O NCO NH NH2 NH3 NO NO2 O O2 OH T u \n", - "##############################################################################\n", - "\n", - "..............................................................................\n", - "Attempt Newton solution of steady-state problem... success.\n", - "\n", - "Problem solved on [24] point grid(s).\n", - "\n", - "..............................................................................\n", - "##############################################################################\n", - "Refining grid in flame.\n", - " New points inserted after grid points 4 5 6 7 8 9 10 11 12 13 14 15 20 \n", + " New points inserted after grid points 8 9 10 11 12 13 14 15 16 27 28 \n", " to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 N2O NCO NH NH2 NH3 NO NO2 O O2 OH T u \n", "##############################################################################\n", "\n", "..............................................................................\n", + "Attempt Newton solution of steady-state problem... failure. \n", + "Take 10 timesteps 7.594e-05 5.228\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [37] point grid(s).\n", + "Problem solved on [42] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 \n", + " New points inserted after grid points 12 13 14 15 16 17 18 19 20 21 40 \n", + " to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 N2O NCO NH NH2 NH3 NO NO2 O O2 OH T point 40 u \n", + "##############################################################################\n", + "\n", + "..............................................................................\n", + "Attempt Newton solution of steady-state problem... success.\n", + "\n", + "Problem solved on [53] point grid(s).\n", + "\n", + "..............................................................................\n", + "##############################################################################\n", + "Refining grid in flame.\n", + " New points inserted after grid points 15 16 17 18 19 20 21 22 23 24 25 26 27 50 \n", " to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 N2O NCO NO NO2 O O2 OH T u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [52] point grid(s).\n", + "Problem solved on [67] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 \n", + " New points inserted after grid points 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 \n", " to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HO2 N N2 NO NO2 O O2 OH T u \n", "##############################################################################\n", "\n", - "..............................................................................\n", + "..............................................................................\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [70] point grid(s).\n", + "Problem solved on [85] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 67 \n", - " to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO H H2 H2O H2O2 HCCO HCCOH HCN HCO HNCO HO2 N2 NO NO2 O O2 OH T u \n", + " New points inserted after grid points 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 \n", + " to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO H H2 H2O H2O2 HCCO HCCOH HCN HCO HNCO HO2 N2 NO2 O O2 OH T u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [99] point grid(s).\n", + "Problem solved on [113] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 28 29 30 31 32 33 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 97 \n", - " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CO CH2OH CH3 CH3CHO CH3O HCCO HCO point 97 \n", + " New points inserted after grid points 34 35 36 37 38 39 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 \n", + " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CO CH2OH CH3 CH3CHO CH3O HCCO HCO \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [129] point grid(s).\n", + "Problem solved on [142] point grid(s).\n", "\n", "..............................................................................\n", "no new points needed in flame\n", - "Flame Speed is: 37.99 cm/s\n" + "Flame Speed is: 38.22 cm/s\n" ] } ], @@ -261,7 +345,7 @@ "Su0 = flame.u[0]\n", "print(\"Flame Speed is: {:.2f} cm/s\".format(Su0*100))\n", "\n", - "#Note that the variable Su0 will also be used downsteam in the sensitivity analysis" + "# Note that the variable Su0 will also be used downsteam in the sensitivity analysis" ] }, { @@ -270,47 +354,15 @@ "source": [ "### Plot figures\n", "\n", - "Check and see if all has gone well. Plot temperature and species fractions to see" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "# Import plotting modules and define plotting preference\n", - "import matplotlib.pylab as plt\n", - "%matplotlib notebook\n", + "Check and see if all has gone well. Plot temperature and species fractions to see\n", "\n", - "plt.rcParams['axes.labelsize'] = 14\n", - "plt.rcParams['xtick.labelsize'] = 12\n", - "plt.rcParams['ytick.labelsize'] = 12\n", - "plt.rcParams['legend.fontsize'] = 10\n", - "plt.rcParams['figure.figsize'] = (8,6)\n", - "\n", - "# Get the best of both ggplot and seaborn\n", - "plt.style.use('ggplot')\n", - "plt.style.use('seaborn-deep')\n", - "\n", - "plt.rcParams['figure.autolayout'] = True" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ "#### Temperature Plot" ] }, { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -318,6 +370,7 @@ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", + "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", @@ -376,6 +429,9 @@ " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", @@ -390,7 +446,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", + " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -445,6 +501,15 @@ " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", @@ -501,8 +566,9 @@ " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", @@ -635,10 +701,10 @@ "}\n", "\n", "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n", - " var x0 = msg['x0'];\n", - " var y0 = fig.canvas.height - msg['y0'];\n", - " var x1 = msg['x1'];\n", - " var y1 = fig.canvas.height - msg['y1'];\n", + " var x0 = msg['x0'] / mpl.ratio;\n", + " var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n", + " var x1 = msg['x1'] / mpl.ratio;\n", + " var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", @@ -794,8 +860,8 @@ " this.canvas_div.focus();\n", " }\n", "\n", - " var x = canvas_pos.x;\n", - " var y = canvas_pos.y;\n", + " var x = canvas_pos.x * mpl.ratio;\n", + " var y = canvas_pos.y * mpl.ratio;\n", "\n", " this.send_message(name, {x: x, y: y, button: event.button,\n", " step: event.step,\n", @@ -855,9 +921,9 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", - "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", + "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", @@ -875,7 +941,7 @@ " // Register the callback with on_msg.\n", " comm.on_msg(function(msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", - " // Pass the mpl event to the overriden (by mpl) onmessage function.\n", + " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data'])\n", " });\n", " return ws;\n", @@ -916,6 +982,7 @@ "};\n", "\n", "mpl.figure.prototype.handle_close = function(fig, msg) {\n", + " var width = fig.canvas.width/mpl.ratio\n", " fig.root.unbind('remove')\n", "\n", " // Update the output cell to use the data from the current canvas.\n", @@ -924,7 +991,7 @@ " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable()\n", - " $(fig.parent_element).html('');\n", + " $(fig.parent_element).html('');\n", " fig.close_ws(fig, msg);\n", "}\n", "\n", @@ -935,8 +1002,9 @@ "\n", "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", + " var width = this.canvas.width/mpl.ratio\n", " var dataURL = this.canvas.toDataURL();\n", - " this.cell_info[1]['text/html'] = '';\n", + " this.cell_info[1]['text/html'] = '';\n", "}\n", "\n", "mpl.figure.prototype.updated_canvas_event = function() {\n", @@ -1079,7 +1147,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1104,12 +1172,21 @@ "#### Major species' plot" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To plot species, we first have to identify the index of the species in the array\n", + "For this, cut & paste the following lines and run in a new cell to get the index\n", + "\n", + " for i, specie in enumerate(gas.species()):\n", + " print(str(i) + '. ' + str(specie))" + ] + }, { "cell_type": "code", "execution_count": 7, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1117,6 +1194,7 @@ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", + "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", @@ -1175,6 +1253,9 @@ " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", @@ -1189,7 +1270,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", + " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -1244,6 +1325,15 @@ " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", @@ -1300,8 +1390,9 @@ " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", @@ -1434,10 +1525,10 @@ "}\n", "\n", "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n", - " var x0 = msg['x0'];\n", - " var y0 = fig.canvas.height - msg['y0'];\n", - " var x1 = msg['x1'];\n", - " var y1 = fig.canvas.height - msg['y1'];\n", + " var x0 = msg['x0'] / mpl.ratio;\n", + " var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n", + " var x1 = msg['x1'] / mpl.ratio;\n", + " var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", @@ -1593,8 +1684,8 @@ " this.canvas_div.focus();\n", " }\n", "\n", - " var x = canvas_pos.x;\n", - " var y = canvas_pos.y;\n", + " var x = canvas_pos.x * mpl.ratio;\n", + " var y = canvas_pos.y * mpl.ratio;\n", "\n", " this.send_message(name, {x: x, y: y, button: event.button,\n", " step: event.step,\n", @@ -1654,9 +1745,9 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", - "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", + "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", @@ -1674,7 +1765,7 @@ " // Register the callback with on_msg.\n", " comm.on_msg(function(msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", - " // Pass the mpl event to the overriden (by mpl) onmessage function.\n", + " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data'])\n", " });\n", " return ws;\n", @@ -1715,6 +1806,7 @@ "};\n", "\n", "mpl.figure.prototype.handle_close = function(fig, msg) {\n", + " var width = fig.canvas.width/mpl.ratio\n", " fig.root.unbind('remove')\n", "\n", " // Update the output cell to use the data from the current canvas.\n", @@ -1723,7 +1815,7 @@ " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable()\n", - " $(fig.parent_element).html('');\n", + " $(fig.parent_element).html('');\n", " fig.close_ws(fig, msg);\n", "}\n", "\n", @@ -1734,8 +1826,9 @@ "\n", "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", + " var width = this.canvas.width/mpl.ratio\n", " var dataURL = this.canvas.toDataURL();\n", - " this.cell_info[1]['text/html'] = '';\n", + " this.cell_info[1]['text/html'] = '';\n", "}\n", "\n", "mpl.figure.prototype.updated_canvas_event = function() {\n", @@ -1878,7 +1971,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1889,13 +1982,6 @@ } ], "source": [ - "\"\"\"\n", - "# To plot species, we first have to identify the index of the species in the array\n", - "# For this, cut & paste the following lines and run in a new cell to get the index\n", - "for i, specie in enumerate(gas.species()):\n", - " print(str(i) + '. ' + str(specie))\n", - "\"\"\"\n", - "\n", "# Extract concentration data\n", "X_CH4 = flame.X[13]\n", "X_CO2 = flame.X[15]\n", @@ -1921,30 +2007,10 @@ "See which reactions effect the flame speed the most" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import a data frame module. This simplifies the code" - ] - }, { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "# Create a dataframe to store sensitivity-analysis data\n", @@ -1960,10 +2026,8 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, + "execution_count": 9, + "metadata": {}, "outputs": [], "source": [ "# Set the value of the perturbation\n", @@ -1975,10 +2039,8 @@ }, { "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, + "execution_count": 10, + "metadata": {}, "outputs": [], "source": [ "for m in range(gas.n_reactions):\n", @@ -2001,15 +2063,26 @@ }, { "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, + "execution_count": 11, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", @@ -2020,23 +2093,23 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", "
2 O + M <=> O2 + M0.001549320.00156775
H + O + M <=> OH + M0.001080930.00110824
H2 + O <=> H + OH0.02516870.0252473
HO2 + O <=> O2 + OH0.003036060.00313172
H2O2 + O <=> HO2 + OH0.0007260280.000752237
\n", @@ -2044,14 +2117,14 @@ ], "text/plain": [ " baseCase\n", - "2 O + M <=> O2 + M 0.00154932\n", - "H + O + M <=> OH + M 0.00108093\n", - "H2 + O <=> H + OH 0.0251687\n", - "HO2 + O <=> O2 + OH 0.00303606\n", - "H2O2 + O <=> HO2 + OH 0.000726028" + "2 O + M <=> O2 + M 0.00156775\n", + "H + O + M <=> OH + M 0.00110824\n", + "H2 + O <=> H + OH 0.0252473\n", + "HO2 + O <=> O2 + OH 0.00313172\n", + "H2O2 + O <=> HO2 + OH 0.000752237" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -2069,10 +2142,8 @@ }, { "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, + "execution_count": 12, + "metadata": {}, "outputs": [ { "data": { @@ -2080,6 +2151,7 @@ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", + "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", @@ -2138,6 +2210,9 @@ " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", @@ -2152,7 +2227,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", + " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -2207,6 +2282,15 @@ " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", @@ -2263,8 +2347,9 @@ " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", @@ -2397,10 +2482,10 @@ "}\n", "\n", "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n", - " var x0 = msg['x0'];\n", - " var y0 = fig.canvas.height - msg['y0'];\n", - " var x1 = msg['x1'];\n", - " var y1 = fig.canvas.height - msg['y1'];\n", + " var x0 = msg['x0'] / mpl.ratio;\n", + " var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n", + " var x1 = msg['x1'] / mpl.ratio;\n", + " var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", @@ -2556,8 +2641,8 @@ " this.canvas_div.focus();\n", " }\n", "\n", - " var x = canvas_pos.x;\n", - " var y = canvas_pos.y;\n", + " var x = canvas_pos.x * mpl.ratio;\n", + " var y = canvas_pos.y * mpl.ratio;\n", "\n", " this.send_message(name, {x: x, y: y, button: event.button,\n", " step: event.step,\n", @@ -2617,9 +2702,9 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", - "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", + "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", @@ -2637,7 +2722,7 @@ " // Register the callback with on_msg.\n", " comm.on_msg(function(msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", - " // Pass the mpl event to the overriden (by mpl) onmessage function.\n", + " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data'])\n", " });\n", " return ws;\n", @@ -2678,6 +2763,7 @@ "};\n", "\n", "mpl.figure.prototype.handle_close = function(fig, msg) {\n", + " var width = fig.canvas.width/mpl.ratio\n", " fig.root.unbind('remove')\n", "\n", " // Update the output cell to use the data from the current canvas.\n", @@ -2686,7 +2772,7 @@ " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable()\n", - " $(fig.parent_element).html('');\n", + " $(fig.parent_element).html('');\n", " fig.close_ws(fig, msg);\n", "}\n", "\n", @@ -2697,8 +2783,9 @@ "\n", "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", + " var width = this.canvas.width/mpl.ratio\n", " var dataURL = this.canvas.toDataURL();\n", - " this.cell_info[1]['text/html'] = '';\n", + " this.cell_info[1]['text/html'] = '';\n", "}\n", "\n", "mpl.figure.prototype.updated_canvas_event = function() {\n", @@ -2841,7 +2928,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -2849,16 +2936,6 @@ }, "metadata": {}, "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ @@ -2882,15 +2959,6 @@ "# Uncomment the following to save the plot. A higher than usual resolution (dpi) helps\n", "# plt.savefig('sensitivityPlot', dpi=300)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], "metadata": { @@ -2909,9 +2977,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/flames/twin_premixed_flame_axisymmetric.ipynb b/flames/twin_premixed_flame_axisymmetric.ipynb index 9e9ee3b..eff73b5 100644 --- a/flames/twin_premixed_flame_axisymmetric.ipynb +++ b/flames/twin_premixed_flame_axisymmetric.ipynb @@ -31,15 +31,13 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Running Cantera Version: 2.3.0a3\n" + "Running Cantera Version: 2.5.0a2\n" ] } ], @@ -53,6 +51,25 @@ "print(\"Running Cantera Version: \" + str(ct.__version__))" ] }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "%matplotlib notebook\n", + "import matplotlib.pyplot as plt\n", + "\n", + "plt.rcParams['figure.autolayout'] = True\n", + "\n", + "plt.rcParams['axes.labelsize'] = 14\n", + "plt.rcParams['xtick.labelsize'] = 12\n", + "plt.rcParams['ytick.labelsize'] = 12\n", + "plt.rcParams['legend.fontsize'] = 10\n", + "plt.rcParams['figure.facecolor'] = 'white'\n", + "plt.rcParams['figure.figsize'] = (8,6)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -62,19 +79,17 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, + "execution_count": 3, + "metadata": {}, "outputs": [], "source": [ - "#Inlet Temperature in Kelvin and Inlet Pressure in Pascals\n", - "#In this case we are setting the inlet T and P to room temperature conditions\n", + "# Inlet Temperature in Kelvin and Inlet Pressure in Pascals\n", + "# In this case we are setting the inlet T and P to room temperature conditions\n", "To = 300\n", "Po = 101325\n", "\n", - "#Define the gas-mixutre and kinetics\n", - "#In this case, we are choosing a GRI3.0 gas\n", + "# Define the gas-mixutre and kinetics\n", + "# In this case, we are choosing a GRI3.0 gas\n", "gas = ct.Solution('gri30.cti')\n", "\n", "# Create a CH4/Air premixed mixture with equivalence ratio=0.75\n", @@ -87,7 +102,7 @@ "\n", "# Done with initial conditions\n", "# Compute the mass flux, as this is what the Flame object requires\n", - "massFlux = gas.density * axial_velocity # units kg/m2/s\n" + "massFlux = gas.density * axial_velocity # units kg/m2/s" ] }, { @@ -99,15 +114,15 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, + "execution_count": 4, + "metadata": {}, "outputs": [], "source": [ - "# Differentiation function for data that has variable grid spacing Used here to\n", - "# compute normal strain-rate\n", + "\n", "def derivative(x, y):\n", + " \"\"\"Differentiation function for data that has variable grid spacing.\n", + " Used here to compute normal strain-rate.\n", + " \"\"\"\n", " dydx = np.zeros(y.shape, y.dtype.type)\n", "\n", " dx = np.diff(x)\n", @@ -178,10 +193,8 @@ }, { "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": true - }, + "execution_count": 5, + "metadata": {}, "outputs": [], "source": [ "# Define a domain half-width of 2.5 cm, meaning the whole domain is 5 cm wide\n", @@ -192,7 +205,7 @@ "\n", "# Uncomment the following line to use a Multi-component formulation. Default is\n", "# mixture-averaged\n", - "#oppFlame.transport_model = 'Multi'" + "# oppFlame.transport_model = 'Multi'" ] }, { @@ -204,10 +217,8 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, + "execution_count": 6, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -231,155 +242,161 @@ " Pressure: 1.013e+05 Pa\n", "\n", "-------------------------------------------------------------------------------\n", - " z u V T lambda H2 \n", + " z u V T lambda eField \n", "-------------------------------------------------------------------------------\n", " 0 2 0 300 0 0 \n", " 0.005 1.6 32 300 0 0 \n", - " 0.01 1.2 64 300 0 2.06e-21 \n", - " 0.0125 1 80 1110 0 3.711e-06 \n", - " 0.015 0.8 96 1920 0 7.422e-06 \n", - " 0.02 0.4 128 1920 0 7.422e-06 \n", - " 0.025 0 160 1920 0 7.422e-06 \n", + " 0.01 1.2 64 300 0 0 \n", + " 0.0125 1 80 1110 0 0 \n", + " 0.015 0.8 96 1920 0 0 \n", + " 0.02 0.4 128 1920 0 0 \n", + " 0.025 0 160 1920 0 0 \n", "\n", "-------------------------------------------------------------------------------\n", - " z H O O2 OH H2O \n", + " z H2 H O O2 OH \n", "-------------------------------------------------------------------------------\n", - " 0 0 0 0.2232 0 0 \n", - " 0.005 0 0 0.2232 0 0 \n", - " 0.01 9.354e-23 1.216e-20 0.2232 1.907e-19 2.604e-17 \n", - " 0.0125 1.685e-07 2.191e-05 0.1386 0.0003435 0.04691 \n", - " 0.015 3.37e-07 4.382e-05 0.05403 0.0006871 0.09382 \n", - " 0.02 3.37e-07 4.382e-05 0.05403 0.0006871 0.09382 \n", - " 0.025 3.37e-07 4.382e-05 0.05403 0.0006871 0.09382 \n", + " 0 0 0 0 0.2232 0 \n", + " 0.005 0 0 0 0.2232 0 \n", + " 0.01 2.06e-21 9.354e-23 1.216e-20 0.2232 1.907e-19 \n", + " 0.0125 3.711e-06 1.685e-07 2.191e-05 0.1386 0.0003435 \n", + " 0.015 7.422e-06 3.37e-07 4.382e-05 0.05403 0.0006871 \n", + " 0.02 7.422e-06 3.37e-07 4.382e-05 0.05403 0.0006871 \n", + " 0.025 7.422e-06 3.37e-07 4.382e-05 0.05403 0.0006871 \n", "\n", "-------------------------------------------------------------------------------\n", - " z HO2 H2O2 C CH CH2 \n", + " z H2O HO2 H2O2 C CH \n", "-------------------------------------------------------------------------------\n", " 0 0 0 0 0 0 \n", " 0.005 0 0 0 0 0 \n", - " 0.01 2.619e-22 1.513e-23 1.528e-38 1.236e-39 4.048e-39 \n", - " 0.0125 4.718e-07 2.725e-08 2.753e-23 2.226e-24 7.292e-24 \n", - " 0.015 9.435e-07 5.45e-08 5.506e-23 4.452e-24 1.458e-23 \n", - " 0.02 9.435e-07 5.45e-08 5.506e-23 4.452e-24 1.458e-23 \n", - " 0.025 9.435e-07 5.45e-08 5.506e-23 4.452e-24 1.458e-23 \n", + " 0.01 2.604e-17 2.619e-22 1.513e-23 1.528e-38 1.236e-39 \n", + " 0.0125 0.04691 4.718e-07 2.725e-08 2.753e-23 2.226e-24 \n", + " 0.015 0.09382 9.435e-07 5.45e-08 5.506e-23 4.452e-24 \n", + " 0.02 0.09382 9.435e-07 5.45e-08 5.506e-23 4.452e-24 \n", + " 0.025 0.09382 9.435e-07 5.45e-08 5.506e-23 4.452e-24 \n", "\n", "-------------------------------------------------------------------------------\n", - " z CH2(S) CH3 CH4 CO CO2 \n", + " z CH2 CH2(S) CH3 CH4 CO \n", "-------------------------------------------------------------------------------\n", - " 0 0 0 0.04197 0 0 \n", - " 0.005 0 0 0.04197 0 0 \n", - " 0.01 1.788e-40 3.885e-38 0.04197 6.135e-20 3.186e-17 \n", - " 0.0125 3.22e-25 6.999e-23 0.02098 0.0001105 0.05739 \n", - " 0.015 6.441e-25 1.4e-22 0 0.0002211 0.1148 \n", - " 0.02 6.441e-25 1.4e-22 8.264e-23 0.0002211 0.1148 \n", - " 0.025 6.441e-25 1.4e-22 8.264e-23 0.0002211 0.1148 \n", + " 0 0 0 0 0.04197 0 \n", + " 0.005 0 0 0 0.04197 0 \n", + " 0.01 4.048e-39 1.788e-40 3.885e-38 0.04197 6.135e-20 \n", + " 0.0125 7.292e-24 3.22e-25 6.999e-23 0.02098 0.0001105 \n", + " 0.015 1.458e-23 6.441e-25 1.4e-22 0 0.0002211 \n", + " 0.02 1.458e-23 6.441e-25 1.4e-22 8.264e-23 0.0002211 \n", + " 0.025 1.458e-23 6.441e-25 1.4e-22 8.264e-23 0.0002211 \n", "\n", "-------------------------------------------------------------------------------\n", - " z HCO CH2O CH2OH CH3O CH3OH \n", + " z CO2 HCO CH2O CH2OH CH3O \n", "-------------------------------------------------------------------------------\n", " 0 0 0 0 0 0 \n", " 0.005 0 0 0 0 0 \n", - " 0.01 2.588e-28 2.804e-30 6.75e-37 8.315e-39 5.227e-38 \n", - " 0.0125 4.662e-13 5.052e-15 1.216e-21 1.498e-23 9.416e-23 \n", - " 0.015 9.324e-13 1.01e-14 2.432e-21 2.996e-23 1.883e-22 \n", - " 0.02 9.324e-13 1.01e-14 2.432e-21 2.996e-23 1.883e-22 \n", - " 0.025 9.324e-13 1.01e-14 2.432e-21 2.996e-23 1.883e-22 \n", + " 0.01 3.186e-17 2.588e-28 2.804e-30 6.75e-37 8.315e-39 \n", + " 0.0125 0.05739 4.662e-13 5.052e-15 1.216e-21 1.498e-23 \n", + " 0.015 0.1148 9.324e-13 1.01e-14 2.432e-21 2.996e-23 \n", + " 0.02 0.1148 9.324e-13 1.01e-14 2.432e-21 2.996e-23 \n", + " 0.025 0.1148 9.324e-13 1.01e-14 2.432e-21 2.996e-23 \n", "\n", "-------------------------------------------------------------------------------\n", - " z C2H C2H2 C2H3 C2H4 C2H5 \n", + " z CH3OH C2H C2H2 C2H3 C2H4 \n", "-------------------------------------------------------------------------------\n", " 0 0 0 0 0 0 \n", " 0.005 0 0 0 0 0 \n", - " 0.01 9.354e-48 7.624e-45 5.836e-51 9.138e-51 1.002e-56 \n", - " 0.0125 1.685e-32 1.373e-29 1.051e-35 1.646e-35 1.805e-41 \n", - " 0.015 3.37e-32 2.747e-29 2.103e-35 3.292e-35 3.61e-41 \n", - " 0.02 3.37e-32 2.747e-29 2.103e-35 3.292e-35 3.61e-41 \n", - " 0.025 3.37e-32 2.747e-29 2.103e-35 3.292e-35 3.61e-41 \n", + " 0.01 5.227e-38 9.354e-48 7.624e-45 5.836e-51 9.138e-51 \n", + " 0.0125 9.416e-23 1.685e-32 1.373e-29 1.051e-35 1.646e-35 \n", + " 0.015 1.883e-22 3.37e-32 2.747e-29 2.103e-35 3.292e-35 \n", + " 0.02 1.883e-22 3.37e-32 2.747e-29 2.103e-35 3.292e-35 \n", + " 0.025 1.883e-22 3.37e-32 2.747e-29 2.103e-35 3.292e-35 \n", "\n", "-------------------------------------------------------------------------------\n", - " z C2H6 HCCO CH2CO HCCOH N \n", + " z C2H5 C2H6 HCCO CH2CO HCCOH \n", "-------------------------------------------------------------------------------\n", " 0 0 0 0 0 0 \n", " 0.005 0 0 0 0 0 \n", - " 0.01 7.332e-58 2.1e-41 3.353e-41 1.05e-44 3.232e-26 \n", - " 0.0125 1.321e-42 3.783e-26 6.04e-26 1.892e-29 5.822e-11 \n", - " 0.015 2.641e-42 7.567e-26 1.208e-25 3.785e-29 1.164e-10 \n", - " 0.02 2.641e-42 7.567e-26 1.208e-25 3.785e-29 1.164e-10 \n", - " 0.025 2.641e-42 7.567e-26 1.208e-25 3.785e-29 1.164e-10 \n", + " 0.01 1.002e-56 7.332e-58 2.1e-41 3.353e-41 1.05e-44 \n", + " 0.0125 1.805e-41 1.321e-42 3.783e-26 6.04e-26 1.892e-29 \n", + " 0.015 3.61e-41 2.641e-42 7.567e-26 1.208e-25 3.785e-29 \n", + " 0.02 3.61e-41 2.641e-42 7.567e-26 1.208e-25 3.785e-29 \n", + " 0.025 3.61e-41 2.641e-42 7.567e-26 1.208e-25 3.785e-29 \n", "\n", "-------------------------------------------------------------------------------\n", - " z NH NH2 NH3 NNH NO \n", + " z N NH NH2 NH3 NNH \n", "-------------------------------------------------------------------------------\n", " 0 0 0 0 0 0 \n", " 0.005 0 0 0 0 0 \n", - " 0.01 2.797e-27 8.651e-28 3.559e-27 4.476e-27 8.318e-19 \n", - " 0.0125 5.038e-12 1.559e-12 6.411e-12 8.062e-12 0.001498 \n", - " 0.015 1.008e-11 3.117e-12 1.282e-11 1.612e-11 0.002997 \n", - " 0.02 1.008e-11 3.117e-12 1.282e-11 1.612e-11 0.002997 \n", - " 0.025 1.008e-11 3.117e-12 1.282e-11 1.612e-11 0.002997 \n", + " 0.01 3.232e-26 2.797e-27 8.651e-28 3.559e-27 4.476e-27 \n", + " 0.0125 5.822e-11 5.038e-12 1.559e-12 6.411e-12 8.062e-12 \n", + " 0.015 1.164e-10 1.008e-11 3.117e-12 1.282e-11 1.612e-11 \n", + " 0.02 1.164e-10 1.008e-11 3.117e-12 1.282e-11 1.612e-11 \n", + " 0.025 1.164e-10 1.008e-11 3.117e-12 1.282e-11 1.612e-11 \n", "\n", "-------------------------------------------------------------------------------\n", - " z NO2 N2O HNO CN HCN \n", + " z NO NO2 N2O HNO CN \n", "-------------------------------------------------------------------------------\n", " 0 0 0 0 0 0 \n", " 0.005 0 0 0 0 0 \n", - " 0.01 1.205e-21 6.697e-23 2.279e-24 1.185e-33 8.215e-31 \n", - " 0.0125 2.17e-06 1.206e-07 4.106e-09 2.135e-18 1.48e-15 \n", - " 0.015 4.341e-06 2.413e-07 8.212e-09 4.269e-18 2.96e-15 \n", - " 0.02 4.341e-06 2.413e-07 8.212e-09 4.269e-18 2.96e-15 \n", - " 0.025 4.341e-06 2.413e-07 8.212e-09 4.269e-18 2.96e-15 \n", + " 0.01 8.318e-19 1.205e-21 6.697e-23 2.279e-24 1.185e-33 \n", + " 0.0125 0.001498 2.17e-06 1.206e-07 4.106e-09 2.135e-18 \n", + " 0.015 0.002997 4.341e-06 2.413e-07 8.212e-09 4.269e-18 \n", + " 0.02 0.002997 4.341e-06 2.413e-07 8.212e-09 4.269e-18 \n", + " 0.025 0.002997 4.341e-06 2.413e-07 8.212e-09 4.269e-18 \n", "\n", "-------------------------------------------------------------------------------\n", - " z H2CN HCNN HCNO HOCN HNCO \n", + " z HCN H2CN HCNN HCNO HOCN \n", "-------------------------------------------------------------------------------\n", " 0 0 0 0 0 0 \n", " 0.005 0 0 0 0 0 \n", - " 0.01 1.546e-38 4.735e-42 1.504e-35 8.599e-31 7.04e-28 \n", - " 0.0125 2.785e-23 8.53e-27 2.71e-20 1.549e-15 1.268e-12 \n", - " 0.015 5.57e-23 1.706e-26 5.42e-20 3.098e-15 2.536e-12 \n", - " 0.02 5.57e-23 1.706e-26 5.42e-20 3.098e-15 2.536e-12 \n", - " 0.025 5.57e-23 1.706e-26 5.42e-20 3.098e-15 2.536e-12 \n", + " 0.01 8.215e-31 1.546e-38 4.735e-42 1.504e-35 8.599e-31 \n", + " 0.0125 1.48e-15 2.785e-23 8.53e-27 2.71e-20 1.549e-15 \n", + " 0.015 2.96e-15 5.57e-23 1.706e-26 5.42e-20 3.098e-15 \n", + " 0.02 2.96e-15 5.57e-23 1.706e-26 5.42e-20 3.098e-15 \n", + " 0.025 2.96e-15 5.57e-23 1.706e-26 5.42e-20 3.098e-15 \n", "\n", "-------------------------------------------------------------------------------\n", - " z NCO N2 AR C3H7 C3H8 \n", + " z HNCO NCO N2 AR C3H7 \n", "-------------------------------------------------------------------------------\n", - " 0 0 0.7348 0 0 0 \n", - " 0.005 0 0.7348 0 0 0 \n", - " 0.01 1.842e-29 0.7348 0 6.242e-76 4.325e-77 \n", - " 0.0125 3.319e-14 0.7341 0 1.125e-60 7.791e-62 \n", - " 0.015 6.638e-14 0.7334 0 2.249e-60 1.558e-61 \n", - " 0.02 6.638e-14 0.7334 0 2.249e-60 1.558e-61 \n", - " 0.025 6.638e-14 0.7334 0 2.249e-60 1.558e-61 \n", + " 0 0 0 0.7348 0 0 \n", + " 0.005 0 0 0.7348 0 0 \n", + " 0.01 7.04e-28 1.842e-29 0.7348 0 6.242e-76 \n", + " 0.0125 1.268e-12 3.319e-14 0.7341 0 1.125e-60 \n", + " 0.015 2.536e-12 6.638e-14 0.7334 0 2.249e-60 \n", + " 0.02 2.536e-12 6.638e-14 0.7334 0 2.249e-60 \n", + " 0.025 2.536e-12 6.638e-14 0.7334 0 2.249e-60 \n", "\n", "-------------------------------------------------------------------------------\n", - " z CH2CHO CH3CHO \n", + " z C3H8 CH2CHO CH3CHO \n", "-------------------------------------------------------------------------------\n", - " 0 0 0 \n", - " 0.005 0 0 \n", - " 0.01 1.343e-47 2.414e-48 \n", - " 0.0125 2.42e-32 4.349e-33 \n", - " 0.015 4.84e-32 8.698e-33 \n", - " 0.02 4.84e-32 8.698e-33 \n", - " 0.025 4.84e-32 8.698e-33 \n", + " 0 0 0 0 \n", + " 0.005 0 0 0 \n", + " 0.01 4.325e-77 1.343e-47 2.414e-48 \n", + " 0.0125 7.791e-62 2.42e-32 4.349e-33 \n", + " 0.015 1.558e-61 4.84e-32 8.698e-33 \n", + " 0.02 1.558e-61 4.84e-32 8.698e-33 \n", + " 0.025 1.558e-61 4.84e-32 8.698e-33 \n", "\n", "\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> products <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", "\n", "\n", "-------------------------------------------------------------------------------\n", - " z dummy \n", + " z \n", "-------------------------------------------------------------------------------\n", - " 0 0 \n", + " 0 \n", "\n", "************ Solving on 7 point grid with energy equation enabled ************\n", "\n", "..............................................................................\n", - "Attempt Newton solution of steady-state problem... failure. \n", + "Attempt Newton solution of steady-state problem... failure. \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "Take 10 timesteps 2.848e-05 5.886\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0004865 5.142\n", + "Take 10 timesteps 0.0004865 5.141\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.008313 2.22\n", + "Take 10 timesteps 0.008313 2.219\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [7] point grid(s).\n", @@ -403,9 +420,9 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001139 5.734\n", + "Take 10 timesteps 0.0001139 5.733\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.002919 3.555\n", + "Take 10 timesteps 0.002919 3.554\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [12] point grid(s).\n", @@ -419,11 +436,11 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001139 5.653\n", + "Take 10 timesteps 0.0001139 5.652\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001442 5.86\n", + "Take 10 timesteps 0.0001442 5.842\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.002463 3.926\n", + "Take 10 timesteps 0.002463 3.921\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [20] point grid(s).\n", @@ -437,7 +454,7 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001139 5.647\n", + "Take 10 timesteps 0.0001139 5.646\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [29] point grid(s).\n", @@ -451,15 +468,13 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 7.594e-05 6.151\n", + "Take 10 timesteps 7.594e-05 6.15\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001442 6.013\n", + "Take 10 timesteps 7.208e-05 6.137\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 4.561e-05 5.695\n", + "Take 10 timesteps 0.0001368 5.859\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001155 5.755\n", - "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.001973 4.03\n", + "Take 10 timesteps 0.0001732 5.516\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [39] point grid(s).\n", @@ -474,15 +489,15 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 5.695e-05 5.862\n", + "Take 10 timesteps 5.695e-05 5.868\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 7.208e-05 6.072\n", + "Take 10 timesteps 7.208e-05 6.08\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0005474 4.974\n", + "Take 10 timesteps 0.0002737 5.145\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 7.306e-05 6.124\n", + "Take 10 timesteps 0.0001948 5.71\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.001248 4.287\n", + "Take 10 timesteps 0.003329 3.349\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [45] point grid(s).\n", @@ -498,7 +513,7 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001709 5.41\n", + "Take 10 timesteps 0.0001709 5.407\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [49] point grid(s).\n", @@ -512,11 +527,11 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001139 5.784\n", + "Take 10 timesteps 0.0001139 5.78\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0005767 5.383\n", + "Take 10 timesteps 0.0005767 5.313\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0003079 5.314\n", + "Take 10 timesteps 0.0004105 5.218\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [56] point grid(s).\n", @@ -529,11 +544,17 @@ "##############################################################################\n", "refine: discarding point at 0.0179688\n", "\n", - "..............................................................................\n", + "..............................................................................\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0001709 5.61\n", + "Take 10 timesteps 0.0001709 5.602\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.001297 4.393\n", + "Take 10 timesteps 0.001297 4.467\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [63] point grid(s).\n", @@ -549,9 +570,9 @@ "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.0002563 5.356\n", + "Take 10 timesteps 0.0002563 5.243\n", "Attempt Newton solution of steady-state problem... failure. \n", - "Take 10 timesteps 0.001297 4.473\n", + "Take 10 timesteps 0.001946 4.415\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [69] point grid(s).\n", @@ -576,7 +597,7 @@ "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 52 53 54 55 56 57 58 59 60 61 \n", - " to resolve C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO H H2 H2O H2O2 HCCO HCCOH HCN HCO HO2 N2 NO2 O O2 OH T point 61 \n", + " to resolve C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO H H2 H2O H2O2 HCCO HCCOH HCN HCO HNCO HO2 N2 NO2 O O2 OH T point 61 \n", "##############################################################################\n", "refine: discarding point at 0.0196875\n", "refine: discarding point at 0.0199219\n", @@ -589,7 +610,7 @@ "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 51 52 55 56 57 58 59 60 61 62 \n", + " New points inserted after grid points 49 50 54 55 56 57 58 59 60 61 \n", " to resolve C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CO CH2OH CH3 CH3CHO CH3O HCCO HCO \n", "##############################################################################\n", "refine: discarding point at 0.0195313\n", @@ -602,8 +623,8 @@ "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 46 47 48 52 54 55 72 \n", - " to resolve C2H6 C3H8 CH3O point 52 point 72 \n", + " New points inserted after grid points 43 45 46 49 53 54 55 \n", + " to resolve C2H5 C2H6 C3H8 CH3O point 49 \n", "##############################################################################\n", "\n", "..............................................................................\n", @@ -614,18 +635,29 @@ "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", - " New points inserted after grid points 45 80 \n", - " to resolve point 45 point 80 \n", + " New points inserted after grid points 50 51 60 \n", + " to resolve CH3O point 60 \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", - "Problem solved on [100] point grid(s).\n", + "Problem solved on [101] point grid(s).\n", "\n", "..............................................................................\n", - "no new points needed in flame\n", - "Solution saved to 'premixed_twin_flame.csv'.\n" + "##############################################################################\n", + "Refining grid in flame.\n", + " New points inserted after grid points 51 \n", + " to resolve point 51 \n", + "##############################################################################\n", + "\n", + "..............................................................................\n", + "Attempt Newton solution of steady-state problem... success.\n", + "\n", + "Problem solved on [102] point grid(s).\n", + "\n", + "..............................................................................\n", + "no new points needed in flame\n" ] } ], @@ -639,24 +671,22 @@ "# is T, Y[i], etc. The spatial variable (distance in meters) is in oppFlame.grid\n", "# Thus to plot temperature vs distance, use oppFlame.grid and oppFlame.T\n", "\n", - "#This is to save output\n", - "oppFlame.write_csv(\"premixed_twin_flame.csv\", quiet=False)" + "# Uncomment this is to save output\n", + "# oppFlame.write_csv(\"premixed_twin_flame.csv\", quiet=False)" ] }, { "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, + "execution_count": 7, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Peak temperature: 1920.5 K\n", - "Strain Rate: 163.6 1/s\n", - "Consumption Speed: 20.80 cm/s\n" + "Peak temperature: 1921.0 K\n", + "Strain Rate: 163.7 1/s\n", + "Consumption Speed: 21.00 cm/s\n" ] } ], @@ -677,28 +707,6 @@ "Note that the graphs only represent one-half of the domain, because the solution is symmetric" ] }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Import plotting modules and define plotting preference\n", - "import matplotlib.pyplot as plt\n", - "%matplotlib notebook\n", - "\n", - "plt.rcParams['figure.autolayout'] = True\n", - "\n", - "plt.rcParams['axes.labelsize'] = 14\n", - "plt.rcParams['xtick.labelsize'] = 12\n", - "plt.rcParams['ytick.labelsize'] = 12\n", - "plt.rcParams['legend.fontsize'] = 10\n", - "plt.rcParams['figure.facecolor'] = 'white'\n", - "plt.rcParams['figure.figsize'] = (8,6)" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -709,9 +717,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -719,6 +725,7 @@ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", + "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", @@ -777,6 +784,9 @@ " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", @@ -791,7 +801,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", + " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -846,6 +856,15 @@ " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", @@ -902,8 +921,9 @@ " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", @@ -1036,10 +1056,10 @@ "}\n", "\n", "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n", - " var x0 = msg['x0'];\n", - " var y0 = fig.canvas.height - msg['y0'];\n", - " var x1 = msg['x1'];\n", - " var y1 = fig.canvas.height - msg['y1'];\n", + " var x0 = msg['x0'] / mpl.ratio;\n", + " var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n", + " var x1 = msg['x1'] / mpl.ratio;\n", + " var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", @@ -1195,8 +1215,8 @@ " this.canvas_div.focus();\n", " }\n", "\n", - " var x = canvas_pos.x;\n", - " var y = canvas_pos.y;\n", + " var x = canvas_pos.x * mpl.ratio;\n", + " var y = canvas_pos.y * mpl.ratio;\n", "\n", " this.send_message(name, {x: x, y: y, button: event.button,\n", " step: event.step,\n", @@ -1256,9 +1276,9 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", - "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", + "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", @@ -1276,7 +1296,7 @@ " // Register the callback with on_msg.\n", " comm.on_msg(function(msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", - " // Pass the mpl event to the overriden (by mpl) onmessage function.\n", + " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data'])\n", " });\n", " return ws;\n", @@ -1317,6 +1337,7 @@ "};\n", "\n", "mpl.figure.prototype.handle_close = function(fig, msg) {\n", + " var width = fig.canvas.width/mpl.ratio\n", " fig.root.unbind('remove')\n", "\n", " // Update the output cell to use the data from the current canvas.\n", @@ -1325,7 +1346,7 @@ " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable()\n", - " $(fig.parent_element).html('');\n", + " $(fig.parent_element).html('');\n", " fig.close_ws(fig, msg);\n", "}\n", "\n", @@ -1336,8 +1357,9 @@ "\n", "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", + " var width = this.canvas.width/mpl.ratio\n", " var dataURL = this.canvas.toDataURL();\n", - " this.cell_info[1]['text/html'] = '';\n", + " this.cell_info[1]['text/html'] = '';\n", "}\n", "\n", "mpl.figure.prototype.updated_canvas_event = function() {\n", @@ -1480,7 +1502,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1516,9 +1538,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1526,6 +1546,7 @@ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", + "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", @@ -1584,6 +1605,9 @@ " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", @@ -1598,7 +1622,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", + " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -1653,6 +1677,15 @@ " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", @@ -1709,8 +1742,9 @@ " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", @@ -1843,10 +1877,10 @@ "}\n", "\n", "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n", - " var x0 = msg['x0'];\n", - " var y0 = fig.canvas.height - msg['y0'];\n", - " var x1 = msg['x1'];\n", - " var y1 = fig.canvas.height - msg['y1'];\n", + " var x0 = msg['x0'] / mpl.ratio;\n", + " var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n", + " var x1 = msg['x1'] / mpl.ratio;\n", + " var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", @@ -2002,8 +2036,8 @@ " this.canvas_div.focus();\n", " }\n", "\n", - " var x = canvas_pos.x;\n", - " var y = canvas_pos.y;\n", + " var x = canvas_pos.x * mpl.ratio;\n", + " var y = canvas_pos.y * mpl.ratio;\n", "\n", " this.send_message(name, {x: x, y: y, button: event.button,\n", " step: event.step,\n", @@ -2063,9 +2097,9 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", - "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", + "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", @@ -2083,7 +2117,7 @@ " // Register the callback with on_msg.\n", " comm.on_msg(function(msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", - " // Pass the mpl event to the overriden (by mpl) onmessage function.\n", + " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data'])\n", " });\n", " return ws;\n", @@ -2124,6 +2158,7 @@ "};\n", "\n", "mpl.figure.prototype.handle_close = function(fig, msg) {\n", + " var width = fig.canvas.width/mpl.ratio\n", " fig.root.unbind('remove')\n", "\n", " // Update the output cell to use the data from the current canvas.\n", @@ -2132,7 +2167,7 @@ " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable()\n", - " $(fig.parent_element).html('');\n", + " $(fig.parent_element).html('');\n", " fig.close_ws(fig, msg);\n", "}\n", "\n", @@ -2143,8 +2178,9 @@ "\n", "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", + " var width = this.canvas.width/mpl.ratio\n", " var dataURL = this.canvas.toDataURL();\n", - " this.cell_info[1]['text/html'] = '';\n", + " this.cell_info[1]['text/html'] = '';\n", "}\n", "\n", "mpl.figure.prototype.updated_canvas_event = function() {\n", @@ -2287,7 +2323,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -2316,9 +2352,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -2326,6 +2360,7 @@ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", + "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", @@ -2384,6 +2419,9 @@ " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", @@ -2398,7 +2436,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", + " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -2453,6 +2491,15 @@ " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", @@ -2509,8 +2556,9 @@ " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", @@ -2643,10 +2691,10 @@ "}\n", "\n", "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n", - " var x0 = msg['x0'];\n", - " var y0 = fig.canvas.height - msg['y0'];\n", - " var x1 = msg['x1'];\n", - " var y1 = fig.canvas.height - msg['y1'];\n", + " var x0 = msg['x0'] / mpl.ratio;\n", + " var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n", + " var x1 = msg['x1'] / mpl.ratio;\n", + " var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", @@ -2802,8 +2850,8 @@ " this.canvas_div.focus();\n", " }\n", "\n", - " var x = canvas_pos.x;\n", - " var y = canvas_pos.y;\n", + " var x = canvas_pos.x * mpl.ratio;\n", + " var y = canvas_pos.y * mpl.ratio;\n", "\n", " this.send_message(name, {x: x, y: y, button: event.button,\n", " step: event.step,\n", @@ -2863,9 +2911,9 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", - "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", + "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", @@ -2883,7 +2931,7 @@ " // Register the callback with on_msg.\n", " comm.on_msg(function(msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", - " // Pass the mpl event to the overriden (by mpl) onmessage function.\n", + " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data'])\n", " });\n", " return ws;\n", @@ -2924,6 +2972,7 @@ "};\n", "\n", "mpl.figure.prototype.handle_close = function(fig, msg) {\n", + " var width = fig.canvas.width/mpl.ratio\n", " fig.root.unbind('remove')\n", "\n", " // Update the output cell to use the data from the current canvas.\n", @@ -2932,7 +2981,7 @@ " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable()\n", - " $(fig.parent_element).html('');\n", + " $(fig.parent_element).html('');\n", " fig.close_ws(fig, msg);\n", "}\n", "\n", @@ -2943,8 +2992,9 @@ "\n", "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", + " var width = this.canvas.width/mpl.ratio\n", " var dataURL = this.canvas.toDataURL();\n", - " this.cell_info[1]['text/html'] = '';\n", + " this.cell_info[1]['text/html'] = '';\n", "}\n", "\n", "mpl.figure.prototype.updated_canvas_event = function() {\n", @@ -3087,7 +3137,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -3122,15 +3172,6 @@ "\n", "plt.legend(loc=2);" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], "metadata": { @@ -3149,9 +3190,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/python_tutorial.ipynb b/python_tutorial.ipynb index 07bc515..bb6cb52 100644 --- a/python_tutorial.ipynb +++ b/python_tutorial.ipynb @@ -26,9 +26,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import cantera as ct\n", @@ -45,9 +43,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1 = ct.Solution('gri30.xml')" @@ -126,9 +122,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1.TP = 1200, 101325" @@ -191,9 +185,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1.TP = 1200, 101325 # temperature, pressure\n", @@ -297,9 +289,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1.X = 'CH4:1, O2:2, N2:7.52'" @@ -315,9 +305,7 @@ { "cell_type": "code", "execution_count": 11, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "phi = 0.8\n", @@ -384,9 +372,7 @@ { "cell_type": "code", "execution_count": 13, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1.X = np.ones(53) # NumPy array of 53 ones" @@ -402,9 +388,7 @@ { "cell_type": "code", "execution_count": 14, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1.Y = np.ones(53)" @@ -420,9 +404,7 @@ { "cell_type": "code", "execution_count": 15, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1.SV = None, 2.1" @@ -438,9 +420,7 @@ { "cell_type": "code", "execution_count": 16, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas1.TPX = None, None, 'CH4:1.0, O2:0.5'" @@ -463,9 +443,7 @@ { "cell_type": "code", "execution_count": 17, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "Xmajor = gas1['CH4','O2','CO2','H2O','N2'].X" @@ -481,9 +459,7 @@ { "cell_type": "code", "execution_count": 18, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "major = gas1['CH4','O2','CO2','H2O','N2']\n", @@ -517,9 +493,7 @@ { "cell_type": "code", "execution_count": 19, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "ct.add_directory('/usr/local/cantera/my_data_files')" @@ -537,9 +511,7 @@ { "cell_type": "code", "execution_count": 20, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "gas2 = ct.Solution('diamond.cti', 'gas')\n", @@ -587,9 +559,7 @@ { "cell_type": "code", "execution_count": 21, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g = ct.Solution('gri30.xml')" @@ -605,9 +575,7 @@ { "cell_type": "code", "execution_count": 22, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g?" @@ -694,6 +662,8 @@ " '_init_cti_xml',\n", " '_init_parts',\n", " '_references',\n", + " 'activities',\n", + " 'activity_coefficients',\n", " 'add_reaction',\n", " 'add_species',\n", " 'atomic_weight',\n", @@ -728,7 +698,6 @@ " 'element_index',\n", " 'element_name',\n", " 'element_names',\n", - " 'element_potentials',\n", " 'elemental_mass_fraction',\n", " 'elemental_mole_fraction',\n", " 'enthalpy_mass',\n", @@ -740,6 +709,7 @@ " 'forward_rate_constants',\n", " 'forward_rates_of_progress',\n", " 'g',\n", + " 'get_equivalence_ratio',\n", " 'gibbs_mass',\n", " 'gibbs_mole',\n", " 'h',\n", @@ -748,6 +718,8 @@ " 'is_reversible',\n", " 'isothermal_compressibility',\n", " 'kinetics_species_index',\n", + " 'kinetics_species_name',\n", + " 'kinetics_species_names',\n", " 'mass_fraction_dict',\n", " 'max_temp',\n", " 'mean_molecular_weight',\n", @@ -755,6 +727,7 @@ " 'mix_diff_coeffs',\n", " 'mix_diff_coeffs_mass',\n", " 'mix_diff_coeffs_mole',\n", + " 'mobilities',\n", " 'modify_reaction',\n", " 'modify_species',\n", " 'mole_fraction_dict',\n", @@ -802,6 +775,7 @@ " 'species_index',\n", " 'species_name',\n", " 'species_names',\n", + " 'species_viscosities',\n", " 'standard_cp_R',\n", " 'standard_enthalpies_RT',\n", " 'standard_entropies_R',\n", @@ -838,9 +812,7 @@ { "cell_type": "code", "execution_count": 24, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g.species_index?" @@ -857,7 +829,6 @@ "cell_type": "code", "execution_count": 25, "metadata": { - "collapsed": true, "scrolled": true }, "outputs": [], @@ -875,9 +846,7 @@ { "cell_type": "code", "execution_count": 26, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g.__class__.T?" @@ -932,9 +901,7 @@ { "cell_type": "code", "execution_count": 28, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g = ct.Solution('gri30.xml')\n", @@ -952,9 +919,7 @@ { "cell_type": "code", "execution_count": 29, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g.TPX = 300.0, ct.one_atm, 'CH4:0.95, O2:2, N2:7.52'\n", @@ -976,9 +941,7 @@ { "cell_type": "code", "execution_count": 30, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g.TPX = 300.0, ct.one_atm, 'CH4:0.95, O2:2, N2:7.52'\n", @@ -996,313 +959,313 @@ "name": "stdout", "output_type": "stream", "text": [ - " 0 5.285e-16 \n", - " 1 -3.147e-15 \n", - " 2 -2.362e-15 \n", - " 3 -1.667e-15 \n", - " 4 4.733e-15 \n", - " 5 1.065e-14 \n", - " 6 7.075e-15 \n", - " 7 -2.011e-16 \n", - " 8 1.046e-14 \n", - " 9 1.745e-15 \n", - " 10 8.84e-15 \n", - " 11 5.404e-16 \n", - " 12 -3.656e-15 \n", - " 13 -3.441e-15 \n", - " 14 1.932e-15 \n", - " 15 5.203e-15 \n", - " 16 3.312e-15 \n", - " 17 -1.808e-14 \n", - " 18 -1.598e-14 \n", - " 19 -1.07e-14 \n", - " 20 7.04e-15 \n", - " 21 1.265e-14 \n", - " 22 7.091e-15 \n", - " 23 2.623e-16 \n", - " 24 1.028e-14 \n", - " 25 6.891e-15 \n", - " 26 5.921e-15 \n", - " 27 2.879e-15 \n", - " 28 8.738e-16 \n", - " 29 6.928e-15 \n", - " 30 -2.736e-15 \n", - " 31 2.515e-15 \n", - " 32 2.115e-15 \n", - " 33 8.353e-15 \n", - " 34 8.335e-15 \n", - " 35 8.207e-15 \n", - " 37 -2.829e-15 \n", - " 38 1.423e-16 \n", - " 39 3.43e-16 \n", - " 40 3.903e-15 \n", - " 41 -3.341e-15 \n", - " 42 5.475e-16 \n", - " 43 -3.504e-15 \n", + " 0 -4.756e-15 \n", + " 1 -3.332e-15 \n", + " 2 -3.936e-16 \n", + " 3 -3.751e-15 \n", + " 4 -6.626e-15 \n", + " 5 -1.503e-15 \n", + " 6 5.377e-15 \n", + " 7 -1.609e-15 \n", + " 8 1.267e-14 \n", + " 9 -1.587e-16 \n", + " 10 -4.093e-15 \n", + " 11 7.16e-15 \n", + " 12 -9.032e-15 \n", + " 13 -1.72e-15 \n", + " 14 -2.147e-16 \n", + " 15 -5.203e-15 \n", + " 16 -1.743e-15 \n", + " 17 5.791e-15 \n", + " 18 1.957e-15 \n", + " 19 -5.548e-15 \n", + " 20 1.886e-15 \n", + " 21 1.421e-15 \n", + " 22 1.223e-16 \n", + " 23 9.182e-15 \n", + " 24 2.055e-15 \n", + " 25 -5.119e-15 \n", + " 26 3.383e-15 \n", + " 27 -1.44e-14 \n", + " 28 -3.495e-16 \n", + " 29 -1.949e-15 \n", + " 30 1.452e-14 \n", + " 31 1.048e-14 \n", + " 32 3.608e-15 \n", + " 33 -3.47e-15 \n", + " 34 -3.443e-15 \n", + " 35 9.966e-15 \n", + " 37 8.611e-16 \n", + " 38 -4.981e-15 \n", + " 39 -1.486e-15 \n", + " 40 -8.614e-15 \n", + " 41 -1.518e-15 \n", + " 42 -1.232e-15 \n", + " 43 -6.832e-15 \n", " 44 -5.306e-15 \n", - " 45 -3.81e-15 \n", - " 46 7.042e-15 \n", - " 47 6.951e-15 \n", - " 48 5.15e-15 \n", - " 49 1.929e-15 \n", - " 50 -5.408e-15 \n", - " 51 -4.728e-15 \n", - " 52 4.812e-15 \n", - " 53 -1.395e-15 \n", - " 54 -7.24e-15 \n", - " 55 -1.122e-14 \n", - " 56 -8.41e-15 \n", - " 57 -2.878e-15 \n", - " 58 1.857e-14 \n", - " 59 1.409e-14 \n", - " 60 9.723e-15 \n", - " 61 3.338e-15 \n", - " 62 1.655e-14 \n", - " 63 -1.881e-15 \n", - " 64 1.077e-14 \n", - " 65 7.982e-15 \n", - " 66 1.713e-15 \n", - " 67 -2.162e-14 \n", - " 68 -1.374e-14 \n", - " 69 -1.379e-14 \n", - " 70 5.819e-15 \n", - " 71 7.647e-15 \n", - " 72 -5.403e-15 \n", - " 73 -5.381e-15 \n", - " 74 -7.317e-15 \n", - " 75 -6.764e-15 \n", - " 76 8.83e-15 \n", - " 77 2.803e-15 \n", - " 78 -2.353e-16 \n", - " 79 -3.039e-15 \n", - " 80 8.536e-15 \n", - " 81 -3.427e-15 \n", - " 82 7.58e-15 \n", - " 83 4.796e-15 \n", - " 84 5.406e-16 \n", - " 85 5.275e-16 \n", - " 86 -6.901e-15 \n", - " 87 -1.658e-15 \n", - " 88 -1.72e-15 \n", - " 89 7.25e-15 \n", - " 90 1.447e-14 \n", - " 91 8.796e-15 \n", - " 92 -3.166e-15 \n", - " 93 8.89e-15 \n", - " 94 7.953e-15 \n", - " 95 -6.425e-15 \n", - " 96 -6.243e-15 \n", - " 97 3.487e-15 \n", - " 98 0 \n", - " 99 -1.069e-14 \n", - " 100 1.697e-15 \n", - " 101 1.078e-14 \n", - " 102 1.072e-14 \n", - " 103 -1.094e-14 \n", - " 104 -1.537e-14 \n", - " 105 -5.474e-15 \n", - " 106 1.27e-14 \n", - " 107 1.624e-14 \n", - " 108 1.965e-14 \n", - " 109 2.119e-14 \n", - " 110 3.669e-15 \n", - " 111 -2.852e-15 \n", - " 112 -6.13e-15 \n", - " 113 -4.862e-15 \n", - " 114 -1.206e-14 \n", - " 115 -1.234e-14 \n", - " 116 -3.541e-16 \n", - " 117 -3.296e-15 \n", - " 118 -5.448e-15 \n", - " 119 -1.78e-14 \n", - " 120 -9.215e-15 \n", - " 121 0 \n", - " 122 1.878e-15 \n", - " 123 -1.032e-14 \n", - " 124 1.05e-14 \n", - " 125 8.262e-15 \n", - " 126 1.26e-14 \n", - " 127 -3.641e-15 \n", - " 128 1.434e-16 \n", - " 129 1.269e-14 \n", - " 130 1.397e-15 \n", - " 131 1.414e-14 \n", - " 132 5.977e-16 \n", - " 133 -7.276e-15 \n", - " 135 1.762e-15 \n", - " 136 -1.105e-14 \n", - " 137 3.411e-16 \n", - " 138 9.284e-15 \n", - " 139 -3.977e-16 \n", - " 140 -3.641e-15 \n", - " 141 6.526e-15 \n", - " 143 3.036e-15 \n", - " 144 -3.935e-15 \n", - " 145 4.489e-15 \n", - " 146 1.506e-14 \n", - " 147 -3.013e-16 \n", - " 148 4.12e-15 \n", - " 149 9.76e-15 \n", - " 150 -2.996e-16 \n", - " 151 6.341e-15 \n", - " 152 1.402e-14 \n", - " 153 1.344e-14 \n", - " 154 -1.047e-14 \n", - " 155 -7.371e-15 \n", - " 156 -4.354e-15 \n", - " 157 -1.26e-14 \n", - " 158 -6.794e-15 \n", - " 159 -1.424e-14 \n", - " 160 -9.318e-16 \n", - " 161 -2.685e-14 \n", - " 162 -3.156e-14 \n", - " 163 -1.211e-14 \n", - " 164 3.935e-15 \n", - " 165 -5.618e-15 \n", - " 166 -5.607e-15 \n", - " 167 3.292e-15 \n", - " 168 1.261e-14 \n", - " 169 4.311e-15 \n", - " 170 -3.259e-16 \n", - " 171 -1.154e-14 \n", - " 172 2.461e-14 \n", - " 173 -1.329e-14 \n", - " 174 7.51e-15 \n", - " 175 -9.564e-16 \n", - " 176 -7.937e-16 \n", - " 177 3.23e-15 \n", - " 178 1.637e-15 \n", - " 179 3.705e-15 \n", - " 180 2.004e-16 \n", - " 181 3.797e-15 \n", - " 182 -3.904e-15 \n", - " 183 7.03e-15 \n", - " 184 2.849e-15 \n", - " 185 -2.256e-15 \n", - " 186 2.02e-15 \n", - " 187 3.979e-16 \n", - " 188 -1.811e-15 \n", - " 189 2.02e-15 \n", - " 190 -8.31e-16 \n", - " 191 0 \n", - " 192 2.007e-15 \n", - " 193 -2.79e-15 \n", - " 194 0 \n", - " 195 3.527e-15 \n", - " 196 -5.021e-15 \n", - " 197 -3.874e-15 \n", - " 198 -1.844e-15 \n", - " 199 5.081e-16 \n", - " 200 0 \n", - " 201 -4.036e-15 \n", - " 202 6.85e-16 \n", - " 203 -5.581e-15 \n", - " 204 -5.864e-15 \n", - " 205 1.635e-15 \n", - " 206 -7.294e-15 \n", - " 207 -8.683e-16 \n", + " 45 -9.065e-15 \n", + " 46 -9.2e-15 \n", + " 47 -1.436e-14 \n", + " 48 -7.131e-15 \n", + " 49 -1.415e-15 \n", + " 50 -1.151e-16 \n", + " 51 2.08e-15 \n", + " 52 -7.122e-15 \n", + " 53 -6.697e-15 \n", + " 54 -1.066e-14 \n", + " 55 4.771e-15 \n", + " 56 1.255e-15 \n", + " 57 -2.753e-15 \n", + " 58 -1.199e-14 \n", + " 59 -7.143e-15 \n", + " 60 -1.246e-14 \n", + " 61 -1.46e-14 \n", + " 62 -8.636e-15 \n", + " 63 4.3e-15 \n", + " 64 -3.79e-15 \n", + " 65 -7.982e-15 \n", + " 66 -1.074e-14 \n", + " 67 3.123e-15 \n", + " 68 -1.094e-15 \n", + " 69 -5.515e-15 \n", + " 70 -8.543e-15 \n", + " 71 8.996e-15 \n", + " 72 4.953e-15 \n", + " 73 6.249e-15 \n", + " 74 -1.42e-14 \n", + " 75 -8.455e-15 \n", + " 76 -1.624e-14 \n", + " 77 -2.242e-16 \n", + " 78 -6.353e-15 \n", + " 79 -3.199e-15 \n", + " 80 -3.712e-15 \n", + " 81 7.139e-16 \n", + " 82 5.75e-15 \n", + " 83 3.837e-15 \n", + " 84 8.785e-15 \n", + " 85 1.055e-15 \n", + " 86 3.893e-15 \n", + " 87 -5.307e-15 \n", + " 88 -5.318e-15 \n", + " 89 1.908e-16 \n", + " 90 1.085e-14 \n", + " 91 7.232e-15 \n", + " 92 2.015e-15 \n", + " 93 7.362e-15 \n", + " 94 -1.295e-15 \n", + " 95 2.142e-15 \n", + " 96 -2.141e-15 \n", + " 97 -3.184e-15 \n", + " 98 6.945e-15 \n", + " 99 3.564e-16 \n", + " 100 1.851e-15 \n", + " 101 -1.03e-14 \n", + " 102 -6.984e-15 \n", + " 103 7.083e-15 \n", + " 104 3.502e-15 \n", + " 105 8.553e-16 \n", + " 106 2.694e-15 \n", + " 107 2.082e-15 \n", + " 108 2.527e-15 \n", + " 109 -1.614e-15 \n", + " 110 1.44e-14 \n", + " 111 -1.036e-14 \n", + " 112 1.086e-14 \n", + " 113 -5.672e-15 \n", + " 114 -3.447e-15 \n", + " 115 -3.33e-15 \n", + " 116 -3.541e-15 \n", + " 117 -5.337e-15 \n", + " 118 -9.301e-16 \n", + " 119 1.057e-14 \n", + " 120 6.485e-15 \n", + " 121 -1.702e-15 \n", + " 122 2.113e-15 \n", + " 123 3.496e-15 \n", + " 124 5.331e-15 \n", + " 125 3.978e-15 \n", + " 126 5.315e-15 \n", + " 127 -3.337e-15 \n", + " 128 -6.885e-15 \n", + " 129 1.692e-16 \n", + " 130 4.969e-15 \n", + " 131 7.138e-15 \n", + " 132 1.494e-16 \n", + " 133 -1.433e-14 \n", + " 135 2.202e-15 \n", + " 136 -3.558e-15 \n", + " 137 1.705e-15 \n", + " 138 -5.142e-15 \n", + " 139 2.187e-15 \n", + " 140 -1.063e-14 \n", + " 141 4.121e-15 \n", + " 143 1.518e-15 \n", + " 144 3.739e-15 \n", + " 145 6.05e-15 \n", + " 146 2.349e-15 \n", + " 147 4.067e-15 \n", + " 148 5.183e-15 \n", + " 149 -4.704e-16 \n", + " 150 4.195e-15 \n", + " 151 -2.67e-15 \n", + " 152 -3.171e-15 \n", + " 153 6.19e-15 \n", + " 154 2.475e-15 \n", + " 155 1.559e-15 \n", + " 156 -2.177e-15 \n", + " 157 2.065e-15 \n", + " 158 1.207e-14 \n", + " 159 -1.072e-14 \n", + " 160 4.26e-15 \n", + " 161 9.977e-15 \n", + " 162 5.986e-15 \n", + " 163 -7.571e-15 \n", + " 164 1.389e-14 \n", + " 165 -2.985e-15 \n", + " 166 -8.343e-15 \n", + " 167 -1.873e-14 \n", + " 168 1.15e-14 \n", + " 169 1.584e-14 \n", + " 170 6.844e-15 \n", + " 171 1.539e-15 \n", + " 172 6.997e-15 \n", + " 173 -3.021e-15 \n", + " 174 -9.388e-15 \n", + " 175 -1.301e-14 \n", + " 176 -1.29e-14 \n", + " 177 1.794e-15 \n", + " 178 3.525e-15 \n", + " 179 2.044e-15 \n", + " 180 5.211e-15 \n", + " 181 3.137e-15 \n", + " 182 -5.092e-16 \n", + " 183 2.429e-15 \n", + " 184 6.597e-15 \n", + " 185 4.338e-15 \n", + " 186 5.61e-16 \n", + " 187 -2.652e-16 \n", + " 188 -7.74e-15 \n", + " 189 1.885e-15 \n", + " 190 -4.779e-15 \n", + " 191 7.254e-15 \n", + " 192 2.737e-15 \n", + " 193 1.462e-15 \n", + " 194 -2.185e-15 \n", + " 195 -3.68e-15 \n", + " 196 -3.195e-15 \n", + " 197 0 \n", + " 198 1.844e-16 \n", + " 199 -6.266e-15 \n", + " 200 1.042e-15 \n", + " 201 -2.691e-15 \n", + " 202 1.096e-15 \n", + " 203 5.445e-16 \n", + " 204 4.599e-16 \n", + " 205 3.419e-15 \n", + " 206 1.975e-15 \n", + " 207 -2.171e-16 \n", " 208 -3.651e-15 \n", - " 209 -1.312e-16 \n", - " 210 -6.959e-15 \n", - " 211 -4.865e-15 \n", - " 212 1.528e-15 \n", - " 213 -1.928e-15 \n", - " 214 -3.551e-15 \n", - " 215 3.246e-15 \n", - " 216 0 \n", - " 217 3.698e-15 \n", - " 218 1.74e-15 \n", - " 219 4.112e-15 \n", - " 220 -3.154e-15 \n", - " 221 1.719e-16 \n", - " 222 -1.883e-15 \n", - " 223 -1.395e-16 \n", - " 224 3.45e-15 \n", - " 225 3.525e-15 \n", - " 226 -4.259e-16 \n", - " 227 3.692e-15 \n", - " 228 1.502e-16 \n", - " 229 2.901e-15 \n", - " 230 4.818e-15 \n", - " 231 3.617e-15 \n", - " 232 1.173e-15 \n", - " 233 4.679e-15 \n", - " 234 4.893e-15 \n", - " 235 3.684e-15 \n", - " 236 7.41e-15 \n", - " 237 0 \n", - " 238 -1.761e-15 \n", - " 239 7.82e-16 \n", - " 240 1.306e-15 \n", - " 241 -7.974e-15 \n", - " 242 -1.807e-15 \n", - " 243 -7.132e-16 \n", - " 244 0 \n", - " 245 3.281e-15 \n", - " 246 8.649e-15 \n", - " 247 1.048e-14 \n", - " 248 3.319e-15 \n", - " 249 -4.6e-16 \n", - " 250 1.996e-15 \n", - " 251 3.33e-15 \n", - " 252 -1.226e-16 \n", - " 253 2.128e-15 \n", - " 254 -1.405e-14 \n", - " 255 -3.197e-15 \n", - " 256 3.222e-15 \n", - " 257 3.815e-15 \n", - " 258 1.361e-14 \n", - " 259 1.054e-14 \n", - " 260 7.209e-15 \n", - " 261 -7.213e-15 \n", - " 262 -1.652e-15 \n", - " 263 2.016e-16 \n", - " 264 -7.362e-16 \n", - " 265 -4.098e-15 \n", - " 266 -5.895e-15 \n", - " 267 -8.422e-16 \n", - " 268 -4.317e-16 \n", - " 269 3.407e-15 \n", - " 270 -2.196e-15 \n", - " 271 -2.216e-16 \n", - " 272 -3.187e-16 \n", - " 273 1.906e-15 \n", - " 274 4.433e-15 \n", - " 275 -3.722e-15 \n", - " 276 4.478e-15 \n", - " 277 2.749e-15 \n", - " 278 1.997e-15 \n", - " 279 6.178e-15 \n", - " 280 5.352e-15 \n", - " 281 3.816e-15 \n", - " 282 0 \n", - " 284 4.345e-15 \n", - " 285 1.062e-14 \n", - " 286 -7.052e-15 \n", - " 288 9.538e-15 \n", - " 290 6.84e-15 \n", - " 293 1.136e-14 \n", - " 294 2.485e-15 \n", - " 295 -1.321e-14 \n", - " 298 2.783e-15 \n", - " 303 6.31e-15 \n", - " 307 5.697e-15 \n", - " 308 -1.076e-14 \n", - " 309 7.356e-15 \n", - " 310 3.072e-15 \n", - " 311 -6.465e-15 \n", - " 312 6.144e-15 \n", - " 313 8.81e-15 \n", - " 314 7.097e-15 \n", - " 315 -8.59e-15 \n", - " 316 4.047e-15 \n", - " 317 3.918e-16 \n", - " 318 1.038e-14 \n", - " 319 -6.812e-15 \n", - " 320 6.885e-16 \n", - " 321 -1.572e-14 \n", - " 322 -7.739e-15 \n", - " 324 -5.967e-15 \n" + " 209 -6.822e-15 \n", + " 210 -3.846e-15 \n", + " 211 -1.802e-16 \n", + " 212 -3.82e-15 \n", + " 213 -5.635e-15 \n", + " 214 -1.592e-15 \n", + " 215 -1.546e-16 \n", + " 216 -8.714e-15 \n", + " 217 -3.328e-15 \n", + " 218 -4.757e-15 \n", + " 219 1.028e-15 \n", + " 220 2.253e-15 \n", + " 221 -1.891e-15 \n", + " 222 0 \n", + " 223 3.906e-15 \n", + " 224 -3.623e-15 \n", + " 225 1.41e-14 \n", + " 226 -8.518e-16 \n", + " 227 -5.316e-15 \n", + " 228 7.057e-15 \n", + " 229 4.955e-15 \n", + " 230 -2.811e-15 \n", + " 231 -1.608e-15 \n", + " 232 2.607e-16 \n", + " 233 1.704e-14 \n", + " 234 1.288e-14 \n", + " 235 -2.403e-15 \n", + " 236 -4.359e-16 \n", + " 237 -3.755e-15 \n", + " 238 5.284e-15 \n", + " 239 -3.91e-16 \n", + " 240 1.543e-15 \n", + " 241 1.687e-15 \n", + " 242 6.066e-15 \n", + " 243 6.419e-15 \n", + " 244 1.869e-16 \n", + " 245 -1.777e-15 \n", + " 246 -5.017e-15 \n", + " 247 7.063e-15 \n", + " 248 7.223e-15 \n", + " 249 -3.68e-15 \n", + " 250 2.928e-15 \n", + " 251 1.082e-14 \n", + " 252 -3.555e-15 \n", + " 253 3.688e-15 \n", + " 254 -3.464e-15 \n", + " 255 -7.992e-16 \n", + " 256 -5.37e-16 \n", + " 257 -8.861e-15 \n", + " 258 1.002e-14 \n", + " 259 1.473e-15 \n", + " 260 -3.605e-15 \n", + " 261 5.441e-15 \n", + " 262 -1.404e-14 \n", + " 263 -8.87e-15 \n", + " 264 -1.509e-14 \n", + " 265 -1.192e-14 \n", + " 266 -1.179e-15 \n", + " 267 -1.684e-15 \n", + " 268 -9.065e-15 \n", + " 269 5.379e-15 \n", + " 270 -7.503e-15 \n", + " 271 -1.064e-14 \n", + " 272 -3.506e-15 \n", + " 273 1.121e-16 \n", + " 274 1.825e-15 \n", + " 275 -7.158e-15 \n", + " 276 -1.008e-14 \n", + " 277 4.998e-16 \n", + " 278 -6.989e-15 \n", + " 279 -1.959e-14 \n", + " 280 -7.091e-15 \n", + " 281 -1.734e-16 \n", + " 282 -5.24e-15 \n", + " 284 6.646e-15 \n", + " 285 -1.078e-14 \n", + " 286 3.836e-15 \n", + " 288 2.384e-15 \n", + " 290 0 \n", + " 293 1.232e-14 \n", + " 294 8.698e-15 \n", + " 295 1.071e-14 \n", + " 298 7.763e-15 \n", + " 303 3.944e-15 \n", + " 307 -4.906e-15 \n", + " 308 -7.438e-15 \n", + " 309 -1.769e-14 \n", + " 310 7.541e-15 \n", + " 311 7.415e-15 \n", + " 312 -1.229e-14 \n", + " 313 -8.027e-15 \n", + " 314 -4.22e-15 \n", + " 315 -8.59e-16 \n", + " 316 -1.138e-15 \n", + " 317 1.371e-14 \n", + " 318 -5.547e-15 \n", + " 319 -1.629e-15 \n", + " 320 -8.262e-15 \n", + " 321 1.1e-14 \n", + " 322 -4.614e-15 \n", + " 324 1.068e-14 \n" ] } ], @@ -1463,9 +1426,7 @@ { "cell_type": "code", "execution_count": 37, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "g.TPX = 300, 101325, {'CH4':0.6, 'O2':1.0, 'N2':3.76}\n", @@ -1487,8 +1448,7 @@ { "data": { "text/plain": [ - "array([ -1.01643954e-19, -5.08219768e-21, -1.77635684e-15,\n", - " 9.91028548e-20])" + "array([-8.80914265e-20, -1.03761536e-20, -1.77635684e-15, -4.99749439e-20])" ] }, "execution_count": 38, @@ -1515,8 +1475,7 @@ { "data": { "text/plain": [ - "array([ 3.18644948e-05, 5.00489577e-08, 1.05964923e-01,\n", - " 2.89502609e-06])" + "array([3.18644948e-05, 5.00489577e-08, 1.05964923e-01, 2.89502609e-06])" ] }, "execution_count": 39, @@ -1544,8 +1503,7 @@ { "data": { "text/plain": [ - "array([ -5.33034657e+08, -2.23248515e+07, -8.76650086e+07,\n", - " -2.49169628e+08])" + "array([-5.33034657e+08, -2.23248515e+07, -8.76650086e+07, -2.49169628e+08])" ] }, "execution_count": 40, @@ -1572,7 +1530,7 @@ { "data": { "text/plain": [ - "-58013370.720880888" + "-58013370.72088288" ] }, "execution_count": 41, @@ -1599,7 +1557,7 @@ { "data": { "text/plain": [ - "-58013370.720880821" + "-58013370.72088274" ] }, "execution_count": 42, @@ -1626,7 +1584,7 @@ { "data": { "text/plain": [ - "-9307123.2625650223" + "-9307123.262565034" ] }, "execution_count": 43, @@ -1662,7 +1620,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.2" + "version": "3.7.2" } }, "nbformat": 4, diff --git a/reactors/NonIdealShockTube.ipynb b/reactors/NonIdealShockTube.ipynb index 6bc9197..3e85dc7 100644 --- a/reactors/NonIdealShockTube.ipynb +++ b/reactors/NonIdealShockTube.ipynb @@ -38,14 +38,14 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Runnning Cantera version: 2.4.0a1\n" + "Runnning Cantera version: 2.5.0a2\n" ] } ], @@ -62,6 +62,21 @@ "print('Runnning Cantera version: ' + ct.__version__)" ] }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "%matplotlib notebook\n", + "import matplotlib.pyplot as plt\n", + "\n", + "plt.rcParams['axes.labelsize'] = 16\n", + "plt.rcParams['xtick.labelsize'] = 12\n", + "plt.rcParams['ytick.labelsize'] = 12\n", + "plt.rcParams['figure.autolayout'] = True" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -75,34 +90,9 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 3, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - "**** WARNING ****\n", - "For species c5h11, discontinuity in cp/R detected at Tmid = 1000\n", - "\tValue computed using low-temperature polynomial: 32.0653\n", - "\tValue computed using high-temperature polynomial: 32.1675\n", - "\n", - "\n", - "**** WARNING ****\n", - "For species c4h4, discontinuity in cp/R detected at Tmid = 1000\n", - "\tValue computed using low-temperature polynomial: 16.6543\n", - "\tValue computed using high-temperature polynomial: 16.6734\n", - "\n", - "\n", - "**** WARNING ****\n", - "For species A3-, discontinuity in cp/R detected at Tmid = 1000\n", - "\tValue computed using low-temperature polynomial: 52.2095\n", - "\tValue computed using high-temperature polynomial: 52.364\n" - ] - } - ], + "outputs": [], "source": [ "gas = ct.Solution('data/WangMechanismRK.cti')" ] @@ -116,10 +106,8 @@ }, { "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": true - }, + "execution_count": 4, + "metadata": {}, "outputs": [], "source": [ "# Define the reactor temperature and pressure:\n", @@ -137,7 +125,7 @@ "r = ct.Reactor(contents=gas)\n", "reactorNetwork = ct.ReactorNet([r])\n", "\n", - "# now compile a list of all variables for which we will store data\n", + "# Now compile a list of all variables for which we will store data\n", "stateVariableNames = [r.component_name(item) for item in range(r.n_vars)]\n", "\n", "# Use the above list to create a DataFrame\n", @@ -153,10 +141,8 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": true - }, + "execution_count": 5, + "metadata": {}, "outputs": [], "source": [ "def ignitionDelay(df, species):\n", @@ -164,24 +150,24 @@ " This function computes the ignition delay from the occurence of the\n", " peak in species' concentration.\n", " \"\"\"\n", - " return df[species].argmax()" + " return df[species].idxmax()" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Computed Ignition Delay: 4.093e-04 seconds. Took 3.12s to compute\n" + "Computed Ignition Delay: 4.093e-04 seconds. Took 3.98s to compute\n" ] } ], "source": [ - "#Tic\n", + "# Tic\n", "t0 = time.time()\n", "\n", "# This is a starting estimate. If you do not get an ignition within this time, increase it\n", @@ -200,7 +186,7 @@ "# We will use the 'oh' species to compute the ignition delay\n", "tau = ignitionDelay(timeHistory, 'oh')\n", "\n", - "#Toc\n", + "# Toc\n", "t1 = time.time()\n", "\n", "print('Computed Ignition Delay: {:.3e} seconds. Took {:3.2f}s to compute'.format(tau, t1-t0))\n", @@ -224,23 +210,6 @@ "### Import modules and set plotting defaults" ] }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt\n", - "import matplotlib as mpl\n", - "\n", - "plt.rcParams['axes.labelsize'] = 16\n", - "plt.rcParams['xtick.labelsize'] = 12\n", - "plt.rcParams['ytick.labelsize'] = 12\n", - "plt.rcParams['figure.autolayout'] = True" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -250,154 +219,8 @@ }, { "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "plt.figure()\n", - "plt.plot(timeHistory.index, timeHistory['oh'],'-o',color='b',markersize=4)\n", - "plt.xlabel('Time (s)',fontname='Times New Roman')\n", - "plt.ylabel('$\\mathdefault{OH\\, mass\\, fraction,}\\, Y_{OH}}$',fontname='Times New Roman')\n", - "\n", - "# Figure formatting:\n", - "plt.xlim([0,0.00075])\n", - "ax = plt.gca()\n", - "font = plt.matplotlib.font_manager.FontProperties(family='Times New Roman',size=14)\n", - "ax.annotate(\"\",xy=(tau,0.005), xytext=(0,0.005),arrowprops=dict(arrowstyle=\"<|-|>\",color='r',linewidth=2.0),fontsize=14,)\n", - "plt.annotate('Ignition Delay Time (IDT)', xy=(0,0), xytext=(0.00004, 0.00525), family='Times New Roman',fontsize=16);\n", - "\n", - "for tick in ax.xaxis.get_major_ticks():\n", - " tick.label1.set_fontsize(12)\n", - " tick.label1.set_fontname('Times New Roman')\n", - "for tick in ax.yaxis.get_major_ticks():\n", - " tick.label1.set_fontsize(12)\n", - " tick.label1.set_fontname('Times New Roman')" - ] - }, - { - "cell_type": "markdown", + "execution_count": 7, "metadata": {}, - "source": [ - "## Illustration : NTC behavior\n", - "In the paper by Kogekar, et al., the reactor model is used to demonstrate the impacts of non-ideal behavior on IDTs in the **N**egative **T**emperature **C**oefficient region, where observed IDTs, counter to intuition, increase with increasing temperature." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Define the temperatures for which we will run the simulations" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Make a list of all the temperatures we would like to run simulations at\n", - "T = [1800, 1600, 1400, 1200, 1100, 1075, 1050, 1025, 1000, 975, 950, 925, 900, 850, 825, 800,\n", - " 750, 700]\n", - "\n", - "estimatedIgnitionDelayTimes = np.ones(len(T))\n", - "\n", - "# Set the initial guesses to a common value. We could probably speed up simulations \n", - "# by tuning this guess, but as seen in the figure above, the 'extra' time after igntion \n", - "# does not add many data points or simulation steps. The time savings would be small.\n", - "estimatedIgnitionDelayTimes[:] = 0.005\n", - "\n", - "# Now create a dataFrame out of these\n", - "ignitionDelays = pd.DataFrame(data={'T':T})\n", - "ignitionDelays['ignDelay'] = np.nan" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Run the code above for each temperature, and save the IDT for each." - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Computed Ignition Delay: 6.354e-07 seconds for T=1800K. Took 2.02s to compute\n", - "Computed Ignition Delay: 1.586e-06 seconds for T=1600K. Took 2.11s to compute\n", - "Computed Ignition Delay: 5.786e-06 seconds for T=1400K. Took 2.34s to compute\n", - "Computed Ignition Delay: 3.911e-05 seconds for T=1200K. Took 2.67s to compute\n", - "Computed Ignition Delay: 1.326e-04 seconds for T=1100K. Took 2.94s to compute\n", - "Computed Ignition Delay: 1.839e-04 seconds for T=1075K. Took 2.77s to compute\n", - "Computed Ignition Delay: 2.533e-04 seconds for T=1050K. Took 2.90s to compute\n", - "Computed Ignition Delay: 3.365e-04 seconds for T=1025K. Took 3.04s to compute\n", - "Computed Ignition Delay: 4.093e-04 seconds for T=1000K. Took 3.13s to compute\n", - "Computed Ignition Delay: 4.289e-04 seconds for T=975K. Took 3.06s to compute\n", - "Computed Ignition Delay: 3.911e-04 seconds for T=950K. Took 3.34s to compute\n", - "Computed Ignition Delay: 3.407e-04 seconds for T=925K. Took 3.21s to compute\n", - "Computed Ignition Delay: 3.145e-04 seconds for T=900K. Took 3.30s to compute\n", - "Computed Ignition Delay: 3.233e-04 seconds for T=850K. Took 3.51s to compute\n", - "Computed Ignition Delay: 3.439e-04 seconds for T=825K. Took 3.48s to compute\n", - "Computed Ignition Delay: 3.852e-04 seconds for T=800K. Took 3.63s to compute\n", - "Computed Ignition Delay: 6.824e-04 seconds for T=750K. Took 3.92s to compute\n", - "Computed Ignition Delay: 2.056e-03 seconds for T=700K. Took 4.04s to compute\n" - ] - } - ], - "source": [ - "for i, temperature in enumerate(T):\n", - " # Setup the gas and reactor\n", - " reactorTemperature = temperature\n", - " reactorPressure = 40.0*101325.0\n", - " gas.TP = reactorTemperature, reactorPressure\n", - " gas.set_equivalence_ratio(phi=1.0, fuel='c12h26', oxidizer={'o2':1.0, 'n2':3.76})\n", - " r = ct.Reactor(contents=gas)\n", - " reactorNetwork = ct.ReactorNet([r])\n", - "\n", - " # Create and empty data frame\n", - " timeHistory = pd.DataFrame(columns=timeHistory.columns)\n", - "\n", - " t0 = time.time()\n", - "\n", - " t = 0\n", - " counter = 0\n", - " while t < estimatedIgnitionDelayTimes[i]:\n", - " t = reactorNetwork.step()\n", - " if not counter % 20:\n", - " timeHistory.loc[t] = r.get_state()\n", - " counter += 1\n", - "\n", - " tau = ignitionDelay(timeHistory, 'oh')\n", - " t1 = time.time()\n", - "\n", - " print('Computed Ignition Delay: {:.3e} seconds for T={}K. Took {:3.2f}s to compute'.format(tau, temperature, t1-t0))\n", - "\n", - " ignitionDelays.set_value(index=i, col='ignDelay', value=tau)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Figure: ignition delay ($\\tau$) vs. the inverse of temperature ($\\frac{1000}{T}$). " - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "scrolled": false - }, "outputs": [ { "data": { @@ -481,7 +304,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", + " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -956,7 +779,7 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", @@ -976,7 +799,7 @@ " // Register the callback with on_msg.\n", " comm.on_msg(function(msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", - " // Pass the mpl event to the overriden (by mpl) onmessage function.\n", + " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data'])\n", " });\n", " return ws;\n", @@ -1128,9 +951,12 @@ " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", - " // select the cell after this one\n", - " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", - " IPython.notebook.select(index + 1);\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", @@ -1179,7 +1005,942 @@ { "data": { "text/html": [ - "" + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.figure()\n", + "plt.plot(timeHistory.index, timeHistory['oh'],'-o',color='b',markersize=4)\n", + "plt.xlabel('Time (s)',fontname='Times New Roman')\n", + "plt.ylabel('$\\mathdefault{OH\\, mass\\, fraction,}\\, Y_{OH}}$',fontname='Times New Roman')\n", + "\n", + "# Figure formatting:\n", + "plt.xlim([0,0.00075])\n", + "ax = plt.gca()\n", + "font = plt.matplotlib.font_manager.FontProperties(family='Times New Roman',size=14)\n", + "ax.annotate(\"\",xy=(tau,0.005), xytext=(0,0.005),arrowprops=dict(arrowstyle=\"<|-|>\",color='r',linewidth=2.0),fontsize=14,)\n", + "plt.annotate('Ignition Delay Time (IDT)', xy=(0,0), xytext=(0.00004, 0.00525), family='Times New Roman',fontsize=16);\n", + "\n", + "for tick in ax.xaxis.get_major_ticks():\n", + " tick.label1.set_fontsize(12)\n", + " tick.label1.set_fontname('Times New Roman')\n", + "for tick in ax.yaxis.get_major_ticks():\n", + " tick.label1.set_fontsize(12)\n", + " tick.label1.set_fontname('Times New Roman')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Illustration : NTC behavior\n", + "In the paper by Kogekar, et al., the reactor model is used to demonstrate the impacts of non-ideal behavior on IDTs in the **N**egative **T**emperature **C**oefficient region, where observed IDTs, counter to intuition, increase with increasing temperature." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Define the temperatures for which we will run the simulations" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "# Make a list of all the temperatures we would like to run simulations at\n", + "T = [1800, 1600, 1400, 1200, 1100, 1075, 1050, 1025, 1000, 975, 950, 925, 900, 850, 825, 800,\n", + " 750, 700]\n", + "\n", + "estimatedIgnitionDelayTimes = np.ones(len(T))\n", + "\n", + "# Set the initial guesses to a common value. We could probably speed up simulations \n", + "# by tuning this guess, but as seen in the figure above, the 'extra' time after igntion \n", + "# does not add many data points or simulation steps. The time savings would be small.\n", + "estimatedIgnitionDelayTimes[:] = 0.005\n", + "\n", + "# Now create a dataFrame out of these\n", + "ignitionDelays = pd.DataFrame(data={'T':T})\n", + "ignitionDelays['ignDelay'] = np.nan" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Run the code above for each temperature, and save the IDT for each." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Computed Ignition Delay: 6.357e-07 seconds for T=1800K. Took 2.36s to compute\n", + "Computed Ignition Delay: 1.585e-06 seconds for T=1600K. Took 2.67s to compute\n", + "Computed Ignition Delay: 5.785e-06 seconds for T=1400K. Took 2.71s to compute\n", + "Computed Ignition Delay: 3.911e-05 seconds for T=1200K. Took 3.00s to compute\n", + "Computed Ignition Delay: 1.326e-04 seconds for T=1100K. Took 3.14s to compute\n", + "Computed Ignition Delay: 1.839e-04 seconds for T=1075K. Took 3.32s to compute\n", + "Computed Ignition Delay: 2.533e-04 seconds for T=1050K. Took 3.45s to compute\n", + "Computed Ignition Delay: 3.365e-04 seconds for T=1025K. Took 3.97s to compute\n", + "Computed Ignition Delay: 4.093e-04 seconds for T=1000K. Took 4.06s to compute\n", + "Computed Ignition Delay: 4.289e-04 seconds for T=975K. Took 4.01s to compute\n", + "Computed Ignition Delay: 3.911e-04 seconds for T=950K. Took 3.94s to compute\n", + "Computed Ignition Delay: 3.407e-04 seconds for T=925K. Took 4.10s to compute\n", + "Computed Ignition Delay: 3.145e-04 seconds for T=900K. Took 3.74s to compute\n", + "Computed Ignition Delay: 3.233e-04 seconds for T=850K. Took 4.12s to compute\n", + "Computed Ignition Delay: 3.439e-04 seconds for T=825K. Took 4.26s to compute\n", + "Computed Ignition Delay: 3.852e-04 seconds for T=800K. Took 4.51s to compute\n", + "Computed Ignition Delay: 6.824e-04 seconds for T=750K. Took 4.37s to compute\n", + "Computed Ignition Delay: 2.056e-03 seconds for T=700K. Took 4.67s to compute\n" + ] + } + ], + "source": [ + "for i, temperature in enumerate(T):\n", + " # Set up the gas and reactor\n", + " reactorTemperature = temperature\n", + " reactorPressure = 40.0*101325.0\n", + " gas.TP = reactorTemperature, reactorPressure\n", + " gas.set_equivalence_ratio(phi=1.0, fuel='c12h26', oxidizer={'o2':1.0, 'n2':3.76})\n", + " r = ct.Reactor(contents=gas)\n", + " reactorNetwork = ct.ReactorNet([r])\n", + "\n", + " # Create an empty data frame\n", + " timeHistory = pd.DataFrame(columns=timeHistory.columns)\n", + "\n", + " t0 = time.time()\n", + "\n", + " t = 0\n", + " counter = 0\n", + " while t < estimatedIgnitionDelayTimes[i]:\n", + " t = reactorNetwork.step()\n", + " if not counter % 20:\n", + " timeHistory.loc[t] = r.get_state()\n", + " counter += 1\n", + "\n", + " tau = ignitionDelay(timeHistory, 'oh')\n", + " t1 = time.time()\n", + "\n", + " print('Computed Ignition Delay: {:.3e} seconds for T={}K. Took {:3.2f}s to compute'.format(tau, temperature, t1-t0))\n", + "\n", + " ignitionDelays.at[i, 'ignDelay'] = tau" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Figure: ignition delay ($\\tau$) vs. the inverse of temperature ($\\frac{1000}{T}$). " + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('