From aab81cc121ab6c2ef5f4588a9aae5c5bc5e56686 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Sun, 27 Oct 2024 21:24:57 +0100 Subject: [PATCH] Fix the tests to work with new default value for dissipative --- tests/test_analyses/test_exergy_analysis.py | 40 +++++++++---------- tests/test_models/test_CGAM_model.py | 1 - .../test_solar_energy_generating_system.py | 2 +- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/tests/test_analyses/test_exergy_analysis.py b/tests/test_analyses/test_exergy_analysis.py index 54c27ee8e..b35c0957f 100644 --- a/tests/test_analyses/test_exergy_analysis.py +++ b/tests/test_analyses/test_exergy_analysis.py @@ -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}) @@ -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') @@ -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 @@ -399,7 +398,6 @@ def setup_method(self): """Set up air compressed air turbine.""" self.Tamb = 20 self.pamb = 1 - fluids = ['Air'] # turbine part self.nw = Network() @@ -407,7 +405,7 @@ def setup_method(self): # components cas = Source('compressed air storage') - reheater = SimpleHeatExchanger('reheating') + reheater = SimpleHeatExchanger('reheating', dissipative=False) turb = Turbine('turbine') amb = Sink('air outlet') @@ -489,7 +487,6 @@ class TestCompression: def setup_method(self): self.Tamb = 20 self.pamb = 1 - fluids = ['Air'] # turbine part self.nw = Network() @@ -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 @@ -568,7 +566,6 @@ class TestExpansion: def setup_method(self): self.Tamb = 20 self.pamb = 1 - fluids = ['Air'] # turbine part self.nw = Network() @@ -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 diff --git a/tests/test_models/test_CGAM_model.py b/tests/test_models/test_CGAM_model.py index 1857485ac..1a9da1efb 100644 --- a/tests/test_models/test_CGAM_model.py +++ b/tests/test_models/test_CGAM_model.py @@ -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 = { diff --git a/tests/test_models/test_solar_energy_generating_system.py b/tests/test_models/test_solar_energy_generating_system.py index 5dcfcacbf..53c053bbb 100644 --- a/tests/test_models/test_solar_energy_generating_system.py +++ b/tests/test_models/test_solar_energy_generating_system.py @@ -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)