def test_network_network_consistency_inlets(): nw = nwk.network(['water']) merge = cmp.merge('merge') sink = cmp.sink('label') a = con.connection(merge, 'out1', sink, 'in1') nw.add_conns(a) nw.check_network()
def create_comps(self): self.inlet = cmp.subsys_interface(label=self.label + '_inlet', num_inter=self.num_branch + 1) self.outlet = cmp.subsys_interface(label=self.label + '_outlet', num_inter=self.num_branch + 1) self.splitter = cmp.splitter(label=self.label + '_splitter') self.merge = cmp.merge(label=self.label + '_merge') self.valve = [] for i in range(self.num_branch): j = str(i) self.valve += [ cmp.valve(label=self.label + '_valve_' + j, mode='man') ]
def create_comps(self): self.num_i = 1 self.num_o = 1 self.inlet = cmp.subsys_interface(label=self.label + '_inlet', num_inter=self.num_i) self.outlet = cmp.subsys_interface(label=self.label + '_outlet', num_inter=self.num_o) self.splitter = [] self.merge = [] self.heat_ex = [] self.valve = [] self.pipe_feed = [] self.pipe_back = [] for i in range(self.num_consumer - 1): j = str(i) self.splitter += [ cmp.splitter(label=self.label + '_splitter_' + j) ] self.merge += [cmp.merge(label=self.label + '_merge_' + j)] self.heat_ex += [ cmp.heat_exchanger_simple(label=self.label + '_heat exchanger_' + j, mode='man') ] self.valve += [ cmp.valve(label=self.label + '_valve_' + j, mode='man') ] self.pipe_feed += [ cmp.pipe(label=self.label + '_pipe feed_' + j, offdesign=['kA']) ] self.pipe_back += [ cmp.pipe(label=self.label + '_pipe back_' + j, offdesign=['kA']) ] self.heat_ex += [ cmp.heat_exchanger_simple(label=self.label + '_heat exchanger_' + str(i + 1), mode='man') ]
nw = nwk.network(fluids=fluids, p_unit='bar', T_unit='C', h_unit='kJ / kg') # %% components # turbine part valve_turb = cmp.valve(label='valve_turb') turbine_hp = cmp.turbine(label='turbine_hp') split = cmp.splitter(label='splitter1') turbine_lp = cmp.turbine(label='turbine_lp') # condenser and preheater condenser = cmp.condenser(label='condenser') preheater = cmp.condenser(label='preheater') valve_pre = cmp.valve(label='valve_pre') valve = cmp.valve(label='valve1') merge = cmp.merge(label='merge1') # feed water pump = cmp.pump(label='pump') steam_generator = cmp.heat_exchanger_simple(label='steam generator') # sources and sinks source = cmp.source(label='source') sink = cmp.sink(label='sink') # for cooling water source_cw = cmp.source(label='source_cw') sink_cw = cmp.sink(label='sink_cw') # %% connections
pu = cmp.pump('pump') sp = cmp.splitter('splitter', num_out=3) # bhe: bhe_name = 'BHE1' assert 'BHE1' in bhe_name, "BHE should be named with 'BHE1'" bhe1 = cmp.heat_exchanger_simple(bhe_name) bhe_name = 'BHE2' assert 'BHE2' in bhe_name, "BHE should be named with 'BHE2'" bhe2 = cmp.heat_exchanger_simple(bhe_name) bhe_name = 'BHE3' assert 'BHE3' in bhe_name, "BHE should be named with 'BHE3'" bhe3 = cmp.heat_exchanger_simple(bhe_name) mg = cmp.merge('merge', num_in=3) cons = cmp.heat_exchanger_simple('consumer') # connections # inlet fc_pu = con.connection(fc_in, 'out1', pu, 'in1') pu_sp = con.connection(pu, 'out1', sp, 'in1') sp_bhe1 = con.connection(sp, 'out1', bhe1, 'in1') sp_bhe2 = con.connection(sp, 'out2', bhe2, 'in1') sp_bhe3 = con.connection(sp, 'out3', bhe3, 'in1') bhe1_mg = con.connection(bhe1, 'out1', mg, 'in1') bhe2_mg = con.connection(bhe2, 'out1', mg, 'in2')
# %% network btes = nwk.network(fluids=['water'], T_unit='C', p_unit='bar', h_unit='kJ / kg') # %% components # cycle closer (from consumer) fc_in = cmp.source('from consumer inflow') fc_out = cmp.sink('from consumer outflow') sp = cmp.splitter('splitter') mg = cmp.merge('merge') # two btes subsystems (pipes in parallel flow): # 10 pipes for outer ring, 5 pipes inner ring bo = bp('btes outer', 4) bi = bp('btes inner', 2) # circulation pump and consumer pump = cmp.pump('circulation pump') cons = cmp.heat_exchanger_simple('consumer') # %% connections # inlet fc_sp = con.connection(fc_in, 'out1', sp, 'in1') sp_bo = con.connection(sp, 'out1', bo.inlet, 'in1')
def setup_network_individual_offdesign(self): """ Set up network for individual offdesign tests. """ so = cmp.source('source') sp = cmp.splitter('splitter', num_out=2) self.pump1 = cmp.pump('pump 1') self.sc1 = cmp.solar_collector('collector field 1') v1 = cmp.valve('valve1') self.pump2 = cmp.pump('pump 2') self.sc2 = cmp.solar_collector('collector field 2') v2 = cmp.valve('valve2') me = cmp.merge('merge', num_in=2) si = cmp.sink('sink') self.pump1.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char']) self.pump2.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char']) self.sc1.set_attr(pr=0.95, lkf_lin=3.33, lkf_quad=0.011, A=1252, E=700, Tamb=20, design=['pr'], offdesign=['zeta']) self.sc2.set_attr(pr=0.95, lkf_lin=3.5, lkf_quad=0.011, A=700, E=800, Tamb=20, design=['pr'], offdesign=['zeta']) fl = { 'N2': 0, 'O2': 0, 'Ar': 0, 'INCOMP::DowQ': 0, 'H2O': 1, 'NH3': 0, 'CO2': 0, 'CH4': 0 } inlet = con.connection(so, 'out1', sp, 'in1', T=50, p=3, fluid=fl) outlet = con.connection(me, 'out1', si, 'in1', p=3) sp_p1 = con.connection(sp, 'out1', self.pump1, 'in1') p1_sc1 = con.connection(self.pump1, 'out1', self.sc1, 'in1') self.sc1_v1 = con.connection(self.sc1, 'out1', v1, 'in1', p=3.1, T=90) v1_me = con.connection(v1, 'out1', me, 'in1') self.sp_p2 = con.connection(sp, 'out2', self.pump2, 'in1') self.p2_sc2 = con.connection(self.pump2, 'out1', self.sc2, 'in1') self.sc2_v2 = con.connection(self.sc2, 'out1', v2, 'in1', p=3.1, m=0.1) v2_me = con.connection(v2, 'out1', me, 'in2') self.nw.add_conns(inlet, outlet, sp_p1, p1_sc1, self.sc1_v1, v1_me, self.sp_p2, self.p2_sc2, self.sc2_v2, v2_me)
# define unit systems and fluid property ranges nw = nwk.network(fluids=fluid_list, p_unit='bar', T_unit='C', p_range=[0.5, 10], T_range=[10, 1200]) # %% components # sinks & sources amb = cmp.source('ambient') sf = cmp.source('fuel') fg = cmp.sink('flue gas outlet') cw_in1 = cmp.source('cooling water inlet1') cw_in2 = cmp.source('cooling water inlet2') cw_out1 = cmp.sink('cooling water outlet1') cw_out2 = cmp.sink('cooling water outlet2') split = cmp.splitter('splitter') merge = cmp.merge('merge') # combustion chamber chp = cmp.cogeneration_unit(label='cogeneration unit') # %% connections amb_comb = con.connection(amb, 'out1', chp, 'in3') sf_comb = con.connection(sf, 'out1', chp, 'in4') comb_fg = con.connection(chp, 'out3', fg, 'in1') nw.add_conns(sf_comb, amb_comb, comb_fg) cw1_chp1 = con.connection(cw_in1, 'out1', chp, 'in1') cw2_chp2 = con.connection(cw_in2, 'out1', chp, 'in2')
def mass_flow(): mf = parameters_data.Q/(4.19*(parameters_data.Td - parameters_data.Tc)) e_w = (hlp.h_pT(100000, 318, 'H2O')) e_c = (hlp.h_pT(100000, 281, 'H2O')) mfc = (100-(e_w*mf))/(e_c-e_w) mfw = mf-mfc return mfc, mfw mass_flow_data = mass_flow() hw_in = cmp.source('hot water') ww_out = cmp.sink('warm water out') cc_in = cmp.source('cold water in') m = cmp.merge('merge', num_in=2) # connections lin1 = con.connection(hw_in, 'out1', m, 'in1') lin2 = con.connection(cc_in, 'out1', m, 'in2') lin3 = con.connection(m, 'out1', ww_out, 'in1') nw.add_conns(lin1, lin2, lin3) # connection parametrization lin1.set_attr(fluid={'H2O': 1}, T=parameters_data.Tw, m=mass_flow_data[0]) lin2.set_attr(fluid={'H2O': 1}, T=parameters_data.Tc, m=mass_flow_data[1]) lin3.set_attr(T=parameters_data.Td) # solve nw.solve('design')