From 8c21403bd8555916117f08722d61068844d6ffd6 Mon Sep 17 00:00:00 2001 From: Pilar Date: Fri, 13 Aug 2021 12:47:49 -0400 Subject: [PATCH] Adapted to the last modifications in libs, the new structure of the city model --- insel/templates/monthly_energy_balance.py | 10 +++++----- main.py | 15 +++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/insel/templates/monthly_energy_balance.py b/insel/templates/monthly_energy_balance.py index 76c175e..4c027bb 100644 --- a/insel/templates/monthly_energy_balance.py +++ b/insel/templates/monthly_energy_balance.py @@ -5,7 +5,7 @@ import pandas as pd import csv from imports.weather.helpers.weather import Weather as wt - +import helpers.constants as cte class MonthlyEnergyBalance: @staticmethod @@ -90,8 +90,8 @@ class MonthlyEnergyBalance: window_area = 0 for hole_polygon in thermal_boundary.surface.holes_polygons: window_area += hole_polygon.area - string = type_code + ' ' + str(0.85*thermal_boundary.area_above_ground) + ' ' + \ - str(thermal_boundary.area_below_ground) + ' ' + str(thermal_boundary.u_value) + ' ' + \ + string = type_code + ' ' + str(0.85*thermal_boundary.surface.area_above_ground) + ' ' + \ + str(thermal_boundary.surface.area_below_ground) + ' ' + str(thermal_boundary.u_value) + ' ' + \ str(0.85*window_area) + ' ' if window_area <= 0.001: @@ -109,7 +109,7 @@ class MonthlyEnergyBalance: file += '\r\n' file += 's 20 polyg 1\r\n' file += 'p 20 12 % Monthly ambient temperature\r\n' - external_temperature = building.external_temperature['month'] + external_temperature = building.external_temperature[cte.MONTH] for i in range(0, len(external_temperature)): file += str(i+1) + ' ' + str(external_temperature.at[i, key]) + '\r\n' @@ -131,7 +131,7 @@ class MonthlyEnergyBalance: ', inclination ' + str(np.rad2deg(surface.inclination)) + ' degrees\r\n' if surface.type != 'Ground': - global_irradiance = surface.global_irradiance['month'] + global_irradiance = surface.global_irradiance[cte.MONTH] for j in range(0, len(global_irradiance)): file += str(j + 1) + ' ' + str(global_irradiance.at[j, 'sra']) + '\r\n' else: diff --git a/main.py b/main.py index 0b15b13..19c9d57 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ import ast import pandas as pd import datetime +import helpers.constants as cte from helpers import monthly_values as mv from simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm from imports.geometry_factory import GeometryFactory @@ -83,13 +84,13 @@ if not weather_step_in_pickle: city.climate_file = (path / f'{args.climate_reference_city}.cli').resolve() WeatherFactory(weather_format, populated_city, file_name=args.weather_file_name).enrich() for building in populated_city.buildings: - if 'hour' not in building.external_temperature: + if cte.HOUR not in building.external_temperature: print('No external temperature found') sys.exit() - if 'month' not in building.external_temperature: - building.external_temperature['month'] = mv.MonthlyValues().\ - get_mean_values(building.external_temperature['hour'][[weather_format]]) + if cte.MONTH not in building.external_temperature: + building.external_temperature[cte.MONTH] = mv.MonthlyValues().\ + get_mean_values(building.external_temperature[cte.HOUR][[weather_format]]) max_buildings_handled_by_sra = 500 for building in city.buildings: @@ -117,8 +118,6 @@ if not weather_step_in_pickle: print('begin_user_assignment_time', datetime.datetime.now()) # Step 4: Assign user defined parameters for building in populated_city.buildings: - building.heated = True - building.cooled = False building.attic_heated = 2 building.basement_heated = 0 @@ -127,12 +126,12 @@ print('begin_insel_time', datetime.datetime.now()) MonthlyDemandCalculation(city, args.project_folder, weather_format).monthly_demand() print('begin_write_results_time', datetime.datetime.now()) -# Step 5: Print results +# Step 6: Print results print_results = None file = 'city name: ' + city.name + '\n' for building in populated_city.buildings: insel_file_name = building.name + '.insel' - building_results = building.heating['month'].rename(columns={'INSEL': building.name}) + building_results = building.heating[cte.MONTH].rename(columns={'INSEL': building.name}) if print_results is None: print_results = building_results else: