CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

how to get Sutherland and JANAF coefficients of air?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree17Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 18, 2018, 15:55
Default
  #61
Member
 
Join Date: Sep 2018
Location: France
Posts: 62
Rep Power: 8
john myce is on a distinguished road
Hello guys,

I used the code made by arvindpj (post #57) by running it on python 3.6 and cantera 2.4 but it does'nt work. I have attached the error message;

does anyone have a clue?

Cheers.
Attached Images
File Type: png Issue for the JANAF coefficient.PNG (8.8 KB, 32 views)
john myce is offline   Reply With Quote

Old   September 18, 2018, 16:15
Default
  #62
Senior Member
 
sheaker's Avatar
 
Oskar
Join Date: Nov 2015
Location: Poland
Posts: 184
Rep Power: 11
sheaker is on a distinguished road
Here is my new "Old NASA Thermo Generator"
Give it a try.
Code:
###########################
#Old NASA Thermo Generator#
#      Oskar Zuranski     #
#   Warsaw, Poland,2018   #
###########################

import sys
import cantera as ct
import numpy as np
import math
from numpy.linalg import inv

#######################################################################
# USER EDITABLE PART
#######################################################################

gas = ct.Solution('gri30.cti','gri30_mix')
#gas = ct.Solution('Dagaut_Ori.cti')
#gas = ct.Solution('curran.cti')

q = 'C2H2:1'

p = 101325
Tlow = 300.0
Tcommon = 1000.0
Thigh = 5000.0
step = 100

#######################################################################
# END OF USER EDITABLE PART
#######################################################################

#######################################################################
# LOW TEMPERATURE RANGE
#######################################################################

# reference temperature for standard enthalpy/entropy
Tref = 298.15

#create gas
gas.TPX = Tlow, p, q

# create empty temperature table for low temperature range
templist = [0 for x in range(step+1)]
np.float64(templist)

#set temperatures in temperature table for low temperature range
for i in range (step+1):
    templist[i] = Tlow+i*((Tcommon-Tlow)/step)
    
#create X matrix
tab = [[0 for x in range(5)] for y in range(5)]
np.float64(tab)

#set X matrix coefficients
for a in range(5):
    for b in range(5):
        for i in range (step+1):
            tab[a][b] += templist[i]**(b+a)

#create Y matrix
tab2 = [0 for x in range(5)]
np.float64(tab2)

#set Y matrix coefficients
for a in range(5):
    for i in range(step+1):
        gas.TPX = templist[i], gas.P, gas.X
        tab2[a] += gas.cp_mole/ct.gas_constant*templist[i]**a

# invert X matrix
inverse = inv(tab)

# multiply X^-1*Y
low_temp_range = np.matmul(inverse,tab2)
print 'Low temperature range coefficients:'

print 'a1 = ',low_temp_range[0]
print 'a2 = ',low_temp_range[1]
print 'a3 = ',low_temp_range[2]
print 'a4 = ',low_temp_range[3]
print 'a5 = ',low_temp_range[4]



gas.TPX = Tref, gas.P, gas.X

hOffset = gas.enthalpy_mole/ct.gas_constant - (low_temp_range[0]*Tref+low_temp_range[1]/2.0*Tref**2+low_temp_range[2]/3.0*Tref**3+low_temp_range[3]/4.0*Tref**4+low_temp_range[4]/5.0*Tref**5)
sOffset = gas.entropy_mole/ct.gas_constant - (low_temp_range[0]*np.log(Tref)+low_temp_range[1]*Tref+low_temp_range[2]/2.0*Tref**2+low_temp_range[3]/3.0*Tref**3+low_temp_range[4]/4.0*Tref**4)

print 'a6 = ', hOffset
print 'a7 = ', sOffset
print ''

#######################################################################
# HIGH TEMPERATURE RANGE
#######################################################################
gas.TPX = Tcommon, gas.P, gas.X

hbak = gas.enthalpy_mole/ct.gas_constant
sbak = gas.entropy_mole/ct.gas_constant

# clear tabs
templist = [0 for x in range(step+1)]
tab = [[0 for x in range(5)] for y in range(5)]
tab2 = [0 for x in range(5)]

#set temperatures in temperature table for high temperature range
for i in range (step+1):
    templist[i] = Tcommon+i*((Thigh-Tcommon)/step)

#set X matrix coefficients
for a in range(5):
    for b in range(5):
        for i in range (step+1):
            tab[a][b] += templist[i]**(b+a)


#set Y matrix coefficients
for a in range(5):
    for i in range(step+1):
        gas.TPX = templist[i], gas.P, gas.X
        tab2[a] += gas.cp_mole/ct.gas_constant*templist[i]**a
        
# inverse X matrix
inverse = inv(tab)

# multiply X^-1*Y
high_temp_range = np.matmul(inverse,tab2)

print 'High temperature range coefficients:'

print 'a1 = ', high_temp_range[0]
print 'a2 = ', high_temp_range[1]
print 'a3 = ', high_temp_range[2]
print 'a4 = ', high_temp_range[3]
print 'a5 = ', high_temp_range[4]



hOffset = hbak - (high_temp_range[0]*Tcommon+high_temp_range[1]/2.0*Tcommon**2+high_temp_range[2]/3.0*Tcommon**3+high_temp_range[3]/4.0*Tcommon**4+high_temp_range[4]/5.0*Tcommon**5)
sOffset = sbak - (high_temp_range[0]*np.log(Tcommon)+high_temp_range[1]*Tcommon+high_temp_range[2]/2.0*Tcommon**2+high_temp_range[3]/3.0*Tcommon**3+high_temp_range[4]/4.0*Tcommon**4)

print 'a6 = ', hOffset
print 'a7 = ', sOffset
print ''
print 'M = ', gas.mean_molecular_weight, '[g/mol]'
sheaker is offline   Reply With Quote

Old   September 18, 2018, 16:25
Default
  #63
Member
 
Arvind Jay
Join Date: Sep 2012
Posts: 97
Rep Power: 15
arvindpj is on a distinguished road
Try this:

Code:
from cantera import *
import numpy as np
import sys

gas = Solution('gri30.cti')
#q = 'CH4:1'
#q = 'O2:7, H2O:95, N2:719, CO:14, CO2:158, NO:4'  #Mole fraction
#gas.TPX = 273.16,101325,q


Pin = 101325 #Pa
Tin = 1200 #K
qmass = 'N2:.76, CO2:.13, H2O:.11'
gas.TPY = Tin,Pin,qmass

gasmass = gas.Y
gasmole = gas.X
gasnames = gas.species_names

n=0

print gas()

print "Temperature:\t", gas.T, "K"
print "Pressure:\t", gas.P, "Pa"

print ""
print "Molar fractions:"
for i in range(gas.n_species):
    if gasmole[i]!=0:
        n+=1    
        if gasmole[i]>=0.1: print n, gasnames[i], "\t{0:.10f}".format(100.0*gasmole[i]), "%"
        else:
            print n, gasnames[i], "\t {0:.10f}".format(100.0*gasmole[i]), "%"

n=0
print ""
print "Mass fractions:"
for i in range(gas.n_species):
    if gasmass[i]!=0:
        n+=1    
        if gasmass[i]>=0.1: print n, gasnames[i], "\t{0:.10f}".format(100.0*gasmass[i]), "%"
        else:
            print n, gasnames[i], "\t {0:.10f}".format(100.0*gasmass[i]), "%"    

#kg/m^3\t{0:.15f}".format(gasmole[i]), "mol/m^3"
print ""
print "Mean molar mass:"
print "M  =", gas.mean_molecular_weight, "kg/kmol"

print ""
print "Density:"
print "rho =", gas.density, "kg/m^3"
print "rho =", gas.density_mole, "kmol/m^3"

print ""
print "Specific gas constant:"
print "R  =",gas_constant/gas.mean_molecular_weight, "J/kg/K"  #CHheck units ??????????

print ""
print "Molar heat capacities:"
print "Cp =", gas.cp_mole/1000.0, "J/mol/K"
print "Cv =", gas.cv_mole/1000.0, "J/mol/K"


print ""
print "Mass heat capacities:"
print "Cp =", gas.cp_mass, "J/kg/K"
print "Cv =", gas.cv_mass, "J/kg/K"

print ""
print "Heat capacity ratio"
print "kappa =", gas.cp_mole/gas.cv_mole
arvindpj is offline   Reply With Quote

Old   September 19, 2018, 07:27
Default
  #64
Member
 
Join Date: Sep 2018
Location: France
Posts: 62
Rep Power: 8
john myce is on a distinguished road
Thanks a lot guys,

It works for both scripts you gave me.

For the script to calculate the Janaf coefficients, the results seem to be quite close from those coefficients in OpenFOAM 5 by choosing the nitrogen (except for a2, a3 and a4 for the lower interval where the gap is high).

Cheers.

Last edited by john myce; September 19, 2018 at 12:30.
john myce is offline   Reply With Quote

Old   October 18, 2022, 11:17
Default How the low_enthalpy_offset and high_enthalpy_offset are calculated
  #65
Senior Member
 
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 145
Rep Power: 17
ziemowitzima is on a distinguished road
Hi,


I am trying to understand how the low_enthalpy_offset and high_enthalpy_offset are calculated ?



what is gas.enthalpy_mass() ?


Thank you.


Mieszko
ziemowitzima is offline   Reply With Quote

Reply

Tags
janaf, openfoam, sutherland

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 15:12.