From 354541829392862a4b2a346c040a9e81f5b12d83 Mon Sep 17 00:00:00 2001 From: s_ranjbar Date: Wed, 28 Aug 2024 15:41:12 -0400 Subject: [PATCH] fix:redundant codes removed --- .../thermal_storage_tank.py | 25 +++---- .../energy_system_sizing.py | 70 ------------------- ...gy_system_sizing_and_simulation_factory.py | 54 -------------- 3 files changed, 10 insertions(+), 139 deletions(-) delete mode 100644 energy_system_modelling_package/energy_system_sizing.py delete mode 100644 energy_system_modelling_package/energy_system_sizing_and_simulation_factory.py diff --git a/energy_system_modelling_package/energy_system_modelling_factories/hvac_dhw_systems_simulation_models/thermal_storage_tank.py b/energy_system_modelling_package/energy_system_modelling_factories/hvac_dhw_systems_simulation_models/thermal_storage_tank.py index ea427348..552e1807 100644 --- a/energy_system_modelling_package/energy_system_modelling_factories/hvac_dhw_systems_simulation_models/thermal_storage_tank.py +++ b/energy_system_modelling_package/energy_system_modelling_factories/hvac_dhw_systems_simulation_models/thermal_storage_tank.py @@ -16,27 +16,23 @@ class StorageTank: self.heating_coil_capacity = heating_coil_capacity def heat_loss_coefficient(self): + r_tot = sum(float(layer.thickness) / float(layer.material.conductivity) for layer in + self.materials) + u_tot = 1 / r_tot + d = math.sqrt((4 * self.volume) / (math.pi * self.height)) + a_side = math.pi * d * self.height + a_top = math.pi * d ** 2 / 4 if self.number_of_vertical_layers == 1: - r_tot = sum(float(layer.thickness) / float(layer.material.conductivity) for layer in - self.materials) - u_tot = 1 / r_tot - d = math.sqrt((4 * self.volume) / (math.pi * self.height)) - a_side = math.pi * d * self.height - a_top = math.pi * d ** 2 / 4 ua = u_tot * (2 * a_top + a_side) return ua else: - r_tot = sum(float(layer.thickness) / float(layer.material.conductivity) for layer in - self.materials) - u_tot = 1 / r_tot - d = math.sqrt((4 * self.volume) / (math.pi * self.height)) - a_side = math.pi * d * self.height - a_top = math.pi * d ** 2 / 4 ua_side = u_tot * a_side ua_top_bottom = u_tot * (a_top + a_side) return ua_side, ua_top_bottom - def calculate_space_heating_fully_mixed(self, charging_flow_rate, discharging_flow_rate, supply_temperature, return_temperature, + + def calculate_space_heating_fully_mixed(self, charging_flow_rate, discharging_flow_rate, supply_temperature, + return_temperature, current_tank_temperature, heat_generator_input, ambient_temperature, dt): ua = self.heat_loss_coefficient() t_tank = (current_tank_temperature + @@ -47,6 +43,5 @@ class StorageTank: return t_tank def calculate_dhw_fully_mixed(self, charging_flow_rate, discharging_flow_rate, supply_temperature, return_temperature, - current_tank_temperature, heat_generator_input, ambient_temperature, dt): + current_tank_temperature, heat_generator_input, ambient_temperature, dt): pass - diff --git a/energy_system_modelling_package/energy_system_sizing.py b/energy_system_modelling_package/energy_system_sizing.py deleted file mode 100644 index 77f876b4..00000000 --- a/energy_system_modelling_package/energy_system_sizing.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -Energy System rule-based sizing -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2023 Concordia CERC group -Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca -""" - -import hub.helpers.constants as cte - - -class SystemSizing: - """ - The energy system sizing class - """ - def __init__(self, buildings): - self.buildings = buildings - - def hvac_sizing(self): - for building in self.buildings: - peak_heating_demand = building.heating_peak_load[cte.YEAR][0] / 3600 - peak_cooling_demand = building.cooling_peak_load[cte.YEAR][0] / 3600 - if peak_heating_demand > peak_cooling_demand: - sizing_demand = peak_heating_demand - for system in building.energy_systems: - if 'Heating' in system.demand_types: - for generation in system.generation_systems: - if generation.system_type == 'Heat Pump': - if generation.source_medium == cte.AIR: - generation.source_temperature = building.external_temperature - generation.nominal_heat_output = 0.6 * sizing_demand / 1000 - if generation.energy_storage_systems is not None: - for storage in generation.energy_storage_systems: - if storage.type_energy_stored == 'thermal': - storage.volume = building.heating_peak_load[cte.YEAR][0] / (cte.WATER_HEAT_CAPACITY*cte.WATER_DENSITY * 20) - elif generation.system_type == 'Boiler': - generation.nominal_heat_output = 0.4 * sizing_demand / 1000 - - else: - sizing_demand = peak_cooling_demand - for system in building.energy_systems: - if 'Cooling' in system.demand_types: - for generation in system.generation_systems: - if generation.system_type == 'Heat Pump': - generation.nominal_heat_output = sizing_demand / 1000 - - def montreal_custom(self): - for building in self.buildings: - energy_systems = building.energy_systems - for energy_system in energy_systems: - demand_types = energy_system.demand_types - generation_systems = energy_system.generation_systems - if cte.HEATING in demand_types: - if len(generation_systems) == 1: - for generation in generation_systems: - generation.nominal_heat_output = building.heating_peak_load[cte.YEAR][0] - else: - for generation in generation_systems: - generation.nominal_heat_output = building.heating_peak_load[cte.YEAR][0] / (len(generation_systems)) - elif cte.COOLING in demand_types: - if len(generation_systems) == 1: - for generation in generation_systems: - generation.nominal_cooling_output = building.cooling_peak_load[cte.YEAR][0] - else: - for generation in generation_systems: - generation.nominal_heat_output = building.cooling_peak_load[cte.YEAR][0] / (len(generation_systems)) - - - - - diff --git a/energy_system_modelling_package/energy_system_sizing_and_simulation_factory.py b/energy_system_modelling_package/energy_system_sizing_and_simulation_factory.py deleted file mode 100644 index ac94862e..00000000 --- a/energy_system_modelling_package/energy_system_sizing_and_simulation_factory.py +++ /dev/null @@ -1,54 +0,0 @@ -""" -EnergySystemSizingSimulationFactory retrieve the energy system archetype sizing and simulation module -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2022 Concordia CERC group -Project Coder Saeed Ranjbar saeed.ranjbar@mail.concordia.ca -""" - -from energy_system_modelling_package.system_simulation_models.archetype13 import Archetype13 -from energy_system_modelling_package.system_simulation_models.archetype13_stratified_tes import Archetype13Stratified -from energy_system_modelling_package.system_simulation_models.archetype1 import Archetype1 -from energy_system_modelling_package.system_simulation_models.archetypes14_15 import Archetype14_15 - - -class EnergySystemsSimulationFactory: - """ - EnergySystemsFactory class - """ - - def __init__(self, handler, building, output_path): - self._output_path = output_path - self._handler = '_' + handler.lower() - self._building = building - - def _archetype1(self): - """ - Enrich the city by using the sizing and simulation model developed for archetype13 of montreal_future_systems - """ - Archetype1(self._building, self._output_path).enrich_buildings() - self._building.level_of_detail.energy_systems = 2 - self._building.level_of_detail.energy_systems = 2 - - def _archetype13(self): - """ - Enrich the city by using the sizing and simulation model developed for archetype13 of montreal_future_systems - """ - Archetype13(self._building, self._output_path).enrich_buildings() - self._building.level_of_detail.energy_systems = 2 - self._building.level_of_detail.energy_systems = 2 - - def _archetype14_15(self): - """ - Enrich the city by using the sizing and simulation model developed for archetype14 and archetype15 of - montreal_future_systems - """ - Archetype14_15(self._building, self._output_path).enrich_buildings() - self._building.level_of_detail.energy_systems = 2 - self._building.level_of_detail.energy_systems = 2 - - def enrich(self): - """ - Enrich the city given to the class using the class given handler - :return: None - """ - getattr(self, self._handler, lambda: None)()