Adapted to the last modifications in libs, the new structure of the city model

This commit is contained in:
Pilar 2021-08-13 12:47:49 -04:00
parent 51fc72b921
commit 8c21403bd8
2 changed files with 12 additions and 13 deletions

View File

@ -5,7 +5,7 @@ import pandas as pd
import csv import csv
from imports.weather.helpers.weather import Weather as wt from imports.weather.helpers.weather import Weather as wt
import helpers.constants as cte
class MonthlyEnergyBalance: class MonthlyEnergyBalance:
@staticmethod @staticmethod
@ -90,8 +90,8 @@ class MonthlyEnergyBalance:
window_area = 0 window_area = 0
for hole_polygon in thermal_boundary.surface.holes_polygons: for hole_polygon in thermal_boundary.surface.holes_polygons:
window_area += hole_polygon.area window_area += hole_polygon.area
string = type_code + ' ' + str(0.85*thermal_boundary.area_above_ground) + ' ' + \ string = type_code + ' ' + str(0.85*thermal_boundary.surface.area_above_ground) + ' ' + \
str(thermal_boundary.area_below_ground) + ' ' + str(thermal_boundary.u_value) + ' ' + \ str(thermal_boundary.surface.area_below_ground) + ' ' + str(thermal_boundary.u_value) + ' ' + \
str(0.85*window_area) + ' ' str(0.85*window_area) + ' '
if window_area <= 0.001: if window_area <= 0.001:
@ -109,7 +109,7 @@ class MonthlyEnergyBalance:
file += '\r\n' file += '\r\n'
file += 's 20 polyg 1\r\n' file += 's 20 polyg 1\r\n'
file += 'p 20 12 % Monthly ambient temperature\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)): for i in range(0, len(external_temperature)):
file += str(i+1) + ' ' + str(external_temperature.at[i, key]) + '\r\n' 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' ', inclination ' + str(np.rad2deg(surface.inclination)) + ' degrees\r\n'
if surface.type != 'Ground': 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)): for j in range(0, len(global_irradiance)):
file += str(j + 1) + ' ' + str(global_irradiance.at[j, 'sra']) + '\r\n' file += str(j + 1) + ' ' + str(global_irradiance.at[j, 'sra']) + '\r\n'
else: else:

15
main.py
View File

@ -11,6 +11,7 @@ import ast
import pandas as pd import pandas as pd
import datetime import datetime
import helpers.constants as cte
from helpers import monthly_values as mv from helpers import monthly_values as mv
from simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm from simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
from imports.geometry_factory import GeometryFactory 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() city.climate_file = (path / f'{args.climate_reference_city}.cli').resolve()
WeatherFactory(weather_format, populated_city, file_name=args.weather_file_name).enrich() WeatherFactory(weather_format, populated_city, file_name=args.weather_file_name).enrich()
for building in populated_city.buildings: 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') print('No external temperature found')
sys.exit() sys.exit()
if 'month' not in building.external_temperature: if cte.MONTH not in building.external_temperature:
building.external_temperature['month'] = mv.MonthlyValues().\ building.external_temperature[cte.MONTH] = mv.MonthlyValues().\
get_mean_values(building.external_temperature['hour'][[weather_format]]) get_mean_values(building.external_temperature[cte.HOUR][[weather_format]])
max_buildings_handled_by_sra = 500 max_buildings_handled_by_sra = 500
for building in city.buildings: for building in city.buildings:
@ -117,8 +118,6 @@ if not weather_step_in_pickle:
print('begin_user_assignment_time', datetime.datetime.now()) print('begin_user_assignment_time', datetime.datetime.now())
# Step 4: Assign user defined parameters # Step 4: Assign user defined parameters
for building in populated_city.buildings: for building in populated_city.buildings:
building.heated = True
building.cooled = False
building.attic_heated = 2 building.attic_heated = 2
building.basement_heated = 0 building.basement_heated = 0
@ -127,12 +126,12 @@ print('begin_insel_time', datetime.datetime.now())
MonthlyDemandCalculation(city, args.project_folder, weather_format).monthly_demand() MonthlyDemandCalculation(city, args.project_folder, weather_format).monthly_demand()
print('begin_write_results_time', datetime.datetime.now()) print('begin_write_results_time', datetime.datetime.now())
# Step 5: Print results # Step 6: Print results
print_results = None print_results = None
file = 'city name: ' + city.name + '\n' file = 'city name: ' + city.name + '\n'
for building in populated_city.buildings: for building in populated_city.buildings:
insel_file_name = building.name + '.insel' 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: if print_results is None:
print_results = building_results print_results = building_results
else: else: