From 37b261767dd3da9932b19e8a7c5ead7f8cc3fb6b Mon Sep 17 00:00:00 2001 From: tblanke <86232208+tblanke@users.noreply.github.com> Date: Fri, 6 Oct 2023 13:15:47 +0200 Subject: [PATCH] Update gui_structure.py --- GHEtool/gui/gui_structure.py | 1128 +++++++++++++++++++--------------- 1 file changed, 631 insertions(+), 497 deletions(-) diff --git a/GHEtool/gui/gui_structure.py b/GHEtool/gui/gui_structure.py index be6bb2b6..67321210 100644 --- a/GHEtool/gui/gui_structure.py +++ b/GHEtool/gui/gui_structure.py @@ -48,8 +48,9 @@ from GHEtool.gui.gui_classes.translation_class import Translations -def load_data_GUI(filename: str, thermal_demand: int, heating_load_column: str, cooling_load_column: str, combined: str, sep: str, - dec: str, fac: float, hourly: bool = False): +def load_data_GUI( + filename: str, thermal_demand: int, heating_load_column: str, cooling_load_column: str, combined: str, sep: str, dec: str, fac: float, hourly: bool = False +): """ This function loads hourly thermal data from a given file. This data can have one or two columns, can be in W, kW or MW. @@ -92,8 +93,8 @@ def load_data_GUI(filename: str, thermal_demand: int, heating_load_column: str, raise FileNotFoundError if heating_load_column == cooling_load_column: - logging.error('Please select different values for the heating and cooling column.') - raise ValueError('Please select different values for the heating and cooling column.') + logging.error("Please select different values for the heating and cooling column.") + raise ValueError("Please select different values for the heating and cooling column.") # Generate list of columns that have to be imported cols: list = [] @@ -107,9 +108,9 @@ def load_data_GUI(filename: str, thermal_demand: int, heating_load_column: str, try: df2: pd_DataFrame = pd_read_csv(filename, usecols=cols, sep=sep, decimal=dec) except FileNotFoundError: - raise FileNotFoundError('The file for the hourly load cannot be found.') + raise FileNotFoundError("The file for the hourly load cannot be found.") except ValueError: - raise ValueError('Please select the correct seperator for the hourly load.') + raise ValueError("Please select the correct seperator for the hourly load.") # not the correct decimal seperator if isinstance(df2.iloc[0, 0], str): @@ -162,8 +163,7 @@ def load_data_GUI(filename: str, thermal_demand: int, heating_load_column: str, return np.array(df2["peak Heating"]), np.array(df2["peak Cooling"]) # resample to a monthly resolution as sum and maximal load - df3: pd_DataFrame = df2.resample("M").agg( - {"Heating Load": "sum", "Cooling Load": "sum", "peak Heating": "max", "peak Cooling": "max"}) + df3: pd_DataFrame = df2.resample("M").agg({"Heating Load": "sum", "Cooling Load": "sum", "peak Heating": "max", "peak Cooling": "max"}) # replace nan with 0 df3 = df3.fillna(0) @@ -228,31 +228,24 @@ def _page_options(self, translations): self.category_calculation = Category(page=self.page_options, label=translations.category_calculation) - self.option_method_size_depth = ButtonBox(label=translations.option_method_size_depth, default_index=0, - entries=[" L2 ", " L3 ", " L4 "], - category=self.category_calculation) - self.option_method_rb_calc = ButtonBox(label=translations.option_method_rb_calc, default_index=1, - entries=[" constant ", " dynamic "], - category=self.category_calculation) + self.option_method_size_depth = ButtonBox( + label=translations.option_method_size_depth, default_index=0, entries=[" L2 ", " L3 ", " L4 "], category=self.category_calculation + ) + self.option_method_rb_calc = ButtonBox( + label=translations.option_method_rb_calc, default_index=1, entries=[" constant ", " dynamic "], category=self.category_calculation + ) self.option_temperature_profile_hourly = ButtonBox( - label=translations.option_temperature_profile_hourly, default_index=0, - entries=[" no ", " yes "], category=self.category_calculation) + label=translations.option_temperature_profile_hourly, default_index=0, entries=[" no ", " yes "], category=self.category_calculation + ) self.category_advanced_options = Category(page=self.page_options, label=translations.category_advanced_options) - self.option_atol = FloatBox(translations.option_atol, 0.05, self.category_advanced_options, - decimal_number=2, - minimal_value=0.01, - maximal_value=100, - step=0.05) - self.option_rtol = FloatBox(translations.option_rtol, 0.5, self.category_advanced_options, - decimal_number=1, - minimal_value=0.1, - maximal_value=100, - step=1) - self.option_max_nb_of_iter = IntBox(translations.option_max_nb_of_iter, 40, self.category_advanced_options, - minimal_value=1, - maximal_value=100, - step=1) + self.option_atol = FloatBox( + translations.option_atol, 0.05, self.category_advanced_options, decimal_number=2, minimal_value=0.01, maximal_value=100, step=0.05 + ) + self.option_rtol = FloatBox( + translations.option_rtol, 0.5, self.category_advanced_options, decimal_number=1, minimal_value=0.1, maximal_value=100, step=1 + ) + self.option_max_nb_of_iter = IntBox(translations.option_max_nb_of_iter, 40, self.category_advanced_options, minimal_value=1, maximal_value=100, step=1) def _page_borefield(self, translations): # create page @@ -300,20 +293,29 @@ def _page_borefield(self, translations): step=0.1, ) self.option_spacing_length.change_event(self.update_borefield) - self.option_borefield_radius = els.FloatBox(category=self.category_borefield, label=translations.option_borefield_radius, - minimal_value=0, maximal_value=1_000_000, default_value=12.5, step=0.1, decimal_number=2) + self.option_borefield_radius = els.FloatBox( + category=self.category_borefield, + label=translations.option_borefield_radius, + minimal_value=0, + maximal_value=1_000_000, + default_value=12.5, + step=0.1, + decimal_number=2, + ) self.option_borefield_radius.change_event(self.update_borefield) - self.option_number_circle_boreholes = els.IntBox(category=self.category_borefield, label=translations.option_number_circle_boreholes, - minimal_value=2, maximal_value=1_000_000, default_value=12, step=1) - self.option_number_circle_boreholes.change_event(self.update_borefield) - self.option_width = IntBox( - category=self.category_borefield, label=translations.option_width, default_value=9, minimal_value=1, maximal_value=40 + self.option_number_circle_boreholes = els.IntBox( + category=self.category_borefield, + label=translations.option_number_circle_boreholes, + minimal_value=2, + maximal_value=1_000_000, + default_value=12, + step=1, ) + self.option_number_circle_boreholes.change_event(self.update_borefield) + self.option_width = IntBox(category=self.category_borefield, label=translations.option_width, default_value=9, minimal_value=1, maximal_value=40) self.option_width.change_event(self.update_borefield) - self.option_length = IntBox( - category=self.category_borefield, label=translations.option_length, default_value=12, minimal_value=1, maximal_value=40 - ) + self.option_length = IntBox(category=self.category_borefield, label=translations.option_length, default_value=12, minimal_value=1, maximal_value=40) self.option_length.change_event(self.update_borefield) self.option_pipe_depth = FloatBox( @@ -347,102 +349,199 @@ def _page_borefield(self, translations): ) self.option_tilted.hide() - self.option_seperator_borefield = ButtonBox(label=translations.option_seperator_borefield, default_index=0, - entries=['Semicolon ";"', 'Comma ","', 'Tab " "'], - category=self.category_borefield) - self.option_decimal_borefield = ButtonBox(label=translations.option_decimal_borefield, default_index=0, - entries=['Point "."', 'Comma ","'], - category=self.category_borefield) + self.option_seperator_borefield = ButtonBox( + label=translations.option_seperator_borefield, + default_index=0, + entries=['Semicolon ";"', 'Comma ","', 'Tab " "'], + category=self.category_borefield, + ) + self.option_decimal_borefield = ButtonBox( + label=translations.option_decimal_borefield, default_index=0, entries=['Point "."', 'Comma ","'], category=self.category_borefield + ) file = f"{FOLDER.joinpath('gui/test_gui/borefield_data.csv')}" - self.borefield_file = els.FileNameBox(label=translations.borefield_file, category=self.category_borefield, default_value=file, - file_extension=["csv", "txt"]) + self.borefield_file = els.FileNameBox( + label=translations.borefield_file, category=self.category_borefield, default_value=file, file_extension=["csv", "txt"] + ) self.import_borefield = els.FunctionButton(button_text=translations.import_borefield, icon="Download", category=self.category_borefield) self.import_borefield.change_event(self.fun_import_borefield) - self.custom_borefield = els.FlexibleAmount(label=translations.custom_borefield, default_length=1, entry_mame="Borehole", - category=self.category_borefield, - min_length=1) + self.custom_borefield = els.FlexibleAmount( + label=translations.custom_borefield, default_length=1, entry_mame="Borehole", category=self.category_borefield, min_length=1 + ) self.custom_borefield.add_option(els.FloatBox, name="x [m]", default_value=0, minimal_value=-1_000_000, maximal_value=1_000_000, decimal_number=2) self.custom_borefield.add_option(els.FloatBox, name="y [m]", default_value=0, minimal_value=-1_000_000, maximal_value=1_000_000, decimal_number=2) self.custom_borefield.add_option(els.FloatBox, name="depth [m]", default_value=100, minimal_value=0, maximal_value=1_000_000) self.custom_borefield.add_option(els.FloatBox, name="buried depth [m]", default_value=2, minimal_value=0, maximal_value=1_000_000, decimal_number=2) - self.custom_borefield.add_option(els.FloatBox, name="Borehole radius [m]", default_value=0.075, minimal_value=0, maximal_value=1_000, - decimal_number=4, step=0.01) + self.custom_borefield.add_option( + els.FloatBox, name="Borehole radius [m]", default_value=0.075, minimal_value=0, maximal_value=1_000, decimal_number=4, step=0.01 + ) self.custom_borefield.change_event(self.update_borefield) # add dependencies - li_aim = [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth, self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped, - self.aim_circle, self.aim_custom] - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile], - [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped, self.aim_circle], - self.option_depth)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], - self.option_spacing_width)) for aim in li_aim] - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], - self.option_spacing_length)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], - self.option_width)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], - self.option_length)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped, self.aim_circle], - self.option_pipe_depth)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped, self.aim_circle], - self.option_pipe_borehole_radius)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_circle], - self.option_number_circle_boreholes)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_circle], - self.option_borefield_radius)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_custom], - self.custom_borefield)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_custom], - self.import_borefield)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_custom], - self.borefield_file)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_custom], - self.option_seperator_borefield)) for aim in li_aim] - - _ = [aim.change_event(partial(show_option_on_multiple_aims, - [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], - [self.aim_custom], - self.option_decimal_borefield)) for aim in li_aim] + li_aim = [ + self.aim_optimize, + self.aim_temp_profile, + self.aim_req_depth, + self.aim_rect, + self.aim_Box_shaped, + self.aim_L_shaped, + self.aim_U_shaped, + self.aim_circle, + self.aim_custom, + ] + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile], + [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped, self.aim_circle], + self.option_depth, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], + self.option_spacing_width, + ) + ) + for aim in li_aim + ] + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], + self.option_spacing_length, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], + self.option_width, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped], + self.option_length, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped, self.aim_circle], + self.option_pipe_depth, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_rect, self.aim_Box_shaped, self.aim_L_shaped, self.aim_U_shaped, self.aim_circle], + self.option_pipe_borehole_radius, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_circle], + self.option_number_circle_boreholes, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_circle], + self.option_borefield_radius, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial(show_option_on_multiple_aims, [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], [self.aim_custom], self.custom_borefield) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial(show_option_on_multiple_aims, [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], [self.aim_custom], self.import_borefield) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial(show_option_on_multiple_aims, [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], [self.aim_custom], self.borefield_file) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_custom], + self.option_seperator_borefield, + ) + ) + for aim in li_aim + ] + + _ = [ + aim.change_event( + partial( + show_option_on_multiple_aims, + [self.aim_optimize, self.aim_temp_profile, self.aim_req_depth], + [self.aim_custom], + self.option_decimal_borefield, + ) + ) + for aim in li_aim + ] [aim.change_event(self.update_borefield) for aim in li_aim] @@ -476,27 +575,24 @@ def _page_earth(self, translations): step=100, ) - self.option_source_ground_temperature = ButtonBox(category=self.category_earth, - label=translations.option_source_ground_temperature, - default_index=1, - entries=['Measured', 'Database', 'Custom']) - self.option_flux_gradient = ButtonBox(category=self.category_earth, - label=translations.option_flux_gradient, - default_index=0, - entries=['Flux', 'Gradient']) + self.option_source_ground_temperature = ButtonBox( + category=self.category_earth, label=translations.option_source_ground_temperature, default_index=1, entries=["Measured", "Database", "Custom"] + ) + self.option_flux_gradient = ButtonBox( + category=self.category_earth, label=translations.option_flux_gradient, default_index=0, entries=["Flux", "Gradient"] + ) - self.option_ground_database = ListBox(category=self.category_earth, - label=translations.option_ground_database, - default_index=0, - entries=LIST_OF_COUNTRY_NAMES) + self.option_ground_database = ListBox( + category=self.category_earth, label=translations.option_ground_database, default_index=0, entries=LIST_OF_COUNTRY_NAMES + ) self.option_ground_database.change_event(self._update_selected_ground_temperature_from_database) - self.hint_ground_database = ResultText(translations.hint_ground_database, - category=self.category_earth, - prefix="The ground temperature at the selected location is: ", suffix="°C") - self.hint_ground_flux_database = ResultText(translations.hint_ground_flux_database, - category=self.category_earth, - prefix="The geothermal heat flux at the selected location is: ", suffix="W/m²") + self.hint_ground_database = ResultText( + translations.hint_ground_database, category=self.category_earth, prefix="The ground temperature at the selected location is: ", suffix="°C" + ) + self.hint_ground_flux_database = ResultText( + translations.hint_ground_flux_database, category=self.category_earth, prefix="The geothermal heat flux at the selected location is: ", suffix="W/m²" + ) # constant ground temperature self.option_ground_temp = FloatBox( category=self.category_earth, @@ -563,14 +659,22 @@ def _page_earth(self, translations): ) self.option_len_peak_heating = FloatBox( - category=self.category_temperatures, label=translations.option_len_peak_heating, - default_value=6, minimal_value=1, maximal_value=8760, step=1, - decimal_number=2 + category=self.category_temperatures, + label=translations.option_len_peak_heating, + default_value=6, + minimal_value=1, + maximal_value=8760, + step=1, + decimal_number=2, ) self.option_len_peak_cooling = FloatBox( - category=self.category_temperatures, label=translations.option_len_peak_cooling, - default_value=6, minimal_value=1, maximal_value=8760, step=1, - decimal_number=2 + category=self.category_temperatures, + label=translations.option_len_peak_cooling, + default_value=6, + minimal_value=1, + maximal_value=8760, + step=1, + decimal_number=2, ) def _page_borehole_resistance(self, translations): @@ -593,16 +697,11 @@ def _page_borehole_resistance(self, translations): self.category_fluid_data = Category(page=self.page_borehole_resistance, label=translations.category_fluid_data) self.option_fluid_selector = ButtonBox( - category=self.category_fluid_data, - label=translations.option_fluid_selector, - default_index=0, - entries=['Custom', 'Glycol mixture']) + category=self.category_fluid_data, label=translations.option_fluid_selector, default_index=0, entries=["Custom", "Glycol mixture"] + ) self.option_glycol_selector = ButtonBox( - category=self.category_fluid_data, - label=translations.option_glycol_selector, - default_index=0, - entries=['Ethylene glycol', 'Propylene glycol'] + category=self.category_fluid_data, label=translations.option_glycol_selector, default_index=0, entries=["Ethylene glycol", "Propylene glycol"] ) self.option_glycol_percentage = FloatBox( category=self.category_fluid_data, @@ -610,15 +709,10 @@ def _page_borehole_resistance(self, translations): decimal_number=0, default_value=20, maximal_value=100, - minimal_value=0 + minimal_value=0, ) self.option_fluid_ref_temp = FloatBox( - category=self.category_fluid_data, - label=translations.option_fluid_ref_temp, - decimal_number=1, - default_value=10, - maximal_value=100, - minimal_value=0 + category=self.category_fluid_data, label=translations.option_fluid_ref_temp, decimal_number=1, default_value=10, maximal_value=100, minimal_value=0 ) self.option_fluid_conductivity = FloatBox( @@ -684,10 +778,7 @@ def _page_borehole_resistance(self, translations): self.category_pipe_data.activate_graphic_left() self.option_U_pipe_or_coaxial_pipe = ButtonBox( - category=self.category_pipe_data, - label=translations.option_U_pipe_or_coaxial_pipe, - default_index=0, - entries=['U-pipe', 'Coaxial pipe'] + category=self.category_pipe_data, label=translations.option_U_pipe_or_coaxial_pipe, default_index=0, entries=["U-pipe", "Coaxial pipe"] ) self.option_pipe_number = IntBox( category=self.category_pipe_data, label=translations.option_pipe_number, default_value=2, minimal_value=1, maximal_value=99 @@ -750,10 +841,12 @@ def _page_borehole_resistance(self, translations): maximal_value=10000, step=0.001, ) - self.option_pipe_coaxial_inner_outer.change_event(lambda: self.option_pipe_coaxial_inner_inner.widget.setMaximum( - self.option_pipe_coaxial_inner_outer.get_value())) - self.option_pipe_coaxial_inner_inner.change_event(lambda: self.option_pipe_coaxial_inner_outer.widget.setMinimum( - self.option_pipe_coaxial_inner_inner.get_value())) + self.option_pipe_coaxial_inner_outer.change_event( + lambda: self.option_pipe_coaxial_inner_inner.widget.setMaximum(self.option_pipe_coaxial_inner_outer.get_value()) + ) + self.option_pipe_coaxial_inner_inner.change_event( + lambda: self.option_pipe_coaxial_inner_outer.widget.setMinimum(self.option_pipe_coaxial_inner_inner.get_value()) + ) self.option_pipe_coaxial_outer_inner = FloatBox( category=self.category_pipe_data, label=translations.option_pipe_coaxial_outer_inner, @@ -772,14 +865,18 @@ def _page_borehole_resistance(self, translations): maximal_value=10000, step=0.001, ) - self.option_pipe_coaxial_inner_outer.change_event(lambda: self.option_pipe_coaxial_outer_inner.widget.setMinimum( - self.option_pipe_coaxial_inner_outer.get_value())) + self.option_pipe_coaxial_inner_outer.change_event( + lambda: self.option_pipe_coaxial_outer_inner.widget.setMinimum(self.option_pipe_coaxial_inner_outer.get_value()) + ) self.option_pipe_coaxial_outer_inner.change_event( - lambda: self.option_pipe_coaxial_inner_outer.widget.setMaximum(self.option_pipe_coaxial_outer_inner.get_value())) + lambda: self.option_pipe_coaxial_inner_outer.widget.setMaximum(self.option_pipe_coaxial_outer_inner.get_value()) + ) self.option_pipe_coaxial_outer_outer.change_event( - lambda: self.option_pipe_coaxial_outer_inner.widget.setMaximum(self.option_pipe_coaxial_outer_outer.get_value())) + lambda: self.option_pipe_coaxial_outer_inner.widget.setMaximum(self.option_pipe_coaxial_outer_outer.get_value()) + ) self.option_pipe_coaxial_outer_inner.change_event( - lambda: self.option_pipe_coaxial_outer_outer.widget.setMinimum(self.option_pipe_coaxial_outer_inner.get_value())) + lambda: self.option_pipe_coaxial_outer_outer.widget.setMinimum(self.option_pipe_coaxial_outer_inner.get_value()) + ) self.option_pipe_borehole_radius_2 = FloatBox( category=self.category_pipe_data, label=translations.option_pipe_borehole_radius_2, @@ -811,9 +908,12 @@ def _page_borehole_resistance(self, translations): maximal_value=10000, step=0.000001, ) - self.pipe_thermal_resistance = ResultText(translations.pipe_thermal_resistance, - category=self.category_pipe_data, - prefix="The equivalent borehole thermal resistance (at 150m) is: ", suffix="mK/W") + self.pipe_thermal_resistance = ResultText( + translations.pipe_thermal_resistance, + category=self.category_pipe_data, + prefix="The equivalent borehole thermal resistance (at 150m) is: ", + suffix="mK/W", + ) self.pipe_thermal_resistance.warning = True # set update events @@ -863,32 +963,32 @@ def _page_thermal_demand(self, translations): def create_category_select_datafile(): self.category_select_file = Category(page=self.page_thermal, label=translations.category_select_file) - self.option_seperator_csv = ButtonBox(label=translations.option_seperator_csv, default_index=0, - entries=['Semicolon ";"', 'Comma ","'], - category=self.category_select_file) - self.option_decimal_csv = ButtonBox(label=translations.option_decimal_csv, default_index=0, - entries=['Point "."', 'Comma ","'], - category=self.category_select_file) + self.option_seperator_csv = ButtonBox( + label=translations.option_seperator_csv, default_index=0, entries=['Semicolon ";"', 'Comma ","'], category=self.category_select_file + ) + self.option_decimal_csv = ButtonBox( + label=translations.option_decimal_csv, default_index=0, entries=['Point "."', 'Comma ","'], category=self.category_select_file + ) self.option_filename = FileNameBox( category=self.category_select_file, label=translations.option_filename, - default_value='', + default_value="", dialog_text="Choose csv file", error_text="no file selected", ) self.option_filename.check_active = True - self.option_column = ButtonBox(label=translations.option_column, default_index=0, - entries=["1 column", "2 columns"], category=self.category_select_file) + self.option_column = ButtonBox( + label=translations.option_column, default_index=0, entries=["1 column", "2 columns"], category=self.category_select_file + ) self.option_heating_column = ListBox(category=self.category_select_file, label=translations.option_heating_column, default_index=0, entries=[]) self.option_cooling_column = ListBox(category=self.category_select_file, label=translations.option_cooling_column, default_index=0, entries=[]) self.option_single_column = ListBox(category=self.category_select_file, label=translations.option_single_column, default_index=0, entries=[]) - self.option_unit_data = ButtonBox(label=translations.option_unit_data, default_index=1, entries=["W", "kW", "MW"], - category=self.category_select_file) + self.option_unit_data = ButtonBox( + label=translations.option_unit_data, default_index=1, entries=["W", "kW", "MW"], category=self.category_select_file + ) - self.hint_press_load = Hint(hint=translations.hint_press_load, - category=self.category_select_file, - warning=True) + self.hint_press_load = Hint(hint=translations.hint_press_load, category=self.category_select_file, warning=True) self.button_load_csv = FunctionButton(category=self.category_select_file, button_text=translations.button_load_csv, icon="Download.svg") @@ -1215,14 +1315,13 @@ def create_category_th_demand(): ) def create_category_building_demand(): - self.category_demand_building_or_geo = \ - Category(page=self.page_thermal, label=translations.category_demand_building_or_geo) - self.geo_load = ButtonBox(label=translations.geo_load, default_index=0, - entries=[" geothermal ", " building "], - category=self.category_demand_building_or_geo) - self.option_include_dhw = ButtonBox(label=translations.option_include_dhw, default_index=0, - entries=[" No ", " Yes "], - category=self.category_demand_building_or_geo) + self.category_demand_building_or_geo = Category(page=self.page_thermal, label=translations.category_demand_building_or_geo) + self.geo_load = ButtonBox( + label=translations.geo_load, default_index=0, entries=[" geothermal ", " building "], category=self.category_demand_building_or_geo + ) + self.option_include_dhw = ButtonBox( + label=translations.option_include_dhw, default_index=0, entries=[" No ", " Yes "], category=self.category_demand_building_or_geo + ) self.SCOP = FloatBox( category=self.category_demand_building_or_geo, label=translations.SCOP, @@ -1271,123 +1370,121 @@ def _page_results(self, translations): def create_category_numerical_results(): self.numerical_results = Category(page=self.page_result, label=translations.numerical_results) - self.result_text_depth = ResultText(translations.result_text_depth, category=self.numerical_results, - prefix="Depth: ", suffix="m") + self.result_text_depth = ResultText(translations.result_text_depth, category=self.numerical_results, prefix="Depth: ", suffix="m") self.result_text_depth.text_to_be_shown("Borefield", "H") self.result_text_depth.function_to_convert_to_text(lambda x: round(x, 2)) - self.result_Rb_calculated = ResultText(translations.result_Rb_calculated, category=self.numerical_results, - prefix="Equivalent borehole thermal resistance: ", suffix="Wm/K") + self.result_Rb_calculated = ResultText( + translations.result_Rb_calculated, category=self.numerical_results, prefix="Equivalent borehole thermal resistance: ", suffix="Wm/K" + ) self.result_Rb_calculated.text_to_be_shown("Borefield", "Rb") self.result_Rb_calculated.function_to_convert_to_text(lambda x: round(x, 4)) - self.result_Reynolds = ResultText(translations.result_Reynolds, - category=self.numerical_results, - prefix="Reynolds number: ", suffix="") + self.result_Reynolds = ResultText(translations.result_Reynolds, category=self.numerical_results, prefix="Reynolds number: ", suffix="") self.result_Reynolds.text_to_be_shown("Borefield", "Re") self.result_Reynolds.function_to_convert_to_text(lambda x: round(x, 0)) - self.results_ground_temperature = ResultText(translations.results_ground_temperature, - category=self.numerical_results, - prefix="Average ground temperature: ", suffix=" deg C") + self.results_ground_temperature = ResultText( + translations.results_ground_temperature, category=self.numerical_results, prefix="Average ground temperature: ", suffix=" deg C" + ) self.results_ground_temperature.text_to_be_shown("Borefield", "_Tg") self.results_ground_temperature.function_to_convert_to_text(lambda x: round(x, 2)) - self.results_heating_load = ResultText(translations.results_heating_load, category=self.numerical_results, - prefix="Heating load on the borefield: ", suffix=" kWh") - self.results_heating_peak_geo = ResultText(translations.results_heating_peak_geo, - category=self.numerical_results, - prefix="with a peak of: ", suffix=" kW") + self.results_heating_load = ResultText( + translations.results_heating_load, category=self.numerical_results, prefix="Heating load on the borefield: ", suffix=" kWh" + ) + self.results_heating_peak_geo = ResultText( + translations.results_heating_peak_geo, category=self.numerical_results, prefix="with a peak of: ", suffix=" kW" + ) self.results_heating_peak_geo.text_to_be_shown("Borefield", "_secundary_borefield_load") - self.results_heating_peak_geo.function_to_convert_to_text( - lambda x: round(getattr(x, "max_peak_heating"), 2)) + self.results_heating_peak_geo.function_to_convert_to_text(lambda x: round(getattr(x, "max_peak_heating"), 2)) self.results_heating_load.text_to_be_shown("Borefield", "_secundary_borefield_load") - self.results_heating_load.function_to_convert_to_text( - lambda x: round(np.sum(getattr(x, "hourly_heating_load")), 0)) - self.results_heating_load_percentage = ResultText(translations.results_heating_load_percentage, - category=self.numerical_results, - prefix="This is ", suffix="% of the heating load") + self.results_heating_load.function_to_convert_to_text(lambda x: round(np.sum(getattr(x, "hourly_heating_load")), 0)) + self.results_heating_load_percentage = ResultText( + translations.results_heating_load_percentage, category=self.numerical_results, prefix="This is ", suffix="% of the heating load" + ) self.results_heating_load_percentage.text_to_be_shown("Borefield", "_percentage_heating") self.results_heating_load_percentage.function_to_convert_to_text(lambda x: round(x, 2)) - self.results_heating_ext = ResultText(translations.results_heating_ext, category=self.numerical_results, - prefix="heating load external: ", suffix=" kWh") + self.results_heating_ext = ResultText( + translations.results_heating_ext, category=self.numerical_results, prefix="heating load external: ", suffix=" kWh" + ) self.results_heating_ext.text_to_be_shown("Borefield", "_external_load") - self.results_heating_ext.function_to_convert_to_text( - lambda x: round(np.sum(getattr(x, "hourly_heating_load"), 0))) - self.results_heating_peak = ResultText(translations.results_heating_peak, category=self.numerical_results, - prefix="with a peak of: ", suffix=" kW") + self.results_heating_ext.function_to_convert_to_text(lambda x: round(np.sum(getattr(x, "hourly_heating_load"), 0))) + self.results_heating_peak = ResultText(translations.results_heating_peak, category=self.numerical_results, prefix="with a peak of: ", suffix=" kW") self.results_heating_peak.text_to_be_shown("Borefield", "_external_load") - self.results_heating_peak.function_to_convert_to_text(lambda x: round(getattr(x, 'max_peak_heating'), 2)) + self.results_heating_peak.function_to_convert_to_text(lambda x: round(getattr(x, "max_peak_heating"), 2)) - self.results_cooling_load = ResultText(translations.results_cooling_load, category=self.numerical_results, - prefix="Cooling load on the borefield: ", suffix=" kWh") - self.results_cooling_peak_geo = ResultText(translations.results_cooling_peak_geo, - category=self.numerical_results, - prefix="with a peak of: ", suffix=" kW") + self.results_cooling_load = ResultText( + translations.results_cooling_load, category=self.numerical_results, prefix="Cooling load on the borefield: ", suffix=" kWh" + ) + self.results_cooling_peak_geo = ResultText( + translations.results_cooling_peak_geo, category=self.numerical_results, prefix="with a peak of: ", suffix=" kW" + ) self.results_cooling_peak_geo.text_to_be_shown("Borefield", "_secundary_borefield_load") - self.results_cooling_peak_geo.function_to_convert_to_text( - lambda x: round(getattr(x, 'max_peak_cooling'), 2)) + self.results_cooling_peak_geo.function_to_convert_to_text(lambda x: round(getattr(x, "max_peak_cooling"), 2)) self.results_cooling_load.text_to_be_shown("Borefield", "_secundary_borefield_load") - self.results_cooling_load.function_to_convert_to_text( - lambda x: round(np.sum(getattr(x, 'hourly_cooling_load')), 0)) - self.results_cooling_load_percentage = ResultText(translations.results_cooling_load_percentage, - category=self.numerical_results, - prefix="This is ", suffix="% of the cooling load") + self.results_cooling_load.function_to_convert_to_text(lambda x: round(np.sum(getattr(x, "hourly_cooling_load")), 0)) + self.results_cooling_load_percentage = ResultText( + translations.results_cooling_load_percentage, category=self.numerical_results, prefix="This is ", suffix="% of the cooling load" + ) self.results_cooling_load_percentage.text_to_be_shown("Borefield", "_percentage_cooling") self.results_cooling_load_percentage.function_to_convert_to_text(lambda x: round(x, 2)) - self.results_cooling_ext = ResultText(translations.results_cooling_ext, category=self.numerical_results, - prefix="cooling load external: ", suffix=" kWh") + self.results_cooling_ext = ResultText( + translations.results_cooling_ext, category=self.numerical_results, prefix="cooling load external: ", suffix=" kWh" + ) self.results_cooling_ext.text_to_be_shown("Borefield", "_external_load") - self.results_cooling_ext.function_to_convert_to_text( - lambda x: round(np.sum(getattr(x, 'hourly_cooling_load')), 0)) - self.results_cooling_peak = ResultText(translations.results_cooling_peak, category=self.numerical_results, - prefix="with a peak of: ", suffix=" kW") + self.results_cooling_ext.function_to_convert_to_text(lambda x: round(np.sum(getattr(x, "hourly_cooling_load")), 0)) + self.results_cooling_peak = ResultText(translations.results_cooling_peak, category=self.numerical_results, prefix="with a peak of: ", suffix=" kW") self.results_cooling_peak.text_to_be_shown("Borefield", "_external_load") - self.results_cooling_peak.function_to_convert_to_text(lambda x: round(getattr(x, 'max_peak_cooling'), 2)) + self.results_cooling_peak.function_to_convert_to_text(lambda x: round(getattr(x, "max_peak_cooling"), 2)) - self.max_temp = ResultText(translations.max_temp, category=self.numerical_results, - prefix="The maximum average fluid temperature is ", suffix=" deg C") + self.max_temp = ResultText( + translations.max_temp, category=self.numerical_results, prefix="The maximum average fluid temperature is ", suffix=" deg C" + ) self.max_temp.text_to_be_shown("Borefield", "results") self.max_temp.function_to_convert_to_text(lambda x: round(max(x.peak_cooling), 2)) - self.min_temp = ResultText(translations.min_temp, category=self.numerical_results, - prefix="The minimum average fluid temperature is ", suffix=" deg C") + self.min_temp = ResultText( + translations.min_temp, category=self.numerical_results, prefix="The minimum average fluid temperature is ", suffix=" deg C" + ) self.min_temp.text_to_be_shown("Borefield", "results") self.min_temp.function_to_convert_to_text(lambda x: round(min(x.peak_heating), 2)) def create_figure_temperature_profile(): - self.figure_temperature_profile = ResultFigure(label=translations.figure_temperature_profile, - page=self.page_result) - - self.figure_temperature_profile.fig_to_be_shown(class_name="Borefield", - function_name="print_temperature_profile") - - self.legend_figure_temperature_profile = FigureOption(category=self.figure_temperature_profile, - label=translations.legend_figure_temperature_profile, - param="legend", - default=0, - entries=["No", "Yes"], - entries_values=[False, True]) - - self.hourly_figure_temperature_profile = FigureOption(category=self.figure_temperature_profile, - label=translations.hourly_figure_temperature_profile, - param="plot_hourly", - default=0, - entries=["No", "Yes"], - entries_values=[False, True]) + self.figure_temperature_profile = ResultFigure(label=translations.figure_temperature_profile, page=self.page_result) + + self.figure_temperature_profile.fig_to_be_shown(class_name="Borefield", function_name="print_temperature_profile") + + self.legend_figure_temperature_profile = FigureOption( + category=self.figure_temperature_profile, + label=translations.legend_figure_temperature_profile, + param="legend", + default=0, + entries=["No", "Yes"], + entries_values=[False, True], + ) + + self.hourly_figure_temperature_profile = FigureOption( + category=self.figure_temperature_profile, + label=translations.hourly_figure_temperature_profile, + param="plot_hourly", + default=0, + entries=["No", "Yes"], + entries_values=[False, True], + ) def create_figure_load_duration(): - self.figure_load_duration = ResultFigure(label=translations.figure_load_duration, - page=self.page_result) + self.figure_load_duration = ResultFigure(label=translations.figure_load_duration, page=self.page_result) - self.figure_load_duration.fig_to_be_shown(class_name="Borefield", - function_name="plot_load_duration") + self.figure_load_duration.fig_to_be_shown(class_name="Borefield", function_name="plot_load_duration") - self.legend_figure_load_duration = FigureOption(category=self.figure_load_duration, - label=translations.legend_figure_load_duration, - param="legend", - default=0, - entries=["No", "Yes"], - entries_values=[False, True]) + self.legend_figure_load_duration = FigureOption( + category=self.figure_load_duration, + label=translations.legend_figure_load_duration, + param="legend", + default=0, + entries=["No", "Yes"], + entries_values=[False, True], + ) # create categories create_category_numerical_results() @@ -1398,8 +1495,7 @@ def _page_settings(self, translations): self.create_settings_page() # add advanced options - self.option_advanced_options = ButtonBox(translations.option_advanced_options, 0, - [' No ', ' Yes '], self.category_save_scenario) + self.option_advanced_options = ButtonBox(translations.option_advanced_options, 0, [" No ", " Yes "], self.category_save_scenario) self.option_advanced_options.add_link_2_show(self.category_advanced_options, on_index=1) # dissable options for figure change @@ -1407,166 +1503,173 @@ def _page_settings(self, translations): self.category_default_figure_settings.show = lambda *kwargs: None def set_dependencies(self) -> None: - self.show_option_under_multiple_conditions(self.option_method_size_depth, - self.aim_req_depth, - custom_logic=self.aim_req_depth.is_checked) - self.show_option_under_multiple_conditions(self.option_temperature_profile_hourly, - self.aim_temp_profile, - custom_logic=self.aim_temp_profile.is_checked) - - self.show_option_under_multiple_conditions(self.option_ground_temp, - self.option_source_ground_temperature, - custom_logic=partial( - self.option_source_ground_temperature.check_linked_value, 0)) - self.show_option_under_multiple_conditions([self.hint_ground_database, - self.hint_ground_flux_database, - self.option_ground_database], - self.option_source_ground_temperature, - custom_logic=partial( - self.option_source_ground_temperature.check_linked_value, 1)) - self.show_option_under_multiple_conditions([self.option_flux_gradient, self.option_ground_temp_gradient], - self.option_source_ground_temperature, - custom_logic=partial( - self.option_source_ground_temperature.check_linked_value, 2)) - self.show_option_under_multiple_conditions(self.option_ground_heat_flux, - self.option_flux_gradient, - custom_logic=partial( - self.option_flux_gradient.check_linked_value, 0), - check_on_visibility_change=True) - self.show_option_under_multiple_conditions(self.option_temp_gradient, - self.option_flux_gradient, - custom_logic=partial( - self.option_flux_gradient.check_linked_value, 1), - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions([self.option_len_peak_heating, self.option_len_peak_cooling], - [self.aim_optimize, self.option_temperature_profile_hourly, - self.option_method_size_depth], - functions_check_for_or=[ - partial(self.option_temperature_profile_hourly.check_linked_value, 0), - partial(self.option_method_size_depth.check_linked_value, 0), - partial(self.option_method_size_depth.check_linked_value, 1), - self.aim_optimize.is_checked - ], check_on_visibility_change=True) - - self.show_option_under_multiple_conditions(self.category_constant_rb, - self.option_method_rb_calc, - custom_logic=partial(self.option_method_rb_calc.check_linked_value, 0)) - self.show_option_under_multiple_conditions([self.category_fluid_data, self.category_pipe_data], - self.option_method_rb_calc, - custom_logic=partial(self.option_method_rb_calc.check_linked_value, 1)) - - self.show_option_under_multiple_conditions([self.option_fluid_capacity, self.option_fluid_conductivity, - self.option_fluid_density, self.option_fluid_viscosity], - [self.option_fluid_selector, self.option_method_rb_calc], - custom_logic=partial(self.option_fluid_selector.check_linked_value, 0)) - self.show_option_under_multiple_conditions([self.option_glycol_selector, self.option_glycol_percentage, - self.option_fluid_ref_temp], - [self.option_fluid_selector, self.option_method_rb_calc], - custom_logic=partial(self.option_fluid_selector.check_linked_value, 1)) - - self.show_option_under_multiple_conditions([self.option_pipe_coaxial_inner_inner, - self.option_pipe_coaxial_inner_outer, - self.option_pipe_coaxial_outer_inner, - self.option_pipe_coaxial_outer_outer], - self.option_U_pipe_or_coaxial_pipe, - custom_logic=partial(self.option_U_pipe_or_coaxial_pipe.check_linked_value, 1), - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions([self.option_pipe_inner_radius, - self.option_pipe_outer_radius, - self.option_pipe_number, - self.option_pipe_distance], - self.option_U_pipe_or_coaxial_pipe, - custom_logic=partial( - self.option_U_pipe_or_coaxial_pipe.check_linked_value, 0), - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions([self.option_heating_column, self.option_cooling_column], - self.option_column, - custom_logic=partial(self.option_column.check_linked_value, 1)) - self.show_option_under_multiple_conditions(self.option_single_column, - self.option_column, - custom_logic=partial(self.option_column.check_linked_value, 0)) - - self.show_option_under_multiple_conditions([self.button_load_csv, self.hint_press_load, self.category_th_demand], - [self.option_method_size_depth, - self.option_temperature_profile_hourly], - functions_check_for_or=[ - partial(self.option_method_size_depth.check_linked_value, 0), - partial(self.option_method_size_depth.check_linked_value, 1), - partial(self.option_temperature_profile_hourly.check_linked_value, 0), - ], - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions([self.SCOP, self.SEER], - self.geo_load, - custom_logic=partial(self.geo_load.check_linked_value, 1)) - - self.show_option_under_multiple_conditions(self.option_include_dhw, - self.aim_optimize, - custom_logic=lambda: not self.aim_optimize.is_checked()) - self.show_option_under_multiple_conditions(self.DHW, - self.option_include_dhw, - custom_logic=partial(self.option_include_dhw.check_linked_value, 1), - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions(self.SCOP_DHW, - [self.geo_load, self.option_include_dhw], - functions_check_for_and=[ - partial(self.geo_load.check_linked_value, 1), - partial(self.option_include_dhw.check_linked_value, 1) - ], - check_on_visibility_change=True) + self.show_option_under_multiple_conditions(self.option_method_size_depth, self.aim_req_depth, custom_logic=self.aim_req_depth.is_checked) + self.show_option_under_multiple_conditions(self.option_temperature_profile_hourly, self.aim_temp_profile, custom_logic=self.aim_temp_profile.is_checked) + + self.show_option_under_multiple_conditions( + self.option_ground_temp, self.option_source_ground_temperature, custom_logic=partial(self.option_source_ground_temperature.check_linked_value, 0) + ) + self.show_option_under_multiple_conditions( + [self.hint_ground_database, self.hint_ground_flux_database, self.option_ground_database], + self.option_source_ground_temperature, + custom_logic=partial(self.option_source_ground_temperature.check_linked_value, 1), + ) + self.show_option_under_multiple_conditions( + [self.option_flux_gradient, self.option_ground_temp_gradient], + self.option_source_ground_temperature, + custom_logic=partial(self.option_source_ground_temperature.check_linked_value, 2), + ) + self.show_option_under_multiple_conditions( + self.option_ground_heat_flux, + self.option_flux_gradient, + custom_logic=partial(self.option_flux_gradient.check_linked_value, 0), + check_on_visibility_change=True, + ) + self.show_option_under_multiple_conditions( + self.option_temp_gradient, + self.option_flux_gradient, + custom_logic=partial(self.option_flux_gradient.check_linked_value, 1), + check_on_visibility_change=True, + ) + + self.show_option_under_multiple_conditions( + [self.option_len_peak_heating, self.option_len_peak_cooling], + [self.aim_optimize, self.option_temperature_profile_hourly, self.option_method_size_depth], + functions_check_for_or=[ + partial(self.option_temperature_profile_hourly.check_linked_value, 0), + partial(self.option_method_size_depth.check_linked_value, 0), + partial(self.option_method_size_depth.check_linked_value, 1), + self.aim_optimize.is_checked, + ], + check_on_visibility_change=True, + ) + + self.show_option_under_multiple_conditions( + self.category_constant_rb, self.option_method_rb_calc, custom_logic=partial(self.option_method_rb_calc.check_linked_value, 0) + ) + self.show_option_under_multiple_conditions( + [self.category_fluid_data, self.category_pipe_data], + self.option_method_rb_calc, + custom_logic=partial(self.option_method_rb_calc.check_linked_value, 1), + ) + + self.show_option_under_multiple_conditions( + [self.option_fluid_capacity, self.option_fluid_conductivity, self.option_fluid_density, self.option_fluid_viscosity], + [self.option_fluid_selector, self.option_method_rb_calc], + custom_logic=partial(self.option_fluid_selector.check_linked_value, 0), + ) + self.show_option_under_multiple_conditions( + [self.option_glycol_selector, self.option_glycol_percentage, self.option_fluid_ref_temp], + [self.option_fluid_selector, self.option_method_rb_calc], + custom_logic=partial(self.option_fluid_selector.check_linked_value, 1), + ) + + self.show_option_under_multiple_conditions( + [ + self.option_pipe_coaxial_inner_inner, + self.option_pipe_coaxial_inner_outer, + self.option_pipe_coaxial_outer_inner, + self.option_pipe_coaxial_outer_outer, + ], + self.option_U_pipe_or_coaxial_pipe, + custom_logic=partial(self.option_U_pipe_or_coaxial_pipe.check_linked_value, 1), + check_on_visibility_change=True, + ) + + self.show_option_under_multiple_conditions( + [self.option_pipe_inner_radius, self.option_pipe_outer_radius, self.option_pipe_number, self.option_pipe_distance], + self.option_U_pipe_or_coaxial_pipe, + custom_logic=partial(self.option_U_pipe_or_coaxial_pipe.check_linked_value, 0), + check_on_visibility_change=True, + ) + + self.show_option_under_multiple_conditions( + [self.option_heating_column, self.option_cooling_column], self.option_column, custom_logic=partial(self.option_column.check_linked_value, 1) + ) + self.show_option_under_multiple_conditions( + self.option_single_column, self.option_column, custom_logic=partial(self.option_column.check_linked_value, 0) + ) + + self.show_option_under_multiple_conditions( + [self.button_load_csv, self.hint_press_load, self.category_th_demand], + [self.option_method_size_depth, self.option_temperature_profile_hourly], + functions_check_for_or=[ + partial(self.option_method_size_depth.check_linked_value, 0), + partial(self.option_method_size_depth.check_linked_value, 1), + partial(self.option_temperature_profile_hourly.check_linked_value, 0), + ], + check_on_visibility_change=True, + ) + + self.show_option_under_multiple_conditions([self.SCOP, self.SEER], self.geo_load, custom_logic=partial(self.geo_load.check_linked_value, 1)) + + self.show_option_under_multiple_conditions(self.option_include_dhw, self.aim_optimize, custom_logic=lambda: not self.aim_optimize.is_checked()) + self.show_option_under_multiple_conditions( + self.DHW, self.option_include_dhw, custom_logic=partial(self.option_include_dhw.check_linked_value, 1), check_on_visibility_change=True + ) + + self.show_option_under_multiple_conditions( + self.SCOP_DHW, + [self.geo_load, self.option_include_dhw], + functions_check_for_and=[partial(self.geo_load.check_linked_value, 1), partial(self.option_include_dhw.check_linked_value, 1)], + check_on_visibility_change=True, + ) self.aim_optimize.change_event(self.disable_button_box(self.geo_load, 0, partial(self.aim_optimize.is_checked))) # result page - list_options_optimize_load_profile = [self.results_heating_ext, self.results_heating_peak_geo, - self.results_heating_load_percentage, self.results_heating_load, - self.results_heating_peak, self.results_cooling_ext, - self.results_cooling_load_percentage, self.results_cooling_load, - self.results_cooling_peak, self.results_cooling_peak_geo] - self.show_option_under_multiple_conditions(list_options_optimize_load_profile, - self.aim_optimize, - custom_logic=self.aim_optimize.is_checked, - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions(self.results_ground_temperature, - self.option_source_ground_temperature, - functions_check_for_or=[ - partial(self.option_source_ground_temperature.check_linked_value, 1), - partial(self.option_source_ground_temperature.check_linked_value, 2) - ], - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions([self.result_Rb_calculated, self.result_Reynolds], - self.option_method_rb_calc, - custom_logic=partial(self.option_method_rb_calc.check_linked_value, 1), - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions(self.result_text_depth, - self.aim_req_depth, - custom_logic=partial(self.aim_req_depth.is_checked), - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions([self.max_temp, self.min_temp], - self.aim_temp_profile, - custom_logic=partial(self.aim_temp_profile.is_checked), - check_on_visibility_change=True) - - self.show_option_under_multiple_conditions([self.hourly_figure_temperature_profile, - self.figure_load_duration], - [self.option_temperature_profile_hourly, - self.aim_optimize, - self.option_method_size_depth], - functions_check_for_or=[ - partial(self.option_temperature_profile_hourly.check_linked_value, 1), - partial(self.aim_optimize.is_checked), - partial(self.option_method_size_depth.check_linked_value, 2) - ], - check_on_visibility_change=True) + list_options_optimize_load_profile = [ + self.results_heating_ext, + self.results_heating_peak_geo, + self.results_heating_load_percentage, + self.results_heating_load, + self.results_heating_peak, + self.results_cooling_ext, + self.results_cooling_load_percentage, + self.results_cooling_load, + self.results_cooling_peak, + self.results_cooling_peak_geo, + ] + self.show_option_under_multiple_conditions( + list_options_optimize_load_profile, self.aim_optimize, custom_logic=self.aim_optimize.is_checked, check_on_visibility_change=True + ) + + self.show_option_under_multiple_conditions( + self.results_ground_temperature, + self.option_source_ground_temperature, + functions_check_for_or=[ + partial(self.option_source_ground_temperature.check_linked_value, 1), + partial(self.option_source_ground_temperature.check_linked_value, 2), + ], + check_on_visibility_change=True, + ) + + self.show_option_under_multiple_conditions( + [self.result_Rb_calculated, self.result_Reynolds], + self.option_method_rb_calc, + custom_logic=partial(self.option_method_rb_calc.check_linked_value, 1), + check_on_visibility_change=True, + ) + + self.show_option_under_multiple_conditions( + self.result_text_depth, self.aim_req_depth, custom_logic=partial(self.aim_req_depth.is_checked), check_on_visibility_change=True + ) + + self.show_option_under_multiple_conditions( + [self.max_temp, self.min_temp], self.aim_temp_profile, custom_logic=partial(self.aim_temp_profile.is_checked), check_on_visibility_change=True + ) + + self.show_option_under_multiple_conditions( + [self.hourly_figure_temperature_profile, self.figure_load_duration], + [self.option_temperature_profile_hourly, self.aim_optimize, self.option_method_size_depth], + functions_check_for_or=[ + partial(self.option_temperature_profile_hourly.check_linked_value, 1), + partial(self.aim_optimize.is_checked), + partial(self.option_method_size_depth.check_linked_value, 2), + ], + check_on_visibility_change=True, + ) def _create_lists(self): # general settings @@ -1606,17 +1709,14 @@ def Upipe(): self.option_pipe_distance.widget.blockSignals(False) # set minimal value for borehole radius self.option_pipe_borehole_radius_2.widget.blockSignals(True) - self.option_pipe_borehole_radius_2.widget.setMinimum(max(r_outer_pipe + distance_min, - self.option_pipe_borehole_radius_2.minimal_value)) + self.option_pipe_borehole_radius_2.widget.setMinimum(max(r_outer_pipe + distance_min, self.option_pipe_borehole_radius_2.minimal_value)) self.option_pipe_borehole_radius_2.widget.blockSignals(False) self.option_pipe_borehole_radius.widget.blockSignals(True) - self.option_pipe_borehole_radius.widget.setMinimum(max(r_outer_pipe + distance_min, - self.option_pipe_borehole_radius.minimal_value)) + self.option_pipe_borehole_radius.widget.setMinimum(max(r_outer_pipe + distance_min, self.option_pipe_borehole_radius.minimal_value)) self.option_pipe_borehole_radius.widget.blockSignals(False) # set max value for pipe radius self.option_pipe_outer_radius.widget.blockSignals(True) - self.option_pipe_outer_radius.widget.setMaximum(min(r_borehole - distance_min, - self.option_pipe_outer_radius.maximal_value)) + self.option_pipe_outer_radius.widget.setMaximum(min(r_borehole - distance_min, self.option_pipe_outer_radius.maximal_value)) self.option_pipe_outer_radius.widget.blockSignals(False) # set max number of U-tubes @@ -1636,12 +1736,10 @@ def coaxial(): self.option_pipe_outer_radius.widget.blockSignals(False) # set min value for borehole radius self.option_pipe_borehole_radius_2.widget.blockSignals(True) - self.option_pipe_borehole_radius_2.widget.setMinimum(max(r_outer_pipe, - self.option_pipe_borehole_radius_2.minimal_value)) + self.option_pipe_borehole_radius_2.widget.setMinimum(max(r_outer_pipe, self.option_pipe_borehole_radius_2.minimal_value)) self.option_pipe_borehole_radius_2.widget.blockSignals(False) self.option_pipe_borehole_radius.widget.blockSignals(True) - self.option_pipe_borehole_radius.widget.setMinimum(max(r_outer_pipe, - self.option_pipe_borehole_radius.minimal_value)) + self.option_pipe_borehole_radius.widget.setMinimum(max(r_outer_pipe, self.option_pipe_borehole_radius.minimal_value)) self.option_pipe_borehole_radius.widget.blockSignals(False) if self.option_U_pipe_or_coaxial_pipe.get_value() == 0: @@ -1658,8 +1756,7 @@ def update_borehole(self) -> None: ------- None """ - frame = self.category_pipe_data.graphic_left if self.category_pipe_data.graphic_left is not None else \ - self.category_pipe_data.graphic_right + frame = self.category_pipe_data.graphic_left if self.category_pipe_data.graphic_left is not None else self.category_pipe_data.graphic_right if isinstance(frame, QtW.QGraphicsView): # draw general frame r_bore = max(self.option_pipe_borehole_radius.get_value() * 10, 0.001) @@ -1667,10 +1764,10 @@ def update_borehole(self) -> None: max_l = min(frame.width(), frame.height()) scale = max_l / r_bore / 1.25 # leave 25 % space # set colors - dark_color = array(globs.DARK.replace('rgb(', '').replace(')', '').split(','), dtype=int64) - white_color = array(globs.WHITE.replace('rgb(', '').replace(')', '').split(','), dtype=int64) - light_color = array(globs.LIGHT.replace('rgb(', '').replace(')', '').split(','), dtype=int64) - grey_color = array(globs.GREY.replace('rgb(', '').replace(')', '').split(','), dtype=int64) + dark_color = array(globs.DARK.replace("rgb(", "").replace(")", "").split(","), dtype=int64) + white_color = array(globs.WHITE.replace("rgb(", "").replace(")", "").split(","), dtype=int64) + light_color = array(globs.LIGHT.replace("rgb(", "").replace(")", "").split(","), dtype=int64) + grey_color = array(globs.GREY.replace("rgb(", "").replace(")", "").split(","), dtype=int64) blue_color = QtG.QColor(dark_color[0], dark_color[1], dark_color[2]) blue_light = QtG.QColor(light_color[0], light_color[1], light_color[2]) white_color = QtG.QColor(white_color[0], white_color[1], white_color[2]) @@ -1774,7 +1871,7 @@ def draw_borefield(): max_size = max(spacing_length * length, spacing_width * width, 1) scale = max_l / max_size / 1.25 # leave 25 % space # set colors - white_color = array(globs.WHITE.replace('rgb(', '').replace(')', '').split(','), dtype=int64) + white_color = array(globs.WHITE.replace("rgb(", "").replace(")", "").split(","), dtype=int64) white_color = QtG.QColor(white_color[0], white_color[1], white_color[2]) brown = QtG.QColor(145, 124, 111) # create graphic scene if not exits otherwise get scene and delete items @@ -1790,13 +1887,24 @@ def draw_borefield(): length = (length - 1) * spacing_length * scale / 2 + r_bore * scale / 2 if self.aim_rect.widget.isChecked(): - coordinates = [(w * spacing_width * scale - width, l * spacing_length * scale - length) for w in range(self.option_width.get_value()) for l in - range(self.option_length.get_value())] + coordinates = [ + (w * spacing_width * scale - width, l * spacing_length * scale - length) + for w in range(self.option_width.get_value()) + for l in range(self.option_length.get_value()) + ] elif self.aim_Box_shaped.widget.isChecked(): - coordinates = [(w * spacing_width * scale - width, l * spacing_length * scale - length) for w in range(self.option_width.get_value()) if not ( - 0 < w < self.option_width.get_value() - 1) for l in range(self.option_length.get_value())] - coordinates += [(w * spacing_width * scale - width, l * spacing_length * scale - length) for w in range(self.option_width.get_value()) for l - in range(self.option_length.get_value()) if not (0 < l < self.option_length.get_value() - 1)] + coordinates = [ + (w * spacing_width * scale - width, l * spacing_length * scale - length) + for w in range(self.option_width.get_value()) + if not (0 < w < self.option_width.get_value() - 1) + for l in range(self.option_length.get_value()) + ] + coordinates += [ + (w * spacing_width * scale - width, l * spacing_length * scale - length) + for w in range(self.option_width.get_value()) + for l in range(self.option_length.get_value()) + if not (0 < l < self.option_length.get_value() - 1) + ] elif self.aim_L_shaped.widget.isChecked(): l = self.option_length.get_value() - 1 coordinates = [(w * spacing_width * scale - width, l * spacing_length * scale - length) for w in range(self.option_width.get_value())] @@ -1814,8 +1922,10 @@ def draw_borefield(): scale = max_l / (2 * self.option_borefield_radius.get_value() + r_bore) / 1.25 # leave 25 % space angle = 2 * pi / self.option_number_circle_boreholes.get_value() radius = self.option_borefield_radius.get_value() * scale - coordinates = [(sin(angle * n) * radius - r_bore * scale / 2, cos(angle * n) * radius - r_bore * scale / 2) for n in - range(self.option_number_circle_boreholes.get_value())] + coordinates = [ + (sin(angle * n) * radius - r_bore * scale / 2, cos(angle * n) * radius - r_bore * scale / 2) + for n in range(self.option_number_circle_boreholes.get_value()) + ] else: coordinates = [(x, y) for x, y, _, _, _ in self.custom_borefield.get_value()] @@ -1851,7 +1961,8 @@ def fun_update_combo_box_data_file(self, filename: str) -> None: None """ filename = ( - self.option_filename.get_value() if not isinstance(filename, str) else filename) if filename is not None else self.option_filename.get_value() + (self.option_filename.get_value() if not isinstance(filename, str) else filename) if filename is not None else self.option_filename.get_value() + ) # get decimal and column seperator sep: str = ";" if self.option_seperator_csv.get_value() == 0 else "," @@ -1898,14 +2009,16 @@ def fun_display_data(self) -> None: try: data_unit = self.option_unit_data.get_value() - loaded_data = load_data_GUI(filename=self.option_filename.get_value(), - thermal_demand=self.option_column.get_value(), - heating_load_column=self.option_heating_column.get_value()[1], - cooling_load_column=self.option_cooling_column.get_value()[1], - combined=self.option_single_column.get_value()[1], - sep=";" if self.option_seperator_csv.get_value() == 0 else ",", - dec="." if self.option_decimal_csv.get_value() == 0 else ",", - fac=0.001 if data_unit == 0 else 1 if data_unit == 1 else 1000) + loaded_data = load_data_GUI( + filename=self.option_filename.get_value(), + thermal_demand=self.option_column.get_value(), + heating_load_column=self.option_heating_column.get_value()[1], + cooling_load_column=self.option_cooling_column.get_value()[1], + combined=self.option_single_column.get_value()[1], + sep=";" if self.option_seperator_csv.get_value() == 0 else ",", + dec="." if self.option_decimal_csv.get_value() == 0 else ",", + fac=0.001 if data_unit == 0 else 1 if data_unit == 1 else 1000, + ) peak_heating, peak_cooling, heating_load, cooling_load = loaded_data # set heating loads to double spinBoxes @@ -1977,7 +2090,7 @@ def fun_import_borefield(self): logging.error(self.translations.no_file_selected[self.option_language.get_value()[0]]) return sep = "," if self.option_seperator_borefield.get_value() == 1 else ";" if self.option_seperator_borefield.get_value() == 0 else "\t" - dec = "." if self.option_decimal_borefield.get_value() == 0 else ',' + dec = "." if self.option_decimal_borefield.get_value() == 0 else "," if filename.endswith(".csv"): data = pd.read_csv(filename, sep=sep, decimal=dec) self.custom_borefield.set_value(data.values) @@ -1996,39 +2109,59 @@ def update_borehole_thermal_resistance(self) -> None: None """ try: - fluid_data = FluidData(self.option_fluid_mass_flow.get_value(), self.option_fluid_conductivity.get_value(), - self.option_fluid_density.get_value(), self.option_fluid_capacity.get_value(), self.option_fluid_viscosity.get_value()) + fluid_data = FluidData( + self.option_fluid_mass_flow.get_value(), + self.option_fluid_conductivity.get_value(), + self.option_fluid_density.get_value(), + self.option_fluid_capacity.get_value(), + self.option_fluid_viscosity.get_value(), + ) if self.option_fluid_selector.get_value() == 1: # use pygfunction to get fluid properties if self.option_glycol_selector.get_value() == 0: - fluid_data.import_fluid_from_pygfunction(gt.media.Fluid('MEG', - self.option_glycol_percentage.get_value(), - self.option_fluid_ref_temp.get_value())) + fluid_data.import_fluid_from_pygfunction( + gt.media.Fluid("MEG", self.option_glycol_percentage.get_value(), self.option_fluid_ref_temp.get_value()) + ) else: - fluid_data.import_fluid_from_pygfunction(gt.media.Fluid('MPG', - self.option_glycol_percentage.get_value(), - self.option_fluid_ref_temp.get_value())) + fluid_data.import_fluid_from_pygfunction( + gt.media.Fluid("MPG", self.option_glycol_percentage.get_value(), self.option_fluid_ref_temp.get_value()) + ) if self.option_U_pipe_or_coaxial_pipe.get_value() == 0: - pipe_data = MultipleUTube(self.option_pipe_grout_conductivity.get_value(), self.option_pipe_inner_radius.get_value(), - self.option_pipe_outer_radius.get_value(), - self.option_pipe_conductivity.get_value(), self.option_pipe_distance.get_value(), self.option_pipe_number.get_value(), - self.option_pipe_roughness.get_value()) + pipe_data = MultipleUTube( + self.option_pipe_grout_conductivity.get_value(), + self.option_pipe_inner_radius.get_value(), + self.option_pipe_outer_radius.get_value(), + self.option_pipe_conductivity.get_value(), + self.option_pipe_distance.get_value(), + self.option_pipe_number.get_value(), + self.option_pipe_roughness.get_value(), + ) else: - pipe_data = CoaxialPipe(self.option_pipe_coaxial_inner_inner.get_value(), - self.option_pipe_coaxial_inner_outer.get_value(), - self.option_pipe_coaxial_outer_inner.get_value(), - self.option_pipe_coaxial_outer_outer.get_value(), - self.option_pipe_conductivity.get_value(), - self.option_pipe_grout_conductivity.get_value(), - self.option_pipe_roughness.get_value(), - True) # constant since this does not change anything + pipe_data = CoaxialPipe( + self.option_pipe_coaxial_inner_inner.get_value(), + self.option_pipe_coaxial_inner_outer.get_value(), + self.option_pipe_coaxial_outer_inner.get_value(), + self.option_pipe_coaxial_outer_outer.get_value(), + self.option_pipe_conductivity.get_value(), + self.option_pipe_grout_conductivity.get_value(), + self.option_pipe_roughness.get_value(), + True, + ) # constant since this does not change anything borehole = Borehole(fluid_data, pipe_data) - resistance = borehole.get_Rb(self.option_depth.get_value(), self.option_pipe_depth.get_value(), self.option_pipe_borehole_radius.get_value(), - self.option_conductivity.get_value()) - self.pipe_thermal_resistance.set_text_value(f'{self.option_depth.get_value()}m): {round(resistance, 4)}') + resistance = borehole.get_Rb( + self.option_depth.get_value(), + self.option_pipe_depth.get_value(), + self.option_pipe_borehole_radius.get_value(), + self.option_conductivity.get_value(), + ) + self.pipe_thermal_resistance.set_text_value(f"{self.option_depth.get_value()}m): {round(resistance, 4)}") except: pass + def translate(self, index: int, translation: Translations) -> None: + super().translate(index, translation) + self._update_selected_ground_temperature_from_database() + def _update_selected_ground_temperature_from_database(self) -> None: """ This function updates the hint for the ground database. @@ -2041,9 +2174,10 @@ def _update_selected_ground_temperature_from_database(self) -> None: temperature, flux = DATASET[self.option_ground_database.get_value()[1]] self.hint_ground_database.set_text_value(temperature) self.hint_ground_flux_database.set_text_value(flux) - except: # pragma: no cover + except KeyError: # pragma: no cover pass + def show_option_on_multiple_aims(first_aims: list[Aim], second_aims: list[Aim], option: Option): def show_hide(): first = any(aim.widget.isChecked() for aim in first_aims)