Skip to content

Feature/add thermal building model #1084

Feature/add thermal building model

Feature/add thermal building model #1084

GitHub Actions / Black failed Oct 6, 2023 in 0s

22 errors

Black found 22 errors

Annotations

Check failure on line 7 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py#L1-L7

-
 """
 copied from https://github.com/architecture-building-systems/RC_BuildingSimulator
 Tool to Evaluate Radiation incident on a surface of a set angle
 """
 

Check failure on line 65 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py#L8-L65

 import math
 import datetime
 
 
 __authors__ = "Prageeth Jayathissa"
-__copyright__ = "Copyright 2016, Architecture and Building Systems - ETH Zurich"
+__copyright__ = (
+    "Copyright 2016, Architecture and Building Systems - ETH Zurich"
+)
 __credits__ = ["pysolar, Quaschning Volker,  Rolf Hanitsch, Linus Walker"]
 __license__ = "MIT"
 __version__ = "0.1"
 __maintainer__ = "Prageeth Jayathissa"
 __email__ = "p.jayathissa@gmail.com"
 __status__ = "production"
 
 
 def sunPositionReader(SunPosition_path):
-
-    sun_labels = ['altitude', 'azimuth']  # 'HOY',
-#
-#    result = pd.read_csv(SunPosition_path, skiprows=1, header=None, names=epw_labels).drop('datasource', axis=1)
-#    result['dayofyear'] = pd.date_range('1/1/2010', periods=8760, freq='H').dayofyear
-#    result['ratio_diffhout'] = result['difhorrad_Whm2']/result['glohorrad_Whm2']
+    sun_labels = ["altitude", "azimuth"]  # 'HOY',
+    #
+    #    result = pd.read_csv(SunPosition_path, skiprows=1, header=None, names=epw_labels).drop('datasource', axis=1)
+    #    result['dayofyear'] = pd.date_range('1/1/2010', periods=8760, freq='H').dayofyear
+    #    result['ratio_diffhout'] = result['difhorrad_Whm2']/result['glohorrad_Whm2']
 
     result = pd.read_csv(SunPosition_path, skiprows=1, names=sun_labels)
 
     return
-class Location(object, ):
+
+
+class Location(
+    object,
+):
     """Set the Location of the Simulation with an Energy Plus Weather File"""
 
-    def __init__(self, epwfile_path, mannheim :bool):
-
+    def __init__(self, epwfile_path, mannheim: bool):
         # Set EPW Labels and import epw file
         if mannheim:
-            epw_labels = ['hour', 'drybulb_C', 'dewpoint_C',
-                          'relhum_percent',
-                          'atmos_Pa', 'exthorrad_Whm2', 'extdirrad_Whm2', 'horirsky_Whm2', 'glohorrad_Whm2',
-                          'dirnorrad_Whm2', 'difhorrad_Whm2', 'glohorillum_lux', 'dirnorillum_lux', 'difhorillum_lux',
-                          'zenlum_lux', 'winddir_deg', 'windspd_ms', 'totskycvr_tenths', 'opaqskycvr_tenths',
-                          'visibility_km',
-                          'ceiling_hgt_m', 'presweathobs', 'presweathcodes', 'precip_wtr_mm', 'aerosol_opt_thousandths',
-                          'snowdepth_cm', 'days_last_snow', 'Albedo', 'liq_precip_depth_mm', 'liq_precip_rate_Hour']
+            epw_labels = [
+                "hour",
+                "drybulb_C",
+                "dewpoint_C",
+                "relhum_percent",
+                "atmos_Pa",
+                "exthorrad_Whm2",
+                "extdirrad_Whm2",
+                "horirsky_Whm2",
+                "glohorrad_Whm2",
+                "dirnorrad_Whm2",
+                "difhorrad_Whm2",
+                "glohorillum_lux",
+                "dirnorillum_lux",
+                "difhorillum_lux",
+                "zenlum_lux",
+                "winddir_deg",
+                "windspd_ms",
+                "totskycvr_tenths",
+                "opaqskycvr_tenths",
+                "visibility_km",
+                "ceiling_hgt_m",
+                "presweathobs",
+                "presweathcodes",
+                "precip_wtr_mm",
+                "aerosol_opt_thousandths",
+                "snowdepth_cm",
+                "days_last_snow",
+                "Albedo",
+                "liq_precip_depth_mm",
+                "liq_precip_rate_Hour",
+            ]
             self.weather_data = pd.read_csv(
-                epwfile_path, header=None, names=epw_labels)
+                epwfile_path, header=None, names=epw_labels
+            )
         else:
-            epw_labels = ['year', 'month', 'day', 'hour', 'minute', 'datasource', 'drybulb_C', 'dewpoint_C', 'relhum_percent',
-                          'atmos_Pa', 'exthorrad_Whm2', 'extdirrad_Whm2', 'horirsky_Whm2', 'glohorrad_Whm2',
-                          'dirnorrad_Whm2', 'difhorrad_Whm2', 'glohorillum_lux', 'dirnorillum_lux', 'difhorillum_lux',
-                          'zenlum_lux', 'winddir_deg', 'windspd_ms', 'totskycvr_tenths', 'opaqskycvr_tenths', 'visibility_km',
-                          'ceiling_hgt_m', 'presweathobs', 'presweathcodes', 'precip_wtr_mm', 'aerosol_opt_thousandths',
-                          'snowdepth_cm', 'days_last_snow', 'Albedo', 'liq_precip_depth_mm', 'liq_precip_rate_Hour']
+            epw_labels = [
+                "year",
+                "month",
+                "day",
+                "hour",
+                "minute",
+                "datasource",
+                "drybulb_C",
+                "dewpoint_C",
+                "relhum_percent",
+                "atmos_Pa",
+                "exthorrad_Whm2",
+                "extdirrad_Whm2",
+                "horirsky_Whm2",
+                "glohorrad_Whm2",
+                "dirnorrad_Whm2",
+                "difhorrad_Whm2",
+                "glohorillum_lux",
+                "dirnorillum_lux",
+                "difhorillum_lux",
+                "zenlum_lux",
+                "winddir_deg",
+                "windspd_ms",
+                "totskycvr_tenths",
+                "opaqskycvr_tenths",
+                "visibility_km",
+                "ceiling_hgt_m",
+                "presweathobs",
+                "presweathcodes",
+                "precip_wtr_mm",
+                "aerosol_opt_thousandths",
+                "snowdepth_cm",
+                "days_last_snow",
+                "Albedo",
+                "liq_precip_depth_mm",
+                "liq_precip_rate_Hour",
+            ]
             self.weather_data = pd.read_csv(
-                epwfile_path, skiprows=8, header=None, names=epw_labels).drop('datasource', axis=1)
-
+                epwfile_path, skiprows=8, header=None, names=epw_labels
+            ).drop("datasource", axis=1)
 
     def calc_sun_position(self, latitude_deg, longitude_deg, year, hoy):
         """
         Calculates the Sun Position for a specific hour and location
         :param latitude_deg: Geographical Latitude in Degrees

Check failure on line 143 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py#L86-L143

         day_of_year = utc_datetime.timetuple().tm_yday
 
         # Calculate the declination angle: The variation due to the earths tilt
         # http://www.pveducation.org/pvcdrom/properties-of-sunlight/declination-angle
         declination_rad = math.radians(
-            23.45 * math.sin((2 * math.pi / 365.0) * (day_of_year - 81)))
+            23.45 * math.sin((2 * math.pi / 365.0) * (day_of_year - 81))
+        )
 
         # Normalise the day to 2*pi
         # There is some reason as to why it is 364 and not 365.26
         angle_of_day = (day_of_year - 81) * (2 * math.pi / 364)
 
         # The deviation between local standard time and true solar time
-        equation_of_time = (9.87 * math.sin(2 * angle_of_day)) - \
-            (7.53 * math.cos(angle_of_day)) - (1.5 * math.sin(angle_of_day))
+        equation_of_time = (
+            (9.87 * math.sin(2 * angle_of_day))
+            - (7.53 * math.cos(angle_of_day))
+            - (1.5 * math.sin(angle_of_day))
+        )
 
         # True Solar Time
-        solar_time = ((utc_datetime.hour * 60) + utc_datetime.minute +
-                      (4 * longitude_deg) + equation_of_time) / 60.0
+        solar_time = (
+            (utc_datetime.hour * 60)
+            + utc_datetime.minute
+            + (4 * longitude_deg)
+            + equation_of_time
+        ) / 60.0
 
         # Angle between the local longitude and longitude where the sun is at
         # higher altitude
         hour_angle_rad = math.radians(15 * (12 - solar_time))
 
         # Altitude Position of the Sun in Radians
-        altitude_rad = math.asin(math.cos(latitude_rad) * math.cos(declination_rad) * math.cos(hour_angle_rad) +
-                                 math.sin(latitude_rad) * math.sin(declination_rad))
+        altitude_rad = math.asin(
+            math.cos(latitude_rad)
+            * math.cos(declination_rad)
+            * math.cos(hour_angle_rad)
+            + math.sin(latitude_rad) * math.sin(declination_rad)
+        )
 
         # Azimuth Position fo the sun in radians
         azimuth_rad = math.asin(
-            math.cos(declination_rad) * math.sin(hour_angle_rad) / math.cos(altitude_rad))
+            math.cos(declination_rad)
+            * math.sin(hour_angle_rad)
+            / math.cos(altitude_rad)
+        )
 
         # I don't really know what this code does, it has been imported from
         # PySolar
-        if(math.cos(hour_angle_rad) >= (math.tan(declination_rad) / math.tan(latitude_rad))):
+        if math.cos(hour_angle_rad) >= (
+            math.tan(declination_rad) / math.tan(latitude_rad)
+        ):
             return math.degrees(altitude_rad), math.degrees(azimuth_rad)
         else:
-            return math.degrees(altitude_rad), (180 - math.degrees(azimuth_rad))
+            return math.degrees(altitude_rad), (
+                180 - math.degrees(azimuth_rad)
+            )
 
 
 class Window(object):
     """docstring for Window"""
 
-    def __init__(self, azimuth_tilt, alititude_tilt=90, glass_solar_transmittance=0.7,
-                 glass_light_transmittance=0.8, area=1):
-
+    def __init__(
+        self,
+        azimuth_tilt,
+        alititude_tilt=90,
+        glass_solar_transmittance=0.7,
+        glass_light_transmittance=0.8,
+        area=1,
+    ):
         self.alititude_tilt_rad = math.radians(alititude_tilt)
         self.azimuth_tilt_rad = math.radians(azimuth_tilt)
         self.glass_solar_transmittance = glass_solar_transmittance
         self.glass_light_transmittance = glass_light_transmittance
         self.area = area
 
-    def calc_solar_gains(self, sun_altitude, sun_azimuth, normal_direct_radiation, horizontal_diffuse_radiation):
+    def calc_solar_gains(
+        self,
+        sun_altitude,
+        sun_azimuth,
+        normal_direct_radiation,
+        horizontal_diffuse_radiation,
+    ):
         """
         Calculates the Solar Gains in the building zone through the set Window
         :param sun_altitude: Altitude Angle of the Sun in Degrees
         :type sun_altitude: float
         :param sun_azimuth: Azimuth angle of the sun in degrees

Check failure on line 168 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py#L148-L168

         :return: self.incident_solar, Incident Solar Radiation on window
         :return: self.solar_gains - Solar gains in building after transmitting through the window
         :rtype: float
         """
 
-        direct_factor = self.calc_direct_solar_factor(sun_altitude, sun_azimuth,)
+        direct_factor = self.calc_direct_solar_factor(
+            sun_altitude,
+            sun_azimuth,
+        )
         diffuse_factor = self.calc_diffuse_solar_factor()
 
         direct_solar = direct_factor * normal_direct_radiation
         diffuse_solar = horizontal_diffuse_radiation * diffuse_factor
         self.incident_solar = (direct_solar + diffuse_solar) * self.area
 
         self.solar_gains = self.incident_solar * self.glass_solar_transmittance
 
-    def calc_illuminance(self, sun_altitude, sun_azimuth, normal_direct_illuminance, horizontal_diffuse_illuminance):
+    def calc_illuminance(
+        self,
+        sun_altitude,
+        sun_azimuth,
+        normal_direct_illuminance,
+        horizontal_diffuse_illuminance,
+    ):
         """
         Calculates the Illuminance in the building zone through the set Window
         :param sun_altitude: Altitude Angle of the Sun in Degrees
         :type sun_altitude: float
         :param sun_azimuth: Azimuth angle of the sun in degrees

Check failure on line 193 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py#L173-L193

         :return: self.incident_illuminance, Incident Illuminance on window [Lumens]
         :return: self.transmitted_illuminance - Illuminance in building after transmitting through the window [Lumens]
         :rtype: float
         """
 
-        direct_factor = self.calc_direct_solar_factor(sun_altitude, sun_azimuth,)
+        direct_factor = self.calc_direct_solar_factor(
+            sun_altitude,
+            sun_azimuth,
+        )
         diffuse_factor = self.calc_diffuse_solar_factor()
 
         direct_illuminance = direct_factor * normal_direct_illuminance
         diffuse_illuminance = diffuse_factor * horizontal_diffuse_illuminance
 
         self.incident_illuminance = (
-            direct_illuminance + diffuse_illuminance) * self.area
-        self.transmitted_illuminance = self.incident_illuminance * \
-            self.glass_light_transmittance
+            direct_illuminance + diffuse_illuminance
+        ) * self.area
+        self.transmitted_illuminance = (
+            self.incident_illuminance * self.glass_light_transmittance
+        )
 
     def calc_direct_solar_factor(self, sun_altitude, sun_azimuth):
         """
         Calculates the cosine of the angle of incidence on the window
         """

Check failure on line 212 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py#L196-L212

         """
         Proportion of the radiation incident on the window (cos of the incident ray)
         ref:Quaschning, Volker, and Rolf Hanitsch. "Shade calculations in photovoltaic systems."
         ISES Solar World Conference, Harare. 1995.
         """
-        direct_factor = math.cos(sun_altitude_rad) * math.sin(self.alititude_tilt_rad) * \
-            math.cos(sun_azimuth_rad - self.azimuth_tilt_rad) + \
-            math.sin(sun_altitude_rad) * math.cos(self.alititude_tilt_rad)
+        direct_factor = math.cos(sun_altitude_rad) * math.sin(
+            self.alititude_tilt_rad
+        ) * math.cos(sun_azimuth_rad - self.azimuth_tilt_rad) + math.sin(
+            sun_altitude_rad
+        ) * math.cos(
+            self.alititude_tilt_rad
+        )
 
         # If the sun is in front of the window surface
-        if(math.degrees(math.acos(direct_factor)) > 90):
+        if math.degrees(math.acos(direct_factor)) > 90:
             direct_factor = 0
 
         else:
             pass
 

Check failure on line 222 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/calculate_gain_by_Sun.py#L215-L222

         """Calculates the proportion of diffuse radiation"""
         # Proportion of incident light on the window surface
         return (1 + math.cos(self.alititude_tilt_rad)) / 2
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     pass

Check failure on line 19 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py#L9-L19

 from tabula_reader import Building
 
 import oemof.solph as solph
 from oemof.solph import views
 from oemof.tools import logger
+
 """
 General description
 -------------------
 This examples optimizes the internal building temperature.
 It is suppose to show how to use the component GenericBuilding.

