Commiting example dir.
This commit is contained in:
parent
53b937679d
commit
c842a6423f
6 changed files with 266 additions and 0 deletions
8
Cantera/python/examples/liquid_vapor/rankine/.cvsignore
Normal file
8
Cantera/python/examples/liquid_vapor/rankine/.cvsignore
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Makefile
|
||||
runtest
|
||||
ct2ctml.log
|
||||
diff_out_0.txt
|
||||
h2o2.xml
|
||||
liquidvapor.xml
|
||||
output_0.txt
|
||||
transport_log.xml
|
||||
15
Cantera/python/examples/liquid_vapor/rankine/Makefile.in
Normal file
15
Cantera/python/examples/liquid_vapor/rankine/Makefile.in
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
PYTHON_CMD = @PYTHON_CMD@
|
||||
|
||||
run:
|
||||
$(PYTHON_CMD) rankine.py
|
||||
|
||||
test:
|
||||
./runtest
|
||||
clean:
|
||||
rm -f *.log *.csv *.xml
|
||||
./cleanup
|
||||
|
||||
# end of file
|
||||
|
||||
5
Cantera/python/examples/liquid_vapor/rankine/cleanup
Executable file
5
Cantera/python/examples/liquid_vapor/rankine/cleanup
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
/bin/rm -rf equilibrate_log*.html
|
||||
/bin/rm -rf .cttmp* ct2ctml.log transport_log.xml vcs_equilibrate_res*.csv \
|
||||
catcomb.csv output_0.txt diff*
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
|
||||
|
||||
***************** State 1 ******************
|
||||
|
||||
water:
|
||||
|
||||
temperature 300 K
|
||||
pressure 3528.21 Pa
|
||||
density 996.589 kg/m^3
|
||||
mean mol. weight 18.016 amu
|
||||
vapor fraction 0
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy -1.58582e+07 -2.857e+08 J
|
||||
internal energy -1.58582e+07 -2.857e+08 J
|
||||
entropy 3913.28 7.05e+04 J/K
|
||||
Gibbs function -1.70322e+07 -3.069e+08 J
|
||||
heat capacity c_p 4.06353e+07 7.321e+08 J/K
|
||||
heat capacity c_v 4156.15 7.488e+04 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2O 1 1 -123.019
|
||||
|
||||
|
||||
***************** State 2 ******************
|
||||
|
||||
water:
|
||||
|
||||
temperature 300.143 K
|
||||
pressure 800000 Pa
|
||||
density 996.91 kg/m^3
|
||||
mean mol. weight 18.016 amu
|
||||
vapor fraction 0
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy -1.58569e+07 -2.857e+08 J
|
||||
internal energy -1.58577e+07 -2.857e+08 J
|
||||
entropy 3915.06 7.053e+04 J/K
|
||||
Gibbs function -1.7032e+07 -3.068e+08 J
|
||||
heat capacity c_p 4178.6 7.528e+04 J/K
|
||||
heat capacity c_v 4127.86 7.437e+04 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2O 1 1 -122.959
|
||||
|
||||
|
||||
***************** State 3 ******************
|
||||
|
||||
water:
|
||||
|
||||
temperature 443.624 K
|
||||
pressure 800000 Pa
|
||||
density 4.15875 kg/m^3
|
||||
mean mol. weight 18.016 amu
|
||||
vapor fraction 1
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy -1.32016e+07 -2.378e+08 J
|
||||
internal energy -1.33939e+07 -2.413e+08 J
|
||||
entropy 10183 1.835e+05 J/K
|
||||
Gibbs function -1.7719e+07 -3.192e+08 J
|
||||
heat capacity c_p 2.30856e+07 4.159e+08 J/K
|
||||
heat capacity c_v 22595 4.071e+05 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2O 1 1 -86.5462
|
||||
|
||||
|
||||
***************** State 4 ******************
|
||||
|
||||
water:
|
||||
|
||||
temperature 300 K
|
||||
pressure 3528.21 Pa
|
||||
density 0.0305583 kg/m^3
|
||||
mean mol. weight 18.016 amu
|
||||
vapor fraction 0.835158
|
||||
|
||||
1 kg 1 kmol
|
||||
----------- ------------
|
||||
enthalpy -1.38221e+07 -2.49e+08 J
|
||||
internal energy -1.39376e+07 -2.511e+08 J
|
||||
entropy 10700.2 1.928e+05 J/K
|
||||
Gibbs function -1.70322e+07 -3.069e+08 J
|
||||
heat capacity c_p 4.06353e+07 7.321e+08 J/K
|
||||
heat capacity c_v 108455 1.954e+06 J/K
|
||||
|
||||
X Y Chem. Pot. / RT
|
||||
------------- ------------ ------------
|
||||
H2O 1 1 -123.019
|
||||
efficiency = 0.233208584856
|
||||
94
Cantera/python/examples/liquid_vapor/rankine/rankine.py
Normal file
94
Cantera/python/examples/liquid_vapor/rankine/rankine.py
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#
|
||||
# A Rankine vapor power cycle
|
||||
#
|
||||
|
||||
from Cantera import *
|
||||
from Cantera.liquidvapor import Water
|
||||
|
||||
|
||||
########################################################
|
||||
#
|
||||
# parameters
|
||||
#
|
||||
|
||||
eta_pump = 0.6 # pump isentropic efficiency
|
||||
eta_turbine = 0.8 # turbine isentropic efficiency
|
||||
pmax = 8.0e5 # maximum pressure
|
||||
|
||||
|
||||
########################################################
|
||||
#
|
||||
# some useful functions
|
||||
#
|
||||
|
||||
def pump(fluid, pfinal, eta):
|
||||
"""Adiabatically pump a fluid to pressure pfinal, using
|
||||
a pump with isentropic efficiency eta."""
|
||||
h0 = fluid.enthalpy_mass()
|
||||
s0 = fluid.entropy_mass()
|
||||
fluid.set(S = s0, P = pfinal)
|
||||
h1s = fluid.enthalpy_mass()
|
||||
isentropic_work = h1s - h0
|
||||
actual_work = isentropic_work / eta
|
||||
h1 = h0 + actual_work
|
||||
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.set(S = s0, P = pfinal)
|
||||
h1s = fluid.enthalpy_mass()
|
||||
isentropic_work = h0 - h1s
|
||||
actual_work = isentropic_work * eta
|
||||
h1 = h0 - actual_work
|
||||
fluid.set(H = h1, P = pfinal)
|
||||
return actual_work
|
||||
|
||||
|
||||
def printState(n, fluid):
|
||||
print '\n\n***************** State '+`n`+' ******************\n', fluid
|
||||
|
||||
|
||||
###############################################################
|
||||
|
||||
|
||||
# create an object representing water
|
||||
w = Water()
|
||||
|
||||
# start with saturated liquid water at 300 K
|
||||
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)
|
||||
h2 = w.enthalpy_mass()
|
||||
printState(2,w)
|
||||
|
||||
# heat it at constant pressure until it reaches the
|
||||
# saturated vapor state at this pressure
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
47
Cantera/python/examples/liquid_vapor/rankine/runtest.in
Executable file
47
Cantera/python/examples/liquid_vapor/rankine/runtest.in
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
temp_success="1"
|
||||
/bin/rm -f output_0.txt diff_csv.txt diff_out_0.txt
|
||||
|
||||
##########################################################################
|
||||
PYTHON_CMD=@PYTHON_CMD@
|
||||
prog=rankine.py
|
||||
if test ! -f $prog ; then
|
||||
echo $prog ' does not exist'
|
||||
exit -1
|
||||
fi
|
||||
#################################################################
|
||||
#
|
||||
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
|
||||
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
|
||||
|
||||
#################################################################
|
||||
|
||||
$PYTHON_CMD $prog > output_0.txt <<+
|
||||
1.0
|
||||
+
|
||||
retnStat=$?
|
||||
if [ $retnStat != "0" ]
|
||||
then
|
||||
temp_success="0"
|
||||
echo "$prog returned with bad status, $retnStat, check output"
|
||||
fi
|
||||
|
||||
diff -w output_blessed_0.txt output_0.txt > diff_out_0.txt
|
||||
retnStat_0=$?
|
||||
|
||||
retnTotal=1
|
||||
if test $retnStat_0 = "0"
|
||||
then
|
||||
retnTotal=0
|
||||
fi
|
||||
|
||||
if test $retnTotal = "0"
|
||||
then
|
||||
echo "Successful test comparison on "`pwd`
|
||||
else
|
||||
echo "Unsuccessful test comparison of txt files on "`pwd` " test"
|
||||
echo " see diff_outi_0.txt "
|
||||
fi
|
||||
|
||||
Loading…
Add table
Reference in a new issue