flame_speed_with_convergence_analysis.ipynb (Source)

Flame Speed with Convergence Analysis

In this example we simulate a freely-propagating, adiabatic, 1-D flame and

  • Calculate its laminar burning velocity
  • Estimate the uncertainty in the laminar burning velocity calculation, due to grid size.

The error estimation and convergence analysis was developed and contributed by Richard West r.west@northeastern.edu in 2019. Please acknowledge it as such if you use it.

The figure below illustrates the setup, in a flame-fixed co-ordinate system. The reactants enter with density $\rho_{u}$, temperature $T_{u}$ and speed $S_{u}$. The products exit the flame at speed $S_{b}$, density $\rho_{b}$ and temperature $T_{b}$.

Freely Propagating Flame

Import Modules

In [4]:
import cantera as ct
import numpy as np
import pandas as pd


%config InlineBackend.figure_formats = ["svg"]
%matplotlib inline
from matplotlib import pyplot as plt
import matplotlib

from IPython.display import display, HTML

import scipy
import scipy.optimize

print(f"Running Cantera Version: {ct.__version__}")
Running Cantera Version: 3.0.0
In [5]:
# Import plotting modules and define plotting preference

plt.rcParams["axes.labelsize"] = 14
plt.rcParams["xtick.labelsize"] = 12
plt.rcParams["ytick.labelsize"] = 12
plt.rcParams["legend.fontsize"] = 10
plt.rcParams["figure.figsize"] = (8, 6)
plt.rcParams["figure.dpi"] = 120

# Get the best of both ggplot and seaborn
plt.style.use("ggplot")
plt.style.use("seaborn-v0_8-deep")

plt.rcParams["figure.autolayout"] = True

Estimate uncertainty from grid size and speeds

In [6]:
def extrapolate_uncertainty(grids, speeds, plot=True):
    """
    Given a list of grid sizes and a corresponding list of flame speeds,
    extrapolate and estimate the uncertainty in the final flame speed.
    Also makes a plot, unless called with `plot=False`.
    """
    grids = list(grids)
    speeds = list(speeds)

    def speed_from_grid_size(grid_size, true_speed, error):
        """
        Given a grid size (or an array or list of grid sizes)
        return a prediction (or array of predictions)
        of the computed flame speed, based on
        the parameters `true_speed` and `error`.

        It seems, from experience, that error scales roughly with
        1/grid_size, so we assume that form.
        """
        return true_speed + error / np.array(grid_size)

    # Fit the chosen form of speed_from_grid_size, to the last four
    # speed and grid size values.
    popt, pcov = scipy.optimize.curve_fit(speed_from_grid_size, grids[-4:], speeds[-4:])

    # How bad the fit was gives you some error, `percent_error_in_true_speed`.
    perr = np.sqrt(np.diag(pcov))
    true_speed_estimate = popt[0]
    percent_error_in_true_speed = perr[0] / popt[0]
    print(
        f"Fitted true_speed is {popt[0] * 100:.4f} ± {perr[0] * 100:.4f} cm/s "
        f"({percent_error_in_true_speed:.1%})"
    )

    # How far your extrapolated infinite grid value is from your extrapolated
    # (or interpolated) final grid value, gives you some other error, `estimated_percent_error`
    estimated_percent_error = (
        speed_from_grid_size(grids[-1], *popt) - true_speed_estimate
    ) / true_speed_estimate
    print(f"Estimated error in final calculation {estimated_percent_error:.1%}")

    # The total estimated error is the sum of these two errors.
    total_percent_error_estimate = abs(percent_error_in_true_speed) + abs(
        estimated_percent_error
    )
    print(f"Estimated total error {total_percent_error_estimate:.1%}")

    if plot:
        plt.semilogx(grids, speeds, "o-")
        plt.ylim(
            min(speeds[-5:] + [true_speed_estimate - perr[0]]) * 0.95,
            max(speeds[-5:] + [true_speed_estimate + perr[0]]) * 1.05,
        )
        plt.plot(grids[-4:], speeds[-4:], "or")
        extrapolated_grids = grids + [grids[-1] * i for i in range(2, 8)]
        plt.plot(
            extrapolated_grids, speed_from_grid_size(extrapolated_grids, *popt), ":r"
        )
        plt.xlim(*plt.xlim())
        plt.hlines(true_speed_estimate, *plt.xlim(), colors="r", linestyles="dashed")
        plt.hlines(
            true_speed_estimate + perr[0],
            *plt.xlim(),
            colors="r",
            linestyles="dashed",
            alpha=0.3,
        )
        plt.hlines(
            true_speed_estimate - perr[0],
            *plt.xlim(),
            colors="r",
            linestyles="dashed",
            alpha=0.3,
        )
        plt.fill_between(
            plt.xlim(),
            true_speed_estimate - perr[0],
            true_speed_estimate + perr[0],
            facecolor="red",
            alpha=0.1,
        )

        above = popt[1] / abs(
            popt[1]
        )  # will be +1 if approach from above or -1 if approach from below

        plt.annotate(
            "",
            xy=(grids[-1], true_speed_estimate),
            xycoords="data",
            xytext=(grids[-1], speed_from_grid_size(grids[-1], *popt)),
            textcoords="data",
            arrowprops=dict(
                arrowstyle="|-|, widthA=0.5, widthB=0.5",
                linewidth=1,
                connectionstyle="arc3",
                color="black",
                shrinkA=0,
                shrinkB=0,
            ),
        )

        plt.annotate(
            f"{abs(estimated_percent_error):.1%}",
            xy=(grids[-1], speed_from_grid_size(grids[-1], *popt)),
            xycoords="data",
            xytext=(5, 15 * above),
            va="center",
            textcoords="offset points",
            arrowprops=dict(arrowstyle="->", connectionstyle="arc3"),
        )

        plt.annotate(
            "",
            xy=(grids[-1] * 4, true_speed_estimate - (above * perr[0])),
            xycoords="data",
            xytext=(grids[-1] * 4, true_speed_estimate),
            textcoords="data",
            arrowprops=dict(
                arrowstyle="|-|, widthA=0.5, widthB=0.5",
                linewidth=1,
                connectionstyle="arc3",
                color="black",
                shrinkA=0,
                shrinkB=0,
            ),
        )
        plt.annotate(
            f"{abs(percent_error_in_true_speed):.1%}",
            xy=(grids[-1] * 4, true_speed_estimate - (above * perr[0])),
            xycoords="data",
            xytext=(5, -15 * above),
            va="center",
            textcoords="offset points",
            arrowprops=dict(arrowstyle="->", connectionstyle="arc3"),
        )

        plt.ylabel("Flame speed (m/s)")
        plt.xlabel("Grid size")
        plt.show()

    return true_speed_estimate, total_percent_error_estimate
In [7]:
def make_callback(flame):
    """
    Create and return a callback function that you will attach to
    a flame solver. The reason we define a function to make the callback function,
    instead of just defining the callback function, is so that it can store
    a pair of lists that persist between function calls, to store the
    values of grid size and flame speed.

    This factory returns the callback function, and the two lists:
    (callback, speeds, grids)
    """
    speeds = []
    grids = []

    def callback(_):
        speed = flame.velocity[0]
        grid = len(flame.grid)
        speeds.append(speed)
        grids.append(grid)
        print(f"Iteration {len(grids)}")
        print(f"Current flame speed is is {speed * 100:.4f} cm/s")
        if len(grids) < 5:
            return 1.0  #
        try:
            extrapolate_uncertainty(grids, speeds)
        except Exception as e:
            print("Couldn't estimate uncertainty. " + str(e))
            return 1.0  # continue anyway
        return 1.0

    return callback, speeds, grids

