def test_heat_ex(self): """ Test component properties of heat exchanger. """ tesin = cmp.sink('TES in') tesout = cmp.source('TES out') hsin = cmp.sink('HS in') hsout = cmp.source('HS out') he = cmp.heat_exchanger('heat exchanger') tes_he = con.connection(tesout, 'out1', he, 'in2') he_tes = con.connection(he, 'out2', tesin, 'in1') hs_he = con.connection(hsout, 'out1', he, 'in1') he_hs = con.connection(he, 'out1', hsin, 'in1') self.nw.add_conns(tes_he, he_tes, hs_he, he_hs) # design specification he.set_attr(pr1=0.98, pr2=0.98, ttd_u=5, design=['pr1', 'pr2', 'ttd_u'], offdesign=['zeta1', 'zeta2', 'kA']) hs_he.set_attr(T=120, p=3, fluid={'N2': 0, 'O2': 0, 'Ar': 0, 'INCOMP::DowQ': 0, 'H2O': 1, 'NH3': 0, 'CO2': 0, 'CH4': 0}) he_hs.set_attr(T=70) tes_he.set_attr(T=40, p=5, fluid={'N2': 0, 'O2': 0, 'Ar': 1, 'INCOMP::DowQ': 0, 'H2O': 0, 'NH3': 0, 'CO2': 0, 'CH4': 0}) b = con.bus('heat transfer', P=-80e3) b.add_comps({'c': he}) self.nw.add_busses(b) self.nw.solve('design') # check heat flow Q = hs_he.m.val_SI * (he_hs.h.val_SI - hs_he.h.val_SI) self.nw.save('tmp') eq_(round(hs_he.T.val - he_tes.T.val, 1), round(he.ttd_u.val, 1), 'Value of terminal temperature difference must be ' + str(he.ttd_u.val) + ', is ' + str(hs_he.T.val - he_tes.T.val) + '.') # check lower terminal temperature difference he_hs.set_attr(T=np.nan) he.set_attr(ttd_l=20) self.nw.solve('design') eq_(round(he_hs.T.val - tes_he.T.val, 1), round(he.ttd_l.val, 1), 'Value of terminal temperature difference must be ' + str(he.ttd_l.val) + ', is ' + str(he_hs.T.val - tes_he.T.val) + '.') # check kA value self.nw.solve('offdesign', design_path='tmp') eq_(round(Q, 1), round(he.Q.val, 1), 'Value of heat flow must be ' + str(he.Q.val) + ', is ' + str(Q) + '.') # trigger errors for negative terminal temperature differences at given kA-value he.set_attr(ttd_l=np.nan) # ttd_l he_hs.set_attr(T=30) try: self.nw.solve('offdesign', design_path='tmp') except ValueError: pass # ttd_u he_hs.set_attr(T=np.nan) he_tes.set_attr(T=130) try: self.nw.solve('offdesign', design_path='tmp') except ValueError: pass shutil.rmtree('./tmp', ignore_errors=True)
amb_in = cmp.source('source ambient') amb_out = cmp.sink('sink ambient') cp1 = cmp.sink('compressor 1') # consumer system cd = cmp.condenser('condenser') rp = cmp.pump('recirculation pump') cons = cmp.heat_exchanger_simple('consumer') # evaporator system ves = cmp.vessel('vessel') dr = cmp.drum('drum') ev = cmp.heat_exchanger('evaporator') su = cmp.heat_exchanger('superheater') pu = cmp.pump('pump evaporator') # %% connections # consumer system c_in_cd = con.connection(c_in, 'out1', cd, 'in1') cb_rp = con.connection(cb, 'out1', rp, 'in1') rp_cd = con.connection(rp, 'out1', cd, 'in2') cd_cons = con.connection(cd, 'out2', cons, 'in1') cons_cf = con.connection(cons, 'out1', cf, 'in1') nw.add_conns(c_in_cd, cb_rp, rp_cd, cd_cons, cons_cf)
def __init__(self, press_in=0, press_out=0, temp_in=0, temp_out=0, overh=0, enth_in=0, enth_out=0, entr_in=0, entr_out=0, work_fl='', mass_fl=0, pr=0, q_cap=0, heat_cap=0, amb_press_in=0, amb_press_out=0, amb_temp_in=0, amb_temp_out=0, pinch_point=0, amb_enth_in=0, amb_enth_out=0, amb_entr_in=0, amb_entr_out=0, amb_work_fl='', amb_mass_fl=0, amb_pr=0, cycle_name='', use_aspen=False, exer_in=0, exer_out=0, amb_exer_in=0, amb_exer_out=0): super().__init__(press_in, press_out, temp_in, temp_out, enth_in, enth_out, entr_in, entr_out, work_fl, mass_fl, cycle_name) self.q_cap = q_cap self.heat_cap = heat_cap self.pr = pr self.amb_enth_in = amb_enth_in self.amb_enth_out = amb_enth_out self.amb_press_in = amb_press_in self.amb_press_out = amb_press_out self.amb_temp_in = amb_temp_in self.amb_temp_out = amb_temp_out self.amb_entr_in = amb_entr_in self.amb_entr_out = amb_entr_out self.pinch_point = pinch_point self.overh = overh self.amb_work_fl = amb_work_fl self.amb_mass_fl = amb_mass_fl self.amb_pr = amb_pr self.is_model_correct = True self.use_aspen = use_aspen self.exer_in = exer_in self.exer_out = exer_out self.amb_exer_in = amb_exer_in self.amb_exer_out = amb_exer_out # Applying the condenser model using TESPy. Firstly the components and connections must be set, afterwards # the function will set the attributes and TESPy engine will calculate the demanded result. # Setting components: self.amb_inlet = cmp.sink('inlet of ambient') self.amb_outlet = cmp.source('outlet of ambient') self.cycle_inlet = cmp.sink('inlet of cycle') self.cycle_outlet = cmp.source('outlet of cycle') self.evaporator = cmp.heat_exchanger('evaporator') # Setting connections between components: self.amb_evap = con.connection(self.amb_outlet, 'out1', self.evaporator, 'in1') self.evap_amb = con.connection(self.evaporator, 'out1', self.amb_inlet, 'in1') self.cycle_evap = con.connection(self.cycle_outlet, 'out1', self.evaporator, 'in2') self.evap_cycle = con.connection(self.evaporator, 'out2', self.cycle_inlet, 'in1') if self.work_fl == '' or self.amb_work_fl == '': print( "Working fluid or the ambient working fluid hasn't been set, so creating the TESPy network model" "can't be completed.\n") else: # Putting the connections into the network (TESPy): # Because TESPy isn't smart enough and it throws error when the working fluid in the cycle # is the same as the one in ambient, # it is necessary to make a division of initialization of network basic attributes: if self.work_fl == self.amb_work_fl: self.nw = nwk.network(fluids=[self.work_fl], T_unit='K', p_unit='Pa', h_unit='J / kg') else: self.nw = nwk.network(fluids=[self.work_fl, self.amb_work_fl], T_unit='K', p_unit='Pa', h_unit='J / kg') self.nw.set_printoptions(print_level='none') self.nw.add_conns(self.amb_evap, self.evap_amb, self.cycle_evap, self.evap_cycle)
T_air = -4.7 p_air = 0.61 mass_flow_rate_brine = 3.4199e2 T_brine_in = 146.6 p_brine_in = 9.4 T_brine_out = 69.1 # calculation T_before_turbine = PropsSI('T', 'P', p_after_pump*0.957627118*0.955752212*1e5, 'Q', 1, 'Isopentane')-273.15+2.3 # basic network nw = nwk.network(fluids=fluids) nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg') # main components condenser = cmp.condenser('condenser') ihe = cmp.heat_exchanger('internal heat exchanger') pump = cmp.pump('feeding pump') turbine = cmp.turbine('turbine') p_and_e = cmp.heat_exchanger('preheater and evaporator') # cooling air source_ca = cmp.source('cooling air source') sink_ca = cmp.sink('cooling air sink') #brine source_b = cmp.source('brine source') sink_b = cmp.sink('brine sink') # working fluid source_wf_1 = cmp.source('working fluid source before turbine') sink_wf_1 = cmp.sink('working fluid sink from before turbine') source_wf_2 = cmp.source('working fluid source from ihe') sink_wf_2 = cmp.sink('working fluid sink from ihe') # connections
def __init__(self, press_in=0, press_out=0, temp_in=0, temp_out=0, enth_in=0, enth_out=0, entr_in=0, entr_out=0, work_fl='', pr=0, heat_val=0, mass_fl=0, temp_cond=0, overcool=0, amb_press_in=0, amb_press_out=0, amb_temp_in=0, amb_temp_out=0, amb_enth_in=0, amb_enth_out=0, amb_work_fl='', amb_mass_fl=0, amb_pr=0, cycle_name=''): super().__init__(press_in, press_out, temp_in, temp_out, enth_in, enth_out, entr_in, entr_out, work_fl, mass_fl, cycle_name) self.heat_val = heat_val self.pr = pr self.temp_cond = temp_cond self.overcool = overcool if temp_out == 0 and enth_out == 0: self.temp_out = self.temp_cond - self.overcool if self.temp_cond == 0 or self.overcool == 0: print( "Condenser.__init__(): The value of temp_out hasn't been declared. Therefore it was initialized" "as: temp_cond minus overcool. It seems however, that one of these values equals 0." ) self.amb_enth_in = amb_enth_in self.amb_enth_out = amb_enth_out self.amb_press_in = amb_press_in self.amb_press_out = amb_press_out self.amb_temp_in = amb_temp_in self.amb_temp_out = amb_temp_out self.amb_work_fl = amb_work_fl self.amb_mass_fl = amb_mass_fl self.amb_pr = amb_pr # For checking if the values are appropriate in function set_attr_pow_cyc(): self.approved = False # Applying the condenser model using TESPy. Firstly the components and connections must be set, afterwards # the function will set the attributes and TESPy solver will calculate the demanded result. # Setting components: self.amb_inlet = cmp.sink("inlet of ambient") self.amb_outlet = cmp.source("outlet of ambient") self.cycle_inlet = cmp.sink("inlet of cycle") self.cycle_outlet = cmp.source("outlet of cycle") self.condenser = cmp.heat_exchanger("condenser") # Setting connections between components: self.amb_cond = con.connection(self.amb_outlet, 'out1', self.condenser, 'in2') self.cond_amb = con.connection(self.condenser, 'out2', self.amb_inlet, 'in1') self.cycle_cond = con.connection(self.cycle_outlet, 'out1', self.condenser, 'in1') self.cond_cycle = con.connection(self.condenser, 'out1', self.cycle_inlet, 'in1') if self.work_fl == '' or self.amb_work_fl == '': print( "Working fluid or the ambient working fluid hasn't been set, so creating the TESPy network model" "can't be completed.\n") else: # Putting the connections into the network (TESPy): # Because TESPy isn't smart enough and it throws error when the working fluid in the cycle # is the same as the one in ambient, # it is necessary to make a division of initialization of network basic attributes: if self.work_fl == self.amb_work_fl: self.nw = nwk.network(fluids=[self.work_fl], T_unit='K', p_unit='Pa', h_unit='J / kg') else: self.nw = nwk.network(fluids=[self.work_fl, self.amb_work_fl], T_unit='K', p_unit='Pa', h_unit='J / kg') self.nw.set_printoptions(print_level='none') self.nw.add_conns(self.amb_cond, self.cond_amb, self.cycle_cond, self.cond_cycle)
# ambient air system sp = cmp.splitter('splitter') fan = cmp.compressor('fan') # consumer system cd = cmp.condenser('condenser') dhp = cmp.pump('district heating pump') cons = cmp.heat_exchanger_simple('consumer') # evaporator system ves = cmp.valve('valve') dr = cmp.drum('drum') ev = cmp.heat_exchanger('evaporator') su = cmp.heat_exchanger('superheater') erp = cmp.pump('evaporator reciculation pump') # compressor-system cp1 = cmp.compressor('compressor 1') cp2 = cmp.compressor('compressor 2') ic = cmp.heat_exchanger('intercooler') # %% connections # consumer system c_in_cd = con.connection(c_in, 'out1', cd, 'in1')
h_unit='kJ / kg', p_range=[1, 10], T_range=[110, 1500], h_range=[500, 4000]) # %% components # gas turbine part comp = cmp.compressor('compressor') c_c = cmp.combustion_chamber('combustion') g_turb = cmp.turbine('gas turbine') CH4 = cmp.source('fuel source') air = cmp.source('ambient air') # waste heat recovery suph = cmp.heat_exchanger('superheater') evap = cmp.heat_exchanger('evaporator') drum = cmp.drum('drum') eco = cmp.heat_exchanger('economizer') dh_whr = cmp.heat_exchanger('waste heat recovery') ch = cmp.sink('chimney') # steam turbine part turb = cmp.turbine('steam turbine') cond = cmp.condenser('condenser') pump = cmp.pump('feed water pump') ls_out = cmp.sink('ls sink') ls_in = cmp.source('ls source') # district heating dh_in = cmp.source('district heating backflow')
def setup(self): # %% network self.nw = nwk.network(fluids=['water', 'NH3'], T_unit='C', p_unit='bar', h_unit='kJ / kg', m_unit='kg / s') # %% components # sources & sinks c_in = cmp.source('coolant in') cb = cmp.source('consumer back flow') cf = cmp.sink('consumer feed flow') amb_in = cmp.source('source ambient') amb_out = cmp.sink('sink ambient') ic_in = cmp.source('source intercool') ic_out = cmp.sink('sink intercool') c_out = cmp.sink('coolant out') # consumer system cd = cmp.heat_exchanger('condenser') rp = cmp.pump('recirculation pump') cons = cmp.heat_exchanger_simple('consumer') # evaporator system va = cmp.valve('valve') dr = cmp.drum('drum') ev = cmp.heat_exchanger('evaporator') su = cmp.heat_exchanger('superheater') pu = cmp.pump('pump evaporator') # compressor-system cp1 = cmp.compressor('compressor 1') cp2 = cmp.compressor('compressor 2') he = cmp.heat_exchanger('intercooler') # busses x = np.array([0, 0.7, 1, 1.3]) y = 1 / np.array([0.8, 0.95, 1, 0.98]) / 0.9583794 motor = cmp_char.characteristics(x=x, y=y) self.power = con.bus('total compressor power') self.power.add_comps({ 'c': cp1, 'char': motor }, { 'c': cp2, 'char': motor }) self.heat = con.bus('total delivered heat') self.heat.add_comps({'c': cd, 'char': -1}) self.nw.add_busses(self.power, self.heat) # %% connections # consumer system c_in_cd = con.connection(c_in, 'out1', cd, 'in1') cb_rp = con.connection(cb, 'out1', rp, 'in1') rp_cd = con.connection(rp, 'out1', cd, 'in2') self.cd_cons = con.connection(cd, 'out2', cons, 'in1') cons_cf = con.connection(cons, 'out1', cf, 'in1') self.nw.add_conns(c_in_cd, cb_rp, rp_cd, self.cd_cons, cons_cf) # connection condenser - evaporator system cd_va = con.connection(cd, 'out1', va, 'in1') self.nw.add_conns(cd_va) # evaporator system va_dr = con.connection(va, 'out1', dr, 'in1') dr_pu = con.connection(dr, 'out1', pu, 'in1') pu_ev = con.connection(pu, 'out1', ev, 'in2') ev_dr = con.connection(ev, 'out2', dr, 'in2') dr_su = con.connection(dr, 'out2', su, 'in2') self.nw.add_conns(va_dr, dr_pu, pu_ev, ev_dr, dr_su) self.amb_in_su = con.connection(amb_in, 'out1', su, 'in1') su_ev = con.connection(su, 'out1', ev, 'in1') ev_amb_out = con.connection(ev, 'out1', amb_out, 'in1') self.nw.add_conns(self.amb_in_su, su_ev, ev_amb_out) # connection evaporator system - compressor system su_cp1 = con.connection(su, 'out2', cp1, 'in1') self.nw.add_conns(su_cp1) # compressor-system cp1_he = con.connection(cp1, 'out1', he, 'in1') he_cp2 = con.connection(he, 'out1', cp2, 'in1') cp2_c_out = con.connection(cp2, 'out1', c_out, 'in1') ic_in_he = con.connection(ic_in, 'out1', he, 'in2') he_ic_out = con.connection(he, 'out2', ic_out, 'in1') self.nw.add_conns(cp1_he, he_cp2, ic_in_he, he_ic_out, cp2_c_out) # %% component parametrization # condenser system rp.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char']) cons.set_attr(pr=1, design=['pr'], offdesign=['zeta']) # evaporator system ev.set_attr(pr1=1, pr2=.999, ttd_l=5, design=['ttd_l'], offdesign=['kA'], kA_char1='EVA_HOT', kA_char2='EVA_COLD') # characteristic line for superheater kA x = np.array( [0, 0.045, 0.136, 0.244, 0.43, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2]) y = np.array( [0, 0.037, 0.112, 0.207, 0.5, 0.8, 0.85, 0.9, 0.95, 1, 1.04, 1.07]) su_char = hlp.dc_cc(x=x, y=y, param='m') su.set_attr(kA_char1='default', kA_char2=su_char, offdesign=['zeta1', 'zeta2', 'kA']) pu.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char']) # compressor system cp1.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char']) cp2.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char']) # characteristic line for intercooler kA x = np.linspace(0, 2.5, 26) y = np.array([ 0.000, 0.164, 0.283, 0.389, 0.488, 0.581, 0.670, 0.756, 0.840, 0.921, 1.000, 1.078, 1.154, 1.228, 1.302, 1.374, 1.446, 1.516, 1.585, 1.654, 1.722, 1.789, 1.855, 1.921, 1.986, 2.051 ]) he_char_cold = hlp.dc_cc(x=x, y=y, param='m') he.set_attr(kA_char1='default', kA_char2=he_char_cold, offdesign=['zeta1', 'zeta2', 'kA']) cd.set_attr(pr2=0.998, design=['pr2'], offdesign=['zeta2', 'kA']) # %% connection parametrization # condenser system c_in_cd.set_attr(fluid={'water': 0, 'NH3': 1}, p=60) cb_rp.set_attr(T=60, p=10, fluid={'water': 1, 'NH3': 0}) self.cd_cons.set_attr(T=105) cons_cf.set_attr(h=con.ref(cb_rp, 1, 0), p=con.ref(cb_rp, 1, 0)) cd_va.set_attr(p=con.ref(c_in_cd, 1, -1000), Td_bp=-5, h0=500, design=['Td_bp']) # evaporator system cold side pu_ev.set_attr(m=con.ref(va_dr, 10, 0), p0=5) dr_su.set_attr(p0=5, T=5) su_cp1.set_attr(p=con.ref(dr_su, 1, -5000), Td_bp=5, h0=1700, design=['Td_bp', 'p']) # evaporator system hot side self.amb_in_su.set_attr(m=20, T=12, p=1, fluid={'water': 1, 'NH3': 0}) su_ev.set_attr(p=con.ref(self.amb_in_su, 1, -100), design=['p']) ev_amb_out.set_attr() # compressor-system cp1_he.set_attr(p=15) he_cp2.set_attr(T=40, p=con.ref(cp1_he, 1, -1000), design=['T', 'p']) ic_in_he.set_attr(p=1, T=20, m=5, fluid={'water': 1, 'NH3': 0}) he_ic_out.set_attr(p=con.ref(ic_in_he, 1, -200), design=['p']) cp2_c_out.set_attr(p=con.ref(c_in_cd, 1, 0), h=con.ref(c_in_cd, 1, 0))
nw = nwk.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 = cmp.compressor('compressor') comp_fuel = cmp.compressor('fuel compressor') c_c = cmp.combustion_chamber('combustion') g_turb = cmp.turbine('gas turbine') CH4 = cmp.source('fuel source') air = cmp.source('ambient air') # waste heat recovery suph = cmp.heat_exchanger('superheater') evap = cmp.heat_exchanger('evaporator') drum = cmp.drum('drum') eco = cmp.heat_exchanger('economizer') ch = cmp.sink('chimney') # steam turbine part turb_hp = cmp.turbine('steam turbine high pressure') cond_dh = cmp.condenser('district heating condenser') mp_split = cmp.splitter('mp split') turb_lp = cmp.turbine('steam turbine low pressure') cond = cmp.condenser('condenser') merge = cmp.merge('merge') pump1 = cmp.pump('feed water pump 1') pump2 = cmp.pump('feed water pump 2') ls_out = cmp.sink('ls sink')