def setup_CombustionChamber_model(self): """Set up the model using the combustion chamber.""" # %% network setup fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O'] self.nw1 = Network(fluids=fluid_list, p_unit='bar', T_unit='C', p_range=[0.5, 20]) # %% components amb = Source('ambient') sf = Source('fuel') cc = CombustionChamber('combustion') cp = Compressor('compressor') gt = Turbine('turbine') fg = Sink('flue gas outlet') # %% connections amb_cp = Connection(amb, 'out1', cp, 'in1') cp_cc = Connection(cp, 'out1', cc, 'in1') sf_cc = Connection(sf, 'out1', cc, 'in2') cc_gt = Connection(cc, 'out1', gt, 'in1', label='flue gas after cc') gt_fg = Connection(gt, 'out1', fg, 'in1', label='flue gas after gt') self.nw1.add_conns(amb_cp, cp_cc, sf_cc, cc_gt, gt_fg) # %% component parameters cc.set_attr(lamb=3) cp.set_attr(eta_s=0.9, pr=15) gt.set_attr(eta_s=0.9) # %% connection parameters amb_cp.set_attr(T=20, p=1, m=100, fluid={ 'Ar': 0.0129, 'N2': 0.7553, 'H2O': 0, 'CH4': 0, 'CO2': 0.0004, 'O2': 0.2314 }) sf_cc.set_attr(T=20, fluid={ 'CO2': 0.04, 'Ar': 0, 'N2': 0, 'O2': 0, 'H2O': 0, 'CH4': 0.96 }) gt_fg.set_attr(p=1) # %% solving mode = 'design' self.nw1.solve(mode=mode)
def test_CombustionChamber_missing_oxygen(): """Test no oxygen in network.""" nw = Network(['H2O', 'N2', 'Ar', 'CO2', 'CH4']) instance = CombustionChamber('combustion chamber') c1 = Connection(Source('air'), 'out1', instance, 'in1') c2 = Connection(Source('fuel'), 'out1', instance, 'in2') c3 = Connection(instance, 'out1', Sink('flue gas'), 'in1') nw.add_conns(c1, c2, c3) with raises(TESPyComponentError): nw.solve('design', init_only=True)
def calc_parameters(self): r"""Postprocessing parameter calculation.""" CombustionChamber.calc_parameters(self) T_ref = 298.15 p_ref = 1e5 res = 0 for i in self.inl: res += i.m.val_SI * (i.h.val_SI - h_mix_pT( [0, p_ref, 0, i.fluid.val], T_ref, force_gas=True)) for o in self.outl: res -= o.m.val_SI * (o.h.val_SI - h_mix_pT( [0, p_ref, 0, o.fluid.val], T_ref, force_gas=True)) self.eta.val = -res / self.ti.val self.Q_loss.val = -(1 - self.eta.val) * self.ti.val if self.inl[1].p.val < self.inl[0].p.val: msg = ( "The pressure at inlet 2 is lower than the pressure at inlet 1 " "at component " + self.label + ".") logging.warning(msg)
def test_CombustionChamber(self): """ Test component properties of combustion chamber. """ instance = CombustionChamber('combustion chamber') self.setup_CombustionChamber_network(instance) # connection parameter specification air = { 'N2': 0.7556, 'O2': 0.2315, 'Ar': 0.0129, 'H2O': 0, 'CO2': 0, 'CH4': 0 } fuel = {'N2': 0, 'O2': 0, 'Ar': 0, 'H2O': 0, 'CO2': 0.04, 'CH4': 0.96} self.c1.set_attr(fluid=air, p=1, T=30) self.c2.set_attr(fluid=fuel, T=30) self.c3.set_attr(T=1200) # test specified bus value on CombustionChamber (must be equal to ti) b = Bus('thermal input', P=1e6) b.add_comps({'comp': instance}) self.nw.add_busses(b) self.nw.solve('design') convergence_check(self.nw.lin_dep) msg = ('Value of thermal input must be ' + str(b.P.val) + ', is ' + str(instance.ti.val) + '.') assert round(b.P.val, 1) == round(instance.ti.val, 1), msg b.set_attr(P=np.nan) # test specified thermal input for CombustionChamber instance.set_attr(ti=1e6) self.nw.solve('design') convergence_check(self.nw.lin_dep) ti = (self.c2.m.val_SI * self.c2.fluid.val['CH4'] * instance.fuels['CH4']['LHV']) msg = ('Value of thermal input must be ' + str(instance.ti.val) + ', is ' + str(ti) + '.') assert round(ti, 1) == round(instance.ti.val, 1), msg # test specified lamb for CombustionChamber self.c3.set_attr(T=np.nan) instance.set_attr(lamb=1) self.nw.solve('design') convergence_check(self.nw.lin_dep) msg = ('Value of oxygen in flue gas must be 0.0, is ' + str(round(self.c3.fluid.val['O2'], 4)) + '.') assert 0.0 == round(self.c3.fluid.val['O2'], 4), msg
CycleCloser) from tespy.connections import Connection, Bus, Ref from tespy.tools import document_model from tespy.tools import CharLine import numpy as np # %% network fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O'] nw = Network(fluids=fluid_list, p_unit='bar', T_unit='C', h_unit='kJ / kg') # %% components # gas turbine part comp = Compressor('compressor') c_c = CombustionChamber('combustion') g_turb = Turbine('gas turbine') CH4 = Source('fuel source') air = Source('ambient air') # waste heat recovery suph = HeatExchanger('superheater') evap = HeatExchanger('evaporator') dr = Drum('drum') eco = HeatExchanger('economizer') dh_whr = HeatExchanger('waste heat recovery') ch = Sink('chimney') # steam turbine part turb = Turbine('steam turbine')
# define full fluid list for the network's variable space fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O'] # define unit systems and fluid property ranges nw = Network(fluids=fluid_list, p_unit='bar', T_unit='C', p_range=[0.5, 10]) # %% components # sinks & sources amb = Source('ambient') sf = Source('fuel') fg = Sink('flue gas outlet') # combustion chamber comb = CombustionChamber(label='combustion chamber') # %% connections amb_comb = Connection(amb, 'out1', comb, 'in1') sf_comb = Connection(sf, 'out1', comb, 'in2') comb_fg = Connection(comb, 'out1', fg, 'in1') nw.add_conns(sf_comb, amb_comb, comb_fg) # %% component parameters # set combustion chamber air to stoichometric air ratio and thermal input comb.set_attr(lamb=3, ti=2e6) # %% connection parameters
# %% network fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O'] nw = Network(fluids=fluid_list, p_unit='bar', T_unit='C', h_unit='kJ / kg', p_range=[1, 100], T_range=[10, 1500], h_range=[10, 4000]) # %% components # gas turbine part comp = Compressor('compressor') comp_fuel = Compressor('fuel compressor') c_c = CombustionChamber('combustion') g_turb = Turbine('gas turbine') CH4 = Source('fuel source') air = Source('ambient air') # waste heat recovery suph = HeatExchanger('superheater') evap = HeatExchanger('evaporator') drum = Drum('drum') eco = HeatExchanger('economizer') ch = Sink('chimney') # steam turbine part turb_hp = Turbine('steam turbine high pressure') cond_dh = Condenser('district heating condenser')
def setup(self): """Set up the model.""" # %% network setup fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O'] self.nw = Network(fluids=fluid_list, p_unit='bar', T_unit='C', p_range=[0.5, 20]) # %% components amb = Source('ambient') sf = Source('fuel') cc = CombustionChamber('combustion') cp = Compressor('compressor') gt = Turbine('turbine') fg = Sink('flue gas outlet') # %% connections amb_cp = Connection(amb, 'out1', cp, 'in1', label='ambient air flow') cp_cc = Connection(cp, 'out1', cc, 'in1') sf_cc = Connection(sf, 'out1', cc, 'in2') cc_gt = Connection(cc, 'out1', gt, 'in1') gt_fg = Connection(gt, 'out1', fg, 'in1') self.nw.add_conns(amb_cp, cp_cc, sf_cc, cc_gt, gt_fg) # %% component parameters cc.set_attr(lamb=3) cp.set_attr(eta_s=0.9, pr=15) gt.set_attr(eta_s=0.9) # %% connection parameters amb_cp.set_attr(T=20, p=1, m=100, fluid={ 'Ar': 0.0129, 'N2': 0.7553, 'H2O': 0, 'CH4': 0, 'CO2': 0.0004, 'O2': 0.2314 }) sf_cc.set_attr(T=20, fluid={ 'CO2': 0.04, 'Ar': 0, 'N2': 0, 'O2': 0, 'H2O': 0, 'CH4': 0.96 }) gt_fg.set_attr(p=1) # motor efficiency x = np.array([ 0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.05, 1.1, 1.15, 1.2, 10 ]) y = np.array([ 0.01, 0.3148, 0.5346, 0.6843, 0.7835, 0.8477, 0.8885, 0.9145, 0.9318, 0.9443, 0.9546, 0.9638, 0.9724, 0.9806, 0.9878, 0.9938, 0.9982, 0.999, 0.9995, 0.9999, 1, 0.9977, 0.9947, 0.9909, 0.9853, 0.9644 ]) * 0.975 self.motor_bus_based = CharLine(x=x, y=y) self.motor_comp_based = CharLine(x=x, y=1 / y) # generator efficiency x = np.array([ 0.100, 0.345, 0.359, 0.383, 0.410, 0.432, 0.451, 0.504, 0.541, 0.600, 0.684, 0.805, 1.000, 1.700, 10 ]) y = np.array([ 0.976, 0.989, 0.990, 0.991, 0.992, 0.993, 0.994, 0.995, 0.996, 0.997, 0.998, 0.999, 1.000, 0.999, 0.99 ]) * 0.975 self.generator = CharLine(x=x, y=y) power_bus_total = Bus('total power output') power_bus_total.add_comps( { 'comp': cp, 'char': self.motor_bus_based, 'base': 'bus' }, { 'comp': gt, 'char': self.generator }) thermal_input = Bus('thermal input') thermal_input.add_comps({'comp': cc}) compressor_power_comp = Bus('compressor power input') compressor_power_comp.add_comps({ 'comp': cp, 'char': self.motor_comp_based }) compressor_power_bus = Bus('compressor power input bus based') compressor_power_bus.add_comps({ 'comp': cp, 'char': self.motor_bus_based, 'base': 'bus' }) self.nw.add_busses(power_bus_total, thermal_input, compressor_power_comp, compressor_power_bus) # %% solving self.nw.solve('design') self.nw.save('tmp')