Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-uniform lambda in using CounterflowTwinPremixedFlame #1593

Closed
yeanment opened this issue Aug 18, 2023 · 3 comments · Fixed by #1594
Closed

Non-uniform lambda in using CounterflowTwinPremixedFlame #1593

yeanment opened this issue Aug 18, 2023 · 3 comments · Fixed by #1594

Comments

@yeanment
Copy link
Contributor

Problem description
When calculating the CounterflowPremixed flame, the lambda should be uniform acorss the compuattional domain. However, the lambda is set to zero in the right symmetry boundary. This might have no significant influence on the overall results. But I believe modify it back should be a good option for consistence.

Steps to reproduce


import os
import time
import matplotlib.pyplot as plt
import numpy as np
import cantera as ct

def plot_solution(f, solution_num, path='output'):
    fig = plt.figure(figsize=(10,10))
    axs = []
    axs.append(plt.subplot2grid((2,2), (0,0))) # top left
    axs.append(plt.subplot2grid((2, 2), (1, 0)))  # middle left
    axs.append(plt.subplot2grid((2, 2), (0, 1)))  # top right
    axs.append(plt.subplot2grid((2, 2), (1, 1)))  # middle right
    
    axs[0].plot(f.grid, f.T, 'o-')
    axs[0].set_xlabel('Distance, m')
    axs[0].set_ylabel('Temperature, K')
    axs[0].set_ylim([200, 2900])
    
    axs[1].plot(f.grid, f.velocity, 'o-')
    axs[1].set_xlabel('Distance, m')
    axs[1].set_ylabel('Axial Velocity, m/s')
    
    axs[2].plot(f.grid, f.spread_rate, 'o-')
    axs[2].set_xlabel('Distance, m')
    axs[2].set_ylabel('Spread Rate, 1/s')
        
    axs[3].plot(f.grid, f.L, 'o-')
    axs[3].set_xlabel('Distance, m')
    axs[3].set_ylabel('Lambda, m/s')
    fig.tight_layout()
    plt.savefig(path + '/combined_flamelet_' + str(solution_num+1) + '.png')
    plt.close()


# Input parameters
p = 1* ct.one_atm  # pressure
tin = 300.0  # fuel inlet temperature
width = 0.02 # Distance between inlets

comp_o = 'O2:1, N2:3.76'  # oxidizer composition
comp_f = 'H2:1.0'  # fuel composition

loglevel = 1  # amount of diagnostic output (0 to 5)

gas = ct.Solution('gri30.yaml')
gas.TPX = tin, p, comp_f
gas.TPX = tin, p, comp_o

gas.set_equivalence_ratio(phi=1.0, fuel=comp_f, oxidizer=comp_o)
density_u = gas.density
f = ct.CounterflowTwinPremixedFlame(gas, width=width)

# Set the state of the two inlets
f.reactants.mdot = density_u*8
f.reactants.Y = gas.Y
f.reactants.T = tin

#f.set_refine_criteria(ratio=4, slope=0.2, curve=0.3, prune=0.04)
f.set_refine_criteria(ratio=10, slope=0.1, curve=0.1, prune=0.05)

# Solve the problem
f.solve(loglevel, auto=True)
f.save('previous_solution.yaml',overwrite=True)

plot_solution(f, -10, '.')
  1. Run the above code
  2. Check the result of lambda

Behavior

A non-uniform lambda is observed at the boundary point. Ideally, this should be uniform across the computational domain.

System information

  • Cantera version: commit cde1e79
  • OS: wsl-Ubuntu20
  • Python/MATLAB/other software versions: Python 3.11

Attachments

Additional context

This problem arises due to the incorrect set of boundary conditions in function evalRightBoundary at Stflow.cpp. At line 1030 (Stflow.cpp), the code
rsd[index(c_offset_L, j)] = lambda(x, j); should be changed to rsd[index(c_offset_L, j)] = lambda(x, j) - lambda(x, j-1);, so that an zero gradient condition is set for the lambda.

@speth
Copy link
Member

speth commented Aug 18, 2023

It looks like this was introduced in #1555. I had commented on exactly this issue in my review (#1555 (comment)), but it looks like the fix got put into the wrong branch of the if statement:

cantera/src/oneD/StFlow.cpp

Lines 1028 to 1034 in cde1e79

if (m_usesLambda) {
rsd[index(c_offset_U, j)] = rho_u(x, j);
rsd[index(c_offset_L, j)] = lambda(x, j);
} else {
rsd[index(c_offset_U, j)] = rho_u(x, j) - rho_u(x, j-1);
rsd[index(c_offset_L, j)] = lambda(x, j) - lambda(x, j-1);
}

Please feel free to open a PR.

@ischoegl
Copy link
Member

mea culpa 😞

@ischoegl
Copy link
Member

@yeanment … I’ll reopen this issue until the proposed fix in #1593 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants