added a CLI option choosing HHV or LHV

This commit is contained in:
ignis 2021-11-30 10:31:28 +09:00
parent b0a7b7167b
commit 7a7a69fe1f

40
coal.py
View file

@ -1,7 +1,18 @@
from functools import reduce
import argparse
import cantera as ct
import argparse
parser = argparse.ArgumentParser(description='Calculate Thermodynamic States of the Coal fired Boiler')
parser.add_argument('--hhv', action='store_true', help='Higher heating value is used')
args = parser.parse_args()
is_HHV = vars(args)['hhv']
stdT = 298.15 # Temperature at standard state, K
"""#############################################################################
Input Parameter Section
#############################################################################"""
@ -10,8 +21,6 @@ Input Parameter Section
t = list(map(float, ''' 348.15 315.65 600.79 308.54 318.03 306.11 339.45 '''.split()))
m = list(map(float, ''' 114.4 6.94 362.92 7.25 7.25 7.25 7.25 '''.split()))
stdT = 298.15 # Temperature at standard state, K
coalT = 348.15 # K
coalMfr = 56.8813 # kg/s
@ -86,25 +95,31 @@ Heating value = Sum(Product Enthalpy of Formation) - Sum(Reactant Enthalpy of Fo
# coal heating value = 5761 Kcal/kg * 4.184 kJ/kcal
coalHV = - 5761 * 4.184 # J/kg, with Moisture and Ash
coalHVdaf = - 5761 * 4.184 / vm_fc # kJ/kg, Dry and Ash Free, Negative since exothermic
print("HV of Coal , kJ/kg = ", coalHV)
print("HV of Coal(daf), kJ/kg = ", coalHVdaf)
print("HHV" if is_HHV else "LHV", "of Coal , kJ/kg = ", coalHV)
print("HHV" if is_HHV else "LHV", "of Coal(daf), kJ/kg = ", coalHVdaf)
# sum product of 1kg coal enthalpy of formation - kJ/kg
def hf_product_coefs (product_name, element_name):
""" returns kJ/kg """
# J/kmol / kg/kmol / 1000
return (nasa_species[product_name].thermo.h(stdT)
/ ct.Element(element_name).weight
/ nasa_species[product_name].composition[element_name]
/ 1000. )
if product_name == "H2O" and is_HHV:
return (-285820 * 1000.
/ ct.Element(element_name).weight
/ nasa_species[product_name].composition[element_name]
/ 1000. )
else:
return (nasa_species[product_name].thermo.h(stdT)
/ ct.Element(element_name).weight
/ nasa_species[product_name].composition[element_name]
/ 1000. )
'''
H(stdT) values from NASA polynomial
H(stdT)/W values from NASA polynomial
- 32762.281048240053
- 119952.68929829611
- 9258.666766366705
H_f values from google search data
H_f/W values from google search data
- 32762.45348
- 141887.60121
- 8919.38250
@ -112,6 +127,11 @@ H_f values from google search data
Discrepency in Enthalpy of Formation for H2O is due to phase difference
value above is for vapor and otherwise is for liquid water
'''
print(hf_product_coefs("CO2", "C"))
print(hf_product_coefs("H2O", "H"))
print(hf_product_coefs("SO2", "S"))
sum_product_hf = (
hf_product_coefs("CO2", "C") * coal.elemental_mass_fraction('C')
+ hf_product_coefs("H2O", "H") * coal.elemental_mass_fraction('H')