Partial correction of hub

This commit is contained in:
Guille Gutierrez 2023-06-02 10:25:34 -04:00
parent 1d8a1dc275
commit dab931cadb

View File

@ -95,8 +95,8 @@ class Control:
dotenv_path=dotenv_path)
self._application_uuid = str(uuid.uuid4())
self._application_id = self._database.persist_application("test", "test application", self.application_uuid)
self._user_id = self._database.create_user("Admin", self._application_id, "Admin@123", UserRoles.Admin)
self._application_id = self._database.persist_application('test', 'test application', self.application_uuid)
self._user_id = self._database.create_user('Admin', self._application_id, 'Admin@123', UserRoles.Admin)
self._pickle_path = 'tests_data/pickle_path.bz2'
@property
@ -121,11 +121,11 @@ class Control:
@property
def insel(self):
return distutils.spawn.find_executable("insel")
return distutils.spawn.find_executable('insel')
@property
def sra(self):
return distutils.spawn.find_executable("sra")
return distutils.spawn.find_executable('sra')
@property
def skip_insel_test(self):
@ -197,54 +197,70 @@ TestDBFactory
if cte.MONTH not in building.cooling:
print(f'building {building.name} not calculated')
continue
monthly_cooling = building.cooling[cte.MONTH][cte.INSEL_MEB]
yearly_cooling = building.cooling[cte.YEAR][cte.INSEL_MEB]
monthly_heating = building.heating[cte.MONTH][cte.INSEL_MEB]
yearly_heating = building.heating[cte.YEAR][cte.INSEL_MEB]
monthly_cooling_peak_load = building.cooling_peak_load[cte.MONTH][cte.COOLING_PEAK_LOAD]
yearly_cooling_peak_load = building.cooling_peak_load[cte.YEAR][cte.COOLING_PEAK_LOAD]
monthly_heating_peak_load = building.heating_peak_load[cte.MONTH][cte.HEATING_PEAK_LOAD]
yearly_heating_peak_load = building.heating_peak_load[cte.YEAR][cte.HEATING_PEAK_LOAD]
monthly_electrical_peak_load = None
yearly_electrical_peak_load = None
monthly_cooling_demand = building.cooling[cte.MONTH][cte.INSEL_MEB]
yearly_cooling_demand = building.cooling[cte.YEAR][cte.INSEL_MEB]
monthly_heating_demand = building.heating[cte.MONTH][cte.INSEL_MEB]
yearly_heating_demand = building.heating[cte.YEAR][cte.INSEL_MEB]
monthly_lighting_electrical_demand = building.lighting_electrical_demand[cte.MONTH][cte.INSEL_MEB]
yearly_lighting_electrical_demand = building.lighting_electrical_demand[cte.YEAR][cte.INSEL_MEB]
monthly_appliances_electrical_demand = building.appliances_electrical_demand[cte.MONTH][cte.INSEL_MEB]
yearly_appliances_electrical_demand = building.appliances_electrical_demand[cte.YEAR][cte.INSEL_MEB]
monthly_domestic_hot_water_heat_demand = building.domestic_hot_water_heat_demand[cte.MONTH][cte.INSEL_MEB]
yearly_domestic_hot_water_heat_demand = building.domestic_hot_water_heat_demand[cte.YEAR][cte.INSEL_MEB]
monthly_heating_consumption = building.domestic_hot_water_heat_demand[cte.YEAR][cte.INSEL_MEB] # building.heating_consumption[cte.MONTH][cte.INSEL_MEB]
yearly_heating_consumption = building.domestic_hot_water_heat_demand[cte.YEAR][cte.INSEL_MEB] #building.heating_consumption[cte.YEAR][cte.INSEL_MEB]
monthly_cooling_consumption = building.domestic_hot_water_heat_demand[cte.YEAR][cte.INSEL_MEB] #building.cooling_consumption[cte.MONTH][cte.INSEL_MEB]
yearly_cooling_consumption = building.domestic_hot_water_heat_demand[cte.YEAR][cte.INSEL_MEB] #building.cooling_consumption[cte.YEAR][cte.INSEL_MEB]
monthly_domestic_hot_water_consumption = building.domestic_hot_water_heat_demand[cte.YEAR][cte.INSEL_MEB] #building.domestic_hot_water_consumption[cte.MONTH][cte.INSEL_MEB]
yearly_domestic_hot_water_consumption = building.domestic_hot_water_heat_demand[cte.YEAR][cte.INSEL_MEB] #building._domestic_hot_water_consumption[cte.YEAR][cte.INSEL_MEB]
monthly_distribution_systems_electrical_consumption = None
yearly_distribution_systems_electrical_consumption = None
monthly_on_site_electrical_production = None
yearly_on_site_electrical_production = None
db_building_id = _building.id
city_objects_id.append(db_building_id)
control.database.add_simulation_results(
cte.INSEL_MEB,
json.dumps({cte.INSEL_MEB: [
{"monthly_cooling_peak_load": monthly_cooling_peak_load.to_json()},
{"yearly_cooling_peak_load": yearly_cooling_peak_load.to_json()},
{"monthly_heating_peak_load": monthly_heating_peak_load.to_json()},
{"yearly_heating_peak_load": yearly_heating_peak_load.to_json()},
{"monthly_electrical_peak_load": monthly_electrical_peak_load.to_json()},
{"yearly_electrical_peak_load": yearly_electrical_peak_load.to_json()},
{"monthly_cooling_demand": monthly_cooling.to_json()},
{"yearly_cooling_demand": yearly_cooling.to_json()},
{"monthly_heating_demand": monthly_heating.to_json()},
{"yearly_heating_demand": yearly_heating.to_json()},
{"monthly_lighting_electrical_demand": monthly_lighting_electrical_demand.to_json()},
{"yearly_lighting_electrical_demand": yearly_lighting_electrical_demand.to_json()},
{"monthly_appliances_electrical_demand": monthly_appliances_electrical_demand.to_json()},
{"yearly_appliances_electrical_demand": yearly_appliances_electrical_demand.to_json()},
{"monthly_domestic_hot_water_heat_demand": monthly_domestic_hot_water_heat_demand.to_json()},
{"yearly_domestic_hot_water_heat_demand": yearly_domestic_hot_water_heat_demand.to_json()},
{"monthly_heating_consumption": monthly_heating_consumption.to_json()},
{"yearly_heating_consumption": yearly_heating_consumption.to_json()},
{"monthly_cooling_consumption": monthly_cooling_consumption.to_json()},
{"yearly_cooling_consumption": yearly_cooling_consumption.to_json()},
{"monthly_domestic_hot_water_consumption": monthly_domestic_hot_water_consumption.to_json()},
{"yearly_domestic_hot_water_consumption": yearly_domestic_hot_water_consumption.to_json()}
{'monthly_cooling_peak_load': monthly_cooling_peak_load.to_json()},
{'yearly_cooling_peak_load': yearly_cooling_peak_load.to_json()},
{'monthly_heating_peak_load': monthly_heating_peak_load.to_json()},
{'yearly_heating_peak_load': yearly_heating_peak_load.to_json()},
{'monthly_electrical_peak_load': monthly_electrical_peak_load.to_json()},
{'yearly_electrical_peak_load': yearly_electrical_peak_load.to_json()},
{'monthly_cooling_demand': monthly_cooling_demand.to_json()},
{'yearly_cooling_demand': yearly_cooling_demand.to_json()},
{'monthly_heating_demand': monthly_heating_demand.to_json()},
{'yearly_heating_demand': yearly_heating_demand.to_json()},
{'monthly_lighting_electrical_demand': monthly_lighting_electrical_demand.to_json()},
{'yearly_lighting_electrical_demand': yearly_lighting_electrical_demand.to_json()},
{'monthly_appliances_electrical_demand': monthly_appliances_electrical_demand.to_json()},
{'yearly_appliances_electrical_demand': yearly_appliances_electrical_demand.to_json()},
{'monthly_domestic_hot_water_heat_demand': monthly_domestic_hot_water_heat_demand.to_json()},
{'yearly_domestic_hot_water_heat_demand': yearly_domestic_hot_water_heat_demand.to_json()},
{'monthly_heating_consumption': monthly_heating_consumption.to_json()},
{'yearly_heating_consumption': yearly_heating_consumption.to_json()},
{'monthly_cooling_consumption': monthly_cooling_consumption.to_json()},
{'yearly_cooling_consumption': yearly_cooling_consumption.to_json()},
{'monthly_domestic_hot_water_consumption': monthly_domestic_hot_water_consumption.to_json()},
{'yearly_domestic_hot_water_consumption': yearly_domestic_hot_water_consumption.to_json()},
{'monthly_distribution_systems_electrical_consumption': monthly_distribution_systems_electrical_consumption.to_json()},
{'yearly_distribution_systems_electrical_consumption': yearly_distribution_systems_electrical_consumption.to_json()},
{'monthly_on_site_electrical_production', monthly_on_site_electrical_production.to_json()},
{'yearly_on_site_electrical_production', yearly_on_site_electrical_production.to_json()}
]}), city_object_id=db_building_id)
self.assertEqual(1, len(city_objects_id), 'wrong number of results')
self.assertIsNotNone(city_objects_id[0], 'city_object_id is None')