Flame Speed with Convergence Analysis#

Requires: cantera >= 3.0.0, matplotlib >= 2.0, pandas

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.

Tags: Python combustion 1D flow flame speed premixed flame plotting

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#

import cantera as ct
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
import matplotlib
import scipy
import scipy.optimize

Define plotting preference#

plt.style.use("ggplot")
plt.style.use("seaborn-v0_8-deep")
plt.rcParams["figure.constrained_layout.use"] = True

Estimate uncertainty from grid size and speeds#

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:
        fig, ax = plt.subplots()
        ax.semilogx(grids, speeds, "o-")
        ax.set_ylim(
            min(speeds[-5:] + [true_speed_estimate - perr[0]]) * 0.95,
            max(speeds[-5:] + [true_speed_estimate + perr[0]]) * 1.05,
        )
        ax.plot(grids[-4:], speeds[-4:], "or")
        extrapolated_grids = grids + [grids[-1] * i for i in range(2, 8)]
        ax.plot(
            extrapolated_grids, speed_from_grid_size(extrapolated_grids, *popt), ":r"
        )
        ax.set_xlim(*ax.get_xlim())  # Prevent automatic expansion of axis limits
        ax.hlines(true_speed_estimate, *ax.get_xlim(), colors="r", linestyles="dashed")
        ax.hlines(
            true_speed_estimate + perr[0],
            *ax.get_xlim(),
            colors="r",
            linestyles="dashed",
            alpha=0.3,
        )
        ax.hlines(
            true_speed_estimate - perr[0],
            *ax.get_xlim(),
            colors="r",
            linestyles="dashed",
            alpha=0.3,
        )
        ax.fill_between(
            ax.get_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

        ax.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,
            ),
        )

        ax.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"),
        )

        ax.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,
            ),
        )
        ax.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"),
        )

        ax.set(xlabel="Grid size", ylabel="Flame speed (m/s)")

    return true_speed_estimate, total_percent_error_estimate
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#

# 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 mixture 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#

# 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 maximum number of grid points to be very high (otherwise default is 1000)
flame.set_max_grid_points(flame.domains[flame.domain_index("flame")], 1e4)

# 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.

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

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

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     2.136e-05      5.493
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0003649      4.613
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.006235      3.334
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 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 NH3 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     6.082e-05      5.551
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.924e-05      6.068
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      2.74e-05      5.886
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.000156      5.659
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.389e-05      6.034
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0005338      4.544
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps       0.01368      1.324
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

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

..............................................................................
##############################################################################
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 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 point 1 point 12 velocity
##############################################################################

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

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

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 2 5 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 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     7.594e-05      5.497
Attempt Newton solution of steady-state problem...    success.

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

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 54 55 56 57
    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 42 velocity
##############################################################################

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

Problem solved on [107] point grid(s).
Iteration 5
Current flame speed is is 37.7735 cm/s
Fitted true_speed is 36.6476 ± 5.2396 cm/s (14.3%)
Estimated error in final calculation -0.7%
Estimated total error 15.0%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 9 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 57 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 103 104 105
    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 74 point 9 velocity
##############################################################################

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

Problem solved on [181] point grid(s).
Iteration 6
Current flame speed is is 37.3888 cm/s
Fitted true_speed is 41.1612 ± 3.0043 cm/s (7.3%)
Estimated error in final calculation -4.6%
Estimated total error 11.9%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 10 15 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 102 172 173 177 178 179
    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 10 point 102 point 15 point 172 point 173 velocity
##############################################################################

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

Problem solved on [251] point grid(s).
Iteration 7
Current flame speed is is 37.3091 cm/s
Fitted true_speed is 36.6078 ± 0.1725 cm/s (0.5%)
Estimated error in final calculation 1.6%
Estimated total error 2.0%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 120 121 122 123 124 125 126 127 248 249
    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 velocity
##############################################################################

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

Problem solved on [337] point grid(s).
Iteration 8
Current flame speed is is 37.3150 cm/s
Fitted true_speed is 37.0292 ± 0.0822 cm/s (0.2%)
Estimated error in final calculation 0.6%
Estimated total error 0.8%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 135 136 137 331
    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 331 velocity
##############################################################################

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

Problem solved on [428] point grid(s).
Iteration 9
Current flame speed is is 37.3516 cm/s
Fitted true_speed is 37.2883 ± 0.0617 cm/s (0.2%)
Estimated error in final calculation 0.1%
Estimated total error 0.3%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 202 203 204 205 206 228 420
    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 point 228 point 420 velocity
##############################################################################

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

Problem solved on [570] point grid(s).
Iteration 10
Current flame speed is is 37.3914 cm/s
Fitted true_speed is 37.4425 ± 0.0329 cm/s (0.1%)
Estimated error in final calculation -0.2%
Estimated total error 0.3%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 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
    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 velocity
##############################################################################

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

Problem solved on [793] point grid(s).
Iteration 11
Current flame speed is is 37.4204 cm/s
Fitted true_speed is 37.4995 ± 0.0032 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 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 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
    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 [1042] point grid(s).
