A code for number of moles

425 views
Skip to first unread message

Anuradh Gunawardena

unread,
Sep 23, 2010, 11:24:44 AM9/23/10
to Cantera User's Group
Hi,
I'm doing an analysis on equilibrium composition of methanol. This is
the code I'm using. What I get is the mole fractions but I want to get
it in moles not as a fraction. I tried to use 'speciesMoles' command
but it didnt work. I think it goes with the mixture command, not with
a single phase problem like this.. am I right? I

gas = importPhase('metohbtx.cti')
nsp = gas.nSpecies()
np = 10 # number of points
Ti = zeros(np)

T1 = 300

for i in range(np):
Ti[i] = T1 + (T2-T1)*i/np
gas.set(T = Ti[i], P = 15*OneAtm, X='CH3OH:1')
gas.equilibrate('TP', maxsteps = 1000000)
print gas

I would really appreciate if some one can give me a hint how to use
speciesMoles command or some other way to get the number of moles for
the equilibrium compostion.

Duminda

Steven DeCaluwe

unread,
Sep 23, 2010, 12:34:35 PM9/23/10
to canter...@googlegroups.com
Hi Duminda,

I think I understand your question - you want to calculate the number of moles in equilibrium relative to some reference point (such as how many you start out with) - is that correct?  For instance, the moles of species i relative to the initial moles methanol?

While there are a number of assumptions you could make to simplify the calculations, for a rigorous and generalized routine I would probably reference everything to the mass of your solution: calculate the moles of methanol per kg of solution before and after equilibrating (using gas.molarDensity()/gas.density()).  Since your initial composition is 100% methanol, multiplying the ratio of these two (moles/kg after equil divided by moles/kg before equil) by your mole fractions will give you the moles of each species per initial mole of methanol.

You could also just reference your equilibrium composition to the mass of solution.  Here you would just multiply your mole fractions by molarDensity()/density() for the equilibrium composition.  Regardless, the equilibrium composition is an intensive property (rather than extensive), so you have to reference it to something, in the end.


Hope this helps,
Steven




--
You received this message because you are subscribed to the Google Groups "Cantera User's Group" group.
To post to this group, send email to canter...@googlegroups.com.
To unsubscribe from this group, send email to cantera-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cantera-users?hl=en.


Anthony Ruiz

unread,
Sep 23, 2010, 4:05:34 PM9/23/10
to Cantera User's Group
Getting moles out of mole fractions is straightforward :
Xk=mole fraction of the kth species=nk/n
with nk the number of moles of the kth species in your mixture and n
the total number of moles in your mixture.
It seems you want nk, then you simply need to multiply Xk by n.

For example, if your mixture has n=2 moles of CH3OH and the
equilibrium calculation gives a final mole fraction of 1/3 for CH3OH,
then you have 1/3*2 moles of CH3OH in your final mixture.

Anthony

Steven DeCaluwe

unread,
Sep 23, 2010, 4:55:23 PM9/23/10
to canter...@googlegroups.com
One caveat to the approach below - the number of moles is not
conserved in an equilibrium calculation.

In your example below, where the final mole fraction of CH3OH is 1/3,
if we assume that each CH3OH is converted to two smaller species
(just as an example, not that this is accurate), the 2 moles of CH3OH
would be converted to 1 mole of CH3OH and 2 moles of smaller
species. You would still have a mole fraction of 1/3 for CH3OH, but
would get 1 mole of CH3OH, not 2/3. This is why I recommended
referencing against mass, which is conserved.

However, without thinking too much about the methanol thermodynamics,
I will say that the number of moles doesn't usually change by very
much in these calculations (in my limited experience). If your mole
fraction for CH3OH ends up very close to 1, Anthony's approach below
should give minimal error.

Regards,
Steven

> --
> You received this message because you are subscribed to the Google
> Groups "Cantera User's Group" group.
> To post to this group, send email to canter...@googlegroups.com.

> To unsubscribe from this group, send email to cantera-users
> +unsub...@googlegroups.com.

Anuradh Gunawardena

unread,
Sep 25, 2010, 4:58:31 PM9/25/10
to canter...@googlegroups.com
Thanks for the help. I used moleDensity/density and it worked.
Is there a comand in Cantera to get the units of a particular output. Say I want to know the units of the 'moledensity' used in Cantera.
Duminda

To unsubscribe from this group, send email to cantera-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/cantera-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Cantera User's Group" group.
To post to this group, send email to canter...@googlegroups.com.
To unsubscribe from this group, send email to cantera-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages