Hello all,
Im new to using cantera and I would like to calculate the laminar
flame speed of different reactive gaz mixtures using Cantera on
Matlab. I Know there are python (adiabatic_flame.py) and c++
(flamespeed.cpp) demos which provides laminar flames speed but
unfortunately the 1D expamples in matlab folder don't include the free
flame calculation only the burner flame case example is available and
I did not found any complete manual for matlab's cantera toolbox.
I searched on this Cantera user's group and yahoo's one and I found
several posts asking the same question but never the answer was
posted, did they finaly solve the problem ?
I have started out by first comparing the provided demos Flame1.m and
flame1.py in an attempt to understand the differences between the
simulations in Matlab and Python. I have also been looking through the
tutorial files provided with Cantera for both Matlab and Python.
Then I tried to transpose the Python's example named
adiabatic_flame.py wich calculate the laminar flame speed but it uses
the function FreeFlame.py wich is not available for matlab in the 1.8
Cantera version I have. Finaly I found a Freeflame.m on the online
sources of cantera's website (
http://code.google.com/
codesearch#YbwRwnBOdvE/cantera18/changes/liquidTransportDevelop/
Cantera/matlab/cantera/1D/FreeFlame.m) I am not sure it is the correct
equivalent for matlab but I tried and it doesn't work.
I provide you my current matlab code and the error message.
%
% ADIABATIC_FLAME - A freely-propagating, premixed methane/air flat
% flame with multicomponent transport properties
%
%helpadiabatic_flame;
%disp('press any key to begin the simulation');
%pause;
clc;
t0 = cputime; % record the starting time
% parameter values
p = oneatm; % pressure
tin = 300.0; % unburned temperature
mdot = 0.04; % kg/m^2/s
comp = 'CH4:0.45, O2:1, N2:3.76'; % premixed gas composition
initial_grid = [0.0, 0.001, 0.01, 0.02, 0.029, 0.03] % m
tol_ss = [1.0e-5, 1.0e-9]; % [rtol atol] for steady-state
% problem
tol_ts = [1.0e-5, 1.0e-9]; % [rtol atol] for time stepping
loglevel = 1; % amount of diagnostic output (0
% to 5)
refine_grid = 1; % 1 to enable refinement, 0 to
% disable
max_jacobian_age = [50, 50];
%%%%%%%%%%%%%%%% create the gas object %%%%%%%%%%%%%%%%%%%%%%%%
%
% This object will be used to evaluate all thermodynamic, kinetic,
% and transport properties
%
gas = GRI30('Multi');
% set its state to that of the unburned gas at the burner
set(gas,'T', tin, 'P', p, 'X', comp);
%%%%%%%%%%%%%%%% create the flow object: freeflame %%%%%%%%%%%%%%%%%%%%
%%%
ff = FreeFlame(gas,'ff');
set(ff, 'P', p, 'grid', initial_grid);
set(ff, 'tol', tol_ss, 'tol-time', tol_ts);
%%%%%%%%%%%%%%% create the inlet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The burner is an Inlet object. The temperature, mass flux,
% and composition (relative molar) may be specified.
%
in = Inlet('in');
set(in, 'T', tin, 'MassFlux', mdot, 'X', comp);
%%%%%%%%%%%%%% create the outlet %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The type of flame is determined by the object that terminates
% the domain. An Outlet object imposes zero gradient boundary
% conditions for the temperature and mass fractions, and zero
% radial velocity and radial pressure gradient.
%
s = Outlet('out');
%%%%%%%%%%%%% create the flame object %%%%%%%%%%%%
%
% Once the component parts have been created, they can be assembled
% to create the flame object.
%
fl = flame(gas, in, ff, s);
setMaxJacAge(fl, max_jacobian_age(1), max_jacobian_age(2));
% if the starting solution is to be read from a previously-saved
% solution, uncomment this line and edit the file name and solution
id.
%restore(fl,'h2flame2.xml', 'energy')
solve(fl, loglevel, refine_grid);
%%%%%%%%%%%% enable the energy equation %%%%%%%%%%%%%%%%%%%%%
%
% The energy equation will now be solved to compute the
% temperature profile. We also tighten the grid refinement
% criteria to get an accurate final solution.
%
enableEnergy(fl);
setRefineCriteria(fl, 10, 0.2, 0.02, -0.00005);
solve(fl, 1, 1);
saveSoln(fl,'h2fl.xml','energy',['solution with energy' ...
' equation']);
%%%%%%%%%% show statistics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
writeStats(fl);
elapsed = cputime - t0;
e = sprintf('Elapsed CPU time: %10.4g',elapsed);
disp(e);
%%%%%%%%%% make plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clf;
figure(1);
plotSolution(fl, 'flow', 'T');
title('Temperature [K]');
figure(2);
plotSolution(fl, 'flow', 'u');
title('Axial Velocity [m/s]');
############################################################################################
############################################################################################
############################################################################################
COMMAND WINDOWS
############################################################################################
############################################################################################
############################################################################################
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
??? Error using ==> ctmethods
************************************************
Cantera Error!
************************************************
Procedure: MultiNewton::step
Error: Jacobian is singular for domain ff, component CH3CHO at point
5
(Matrix row 343)
see file bandmatrix.csv
Error in ==> stack_methods at 13
v = ctmethods(90, n, job, a, b);
Error in ==> Stack.solve at 4
stack_methods(s.stack_id, 104, loglevel, refine_grid);
Error in ==> adiabatic_flame at 82
solve(fl, loglevel, refine_grid);