Iteration 12
Current flame speed is is 37.4531 cm/s
Fitted true_speed is 37.5165 ± 0.0092 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 217
    to resolve CH3O
##############################################################################

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

Problem solved on [1043] point grid(s).
Iteration 13
Current flame speed is is 37.4572 cm/s
Fitted true_speed is 37.5302 ± 0.0132 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%

..............................................................................
no new points needed in flame
Flame Speed is: 37.46 cm/s

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

flame speed convergence analysis
Fitted true_speed is 37.5302 ± 0.0132 cm/s (0.0%)
Estimated error in final calculation -0.2%
Estimated total error 0.2%

0.3753021869028595

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.

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()

    fig, ax = plt.subplots()
    ax.loglog(grids, actual_raw_percent_errors * 100, "o-", label="raw error")
    ax.loglog(
        grids,
        actual_extrapolated_percent_errors * 100,
        "o-",
        label="extrapolated error",
    )
    ax.loglog(
        grids, total_percent_error_estimates * 100, "o-", label="estimated error"
    )
    ax.set(xlabel="Grid size", ylabel="Error in flame speed (%)")
    ax.legend()
    ax.set_title(flame.get_refine_criteria())
    ax.get_yaxis().set_major_formatter(matplotlib.ticker.PercentFormatter())
    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,
    )
    return data


analyze_errors(grids, speeds, best_true_speed_estimate)
{'ratio': 2.0, 'slope': 0.01, 'curve': 0.01, 'prune': 0.0}
[17, 17, 32, 59]
Fitted true_speed is 34.1266 ± 7.0498 cm/s (20.7%)
Estimated error in final calculation 2.1%
Estimated total error 22.8%
Actual extrapolated error (with hindsight) 9.1%
Actual raw error (with hindsight) 4.3%

[17, 17, 32, 59, 107]
Fitted true_speed is 36.6476 ± 5.2396 cm/s (14.3%)
Estimated error in final calculation -0.7%
Estimated total error 15.0%
Actual extrapolated error (with hindsight) 2.4%
Actual raw error (with hindsight) 0.6%

[17, 17, 32, 59, 107, 181]
Fitted true_speed is 41.1612 ± 3.0043 cm/s (7.3%)
Estimated error in final calculation -4.6%
Estimated total error 11.9%
Actual extrapolated error (with hindsight) 9.7%
Actual raw error (with hindsight) 0.4%

[17, 17, 32, 59, 107, 181, 251]
Fitted true_speed is 36.6078 ± 0.1725 cm/s (0.5%)
Estimated error in final calculation 1.6%
Estimated total error 2.0%
Actual extrapolated error (with hindsight) 2.5%
Actual raw error (with hindsight) 0.6%

[17, 17, 32, 59, 107, 181, 251, 337]
Fitted true_speed is 37.0292 ± 0.0822 cm/s (0.2%)
Estimated error in final calculation 0.6%
Estimated total error 0.8%
Actual extrapolated error (with hindsight) 1.3%
Actual raw error (with hindsight) 0.6%

[17, 17, 32, 59, 107, 181, 251, 337, 428]
Fitted true_speed is 37.2883 ± 0.0617 cm/s (0.2%)
Estimated error in final calculation 0.1%
Estimated total error 0.3%
Actual extrapolated error (with hindsight) 0.6%
Actual raw error (with hindsight) 0.5%

[17, 17, 32, 59, 107, 181, 251, 337, 428, 570]
Fitted true_speed is 37.4425 ± 0.0329 cm/s (0.1%)
Estimated error in final calculation -0.2%
Estimated total error 0.3%
Actual extrapolated error (with hindsight) 0.2%
Actual raw error (with hindsight) 0.4%

[17, 17, 32, 59, 107, 181, 251, 337, 428, 570, 793]
Fitted true_speed is 37.4995 ± 0.0032 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%

[17, 17, 32, 59, 107, 181, 251, 337, 428, 570, 793, 1042]
Fitted true_speed is 37.5165 ± 0.0092 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%

[17, 17, 32, 59, 107, 181, 251, 337, 428, 570, 793, 1042, 1043]
Fitted true_speed is 37.5302 ± 0.0132 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%
actual error in raw value actual error in extrapolated value estimated error
17 NaN NaN NaN
17 NaN NaN NaN
32 NaN NaN NaN
59 4.284722 9.068952 22.750584
107 0.648118 2.351690 14.963788
181 0.376845 9.674786 11.859041
251 0.589259 2.457800 2.045202
337 0.573559 1.334973 0.835049
428 0.476038 0.644643 0.254728
570 0.369820 0.233823 0.258882
793 0.292590 0.081785 0.218611
1042 0.205450 0.036577 0.206588
1043 0.194651 0.000000 0.241770


Repeat with less tight refine criteria#

refine_criteria = {"ratio": 3, "slope": 0.1, "curve": 0.1}

# 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")

# Use the best true speed estimate from the fine grid tight criteria above
analyze_errors(grids, speeds, best_true_speed_estimate)
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • {'ratio': 3.0, 'slope': 0.1, 'curve': 0.1, 'prune': 0.0}
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     2.136e-05      5.493
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0003649      4.613
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.006235      3.334
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 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 NH3 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     2.136e-05       5.75
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     6.082e-05      5.551
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.924e-05      6.068
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      2.74e-05      5.886
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.000156      5.659
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.389e-05      6.034
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0005338      4.544
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps       0.01368      1.324
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

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

..............................................................................
##############################################################################
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
##############################################################################

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

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

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 7 8 9 10 11 12 13 14 19
    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.496
Attempt Newton solution of steady-state problem...    success.

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

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

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

Problem solved on [45] point grid(s).
Iteration 5
Current flame speed is is 37.8534 cm/s
Fitted true_speed is 38.2130 ± 8.2263 cm/s (21.5%)
Estimated error in final calculation -3.5%
Estimated total error 25.0%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 11 12 13 14 15 16 17 18 19 20 21 22 23
    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 [58] point grid(s).
Iteration 6
Current flame speed is is 37.5887 cm/s
Fitted true_speed is 45.7259 ± 5.3906 cm/s (11.8%)
Estimated error in final calculation -13.4%
Estimated total error 25.2%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 54
    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 [77] point grid(s).
Iteration 7
Current flame speed is is 37.7312 cm/s
Fitted true_speed is 36.2388 ± 0.7515 cm/s (2.1%)
Estimated error in final calculation 3.2%
Estimated total error 5.3%

..............................................................................
##############################################################################
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 38 39 40 41 42 43 44 45 46
    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 [105] point grid(s).
Iteration 8
Current flame speed is is 37.9687 cm/s
Fitted true_speed is 37.9305 ± 0.3235 cm/s (0.9%)
Estimated error in final calculation -0.2%
Estimated total error 1.1%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 30 31 32 33 34 35 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CO CH2OH CH3 CH3CHO CH3O HCCO HCO
##############################################################################

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

Problem solved on [134] point grid(s).
Iteration 9
Current flame speed is is 38.2864 cm/s
Fitted true_speed is 38.6933 ± 0.1932 cm/s (0.5%)
Estimated error in final calculation -1.3%
Estimated total error 1.8%

..............................................................................
no new points needed in flame
Flame Speed is: 38.29 cm/s
[17, 17, 24, 34]
Fitted true_speed is 34.1344 ± 11.1977 cm/s (32.8%)
Estimated error in final calculation 3.2%
Estimated total error 36.0%
Actual extrapolated error (with hindsight) 9.0%
Actual raw error (with hindsight) 4.3%

[17, 17, 24, 34, 45]
Fitted true_speed is 38.2130 ± 8.2263 cm/s (21.5%)
Estimated error in final calculation -3.5%
Estimated total error 25.0%
Actual extrapolated error (with hindsight) 1.8%
Actual raw error (with hindsight) 0.9%

[17, 17, 24, 34, 45, 58]
Fitted true_speed is 45.7259 ± 5.3906 cm/s (11.8%)
Estimated error in final calculation -13.4%
Estimated total error 25.2%
Actual extrapolated error (with hindsight) 21.8%
Actual raw error (with hindsight) 0.2%

[17, 17, 24, 34, 45, 58, 77]
Fitted true_speed is 36.2388 ± 0.7515 cm/s (2.1%)
Estimated error in final calculation 3.2%
Estimated total error 5.3%
Actual extrapolated error (with hindsight) 3.4%
Actual raw error (with hindsight) 0.5%

[17, 17, 24, 34, 45, 58, 77, 105]
Fitted true_speed is 37.9305 ± 0.3235 cm/s (0.9%)
Estimated error in final calculation -0.2%
Estimated total error 1.1%
Actual extrapolated error (with hindsight) 1.1%
Actual raw error (with hindsight) 1.2%

[17, 17, 24, 34, 45, 58, 77, 105, 134]
Fitted true_speed is 38.6933 ± 0.1932 cm/s (0.5%)
Estimated error in final calculation -1.3%
Estimated total error 1.8%
Actual extrapolated error (with hindsight) 3.1%
Actual raw error (with hindsight) 2.0%
actual error in raw value actual error in extrapolated value estimated error
17 NaN NaN NaN
17 NaN NaN NaN
24 NaN NaN NaN
34 4.347154 9.048150 35.996809
45 0.861057 1.819285 25.040149
58 0.155766 21.837677 25.218775
77 0.535434 3.440964 5.304431
105 1.168300 1.066517 1.087984
134 2.014831 3.099162 1.805927


Default (loose) criteria#

flame = ct.FreeFlame(gas, width=width)
refine_criteria = flame.get_refine_criteria()
refine_criteria.update({"prune": 0})
refine_criteria

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")

analyze_errors(grids, speeds, best_true_speed_estimate)
  • flame speed convergence analysis
  • flame speed convergence analysis
  • {'ratio': 10.0, 'slope': 0.8, 'curve': 0.8, 'prune': 0.0}
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     2.136e-05      5.493
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0003649      4.613
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.006235      3.334
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 2 3 4 5
    to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CO CO2 H H2 H2O2 HCCO HCN HCNO HCO HNCO HO2 N2 N2O NH3 NO2 O O2 OH
##############################################################################

*********** Solving on 13 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     6.082e-05      5.551
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      4.33e-05      6.079
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     3.082e-05      5.987
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0001756      5.574
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.562e-05      6.082
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0006006      4.467
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps       0.01539      1.272
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 3 4 5
    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 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.582
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0003897      4.714
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     8.669e-06      6.817
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     6.583e-05      5.988
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     2.343e-05      6.023
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     5.005e-05      6.011
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     4.751e-05      5.728
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0005411      4.922
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.354e-05      6.447
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     7.713e-05      5.016
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.001977      3.884
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps         0.076    0.02631
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

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

..............................................................................
##############################################################################
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 CO2 H H2 H2O H2O2 HCCO HCN HCO HNCO HO2 N N2 NCO NO NO2 O O2 OH T velocity
##############################################################################

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

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

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 5 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 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.505
Attempt Newton solution of steady-state problem...    success.

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

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

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

Problem solved on [28] point grid(s).
Iteration 5
Current flame speed is is 39.8788 cm/s
Fitted true_speed is 45.8609 ± 14.4143 cm/s (31.4%)
Estimated error in final calculation -14.6%
Estimated total error 46.1%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 9 10 11 12
    to resolve C C2H2 C2H3 C2H4 C2H5 C3H7 C3H8 CH2 CH2(S) CH2OH CH3CHO HCCO HCCOH HCNO HCO
##############################################################################

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

Problem solved on [32] point grid(s).
Iteration 6
Current flame speed is is 42.1753 cm/s
Fitted true_speed is 60.8599 ± 8.3884 cm/s (13.8%)
Estimated error in final calculation -29.0%
Estimated total error 42.8%

..............................................................................
no new points needed in flame
Flame Speed is: 42.18 cm/s
[16, 16, 19, 23]
Fitted true_speed is 37.6562 ± 21.1378 cm/s (56.1%)
Estimated error in final calculation -3.1%
Estimated total error 59.2%
Actual extrapolated error (with hindsight) 0.3%
Actual raw error (with hindsight) 7.2%

[16, 16, 19, 23, 28]
Fitted true_speed is 45.8609 ± 14.4143 cm/s (31.4%)
Estimated error in final calculation -14.6%
Estimated total error 46.1%
Actual extrapolated error (with hindsight) 22.2%
Actual raw error (with hindsight) 6.3%

[16, 16, 19, 23, 28, 32]
Fitted true_speed is 60.8599 ± 8.3884 cm/s (13.8%)
Estimated error in final calculation -29.0%
Estimated total error 42.8%
Actual extrapolated error (with hindsight) 62.2%
Actual raw error (with hindsight) 12.4%
actual error in raw value actual error in extrapolated value estimated error
16 NaN NaN NaN
16 NaN NaN NaN
19 NaN NaN NaN
23 7.221354 0.335707 59.191253
28 6.257826 22.197342 46.069353
32 12.376885 62.162463 42.777553


Middling refine criteria#

refine_criteria = {"ratio": 3, "slope": 0.1, "curve": 0.1}

# 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")
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     2.136e-05      5.493
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0003649      4.613
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.006235      3.334
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 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 NH3 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     2.136e-05       5.75
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     6.082e-05      5.551
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.924e-05      6.068
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      2.74e-05      5.886
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.000156      5.659
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     1.389e-05      6.034
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0005338      4.544
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps       0.01368      1.324
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

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

..............................................................................
##############################################################################
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
##############################################################################

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

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

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 7 8 9 10 11 12 13 14 19
    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.496
Attempt Newton solution of steady-state problem...    success.

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

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

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

Problem solved on [45] point grid(s).
Iteration 5
Current flame speed is is 37.8534 cm/s
Fitted true_speed is 38.2130 ± 8.2263 cm/s (21.5%)
Estimated error in final calculation -3.5%
Estimated total error 25.0%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 11 12 13 14 15 16 17 18 19 20 21 22 23
    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 [58] point grid(s).
Iteration 6
Current flame speed is is 37.5887 cm/s
Fitted true_speed is 45.7259 ± 5.3906 cm/s (11.8%)
Estimated error in final calculation -13.4%
Estimated total error 25.2%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 54
    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 [77] point grid(s).
Iteration 7
Current flame speed is is 37.7312 cm/s
Fitted true_speed is 36.2388 ± 0.7515 cm/s (2.1%)
Estimated error in final calculation 3.2%
Estimated total error 5.3%

..............................................................................
##############################################################################
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 38 39 40 41 42 43 44 45 46
    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 [105] point grid(s).
Iteration 8
Current flame speed is is 37.9687 cm/s
Fitted true_speed is 37.9305 ± 0.3235 cm/s (0.9%)
Estimated error in final calculation -0.2%
Estimated total error 1.1%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 30 31 32 33 34 35 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    to resolve C C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CO CH2OH CH3 CH3CHO CH3O HCCO HCO
##############################################################################

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