Define the reactant conditions, gas mixture and kinetic mechanism associated with the gas

In [8]:
# Inlet Temperature in Kelvin and Inlet Pressure in Pascals
# In this case we are setting the inlet T and P to room temperature conditions
To = 300
Po = 101325

# Define the gas-mixutre and kinetics
# In this case, we are choosing a GRI3.0 gas
gas = ct.Solution("gri30.yaml")

# Create a stoichiometric CH4/Air premixed mixture
gas.set_equivalence_ratio(1.0, "CH4", {"O2": 1.0, "N2": 3.76})
gas.TP = To, Po

Define flame simulation conditions

In [9]:
# Domain width in metres
width = 0.014

# Create the flame object
flame = ct.FreeFlame(gas, width=width)

# Define logging level
loglevel = 1

# Define tight tolerances for the solver
refine_criteria = {"ratio": 2, "slope": 0.01, "curve": 0.01}
flame.set_refine_criteria(**refine_criteria)

# Set maxiumum number of grid points to be very high (otherwise default is 1000)
flame.set_max_grid_points(flame.domains[flame.domain_index("flame")], 1e4)
In [10]:
# Set up the the callback function and lists of speeds and grids
callback, speeds, grids = make_callback(flame)
flame.set_steady_callback(callback)

Solve

After the first five iterations, it will start to estimate the uncertainty.

In [11]:
flame.solve(loglevel=loglevel, auto=True)

Su0 = flame.velocity[0]
print(f"Flame Speed is: {Su0 * 100:.2f} cm/s")
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05      5.455
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0003649      4.425
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.653e-05       5.86
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.734e-05      6.005
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0006666      4.488
Attempt Newton solution of steady-state problem...    success.

Problem solved on [9] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.028 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 0 1 2 3 4 5 6 7 
    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 HNO HO2 N N2 N2O NCO NH NH2 NO NO2 O O2 OH T point 0 point 6 velocity 
##############################################################################

*********** Solving on 17 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05       5.75
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.055e-05      5.579
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.887e-05      5.942
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.055e-05      6.116
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001756      5.505
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.041e-05      6.236
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0004004      4.705
Attempt Newton solution of steady-state problem...    success.

Problem solved on [17] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
    to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CN 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 1 point 12 velocity 
##############################################################################

*********** Solving on 32 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.424e-05      6.312
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.604e-05      5.689
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.283e-05      6.137
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001096      5.738
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.601e-05      6.025
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.172e-06      6.598
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001055      5.836
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.256e-06      6.694
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001069      5.614
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001015      5.517
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.709e-05      5.759
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0006942      4.539
Attempt Newton solution of steady-state problem...    success.

Problem solved on [32] point grid(s).
Iteration 1
Current flame speed is is 44.6983 cm/s

..............................................................................
grid refinement disabled.

******************** Solving with grid refinement enabled ********************

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [32] point grid(s).
Iteration 2
Current flame speed is is 44.6978 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
    to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CN 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 2 point 23 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      5.009
Attempt Newton solution of steady-state problem...    success.

Problem solved on [58] point grid(s).
Iteration 3
Current flame speed is is 30.3324 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 11 12 13 14 15 16 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 45 46 47 48 49 50 51 52 53 54 55 56 
    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 41 point 6 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     7.594e-05      5.215
Attempt Newton solution of steady-state problem...    success.

Problem solved on [105] point grid(s).
Iteration 4
Current flame speed is is 40.0036 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 16 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 45 46 47 48 49 50 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 
    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 point 72 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [172] point grid(s).
Iteration 5
Current flame speed is is 37.8572 cm/s
Fitted true_speed is 34.8135 ± 6.4414 cm/s (18.5%)
Estimated error in final calculation 3.6%
Estimated total error 22.1%
2023-11-05T18:07:18.018762image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 64 65 66 67 68 69 70 71 86 168 169 170 
    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 point 86 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [227] point grid(s).
Iteration 6
Current flame speed is is 37.4233 cm/s
Fitted true_speed is 41.7595 ± 3.3080 cm/s (7.9%)
Estimated error in final calculation -6.1%
Estimated total error 14.0%
2023-11-05T18:07:19.063990image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 19 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 106 223 224 225 
    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 point 106 point 19 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [290] point grid(s).
Iteration 7
Current flame speed is is 37.3209 cm/s
Fitted true_speed is 35.4723 ± 0.4057 cm/s (1.1%)
Estimated error in final calculation 4.5%
Estimated total error 5.6%
2023-11-05T18:07:20.189388image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 282 287 288 
    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 N2 NO NO2 O O2 OH T point 282 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [370] point grid(s).
Iteration 8
Current flame speed is is 37.3178 cm/s
Fitted true_speed is 36.7537 ± 0.2120 cm/s (0.6%)
Estimated error in final calculation 1.3%
Estimated total error 1.9%
2023-11-05T18:07:21.581780image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 36 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 191 
    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 HCO HNCO HO2 N2 NO NO2 O O2 OH T point 191 point 36 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [463] point grid(s).
Iteration 9
Current flame speed is is 37.3443 cm/s
Fitted true_speed is 37.2361 ± 0.0819 cm/s (0.2%)
Estimated error in final calculation 0.2%
Estimated total error 0.4%
2023-11-05T18:07:23.187950image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 
    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 HO2 N2 NO2 O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [604] point grid(s).
Iteration 10
Current flame speed is is 37.3846 cm/s
Fitted true_speed is 37.4287 ± 0.0363 cm/s (0.1%)
Estimated error in final calculation -0.2%
Estimated total error 0.3%
2023-11-05T18:07:25.249744image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 74 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 
    to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CO H H2 H2O H2O2 HCCO HCN HCO HO2 N2 O O2 OH T point 74 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [828] point grid(s).
Iteration 11
Current flame speed is is 37.4105 cm/s
Fitted true_speed is 37.4873 ± 0.0084 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%
2023-11-05T18:07:27.929542image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 
    to resolve C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2CO CH2OH CH3 CH3CHO CH3O CO H2O2 HCCO HCO HO2 OH 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [1077] point grid(s).
Iteration 12
Current flame speed is is 37.4467 cm/s
Fitted true_speed is 37.5145 ± 0.0121 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%
2023-11-05T18:07:31.514161image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 726 
    to resolve point 726 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [1078] point grid(s).
Iteration 13
Current flame speed is is 37.4498 cm/s
Fitted true_speed is 37.5275 ± 0.0169 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.3%
2023-11-05T18:07:34.747498image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
no new points needed in flame
Flame Speed is: 37.45 cm/s

Use the final lists of grid sizes and flame speeds to make one final extrapolation "best guess"

In [12]:
best_true_speed_estimate, best_total_percent_error_estimate = extrapolate_uncertainty(
    grids, speeds
)

best_true_speed_estimate
Fitted true_speed is 37.5275 ± 0.0169 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.3%
2023-11-05T18:07:35.217499image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
Out[12]:
0.37527457649259965

Analyze the error predictions

Now let's see how good our error estimates were, with hindsight.

If we assume that the final answer, with a very fine grid, has actually converged and is is the "truth", then we can find out how large the errors were in the previous values, and compare these with our estimated errors. This will show if our estimates are reasonable, or conservative, or too optimistic.

In [13]:
def analyze_errors(grids, speeds, true_speed):
    """
    If we assume that the final answer, with a very fine grid,
    has actually converged and is is the "truth", then we can
    find out how large the errors were in the previous values,
    and compare these with our estimated errors.
    This will show if our estimates are reasonable, or conservative, or too optimistic.
    """
    true_speed_estimates = np.full_like(speeds, np.NaN)
    total_percent_error_estimates = np.full_like(speeds, np.NaN)
    actual_extrapolated_percent_errors = np.full_like(speeds, np.NaN)
    actual_raw_percent_errors = np.full_like(speeds, np.NaN)
    for i in range(3, len(grids)):
        print(grids[: i + 1])
        true_speed_estimate, total_percent_error_estimate = extrapolate_uncertainty(
            grids[: i + 1], speeds[: i + 1], plot=False
        )
        actual_extrapolated_percent_error = (
            abs(true_speed_estimate - true_speed) / true_speed
        )
        actual_raw_percent_error = abs(speeds[i] - true_speed) / true_speed
        print(
            "Actual extrapolated error (with hindsight) "
            f"{actual_extrapolated_percent_error:.1%}"
        )
        print(f"Actual raw error (with hindsight) {actual_raw_percent_error:.1%}")

        true_speed_estimates[i] = true_speed_estimate
        total_percent_error_estimates[i] = total_percent_error_estimate
        actual_extrapolated_percent_errors[i] = actual_extrapolated_percent_error
        actual_raw_percent_errors[i] = actual_raw_percent_error
        print()

    plt.loglog(grids, actual_raw_percent_errors * 100, "o-", label="raw error")
    plt.loglog(
        grids,
        actual_extrapolated_percent_errors * 100,
        "o-",
        label="extrapolated error",
    )
    plt.loglog(
        grids, total_percent_error_estimates * 100, "o-", label="estimated error"
    )
    plt.ylabel("Error in flame speed (%)")
    plt.xlabel("Grid size")
    plt.legend()
    plt.title(flame.get_refine_criteria())
    plt.gca().get_yaxis().set_major_formatter(matplotlib.ticker.PercentFormatter())
    plt.show()
    flame.get_refine_criteria()

    data = pd.DataFrame(
        data={
            "actual error in raw value": actual_raw_percent_errors * 100,
            "actual error in extrapolated value": actual_extrapolated_percent_errors
            * 100,
            "estimated error": total_percent_error_estimates * 100,
        },
        index=grids,
    )
    display(data)
In [14]:
analyze_errors(grids, speeds, best_true_speed_estimate)
[32, 32, 58, 105]
Fitted true_speed is 31.4318 ± 8.5377 cm/s (27.2%)
Estimated error in final calculation 11.5%
Estimated total error 38.7%
Actual extrapolated error (with hindsight) 16.2%
Actual raw error (with hindsight) 6.6%

[32, 32, 58, 105, 172]
Fitted true_speed is 34.8135 ± 6.4414 cm/s (18.5%)
Estimated error in final calculation 3.6%
Estimated total error 22.1%
Actual extrapolated error (with hindsight) 7.2%
Actual raw error (with hindsight) 0.9%

[32, 32, 58, 105, 172, 227]
Fitted true_speed is 41.7595 ± 3.3080 cm/s (7.9%)
Estimated error in final calculation -6.1%
Estimated total error 14.0%
Actual extrapolated error (with hindsight) 11.3%
Actual raw error (with hindsight) 0.3%

[32, 32, 58, 105, 172, 227, 290]
Fitted true_speed is 35.4723 ± 0.4057 cm/s (1.1%)
Estimated error in final calculation 4.5%
Estimated total error 5.6%
Actual extrapolated error (with hindsight) 5.5%
Actual raw error (with hindsight) 0.6%

[32, 32, 58, 105, 172, 227, 290, 370]
Fitted true_speed is 36.7537 ± 0.2120 cm/s (0.6%)
Estimated error in final calculation 1.3%
Estimated total error 1.9%
Actual extrapolated error (with hindsight) 2.1%
Actual raw error (with hindsight) 0.6%

[32, 32, 58, 105, 172, 227, 290, 370, 463]
Fitted true_speed is 37.2361 ± 0.0819 cm/s (0.2%)
Estimated error in final calculation 0.2%
Estimated total error 0.4%
Actual extrapolated error (with hindsight) 0.8%
Actual raw error (with hindsight) 0.5%

[32, 32, 58, 105, 172, 227, 290, 370, 463, 604]
Fitted true_speed is 37.4287 ± 0.0363 cm/s (0.1%)
Estimated error in final calculation -0.2%
Estimated total error 0.3%
Actual extrapolated error (with hindsight) 0.3%
Actual raw error (with hindsight) 0.4%

[32, 32, 58, 105, 172, 227, 290, 370, 463, 604, 828]
Fitted true_speed is 37.4873 ± 0.0084 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%
Actual extrapolated error (with hindsight) 0.1%
Actual raw error (with hindsight) 0.3%

[32, 32, 58, 105, 172, 227, 290, 370, 463, 604, 828, 1077]
Fitted true_speed is 37.5145 ± 0.0121 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%
Actual extrapolated error (with hindsight) 0.0%
Actual raw error (with hindsight) 0.2%

[32, 32, 58, 105, 172, 227, 290, 370, 463, 604, 828, 1077, 1078]
Fitted true_speed is 37.5275 ± 0.0169 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.3%
Actual extrapolated error (with hindsight) 0.0%
Actual raw error (with hindsight) 0.2%

2023-11-05T18:07:35.778500image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
actual error in raw value actual error in extrapolated value estimated error
32 NaN NaN NaN
32 NaN NaN NaN
58 NaN NaN NaN
105 6.598085 16.243313 38.705261
172 0.878544 7.231856 22.070443
227 0.277591 11.277264 14.031632
290 0.550324 5.476341 5.635226
370 0.558652 2.061745 1.881478
463 0.488097 0.776279 0.430648
604 0.380804 0.263273 0.250958
828 0.311726 0.106941 0.227774
1077 0.215185 0.034476 0.228593
1078 0.206854 0.000000 0.264177

Repeat with less tight refine criteria

In [15]:
refine_criteria = {"ratio": 3, "slope": 0.1, "curve": 0.1}
In [16]:
# Reset the gas
gas.set_equivalence_ratio(1.0, "CH4", {"O2": 1.0, "N2": 3.76})
gas.TP = To, Po

# Create a new flame object
flame = ct.FreeFlame(gas, width=width)

flame.set_refine_criteria(**refine_criteria)
flame.set_max_grid_points(flame.domains[flame.domain_index("flame")], 1e4)

callback, speeds, grids = make_callback(flame)
flame.set_steady_callback(callback)

# Define logging level
loglevel = 1

flame.solve(loglevel=loglevel, auto=True)

Su0 = flame.velocity[0]
print(f"Flame Speed is: {Su0 * 100:.2f} cm/s")
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05      5.455
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0003649      4.425
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.653e-05       5.86
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.734e-05      6.005
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0006666      4.488
Attempt Newton solution of steady-state problem...    success.

Problem solved on [9] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.028 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 0 1 2 3 4 5 6 
    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 velocity 
##############################################################################

*********** Solving on 16 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05       5.75
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.055e-05      5.579
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     5.773e-05      6.027
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      2.74e-05      5.924
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     7.802e-05      5.655
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.852e-05      5.771
Attempt Newton solution of steady-state problem...    success.

Problem solved on [16] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 3 4 5 6 7 8 9 
    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 velocity 
##############################################################################

*********** Solving on 23 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.424e-05      6.312
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.604e-05      5.689
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     9.622e-06      6.227
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001644      5.518
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps       1.3e-05      6.218
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.083e-05      6.329
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     5.932e-05       5.87
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.056e-05      6.871
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001203      5.583
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     8.561e-05      5.809
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.095e-05      5.255
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      0.001562      4.092
Attempt Newton solution of steady-state problem...    success.

Problem solved on [23] point grid(s).
Iteration 1
Current flame speed is is 44.6981 cm/s

..............................................................................
grid refinement disabled.

******************** Solving with grid refinement enabled ********************

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [23] point grid(s).
Iteration 2
Current flame speed is is 44.6978 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 7 8 9 10 11 12 13 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      5.009
Attempt Newton solution of steady-state problem...    success.

Problem solved on [31] point grid(s).
Iteration 3
Current flame speed is is 30.3501 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 8 9 10 11 12 13 14 15 16 27 28 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     7.594e-05      5.214
Attempt Newton solution of steady-state problem...    success.

Problem solved on [42] point grid(s).
Iteration 4
Current flame speed is is 40.0123 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 12 13 14 15 16 17 18 19 20 21 40 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [53] point grid(s).
Iteration 5
Current flame speed is is 37.9210 cm/s
Fitted true_speed is 32.9928 ± 11.5353 cm/s (35.0%)
Estimated error in final calculation 10.1%
Estimated total error 45.1%
2023-11-05T18:07:52.668447image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 15 16 17 18 19 20 21 22 23 24 25 26 27 50 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [67] point grid(s).
Iteration 6
Current flame speed is is 37.5990 cm/s
Fitted true_speed is 45.7119 ± 6.3915 cm/s (14.0%)
Estimated error in final calculation -13.4%
Estimated total error 27.4%
2023-11-05T18:07:53.156892image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [85] point grid(s).
Iteration 7
Current flame speed is is 37.7021 cm/s
Fitted true_speed is 34.9890 ± 1.3730 cm/s (3.9%)
Estimated error in final calculation 6.4%
Estimated total error 10.4%
2023-11-05T18:07:53.663892image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    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 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [113] point grid(s).
Iteration 8
Current flame speed is is 37.9275 cm/s
Fitted true_speed is 37.8010 ± 0.3792 cm/s (1.0%)
Estimated error in final calculation -0.0%
Estimated total error 1.0%
2023-11-05T18:07:54.255963image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    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 
    to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CO CH2OH CH3 CH3CHO CH3O HCCO HCO 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [142] point grid(s).
Iteration 9
Current flame speed is is 38.2540 cm/s
Fitted true_speed is 38.7141 ± 0.2179 cm/s (0.6%)
Estimated error in final calculation -1.4%
Estimated total error 2.0%
2023-11-05T18:07:54.933964image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
no new points needed in flame
Flame Speed is: 38.25 cm/s
In [17]:
# Use the best true speed estimate from the fine grid tight criteria above
analyze_errors(grids, speeds, best_true_speed_estimate)
[23, 23, 31, 42]
Fitted true_speed is 26.0965 ± 15.3671 cm/s (58.9%)
Estimated error in final calculation 35.3%
Estimated total error 94.2%
Actual extrapolated error (with hindsight) 30.5%
Actual raw error (with hindsight) 6.6%

[23, 23, 31, 42, 53]
Fitted true_speed is 32.9928 ± 11.5353 cm/s (35.0%)
Estimated error in final calculation 10.1%
Estimated total error 45.1%
Actual extrapolated error (with hindsight) 12.1%
Actual raw error (with hindsight) 1.0%

[23, 23, 31, 42, 53, 67]
Fitted true_speed is 45.7119 ± 6.3915 cm/s (14.0%)
Estimated error in final calculation -13.4%
Estimated total error 27.4%
Actual extrapolated error (with hindsight) 21.8%
Actual raw error (with hindsight) 0.2%

[23, 23, 31, 42, 53, 67, 85]
Fitted true_speed is 34.9890 ± 1.3730 cm/s (3.9%)
Estimated error in final calculation 6.4%
Estimated total error 10.4%
Actual extrapolated error (with hindsight) 6.8%
Actual raw error (with hindsight) 0.5%

[23, 23, 31, 42, 53, 67, 85, 113]
Fitted true_speed is 37.8010 ± 0.3792 cm/s (1.0%)
Estimated error in final calculation -0.0%
Estimated total error 1.0%
Actual extrapolated error (with hindsight) 0.7%
Actual raw error (with hindsight) 1.1%

[23, 23, 31, 42, 53, 67, 85, 113, 142]
Fitted true_speed is 38.7141 ± 0.2179 cm/s (0.6%)
Estimated error in final calculation -1.4%
Estimated total error 2.0%
Actual extrapolated error (with hindsight) 3.2%
Actual raw error (with hindsight) 1.9%

2023-11-05T18:07:55.495111image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
actual error in raw value actual error in extrapolated value estimated error
23 NaN NaN NaN
23 NaN NaN NaN
31 NaN NaN NaN
42 6.621435 30.460181 94.208066
53 1.048546 12.083658 45.110086
67 0.190661 21.809250 27.413437
85 0.465314 6.764259 10.360387
113 1.066129 0.728839 1.026614
142 1.935950 3.161962 2.004120

Default (loose) criteria

In [18]:
flame = ct.FreeFlame(gas, width=width)
flame.get_refine_criteria()
refine_criteria = flame.get_refine_criteria()
refine_criteria.update({"prune": 0})
refine_criteria
Out[18]:
{'ratio': 10.0, 'slope': 0.8, 'curve': 0.8, 'prune': 0}
In [19]:
gas.set_equivalence_ratio(1.0, "CH4", {"O2": 1.0, "N2": 3.76})
gas.TP = To, Po

# Create a new flame object
flame = ct.FreeFlame(gas, width=width)

flame.set_refine_criteria(**refine_criteria)
flame.set_max_grid_points(flame.domains[flame.domain_index("flame")], 1e4)

callback, speeds, grids = make_callback(flame)
flame.set_steady_callback(callback)

# Define logging level
loglevel = 1

flame.solve(loglevel=loglevel, auto=True)

Su0 = flame.velocity[0]
print(f"Flame Speed is: {Su0 * 100:.2f} cm/s")
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05      5.455
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0003649      4.425
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.653e-05       5.86
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.734e-05      6.005
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0006666      4.488
Attempt Newton solution of steady-state problem...    success.

Problem solved on [9] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.028 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 1 2 3 4 
    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 HCN HCO HNCO HO2 N N2 NCO NO NO2 O O2 OH T velocity 
##############################################################################

*********** Solving on 13 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05      5.751
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.055e-05       5.58
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      4.33e-05      5.984
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.312e-05      5.985
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     8.778e-05      5.609
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.124e-05      5.671
Attempt Newton solution of steady-state problem...    success.

Problem solved on [13] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 4 5 6 
    to resolve C 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 HCN HCO HNCO HO2 N N2 NCO NO2 O O2 OH T velocity 
##############################################################################

*********** Solving on 16 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05       5.76
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.082e-05       5.59
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001948      5.043
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.027e-05      6.376
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.463e-05      6.611
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     8.332e-05      5.851
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     7.415e-06      6.836
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     8.446e-05      5.675
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0003207       5.31
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      2.14e-05      5.776
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0005485      4.579
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps       0.01406      1.764
Attempt Newton solution of steady-state problem...    success.

