def create_comps(self): for i in range(self.num_consumer - 1): j = str(i) self.comps['feed_' + j] = pipe(self.label + '_pipe feed_' + j) self.comps['return_' + j] = pipe(self.label + '_pipe return_' + j) for i in range(self.num_consumer): j = str(i) self.comps['splitter_' + j] = splitter(self.label + '_splitter_' + j) self.comps['merge_' + j] = merge(self.label + '_merge_' + j) self.comps['consumer_' + j] = heat_exchanger_simple(self.label + '_consumer_' + j) self.comps['valve_' + j] = valve(self.label + '_valve_' + j)
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 = heat_exchanger_simple('energy balance closing') closer = cycle_closer('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')
def pipe_return_definition(df_pipes_data): pb = {} for index, row in df_pipes_data.iterrows(): #pipe_name_back = "pipe" + str(row["ID"]) + "_back" ks = row["Roughness"] L = row["LENGTH"] D = row["Diameter"] kA = row["Ch"] pb[row['ID']] = pipe("pipe" + str(row["ID"]) + "_back", ks=ks, L=L, D=D, kA=kA) return pb
from tespy.connections import connection from tespy.components import source, sink, pipe from tespy.networks import network import numpy as np from matplotlib import pyplot as plt nw = network(['water'], p_unit='bar', T_unit='C', h_unit='kJ / kg') # %% components pi = pipe('pipe') si = sink('sink') so = source('source') # %% 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
# sources and sinks so = source('source') si = sink('sink') so1 = source('source1') si1 = sink('sink1') so2 = source('source2') si2 = sink('sink2') # %% construction part # pipe_feed pif1 = pipe('pipe1_feed', ks=7e-5, L=50, D=0.15, offdesign=['kA_char']) pif2 = pipe('pipe2_feed', ks=7e-5, L=200, D=0.15, offdesign=['kA_char']) pif4 = pipe('pipe4_feed', ks=7e-5, L=50, D=0.15, offdesign=['kA_char']) pif7 = pipe('pipe7_feed', ks=7e-5, L=175, D=0.15, offdesign=['kA_char']) pif8 = pipe('pipe8_feed', ks=7e-5, L=75, D=0.15, offdesign=['kA_char']) pif10 = pipe('pipe10_feed', ks=7e-5, L=450, D=0.1, offdesign=['kA_char']) pif11 = pipe('pipe11_feed', ks=7e-5, L=60, D=0.04, offdesign=['kA_char']) pif16 = pipe('pipe16_feed', ks=7e-5, L=30, D=0.065, offdesign=['kA_char']) pif17 = pipe('pipe17_feed', ks=7e-5, L=250, D=0.065, offdesign=['kA_char']) pif21 = pipe('pipe21_feed', ks=7e-5, L=30, D=0.04, offdesign=['kA_char']) # pipe_back