*** empty log message ***

This commit is contained in:
Dave Goodwin 2004-03-12 11:44:04 +00:00
parent d298e3b4b0
commit 52ea110888
5 changed files with 132 additions and 77 deletions

View file

@ -0,0 +1,18 @@
"""Fluids with complete liquid/vapor equations of state."""
from importFromFile import importPhase
def Water():
return importPhase('liquidvapor.cti','water')
def Nitrogen():
return importPhase('liquidvapor.cti','nitrogen')
def Methane():
return importPhase('liquidvapor.cti','methane')
def Hydrogen():
return importPhase('liquidvapor.cti','hydrogen')
def Oxygen():
return importPhase('liquidvapor.cti','oxygen')

View file

@ -1,16 +0,0 @@
from importFromFile import importPhase
def Water():
return importPhase('purefluids.cti','water')
def Nitrogen():
return importPhase('purefluids.cti','nitrogen')
def Methane():
return importPhase('purefluids.cti','methane')
def Hydrogen():
return importPhase('purefluids.cti','hydrogen')
def Oxygen():
return importPhase('purefluids.cti','oxygen')

View file

@ -1,58 +1,98 @@
from exceptions import CanteraError
def setByName(a, options):
tval = None
pval = None
hval = None
uval = None
sval = None
vval = None
qval = None
np = 0
nt = 0
nv = 0
nx = 0
ny = 0
ns = 0
nh = 0
nu = 0
nq = 0
for o in options.keys():
val = options[o]
if o == 'Temperature' or o == 'T':
a.setTemperature(val)
nt += 1
tval = val
elif o == 'Density' or o == 'Rho':
a.setDensity(val)
nv += 1
vval = 1.0/val
elif o == 'V':
a.setDensity(1.0/val)
elif o == 'Volume' or o == 'V':
nv += 1
vval = val
elif o == 'MoleFractions' or o == 'X':
nx += 1
a.setMoleFractions(val)
elif o == 'MassFractions' or o == 'Y':
ny += 1
a.setMassFractions(val)
elif o == 'Pressure' or o == 'P':
pval = val
np = np + 1
np += 1
elif o == 'Enthalpy' or o == 'H':
hval = val
np = np + 1
nh += 1
elif o == 'IntEnergy' or o == 'U':
uval = val
np = np + 1
nu += 1
elif o == 'Entropy' or o == 'S':
sval = val
np = np + 1
ns += 1
elif o == 'Sat' or o == 'Vapor' or o == 'Vap':
nq += 1
qval = val
else:
raise CanteraError('unknown property: '+o)
if np == 1:
if pval:
a.setPressure(pval)
if nx + ny > 1:
raise CanteraError('composition specified multiple times')
if np >= 2:
if pval and hval:
a.setState_HP(hval,pval)
elif uval and vval:
a.setState_UV(uval,vval)
elif sval and pval:
a.setState_SP(sval,pval)
elif sval and vval:
a.setState_SV(sval,vval)
ntot = nt + np + nv + ns + nh + nu + nq
if ntot == 1:
if nt == 1:
a.setTemperature(tval)
elif nv == 1:
a.setDensity(1.0/vval)
elif np == 1:
a.seetPressure(pval)
else:
props = options.keys()
raise CanteraError('property '+props[0]+
' can only be set in combination with '
+'another property')
elif ntot == 2:
if np == 1 and nh == 1:
a.setState_HP(hval, pval)
elif nu == 1 and nv == 1:
a.setState_UV(uval, vval)
elif ns == 1 and np == 1:
a.setState_SP(sval, pval)
elif ns == 1 and nv == 1:
a.setState_SV(sval, vval)
elif nt == 1 and np == 1:
a.setState_TP(tval, pval)
elif nt == 1 and nv == 1:
a.setState_TR(tval, 1.0/vval)
elif nt == 1 and nq == 1:
a.setState_Tsat(tval, qval)
elif np == 1 and nq == 1:
a.setState_Psat(pval, qval)
else:
raise CanteraError('unimplemented property pair')
def set(a, **options):
setByName(a, options)

View file