Problem solved on [134] point grid(s).
Iteration 9
Current flame speed is is 38.2864 cm/s
Fitted true_speed is 38.6933 ± 0.1932 cm/s (0.5%)
Estimated error in final calculation -1.3%
Estimated total error 1.8%

..............................................................................
no new points needed in flame
Flame Speed is: 38.29 cm/s
{'ratio': 3.0, 'slope': 0.1, 'curve': 0.1, 'prune': 0.0}
[17, 17, 24, 34]
Fitted true_speed is 34.1344 ± 11.1977 cm/s (32.8%)
Estimated error in final calculation 3.2%
Estimated total error 36.0%
Actual extrapolated error (with hindsight) 9.0%
Actual raw error (with hindsight) 4.3%

[17, 17, 24, 34, 45]
Fitted true_speed is 38.2130 ± 8.2263 cm/s (21.5%)
Estimated error in final calculation -3.5%
Estimated total error 25.0%
Actual extrapolated error (with hindsight) 1.8%
Actual raw error (with hindsight) 0.9%

[17, 17, 24, 34, 45, 58]
Fitted true_speed is 45.7259 ± 5.3906 cm/s (11.8%)
Estimated error in final calculation -13.4%
Estimated total error 25.2%
Actual extrapolated error (with hindsight) 21.8%
Actual raw error (with hindsight) 0.2%

[17, 17, 24, 34, 45, 58, 77]
Fitted true_speed is 36.2388 ± 0.7515 cm/s (2.1%)
Estimated error in final calculation 3.2%
Estimated total error 5.3%
Actual extrapolated error (with hindsight) 3.4%
Actual raw error (with hindsight) 0.5%

[17, 17, 24, 34, 45, 58, 77, 105]
Fitted true_speed is 37.9305 ± 0.3235 cm/s (0.9%)
Estimated error in final calculation -0.2%
Estimated total error 1.1%
Actual extrapolated error (with hindsight) 1.1%
Actual raw error (with hindsight) 1.2%

[17, 17, 24, 34, 45, 58, 77, 105, 134]
Fitted true_speed is 38.6933 ± 0.1932 cm/s (0.5%)
Estimated error in final calculation -1.3%
Estimated total error 1.8%
Actual extrapolated error (with hindsight) 3.1%
Actual raw error (with hindsight) 2.0%
actual error in raw value actual error in extrapolated value estimated error
17 NaN NaN NaN
17 NaN NaN NaN
24 NaN NaN NaN
34 4.347154 9.048150 35.996809
45 0.861057 1.819285 25.040149
58 0.155766 21.837677 25.218775
77 0.535434 3.440964 5.304431
105 1.168300 1.066517 1.087984
134 2.014831 3.099162 1.805927


Try a Hydrogen flame (still with GRI mech)#

# Tight criteria
refine_criteria = {"ratio": 2, "slope": 0.01, "curve": 0.01}

# 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")
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     4.746e-06      7.177
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0001216      5.217
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.385
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     4.055e-05      5.927
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

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

..............................................................................
##############################################################################
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 H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 1 point 12 velocity
##############################################################################

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

Problem solved on [32] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
Refining grid in flame.
    New points inserted after grid points 2 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 H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 2 point 23 velocity
##############################################################################

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

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     2.373e-06      7.468
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     6.007e-06      7.345
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     6.842e-05      5.896
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

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

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 7 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
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 40 point 7 velocity
##############################################################################

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0002563       4.29
Attempt Newton solution of steady-state problem...    success.

Problem solved on [102] point grid(s).
Iteration 5
Current flame speed is is 338.1343 cm/s
Fitted true_speed is 348.7819 ± 20.7897 cm/s (6.0%)
Estimated error in final calculation -10.7%
Estimated total error 16.6%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 6 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 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
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO NO2 O O2 OH T point 6 point 69 velocity
##############################################################################

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

Problem solved on [169] point grid(s).
Iteration 6
Current flame speed is is 291.7385 cm/s
Fitted true_speed is 338.2878 ± 43.0117 cm/s (12.7%)
Estimated error in final calculation -6.6%
Estimated total error 19.3%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 58 59 60 61 62 63 166 167
    to resolve H H2 H2O H2O2 HO2 N N2 N2O NNH NO O O2 OH T velocity
##############################################################################

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

Problem solved on [209] point grid(s).
Iteration 7
Current flame speed is is 262.8029 cm/s
Fitted true_speed is 294.8357 ± 45.5419 cm/s (15.4%)
Estimated error in final calculation -0.9%
Estimated total error 16.3%

..............................................................................
##############################################################################
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 51 52 53 54 55 56 57 58 59 60 61 62 63 85 205 206 207
    to resolve H H2 H2O H2O2 HO2 N2 N2O NO O O2 OH T point 85 velocity
##############################################################################

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

Problem solved on [254] point grid(s).
Iteration 8
Current flame speed is is 248.0358 cm/s
Fitted true_speed is 192.8185 ± 11.3247 cm/s (5.9%)
Estimated error in final calculation 30.9%
Estimated total error 36.7%

