Skip to content

Commit

Permalink
Fix the tests to work with new default value for dissipative
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Oct 27, 2024
1 parent e30fede commit aab81cc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
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 aab81cc

Please sign in to comment.