getting mole fractions out of counterflow solution

498 views
Skip to first unread message

Roger

unread,
Sep 12, 2013, 8:57:28 AM9/12/13
to canter...@googlegroups.com
Hey ,

I got a question concerning the counterflow flame in Matlab.
If i calculate the flame there comes a 1x1 stack in the Matlab workspace. This stack contains the velocity, temperature and species mass fractions at every position in the flame.
Now i know i can get the solution for a species with for example: solution(fl, 'flow', 'N2'). This gives me the solution of N2 but in mass fractions.
Is there any way i can get the solution in mole fractions?

Greetings,

Roger

Ray Speth

unread,
Sep 13, 2013, 3:39:46 PM9/13/13
to canter...@googlegroups.com
Roger,

There's no trivial way to do this using the Matlab interface. To get the mole fractions, you would need to get the mass fractions for all the species, building a 2D array of mass fraction at each point. Then, for each point, set the state of the IdealGasMix object using the mass fractions at that point and then get the the mole fractions.

In the Cython module, Flame objects have the properties 'X' and 'Y' which return the full mole or mass fraction arrays directly.

Regards,
Ray

Steven DeCaluwe

unread,
Sep 13, 2013, 4:03:49 PM9/13/13
to canter...@googlegroups.com
Would converting the mass fractions directly to mole fractions be faster than re-loading the state?

Calculate just once:
m_i = molarMasses(gas_object)
m_inv = 1./m_i

Then for each point:

y =  mass fractions at each point (loaded from solution)

and 

x_i = y.*m_inv/(y'*m_inv)

gets you the array of mole fractions.


I just implemented it in Matlab to test, and converting directly takes 2.8e-5 seconds, whereas setting the state and then calling the moleFractions function takes 6.3e-4 seconds (i.e. converting it directly was ~22 times faster).

Still not trivial, but a little faster.

-Steven


--
You received this message because you are subscribed to the Google Groups "Cantera User's Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.
To post to this group, send email to canter...@googlegroups.com.
Visit this group at http://groups.google.com/group/cantera-users.
For more options, visit https://groups.google.com/groups/opt_out.

Roger

unread,
Sep 16, 2013, 3:45:19 AM9/16/13
to canter...@googlegroups.com
Thanks for the reply guys, I got the mole fractions by setting the state with  G = set(gas, 'T', t, 'P,' p , 'Y', species).
then moleFractions(gas). Since i only needed the mole fractions at the peak temperature i used this temperature and the species content here.

Regards,

Roger

Op donderdag 12 september 2013 14:57:28 UTC+2 schreef Roger:
Reply all
Reply to author
Forward
0 new messages