{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Twin Premixed Counter-Flow Flame Example" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example documents how to simulate two identical, axisymmetric, premixed jets of reactants shooting into each other. An illustration of this configuration is shown in the figure below" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import modules" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running Cantera Version: 2.3.0a3\n" ] } ], "source": [ "from __future__ import print_function\n", "from __future__ import division\n", "\n", "import cantera as ct\n", "import numpy as np\n", "\n", "print(\"Running Cantera Version: \" + str(ct.__version__))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Define the reactant conditions, gas mixture and kinetic mechanism associated with the gas" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "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", "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", "gas = ct.Solution('gri30.cti')\n", "\n", "# Create a CH4/Air premixed mixture with equivalence ratio=0.75\n", "gas.set_equivalence_ratio(0.75, 'CH4', {'O2':1.0, 'N2':3.76})\n", "gas.TP = To, Po\n", "\n", "# Set the velocity of the reactants\n", "# This is what determines the strain-rate\n", "axial_velocity = 2.0 # in m/s\n", "\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" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Define functions" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Differentiation function for data that has variable grid spacing Used here to\n", "# compute normal strain-rate\n", "def derivative(x, y):\n", " dydx = np.zeros(y.shape, y.dtype.type)\n", "\n", " dx = np.diff(x)\n", " dy = np.diff(y)\n", " dydx[0:-1] = dy/dx\n", "\n", " dydx[-1] = (y[-1] - y[-2])/(x[-1] - x[-2])\n", "\n", " return dydx\n", "\n", "def computeStrainRates(oppFlame):\n", " # Compute the derivative of axial velocity to obtain normal strain rate\n", " strainRates = derivative(oppFlame.grid, oppFlame.u)\n", "\n", " # Obtain the location of the max. strain rate upstream of the pre-heat zone.\n", " # This is the characteristic strain rate\n", " maxStrLocation = abs(strainRates).argmax()\n", " minVelocityPoint = oppFlame.u[:maxStrLocation].argmin()\n", "\n", " # Characteristic Strain Rate = K\n", " strainRatePoint = abs(strainRates[:minVelocityPoint]).argmax()\n", " K = abs(strainRates[strainRatePoint])\n", "\n", " return strainRates, strainRatePoint, K\n", "\n", "def computeConsumptionSpeed(oppFlame):\n", "\n", " Tb = max(oppFlame.T)\n", " Tu = min(oppFlame.T)\n", " rho_u = max(oppFlame.density)\n", "\n", " integrand = oppFlame.heat_release_rate/oppFlame.cp\n", "\n", " I = np.trapz(integrand, oppFlame.grid)\n", " Sc = I/(Tb - Tu)/rho_u\n", "\n", " return Sc\n", "\n", "# This function is called to run the solver\n", "def solveOpposedFlame(oppFlame, massFlux=0.12, loglevel=0,\n", " ratio=2, slope=0.3, curve=0.3, prune=0.05):\n", " \"\"\"\n", " Execute this function to run the Oppposed Flow Simulation This function\n", " takes a CounterFlowTwinPremixedFlame object as the first argument\n", " \"\"\"\n", "\n", " oppFlame.reactants.mdot = massFlux\n", " oppFlame.set_refine_criteria(ratio=ratio, slope=slope, curve=curve, prune=prune)\n", "\n", " oppFlame.show_solution()\n", " oppFlame.solve(loglevel, auto=True)\n", "\n", " # Compute the strain rate, just before the flame. This is not necessarily\n", " # the maximum We use the max. strain rate just upstream of the pre-heat zone\n", " # as this is the strain rate that computations comprare against, like when\n", " # plotting Su vs. K\n", " strainRates, strainRatePoint, K = computeStrainRates(oppFlame)\n", "\n", " return np.max(oppFlame.T), K, strainRatePoint" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Define a flame object, domain width and tranport model" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Define a domain half-width of 2.5 cm, meaning the whole domain is 5 cm wide\n", "width = 0.025\n", "\n", "# Create the flame object\n", "oppFlame = ct.CounterflowTwinPremixedFlame(gas, width=width)\n", "\n", "# Uncomment the following line to use a Multi-component formulation. Default is\n", "# mixture-averaged\n", "#oppFlame.transport_model = 'Multi'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Run the Solver" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> reactants <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", "\n", " Mass Flux: 2.268 kg/m^2/s \n", " Temperature: 300 K \n", " Mass Fractions: \n", " O2 0.2232 \n", " CH4 0.04197 \n", " N2 0.7348 \n", "\n", "\n", "\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> flame <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", "\n", " Pressure: 1.013e+05 Pa\n", "\n", "-------------------------------------------------------------------------------\n", " z u V T lambda H2 \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", "\n", "-------------------------------------------------------------------------------\n", " z H O O2 OH H2O \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", "\n", "-------------------------------------------------------------------------------\n", " z HO2 H2O2 C CH CH2 \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", "\n", "-------------------------------------------------------------------------------\n", " z CH2(S) CH3 CH4 CO CO2 \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", "\n", "-------------------------------------------------------------------------------\n", " z HCO CH2O CH2OH CH3O CH3OH \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", "\n", "-------------------------------------------------------------------------------\n", " z C2H C2H2 C2H3 C2H4 C2H5 \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", "\n", "-------------------------------------------------------------------------------\n", " z C2H6 HCCO CH2CO HCCOH N \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", "\n", "-------------------------------------------------------------------------------\n", " z NH NH2 NH3 NNH NO \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", "\n", "-------------------------------------------------------------------------------\n", " z NO2 N2O HNO CN HCN \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", "\n", "-------------------------------------------------------------------------------\n", " z H2CN HCNN HCNO HOCN HNCO \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", "\n", "-------------------------------------------------------------------------------\n", " z NCO N2 AR C3H7 C3H8 \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", "\n", "-------------------------------------------------------------------------------\n", " z 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", "\n", "\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> products <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", "\n", "\n", "-------------------------------------------------------------------------------\n", " z dummy \n", "-------------------------------------------------------------------------------\n", " 0 0 \n", "\n", "************ Solving on 7 point grid with energy equation enabled ************\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "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", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.008313 2.22\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [7] point grid(s).\n", "\n", "..............................................................................\n", "grid refinement disabled.\n", "\n", "******************** Solving with grid refinement enabled ********************\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [7] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 1 2 3 4 5 \n", " to resolve C2H2 C2H4 C2H6 CH CH2 CH2(S) CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCN HCO HNCO HO2 N2 N2O NO NO2 O O2 OH T V point 1 point 4 u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001139 5.734\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.002919 3.555\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [12] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 2 4 5 6 7 8 9 10 \n", " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCN HCO HNCO HO2 N2 N2O NO NO2 O O2 OH T V point 2 point 7 u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001139 5.653\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001442 5.86\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.002463 3.926\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [20] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 1 4 9 10 11 12 13 17 18 \n", " to resolve C C2H2 C2H3 C2H4 C2H6 CH CH2 CH2(S) CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCN HCO HNCO HO2 N2 N2O NO NO2 O O2 OH T V point 1 point 4 u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001139 5.647\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [29] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 0 10 14 15 16 17 18 23 26 27 \n", " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCN HCO HNCO HO2 N2 N2O NO NO2 O O2 OH T V point 0 point 10 point 23 u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 7.594e-05 6.151\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001442 6.013\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 4.561e-05 5.695\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", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [39] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 24 25 26 27 28 36 37 \n", " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCN HCO HNCO HO2 N2 N2O NO NO2 O O2 OH T V u \n", "##############################################################################\n", "refine: discarding point at 0.0148437\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 5.695e-05 5.862\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 7.208e-05 6.072\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0005474 4.974\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 7.306e-05 6.124\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.001248 4.287\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [45] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 28 29 30 31 32 33 \n", " to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO CO2 H H2 H2O H2O2 HCCO HCN HCO HNCO HO2 N2 N2O NO NO2 O O2 OH T V u \n", "##############################################################################\n", "refine: discarding point at 0.0170313\n", "refine: discarding point at 0.0173438\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001709 5.41\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [49] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 30 31 32 33 34 35 36 \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 HCO HNCO HO2 N2 N2O NO NO2 O O2 OH T V u \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001139 5.784\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0005767 5.383\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0003079 5.314\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [56] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 29 34 39 40 41 42 43 44 \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 N2 N2O NO NO2 O O2 OH T point 29 point 34 u \n", "##############################################################################\n", "refine: discarding point at 0.0179688\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0001709 5.61\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.001297 4.393\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [63] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 45 46 47 48 49 50 51 52 \n", " to resolve 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 HCO HNCO HO2 N2 NO NO2 O O2 OH T point 46 u \n", "##############################################################################\n", "refine: discarding point at 0.0184375\n", "refine: discarding point at 0.01875\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.0002563 5.356\n", "Attempt Newton solution of steady-state problem... failure. \n", "Take 10 timesteps 0.001297 4.473\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [69] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 42 50 51 52 53 54 55 56 57 \n", " to resolve 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 HCO HNCO HO2 N2 NO2 O O2 OH T point 42 point 53 u \n", "##############################################################################\n", "refine: discarding point at 0.0182813\n", "refine: discarding point at 0.0185938\n", "refine: discarding point at 0.0189063\n", "refine: discarding point at 0.0192188\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [74] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\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", "##############################################################################\n", "refine: discarding point at 0.0196875\n", "refine: discarding point at 0.0199219\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [82] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 51 52 55 56 57 58 59 60 61 62 \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", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [91] point grid(s).\n", "\n", "..............................................................................\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", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [98] point grid(s).\n", "\n", "..............................................................................\n", "##############################################################################\n", "Refining grid in flame.\n", " New points inserted after grid points 45 80 \n", " to resolve point 45 point 80 \n", "##############################################################################\n", "\n", "..............................................................................\n", "Attempt Newton solution of steady-state problem... success.\n", "\n", "Problem solved on [100] point grid(s).\n", "\n", "..............................................................................\n", "no new points needed in flame\n", "Solution saved to 'premixed_twin_flame.csv'.\n" ] } ], "source": [ "# The solver returns the peak temperature, strain rate and\n", "# the point which we ascribe to the characteristic strain rate.\n", "\n", "(T, K, strainRatePoint) = solveOpposedFlame(oppFlame, massFlux, loglevel=1)\n", "\n", "# You can plot/see all state space variables by calling oppFlame.foo where foo\n", "# 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)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "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" ] } ], "source": [ "Sc = computeConsumptionSpeed(oppFlame)\n", "\n", "print(\"Peak temperature: {0:.1f} K\".format(T))\n", "print(\"Strain Rate: {0:.1f} 1/s\".format(K))\n", "print(\"Consumption Speed: {0:.2f} cm/s\".format(Sc*100))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot figures\n", "\n", "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": {}, "source": [ "#### Axial velocity plot" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\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", " 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", " this.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 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);\n", " canvas.attr('height', height);\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 = $('');\n", " button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n", " 'ui-button-icon-only');\n", " button.attr('role', 'button');\n", " button.attr('aria-disabled', 'false');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", "\n", " var icon_img = $('');\n", " icon_img.addClass('ui-button-icon-primary ui-icon');\n", " icon_img.addClass(image);\n", " icon_img.addClass('ui-corner-all');\n", "\n", " var tooltip_span = $('');\n", " tooltip_span.addClass('ui-button-text');\n", " tooltip_span.html(tooltip);\n", "\n", " button.append(icon_img);\n", " button.append(tooltip_span);\n", "\n", " nav_element.append(button);\n", " }\n", "\n", " var fmt_picker_span = $('');\n", "\n", " var fmt_picker = $('');\n", " fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n", " fmt_picker_span.append(fmt_picker);\n", " nav_element.append(fmt_picker_span);\n", " this.format_dropdown = fmt_picker[0];\n", "\n", " for (var ind in mpl.extensions) {\n", " var fmt = mpl.extensions[ind];\n", " var option = $(\n", " '', {selected: fmt === mpl.default_extension}).html(fmt);\n", " fmt_picker.append(option)\n", " }\n", "\n", " // Add hover states to the ui-buttons\n", " $( \".ui-button\" ).hover(\n", " function() { $(this).addClass(\"ui-state-hover\");},\n", " function() { $(this).removeClass(\"ui-state-hover\");}\n", " );\n", "\n", " var status_bar = $('