Problem solved on [16] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.112 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 5 6 7 
    to resolve C 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 HCN HCO HNCO HO2 N N2 NCO NO2 O O2 OH T velocity 
##############################################################################

*********** Solving on 19 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05      5.762
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.082e-05      5.596
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      0.001559      4.049
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.935e-05      5.904
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.583e-05      5.707
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.343e-05      6.296
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     5.005e-05       5.92
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.167e-05      5.878
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.006e-05      5.984
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      2.14e-05      6.426
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.428e-05      5.995
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.661e-05      6.025
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      6.95e-05      5.678
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0007916        4.7
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.642e-05      5.823
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0006771      4.519
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps       0.01157      2.455
Attempt Newton solution of steady-state problem...    success.

Problem solved on [19] point grid(s).
Iteration 1
Current flame speed is is 44.8126 cm/s

..............................................................................
grid refinement disabled.

******************** Solving with grid refinement enabled ********************

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [19] point grid(s).
Iteration 2
Current flame speed is is 44.8121 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 7 8 
    to resolve C 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 HCN HCO HNCO HO2 N N2 NCO NO2 O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      5.015
Attempt Newton solution of steady-state problem...    success.

Problem solved on [22] point grid(s).
Iteration 3
Current flame speed is is 30.2398 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 7 8 9 10 
    to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CO H H2 H2O2 HCCO HCCOH HCN HCNO HCO HNCO N2 NH3 NO2 O OH 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     7.594e-05      5.227
Attempt Newton solution of steady-state problem...    success.

Problem solved on [26] point grid(s).
Iteration 4
Current flame speed is is 40.7840 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 7 8 9 10 11 12 
    to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2OH CH3 CH3CHO CH3O CH4 CO H2O HCCO HCCOH HCN HCNO HCO HNCO N N2 NCO NO2 O OH 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [32] point grid(s).
Iteration 5
Current flame speed is is 38.7786 cm/s
Fitted true_speed is 34.0902 ± 19.9313 cm/s (58.5%)
Estimated error in final calculation 10.0%
Estimated total error 68.4%
2023-11-05T18:08:18.407364image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 12 13 14 15 
    to resolve C C2H2 C2H3 C2H5 C3H7 CH CH2 CH2(S) CH2OH HCCO HCCOH HCO 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [36] point grid(s).
Iteration 6
Current flame speed is is 41.3077 cm/s
Fitted true_speed is 56.6055 ± 9.9760 cm/s (17.6%)
Estimated error in final calculation -25.9%
Estimated total error 43.5%
2023-11-05T18:08:18.823363image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
no new points needed in flame
Flame Speed is: 41.31 cm/s
In [20]:
analyze_errors(grids, speeds, best_true_speed_estimate)
[19, 19, 22, 26]
Fitted true_speed is 18.8343 ± 30.5814 cm/s (162.4%)
Estimated error in final calculation 92.1%
Estimated total error 254.5%
Actual extrapolated error (with hindsight) 49.8%
Actual raw error (with hindsight) 8.7%

[19, 19, 22, 26, 32]
Fitted true_speed is 34.0902 ± 19.9313 cm/s (58.5%)
Estimated error in final calculation 10.0%
Estimated total error 68.4%
Actual extrapolated error (with hindsight) 9.2%
Actual raw error (with hindsight) 3.3%

[19, 19, 22, 26, 32, 36]
Fitted true_speed is 56.6055 ± 9.9760 cm/s (17.6%)
Estimated error in final calculation -25.9%
Estimated total error 43.5%
Actual extrapolated error (with hindsight) 50.8%
Actual raw error (with hindsight) 10.1%

2023-11-05T18:08:19.275363image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
actual error in raw value actual error in extrapolated value estimated error
19 NaN NaN NaN
19 NaN NaN NaN
22 NaN NaN NaN
26 8.677759 49.812034 254.460955
32 3.333974 9.159402 68.438540
36 10.073331 50.837497 43.478182

Middling refine criteria

In [21]:
refine_criteria = {"ratio": 3, "slope": 0.1, "curve": 0.1}
In [22]:
# Reset the gas
gas.set_equivalence_ratio(1.0, "CH4", {"O2": 1.0, "N2": 3.76})
gas.TP = To, Po

# Create a new flame object
flame = ct.FreeFlame(gas, width=width)

flame.set_refine_criteria(**refine_criteria)
flame.set_max_grid_points(flame.domains[flame.domain_index("flame")], 1e4)

callback, speeds, grids = make_callback(flame)
flame.set_steady_callback(callback)

# Define logging level
loglevel = 1

flame.solve(loglevel=loglevel, auto=True)

Su0 = flame.velocity[0]
print(f"Flame Speed is: {Su0 * 100:.2f} cm/s")
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05      5.455
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0003649      4.425
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.653e-05       5.86
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.734e-05      6.005
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0006666      4.488
Attempt Newton solution of steady-state problem...    success.

Problem solved on [9] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.028 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 0 1 2 3 4 5 6 
    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 velocity 
##############################################################################

*********** Solving on 16 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.136e-05       5.75
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.055e-05      5.579
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     5.773e-05      6.027
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      2.74e-05      5.924
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     7.802e-05      5.655
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.852e-05      5.771
Attempt Newton solution of steady-state problem...    success.

Problem solved on [16] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 3 4 5 6 7 8 9 
    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 velocity 
##############################################################################

*********** Solving on 23 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.424e-05      6.312
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     3.604e-05      5.689
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     9.622e-06      6.227
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001644      5.518
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps       1.3e-05      6.218
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.083e-05      6.329
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     5.932e-05       5.87
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     1.056e-05      6.871
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001203      5.583
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     8.561e-05      5.809
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.095e-05      5.255
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      0.001562      4.092
Attempt Newton solution of steady-state problem...    success.

Problem solved on [23] point grid(s).
Iteration 1
Current flame speed is is 44.6981 cm/s

..............................................................................
grid refinement disabled.

******************** Solving with grid refinement enabled ********************

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [23] point grid(s).
Iteration 2
Current flame speed is is 44.6978 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 7 8 9 10 11 12 13 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      5.009
Attempt Newton solution of steady-state problem...    success.

Problem solved on [31] point grid(s).
Iteration 3
Current flame speed is is 30.3501 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 8 9 10 11 12 13 14 15 16 27 28 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     7.594e-05      5.214
Attempt Newton solution of steady-state problem...    success.

Problem solved on [42] point grid(s).
Iteration 4
Current flame speed is is 40.0123 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 12 13 14 15 16 17 18 19 20 21 40 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [53] point grid(s).
Iteration 5
Current flame speed is is 37.9210 cm/s
Fitted true_speed is 32.9928 ± 11.5353 cm/s (35.0%)
Estimated error in final calculation 10.1%
Estimated total error 45.1%
2023-11-05T18:08:36.721277image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 15 16 17 18 19 20 21 22 23 24 25 26 27 50 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [67] point grid(s).
Iteration 6
Current flame speed is is 37.5990 cm/s
Fitted true_speed is 45.7119 ± 6.3915 cm/s (14.0%)
Estimated error in final calculation -13.4%
Estimated total error 27.4%
2023-11-05T18:08:37.213041image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [85] point grid(s).
Iteration 7
Current flame speed is is 37.7021 cm/s
Fitted true_speed is 34.9890 ± 1.3730 cm/s (3.9%)
Estimated error in final calculation 6.4%
Estimated total error 10.4%
2023-11-05T18:08:37.745472image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    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 
    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 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [113] point grid(s).