..............................................................................
##############################################################################
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 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 105 128 246 250 251 252
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T point 105 point 128 point 246 velocity
##############################################################################

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

Problem solved on [309] point grid(s).
Iteration 9
Current flame speed is is 240.5816 cm/s
Fitted true_speed is 174.5868 ± 10.8210 cm/s (6.2%)
Estimated error in final calculation 35.8%
Estimated total error 42.0%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 26 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 85 86 87 88 89 90 91 92 93 296 305 306 307
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T point 26 point 296 velocity
##############################################################################

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

Problem solved on [376] point grid(s).
Iteration 10
Current flame speed is is 236.8064 cm/s
Fitted true_speed is 202.1666 ± 6.5242 cm/s (3.2%)
Estimated error in final calculation 16.2%
Estimated total error 19.4%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 25 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 368 373 374
    to resolve H H2 H2O H2O2 HO2 N2 NO O O2 OH T point 25 point 368 velocity
##############################################################################

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

Problem solved on [471] point grid(s).
Iteration 11
Current flame speed is is 234.8979 cm/s
Fitted true_speed is 218.3273 ± 3.5282 cm/s (1.6%)
Estimated error in final calculation 7.1%
Estimated total error 8.7%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 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
    to resolve H H2 H2O H2O2 HO2 N2 O O2 OH T velocity
##############################################################################

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

Problem solved on [616] point grid(s).
Iteration 12
Current flame speed is is 233.9327 cm/s
Fitted true_speed is 226.6729 ± 1.8472 cm/s (0.8%)
Estimated error in final calculation 2.9%
Estimated total error 3.8%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 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 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
    to resolve H H2 H2O H2O2 HO2 N2 O O2 OH T velocity
##############################################################################

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

Problem solved on [814] point grid(s).
Iteration 13
Current flame speed is is 233.4627 cm/s
Fitted true_speed is 230.3342 ± 0.7465 cm/s (0.3%)
Estimated error in final calculation 1.2%
Estimated total error 1.6%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 69 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 470
    to resolve H2O2 HO2 OH T point 470 point 69 velocity
##############################################################################

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

Problem solved on [931] point grid(s).
Iteration 14
Current flame speed is is 233.1794 cm/s
Fitted true_speed is 231.4480 ± 0.1835 cm/s (0.1%)
Estimated error in final calculation 0.7%
Estimated total error 0.8%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 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 588
    to resolve HO2 point 588
##############################################################################

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

Problem solved on [974] point grid(s).
Iteration 15
Current flame speed is is 233.1401 cm/s
Fitted true_speed is 231.7652 ± 0.1081 cm/s (0.0%)
Estimated error in final calculation 0.6%
Estimated total error 0.6%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 197 282
    to resolve point 197 point 282
##############################################################################

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

Problem solved on [976] point grid(s).
Iteration 16
Current flame speed is is 233.1287 cm/s
Fitted true_speed is 231.4471 ± 0.1361 cm/s (0.1%)
Estimated error in final calculation 0.7%
Estimated total error 0.8%

..............................................................................
no new points needed in flame
Flame Speed is: 233.13 cm/s

get a new best true speed estimate

flame speed convergence analysis
Fitted true_speed is 231.4471 ± 0.1361 cm/s (0.1%)
Estimated error in final calculation 0.7%
Estimated total error 0.8%
{'ratio': 2.0, 'slope': 0.01, 'curve': 0.01, 'prune': 0.0}
[17, 17, 57, 57]
Fitted true_speed is 324.1807 ± 0.0001 cm/s (0.0%)
Estimated error in final calculation -17.8%
Estimated total error 17.8%
Actual extrapolated error (with hindsight) 40.1%
Actual raw error (with hindsight) 15.1%

[17, 17, 57, 57, 102]
Fitted true_speed is 348.7819 ± 20.7897 cm/s (6.0%)
Estimated error in final calculation -10.7%
Estimated total error 16.6%
Actual extrapolated error (with hindsight) 50.7%
Actual raw error (with hindsight) 46.1%

[17, 17, 57, 57, 102, 169]
Fitted true_speed is 338.2878 ± 43.0117 cm/s (12.7%)
Estimated error in final calculation -6.6%
Estimated total error 19.3%
Actual extrapolated error (with hindsight) 46.2%
Actual raw error (with hindsight) 26.0%

[17, 17, 57, 57, 102, 169, 209]
Fitted true_speed is 294.8357 ± 45.5419 cm/s (15.4%)
Estimated error in final calculation -0.9%
Estimated total error 16.3%
Actual extrapolated error (with hindsight) 27.4%
Actual raw error (with hindsight) 13.5%

[17, 17, 57, 57, 102, 169, 209, 254]
Fitted true_speed is 192.8185 ± 11.3247 cm/s (5.9%)
Estimated error in final calculation 30.9%
Estimated total error 36.7%
Actual extrapolated error (with hindsight) 16.7%
Actual raw error (with hindsight) 7.2%