Check failure on line 85 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py#L29-L85

 """
 
 __copyright__ = "oemof developer group"
 __license__ = "MIT"
 
+
 def main():
     #  create solver
     solver = "cbc"  # 'glpk', 'gurobi',....
     debug = False  # Set number_of_timesteps to 3 to get a readable lp-file.
     solver_verbose = False  # show/hide solver output
     number_of_time_steps = 8760
-    mainPath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
-
-    #Generates 5RC Building-Model
+    mainPath = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+
+    # Generates 5RC Building-Model
     building_status = "no_refurbishment"
     if building_status == "no_refurbishment":
-        building_example = Building (tabula_building_code ='DE.N.SFH.04.Gen.ReEx.001.001',
-                                     class_building = "average",
-                                     number_of_time_steps=number_of_time_steps)
+        building_example = Building(
+            tabula_building_code="DE.N.SFH.04.Gen.ReEx.001.001",
+            class_building="average",
+            number_of_time_steps=number_of_time_steps,
+        )
     elif building_status == "usual_refurbishment":
-        building_example = Building (tabula_building_code ='DE.N.SFH.04.Gen.ReEx.001.002',
-                                     class_building = "average",
-                                     number_of_time_steps=number_of_time_steps)
+        building_example = Building(
+            tabula_building_code="DE.N.SFH.04.Gen.ReEx.001.002",
+            class_building="average",
+            number_of_time_steps=number_of_time_steps,
+        )
     elif building_status == "advanced_refurbishment":
-        building_example = Building (tabula_building_code ='DE.N.SFH.04.Gen.ReEx.001.003',
-                                     class_building = "average",
-                                     number_of_time_steps=number_of_time_steps)
+        building_example = Building(
+            tabula_building_code="DE.N.SFH.04.Gen.ReEx.001.003",
+            class_building="average",
+            number_of_time_steps=number_of_time_steps,
+        )
     building_example.calculate_all_parameters()
 
     # Pre-Calculation of solar gains with weather_data and building_data
-    Mannheim = calculate_gain_by_Sun.Location(mannheim=True, epwfile_path=os.path.join(mainPath, 'thermal_building_model', 'DEU_BW_Mannheim_107290_TRY2010_12_Jahr_BBSR.csv'))
-    solar_gains = building_example.calc_solar_gaings_through_windows(object_location_of_building = Mannheim)
-    t_outside = pd.read_csv(os.path.join(mainPath, 'thermal_building_model', 'DEU_BW_Mannheim_107290_TRY2010_12_Jahr_BBSR.csv') ,header=None)[1].tolist()
+    Mannheim = calculate_gain_by_Sun.Location(
+        mannheim=True,
+        epwfile_path=os.path.join(
+            mainPath,
+            "thermal_building_model",
+            "DEU_BW_Mannheim_107290_TRY2010_12_Jahr_BBSR.csv",
+        ),
+    )
+    solar_gains = building_example.calc_solar_gaings_through_windows(
+        object_location_of_building=Mannheim
+    )
+    t_outside = pd.read_csv(
+        os.path.join(
+            mainPath,
+            "thermal_building_model",
+            "DEU_BW_Mannheim_107290_TRY2010_12_Jahr_BBSR.csv",
+        ),
+        header=None,
+    )[1].tolist()
 
     # Internal gains of residents, machines (f.e. fridge, computer,...) and lights have to be added manually
-    internal_gains=[]
+    internal_gains = []
     for _ in range(number_of_time_steps):
         internal_gains.append(0)
     # initiate the logger (see the API docs for more information)
     logger.define_logging(
         logfile="oemof_example.log",
         screen_level=logging.INFO,
         file_level=logging.INFO,
     )
 
     logging.info("Initialize the energy system")
-    date_time_index = solph.create_time_index(2012,
-                                              number=number_of_time_steps)
-    es = solph.EnergySystem(timeindex=date_time_index,
-                            infer_last_interval=False)
-
+    date_time_index = solph.create_time_index(
+        2012, number=number_of_time_steps
+    )
+    es = solph.EnergySystem(
+        timeindex=date_time_index, infer_last_interval=False
+    )
 
     b_heat = solph.buses.Bus(label="b_heat")
     es.add(b_heat)
     b_cool = solph.buses.Bus(label="b_cool")
     es.add(b_cool)

Check failure on line 137 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py#L88-L137

     b_elect = solph.buses.Bus(label="electricity_from_grid")
     es.add(b_elect)
     building_temp = solph.buses.Bus(label="building_temp")
     es.add(building_temp)
 
-    es.add(solph.components.Source(
+    es.add(
+        solph.components.Source(
             label="elect_from_grid",
             outputs={b_elect: solph.flows.Flow(variable_costs=30)},
         )
     )
 
-    es.add(solph.components.Sink(
+    es.add(
+        solph.components.Sink(
             label="elect_into_grid",
             inputs={b_elect: solph.flows.Flow(variable_costs=10)},
         )
     )
 
     es.add(
         solph.components.Transformer(
             label="ElectricalHeater",
             inputs={b_elect: solph.flows.Flow()},
             outputs={b_heat: solph.flows.Flow(nominal_value=65000)},
-            conversion_factors={b_elect: 1}
+            conversion_factors={b_elect: 1},
         )
     )
     es.add(
         solph.components.Transformer(
             label="ElectricalCooler",
             inputs={b_cool: solph.flows.Flow()},
             outputs={b_elect: solph.flows.Flow(nominal_value=65000)},
-            conversion_factors={b_elect: 1}
+            conversion_factors={b_elect: 1},
         )
     )
 
     es.add(
         solph.components.experimental.GenericBuilding(
             label="GenericBuilding",
-            inputs={b_heat: solph.flows.Flow(variable_costs=0) },
-            outputs={b_cool: solph.flows.Flow(variable_costs=0) },
+            inputs={b_heat: solph.flows.Flow(variable_costs=0)},
+            outputs={b_cool: solph.flows.Flow(variable_costs=0)},
             solar_gains=solar_gains,
             t_outside=t_outside,
             internal_gains=internal_gains,
             t_set_heating=20,
-            t_set_cooling = 30,
+            t_set_cooling=30,
             building_config=building_example.building_config,
             t_inital=20,
         )
     )
 

Check failure on line 202 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/thermal_building_model.py#L168-L202

     es.results["meta"] = solph.processing.meta_results(model)
     results = es.results["main"]
     custom_building = views.node(results, "GenericBuilding")
 
     fig, ax = plt.subplots(figsize=(10, 5))
-    custom_building['sequences'][(('GenericBuilding', 'None'), 't_air')].plot(
+    custom_building["sequences"][(("GenericBuilding", "None"), "t_air")].plot(
         ax=ax, kind="line", drawstyle="steps-post"
     )
 
     ax.set_ylabel("t_air in Celsius")
     plt.show()
 
     fig, ax = plt.subplots(figsize=(10, 5))
     custom_building = views.node(results, "GenericBuilding")
-    custom_building['sequences'][(('b_heat', 'GenericBuilding'), 'flow')].plot(
+    custom_building["sequences"][(("b_heat", "GenericBuilding"), "flow")].plot(
         ax=ax, kind="line", drawstyle="steps-post"
     )
     ax.set_ylabel("heat demand in Watt")
 
     fig, ax = plt.subplots(figsize=(10, 5))
     custom_building = views.node(results, "GenericBuilding")
-    custom_building['sequences'][(('GenericBuilding', 'b_cool'), 'flow')].plot(
+    custom_building["sequences"][(("GenericBuilding", "b_cool"), "flow")].plot(
         ax=ax, kind="line", drawstyle="steps-post"
     )
     ax.set_ylabel("cooling demand in Watt")
     plt.show()
 
     # print the solver results
     print("********* Meta results *********")
     pp.pprint(es.results["meta"])
     print("")
 
+
 if __name__ == "__main__":
     main()

Check failure on line 18 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py#L4-L18

 
 """
 import pandas as pd
 from calculate_gain_by_Sun import Location
 from calculate_gain_by_Sun import Window
-from  dataclasses import dataclass
+from dataclasses import dataclass
 import os
-mainPath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
-tabula_df = pd.DataFrame(pd.read_csv(os.path.join(mainPath, 'thermal_building_model', 'tabula_data_sorted.csv'),low_memory=False))
+
+mainPath = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+tabula_df = pd.DataFrame(
+    pd.read_csv(
+        os.path.join(
+            mainPath, "thermal_building_model", "tabula_data_sorted.csv"
+        ),
+        low_memory=False,
+    )
+)
+
 
 @dataclass
 class BuildingConfig:
     r"""
     The BuildingConfig gets generated by the function build_building_config of the building class

Check failure on line 216 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py#L41-L216

     Notes
     -----
     Examples
     --------
     """
-    total_internal_area : float
-    h_ve : float
-    h_tr_w : float
+    total_internal_area: float
+    h_ve: float
+    h_tr_w: float
     h_tr_em: float
-    h_tr_is : float
-    mass_area : float
-    h_tr_ms : float
-    c_m : float
-    floor_area : float
-    heat_transfer_coefficient_ventilation : float
-    total_air_change_rate : float
+    h_tr_is: float
+    mass_area: float
+    h_tr_ms: float
+    c_m: float
+    floor_area: float
+    heat_transfer_coefficient_ventilation: float
+    total_air_change_rate: float
+
 
 class Building:
-    def __init__(self,
-                 tabula_building_code : str,
-                 class_building : str,
-                 number_of_time_steps : float):
+    def __init__(
+        self,
+        tabula_building_code: str,
+        class_building: str,
+        number_of_time_steps: float,
+    ):
         self.tabula_building_code = tabula_building_code
         self.class_building = class_building
         self.number_of_time_steps = number_of_time_steps
         # DIN 13790: 12.3.1.2
-        self.list_class_buildig = {"very light": {"a_m_var": 2.5, "c_m_var": 80000},
-                                   "light": {"a_m_var": 2.5, "c_m_var": 110000},
-                                   "average": {"a_m_var": 2.5, "c_m_var": 165000},
-                                   "heavy": {"a_m_var": 3.0, "c_m_var": 260000},
-                                   "very heavy": {"a_m_var": 3.0, "c_m_var": 370000}}
+        self.list_class_buildig = {
+            "very light": {"a_m_var": 2.5, "c_m_var": 80000},
+            "light": {"a_m_var": 2.5, "c_m_var": 110000},
+            "average": {"a_m_var": 2.5, "c_m_var": 165000},
+            "heavy": {"a_m_var": 3.0, "c_m_var": 260000},
+            "very heavy": {"a_m_var": 3.0, "c_m_var": 370000},
+        }
         self.building_config = {}
 
     def calculate_all_parameters(self):
         self.get_building_parameters_from_csv()
-        self.total_internal_area : float = self.calc_internal_area()
-        self.h_ve : float = self.calc_h_ve()
-        self.h_tr_w : float = self.calc_h_tr_w()
-        self.h_tr_em : float = self.calc_h_tr_em()
-        self.h_tr_is : float = self.calf_h_tr_is()
-        self.mass_area : float = self.calc_mass_area()
-        self.h_tr_ms : float= self.calf_h_tr_ms()
-        self.c_m : float = self.calc_c_m()
-        #self.solar_gains : list  = self.calc_solar_gaings_through_windows()
+        self.total_internal_area: float = self.calc_internal_area()
+        self.h_ve: float = self.calc_h_ve()
+        self.h_tr_w: float = self.calc_h_tr_w()
+        self.h_tr_em: float = self.calc_h_tr_em()
+        self.h_tr_is: float = self.calf_h_tr_is()
+        self.mass_area: float = self.calc_mass_area()
+        self.h_tr_ms: float = self.calf_h_tr_ms()
+        self.c_m: float = self.calc_c_m()
+        # self.solar_gains : list  = self.calc_solar_gaings_through_windows()
         self.building_config = self.build_building_config()
 
     def build_building_config(self):
-        building_config = BuildingConfig(total_internal_area = self.total_internal_area,
-                           h_ve = self.h_ve ,
-                           h_tr_w = self.h_tr_w ,
-                           h_tr_em = self.h_tr_em ,
-                           h_tr_is = self.h_tr_is ,
-                           mass_area = self.mass_area ,
-                           h_tr_ms = self.h_tr_ms ,
-                           c_m = self.c_m ,
-                           floor_area = self.floor_area ,
-                           heat_transfer_coefficient_ventilation = self.heat_transfer_coefficient_ventilation,
-                           #solar_gains = self.solar_gains,
-                           total_air_change_rate = self.total_air_change_rate)
+        building_config = BuildingConfig(
+            total_internal_area=self.total_internal_area,
+            h_ve=self.h_ve,
+            h_tr_w=self.h_tr_w,
+            h_tr_em=self.h_tr_em,
+            h_tr_is=self.h_tr_is,
+            mass_area=self.mass_area,
+            h_tr_ms=self.h_tr_ms,
+            c_m=self.c_m,
+            floor_area=self.floor_area,
+            heat_transfer_coefficient_ventilation=self.heat_transfer_coefficient_ventilation,
+            # solar_gains = self.solar_gains,
+            total_air_change_rate=self.total_air_change_rate,
+        )
         return building_config
 
     def get_building_parameters_from_csv(self):
-        row = tabula_df.loc[tabula_df["Code_BuildingVariant"] == self.tabula_building_code]
-        building_volume = row["V_C"].values[0] #room_vol
-        list_type = ["" , "Measure_" , "Actual_"]
-        t_b = list_type [1]
-        self.opaque_elements = ["wall", "roof", "floor" ]
-
-        self.a_roof = {"a_roof_1" : float(row["A_Roof_1"].values[0]),
-                       "a_roof_2" : float(row["A_Roof_2"].values[0])}
-        self.u_roof = {"u_roof_1" : float(row["U_"+str(t_b)+"Roof_1"].values[0]),
-                       "u_roof_2" : float(row["U_"+str(t_b)+"Roof_2"].values[0])}
-        self.b_roof = {"b_roof_1" : float(row["b_Transmission_Roof_1"].values[0]),
-                       "b_roof_2" : float(row["b_Transmission_Roof_2"].values[0])}
-
-        self.a_floor = {"a_floor_1" : float(row["A_Floor_1"].values[0]),
-                        "a_floor_2" : float(row["A_Floor_2"].values[0])}
-        self.u_floor = {"u_floor_1" : float(row["U_"+str(t_b)+"Floor_1"].values[0]),
-                        "u_floor_2" : float(row["U_"+str(t_b)+"Floor_2"].values[0])}
-        self.b_floor = {"b_floor_1" : float(row["b_Transmission_Floor_1"].values[0]),
-                        "b_floor_2" : float(row["b_Transmission_Floor_2"].values[0])}
-
-        self.a_wall = {"a_wall_1" : float(row["A_Wall_1"].values[0]),
-                       "a_wall_2" : float(row["A_Wall_2"].values[0]),
-                       "a_wall_3" : float(row["A_Wall_3"].values[0])}
-        self.u_wall = {"u_wall_1" : float(row["U_"+str(t_b)+"Wall_1"].values[0]),
-                       "u_wall_2" : float(row["U_"+str(t_b)+"Wall_2"].values[0]),
-                       "u_wall_3" : float(row["U_"+str(t_b)+"Wall_3"].values[0])}
-        self.b_wall = {"b_wall_1" : float(row["b_Transmission_Wall_1"].values[0]),
-                       "b_wall_2" : float(row["b_Transmission_Wall_2"].values[0]),
-                       "b_wall_3" : float(row["b_Transmission_Wall_3"].values[0])}
-
-        self.a_door = {"a_door_1" : float(row["A_Door_1"].values[0])}
-        self.u_door = {"u_door_1" : float(row["U_"+str(t_b)+"Door_1"].values[0])}
-
-        self.a_window = {"a_window_1" : float(row["A_Window_1"].values[0]),
-                         "a_window_2" : float(row["A_Window_2"].values[0])}
-        self.a_window_specific = {"a_window_horizontal" : float(row["A_Window_Horizontal"].values[0]),
-                                  "a_window_east" : float(row["A_Window_East"].values[0]),
-                                  "a_window_south" : float(row["A_Window_South"].values[0]),
-                                  "a_window_west" : float(row["A_Window_West"].values[0]),
-                                  "a_window_north" : float(row["A_Window_North"].values[0])}
-        self.delta_u_thermal_bridiging = {"delta_u_thermal_bridiging" : float(row["delta_U_ThermalBridging"].values[0])}
-        self.u_window = {"u_window_1" : float(row["U_"+str(t_b)+"Window_1"].values[0]),
-                         "u_window_2" : float(row["U_"+str(t_b)+"Window_2"].values[0])}
-
-        self.g_gl_n_window =  {"g_gl_n_window_1" : float(row["g_gl_n_"+str(t_b)+"Window_1"].values[0]),
-                               "g_gl_n_window_2" : float(row["g_gl_n_"+str(t_b)+"Window_2"].values[0])}
+        row = tabula_df.loc[
+            tabula_df["Code_BuildingVariant"] == self.tabula_building_code
+        ]
+        building_volume = row["V_C"].values[0]  # room_vol
+        list_type = ["", "Measure_", "Actual_"]
+        t_b = list_type[1]
+        self.opaque_elements = ["wall", "roof", "floor"]
+
+        self.a_roof = {
+            "a_roof_1": float(row["A_Roof_1"].values[0]),
+            "a_roof_2": float(row["A_Roof_2"].values[0]),
+        }
+        self.u_roof = {
+            "u_roof_1": float(row["U_" + str(t_b) + "Roof_1"].values[0]),
+            "u_roof_2": float(row["U_" + str(t_b) + "Roof_2"].values[0]),
+        }
+        self.b_roof = {
+            "b_roof_1": float(row["b_Transmission_Roof_1"].values[0]),
+            "b_roof_2": float(row["b_Transmission_Roof_2"].values[0]),
+        }
+
+        self.a_floor = {
+            "a_floor_1": float(row["A_Floor_1"].values[0]),
+            "a_floor_2": float(row["A_Floor_2"].values[0]),
+        }
+        self.u_floor = {
+            "u_floor_1": float(row["U_" + str(t_b) + "Floor_1"].values[0]),
+            "u_floor_2": float(row["U_" + str(t_b) + "Floor_2"].values[0]),
+        }
+        self.b_floor = {
+            "b_floor_1": float(row["b_Transmission_Floor_1"].values[0]),
+            "b_floor_2": float(row["b_Transmission_Floor_2"].values[0]),
+        }
+
+        self.a_wall = {
+            "a_wall_1": float(row["A_Wall_1"].values[0]),
+            "a_wall_2": float(row["A_Wall_2"].values[0]),
+            "a_wall_3": float(row["A_Wall_3"].values[0]),
+        }
+        self.u_wall = {
+            "u_wall_1": float(row["U_" + str(t_b) + "Wall_1"].values[0]),
+            "u_wall_2": float(row["U_" + str(t_b) + "Wall_2"].values[0]),
+            "u_wall_3": float(row["U_" + str(t_b) + "Wall_3"].values[0]),
+        }
+        self.b_wall = {
+            "b_wall_1": float(row["b_Transmission_Wall_1"].values[0]),
+            "b_wall_2": float(row["b_Transmission_Wall_2"].values[0]),
+            "b_wall_3": float(row["b_Transmission_Wall_3"].values[0]),
+        }
+
+        self.a_door = {"a_door_1": float(row["A_Door_1"].values[0])}
+        self.u_door = {
+            "u_door_1": float(row["U_" + str(t_b) + "Door_1"].values[0])
+        }
+
+        self.a_window = {
+            "a_window_1": float(row["A_Window_1"].values[0]),
+            "a_window_2": float(row["A_Window_2"].values[0]),
+        }
+        self.a_window_specific = {
+            "a_window_horizontal": float(row["A_Window_Horizontal"].values[0]),
+            "a_window_east": float(row["A_Window_East"].values[0]),
+            "a_window_south": float(row["A_Window_South"].values[0]),
+            "a_window_west": float(row["A_Window_West"].values[0]),
+            "a_window_north": float(row["A_Window_North"].values[0]),
+        }
+        self.delta_u_thermal_bridiging = {
+            "delta_u_thermal_bridiging": float(
+                row["delta_U_ThermalBridging"].values[0]
+            )
+        }
+        self.u_window = {
+            "u_window_1": float(row["U_" + str(t_b) + "Window_1"].values[0]),
+            "u_window_2": float(row["U_" + str(t_b) + "Window_2"].values[0]),
+        }
+
+        self.g_gl_n_window = {
+            "g_gl_n_window_1": float(
+                row["g_gl_n_" + str(t_b) + "Window_1"].values[0]
+            ),
+            "g_gl_n_window_2": float(
+                row["g_gl_n_" + str(t_b) + "Window_2"].values[0]
+            ),
+        }
 
         self.floor_area = float(row["A_C_Ref"].values[0])
-        self.heat_transfer_coefficient_ventilation = float(row["h_Ventilation"].values[0])
+        self.heat_transfer_coefficient_ventilation = float(
+            row["h_Ventilation"].values[0]
+        )
 
         # References to check results
-        self.q_transmission_losses_annual = float(row["q_ht_tr"].values[0] * self.floor_area) #[kWh/a)]
-        self.q_ventilation_losses_annual = float(row["q_ht_ve"].values[0] * self.floor_area) #[kWh/a)]
-        self.q_total_losses_annual = float(row["q_ht"].values[0]) #[kWh/(m²a)]
-        self.q_solar_gains_annual = float (row["q_sol"].values[0]) #[kWh/(m²a)]
-        self.q_internal_gains_annual = float(row["q_int"].values[0]) #[kWh/(m²a)]
-        self.q_internal_gains_annual = float(row["q_int"].values[0])  # [kWh/(m²a)]
-        self.total_air_change_rate = float(row["n_air_use"] + row["n_air_infiltration"]) # [1/h]
-        self.room_height = float(row["h_room"])   # [m]
-        self.q_total_losses = float (row["q_ht"] * self.floor_area) # [kWh/a]
-        self.q_heating_demand_annual = float(row["q_h_nd"] * self.floor_area)  # [kWh/a]
-        self.h_transmission = float(row["h_Transmission"] * self.floor_area)   # [W/K]
-        self.h_ventilation = float (row["h_Ventilation"] * self.floor_area) # [W/K]
+        self.q_transmission_losses_annual = float(
+            row["q_ht_tr"].values[0] * self.floor_area
+        )  # [kWh/a)]
+        self.q_ventilation_losses_annual = float(
+            row["q_ht_ve"].values[0] * self.floor_area
+        )  # [kWh/a)]
+        self.q_total_losses_annual = float(
+            row["q_ht"].values[0]
+        )  # [kWh/(m²a)]
+        self.q_solar_gains_annual = float(
+            row["q_sol"].values[0]
+        )  # [kWh/(m²a)]
+        self.q_internal_gains_annual = float(
+            row["q_int"].values[0]
+        )  # [kWh/(m²a)]
+        self.q_internal_gains_annual = float(
+            row["q_int"].values[0]
+        )  # [kWh/(m²a)]
+        self.total_air_change_rate = float(
+            row["n_air_use"] + row["n_air_infiltration"]
+        )  # [1/h]
+        self.room_height = float(row["h_room"])  # [m]
+        self.q_total_losses = float(row["q_ht"] * self.floor_area)  # [kWh/a]
+        self.q_heating_demand_annual = float(
+            row["q_h_nd"] * self.floor_area
+        )  # [kWh/a]
+        self.h_transmission = float(
+            row["h_Transmission"] * self.floor_area
+        )  # [W/K]
+        self.h_ventilation = float(
+            row["h_Ventilation"] * self.floor_area
+        )  # [W/K]
 
     def calc_internal_area(self):
         # DIN 7.2.2.2