Iteration 8
Current flame speed is is 37.9275 cm/s
Fitted true_speed is 37.8010 ± 0.3792 cm/s (1.0%)
Estimated error in final calculation -0.0%
Estimated total error 1.0%
2023-11-05T18:08:38.438852image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    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 
    to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CO CH2OH CH3 CH3CHO CH3O HCCO HCO 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [142] point grid(s).
Iteration 9
Current flame speed is is 38.2540 cm/s
Fitted true_speed is 38.7141 ± 0.2179 cm/s (0.6%)
Estimated error in final calculation -1.4%
Estimated total error 2.0%
2023-11-05T18:08:39.152751image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
no new points needed in flame
Flame Speed is: 38.25 cm/s
In [23]:
analyze_errors(grids, speeds, best_true_speed_estimate)
[23, 23, 31, 42]
Fitted true_speed is 26.0965 ± 15.3671 cm/s (58.9%)
Estimated error in final calculation 35.3%
Estimated total error 94.2%
Actual extrapolated error (with hindsight) 30.5%
Actual raw error (with hindsight) 6.6%

[23, 23, 31, 42, 53]
Fitted true_speed is 32.9928 ± 11.5353 cm/s (35.0%)
Estimated error in final calculation 10.1%
Estimated total error 45.1%
Actual extrapolated error (with hindsight) 12.1%
Actual raw error (with hindsight) 1.0%

[23, 23, 31, 42, 53, 67]
Fitted true_speed is 45.7119 ± 6.3915 cm/s (14.0%)
Estimated error in final calculation -13.4%
Estimated total error 27.4%
Actual extrapolated error (with hindsight) 21.8%
Actual raw error (with hindsight) 0.2%

[23, 23, 31, 42, 53, 67, 85]
Fitted true_speed is 34.9890 ± 1.3730 cm/s (3.9%)
Estimated error in final calculation 6.4%
Estimated total error 10.4%
Actual extrapolated error (with hindsight) 6.8%
Actual raw error (with hindsight) 0.5%

[23, 23, 31, 42, 53, 67, 85, 113]
Fitted true_speed is 37.8010 ± 0.3792 cm/s (1.0%)
Estimated error in final calculation -0.0%
Estimated total error 1.0%
Actual extrapolated error (with hindsight) 0.7%
Actual raw error (with hindsight) 1.1%

[23, 23, 31, 42, 53, 67, 85, 113, 142]
Fitted true_speed is 38.7141 ± 0.2179 cm/s (0.6%)
Estimated error in final calculation -1.4%
Estimated total error 2.0%
Actual extrapolated error (with hindsight) 3.2%
Actual raw error (with hindsight) 1.9%

2023-11-05T18:08:39.677752image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
actual error in raw value actual error in extrapolated value estimated error
23 NaN NaN NaN
23 NaN NaN NaN
31 NaN NaN NaN
42 6.621435 30.460181 94.208066
53 1.048546 12.083658 45.110086
67 0.190661 21.809250 27.413437
85 0.465314 6.764259 10.360387
113 1.066129 0.728839 1.026614
142 1.935950 3.161962 2.004120

Try a Hydrogen flame (still with GRI mech)

In [24]:
# Tight criteria
refine_criteria = {"ratio": 2, "slope": 0.01, "curve": 0.01}
In [25]:
# Reset the gas
gas.set_equivalence_ratio(1.0, "H2", {"O2": 1.0, "N2": 3.76})
gas.TP = To, Po

# Create a new flame object
flame = ct.FreeFlame(gas, width=width)

flame.set_refine_criteria(**refine_criteria)
flame.set_max_grid_points(flame.domains[flame.domain_index("flame")], 1e4)

callback, speeds, grids = make_callback(flame)
flame.set_steady_callback(callback)

# Define logging level
loglevel = 1

flame.solve(loglevel=loglevel, auto=True)

Su0 = flame.velocity[0]
print(f"Flame Speed is: {Su0 * 100:.2f} cm/s")
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.746e-06      7.147
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001216      5.304
Attempt Newton solution of steady-state problem...    success.

Problem solved on [9] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.028 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 0 1 2 3 4 5 6 7 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 0 point 6 velocity 
##############################################################################

*********** Solving on 17 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      3.56e-06      7.384
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.055e-05      5.804
Attempt Newton solution of steady-state problem...    success.

Problem solved on [17] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 1 3 4 5 6 7 8 9 10 11 12 13 14 15 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 1 point 12 velocity 
##############################################################################

*********** Solving on 31 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.373e-06      7.429
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.007e-06      7.408
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001026      5.606
Attempt Newton solution of steady-state problem...    success.

Problem solved on [31] point grid(s).
Iteration 1
Current flame speed is is 196.2847 cm/s

..............................................................................
grid refinement disabled.

******************** Solving with grid refinement enabled ********************

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [31] point grid(s).
Iteration 2
Current flame speed is is 196.2849 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 22 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      4.724
Attempt Newton solution of steady-state problem...    success.

Problem solved on [55] point grid(s).
Iteration 3
Current flame speed is is 338.7851 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 5 10 11 12 13 14 15 16 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 45 46 47 48 49 50 51 52 53 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 38 point 5 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      4.549
Attempt Newton solution of steady-state problem...    success.

Problem solved on [100] point grid(s).
Iteration 4
Current flame speed is is 371.4092 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 4 15 16 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 45 46 47 48 49 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 4 point 67 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [168] point grid(s).
Iteration 5
Current flame speed is is 302.8679 cm/s
Fitted true_speed is 387.0255 ± 56.3136 cm/s (14.6%)
Estimated error in final calculation -7.8%
Estimated total error 22.4%
2023-11-05T18:08:48.669190image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 3 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 45 46 47 48 49 50 51 56 57 58 59 60 61 165 166 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO O O2 OH T point 3 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [211] point grid(s).
Iteration 6
Current flame speed is is 269.1805 cm/s
Fitted true_speed is 277.4475 ± 45.1324 cm/s (16.3%)
Estimated error in final calculation 7.6%
Estimated total error 23.8%
2023-11-05T18:08:50.149379image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 2 18 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 51 52 53 54 55 56 57 58 59 60 61 62 63 87 207 208 209 
    to resolve H H2 H2O H2O2 HO2 N2 N2O NO O O2 OH T point 18 point 2 point 87 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [258] point grid(s).
Iteration 7
Current flame speed is is 251.3992 cm/s
Fitted true_speed is 179.2606 ± 9.0015 cm/s (5.0%)
Estimated error in final calculation 42.1%
Estimated total error 47.1%
2023-11-05T18:08:51.433442image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 18 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 107 250 254 255 256 
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T point 107 point 18 point 250 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [314] point grid(s).
Iteration 8
Current flame speed is is 242.3121 cm/s
Fitted true_speed is 168.0459 ± 10.3078 cm/s (6.1%)
Estimated error in final calculation 42.0%
Estimated total error 48.1%
2023-11-05T18:08:52.727440image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 17 29 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 130 301 310 311 312 
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T point 130 point 17 point 29 point 301 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [384] point grid(s).
Iteration 9
Current flame speed is is 237.6932 cm/s
Fitted true_speed is 196.6826 ± 7.4651 cm/s (3.8%)
Estimated error in final calculation 19.7%
Estimated total error 23.5%
2023-11-05T18:08:54.200161image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 29 35 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 197 376 381 382 
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T point 197 point 29 point 35 point 376 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [482] point grid(s).
Iteration 10
Current flame speed is is 235.3565 cm/s
Fitted true_speed is 215.4622 ± 4.2600 cm/s (2.0%)
Estimated error in final calculation 8.6%
Estimated total error 10.6%
2023-11-05T18:08:55.917638image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 
    to resolve H H2 H2O H2O2 HO2 N2 O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [627] point grid(s).