[17, 17, 57, 57, 102, 169, 209, 254, 309]
Fitted true_speed is 174.5868 ± 10.8210 cm/s (6.2%)
Estimated error in final calculation 35.8%
Estimated total error 42.0%
Actual extrapolated error (with hindsight) 24.6%
Actual raw error (with hindsight) 3.9%

[17, 17, 57, 57, 102, 169, 209, 254, 309, 376]
Fitted true_speed is 202.1666 ± 6.5242 cm/s (3.2%)
Estimated error in final calculation 16.2%
Estimated total error 19.4%
Actual extrapolated error (with hindsight) 12.7%
Actual raw error (with hindsight) 2.3%

[17, 17, 57, 57, 102, 169, 209, 254, 309, 376, 471]
Fitted true_speed is 218.3273 ± 3.5282 cm/s (1.6%)
Estimated error in final calculation 7.1%
Estimated total error 8.7%
Actual extrapolated error (with hindsight) 5.7%
Actual raw error (with hindsight) 1.5%

[17, 17, 57, 57, 102, 169, 209, 254, 309, 376, 471, 616]
Fitted true_speed is 226.6729 ± 1.8472 cm/s (0.8%)
Estimated error in final calculation 2.9%
Estimated total error 3.8%
Actual extrapolated error (with hindsight) 2.1%
Actual raw error (with hindsight) 1.1%

[17, 17, 57, 57, 102, 169, 209, 254, 309, 376, 471, 616, 814]
Fitted true_speed is 230.3342 ± 0.7465 cm/s (0.3%)
Estimated error in final calculation 1.2%
Estimated total error 1.6%
Actual extrapolated error (with hindsight) 0.5%
Actual raw error (with hindsight) 0.9%

[17, 17, 57, 57, 102, 169, 209, 254, 309, 376, 471, 616, 814, 931]
Fitted true_speed is 231.4480 ± 0.1835 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%

[17, 17, 57, 57, 102, 169, 209, 254, 309, 376, 471, 616, 814, 931, 974]
Fitted true_speed is 231.7652 ± 0.1081 cm/s (0.0%)
Estimated error in final calculation 0.6%
Estimated total error 0.6%
Actual extrapolated error (with hindsight) 0.1%
Actual raw error (with hindsight) 0.7%

[17, 17, 57, 57, 102, 169, 209, 254, 309, 376, 471, 616, 814, 931, 974, 976]
Fitted true_speed is 231.4471 ± 0.1361 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%
actual error in raw value actual error in extrapolated value estimated error
17 NaN NaN NaN
17 NaN NaN NaN
57 NaN NaN NaN
57 15.100861 40.066861 17.824350
102 46.095697 50.696171 16.632410
169 26.049741 46.162020 19.272126
209 13.547722 27.387921 16.311033
254 7.167365 16.690055 36.734136
309 3.946663 24.567306 41.955244
376 2.315537 12.651049 19.387024
471 1.490980 5.668583 8.693310
616 1.073928 2.062788 3.750767
814 0.870852 0.480840 1.565003
931 0.748468 0.000363 0.821996
974 0.731495 0.137436 0.641833
976 0.726535 0.000000 0.782988


Middling refine criteria, Hydrogen flame#

refine_criteria = {"ratio": 3, "slope": 0.1, "curve": 0.1}

# 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")
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
  • flame speed convergence analysis
************ Solving on 8 point grid with energy equation enabled ************

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     4.746e-06      7.177
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     0.0001216      5.217
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.385
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     4.055e-05      5.927
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

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

..............................................................................
##############################################################################
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
##############################################################################

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

Problem solved on [28] point grid(s).
Expanding domain to accommodate flame thickness. New width: 0.056 m
##############################################################################
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
##############################################################################

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

..............................................................................
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     2.373e-06      7.468
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     6.007e-06      7.345
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps     6.842e-05      5.889
Attempt Newton solution of steady-state problem...    failure.
Take 10 timesteps      0.001169      3.232
Attempt Newton solution of steady-state problem...    success.

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

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

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

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

Problem solved on [36] point grid(s).
Iteration 4
Current flame speed is is 266.3976 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.0002563      4.159
Attempt Newton solution of steady-state problem...    success.

Problem solved on [43] point grid(s).
Iteration 5
Current flame speed is is 338.1343 cm/s
Fitted true_speed is 425.6827 ± 37.1260 cm/s (8.7%)
Estimated error in final calculation -27.8%
Estimated total error 36.6%

..............................................................................
##############################################################################
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 6
Current flame speed is is 291.7345 cm/s
Fitted true_speed is 407.7931 ± 124.8090 cm/s (30.6%)
Estimated error in final calculation -22.9%
Estimated total error 53.5%

..............................................................................
##############################################################################
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 7
Current flame speed is is 262.7941 cm/s
Fitted true_speed is 267.9000 ± 110.0686 cm/s (41.1%)
Estimated error in final calculation 6.1%
Estimated total error 47.2%

..............................................................................
##############################################################################
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 8
Current flame speed is is 247.9646 cm/s
Fitted true_speed is 115.6049 ± 22.0950 cm/s (19.1%)
Estimated error in final calculation 108.9%
Estimated total error 128.1%