-        var_at = 4.5 # the dimensionless ratio between the surface area of all surfaces facing into the room and the useful area.
+        var_at = 4.5  # the dimensionless ratio between the surface area of all surfaces facing into the room and the useful area.
         total_internal_area = self.floor_area * var_at
         return total_internal_area
 
     def calc_h_tr_em(self):
-        h_tr_em=0
-        a_external=0
-        for x in range(1,len(self.a_wall)+1):
-            h_tr_em = h_tr_em + self.a_wall["a_wall_"+str(x)] *  self.u_wall["u_wall_"+str(x)] * self.b_wall["b_wall_"+str(x)]
-            a_external = a_external + self.a_wall["a_wall_"+str(x)]
-
-        for x in range(1,len(self.a_roof)+1):
-            h_tr_em = h_tr_em + self.a_roof["a_roof_"+str(x)] *  self.u_roof["u_roof_"+str(x)] * self.b_roof["b_roof_"+str(x)]
-            a_external = a_external + self.a_roof["a_roof_"+str(x)]
-
-        for x in range(1,len(self.a_floor)+1):
-            h_tr_em = h_tr_em + self.a_floor["a_floor_"+str(x)] *  self.u_floor["u_floor_"+str(x)] * self.b_floor["b_floor_"+str(x)]
-            a_external = a_external + self.a_floor["a_floor_"+str(x)]
+        h_tr_em = 0
+        a_external = 0
+        for x in range(1, len(self.a_wall) + 1):
+            h_tr_em = (
+                h_tr_em
+                + self.a_wall["a_wall_" + str(x)]
+                * self.u_wall["u_wall_" + str(x)]
+                * self.b_wall["b_wall_" + str(x)]
+            )
+            a_external = a_external + self.a_wall["a_wall_" + str(x)]
+
+        for x in range(1, len(self.a_roof) + 1):
+            h_tr_em = (
+                h_tr_em
+                + self.a_roof["a_roof_" + str(x)]
+                * self.u_roof["u_roof_" + str(x)]
+                * self.b_roof["b_roof_" + str(x)]
+            )
+            a_external = a_external + self.a_roof["a_roof_" + str(x)]
+
+        for x in range(1, len(self.a_floor) + 1):
+            h_tr_em = (
+                h_tr_em
+                + self.a_floor["a_floor_" + str(x)]
+                * self.u_floor["u_floor_" + str(x)]
+                * self.b_floor["b_floor_" + str(x)]
+            )
+            a_external = a_external + self.a_floor["a_floor_" + str(x)]
 
         for x in range(1, len(self.a_door) + 1):
-            h_tr_em = h_tr_em + self.a_door["a_door_" + str(x)] * self.u_door["u_door_" + str(x)]
+            h_tr_em = (
+                h_tr_em
+                + self.a_door["a_door_" + str(x)]
+                * self.u_door["u_door_" + str(x)]
+            )
             a_external = a_external + self.a_door["a_door_" + str(x)]
-        h_tr_em = h_tr_em + self.delta_u_thermal_bridiging["delta_u_thermal_bridiging"] * a_external
-        return h_tr_em #[W/K]
+        h_tr_em = (
+            h_tr_em
+            + self.delta_u_thermal_bridiging["delta_u_thermal_bridiging"]
+            * a_external
+        )
+        return h_tr_em  # [W/K]
 
     def calc_h_tr_w(self):
-        h_tr_w= 0
-        a_window= 0
-        for x in range(1,len(self.a_window)+1):
-            h_tr_w = h_tr_w + self.a_window["a_window_"+str(x)] *  self.u_window["u_window_"+str(x)]
-            a_window = a_window * self.a_window["a_window_"+str(x)]
-        h_tr_w = h_tr_w + self.delta_u_thermal_bridiging["delta_u_thermal_bridiging"] * a_window
-        return h_tr_w #[W/K]
+        h_tr_w = 0
+        a_window = 0
+        for x in range(1, len(self.a_window) + 1):
+            h_tr_w = (
+                h_tr_w
+                + self.a_window["a_window_" + str(x)]
+                * self.u_window["u_window_" + str(x)]
+            )
+            a_window = a_window * self.a_window["a_window_" + str(x)]
+        h_tr_w = (
+            h_tr_w
+            + self.delta_u_thermal_bridiging["delta_u_thermal_bridiging"]
+            * a_window
+        )
+        return h_tr_w  # [W/K]
 
     def calc_h_ve(self):
         # Determine the ventilation conductance, based on DIN13790 9.3.1
-        air_cap_vol_heat= 1200 #volume-related heat storage capacity of the air in [J/(m^3 * K)]
-        total_air_change_per_hour = self.total_air_change_rate * self.room_height * self.floor_area#[m^3 / h]
-
-        h_ve = (air_cap_vol_heat / 3600) *total_air_change_per_hour #[W/K]
+        air_cap_vol_heat = 1200  # volume-related heat storage capacity of the air in [J/(m^3 * K)]
+        total_air_change_per_hour = (
+            self.total_air_change_rate * self.room_height * self.floor_area
+        )  # [m^3 / h]
+
+        h_ve = (air_cap_vol_heat / 3600) * total_air_change_per_hour  # [W/K]
         return h_ve