@ -1,14 +1,21 @@
#
# an Rankine cycle
# A Rankine vapor power cycle
#
from Cantera import *
from Cantera.liquidvapor import Water
########################################################
#
# parameters
#
eta_pump = 0.6 # pump isentropic efficiency
et_turbine = 0.8 # turbine isentropic efficiency
eta_turbine = 0.8 # turbine isentropic efficiency
pmax = 8.0e5 # maximum pressure
########################################################
#
# some useful functions
@ -19,27 +26,33 @@ def pump(fluid, pfinal, eta):
a pump with isentropic efficiency eta."""
h0 = fluid.enthalpy_mass()
s0 = fluid.entropy_mass()
fluid.setState_SP(s0, pfinal)
fluid.set(S = s0, P = pfinal)
h1s = fluid.enthalpy_mass()
isentropic_work = h1s - h0
actual_work = isentropic_work / eta
h1 = h0 + actual_work
fluid.setState_HP(h1, pfinal)
fluid.set(H = h1, P = pfinal)
return actual_work
def expand(fluid, pfinal, eta):
"""Adiabatically expand a fluid to pressure pfinal, using
a turbine with isentropic efficiency eta."""
h0 = fluid.enthalpy_mass()
s0 = fluid.entropy_mass()
fluid.setState_SP(s0, pfinal)
fluid.set(S = s0, P = pfinal)
h1s = fluid.enthalpy_mass()
isentropic_work = h0 - h1s
actual_work = isentropic_work * eta
h1 = h0 - actual_work
fluid.setState_HP(h1, pfinal)
fluid.set(H = h1, P = pfinal)
return actual_work
def printState(n, fluid):
print '\n\n***************** State '+`n`+' ******************\n', fluid
###############################################################
@ -47,37 +60,35 @@ def expand(fluid, pfinal, eta):
w = Water()
# start with saturated liquid water at 300 K
w.setTemperature(300.0)
w.setState_Tsat(0.0)
hf = w.enthalpy_mass()
print w
w.setState_Tsat(1.0)
hv = w.enthalpy_mass()
print hv - hf
print w
w.set(T = 300.0, Vapor = 0.0)
h1 = w.enthalpy_mass()
p1 = w.pressure()
printState(1,w)
# pump it adiabatically to pmax
pump_work = pump(w, pmax, eta_pump)
print pump_work
h2 = w.enthalpy_mass()
printState(2,w)
# heat it at constant pressure until it reaches the
# saturated vapor state at this pressure
#w.setState_Psat(1.0)
#print w
w.set(P = pmax, Vapor = 1.0)
h3 = w.enthalpy_mass()
heat_added = h3 - h2
printState(3,w)
# expand back to p1
turbine_work = expand(w, p1, eta_turbine)
printState(4,w)
# efficiency
eff = (turbine_work - pump_work)/heat_added
print 'efficiency = ',eff
w.setTemperature(273.16)
w.setState_Tsat(0.0)
h0 = w.enthalpy_mass()
for t in [300.0, 350.0, 400.0, 450.0, 500.0]:
w.setTemperature(t)
w.setState_Tsat(0.0)
hf = w.enthalpy_mass()
w.setState_Tsat(1.0)
hv = w.enthalpy_mass()
print t, 0.001*(hf - h0), 0.001*(hv - h0), 0.001*(hv - hf)
for t in [750.0, 800.0, 850.0, 1150.0]:
w.setState_TP(t, 2.0e4)
print t, w.enthalpy_mass() - h0

View file

@ -1,38 +1,40 @@
# These phase definitions actually represent multiphase fluids. They
# use equations of state in the 'TPX' package, which in turn take most
# of the equations of state from the compilation 'Thermodynamic
# Properties in SI', by W. C. Reynolds.
# These phase definitions represent fluids with complete liquid/vapor
# equations of state. Depending on conditions, they may represent a
# single-phase fluid, either liquid or vapor, or a saturated
# liquid/vapor mixture. They use equations of state in the 'TPX'
# package, which in turn take most of the equations of state from the
# compilation 'Thermodynamic Properties in SI', by W. C. Reynolds.
pure_fluid(name = "water",
liquid_vapor(name = "water",
elements = " O H ",
species = "H2O",
substance_flag = 0,
initial_state = state(temperature = 300.0,
pressure = OneAtm) )
pure_fluid(name = "nitrogen",
liquid_vapor(name = "nitrogen",
elements = " N ",
species = "N2",
substance_flag = 1,
initial_state = state(temperature = 300.0,
pressure = OneAtm) )
pure_fluid(name = "methane",
liquid_vapor(name = "methane",
elements = " C H ",
species = "CH4",
substance_flag = 2,
initial_state = state(temperature = 300.0,
pressure = OneAtm) )
pure_fluid(name = "hydrogen",
liquid_vapor(name = "hydrogen",
elements = " H ",
species = "H2",
substance_flag = 3,
initial_state = state(temperature = 300.0,
pressure = OneAtm) )
pure_fluid(name = "oxygen",
liquid_vapor(name = "oxygen",
elements = " O ",
species = "O2",
substance_flag = 4,