Skip to content

Commit

Permalink
merged entropy analysis branch
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Jun 26, 2018
2 parents e3409bf + b0aed98 commit e0839ab
Showing 1 changed file with 48 additions and 43 deletions.
91 changes: 48 additions & 43 deletions tespy/components/components.py
Expand Up @@ -805,11 +805,11 @@ class turbomachine(component):
- out1
"""
def attr(self):
return ['P', 'eta_s', 'pr', 'eta_s_char']
return ['P', 'eta_s', 'pr', 'eta_s_char', 'Sirr']

def attr_prop(self):
return {'P': dc_cp(), 'eta_s': dc_cp(), 'pr': dc_cp(),
'eta_s_char': dc_cc()}
'eta_s_char': dc_cc(), 'Sirr': dc_cp()}

def default_design(self):
return ['pr', 'eta_s']
Expand Down Expand Up @@ -1048,29 +1048,26 @@ def calc_parameters(self, nw, mode):
self.pr.val = outl[0].p.val_SI / inl[0].p.val_SI

if mode == 'pre':

self.i0 = inl[0].to_flow()
self.o0 = outl[0].to_flow()
self.i0[3] = self.i0[3].copy()
self.o0[3] = self.i0[3].copy()
self.dh_s0 = (self.h_os(self.i0, self.o0) - self.i0[2])

if mode == 'post':
self.Sirr.val = inl[0].m.val_SI * (s_mix_ph(outl[0].to_flow()) -
s_mix_ph(inl[0].to_flow()))

def print_parameters(self, nw):

inl, outl = (nw.comps.loc[self].i.tolist(),
nw.comps.loc[self].o.tolist())
i1 = inl[0].to_flow()
o1 = outl[0].to_flow()
print('##### ', self.label, ' #####')
if self.eta_s.val > 1:
print('!!!!! Error in parametrisation of the model, '
'eta_s higher than 1 !!!!!')
print('P = ', self.P.val, 'W; '
'eta_s = ', self.eta_s.val, '; '
'pr = ', self.pr.val, '; '
'm = ', inl[0].m.val_SI, 'kg / s; '
'Sirr = ', inl[0].m.val_SI *
(s_mix_ph(o1) - s_mix_ph(i1)), 'W / K')
'Sirr = ', self.Sirr.val, '; ')

# %%

Expand Down Expand Up @@ -1519,10 +1516,11 @@ def component(self):
return 'compressor'

def attr(self):
return ['P', 'eta_s', 'pr', 'vigv', 'char_map']
return ['P', 'eta_s', 'pr', 'vigv', 'char_map', 'Sirr']

def attr_prop(self):
return {'P': dc_cp(), 'eta_s': dc_cp(), 'pr': dc_cp(), 'vigv': dc_cp(),
'Sirr': dc_cp(),
'char_map': dc_cc(func=cmp_char.compressor())}

def default_offdesign(self):
Expand Down Expand Up @@ -1967,10 +1965,11 @@ def component(self):
return 'turbine'

def attr(self):
return ['P', 'eta_s', 'pr', 'eta_s_char', 'cone']
return ['P', 'eta_s', 'pr', 'eta_s_char', 'cone', 'Sirr']

def attr_prop(self):
return {'P': dc_cp(), 'eta_s': dc_cp(), 'pr': dc_cp(),
'Sirr': dc_cp(),
'eta_s_char': dc_cc(method='TRAUPEL', param='dh_s'),
'cone': dc_cc(method='default')}

Expand Down Expand Up @@ -3497,8 +3496,8 @@ def calc_parameters(self, nw, mode):

if mode == 'pre':
if 'lamb' in self.offdesign:
self.lamb.val = n_oxygen / (
n_fuel * (self.n['C'] + self.n['H'] / 4))
self.lamb.val = n_oxygen / (n_fuel *
(self.n['C'] + self.n['H'] / 4))

def print_parameters(self, nw):

Expand Down Expand Up @@ -4370,6 +4369,8 @@ def calc_parameters(self, nw, mode):
(8 * inl[0].m.val_SI ** 2 *
(v_mix_ph(inl[0].to_flow()) +
v_mix_ph(outl[0].to_flow())) / 2))
self.Sirr.val = inl[0].m.val_SI * (s_mix_ph(outl[0].to_flow()) -
s_mix_ph(inl[0].to_flow()))

if mode == 'pre':
if 'pr' in self.offdesign:
Expand All @@ -4383,16 +4384,10 @@ def calc_parameters(self, nw, mode):

def print_parameters(self, nw):

inl, outl = (nw.comps.loc[self].i.tolist(),
nw.comps.loc[self].o.tolist())

print('##### ', self.label, ' #####')
print('pr = ', self.pr.val, '; '
'zeta = ', self.zeta.val, 'kg / m^4 * s ; '
'm = ', inl[0].m.val_SI, 'kg / s ; '
'Sirr = ', inl[0].m.val_SI * (s_mix_ph(outl[0].to_flow()) -
s_mix_ph(inl[0].to_flow())),
'W / K')
'Sirr = ', self.Sirr.val, 'W / K')

# %%

Expand Down Expand Up @@ -4465,13 +4460,15 @@ def comp_init(self, nw):

def attr(self):
return ['Q', 'pr', 'zeta', 'D', 'L', 'ks',
'kA', 't_a', 't_a_design', 'kA_char']
'kA', 't_a', 't_a_design', 'kA_char',
'SQ1', 'SQ2', 'Sirr']

def attr_prop(self):
return {'Q': dc_cp(), 'pr': dc_cp(), 'zeta': dc_cp(),
'D': dc_cp(), 'L': dc_cp(), 'ks': dc_cp(),
'kA': dc_cp(), 't_a': dc_cp(), 't_a_design': dc_cp(),
'kA_char': dc_cc(method='HE_HOT', param='m')}
'kA_char': dc_cc(method='HE_HOT', param='m'),
'SQ1': dc_cp(), 'SQ2': dc_cp(), 'Sirr': dc_cp()}

def default_design(self):
return ['pr']
Expand Down Expand Up @@ -4774,6 +4771,10 @@ def calc_parameters(self, nw, mode):
inl, outl = (nw.comps.loc[self].i.tolist(),
nw.comps.loc[self].o.tolist())

if mode == 'post':
self.SQ1.val = inl[0].m.val_SI * (s_mix_ph(outl[0].to_flow()) -
s_mix_ph(inl[0].to_flow()))

if mode == 'pre':

self.i0 = inl[0].to_flow()
Expand Down Expand Up @@ -4819,6 +4820,11 @@ def calc_parameters(self, nw, mode):
print(msg)
nw.errors += [self]

if mode == 'post':
self.SQ2.val = - inl[0].m.val_SI * (
outl[0].h.val_SI - inl[0].h.val_SI) / t_a
self.Sirr.val = self.SQ1.val + self.Q2.val

self.kA.val = inl[0].m.val_SI * (
outl[0].h.val_SI - inl[0].h.val_SI) / (
(ttd_u - ttd_l) / math.log(ttd_l / ttd_u))
Expand Down Expand Up @@ -4847,17 +4853,13 @@ def calc_parameters(self, nw, mode):

def print_parameters(self, nw):

inl, outl = (nw.comps.loc[self].i.tolist(),
nw.comps.loc[self].o.tolist())

print('##### ', self.label, ' #####')
print('Q = ', self.Q.val, 'W; '
'pr = ', self.pr.val, '; '
'zeta = ', self.zeta.val, 'kg / m^4 * s; '
'm = ', inl[0].m.val_SI, 'kg / s; '
'Sq = ', inl[0].m.val_SI * (s_mix_ph(outl[0].to_flow()) -
s_mix_ph(inl[0].to_flow())),
'W / K; ')
'SQ1 = ', self.SQ1.val, 'W / K; '
'SQ2 = ', self.SQ2.val, 'W / K; '
'Sirr = ', self.Sirr.val, 'W / K; ')
if self.t_a.is_set or self.t_a_design.is_set:
print('kA = ', self.kA.val, 'W / (m^2 * K)')

Expand Down Expand Up @@ -4985,15 +4987,17 @@ def comp_init(self, nw):
def attr(self):
return ['Q', 'kA', 'td_log', 'kA_char1', 'kA_char2',
'ttd_u', 'ttd_l',
'pr1', 'pr2', 'zeta1', 'zeta2']
'pr1', 'pr2', 'zeta1', 'zeta2',
'SQ1', 'SQ2', 'Sirr']

def attr_prop(self):
return {'Q': dc_cp(), 'kA': dc_cp(), 'td_log': dc_cp(),
'kA_char1': dc_cc(method='HE_HOT', param='m'),
'kA_char2': dc_cc(method='HE_COLD', param='m'),
'ttd_u': dc_cp(), 'ttd_l': dc_cp(),
'pr1': dc_cp(), 'pr2': dc_cp(),
'zeta1': dc_cp(), 'zeta2': dc_cp()}
'zeta1': dc_cp(), 'zeta2': dc_cp(),
'SQ1': dc_cp(), 'SQ2': dc_cp(), 'Sirr': dc_cp()}
# derivatives for logarithmic temperature difference not implemented
# return (component.attr(self) +
# ['Q', 'kA', 'td_log', 'ttd_u', 'ttd_l',
Expand Down Expand Up @@ -5644,6 +5648,13 @@ def calc_parameters(self, nw, mode):
(v_mix_ph(inl[1].to_flow()) +
v_mix_ph(outl[1].to_flow())) / 2))

if mode == 'post':
self.SQ1.val = inl[0].m.val_SI * (s_mix_ph(outl[0].to_flow()) -
s_mix_ph(inl[0].to_flow()))
self.SQ2.val = inl[1].m.val_SI * (s_mix_ph(outl[1].to_flow()) -
s_mix_ph(inl[1].to_flow()))
self.Sirr.val = self.SQ1.val + self.SQ2.val

# improve this part (for heat exchangers only atm)
if self.kA.is_set:
expr = inl[0].m.val_SI / self.i10[0]
Expand All @@ -5664,9 +5675,6 @@ def calc_parameters(self, nw, mode):

def print_parameters(self, nw):

inl, outl = (nw.comps.loc[self].i.tolist(),
nw.comps.loc[self].o.tolist())

print('##### ', self.label, ' #####')
if self.ttd_u.val < 0 and self.kA.is_set:
print('!!!!! ERROR calculating heat exchanger: !!!!!\n'
Expand All @@ -5681,13 +5689,9 @@ def print_parameters(self, nw):
'pr2 = ', self.pr2.val, '; '
'zeta1 = ', self.zeta1.val, '; '
'zeta2 = ', self.zeta2.val, '; '
'm1 = ', inl[0].m.val_SI, 'kg / s; '
'm2 = ', inl[1].m.val_SI, 'kg / s; '
'Sirr = ', inl[1].m.val_SI * (s_mix_ph(outl[1].to_flow()) -
s_mix_ph(inl[1].to_flow())) +
inl[0].m.val_SI * (s_mix_ph(outl[0].to_flow()) -
s_mix_ph(inl[0].to_flow())), 'W / K'
)
'SQ1 = ', self.SQ1.val, 'W / K; '
'SQ2 = ', self.SQ2.val, 'W / K; '
'Sirr = ', self.Sirr.val, 'W / K; ')

# %%

Expand Down Expand Up @@ -5753,7 +5757,8 @@ def attr_prop(self):
'kA_char2': dc_cc(method='COND_COLD', param='m'),
'ttd_u': dc_cp(), 'ttd_l': dc_cp(),
'pr1': dc_cp(), 'pr2': dc_cp(),
'zeta1': dc_cp(), 'zeta2': dc_cp()}
'zeta1': dc_cp(), 'zeta2': dc_cp(),
'SQ1': dc_cp(), 'SQ2': dc_cp(), 'Sirr': dc_cp()}

def default_design(self):
return [n for n in heat_exchanger.default_design(self) if n != 'pr1']
Expand Down

0 comments on commit e0839ab

Please sign in to comment.