Exemple #1
0
 def setup(self):
     self.nw = nwk.network(['water', 'air'])
     self.comp = cmp.cogeneration_unit('cogeneration unit')
     self.pipe = cmp.pipe('pipe')
     self.conn = con.connection(self.comp, 'out1', self.pipe, 'in1')
     self.bus = con.bus('mybus')
     self.sub = subsys.subsystem('MySub')
Exemple #2
0
def test_network_missing_data_in_individual_design_case_file():
    nw = nwk.network(['water'])
    source = cmp.source('source')
    pipe = cmp.pipe('pipe', Q=0, pr=0.95, design=['pr'], offdesign=['zeta'])
    sink = cmp.sink('sink')
    a = con.connection(source, 'out1', pipe, 'in1', m=1, p=1e5, T=293.15,
                       fluid={'water': 1})
    b = con.connection(pipe, 'out1', sink, 'in1', design_path='tmp2')
    nw.add_conns(a, b)
    nw.solve('design')
    nw.save('tmp')
    nw.save('tmp2')

    inputs = open('./tmp/conn.csv')
    all_lines = inputs.readlines()
    all_lines.pop(len(all_lines) - 1)
    inputs.close()

    with open('./tmp2/conn.csv', 'w') as out:
        for line in all_lines:
            out.write(line.strip() + '\n')
    try:
        nw.solve('offdesign', design_path='tmp')
    except hlp.TESPyNetworkError:
        pass

    shutil.rmtree('./tmp', ignore_errors=True)
    shutil.rmtree('./tmp2', ignore_errors=True)
    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')
        ]
Exemple #4
0
def test_network_max_iter():
    nw = nwk.network(['water'])
    source = cmp.source('source')
    pipe = cmp.pipe('pipe', pr=1, Q=100e3)
    sink = cmp.sink('sink')
    a = con.connection(source, 'out1', pipe, 'in1', m=1, p=1e5, T=280, fluid={'water': 1})
    b = con.connection(pipe, 'out1', sink, 'in1')
    nw.add_conns(a, b)
    nw.solve('design', max_iter=2)
    eq_(nw.max_iter, nw.iter + 1, 'This test must result in the itercount being equal to the max iter statement.')
Exemple #5
0
def test_network_no_progress():
    nw = nwk.network(['water'])
    source = cmp.source('source')
    pipe = cmp.pipe('pipe', pr=1, Q=-100e3)
    sink = cmp.sink('sink')
    a = con.connection(source, 'out1', pipe, 'in1', m=1, p=1e5, T=280, fluid={'water': 1})
    b = con.connection(pipe, 'out1', sink, 'in1')
    nw.add_conns(a, b)
    nw.solve('design')
    eq_(nw.progress, False, 'This test must result in a calculation making no progress, as the pipe\'s outlet enthalpy is below fluid property range.')
Exemple #6
0
from tespy import nwk, con, cmp, hlp
import numpy as np
from matplotlib import pyplot as plt

nw = nwk.network(['water'], p_unit='bar', T_unit='C', h_unit='kJ / kg')

# %% components
pipe = cmp.pipe('pipe')
pipe2 = cmp.pipe('pipe2')
pipe3 = cmp.pipe('pipe3')
pipe4 = cmp.pipe('pipe4')
pipe5 = cmp.pipe('pipe5')
pipe6 = cmp.pipe('pipe6')
sink = cmp.sink('sink')
source = cmp.source('source')

# %% connections

a = con.connection(source, 'out1', pipe, 'in1')
b = con.connection(pipe, 'out1', pipe2, 'in1')
c = con.connection(pipe2, 'out1', pipe3, 'in1')
d = con.connection(pipe3, 'out1', pipe4, 'in1')
e = con.connection(pipe4, 'out1', pipe5, 'in1')
f = con.connection(pipe5, 'out1', pipe6, 'in1')
g = con.connection(pipe6, 'out1', sink, 'in1')

nw.add_conns(a, b, c, d, e, f, g)

# %% connection parameters

a.set_attr(h=40, fluid={'water': 1}, p=1, m=10)
Exemple #7
0
# sources and sinks

so = cmp.source('source')
si = cmp.sink('sink')

so1 = cmp.source('source1')
si1 = cmp.sink('sink1')

so2 = cmp.source('source2')
si2 = cmp.sink('sink2')

# %% construction part

# pipe_feed

pif1 = cmp.pipe('pipe1_feed', ks=7e-5, L=50, D=0.15, offdesign=['kA'])
pif2 = cmp.pipe('pipe2_feed', ks=7e-5, L=200, D=0.15, offdesign=['kA'])

pif4 = cmp.pipe('pipe4_feed', ks=7e-5, L=50, D=0.15, offdesign=['kA'])
pif7 = cmp.pipe('pipe7_feed', ks=7e-5, L=175, D=0.15, offdesign=['kA'])

pif8 = cmp.pipe('pipe8_feed', ks=7e-5, L=75, D=0.15, offdesign=['kA'])
pif10 = cmp.pipe('pipe10_feed', ks=7e-5, L=450, D=0.1, offdesign=['kA'])

pif11 = cmp.pipe('pipe11_feed', ks=7e-5, L=60, D=0.04, offdesign=['kA'])
pif16 = cmp.pipe('pipe16_feed', ks=7e-5, L=30, D=0.065, offdesign=['kA'])

pif17 = cmp.pipe('pipe17_feed', ks=7e-5, L=250, D=0.065, offdesign=['kA'])
pif21 = cmp.pipe('pipe21_feed', ks=7e-5, L=30, D=0.04, offdesign=['kA'])

# pipe_back