Transport properties.

1,127 views
Skip to first unread message

shyam

unread,
Aug 15, 2010, 5:01:04 PM8/15/10
to Cantera User's Group
Hello all, I am trying to get transport properties for some fuel-air
mixtures using the GRI30 mechanism. I have a .cti file created with
the required 'inp', 'thermo' and 'transport' files. So it should have
the transport properties for all species in it. I have been trying the
command, gas = gri30('Mix'), which should set up the gas object with
mixture averaged transport properties. But this command keeps failing
with the following message:
************************************************
Cantera Error!
************************************************


Procedure: xml_find_id
Error: id not found: gri30_mix

Error in ==> c:\documents and settings\shyam menon\my documents\cantera
\matlab\toolbox\cantera\ctmethods.dll
Error in ==> c:\documents and settings\shyam menon\my documents\cantera
\matlab\toolbox\cantera\@XML_Node\findByID.m
On line 4 ==> index = ctmethods(10, 8, root.id, id);


I am not sure why this is happening, but if anyone has experienced
this before and has a fix, it would be awesome if you could post it.
Thanks a lot!! Shyam.

shyam

unread,
Aug 16, 2010, 7:31:10 AM8/16/10
to Cantera User's Group
Hello all, I am able to get the same to work if i use the command,
gas=IdealGasMix('gri30_mix.cti') or
gas=IdealGasMix('gri30_multi.cti'); !!
Shyam.

Steven DeCaluwe

unread,
Aug 16, 2010, 10:29:57 AM8/16/10
to canter...@googlegroups.com
Hi Shyam,