-        '''
+        """
         # Determine the ventilation conductance, based on RC-Repository
         ach_vent = 1.5
         ach_infl = 0.5
         ventilation_efficiency = 0.6
         ach_tot = ach_infl + ach_vent  # Total Air Changes Per Hour

Check failure on line 228 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py#L217-L228

         # [ISO: E -27]
         b_ek = (1 - (ach_vent / (ach_tot)) * ventilation_efficiency)
         self.h_ve_adj = 1200 * b_ek * self.room_vol * \
             (ach_tot / 3600)  # Conductance through ventilation [W/M]
 
-        '''
+        """
         return h_ve
 
     def calf_h_tr_ms(self):
         h_tr_ms = 9.1 * self.mass_area
         return h_tr_ms

Check failure on line 277 in /home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/examples/thermal_building_model/tabula_reader.py#L230-L277

         h_tr_is = 3.45 * self.total_internal_area
         return h_tr_is
 
     def calc_mass_area(self):
         # Based on ISO standard 12.3.1.2
-        mass_area = self.floor_area * self.list_class_buildig[self.class_building]["a_m_var"]
+        mass_area = (
+            self.floor_area
+            * self.list_class_buildig[self.class_building]["a_m_var"]
+        )
         return mass_area
 
     def calc_c_m(self):
         # [kWh/K] Room Capacitance. Based on ISO standard 12.3.1.2
-        c_m = self.floor_area * self.list_class_buildig[self.class_building]["c_m_var"]
+        c_m = (
+            self.floor_area
+            * self.list_class_buildig[self.class_building]["c_m_var"]
+        )
         return c_m
 
     def calc_solar_gaings_through_windows(self, object_location_of_building):
         a_window_total = 0
         g_gl_n_window_avg = 0
-        for x in range(1,len(self.u_window)+1):
-            a_window_total = a_window_total + self.a_window["a_window_"+str(x)]
-
-        for x in range(1,len(self.g_gl_n_window)+1):
-            g_gl_n_window_avg =g_gl_n_window_avg + (self.g_gl_n_window["g_gl_n_window_" + str(x)] * self.a_window["a_window_"+str(x)]) / a_window_total
-
-        compass_directions = {"north" : { "azimuth_tilt": 270 , "alititude_tilt":90},
-                              "east" : { "azimuth_tilt": 90 , "alititude_tilt":90},
-                              "south" : { "azimuth_tilt": 180 , "alititude_tilt":90},
-                              "west" : { "azimuth_tilt": 0 , "alititude_tilt":90},
-                              "horizontal" : { "azimuth_tilt": 0 , "alititude_tilt":0}}
-        list_solar_gains=[]
+        for x in range(1, len(self.u_window) + 1):
+            a_window_total = (
+                a_window_total + self.a_window["a_window_" + str(x)]
+            )
+
+        for x in range(1, len(self.g_gl_n_window) + 1):
+            g_gl_n_window_avg = (
+                g_gl_n_window_avg
+                + (
+                    self.g_gl_n_window["g_gl_n_window_" + str(x)]
+                    * self.a_window["a_window_" + str(x)]
+                )
+                / a_window_total
+            )
+
+        compass_directions = {
+            "north": {"azimuth_tilt": 270, "alititude_tilt": 90},
+            "east": {"azimuth_tilt": 90, "alititude_tilt": 90},
+            "south": {"azimuth_tilt": 180, "alititude_tilt": 90},
+            "west": {"azimuth_tilt": 0, "alititude_tilt": 90},
+            "horizontal": {"azimuth_tilt": 0, "alititude_tilt": 0},
+        }
+        list_solar_gains = []
         for hour in range(self.number_of_time_steps):
-            sum_solar_gains=0
+            sum_solar_gains = 0
             for x in compass_directions:
-                altitude, azimuth = object_location_of_building.calc_sun_position(
-                    latitude_deg=48.16, longitude_deg=46.38, year=2015, hoy=hour)
+                (
+                    altitude,
+                    azimuth,
+                ) = object_location_of_building.calc_sun_position(
+                    latitude_deg=48.16,
+                    longitude_deg=46.38,
+                    year=2015,
+                    hoy=hour,
+                )
                 azimuth_tilt = compass_directions[x]["azimuth_tilt"]
                 alititude_tilt = compass_directions[x]["alititude_tilt"]
-                window_var = Window (azimuth_tilt=azimuth_tilt, alititude_tilt=alititude_tilt,
-                                     glass_solar_transmittance=g_gl_n_window_avg,
-                                     glass_light_transmittance=0.8, area=self.a_window_specific["a_window_" + str(x)])
-
-                window_var.calc_solar_gains(sun_altitude=altitude, sun_azimuth=azimuth,
-                                                 normal_direct_radiation=object_location_of_building.weather_data[
-                                                     'dirnorrad_Whm2'][hour],
-                                                 horizontal_diffuse_radiation=object_location_of_building.weather_data['difhorrad_Whm2'][hour])
+                window_var = Window(
+                    azimuth_tilt=azimuth_tilt,
+                    alititude_tilt=alititude_tilt,
+                    glass_solar_transmittance=g_gl_n_window_avg,
+                    glass_light_transmittance=0.8,
+                    area=self.a_window_specific["a_window_" + str(x)],
+                )
+
+                window_var.calc_solar_gains(
+                    sun_altitude=altitude,
+                    sun_azimuth=azimuth,
+                    normal_direct_radiation=object_location_of_building.weather_data[
+                        "dirnorrad_Whm2"
+                    ][
+                        hour
+                    ],
+                    horizontal_diffuse_radiation=object_location_of_building.weather_data[
+                        "difhorrad_Whm2"
+                    ][
+                        hour
+                    ],
+                )
                 sum_solar_gains = window_var.solar_gains + sum_solar_gains
             list_solar_gains.append(sum_solar_gains)
         return list_solar_gains
-

Check failure on line 20 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/__init__.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/__init__.py#L9-L20

 
 from ._generic_caes import GenericCAES
 from ._piecewise_linear_converter import PiecewiseLinearConverter
 from ._sink_dsm import SinkDSM
 from ._generic_building import GenericBuilding
+
 __all__ = [
     "GenericCAES",
     "PiecewiseLinearConverter",
     "SinkDSM",
-    "GenericBuilding"
+    "GenericBuilding",
 ]

Check failure on line 107 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py#L83-L107

         solar_gains: List,
         internal_gains: List,
         inputs=None,
         outputs=None,
         phi_m_tot: float = 0,
-        t_set_heating : float = 20,
+        t_set_heating: float = 20,
         t_set_cooling: float = 40,
         t_inital: float = 20,
         t_m: float = 20,
-        t_m_ts: float = 20
+        t_m_ts: float = 20,
     ):
         if inputs is None:
             inputs = {}
         if outputs is None:
             outputs = {}
-        super().__init__(
-            label=label,
-            inputs=inputs,
-            outputs=outputs)
+        super().__init__(label=label, inputs=inputs, outputs=outputs)
 
         self.building_config = building_config
         self.t_e = t_outside
         self.internal_gains = internal_gains
         self.phi_m_tot = phi_m_tot

Check failure on line 138 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py#L110-L138

         self.t_inital = t_inital
         self.t_m = t_m
         self.t_m_ts = t_m_ts
 
         self.floor_area = self.building_config.floor_area  # [m2] Floor Area
-        self.mass_area = self.building_config.mass_area  # [m2] Effective Mass Area DIN 12.3.1.2
-        self.A_t = self.building_config.total_internal_area  # [m2] the area of all surfaces facing the room DIN 7.2.2.2
+        self.mass_area = (
+            self.building_config.mass_area
+        )  # [m2] Effective Mass Area DIN 12.3.1.2
+        self.A_t = (
+            self.building_config.total_internal_area
+        )  # [m2] the area of all surfaces facing the room DIN 7.2.2.2
         self.c_m = self.building_config.c_m  # [kWh/K] Room Capacitance
-        self.ach_tot = self.building_config.total_air_change_rate  # [m3/s]Total Air Changes Per Hour
-
-        self.h_tr_em = self.building_config.h_tr_em  # [W/K] Conductance of opaque surfaces to exterior
-        self.h_tr_w = self.building_config.h_tr_w  # [W/K] Conductance to exterior through glazed surfaces
-        self.h_ve = self.building_config.h_ve  # [W/K] Conductance to ventilation
-        self.h_tr_ms = self.building_config.h_tr_ms  # [W/K] transmittance from the internal air to the thermal mass
-        self.h_tr_is = self.building_config.h_tr_is  # [W/K] Conductance from the conditioned air to interior zone surface
-
-        self.phi_st = []  # [W] Combination of internal and solar gains directly to the internal surfa
-        self.phi_m = []  # [W] Combination of internal and solar gains directly to the medium
-        self.phi_ia = []  # [W] Combination of internal and solar gains to the air
+        self.ach_tot = (
+            self.building_config.total_air_change_rate
+        )  # [m3/s]Total Air Changes Per Hour
+
+        self.h_tr_em = (
+            self.building_config.h_tr_em
+        )  # [W/K] Conductance of opaque surfaces to exterior
+        self.h_tr_w = (
+            self.building_config.h_tr_w
+        )  # [W/K] Conductance to exterior through glazed surfaces
+        self.h_ve = (
+            self.building_config.h_ve
+        )  # [W/K] Conductance to ventilation
+        self.h_tr_ms = (
+            self.building_config.h_tr_ms
+        )  # [W/K] transmittance from the internal air to the thermal mass
+        self.h_tr_is = (
+            self.building_config.h_tr_is
+        )  # [W/K] Conductance from the conditioned air to interior zone surface
+
+        self.phi_st = (
+            []
+        )  # [W] Combination of internal and solar gains directly to the internal surfa
+        self.phi_m = (
+            []
+        )  # [W] Combination of internal and solar gains directly to the medium
+        self.phi_ia = (
+            []
+        )  # [W] Combination of internal and solar gains to the air
         for i in range(len(self.solar_gains)):
-            self.h_tr_1 = self.calc_h_tr_1()  # [W/K] combined heat conductance, see function for definition
-            self.h_tr_2 = self.calc_h_tr_2()  # [W/K] combined heat conductance, see function for definition
-            self.h_tr_3 = self.calc_h_tr_3()  # [W/K] combined heat conductance, see function for definition
+            self.h_tr_1 = (
+                self.calc_h_tr_1()
+            )  # [W/K] combined heat conductance, see function for definition
+            self.h_tr_2 = (
+                self.calc_h_tr_2()
+            )  # [W/K] combined heat conductance, see function for definition
+            self.h_tr_3 = (
+                self.calc_h_tr_3()
+            )  # [W/K] combined heat conductance, see function for definition
             self.phi_ia.append(self.calc_phi_ia(i))
             self.phi_st.append(self.calc_phi_st(i))
             self.phi_m.append(self.calc_phi_m(i))
 
     def calc_h_tr_1(self):

Check failure on line 185 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py#L165-L185

     def calc_phi_st(self, i: float):
         """
         Heat flow in [W] to the surface node
         (based on the breakdown in section C.2) formulas C.1-C.3 in [ISO 13790]
         """
-        return (1 - (self.mass_area / self.A_t) -
-                (self.h_tr_w / (9.1 * self.A_t))) * (0.5 * self.internal_gains[i] + self.solar_gains[i])
+        return (
+            1 - (self.mass_area / self.A_t) - (self.h_tr_w / (9.1 * self.A_t))
+        ) * (0.5 * self.internal_gains[i] + self.solar_gains[i])
 
     def calc_phi_m(self, i: float):
         """
         Heatflow in [W] to the thermal mass node
         (based on the breakdown in section C.2) formulas C.1-C.3 in [ISO 13790]
         """
-        return (self.mass_area / self.A_t) * \
-               (0.5 * self.internal_gains[i] + self.solar_gains[i])
+        return (self.mass_area / self.A_t) * (
+            0.5 * self.internal_gains[i] + self.solar_gains[i]
+        )
 
     def _check_number_of_flows(self):
         """Ensure that there is only one inflow and outflow to the building"""
         msg = "Only one {0} flow allowed in the GenericBuilding {1}."
         check_node_object_for_missing_attribute(self, "inputs")

Check failure on line 208 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py#L197-L208

 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
 
     def _create(self, group=None):
-
         m = self.parent_block()
         if group is None:
             return None
 
         i = {n: [i for i in n.inputs][0] for n in group}

Check failure on line 301 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py#L224-L301

                 n.t_set_cooling,
             )
             return bounds
 
         self.t_air = Var(
-            self.BUILDING, m.TIMEPOINTS, bounds=_internal_temperature_bound_rule
-        )
-        self.t_m_ts = Var(
-            self.BUILDING, m.TIMEPOINTS
-        )
-
-        self.phi_m_tot = Var(
-            self.BUILDING, m.TIMEPOINTS
-        )
+            self.BUILDING,
+            m.TIMEPOINTS,
+            bounds=_internal_temperature_bound_rule,
+        )
+        self.t_m_ts = Var(self.BUILDING, m.TIMEPOINTS)
+
+        self.phi_m_tot = Var(self.BUILDING, m.TIMEPOINTS)
 
         # set the initial building temperature
         # ToDo: More elegant code possible?
         for n in group:
             if n.t_inital is not None:
-                self.t_air[n, 0] = (
-                    n.t_inital
-                )
+                self.t_air[n, 0] = n.t_inital
                 self.t_air[n, 0].fix()
 
             if n.t_m_ts is not None:
-                self.t_m_ts[n, 0] = (
-                    n.t_inital
-                )
+                self.t_m_ts[n, 0] = n.t_inital
                 self.t_m_ts[n, 0].fix()
 
             if n.phi_m_tot is not None:
-                self.phi_m_tot[n, 0] = (
-                    0
-                )
+                self.phi_m_tot[n, 0] = 0
                 self.phi_m_tot[n, 0].fix()
 
         def _storage_balance_rule_ts(block, n, p, t):
             t_m_last_ts = block.t_m_ts[n, t]
             phi_m_tot = block.phi_m_tot[n, t + 1]
-            t_m_current_ts = (t_m_last_ts * ((n.c_m / 3600) - 0.5 * (n.h_tr_3 + n.h_tr_em)) + phi_m_tot) / (
-                    (n.c_m / 3600) + 0.5 * (n.h_tr_3 + n.h_tr_em))
+            t_m_current_ts = (
+                t_m_last_ts * ((n.c_m / 3600) - 0.5 * (n.h_tr_3 + n.h_tr_em))
+                + phi_m_tot
+            ) / ((n.c_m / 3600) + 0.5 * (n.h_tr_3 + n.h_tr_em))
 
             return block.t_m_ts[n, t + 1] == t_m_current_ts
 
-        self.balance_t_m_current_t_s = Constraint(self.BUILDING, m.TIMEINDEX, rule=_storage_balance_rule_ts)
+        self.balance_t_m_current_t_s = Constraint(
+            self.BUILDING, m.TIMEINDEX, rule=_storage_balance_rule_ts
+        )
 
         def _storage_balance_rule_phi_m_tot(block, n, p, t):
             phi_hc_heat = m.flow[i[n], n, p, t]
             phi_hc_cool = m.flow[n, o[n], p, t]
             phi_hc_nd = phi_hc_heat - phi_hc_cool
 
-            phi_m_tot = n.phi_m[t] + n.h_tr_em * n.t_e[t] + (n.h_tr_3 / n.h_tr_2) * (
-                n.phi_st[t] + n.h_tr_w * n.t_e[t] + n.h_tr_1 * (((n.phi_ia[t] + phi_hc_nd) / n.h_ve) + n.t_e[t]))
+            phi_m_tot = (
+                n.phi_m[t]
+                + n.h_tr_em * n.t_e[t]
+                + (n.h_tr_3 / n.h_tr_2)
+                * (
+                    n.phi_st[t]
+                    + n.h_tr_w * n.t_e[t]
+                    + n.h_tr_1
+                    * (((n.phi_ia[t] + phi_hc_nd) / n.h_ve) + n.t_e[t])
+                )
+            )
             return block.phi_m_tot[n, t + 1] == phi_m_tot
 
-        self.balance_phi_m_tot = Constraint(self.BUILDING, m.TIMEINDEX, rule=_storage_balance_rule_phi_m_tot)
+        self.balance_phi_m_tot = Constraint(
+            self.BUILDING, m.TIMEINDEX, rule=_storage_balance_rule_phi_m_tot
+        )
 
         def _storage_balance_rule_t_air(block, n, p, t):
             phi_hc_heat = m.flow[i[n], n, p, t]
             phi_hc_cool = m.flow[n, o[n], p, t]
             phi_hc_nd = phi_hc_heat - phi_hc_cool
             t_m_last_ts = block.t_m_ts[n, t]
             t_m_current_ts = block.t_m_ts[n, t + 1]
             t_m = (t_m_last_ts + t_m_current_ts) / 2
 
-            t_s = (n.h_tr_ms * t_m + n.phi_st[t] + n.h_tr_w * n.t_e[t] + n.h_tr_1 * (
-                    n.t_e[t] + (n.phi_ia[t] + phi_hc_nd) / n.h_ve)) / \
-                  (n.h_tr_ms + n.h_tr_w + n.h_tr_1)
-            t_air = (n.h_tr_is * t_s + n.h_ve * n.t_e[t] + n.phi_ia[t] + phi_hc_nd) / (n.h_tr_is + n.h_ve)
+            t_s = (
+                n.h_tr_ms * t_m
+                + n.phi_st[t]
+                + n.h_tr_w * n.t_e[t]
+                + n.h_tr_1 * (n.t_e[t] + (n.phi_ia[t] + phi_hc_nd) / n.h_ve)
+            ) / (n.h_tr_ms + n.h_tr_w + n.h_tr_1)
+            t_air = (
+                n.h_tr_is * t_s + n.h_ve * n.t_e[t] + n.phi_ia[t] + phi_hc_nd
+            ) / (n.h_tr_is + n.h_ve)
             return block.t_air[n, t + 1] == t_air
 
-        self.balance_t_air = Constraint(self.BUILDING, m.TIMEINDEX, rule=_storage_balance_rule_t_air)
+        self.balance_t_air = Constraint(
+            self.BUILDING, m.TIMEINDEX, rule=_storage_balance_rule_t_air
+        )
 
     def _objective_expression(self):
         r"""
         Objective expression for BUILDING with no investment.
         Note: This adds nothing as variable costs are already

Check failure on line 308 in /home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/oemof-solph/oemof-solph/src/oemof/solph/components/experimental/_generic_building.py#L302-L308

         """
         if not hasattr(self, "BUILDING"):
             return 0
 
         return 0
-