def test_combustion_chamber_missing_fuel(): """Test no fuel in network.""" nw = network(['H2O', 'N2', 'O2', 'Ar', 'CO2']) instance = combustion.combustion_chamber('combustion chamber') c1 = connection(basics.source('air'), 'out1', instance, 'in1') c2 = connection(basics.source('fuel'), 'out1', instance, 'in2') c3 = connection(instance, 'out1', basics.sink('flue gas'), 'in1') nw.add_conns(c1, c2, c3) with raises(TESPyComponentError): nw.solve('design', init_only=True)
def test_combustion_chamber(self): """ Test component properties of combustion chamber. """ instance = combustion_chamber('combustion chamber') self.setup_combustion_chamber_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 combustion_chamber (must be equal to ti) b = bus('thermal input', P=1e6) b.add_comps({'c': 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) + '.') eq_(round(b.P.val, 1), round(instance.ti.val, 1), msg) b.set_attr(P=np.nan) # test specified thermal input for combustion_chamber 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) + '.') eq_(round(ti, 1), round(instance.ti.val, 1), msg) # test specified lamb for combustion_chamber 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)) + '.') eq_(0.0, round(self.c3.fluid.val['O2'], 4), msg)
def setup_combustion_chamber_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], T_range=[10, 2000]) # %% components amb = source('ambient') sf = source('fuel') cc = combustion_chamber('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 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], T_range=[10, 2000]) # %% components amb = source('ambient') sf = source('fuel') cc = combustion_chamber('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 = char_line(x=x, y=y) self.motor_comp_based = char_line(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 = char_line(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')
# %% 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 = combustion_chamber('combustion') g_turb = turbine('gas turbine') CH4 = source('fuel source') air = source('ambient air') # waste heat recovery suph = heat_exchanger('superheater') evap = heat_exchanger('evaporator') drum = drum('drum') eco = heat_exchanger('economizer') ch = sink('chimney') # steam turbine part turb_hp = turbine('steam turbine high pressure') cond_dh = condenser('district heating condenser')