..............................................................................
##############################################################################
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
    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 [92] point grid(s).
Iteration 9
Current flame speed is is 240.4975 cm/s
Fitted true_speed is 172.3656 ± 15.3938 cm/s (8.9%)
Estimated error in final calculation 36.9%
Estimated total error 45.9%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    to resolve H2O2 HO2 N2 O OH T velocity
##############################################################################

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

Problem solved on [113] point grid(s).
Iteration 10
Current flame speed is is 236.3507 cm/s
Fitted true_speed is 203.6960 ± 6.4101 cm/s (3.1%)
Estimated error in final calculation 15.1%
Estimated total error 18.3%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    to resolve H2O2 HO2
##############################################################################

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

Problem solved on [127] point grid(s).
Iteration 11
Current flame speed is is 234.0603 cm/s
Fitted true_speed is 214.6007 ± 1.3560 cm/s (0.6%)
Estimated error in final calculation 9.0%
Estimated total error 9.6%

..............................................................................
##############################################################################
Refining grid in flame.
    New points inserted after grid points 39 40 41 42 43
    to resolve HO2
##############################################################################

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

Problem solved on [132] point grid(s).
Iteration 12
Current flame speed is is 233.7520 cm/s
Fitted true_speed is 217.7925 ± 0.5751 cm/s (0.3%)
Estimated error in final calculation 7.3%
Estimated total error 7.5%

..............................................................................
no new points needed in flame
Flame Speed is: 233.75 cm/s
{'ratio': 3.0, 'slope': 0.1, 'curve': 0.1, 'prune': 0.0}
[17, 17, 36, 36]
Fitted true_speed is 388.0462 ± 0.0003 cm/s (0.0%)
Estimated error in final calculation -31.3%
Estimated total error 31.3%
Actual extrapolated error (with hindsight) 67.7%
Actual raw error (with hindsight) 15.1%

[17, 17, 36, 36, 43]
Fitted true_speed is 425.6827 ± 37.1260 cm/s (8.7%)
Estimated error in final calculation -27.8%
Estimated total error 36.6%
Actual extrapolated error (with hindsight) 83.9%
Actual raw error (with hindsight) 46.1%

[17, 17, 36, 36, 43, 51]
Fitted true_speed is 407.7931 ± 124.8090 cm/s (30.6%)
Estimated error in final calculation -22.9%
Estimated total error 53.5%
Actual extrapolated error (with hindsight) 76.2%
Actual raw error (with hindsight) 26.0%

[17, 17, 36, 36, 43, 51, 61]
Fitted true_speed is 267.9000 ± 110.0686 cm/s (41.1%)
Estimated error in final calculation 6.1%
Estimated total error 47.2%
Actual extrapolated error (with hindsight) 15.7%
Actual raw error (with hindsight) 13.5%

[17, 17, 36, 36, 43, 51, 61, 74]
Fitted true_speed is 115.6049 ± 22.0950 cm/s (19.1%)
Estimated error in final calculation 108.9%
Estimated total error 128.1%
Actual extrapolated error (with hindsight) 50.1%
Actual raw error (with hindsight) 7.1%

[17, 17, 36, 36, 43, 51, 61, 74, 92]
Fitted true_speed is 172.3656 ± 15.3938 cm/s (8.9%)
Estimated error in final calculation 36.9%
Estimated total error 45.9%
Actual extrapolated error (with hindsight) 25.5%
Actual raw error (with hindsight) 3.9%

[17, 17, 36, 36, 43, 51, 61, 74, 92, 113]
Fitted true_speed is 203.6960 ± 6.4101 cm/s (3.1%)
Estimated error in final calculation 15.1%
Estimated total error 18.3%
Actual extrapolated error (with hindsight) 12.0%
Actual raw error (with hindsight) 2.1%

[17, 17, 36, 36, 43, 51, 61, 74, 92, 113, 127]
Fitted true_speed is 214.6007 ± 1.3560 cm/s (0.6%)
Estimated error in final calculation 9.0%
Estimated total error 9.6%
Actual extrapolated error (with hindsight) 7.3%
Actual raw error (with hindsight) 1.1%

[17, 17, 36, 36, 43, 51, 61, 74, 92, 113, 127, 132]
Fitted true_speed is 217.7925 ± 0.5751 cm/s (0.3%)
Estimated error in final calculation 7.3%
Estimated total error 7.5%
Actual extrapolated error (with hindsight) 5.9%
Actual raw error (with hindsight) 1.0%
actual error in raw value actual error in extrapolated value estimated error
17 NaN NaN NaN
17 NaN NaN NaN
36 NaN NaN NaN
36 15.100853 67.660863 31.349030
43 46.095704 83.922218 36.560916
51 26.048002 76.192758 53.494964
61 13.543897 15.749994 47.234864
74 7.136626 50.051267 128.055351
92 3.910326 25.526990 45.850818
113 2.118673 11.990250 18.276564
127 1.129078 7.278744 9.599802
132 0.995875 5.899663 7.532737


Total running time of the script: (2 minutes 34.944 seconds)

Gallery generated by Sphinx-Gallery