Iteration 11
Current flame speed is is 234.1690 cm/s
Fitted true_speed is 225.3146 ± 2.1534 cm/s (1.0%)
Estimated error in final calculation 3.6%
Estimated total error 4.6%
2023-11-05T18:08:58.071552image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 
    to resolve H H2 H2O H2O2 HO2 N2 O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [825] point grid(s).
Iteration 12
Current flame speed is is 233.5845 cm/s
Fitted true_speed is 229.6882 ± 0.8939 cm/s (0.4%)
Estimated error in final calculation 1.6%
Estimated total error 1.9%
2023-11-05T18:09:00.761079image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 76 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 477 
    to resolve H2O2 HO2 OH T point 477 point 76 velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [942] point grid(s).
Iteration 13
Current flame speed is is 233.3031 cm/s
Fitted true_speed is 231.1330 ± 0.2485 cm/s (0.1%)
Estimated error in final calculation 0.9%
Estimated total error 1.0%
2023-11-05T18:09:03.781199image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 595 
    to resolve HO2 point 595 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [985] point grid(s).
Iteration 14
Current flame speed is is 233.2641 cm/s
Fitted true_speed is 231.6437 ± 0.0624 cm/s (0.0%)
Estimated error in final calculation 0.7%
Estimated total error 0.7%
2023-11-05T18:09:06.793973image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 204 289 
    to resolve point 204 point 289 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [987] point grid(s).
Iteration 15
Current flame speed is is 233.2541 cm/s
Fitted true_speed is 231.5636 ± 0.1389 cm/s (0.1%)
Estimated error in final calculation 0.7%
Estimated total error 0.8%
2023-11-05T18:09:09.847467image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
no new points needed in flame
Flame Speed is: 233.25 cm/s
In [26]:
# get a new best true speed estimate
best_true_speed_estimate, best_total_percent_error_estimate = extrapolate_uncertainty(
    grids, speeds
)
Fitted true_speed is 231.5636 ± 0.1389 cm/s (0.1%)
Estimated error in final calculation 0.7%
Estimated total error 0.8%
2023-11-05T18:09:10.297439image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
In [27]:
analyze_errors(grids, speeds, best_true_speed_estimate)
[31, 31, 55, 100]
Fitted true_speed is 468.1312 ± 24.3574 cm/s (5.2%)
Estimated error in final calculation -17.7%
Estimated total error 22.9%
Actual extrapolated error (with hindsight) 102.2%
Actual raw error (with hindsight) 60.4%

[31, 31, 55, 100, 168]
Fitted true_speed is 387.0255 ± 56.3136 cm/s (14.6%)
Estimated error in final calculation -7.8%
Estimated total error 22.4%
Actual extrapolated error (with hindsight) 67.1%
Actual raw error (with hindsight) 30.8%

[31, 31, 55, 100, 168, 211]
Fitted true_speed is 277.4475 ± 45.1324 cm/s (16.3%)
Estimated error in final calculation 7.6%
Estimated total error 23.8%
Actual extrapolated error (with hindsight) 19.8%
Actual raw error (with hindsight) 16.2%

[31, 31, 55, 100, 168, 211, 258]
Fitted true_speed is 179.2606 ± 9.0015 cm/s (5.0%)
Estimated error in final calculation 42.1%
Estimated total error 47.1%
Actual extrapolated error (with hindsight) 22.6%
Actual raw error (with hindsight) 8.6%

[31, 31, 55, 100, 168, 211, 258, 314]
Fitted true_speed is 168.0459 ± 10.3078 cm/s (6.1%)
Estimated error in final calculation 42.0%
Estimated total error 48.1%
Actual extrapolated error (with hindsight) 27.4%
Actual raw error (with hindsight) 4.6%

[31, 31, 55, 100, 168, 211, 258, 314, 384]
Fitted true_speed is 196.6826 ± 7.4651 cm/s (3.8%)
Estimated error in final calculation 19.7%
Estimated total error 23.5%
Actual extrapolated error (with hindsight) 15.1%
Actual raw error (with hindsight) 2.6%

[31, 31, 55, 100, 168, 211, 258, 314, 384, 482]
Fitted true_speed is 215.4622 ± 4.2600 cm/s (2.0%)
Estimated error in final calculation 8.6%
Estimated total error 10.6%
Actual extrapolated error (with hindsight) 7.0%
Actual raw error (with hindsight) 1.6%

[31, 31, 55, 100, 168, 211, 258, 314, 384, 482, 627]
Fitted true_speed is 225.3146 ± 2.1534 cm/s (1.0%)
Estimated error in final calculation 3.6%
Estimated total error 4.6%
Actual extrapolated error (with hindsight) 2.7%
Actual raw error (with hindsight) 1.1%

[31, 31, 55, 100, 168, 211, 258, 314, 384, 482, 627, 825]
Fitted true_speed is 229.6882 ± 0.8939 cm/s (0.4%)
Estimated error in final calculation 1.6%
Estimated total error 1.9%
Actual extrapolated error (with hindsight) 0.8%
Actual raw error (with hindsight) 0.9%

[31, 31, 55, 100, 168, 211, 258, 314, 384, 482, 627, 825, 942]
Fitted true_speed is 231.1330 ± 0.2485 cm/s (0.1%)
Estimated error in final calculation 0.9%
Estimated total error 1.0%
Actual extrapolated error (with hindsight) 0.2%
Actual raw error (with hindsight) 0.8%

[31, 31, 55, 100, 168, 211, 258, 314, 384, 482, 627, 825, 942, 985]
Fitted true_speed is 231.6437 ± 0.0624 cm/s (0.0%)
Estimated error in final calculation 0.7%
Estimated total error 0.7%
Actual extrapolated error (with hindsight) 0.0%
Actual raw error (with hindsight) 0.7%

[31, 31, 55, 100, 168, 211, 258, 314, 384, 482, 627, 825, 942, 985, 987]
Fitted true_speed is 231.5636 ± 0.1389 cm/s (0.1%)
Estimated error in final calculation 0.7%
Estimated total error 0.8%
Actual extrapolated error (with hindsight) 0.0%
Actual raw error (with hindsight) 0.7%

2023-11-05T18:09:10.846247image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
actual error in raw value actual error in extrapolated value estimated error
31 NaN NaN NaN
31 NaN NaN NaN
55 NaN NaN NaN
100 60.391857 102.160937 22.941655
168 30.792503 67.135681 22.397651
211 16.244722 19.814787 23.844963
258 8.565925 22.586881 47.073794
314 4.641706 27.429914 48.149855
384 2.647045 15.063273 23.453250
482 1.637931 6.953373 10.582288
627 1.125118 2.698635 4.568336
825 0.872723 0.809901 1.943660
942 0.751198 0.185981 1.025681
985 0.734359 0.034590 0.722065
987 0.730035 0.000000 0.787288

Middling refine criteria, Hydrogen flame

In [28]:
refine_criteria = {"ratio": 3, "slope": 0.1, "curve": 0.1}
In [29]:
# Reset the gas
gas.set_equivalence_ratio(1.0, "H2", {"O2": 1.0, "N2": 3.76})
gas.TP = To, Po

# Create a new flame object
flame = ct.FreeFlame(gas, width=width)

