def setup_pipeline_network(self, fluid_list): """Setup a pipeline network.""" self.nw = Network(fluids=fluid_list) self.nw.set_attr(p_unit='bar', T_unit='C', iterinfo=False) # %% components # main components pu = Pump('pump') pi = Pipe('pipeline') es = HeatExchangerSimple('energy balance closing') closer = CycleCloser('cycle closer') pu_pi = Connection(pu, 'out1', pi, 'in1') pi_es = Connection(pi, 'out1', es, 'in1') es_closer = Connection(es, 'out1', closer, 'in1') closer_pu = Connection(closer, 'out1', pu, 'in1') self.nw.add_conns(pu_pi, pi_es, es_closer, closer_pu) # %% parametrization of components pu.set_attr(eta_s=0.7) pi.set_attr(pr=0.95, L=100, ks=1e-5, D='var', Q=0) es.set_attr(pr=1) # %% parametrization of connections pu_pi.set_attr(p=20, T=100, m=10, fluid={self.nw.fluids[0]: 1}) # %% solving self.nw.solve('design')
# %% connections a = Connection(so, 'out1', pi, 'in1') b = Connection(pi, 'out1', si, 'in1') nw.add_conns(a, b) # %% connection parameters a.set_attr(h=40, fluid={'water': 1}, p=1, m=10) # %% component parameters pi.set_attr(ks=1e-5, L=100, D='var', Q=0) # %% solve nw.set_attr(iterinfo=False) # specify different pressure ratios for the pipe, # calculate the diameter required for pr in np.linspace(0.9, 0.999, 10): pi.set_attr(pr=pr) nw.solve(mode='design') print('Pressure ratio: ' + str(round(pr, 3)) + ', diameter: ' + str(round(pi.D.val * 1000, 0)) + ' mm.') document_model(nw)