Found a bug in comnet factory and modified type of data from temperature to any number
This commit is contained in:
parent
1dc325a38f
commit
a6e239bb45
|
@ -75,7 +75,7 @@ class UsageHelper:
|
|||
_comnet_data_type_to_hub_data_type = {
|
||||
'Fraction': cte.FRACTION,
|
||||
'OnOff': cte.ON_OFF,
|
||||
'Temperature': cte.TEMPERATURE
|
||||
'Temperature': cte.ANY_NUMBER
|
||||
}
|
||||
|
||||
_comnet_schedules_key_to_comnet_schedules = {
|
||||
|
|
|
@ -13,7 +13,6 @@ from typing import List, Union
|
|||
from city_model_structure.attributes.polygon import Polygon
|
||||
from city_model_structure.attributes.plane import Plane
|
||||
from city_model_structure.attributes.point import Point
|
||||
from city_model_structure.energy_systems.pv_system import PvSystem
|
||||
import helpers.constants as cte
|
||||
|
||||
|
||||
|
@ -263,22 +262,6 @@ class Surface:
|
|||
"""
|
||||
self._holes_polygons = value
|
||||
|
||||
@property
|
||||
def pv_system_installed(self) -> PvSystem:
|
||||
"""
|
||||
Get PV system installed on the surface
|
||||
:return: PvSystem
|
||||
"""
|
||||
return self._pv_system_installed
|
||||
|
||||
@pv_system_installed.setter
|
||||
def pv_system_installed(self, value):
|
||||
"""
|
||||
Set PV system installed on the surface
|
||||
:param value: PvSystem
|
||||
"""
|
||||
self._pv_system_installed = value
|
||||
|
||||
@property
|
||||
def inverse(self) -> Surface:
|
||||
"""
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
"""
|
||||
pv_system defines a pv system including all components: PV panels, transformer...
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Concordia CERC group
|
||||
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
"""
|
||||
|
||||
from typing import Union
|
||||
|
||||
|
||||
class PvSystem:
|
||||
"""
|
||||
PvSystem class
|
||||
"""
|
||||
def __init__(self):
|
||||
self._modules_mean_seasonal_efficiency = None
|
||||
self._total_area = None
|
||||
self._module_area = None
|
||||
self._number_of_modules = None
|
||||
self._overall_system_performance_ratio = None
|
||||
self._electricity_generation = None
|
||||
|
||||
@property
|
||||
def modules_mean_seasonal_efficiency(self) -> Union[None, float]:
|
||||
"""
|
||||
Get mean modules efficiency (-)
|
||||
:return: None or float
|
||||
"""
|
||||
return self._modules_mean_seasonal_efficiency
|
||||
|
||||
@modules_mean_seasonal_efficiency.setter
|
||||
def modules_mean_seasonal_efficiency(self, value):
|
||||
"""
|
||||
Set mean modules efficiency (-)
|
||||
:param value: float
|
||||
"""
|
||||
if value is not None:
|
||||
self._modules_mean_seasonal_efficiency = float(value)
|
||||
|
||||
@property
|
||||
def total_area(self) -> Union[None, float]:
|
||||
"""
|
||||
Get total modules area in square meters
|
||||
:return: None or float
|
||||
"""
|
||||
return self._total_area
|
||||
|
||||
@total_area.setter
|
||||
def total_area(self, value):
|
||||
"""
|
||||
Set total modules area in square meters
|
||||
:param value: float
|
||||
"""
|
||||
if value is not None:
|
||||
self._total_area = float(value)
|
||||
|
||||
@property
|
||||
def module_area(self) -> Union[None, float]:
|
||||
"""
|
||||
Get module area in square meters
|
||||
:return: None or float
|
||||
"""
|
||||
return self._module_area
|
||||
|
||||
@module_area.setter
|
||||
def module_area(self, value):
|
||||
"""
|
||||
Set module area in square meters
|
||||
:param value: float
|
||||
"""
|
||||
if value is not None:
|
||||
self._module_area = float(value)
|
||||
|
||||
@property
|
||||
def number_of_modules(self) -> Union[None, int]:
|
||||
"""
|
||||
Get number of modules
|
||||
:return: None or int
|
||||
"""
|
||||
return self._number_of_modules
|
||||
|
||||
@number_of_modules.setter
|
||||
def number_of_modules(self, value):
|
||||
"""
|
||||
Set number of modules
|
||||
:param value: int
|
||||
"""
|
||||
if value is not None:
|
||||
self._number_of_modules = int(value)
|
||||
|
||||
@property
|
||||
def overall_system_performance_ratio(self) -> Union[None, float]:
|
||||
"""
|
||||
Get overall system performance ratio (-)
|
||||
:return: None or float
|
||||
"""
|
||||
return self._overall_system_performance_ratio
|
||||
|
||||
@overall_system_performance_ratio.setter
|
||||
def overall_system_performance_ratio(self, value):
|
||||
"""
|
||||
Set overall system performance ratio (-)
|
||||
:param value: float
|
||||
"""
|
||||
if value is not None:
|
||||
self._overall_system_performance_ratio = float(value)
|
||||
|
||||
@property
|
||||
def electricity_generation(self) -> Union[None, float]:
|
||||
"""
|
||||
Get electricity generation in J
|
||||
:return: None or float
|
||||
"""
|
||||
return self._electricity_generation
|
||||
|
||||
@electricity_generation.setter
|
||||
def electricity_generation(self, value):
|
||||
"""
|
||||
Set electricity generation in J
|
||||
:param value: float
|
||||
"""
|
||||
if value is not None:
|
||||
self._electricity_generation = float(value)
|
|
@ -156,8 +156,8 @@ class Idf:
|
|||
Visible_Absorptance=layer.material.visible_absorptance
|
||||
)
|
||||
|
||||
def _add_standard_compact_hourly_schedule(self, usage, schedules):
|
||||
_kwargs = {'Name': f'{schedules[0].type} schedules {usage}',
|
||||
def _add_standard_compact_hourly_schedule(self, usage, schedule_type, schedules):
|
||||
_kwargs = {'Name': f'{schedule_type} schedules {usage}',
|
||||
'Schedule_Type_Limits_Name': self.idf_type_limits[schedules[0].data_type],
|
||||
'Field_1': 'Through: 12/31'}
|
||||
for j, schedule in enumerate(schedules):
|
||||
|
@ -206,23 +206,23 @@ class Idf:
|
|||
_schedule.values = _infiltration_values
|
||||
_infiltration_schedules.append(_schedule)
|
||||
for schedule in self._idf.idfobjects[self._HOURLY_SCHEDULE]:
|
||||
if schedule.Name == f'{_infiltration_schedules[0].type} schedules {thermal_zone.usage}':
|
||||
if schedule.Name == f'Infiltration schedules {thermal_zone.usage}':
|
||||
return
|
||||
return self._add_standard_compact_hourly_schedule(thermal_zone.usage, _infiltration_schedules)
|
||||
return self._add_standard_compact_hourly_schedule(thermal_zone.usage, 'Infiltration', _infiltration_schedules)
|
||||
|
||||
def _add_schedules(self, usage, new_schedules, schedule_from_file=False):
|
||||
def _add_schedules(self, usage, schedule_type, new_schedules, schedule_from_file=False):
|
||||
if schedule_from_file:
|
||||
new_schedule = new_schedules[0]
|
||||
for schedule in self._idf.idfobjects[self._FILE_SCHEDULE]:
|
||||
if schedule.Name == f'{new_schedule.type} schedules {usage}':
|
||||
if schedule.Name == f'{schedule_type} schedules {usage}':
|
||||
return
|
||||
file_name = self._write_schedules_file(usage, new_schedule)
|
||||
return self._add_file_schedule(usage, new_schedule, file_name)
|
||||
else:
|
||||
for schedule in self._idf.idfobjects[self._HOURLY_SCHEDULE]:
|
||||
if schedule.Name == f'{new_schedules[0].type} schedules {usage}':
|
||||
if schedule.Name == f'{schedule_type} schedules {usage}':
|
||||
return
|
||||
return self._add_standard_compact_hourly_schedule(usage, new_schedules)
|
||||
return self._add_standard_compact_hourly_schedule(usage, schedule_type, new_schedules)
|
||||
|
||||
def _add_construction(self, thermal_boundary):
|
||||
for construction in self._idf.idfobjects[self._CONSTRUCTION]:
|
||||
|
@ -277,15 +277,16 @@ class Idf:
|
|||
self._idf.newidfobject(self._ZONE, Name=thermal_zone.id, Volume=thermal_zone.volume)
|
||||
self._add_heating_system(thermal_zone)
|
||||
|
||||
def _add_thermostat(self, usage_zone):
|
||||
thermostat_name = f'Thermostat {usage_zone.usage}'
|
||||
def _add_thermostat(self, thermal_zone):
|
||||
thermostat_name = f'Thermostat {thermal_zone.usage}'
|
||||
for thermostat in self._idf.idfobjects[self._THERMOSTAT]:
|
||||
if thermostat.Name == thermostat_name:
|
||||
return thermostat
|
||||
# todo: change schedules to schedule name and create schedules using the add_schedule function
|
||||
return self._idf.newidfobject(self._THERMOSTAT,
|
||||
Name=thermostat_name,
|
||||
Constant_Heating_Setpoint=usage_zone.thermal_control.mean_heating_set_point,
|
||||
Constant_Cooling_Setpoint=usage_zone.thermal_control.mean_cooling_set_point)
|
||||
Heating_Setpoint_Schedule_Name=f'Heating thermostat schedules {thermal_zone.usage}',
|
||||
Cooling_Setpoint_Schedule_Name=f'Cooling thermostat schedules {thermal_zone.usage}')
|
||||
|
||||
def _add_heating_system(self, thermal_zone):
|
||||
for air_system in self._idf.idfobjects[self._IDEAL_LOAD_AIR_SYSTEM]:
|
||||
|
@ -301,6 +302,9 @@ class Idf:
|
|||
|
||||
def _add_occupancy(self, thermal_zone):
|
||||
number_of_people = thermal_zone.occupancy.occupancy_density * thermal_zone.total_floor_area
|
||||
print('aaaaaaaa', thermal_zone.occupancy.sensible_radiative_internal_gain)
|
||||
print(thermal_zone.occupancy.sensible_convective_internal_gain)
|
||||
print(thermal_zone.occupancy.latent_internal_gain)
|
||||
fraction_radiant = thermal_zone.occupancy.sensible_radiative_internal_gain / \
|
||||
(thermal_zone.occupancy.sensible_radiative_internal_gain +
|
||||
thermal_zone.occupancy.sensible_convective_internal_gain +
|
||||
|
@ -359,10 +363,12 @@ class Idf:
|
|||
self._add_window_construction_and_material(thermal_opening)
|
||||
usage = thermal_zone.usage
|
||||
self._add_infiltration_schedules(thermal_zone)
|
||||
# todo: why is this schedule unused?
|
||||
self._add_schedules(usage, thermal_zone.lighting.schedules)
|
||||
self._add_schedules(usage, thermal_zone.occupancy.occupancy_schedules, schedule_from_file=True)
|
||||
self._add_schedules(usage, thermal_zone.thermal_control.hvac_availability_schedules)
|
||||
# todo: why are there schedules unused?
|
||||
self._add_schedules(usage, 'Lighting', thermal_zone.lighting.schedules)
|
||||
self._add_schedules(usage, 'Occupancy', thermal_zone.occupancy.occupancy_schedules, schedule_from_file=False)
|
||||
self._add_schedules(usage, 'HVAC AVAIL', thermal_zone.thermal_control.hvac_availability_schedules)
|
||||
self._add_schedules(usage, 'Heating thermostat', thermal_zone.thermal_control.heating_set_point_schedules)
|
||||
self._add_schedules(usage, 'Cooling thermostat', thermal_zone.thermal_control.cooling_set_point_schedules)
|
||||
|
||||
self._add_zone(thermal_zone)
|
||||
self._add_heating_system(thermal_zone)
|
||||
|
|
|
@ -46,7 +46,7 @@ class ComnetSchedules:
|
|||
schedule.day_types = [cte.SUNDAY]
|
||||
schedule.type = name
|
||||
schedule.data_type = SchedulesHelper.data_type_from_comnet(data_type)
|
||||
if schedule.data_type == cte.TEMPERATURE:
|
||||
if schedule.data_type == cte.ANY_NUMBER:
|
||||
values = []
|
||||
for cell in row_cells[schedules_per_schedule_type:].to_numpy():
|
||||
values.append((float(cell) - 32.) * 5 / 9)
|
||||
|
|
|
@ -28,7 +28,7 @@ class SchedulesHelper:
|
|||
_comnet_to_data_type = {
|
||||
'Fraction': cte.FRACTION,
|
||||
'OnOff': cte.ON_OFF,
|
||||
'Temperature': cte.TEMPERATURE
|
||||
'Temperature': cte.ANY_NUMBER
|
||||
}
|
||||
|
||||
# usage
|
||||
|
|
|
@ -133,7 +133,7 @@ class ComnetUsageParameters:
|
|||
_schedule.day_types = [cte.SUNDAY, cte.HOLIDAY]
|
||||
_schedule.type = name
|
||||
_schedule.data_type = SchedulesHelper.data_type_from_comnet(data_type)
|
||||
if _schedule.data_type == cte.TEMPERATURE:
|
||||
if _schedule.data_type == cte.ANY_NUMBER:
|
||||
values = []
|
||||
for cell in row_cells[schedules_per_schedule_type:].to_numpy():
|
||||
values.append((float(cell) - 32.) * 5 / 9)
|
||||
|
@ -229,15 +229,15 @@ class ComnetUsageParameters:
|
|||
usage_zone.mechanical_air_change = archetype.mechanical_air_change * cte.METERS_TO_FEET ** 2 \
|
||||
* cte.HOUR_TO_MINUTES / cte.METERS_TO_FEET ** 3 / volume_per_area
|
||||
_occupancy = Occupancy()
|
||||
_occupancy.occupancy_density = archetype.occupancy.occupancy_density / cte.METERS_TO_FEET**2
|
||||
_occupancy.occupancy_density = archetype.occupancy.occupancy_density * cte.METERS_TO_FEET**2
|
||||
_occupancy.sensible_radiative_internal_gain = archetype.occupancy.sensible_radiative_internal_gain \
|
||||
* archetype.occupancy.occupancy_density / cte.METERS_TO_FEET**2 \
|
||||
* archetype.occupancy.occupancy_density \
|
||||
* cte.BTU_H_TO_WATTS
|
||||
_occupancy.latent_internal_gain = archetype.occupancy.latent_internal_gain \
|
||||
* archetype.occupancy.occupancy_density / cte.METERS_TO_FEET**2 \
|
||||
* archetype.occupancy.occupancy_density \
|
||||
* cte.BTU_H_TO_WATTS
|
||||
_occupancy.sensible_convective_internal_gain = archetype.occupancy.sensible_convective_internal_gain \
|
||||
* archetype.occupancy.occupancy_density / cte.METERS_TO_FEET**2 \
|
||||
* archetype.occupancy.occupancy_density \
|
||||
* cte.BTU_H_TO_WATTS
|
||||
_occupancy.occupancy_schedules = archetype.occupancy.occupancy_schedules
|
||||
usage_zone.occupancy = _occupancy
|
||||
|
|
|
@ -87,7 +87,7 @@ class HftUsageInterface:
|
|||
_schedule.type = 'heating temperature'
|
||||
_schedule.time_range = cte.DAY
|
||||
_schedule.time_step = cte.HOUR
|
||||
_schedule.data_type = cte.TEMPERATURE
|
||||
_schedule.data_type = cte.ANY_NUMBER
|
||||
_schedule.day_types = [cte.MONDAY, cte.TUESDAY, cte.WEDNESDAY, cte.THURSDAY, cte.FRIDAY, cte.SATURDAY,
|
||||
cte.SUNDAY]
|
||||
_values = zone_usage_type['endUses']['space_heating']['schedule']['weekDayProfile']['values']
|
||||
|
@ -108,7 +108,7 @@ class HftUsageInterface:
|
|||
_schedule.type = 'cooling temperature'
|
||||
_schedule.time_range = cte.DAY
|
||||
_schedule.time_step = cte.HOUR
|
||||
_schedule.data_type = cte.TEMPERATURE
|
||||
_schedule.data_type = cte.ANY_NUMBER
|
||||
_schedule.day_types = [cte.MONDAY, cte.TUESDAY, cte.WEDNESDAY, cte.THURSDAY, cte.FRIDAY, cte.SATURDAY,
|
||||
cte.SUNDAY]
|
||||
_values = zone_usage_type['endUses']['space_cooling']['schedule']['weekDayProfile']['values']
|
||||
|
@ -209,7 +209,7 @@ class HftUsageInterface:
|
|||
_schedule.type = 'heating temperature'
|
||||
_schedule.time_range = cte.DAY
|
||||
_schedule.time_step = cte.HOUR
|
||||
_schedule.data_type = cte.TEMPERATURE
|
||||
_schedule.data_type = cte.ANY_NUMBER
|
||||
_schedule.day_types = [cte.MONDAY, cte.TUESDAY, cte.WEDNESDAY, cte.THURSDAY, cte.FRIDAY, cte.SATURDAY,
|
||||
cte.SUNDAY]
|
||||
_values = usage_zone_variant['endUses']['space_heating']['schedule']['weekDayProfile']['values']
|
||||
|
@ -232,7 +232,7 @@ class HftUsageInterface:
|
|||
_schedule.type = 'cooling temperature'
|
||||
_schedule.time_range = cte.DAY
|
||||
_schedule.time_step = cte.HOUR
|
||||
_schedule.data_type = cte.TEMPERATURE
|
||||
_schedule.data_type = cte.ANY_NUMBER
|
||||
_schedule.day_types = [cte.MONDAY, cte.TUESDAY, cte.WEDNESDAY, cte.THURSDAY, cte.FRIDAY, cte.SATURDAY,
|
||||
cte.SUNDAY]
|
||||
_values = usage_zone_variant['endUses']['space_cooling']['schedule']['weekDayProfile']['values']
|
||||
|
|
Loading…
Reference in New Issue
Block a user