Hi,
I'm new with CANTERA and I'm running it as matlab toolbox. I'm trying to start with CANTERA for CH4 combustion using GRI30 mechanism.
How to calculate total heat release rate from the reactions in matlab? I can find creationRates of the species.
Appreciate any advice
Hi Nick, thank you for the advice,
I expected that this is done by the reactors solutions. But how about using it in your own "reactor". I've tried to implement the kinetics in my own, simple zero-d CI engine model. The energy equations are solved by iteration, step, by step in Crank angle (CA) domain (but this is just scaling from time domain).
My first, general idea to implement Cantera kinetics to the code was rather simple:
1. input parameters to cantera:
set(Gas,'Pressure',P(i),'Temperature',T(i),'Y',Y(i))
2. Calculate using CANTERA solutions:
-internal energy of the system U=cv_mole(Gas).*moleFractions(Gas)*N %N is a total number of moles
-heat release rate from combustion : dQ/da=(30/(pi*n)*enthalpies_RT(Gas).*netProdRates(Gas)*R*T(i)*V(i); %(30/(pi*n) is just scaling from t->CA domain.
-change of mass fractions dY/da=(30/(pi*n)*ydot(Gas)
-mass fractions after calculation step Y(i+1)=(dY/da)*da+Y(i)
3. Calculate using own model state parameters after calculation step (taking to account internal energy U, heat release rate dQ/da from the above calculations)
P(i+1), T(i+1), V(i+1)
4. Repeat from point 1 with new values of P, T, Y.
The algorithm goes well if I set dY/da=0 arbitrarily (i.e. for compression), otherwise after few steps i get negative values of fractions Y and as a consequence negative temperatures (the calculation collapses).
I suspect that what I’m doing wrong is using set(Gas,'Pressure',P(i),'Temperature',T(i),'Y',Y(i)) command every time to set new parameters in the loop step. Probably I cannot do it simply by this command because it changes other parameters of the gas composition.
Could you advise if my suspicions are correct and advise how to solve this problem in a different way.
Regards,
Maciek
network = ReactorNet({r});
Finally you simply need to step the ReactorNet between your initial and ending crank angle using the step() or advance() functions
Nick