Glad to hear you got it working. Your other error is somewhat
perplexing - I just input the same "gas = gri30('Mix')" command into
Matlab (I assume you're using Matlab?), and it created the phase just
fine.

The only possibility that comes to mind is where you say "I have
a .cti file created with..." I'm assuming that you're using the
"gri30.cti" file supplied with Cantera, but if you've instead created
your own version, is it possible that you've given the phase
declarations a name other than 'gri30_mix'? If so, the 'gri30.m'
function in the Matlab toolbox is looking for a phase name
('gri30_mix') that doesn't exist, which would result in your error
below.

Does the following call:

gas = importPhase('gri30.cti', 'gri30_mix')

also result in an error?

> --
> 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.
> For more options, visit this group at http://groups.google.com/
> group/cantera-users?hl=en.
>

Oku Nyong

unread,
May 14, 2015, 8:28:50 AM5/14/15
to canter...@googlegroups.com
Dear Bryan,
I  also sorry  for my previous post of the wrong window.I wasn't watchful on my own part.You guys are really doing a good job.I have updated my cantera to the use Beta Cantera 2.2 hoping to get use to new updated  package.
I actually ran this

import cantera as ct
gas = ct.Solution('h2o2.xml')
gas.TP = 1000, None
print gas.thermal_conductivity
print gas.viscosity

and  i got the values for the thermal conductivity and gas viscosity at 1000k,I intend to calculate the transport properties for two range of temperature for instance T < 1000 K, and another for
 T > 1000 K.
Does Cantera uses the NASA  parameterizations for range of temperature?
I would be glad if you could illustrate with an example how to calculate this temperature dependence thermal conductivity and gas viscosity for two temperature range using air.
Thank you.


Bryan W. Weber

unread,
May 14, 2015, 11:09:55 AM5/14/15
to canter...@googlegroups.com
Dear Oku,

I'm glad what you ran worked. I don't have time right now to write the whole code for you, but you can use a for loop and change the temperature by the line gas.TP in the code you have already. Cantera uses the NASA polynomial parameterization for the thermo parameters, I'm not sure how it calculates the thermal conductivity and viscosity.

Bryan

Oku Nyong

unread,
May 14, 2015, 2:58:40 PM5/14/15
to canter...@googlegroups.com
Dear Bryan,
Thank you for your response.i went through the cantera documentation and found out under the Thermodynamics properties,there is the   NASA polynomial parameterization which has upto 7 coefficient which is what i actually trying to determine  using air for now then later look into mixtures of gases.It's really confusing trying to put the code together but came  up with this;which gave an error shown below.Please pardon me i'm a novice in this regard  i still welcome comments on how to improve on the code.
Thank you.

import cantera as ct
gas = ct.Solution('air.xml')
for n in range(gas):
    if T < 1000:
        print gas.thermal_conductivity
        print gas.viscosity
        ctml_writer.NASA((200.0, 1000.0), 7)
    elif T > 1000:
        print gas.thermal_conductivity
        print gas.viscosity
        ctml_writer.NASA((1000, 1300.0), 7)


ERROR MESSAGE
Traceback (most recent call last):
  File "C:\Users\User\Desktop\transport.py", line 3, in <module>
    for n in range(gas):
TypeError: range() integer end argument expected, got Solution.
--
You received this message because you are subscribed to the Google Groups "Cantera Users' 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.

Steven DeCaluwe

unread,
May 15, 2015, 9:01:15 AM5/15/15
to canter...@googlegroups.com
Oku,

In your for loop, you need to feed the 'range' function an integer (the number of steps+1, in this case). Instead, you are sending it a Cantera solution object. 

You also need to set up an array of the Temperature that you want to probe. 

More efficiently, you could just send this to your for loop. If 'Temps' is an array of temperature values, you could initiate your loop with

for T in Temps:
   gas.setTemperature(T)
   print T 
   print gas.thermal_conductivity
   print gas.viscosity
   
I'm not sure that the calls to ctml_writer are needed - once you create the air solution object, the crml_writer is called by the underlying code to implement the NASA polynomials. 

I haven't used the Python interface in a while. So please forgive me if my syntax is off. 

Cheers,
Steven

Sent from my iPhone

Oku Nyong

unread,
May 16, 2015, 4:22:19 AM5/16/15
to canter...@googlegroups.com
Dear Steven,
Thank you your input i have structute the code this way but a single value each for the viscosity and thermal conductivity was outpt rather than the polynomial coefficient  expected,i'm really short of ideas on the way forward.What i'm trying to achieve is generating a polynomial coefficient for the both properties at range of temperatures(T > 1000 and T <1000).The ouput i get from this code is given below; Any useful input from anyone  is welcome.
Thank you.
output
0.0262498170634
2.0558724663e-05

import cantera as ct
import numpy as np
#creating a gas and seting its state

gas = ct.Solution('air.xml')
air = ct.Solution('air.xml')
gas.TPX = 298, None, 'O2:0.21,O2:0.78,AR:0.01'
#main loop
ntemp = 1;
dT = 50
T = 200
for n in range(ntemp):
    if T < 1000:
        T += dT
        print gas.thermal_conductivity
        print gas.viscosity

Oku Nyong

unread,
May 20, 2015, 12:20:33 AM5/20/15
to canter...@googlegroups.com
Hello,
I have been trying to determine the thermal conductivity and viscosity of a gas /mixtures for ranges of temperature using cantera/python platform.Please see the attached file for the code would be glad if anyone could diagnose the error found in the code.
Thank you.


On 14/05/2015 16:09, Bryan W. Weber wrote:
trans_cal.py

Bryan W. Weber

unread,
May 20, 2015, 5:37:04 AM5/20/15
to canter...@googlegroups.com
Dear Oku,

In the spirit of "teaching to fish", can you please tell us what the error you get is, and also tell us what you don't understand about how to fix the error?

Thank you!
Bryan

On Wednesday, May 20, 2015 at 12:20:33 AM UTC-4, Oku wrote:
Hello,
I have been trying to determine the thermal conductivity and viscosity of a gas /mixtures for ranges of temperature using cantera/python platform.Please see the attached file for the code would be glad if anyone could diagnose the error found in the code.
Thank you.

On 14/05/2015 16:09, Bryan W. Weber wrote:
Dear Oku,

I'm glad what you ran worked. I don't have time right now to write the whole code for you, but you can use a for loop and change the temperature by the line gas.TP in the code you have already. Cantera uses the NASA polynomial parameterization for the thermo parameters, I'm not sure how it calculates the thermal conductivity and viscosity.

Bryan

On Thursday, May 14, 2015 at 8:28:50 AM UTC-4, Oku Nyong wrote:
Dear Bryan,
I  also sorry  for my previous post of the wrong window.I wasn't watchful on my own part.You guys are really doing a good job.I have updated my cantera to the use Beta Cantera 2.2 hoping to get use to new updated  package.
I actually ran this

import cantera as ct
gas = ct.Solution('h2o2.xml')
gas.TP = 1000, None
print gas.thermal_conductivity
print gas.viscosity

and  i got the values for the thermal conductivity and gas viscosity at 1000k,I intend to calculate the transport properties for two range of temperature for instance T < 1000 K, and another for
 T > 1000 K.
Does Cantera uses the NASA  parameterizations for range of temperature?
I would be glad if you could illustrate with an example how to calculate this temperature dependence thermal conductivity and gas viscosity for two temperature range using air.
Thank you.


--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-users+unsubscribe@googlegroups.com.

Oku Nyong

unread,
May 20, 2015, 6:51:49 AM5/20/15
to canter...@googlegroups.com
Dear Bryan,
Sorry for that the error  is shown below.The error points to  line 46.


Traceback (most recent call last):
  File "C:\Users\User\Desktop\cal_transport\trans_cal.py", line 46, in <module>
    print('%10.3e %10.3f %10.3f' % ( T(k),  t_c (W/mk),  v (kg/ms)))
NameError: name 'T' is not defined
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.

Bryan W. Weber

unread,
May 20, 2015, 8:45:18 AM5/20/15
to canter...@googlegroups.com
Dear Oku,

In that line, you are trying to print a header to your screen (I guess) but that's not what you're telling Python to do. You're telling Python to print the number returned by the function T when given the input k. However, the error comes up because Python cannot find a function (or other variable) called T; this is why it tells you that T is undefined. Instead, you need to tell Python to print a string and it is not necessary to use the % syntax to do so.

Bryan

Oku Nyong

unread,
May 20, 2015, 2:23:08 PM5/20/15
to canter...@googlegroups.com
Dear Bryan,
I did modify the code into a more simpler one it runs but not outputing the the thermal properties at an incremental value of the given temperature. What i would prefer is for the code to compute the  properties at  time step specified within  the range of temperature. please i  also want to know if  that's the   right syntax of representing the transport data in the code, the printed  result is shown  below and the code in the attached file.i appreciate your comment.
Thank you.

temp  thernal_cond            viscosity
260  0.0226120561575 1.62097918049e-05
270  0.0226120561575 1.62097918049e-05
280  0.0226120561575 1.62097918049e-05
290  0.0226120561575 1.62097918049e-05
300  0.0226120561575 1.62097918049e-05
310  0.0226120561575 1.62097918049e-05
320  0.0226120561575 1.62097918049e-05
330  0.0226120561575 1.62097918049e-05
340  0.0226120561575 1.62097918049e-05
350  0.0226120561575 1.62097918049e-05
360  0.0226120561575 1.62097918049e-05
370 0.0226120561575 1.62097918049e-05
380 0.0226120561575 1.62097918049e-05
390 0.0226120561575 1.62097918049e-05
400 0.0226120561575 1.62097918049e-05
410 0.0226120561575 1.62097918049e-05
420 0.0226120561575 1.62097918049e-05
430 0.0226120561575 1.62097918049e-05
440 0.0226120561575 1.62097918049e-05
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.
trans_cal.py

Bryan W. Weber

unread,
May 20, 2015, 3:19:18 PM5/20/15
to canter...@googlegroups.com
Dear Oku,

You have to set the temperature of the Solution every time you want to recalculate the properties.

gas.TP = T, None

Bryan

Oku Nyong

unread,
May 20, 2015, 8:30:02 PM5/20/15
to canter...@googlegroups.com
Dear Bryan,
Thanks alot it work.
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages