Skip to content

Commit

Permalink
Merge branch 'feature/make-dissipative-mandatory-keyword-for-exergy-a…
Browse files Browse the repository at this point in the history
…nalysis' into dev
  • Loading branch information
fwitte committed Oct 27, 2024
2 parents 95d678b + 81c7dce commit b836623
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 26 deletions.
7 changes: 5 additions & 2 deletions docs/whats_new/v0-7-7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ Bug Fixes
available in the namespace via the :code:`@component_registry` decorator
(`PR #536 <https://github.com/oemof/tespy/pull/536>`__).
- Fixed a typo in the Jacobian of the hot side and cold side
:code:`HeatExchanger` effectiveness
(`PR #563 <https://github.com/oemof/tespy/pull/563>`__).
:code:`HeatExchanger` effectiveness.

Other Changes
#############
- Make the :code:`reset_topology_reduction_specifications` method of the
`Network` class a public method
(`PR #559 <https://github.com/oemof/tespy/pull/559>`__).
- Components of class :code:`SimpleHeatExchanger` need explicit specification
of the :code:`dissipative` attribute in the next major version of tespy in
context of the exergy analysis
(`PR #563 <https://github.com/oemof/tespy/pull/563>`__).

Documentation
#############
Expand Down
10 changes: 9 additions & 1 deletion src/tespy/components/heat_exchangers/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def get_parameters(self):
'ks_HW': dc_cp(val=10, min_val=1e-1, max_val=1e3, d=1e-2),
'kA': dc_cp(min_val=0, d=1),
'kA_char': dc_cc(param='m'), 'Tamb': dc_cp(),
'dissipative': dc_simple(val=True),
'dissipative': dc_simple(val=None),
'darcy_group': dc_gcp(
elements=['L', 'ks', 'D'], num_eq=1,
latex=self.darcy_func_doc,
Expand Down Expand Up @@ -1045,6 +1045,14 @@ def exergy_balance(self, T0):
\dot{E}_\mathrm{F} & \dot{Q} > 0\\
\end{cases}
"""
if self.dissipative.val is None:
self.dissipative.val = True
msg = (
"In a future version of TESPy, the dissipative property must "
"explicitly be set to True or False in the context of the "
f"exergy analysis for component {self.label}."
)
logger.warning(msg)
if self.Q.val < 0:
if self.inl[0].T.val_SI >= T0 and self.outl[0].T.val_SI >= T0:
if self.dissipative.val:
Expand Down
40 changes: 19 additions & 21 deletions tests/test_analyses/test_exergy_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def setup_method(self):
# component parameters
turb.set_attr(eta_s=1)
fwp_turb.set_attr(eta_s=1)
condenser.set_attr(pr=1)
condenser.set_attr(pr=1, dissipative=True)
fwp.set_attr(eta_s=1)
steam_generator.set_attr(pr=1)
steam_generator.set_attr(pr=1, dissipative=False)

# connection parameters
fs_in.set_attr(m=10, p=120, T=600, fluid={'water': 1})
Expand Down Expand Up @@ -274,14 +274,13 @@ def setup_method(self):
"""Set up simple refrigerator."""
self.Tamb = 20
self.pamb = 1
fluids = ['R134a']
self.nw = Network()
self.nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg')

# create components
va = Valve('expansion valve')
cp = Compressor('compressor')
cond = SimpleHeatExchanger('condenser')
cond = SimpleHeatExchanger('condenser', dissipative=True)
eva = SimpleHeatExchanger('evaporator', dissipative=False)
cc = CycleCloser('cycle closer')

Expand Down Expand Up @@ -349,7 +348,7 @@ def setup_method(self):
# components
amb = Source('air intake')
cp = Compressor('compressor')
cooler = SimpleHeatExchanger('cooling')
cooler = SimpleHeatExchanger('cooling', dissipative=True)
cas = Sink('compressed air storage')

# power input bus
Expand Down Expand Up @@ -399,15 +398,14 @@ def setup_method(self):
"""Set up air compressed air turbine."""
self.Tamb = 20
self.pamb = 1
fluids = ['Air']

# turbine part
self.nw = Network()
self.nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg')

# components
cas = Source('compressed air storage')
reheater = SimpleHeatExchanger('reheating')
reheater = SimpleHeatExchanger('reheating', dissipative=False)
turb = Turbine('turbine')
amb = Sink('air outlet')

Expand Down Expand Up @@ -489,7 +487,6 @@ class TestCompression:
def setup_method(self):
self.Tamb = 20
self.pamb = 1
fluids = ['Air']

# turbine part
self.nw = Network()
Expand Down Expand Up @@ -548,18 +545,19 @@ def run_analysis(self):
ean.network_data.E_F - ean.network_data.E_P -
ean.network_data.E_L - ean.network_data.E_D)
msg = (
'Exergy balance must be closed (residual value smaller than ' +
str(ERR ** 0.5) + ') for this test but is ' +
str(round(abs(exergy_balance), 4)) + '.')
'Exergy balance must be closed (residual value smaller than '
f'{ERR ** 0.5}) for this test but is '
f'{round(abs(exergy_balance), 4)}.'
)
assert abs(exergy_balance) <= ERR ** 0.5, msg

E_D_agg = ean.aggregation_data['E_D'].sum()
E_D_nw = ean.network_data.loc['E_D']
msg = (
'The exergy destruction of the aggregated components and '
'respective busses (' + str(round(E_D_agg)) + ') must be equal to '
'the exergy destruction of the network (' + str(round(E_D_nw)) +
').')
f'respective busses ({round(E_D_agg)}) must be equal to the exergy '
f'destruction of the network ({round(E_D_nw)}).'
)
assert E_D_agg == E_D_nw, msg


Expand All @@ -568,7 +566,6 @@ class TestExpansion:
def setup_method(self):
self.Tamb = 20
self.pamb = 1
fluids = ['Air']

# turbine part
self.nw = Network()
Expand Down Expand Up @@ -628,16 +625,17 @@ def run_analysis(self):
ean.network_data.E_F - ean.network_data.E_P -
ean.network_data.E_L - ean.network_data.E_D)
msg = (
'Exergy balance must be closed (residual value smaller than ' +
str(ERR ** 0.5) + ') for this test but is ' +
str(round(abs(exergy_balance), 4)) + '.')
'Exergy balance must be closed (residual value smaller than '
f'{ERR ** 0.5}) for this test but is '
f'{round(abs(exergy_balance), 4)}.'
)
assert abs(exergy_balance) <= ERR ** 0.5, msg

E_D_agg = ean.aggregation_data['E_D'].sum()
E_D_nw = ean.network_data.loc['E_D']
msg = (
'The exergy destruction of the aggregated components and '
'respective busses (' + str(round(E_D_agg)) + ') must be equal to '
'the exergy destruction of the network (' + str(round(E_D_nw)) +
').')
f'respective busses ({round(E_D_agg)}) must be equal to the exergy '
f'destruction of the network ({round(E_D_nw)}).'
)
assert E_D_agg == E_D_nw, msg
1 change: 0 additions & 1 deletion tests/test_models/test_CGAM_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
class TestCGAM:

def setup_method(self):
fluid_list = ['O2', 'H2O', 'N2', 'CO2', 'CH4']
self.nwk = Network(p_unit='bar', T_unit='C')

air_molar = {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models/test_solar_energy_generating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def setup_method(self):
pt.set_attr(doc=0.95, aoi=0,
Tamb=25, A='var', eta_opt=0.73,
c_1=0.00496, c_2=0.000691, E=1000,
iam_1=1, iam_2=1)
iam_1=1, iam_2=1, dissipative=False)

ptpump.set_attr(eta_s=0.6)

Expand Down

0 comments on commit b836623

Please sign in to comment.