This commit is contained in:
Guille Gutierrez 2024-12-02 20:53:45 +01:00
parent f4598ac946
commit fba7effd52
3 changed files with 27 additions and 23 deletions

View File

@ -10,7 +10,7 @@ class IdfInfiltration(IdfBase):
@staticmethod @staticmethod
def add_surface(self, thermal_zone, zone_name): def add_surface(self, thermal_zone, zone_name):
IdfInfiltration._add_infiltration(self, thermal_zone, zone_name, 'Flow/ExteriorWallArea', 1) IdfInfiltration._add_infiltration(self, thermal_zone, zone_name, 'Flow/ExteriorWallArea', cte.INFILTRATION_75PA_TO_4PA)
@staticmethod @staticmethod
def _add_infiltration(self, thermal_zone, zone_name, calculation_method, multiplier): def _add_infiltration(self, thermal_zone, zone_name, calculation_method, multiplier):

View File

@ -61,21 +61,21 @@ class EnergyPlus:
continue continue
for line in self._lines: for line in self._lines:
building_energy_demands[header].append(line[position]) building_energy_demands[header].append(line[position])
# print(building_energy_demands['Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)'])
EnergyPlus._set_building_demands(building, building_energy_demands) EnergyPlus._set_building_demands(building, building_energy_demands)
@staticmethod @staticmethod
def _set_building_demands(building, building_energy_demands): def _set_building_demands(building, building_energy_demands):
print(building.name, building_energy_demands) heating = [float(x) for x in building_energy_demands['Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)']]
building.heating_demand[cte.HOUR] = [float(x) for x in building_energy_demands[ cooling = [float(x) for x in building_energy_demands['Zone Ideal Loads Supply Air Total Cooling Energy [J](Hourly)']]
'Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)']] dhw = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands['Water Use Equipment Heating Rate [W](Hourly)']]
building.cooling_demand[cte.HOUR] = [float(x) for x in building_energy_demands[ appliances = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands['Other Equipment Electricity Rate [W](Hourly)']]
'Zone Ideal Loads Supply Air Total Cooling Energy [J](Hourly)']] lighting = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands['Zone Lights Electricity Rate [W](Hourly)']]
building.domestic_hot_water_heat_demand[cte.HOUR] = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands[ building.heating_demand[cte.HOUR] = heating.copy()
'Water Use Equipment Heating Rate [W](Hourly)']] building.cooling_demand[cte.HOUR] = cooling.copy()
building.appliances_electrical_demand[cte.HOUR] = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands[ building.domestic_hot_water_heat_demand[cte.HOUR] = dhw.copy()
'Other Equipment Electricity Rate [W](Hourly)']] building.appliances_electrical_demand[cte.HOUR] = appliances.copy()
building.lighting_electrical_demand[cte.HOUR] = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands[ building.lighting_electrical_demand[cte.HOUR] = lighting.copy()
'Zone Lights Electricity Rate [W](Hourly)']]
building.heating_demand[cte.MONTH] = [] building.heating_demand[cte.MONTH] = []
building.cooling_demand[cte.MONTH] = [] building.cooling_demand[cte.MONTH] = []
building.domestic_hot_water_heat_demand[cte.MONTH] = [] building.domestic_hot_water_heat_demand[cte.MONTH] = []
@ -83,20 +83,25 @@ class EnergyPlus:
building.lighting_electrical_demand[cte.MONTH] = [] building.lighting_electrical_demand[cte.MONTH] = []
start = 0 start = 0
"""
for hours in cte.HOURS_A_MONTH.values(): for hours in cte.HOURS_A_MONTH.values():
end = hours + start end = hours + start
if end == 8760:
print(building.heating_demand[cte.HOUR][start: end])
building.heating_demand[cte.MONTH].append(sum(building.heating_demand[cte.HOUR][start: end])) building.heating_demand[cte.MONTH].append(sum(building.heating_demand[cte.HOUR][start: end]))
building.cooling_demand[cte.MONTH].append(sum(building.cooling_demand[cte.HOUR][start: end])) building.cooling_demand[cte.MONTH].append(sum(building.cooling_demand[cte.HOUR][start: end]))
building.domestic_hot_water_heat_demand[cte.MONTH].append(sum(building.domestic_hot_water_heat_demand[cte.HOUR][start: end])) building.domestic_hot_water_heat_demand[cte.MONTH].append(sum(dhw[start: end]))
building.appliances_electrical_demand[cte.MONTH].append(sum(building.appliances_electrical_demand[cte.HOUR][start: end])) building.appliances_electrical_demand[cte.MONTH].append(sum(appliances[start: end]))
building.lighting_electrical_demand[cte.MONTH].append(sum(building.lighting_electrical_demand[cte.HOUR][start: end])) building.lighting_electrical_demand[cte.MONTH].append(sum(lighting[start: end]))
start = end start = end
"""
building.heating_demand[cte.YEAR] = [sum(building.heating_demand[cte.HOUR])]
building.cooling_demand[cte.YEAR] = [sum(building.cooling_demand[cte.HOUR])]
building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_demand[cte.HOUR])]
building.appliances_electrical_demand[cte.YEAR] = [sum(building.appliances_electrical_demand[cte.HOUR])]
building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.HOUR])]
building.heating_demand[cte.YEAR] = [sum(building.heating_demand[cte.MONTH])] #print(f'jan: {building.heating_demand[cte.MONTH][0]}, year {building.heating_demand[cte.YEAR]}')
building.cooling_demand[cte.YEAR] = [sum(building.cooling_demand[cte.MONTH])]
building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_demand[cte.MONTH])]
building.appliances_electrical_demand[cte.YEAR] = [sum(building.appliances_electrical_demand[cte.MONTH])]
building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.MONTH])]

View File

@ -151,6 +151,7 @@ class TestExports(TestCase):
ResultFactory('cerc_idf', city, csv_output_path).enrich() ResultFactory('cerc_idf', city, csv_output_path).enrich()
self.assertTrue(csv_output_path.is_file()) self.assertTrue(csv_output_path.is_file())
for building in city.buildings: for building in city.buildings:
print(building.name)
self.assertIsNotNone(building.heating_demand) self.assertIsNotNone(building.heating_demand)
self.assertIsNotNone(building.cooling_demand) self.assertIsNotNone(building.cooling_demand)
self.assertIsNotNone(building.domestic_hot_water_heat_demand) self.assertIsNotNone(building.domestic_hot_water_heat_demand)
@ -159,9 +160,7 @@ class TestExports(TestCase):
total_demand = sum(building.heating_demand[cte.HOUR]) total_demand = sum(building.heating_demand[cte.HOUR])
total_demand_month = sum(building.heating_demand[cte.MONTH]) total_demand_month = sum(building.heating_demand[cte.MONTH])
print(building.heating_demand[cte.YEAR]) print(building.heating_demand[cte.YEAR])
print(building.heating_demand[cte.YEAR][0], total_demand_month, total_demand) # print(building.heating_demand[cte.YEAR][0], total_demand_month, total_demand)
self.assertAlmostEqual(total_demand, building.heating_demand[cte.YEAR][0], 2) self.assertAlmostEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
total_demand = sum(building.heating_demand[cte.MONTH])
self.assertEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
except Exception: except Exception:
self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!") self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!")