flame.set_refine_criteria(**refine_criteria)
flame.set_max_grid_points(flame.domains[flame.domain_index("flame")], 1e4)

callback, speeds, grids = make_callback(flame)
flame.set_steady_callback(callback)

# Define logging level
loglevel = 1

flame.solve(loglevel=loglevel, auto=True)

Su0 = flame.velocity[0]
print(f"Flame Speed is: {Su0 * 100:.2f} cm/s")
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.746e-06      7.147
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001216      5.304
Attempt Newton solution of steady-state problem...    success.

Problem solved on [9] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.028 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 0 1 2 3 4 5 6 7 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T velocity 
##############################################################################

*********** Solving on 17 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps      3.56e-06      7.384
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     4.055e-05      5.804
Attempt Newton solution of steady-state problem...    success.

Problem solved on [17] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 3 4 5 6 7 8 9 12 13 14 15 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T velocity 
##############################################################################

*********** Solving on 28 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     2.373e-06      7.429
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     6.007e-06      7.408
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001026      5.606
Attempt Newton solution of steady-state problem...    success.

Problem solved on [28] point grid(s).
Iteration 1
Current flame speed is is 196.2847 cm/s

..............................................................................
grid refinement disabled.

******************** Solving with grid refinement enabled ********************

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [28] point grid(s).
Iteration 2
Current flame speed is is 196.2849 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 7 8 9 10 11 12 13 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      4.724
Attempt Newton solution of steady-state problem...    success.

Problem solved on [36] point grid(s).
Iteration 3
Current flame speed is is 338.7851 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 9 10 11 12 13 14 15 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure. 
Take 10 timesteps     0.0001709      4.443
Attempt Newton solution of steady-state problem...    success.

Problem solved on [43] point grid(s).
Iteration 4
Current flame speed is is 371.4091 cm/s

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 12 13 14 15 16 17 18 19 
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [51] point grid(s).
Iteration 5
Current flame speed is is 302.8603 cm/s
Fitted true_speed is 515.4260 ± 143.9783 cm/s (27.9%)
Estimated error in final calculation -30.5%
Estimated total error 58.4%
2023-11-05T18:09:17.317962image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 14 15 16 17 18 19 20 21 22 23 
    to resolve H H2 H2O H2O2 HO2 N2 N2O NNH NO O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [61] point grid(s).
Iteration 6
Current flame speed is is 269.1529 cm/s
Fitted true_speed is 169.2920 ± 90.5725 cm/s (53.5%)
Estimated error in final calculation 67.3%
Estimated total error 120.8%
2023-11-05T18:09:18.025961image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 17 18 19 20 21 22 23 24 25 26 27 28 29 
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [74] point grid(s).
Iteration 7
Current flame speed is is 251.2720 cm/s
Fitted true_speed is 74.8902 ± 37.9581 cm/s (50.7%)
Estimated error in final calculation 222.0%
Estimated total error 272.6%
2023-11-05T18:09:18.561042image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [93] point grid(s).
Iteration 8
Current flame speed is is 242.1372 cm/s
Fitted true_speed is 163.1254 ± 17.8971 cm/s (11.0%)
Estimated error in final calculation 45.2%
Estimated total error 56.1%
2023-11-05T18:09:19.138502image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    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 
    to resolve H2O2 HO2 N2 O OH T velocity 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [114] point grid(s).
Iteration 9
Current flame speed is is 237.2039 cm/s
Fitted true_speed is 198.6249 ± 7.6417 cm/s (3.8%)
Estimated error in final calculation 18.3%
Estimated total error 22.2%
2023-11-05T18:09:19.755502image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 
    to resolve H2O2 HO2 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [129] point grid(s).
Iteration 10
Current flame speed is is 234.8525 cm/s
Fitted true_speed is 212.2587 ± 1.7464 cm/s (0.8%)
Estimated error in final calculation 10.4%
Estimated total error 11.2%
2023-11-05T18:09:20.427752image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 41 42 43 44 
    to resolve HO2 
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    success.

Problem solved on [133] point grid(s).
Iteration 11
Current flame speed is is 234.6051 cm/s
Fitted true_speed is 216.5964 ± 0.7098 cm/s (0.3%)
Estimated error in final calculation 8.2%
Estimated total error 8.5%
2023-11-05T18:09:21.082690image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
..............................................................................
no new points needed in flame
Flame Speed is: 234.61 cm/s
In [30]:
analyze_errors(grids, speeds, best_true_speed_estimate)
[28, 28, 36, 43]
Fitted true_speed is 729.5779 ± 52.4436 cm/s (7.2%)
Estimated error in final calculation -47.3%
Estimated total error 54.4%
Actual extrapolated error (with hindsight) 215.1%
Actual raw error (with hindsight) 60.4%

[28, 28, 36, 43, 51]
Fitted true_speed is 515.4260 ± 143.9783 cm/s (27.9%)
Estimated error in final calculation -30.5%
Estimated total error 58.4%
Actual extrapolated error (with hindsight) 122.6%
Actual raw error (with hindsight) 30.8%

[28, 28, 36, 43, 51, 61]
Fitted true_speed is 169.2920 ± 90.5725 cm/s (53.5%)
Estimated error in final calculation 67.3%
Estimated total error 120.8%
Actual extrapolated error (with hindsight) 26.9%
Actual raw error (with hindsight) 16.2%

[28, 28, 36, 43, 51, 61, 74]
Fitted true_speed is 74.8902 ± 37.9581 cm/s (50.7%)
Estimated error in final calculation 222.0%
Estimated total error 272.6%
Actual extrapolated error (with hindsight) 67.7%
Actual raw error (with hindsight) 8.5%

[28, 28, 36, 43, 51, 61, 74, 93]
Fitted true_speed is 163.1254 ± 17.8971 cm/s (11.0%)
Estimated error in final calculation 45.2%
Estimated total error 56.1%
Actual extrapolated error (with hindsight) 29.6%
Actual raw error (with hindsight) 4.6%

[28, 28, 36, 43, 51, 61, 74, 93, 114]
Fitted true_speed is 198.6249 ± 7.6417 cm/s (3.8%)
Estimated error in final calculation 18.3%
Estimated total error 22.2%
Actual extrapolated error (with hindsight) 14.2%
Actual raw error (with hindsight) 2.4%

[28, 28, 36, 43, 51, 61, 74, 93, 114, 129]
Fitted true_speed is 212.2587 ± 1.7464 cm/s (0.8%)
Estimated error in final calculation 10.4%
Estimated total error 11.2%
Actual extrapolated error (with hindsight) 8.3%
Actual raw error (with hindsight) 1.4%

[28, 28, 36, 43, 51, 61, 74, 93, 114, 129, 133]
Fitted true_speed is 216.5964 ± 0.7098 cm/s (0.3%)
Estimated error in final calculation 8.2%
Estimated total error 8.5%
Actual extrapolated error (with hindsight) 6.5%
Actual raw error (with hindsight) 1.3%

2023-11-05T18:09:21.586485image/svg+xmlMatplotlib v3.8.1, https://matplotlib.org/
actual error in raw value actual error in extrapolated value estimated error
28 NaN NaN NaN
28 NaN NaN NaN
36 NaN NaN NaN
43 60.391813 215.065841 54.445157
51 30.789218 122.585053 58.421792
61 16.232816 26.891783 120.817607
74 8.510982 67.658918 272.645223
93 4.566177 29.554841 56.134037
114 2.435738 14.224484 22.186259
129 1.420300 8.336790 11.247385
133 1.313447 6.463550 8.549603