forked from s_ranjbar/city_retrofit
from usage_zone to usage
This commit is contained in:
parent
1b47ea64b5
commit
c61dca2fe6
|
@ -398,8 +398,8 @@ class Building(CityObject):
|
|||
return False
|
||||
for internal_zone in self.internal_zones:
|
||||
if internal_zone.usages is not None:
|
||||
for usage_zone in internal_zone.usages:
|
||||
if usage_zone.thermal_control is not None:
|
||||
for usage in internal_zone.usages:
|
||||
if usage.thermal_control is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class ThermalZone:
|
|||
self._usages = None
|
||||
|
||||
@property
|
||||
def usage_zones(self):
|
||||
def usages(self):
|
||||
# example 70-office_30-residential
|
||||
if self._usage_from_parent:
|
||||
self._usages = copy.deepcopy(self._parent_internal_zone.usages)
|
||||
|
@ -234,8 +234,8 @@ class ThermalZone:
|
|||
if self._parent_internal_zone.usages is None:
|
||||
return None
|
||||
self._usage_name = ''
|
||||
for usage_zone in self._parent_internal_zone.usages:
|
||||
self._usage_name += str(round(usage_zone.percentage * 100)) + '-' + usage_zone.name + '_'
|
||||
for usage in self._parent_internal_zone.usages:
|
||||
self._usage_name += str(round(usage.percentage * 100)) + '-' + usage.name + '_'
|
||||
self._usage_name = self._usage_name[:-1]
|
||||
return self._usage_name
|
||||
|
||||
|
@ -253,12 +253,12 @@ class ThermalZone:
|
|||
Get thermal zone usage hours per day
|
||||
:return: None or float
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
if self._hours_day is None:
|
||||
self._hours_day = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
self._hours_day += usage_zone.percentage * usage_zone.hours_day
|
||||
for usage in self.usages:
|
||||
self._hours_day += usage.percentage * usage.hours_day
|
||||
return self._hours_day
|
||||
|
||||
@property
|
||||
|
@ -267,12 +267,12 @@ class ThermalZone:
|
|||
Get thermal zone usage days per year
|
||||
:return: None or float
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
if self._days_year is None:
|
||||
self._days_year = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
self._days_year += usage_zone.percentage * usage_zone.days_year
|
||||
for usage in self.usages:
|
||||
self._days_year += usage.percentage * usage.days_year
|
||||
return self._days_year
|
||||
|
||||
@property
|
||||
|
@ -281,14 +281,14 @@ class ThermalZone:
|
|||
Get thermal zone mechanical air change in air change per hour (ACH)
|
||||
:return: None or float
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
if self._mechanical_air_change is None:
|
||||
self._mechanical_air_change = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.mechanical_air_change is None:
|
||||
for usage in self.usages:
|
||||
if usage.mechanical_air_change is None:
|
||||
return None
|
||||
self._mechanical_air_change += usage_zone.percentage * usage_zone.mechanical_air_change
|
||||
self._mechanical_air_change += usage.percentage * usage.mechanical_air_change
|
||||
return self._mechanical_air_change
|
||||
|
||||
@property
|
||||
|
@ -297,7 +297,7 @@ class ThermalZone:
|
|||
Get occupancy in the thermal zone
|
||||
:return: None or Occupancy
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
|
||||
if self._occupancy is None:
|
||||
|
@ -306,20 +306,20 @@ class ThermalZone:
|
|||
_convective_part = 0
|
||||
_radiative_part = 0
|
||||
_latent_part = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.occupancy is None:
|
||||
for usage in self.usages:
|
||||
if usage.occupancy is None:
|
||||
return None
|
||||
_occupancy_density += usage_zone.percentage * usage_zone.occupancy.occupancy_density
|
||||
if usage_zone.occupancy.sensible_convective_internal_gain is not None:
|
||||
_convective_part += usage_zone.percentage * usage_zone.occupancy.sensible_convective_internal_gain
|
||||
_radiative_part += usage_zone.percentage * usage_zone.occupancy.sensible_radiative_internal_gain
|
||||
_latent_part += usage_zone.percentage * usage_zone.occupancy.latent_internal_gain
|
||||
_occupancy_density += usage.percentage * usage.occupancy.occupancy_density
|
||||
if usage.occupancy.sensible_convective_internal_gain is not None:
|
||||
_convective_part += usage.percentage * usage.occupancy.sensible_convective_internal_gain
|
||||
_radiative_part += usage.percentage * usage.occupancy.sensible_radiative_internal_gain
|
||||
_latent_part += usage.percentage * usage.occupancy.latent_internal_gain
|
||||
self._occupancy.occupancy_density = _occupancy_density
|
||||
self._occupancy.sensible_convective_internal_gain = _convective_part
|
||||
self._occupancy.sensible_radiative_internal_gain = _radiative_part
|
||||
self._occupancy.latent_internal_gain = _latent_part
|
||||
|
||||
_occupancy_reference = self.usage_zones[0].occupancy
|
||||
_occupancy_reference = self.usages[0].occupancy
|
||||
if _occupancy_reference.occupancy_schedules is not None:
|
||||
_schedules = []
|
||||
for i_schedule in range(0, len(_occupancy_reference.occupancy_schedules)):
|
||||
|
@ -333,8 +333,8 @@ class ThermalZone:
|
|||
new_values = []
|
||||
for i_value in range(0, len(_occupancy_reference.occupancy_schedules[i_schedule].values)):
|
||||
_new_value = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
_new_value += usage_zone.percentage * usage_zone.occupancy.occupancy_schedules[i_schedule].values[i_value]
|
||||
for usage in self.usages:
|
||||
_new_value += usage.percentage * usage.occupancy.occupancy_schedules[i_schedule].values[i_value]
|
||||
new_values.append(_new_value)
|
||||
schedule.values = new_values
|
||||
_schedules.append(schedule)
|
||||
|
@ -347,7 +347,7 @@ class ThermalZone:
|
|||
Get lighting information
|
||||
:return: None or Lighting
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
|
||||
if self._lighting is None:
|
||||
|
@ -356,17 +356,17 @@ class ThermalZone:
|
|||
_convective_part = 0
|
||||
_radiative_part = 0
|
||||
_latent_part = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.lighting is None:
|
||||
for usage in self.usages:
|
||||
if usage.lighting is None:
|
||||
return None
|
||||
_lighting_density += usage_zone.percentage * usage_zone.lighting.density
|
||||
if usage_zone.lighting.convective_fraction is not None:
|
||||
_convective_part += usage_zone.percentage * usage_zone.lighting.density \
|
||||
* usage_zone.lighting.convective_fraction
|
||||
_radiative_part += usage_zone.percentage * usage_zone.lighting.density \
|
||||
* usage_zone.lighting.radiative_fraction
|
||||
_latent_part += usage_zone.percentage * usage_zone.lighting.density \
|
||||
* usage_zone.lighting.latent_fraction
|
||||
_lighting_density += usage.percentage * usage.lighting.density
|
||||
if usage.lighting.convective_fraction is not None:
|
||||
_convective_part += usage.percentage * usage.lighting.density \
|
||||
* usage.lighting.convective_fraction
|
||||
_radiative_part += usage.percentage * usage.lighting.density \
|
||||
* usage.lighting.radiative_fraction
|
||||
_latent_part += usage.percentage * usage.lighting.density \
|
||||
* usage.lighting.latent_fraction
|
||||
self._lighting.density = _lighting_density
|
||||
if _lighting_density > 0:
|
||||
self._lighting.convective_fraction = _convective_part / _lighting_density
|
||||
|
@ -377,7 +377,7 @@ class ThermalZone:
|
|||
self._lighting.radiative_fraction = 0
|
||||
self._lighting.latent_fraction = 0
|
||||
|
||||
_lighting_reference = self.usage_zones[0].lighting
|
||||
_lighting_reference = self.usages[0].lighting
|
||||
if _lighting_reference.schedules is not None:
|
||||
_schedules = []
|
||||
for i_schedule in range(0, len(_lighting_reference.schedules)):
|
||||
|
@ -391,8 +391,8 @@ class ThermalZone:
|
|||
new_values = []
|
||||
for i_value in range(0, len(_lighting_reference.schedules[i_schedule].values)):
|
||||
_new_value = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
_new_value += usage_zone.percentage * usage_zone.lighting.schedules[i_schedule].values[i_value]
|
||||
for usage in self.usages:
|
||||
_new_value += usage.percentage * usage.lighting.schedules[i_schedule].values[i_value]
|
||||
new_values.append(_new_value)
|
||||
schedule.values = new_values
|
||||
_schedules.append(schedule)
|
||||
|
@ -405,7 +405,7 @@ class ThermalZone:
|
|||
Get appliances information
|
||||
:return: None or Appliances
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
|
||||
if self._appliances is None:
|
||||
|
@ -414,17 +414,17 @@ class ThermalZone:
|
|||
_convective_part = 0
|
||||
_radiative_part = 0
|
||||
_latent_part = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.appliances is None:
|
||||
for usage in self.usages:
|
||||
if usage.appliances is None:
|
||||
return None
|
||||
_appliances_density += usage_zone.percentage * usage_zone.appliances.density
|
||||
if usage_zone.appliances.convective_fraction is not None:
|
||||
_convective_part += usage_zone.percentage * usage_zone.appliances.density \
|
||||
* usage_zone.appliances.convective_fraction
|
||||
_radiative_part += usage_zone.percentage * usage_zone.appliances.density \
|
||||
* usage_zone.appliances.radiative_fraction
|
||||
_latent_part += usage_zone.percentage * usage_zone.appliances.density \
|
||||
* usage_zone.appliances.latent_fraction
|
||||
_appliances_density += usage.percentage * usage.appliances.density
|
||||
if usage.appliances.convective_fraction is not None:
|
||||
_convective_part += usage.percentage * usage.appliances.density \
|
||||
* usage.appliances.convective_fraction
|
||||
_radiative_part += usage.percentage * usage.appliances.density \
|
||||
* usage.appliances.radiative_fraction
|
||||
_latent_part += usage.percentage * usage.appliances.density \
|
||||
* usage.appliances.latent_fraction
|
||||
self._appliances.density = _appliances_density
|
||||
if _appliances_density > 0:
|
||||
self._appliances.convective_fraction = _convective_part / _appliances_density
|
||||
|
@ -435,7 +435,7 @@ class ThermalZone:
|
|||
self._appliances.radiative_fraction = 0
|
||||
self._appliances.latent_fraction = 0
|
||||
|
||||
_appliances_reference = self.usage_zones[0].appliances
|
||||
_appliances_reference = self.usages[0].appliances
|
||||
if _appliances_reference.schedules is not None:
|
||||
_schedules = []
|
||||
for i_schedule in range(0, len(_appliances_reference.schedules)):
|
||||
|
@ -449,8 +449,8 @@ class ThermalZone:
|
|||
new_values = []
|
||||
for i_value in range(0, len(_appliances_reference.schedules[i_schedule].values)):
|
||||
_new_value = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
_new_value += usage_zone.percentage * usage_zone.appliances.schedules[i_schedule].values[i_value]
|
||||
for usage in self.usages:
|
||||
_new_value += usage.percentage * usage.appliances.schedules[i_schedule].values[i_value]
|
||||
new_values.append(_new_value)
|
||||
schedule.values = new_values
|
||||
_schedules.append(schedule)
|
||||
|
@ -463,7 +463,7 @@ class ThermalZone:
|
|||
Calculates and returns the list of all internal gains defined
|
||||
:return: [InternalGain]
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
|
||||
if self._internal_gains is None:
|
||||
|
@ -481,17 +481,17 @@ class ThermalZone:
|
|||
_base_schedule.data_type = cte.ANY_NUMBER
|
||||
_schedules_defined = True
|
||||
values = numpy.zeros([24, 8])
|
||||
for usage_zone in self.usage_zones:
|
||||
for internal_gain in usage_zone.internal_gains:
|
||||
_average_internal_gain += internal_gain.average_internal_gain * usage_zone.percentage
|
||||
_convective_fraction += internal_gain.average_internal_gain * usage_zone.percentage \
|
||||
for usage in self.usages:
|
||||
for internal_gain in usage.internal_gains:
|
||||
_average_internal_gain += internal_gain.average_internal_gain * usage.percentage
|
||||
_convective_fraction += internal_gain.average_internal_gain * usage.percentage \
|
||||
* internal_gain.convective_fraction
|
||||
_radiative_fraction += internal_gain.average_internal_gain * usage_zone.percentage \
|
||||
_radiative_fraction += internal_gain.average_internal_gain * usage.percentage \
|
||||
* internal_gain.radiative_fraction
|
||||
_latent_fraction += internal_gain.average_internal_gain * usage_zone.percentage \
|
||||
_latent_fraction += internal_gain.average_internal_gain * usage.percentage \
|
||||
* internal_gain.latent_fraction
|
||||
for usage_zone in self.usage_zones:
|
||||
for internal_gain in usage_zone.internal_gains:
|
||||
for usage in self.usages:
|
||||
for internal_gain in usage.internal_gains:
|
||||
if internal_gain.schedules is None:
|
||||
_schedules_defined = False
|
||||
break
|
||||
|
@ -500,7 +500,7 @@ class ThermalZone:
|
|||
break
|
||||
for day, _schedule in enumerate(internal_gain.schedules):
|
||||
for v, value in enumerate(_schedule.values):
|
||||
values[v, day] += value * usage_zone.percentage
|
||||
values[v, day] += value * usage.percentage
|
||||
|
||||
if _schedules_defined:
|
||||
_schedules = []
|
||||
|
@ -525,7 +525,7 @@ class ThermalZone:
|
|||
Get thermal control of this thermal zone
|
||||
:return: None or ThermalControl
|
||||
"""
|
||||
if self.usage_zones is None:
|
||||
if self.usages is None:
|
||||
return None
|
||||
|
||||
if self._thermal_control is None:
|
||||
|
@ -533,15 +533,15 @@ class ThermalZone:
|
|||
_mean_heating_set_point = 0
|
||||
_heating_set_back = 0
|
||||
_mean_cooling_set_point = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
_mean_heating_set_point += usage_zone.percentage * usage_zone.thermal_control.mean_heating_set_point
|
||||
_heating_set_back += usage_zone.percentage * usage_zone.thermal_control.heating_set_back
|
||||
_mean_cooling_set_point += usage_zone.percentage * usage_zone.thermal_control.mean_cooling_set_point
|
||||
for usage in self.usages:
|
||||
_mean_heating_set_point += usage.percentage * usage.thermal_control.mean_heating_set_point
|
||||
_heating_set_back += usage.percentage * usage.thermal_control.heating_set_back
|
||||
_mean_cooling_set_point += usage.percentage * usage.thermal_control.mean_cooling_set_point
|
||||
self._thermal_control.mean_heating_set_point = _mean_heating_set_point
|
||||
self._thermal_control.heating_set_back = _heating_set_back
|
||||
self._thermal_control.mean_cooling_set_point = _mean_cooling_set_point
|
||||
|
||||
_thermal_control_reference = self.usage_zones[0].thermal_control
|
||||
_thermal_control_reference = self.usages[0].thermal_control
|
||||
_types_reference = []
|
||||
if _thermal_control_reference.hvac_availability_schedules is not None:
|
||||
_types_reference.append([cte.HVAC_AVAILABILITY, _thermal_control_reference.hvac_availability_schedules])
|
||||
|
@ -564,16 +564,16 @@ class ThermalZone:
|
|||
new_values = []
|
||||
for i_value in range(0, len(_schedule_type[i_schedule].values)):
|
||||
_new_value = 0
|
||||
for usage_zone in self.usage_zones:
|
||||
for usage in self.usages:
|
||||
if _types_reference[i_type][0] == cte.HVAC_AVAILABILITY:
|
||||
_new_value += usage_zone.percentage * \
|
||||
usage_zone.thermal_control.hvac_availability_schedules[i_schedule].values[i_value]
|
||||
_new_value += usage.percentage * \
|
||||
usage.thermal_control.hvac_availability_schedules[i_schedule].values[i_value]
|
||||
elif _types_reference[i_type][0] == cte.HEATING_SET_POINT:
|
||||
_new_value += usage_zone.percentage * \
|
||||
usage_zone.thermal_control.heating_set_point_schedules[i_schedule].values[i_value]
|
||||
_new_value += usage.percentage * \
|
||||
usage.thermal_control.heating_set_point_schedules[i_schedule].values[i_value]
|
||||
elif _types_reference[i_type][0] == cte.COOLING_SET_POINT:
|
||||
_new_value += usage_zone.percentage * \
|
||||
usage_zone.thermal_control.cooling_set_point_schedules[i_schedule].values[i_value]
|
||||
_new_value += usage.percentage * \
|
||||
usage.thermal_control.cooling_set_point_schedules[i_schedule].values[i_value]
|
||||
new_values.append(_new_value)
|
||||
schedule.values = new_values
|
||||
_schedules.append(schedule)
|
||||
|
|
|
@ -265,9 +265,9 @@ class EnergyAde:
|
|||
def _thermal_zones(self, building, city):
|
||||
thermal_zones = []
|
||||
for index, thermal_zone in enumerate(building.thermal_zones):
|
||||
usage_zones = []
|
||||
for usage_zone in thermal_zone.usages:
|
||||
usage_zones.append({'@xlink:href': f'#GML_{usage_zone.id}'})
|
||||
usages = []
|
||||
for usage in thermal_zone.usages:
|
||||
usages.append({'@xlink:href': f'#GML_{usage.id}'})
|
||||
thermal_zone_dic = {
|
||||
'energy:ThermalZone': {
|
||||
'@gml:id': f'GML_{thermal_zone.id}',
|
||||
|
@ -309,7 +309,7 @@ class EnergyAde:
|
|||
'energy:boundedBy': self._thermal_boundaries(city, thermal_zone)
|
||||
}
|
||||
}
|
||||
thermal_zone_dic['energy:ThermalZone']['energy:contains'] = usage_zones
|
||||
thermal_zone_dic['energy:ThermalZone']['energy:contains'] = usages
|
||||
thermal_zones.append(thermal_zone_dic)
|
||||
return thermal_zones
|
||||
|
||||
|
|
|
@ -461,8 +461,8 @@ class Idf:
|
|||
if surface.Type == self.idf_surfaces[boundary.surface.type]:
|
||||
surface.Construction_Name = boundary.construction_name
|
||||
break
|
||||
for usage_zone in thermal_zone.usages:
|
||||
surface.Zone_Name = usage_zone.id
|
||||
for usage in thermal_zone.usages:
|
||||
surface.Zone_Name = usage.id
|
||||
break
|
||||
break
|
||||
self._idf.intersect_match()
|
||||
|
|
|
@ -79,23 +79,23 @@ class InselMonthlyEnergyBalance(Insel):
|
|||
# ZONES AND SURFACES
|
||||
parameters.append(f'{len(internal_zone.usages)} % BP(10) Number of zones')
|
||||
|
||||
for i, usage_zone in enumerate(internal_zone.usages):
|
||||
percentage_usage = usage_zone.percentage
|
||||
for i, usage in enumerate(internal_zone.usages):
|
||||
percentage_usage = usage.percentage
|
||||
parameters.append(f'{float(internal_zone.area) * percentage_usage} % BP(11) #1 Area of zone {i + 1} (m2)')
|
||||
total_internal_gain = 0
|
||||
for ig in usage_zone.internal_gains:
|
||||
for ig in usage.internal_gains:
|
||||
total_internal_gain += float(ig.average_internal_gain) * \
|
||||
(float(ig.convective_fraction) + float(ig.radiative_fraction))
|
||||
parameters.append(f'{total_internal_gain} % BP(12) #2 Internal gains of zone {i + 1}')
|
||||
parameters.append(f'{usage_zone.thermal_control.mean_heating_set_point} % BP(13) #3 Heating setpoint temperature '
|
||||
parameters.append(f'{usage.thermal_control.mean_heating_set_point} % BP(13) #3 Heating setpoint temperature '
|
||||
f'zone {i + 1} (degree Celsius)')
|
||||
parameters.append(f'{usage_zone.thermal_control.heating_set_back} % BP(14) #4 Heating setback temperature '
|
||||
parameters.append(f'{usage.thermal_control.heating_set_back} % BP(14) #4 Heating setback temperature '
|
||||
f'zone {i + 1} (degree Celsius)')
|
||||
parameters.append(f'{usage_zone.thermal_control.mean_cooling_set_point} % BP(15) #5 Cooling setpoint temperature '
|
||||
parameters.append(f'{usage.thermal_control.mean_cooling_set_point} % BP(15) #5 Cooling setpoint temperature '
|
||||
f'zone {i + 1} (degree Celsius)')
|
||||
parameters.append(f'{usage_zone.hours_day} % BP(16) #6 Usage hours per day zone {i + 1}')
|
||||
parameters.append(f'{usage_zone.days_year} % BP(17) #7 Usage days per year zone {i + 1}')
|
||||
parameters.append(f'{usage_zone.mechanical_air_change} % BP(18) #8 Minimum air change rate zone {i + 1} (ACH)')
|
||||
parameters.append(f'{usage.hours_day} % BP(16) #6 Usage hours per day zone {i + 1}')
|
||||
parameters.append(f'{usage.days_year} % BP(17) #7 Usage days per year zone {i + 1}')
|
||||
parameters.append(f'{usage.mechanical_air_change} % BP(18) #8 Minimum air change rate zone {i + 1} (ACH)')
|
||||
|
||||
parameters.append(f'{len(thermal_zone.thermal_boundaries)} % Number of surfaces = BP(11+8z) \n'
|
||||
f'% 1. Surface type (1=wall, 2=ground 3=roof, 4=flat roof)\n'
|
||||
|
|
|
@ -29,13 +29,13 @@ class MonthlyToHourlyDemand:
|
|||
# todo: this method and the insel model have to be reviewed for more than one thermal zone
|
||||
external_temp = self._building.external_temperature[cte.HOUR]
|
||||
# todo: review index depending on how the schedules are defined, either 8760 or 24 hours
|
||||
for usage_zone in self._building.usages:
|
||||
temp_set = float(usage_zone.heating_setpoint)-3
|
||||
temp_back = float(usage_zone.heating_setback)-3
|
||||
for usage in self._building.usages:
|
||||
temp_set = float(usage.heating_setpoint)-3
|
||||
temp_back = float(usage.heating_setback)-3
|
||||
# todo: if these are data frames, then they should be called as (Occupancy should be in low case):
|
||||
# usage_zone.schedules.Occupancy
|
||||
# usage.schedules.Occupancy
|
||||
# self._conditioning_seasons.heating
|
||||
occupancy = Occupant().get_complete_year_schedule(usage_zone.schedules['Occupancy'])
|
||||
occupancy = Occupant().get_complete_year_schedule(usage.schedules['Occupancy'])
|
||||
heating_schedule = self._conditioning_seasons['heating']
|
||||
|
||||
hourly_heating = []
|
||||
|
@ -90,10 +90,10 @@ class MonthlyToHourlyDemand:
|
|||
# todo: this method and the insel model have to be reviewed for more than one thermal zone
|
||||
external_temp = self._building.external_temperature[cte.HOUR]
|
||||
# todo: review index depending on how the schedules are defined, either 8760 or 24 hours
|
||||
for usage_zone in self._building.usages:
|
||||
temp_set = float(usage_zone.cooling_setpoint)
|
||||
for usage in self._building.usages:
|
||||
temp_set = float(usage.cooling_setpoint)
|
||||
temp_back = 100
|
||||
occupancy = Occupant().get_complete_year_schedule(usage_zone.schedules['Occupancy'])
|
||||
occupancy = Occupant().get_complete_year_schedule(usage.schedules['Occupancy'])
|
||||
cooling_schedule = self._conditioning_seasons['cooling']
|
||||
|
||||
hourly_cooling = []
|
||||
|
|
|
@ -52,13 +52,13 @@ class ComnetUsageParameters:
|
|||
if internal_zone.area <= 0:
|
||||
raise Exception('Internal zone area is zero, ACH cannot be calculated')
|
||||
volume_per_area = internal_zone.volume / internal_zone.area
|
||||
usage_zone = Usage()
|
||||
usage_zone.name = usage_name
|
||||
self._assign_values(usage_zone, archetype_usage, volume_per_area)
|
||||
usage_zone.percentage = 1
|
||||
self._calculate_reduced_values_from_extended_library(usage_zone, archetype_usage)
|
||||
usage = Usage()
|
||||
usage.name = usage_name
|
||||
self._assign_values(usage, archetype_usage, volume_per_area)
|
||||
usage.percentage = 1
|
||||
self._calculate_reduced_values_from_extended_library(usage, archetype_usage)
|
||||
|
||||
internal_zone.usages = [usage_zone]
|
||||
internal_zone.usages = [usage]
|
||||
|
||||
@staticmethod
|
||||
def _search_archetypes(comnet_catalog, usage_name):
|
||||
|
@ -69,41 +69,41 @@ class ComnetUsageParameters:
|
|||
raise KeyError('archetype not found')
|
||||
|
||||
@staticmethod
|
||||
def _assign_values(usage_zone, archetype, volume_per_area):
|
||||
def _assign_values(usage, archetype, volume_per_area):
|
||||
# Due to the fact that python is not a typed language, the wrong object type is assigned to
|
||||
# usage_zone.occupancy when writing usage_zone.occupancy = archetype.occupancy.
|
||||
# usage.occupancy when writing usage.occupancy = archetype.occupancy.
|
||||
# Same happens for lighting and appliances. Therefore, this walk around has been done.
|
||||
usage_zone.mechanical_air_change = archetype.ventilation_rate / volume_per_area \
|
||||
* cte.HOUR_TO_MINUTES * cte.MINUTES_TO_SECONDS
|
||||
usage.mechanical_air_change = archetype.ventilation_rate / volume_per_area \
|
||||
* cte.HOUR_TO_MINUTES * cte.MINUTES_TO_SECONDS
|
||||
_occupancy = Occupancy()
|
||||
_occupancy.occupancy_density = archetype.occupancy.occupancy_density
|
||||
_occupancy.sensible_radiative_internal_gain = archetype.occupancy.sensible_radiative_internal_gain
|
||||
_occupancy.latent_internal_gain = archetype.occupancy.latent_internal_gain
|
||||
_occupancy.sensible_convective_internal_gain = archetype.occupancy.sensible_convective_internal_gain
|
||||
_occupancy.occupancy_schedules = archetype.occupancy.schedules
|
||||
usage_zone.occupancy = _occupancy
|
||||
usage.occupancy = _occupancy
|
||||
_lighting = Lighting()
|
||||
_lighting.density = archetype.lighting.density
|
||||
_lighting.convective_fraction = archetype.lighting.convective_fraction
|
||||
_lighting.radiative_fraction = archetype.lighting.radiative_fraction
|
||||
_lighting.latent_fraction = archetype.lighting.latent_fraction
|
||||
_lighting.schedules = archetype.lighting.schedules
|
||||
usage_zone.lighting = _lighting
|
||||
usage.lighting = _lighting
|
||||
_appliances = Appliances()
|
||||
_appliances.density = archetype.appliances.density
|
||||
_appliances.convective_fraction = archetype.appliances.convective_fraction
|
||||
_appliances.radiative_fraction = archetype.appliances.radiative_fraction
|
||||
_appliances.latent_fraction = archetype.appliances.latent_fraction
|
||||
_appliances.schedules = archetype.appliances.schedules
|
||||
usage_zone.appliances = _appliances
|
||||
usage.appliances = _appliances
|
||||
_control = ThermalControl()
|
||||
_control.cooling_set_point_schedules = archetype.thermal_control.cooling_set_point_schedules
|
||||
_control.heating_set_point_schedules = archetype.thermal_control.heating_set_point_schedules
|
||||
_control.hvac_availability_schedules = archetype.thermal_control.hvac_availability_schedules
|
||||
usage_zone.thermal_control = _control
|
||||
usage.thermal_control = _control
|
||||
|
||||
@staticmethod
|
||||
def _calculate_reduced_values_from_extended_library(usage_zone, archetype):
|
||||
def _calculate_reduced_values_from_extended_library(usage, archetype):
|
||||
number_of_days_per_type = {'WD': 251, 'Sat': 52, 'Sun': 62}
|
||||
total = 0
|
||||
for schedule in archetype.thermal_control.hvac_availability_schedules:
|
||||
|
@ -117,8 +117,8 @@ class ComnetUsageParameters:
|
|||
for value in schedule.values:
|
||||
total += value * number_of_days_per_type['WD']
|
||||
|
||||
usage_zone.hours_day = total / 365
|
||||
usage_zone.days_year = 365
|
||||
usage.hours_day = total / 365
|
||||
usage.days_year = 365
|
||||
|
||||
max_heating_setpoint = cte.MIN_FLOAT
|
||||
min_heating_setpoint = cte.MAX_FLOAT
|
||||
|
@ -141,9 +141,9 @@ class ComnetUsageParameters:
|
|||
if min(schedule.values) < min_cooling_setpoint:
|
||||
min_cooling_setpoint = min(schedule.values)
|
||||
|
||||
usage_zone.thermal_control.mean_heating_set_point = max_heating_setpoint
|
||||
usage_zone.thermal_control.heating_set_back = min_heating_setpoint
|
||||
usage_zone.thermal_control.mean_cooling_set_point = min_cooling_setpoint
|
||||
usage.thermal_control.mean_heating_set_point = max_heating_setpoint
|
||||
usage.thermal_control.heating_set_back = min_heating_setpoint
|
||||
usage.thermal_control.mean_cooling_set_point = min_cooling_setpoint
|
||||
|
||||
@staticmethod
|
||||
def _calculate_internal_gains(archetype):
|
||||
|
|
|
@ -59,14 +59,14 @@ class NrcanUsageParameters:
|
|||
if internal_zone.area <= 0:
|
||||
raise Exception('Internal zone area is zero, ACH cannot be calculated')
|
||||
volume_per_area = internal_zone.volume / internal_zone.area
|
||||
usage_zone = Usage()
|
||||
usage_zone.name = usage_name
|
||||
self._assign_values(usage_zone, archetype_usage, volume_per_area)
|
||||
self._assign_comnet_extra_values(usage_zone, comnet_archetype_usage)
|
||||
usage_zone.percentage = 1
|
||||
self._calculate_reduced_values_from_extended_library(usage_zone, archetype_usage)
|
||||
usage = Usage()
|
||||
usage.name = usage_name
|
||||
self._assign_values(usage, archetype_usage, volume_per_area)
|
||||
self._assign_comnet_extra_values(usage, comnet_archetype_usage)
|
||||
usage.percentage = 1
|
||||
self._calculate_reduced_values_from_extended_library(usage, archetype_usage)
|
||||
|
||||
internal_zone.usages = [usage_zone]
|
||||
internal_zone.usages = [usage]
|
||||
|
||||
@staticmethod
|
||||
def _search_archetypes(catalog, usage_name):
|
||||
|
@ -77,50 +77,50 @@ class NrcanUsageParameters:
|
|||
raise KeyError('archetype not found')
|
||||
|
||||
@staticmethod
|
||||
def _assign_values(usage_zone, archetype, volume_per_area):
|
||||
def _assign_values(usage, archetype, volume_per_area):
|
||||
if archetype.mechanical_air_change > 0:
|
||||
usage_zone.mechanical_air_change = archetype.mechanical_air_change
|
||||
usage.mechanical_air_change = archetype.mechanical_air_change
|
||||
elif archetype.ventilation_rate > 0:
|
||||
usage_zone.mechanical_air_change = archetype.ventilation_rate / volume_per_area \
|
||||
* cte.HOUR_TO_MINUTES * cte.MINUTES_TO_SECONDS
|
||||
usage.mechanical_air_change = archetype.ventilation_rate / volume_per_area \
|
||||
* cte.HOUR_TO_MINUTES * cte.MINUTES_TO_SECONDS
|
||||
else:
|
||||
usage_zone.mechanical_air_change = 0
|
||||
usage.mechanical_air_change = 0
|
||||
_occupancy = Occupancy()
|
||||
_occupancy.occupancy_density = archetype.occupancy.occupancy_density
|
||||
_occupancy.sensible_radiative_internal_gain = archetype.occupancy.sensible_radiative_internal_gain
|
||||
_occupancy.latent_internal_gain = archetype.occupancy.latent_internal_gain
|
||||
_occupancy.sensible_convective_internal_gain = archetype.occupancy.sensible_convective_internal_gain
|
||||
_occupancy.occupancy_schedules = archetype.occupancy.schedules
|
||||
usage_zone.occupancy = _occupancy
|
||||
usage.occupancy = _occupancy
|
||||
_lighting = Lighting()
|
||||
_lighting.density = archetype.lighting.density
|
||||
_lighting.convective_fraction = archetype.lighting.convective_fraction
|
||||
_lighting.radiative_fraction = archetype.lighting.radiative_fraction
|
||||
_lighting.latent_fraction = archetype.lighting.latent_fraction
|
||||
_lighting.schedules = archetype.lighting.schedules
|
||||
usage_zone.lighting = _lighting
|
||||
usage.lighting = _lighting
|
||||
_appliances = Appliances()
|
||||
_appliances.density = archetype.appliances.density
|
||||
_appliances.convective_fraction = archetype.appliances.convective_fraction
|
||||
_appliances.radiative_fraction = archetype.appliances.radiative_fraction
|
||||
_appliances.latent_fraction = archetype.appliances.latent_fraction
|
||||
_appliances.schedules = archetype.appliances.schedules
|
||||
usage_zone.appliances = _appliances
|
||||
usage.appliances = _appliances
|
||||
_control = ThermalControl()
|
||||
_control.cooling_set_point_schedules = archetype.thermal_control.cooling_set_point_schedules
|
||||
_control.heating_set_point_schedules = archetype.thermal_control.heating_set_point_schedules
|
||||
_control.hvac_availability_schedules = archetype.thermal_control.hvac_availability_schedules
|
||||
usage_zone.thermal_control = _control
|
||||
usage.thermal_control = _control
|
||||
|
||||
@staticmethod
|
||||
def _assign_comnet_extra_values(usage_zone, archetype):
|
||||
_occupancy = usage_zone.occupancy
|
||||
def _assign_comnet_extra_values(usage, archetype):
|
||||
_occupancy = usage.occupancy
|
||||
_occupancy.sensible_radiative_internal_gain = archetype.occupancy.sensible_radiative_internal_gain
|
||||
_occupancy.latent_internal_gain = archetype.occupancy.latent_internal_gain
|
||||
_occupancy.sensible_convective_internal_gain = archetype.occupancy.sensible_convective_internal_gain
|
||||
|
||||
@staticmethod
|
||||
def _calculate_reduced_values_from_extended_library(usage_zone, archetype):
|
||||
def _calculate_reduced_values_from_extended_library(usage, archetype):
|
||||
number_of_days_per_type = {'WD': 251, 'Sat': 52, 'Sun': 62}
|
||||
total = 0
|
||||
for schedule in archetype.thermal_control.hvac_availability_schedules:
|
||||
|
@ -134,8 +134,8 @@ class NrcanUsageParameters:
|
|||
for value in schedule.values:
|
||||
total += value * number_of_days_per_type['WD']
|
||||
|
||||
usage_zone.hours_day = total / 365
|
||||
usage_zone.days_year = 365
|
||||
usage.hours_day = total / 365
|
||||
usage.days_year = 365
|
||||
|
||||
max_heating_setpoint = cte.MIN_FLOAT
|
||||
min_heating_setpoint = cte.MAX_FLOAT
|
||||
|
@ -158,6 +158,6 @@ class NrcanUsageParameters:
|
|||
if min(schedule.values) < min_cooling_setpoint:
|
||||
min_cooling_setpoint = min(schedule.values)
|
||||
|
||||
usage_zone.thermal_control.mean_heating_set_point = max_heating_setpoint
|
||||
usage_zone.thermal_control.heating_set_back = min_heating_setpoint
|
||||
usage_zone.thermal_control.mean_cooling_set_point = min_cooling_setpoint
|
||||
usage.thermal_control.mean_heating_set_point = max_heating_setpoint
|
||||
usage.thermal_control.heating_set_back = min_heating_setpoint
|
||||
usage.thermal_control.mean_cooling_set_point = min_cooling_setpoint
|
||||
|
|
|
@ -35,9 +35,9 @@ class TestGeometryFactory(TestCase):
|
|||
self._check_buildings(city)
|
||||
for building in city.buildings:
|
||||
for internal_zone in building.internal_zones:
|
||||
self.assertIsNot(len(internal_zone.usages), 0, 'no building usage_zones defined')
|
||||
for usage_zone in internal_zone.usages:
|
||||
self.assertIsNotNone(usage_zone.id, 'usage id is none')
|
||||
self.assertIsNot(len(internal_zone.usages), 0, 'no building usages defined')
|
||||
for usage in internal_zone.usages:
|
||||
self.assertIsNotNone(usage.id, 'usage id is none')
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
self._check_thermal_zone(thermal_zone)
|
||||
|
||||
|
|
|
@ -133,13 +133,13 @@ class TestExports(TestCase):
|
|||
if thermal_boundary.type is not cte.GROUND:
|
||||
self.assertIsNotNone(thermal_boundary.parent_surface.short_wave_reflectance)
|
||||
|
||||
for usage_zone in internal_zone.usages:
|
||||
self.assertIsNotNone(usage_zone.percentage, f'usage zone {usage_zone.name} percentage is none')
|
||||
self.assertIsNotNone(usage_zone.internal_gains, f'usage zone {usage_zone.name} internal_gains is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control, f'usage zone {usage_zone.name} thermal_control is none')
|
||||
self.assertIsNotNone(usage_zone.hours_day, f'usage zone {usage_zone.name} hours_day is none')
|
||||
self.assertIsNotNone(usage_zone.days_year, f'usage zone {usage_zone.name} days_year is none')
|
||||
self.assertIsNotNone(usage_zone.mechanical_air_change, f'usage zone {usage_zone.name} '
|
||||
for usage in internal_zone.usages:
|
||||
self.assertIsNotNone(usage.percentage, f'usage zone {usage.name} percentage is none')
|
||||
self.assertIsNotNone(usage.internal_gains, f'usage zone {usage.name} internal_gains is none')
|
||||
self.assertIsNotNone(usage.thermal_control, f'usage zone {usage.name} thermal_control is none')
|
||||
self.assertIsNotNone(usage.hours_day, f'usage zone {usage.name} hours_day is none')
|
||||
self.assertIsNotNone(usage.days_year, f'usage zone {usage.name} days_year is none')
|
||||
self.assertIsNotNone(usage.mechanical_air_change, f'usage zone {usage.name} '
|
||||
f'mechanical_air_change is none')
|
||||
# export files
|
||||
try:
|
||||
|
|
|
@ -68,15 +68,15 @@ class TestUsageFactory(TestCase):
|
|||
self.assertIsNone(building.households, 'building households is not none')
|
||||
self.assertTrue(building.is_conditioned, 'building is not conditioned')
|
||||
|
||||
def _check_usage_zone(self, usage_zone):
|
||||
self.assertIsNotNone(usage_zone.name, 'usage is none')
|
||||
self.assertIsNotNone(usage_zone.percentage, 'usage percentage is none')
|
||||
self.assertIsNotNone(usage_zone.hours_day, 'hours per day is none')
|
||||
self.assertIsNotNone(usage_zone.days_year, 'days per year is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control, 'thermal control is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control.mean_heating_set_point, 'control heating set point is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control.heating_set_back, 'control heating set back is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control.mean_cooling_set_point, 'control cooling set point is none')
|
||||
def _check_usage(self, usage):
|
||||
self.assertIsNotNone(usage.name, 'usage is none')
|
||||
self.assertIsNotNone(usage.percentage, 'usage percentage is none')
|
||||
self.assertIsNotNone(usage.hours_day, 'hours per day is none')
|
||||
self.assertIsNotNone(usage.days_year, 'days per year is none')
|
||||
self.assertIsNotNone(usage.thermal_control, 'thermal control is none')
|
||||
self.assertIsNotNone(usage.thermal_control.mean_heating_set_point, 'control heating set point is none')
|
||||
self.assertIsNotNone(usage.thermal_control.heating_set_back, 'control heating set back is none')
|
||||
self.assertIsNotNone(usage.thermal_control.mean_cooling_set_point, 'control cooling set point is none')
|
||||
|
||||
def test_import_comnet(self):
|
||||
"""
|
||||
|
@ -91,16 +91,16 @@ class TestUsageFactory(TestCase):
|
|||
self._check_buildings(city)
|
||||
for building in city.buildings:
|
||||
for internal_zone in building.internal_zones:
|
||||
self.assertIsNot(len(internal_zone.usages), 0, 'no building usage_zones defined')
|
||||
for usage_zone in internal_zone.usages:
|
||||
self._check_usage_zone(usage_zone)
|
||||
self.assertIsNotNone(usage_zone.mechanical_air_change, 'mechanical air change is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control.heating_set_point_schedules,
|
||||
self.assertIsNot(len(internal_zone.usages), 0, 'no building usage defined')
|
||||
for usage in internal_zone.usages:
|
||||
self._check_usage(usage)
|
||||
self.assertIsNotNone(usage.mechanical_air_change, 'mechanical air change is none')
|
||||
self.assertIsNotNone(usage.thermal_control.heating_set_point_schedules,
|
||||
'control heating set point schedule is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control.cooling_set_point_schedules,
|
||||
self.assertIsNotNone(usage.thermal_control.cooling_set_point_schedules,
|
||||
'control cooling set point schedule is none')
|
||||
self.assertIsNotNone(usage_zone.occupancy, 'occupancy is none')
|
||||
occupancy = usage_zone.occupancy
|
||||
self.assertIsNotNone(usage.occupancy, 'occupancy is none')
|
||||
occupancy = usage.occupancy
|
||||
self.assertIsNotNone(occupancy.occupancy_density, 'occupancy density is none')
|
||||
self.assertIsNotNone(occupancy.latent_internal_gain, 'occupancy latent internal gain is none')
|
||||
self.assertIsNotNone(occupancy.sensible_convective_internal_gain,
|
||||
|
@ -109,19 +109,19 @@ class TestUsageFactory(TestCase):
|
|||
'occupancy sensible radiant internal gain is none')
|
||||
self.assertIsNotNone(occupancy.occupancy_schedules, 'occupancy schedule is none')
|
||||
self.assertIsNone(occupancy.occupants, 'occupancy density is not none')
|
||||
self.assertIsNotNone(usage_zone.lighting, 'lighting is none')
|
||||
lighting = usage_zone.lighting
|
||||
self.assertIsNotNone(usage.lighting, 'lighting is none')
|
||||
lighting = usage.lighting
|
||||
self.assertIsNotNone(lighting.density, 'lighting density is none')
|
||||
self.assertIsNotNone(lighting.latent_fraction, 'lighting latent fraction is none')
|
||||
self.assertIsNotNone(lighting.convective_fraction, 'lighting convective fraction is none')
|
||||
self.assertIsNotNone(lighting.radiative_fraction, 'lighting radiant fraction is none')
|
||||
self.assertIsNotNone(lighting.schedules, 'lighting schedule is none')
|
||||
self.assertIsNotNone(usage_zone.appliances, 'appliances is none')
|
||||
appliances = usage_zone.appliances
|
||||
self.assertIsNotNone(usage.appliances, 'appliances is none')
|
||||
appliances = usage.appliances
|
||||
self.assertIsNotNone(appliances.density, 'appliances density is none')
|
||||
self.assertIsNotNone(appliances.latent_fraction, 'appliances latent fraction is none')
|
||||
self.assertIsNotNone(appliances.convective_fraction, 'appliances convective fraction is none')
|
||||
self.assertIsNotNone(appliances.radiative_fraction, 'appliances radiant fraction is none')
|
||||
self.assertIsNotNone(appliances.schedules, 'appliances schedule is none')
|
||||
self.assertIsNotNone(usage_zone.thermal_control.hvac_availability_schedules,
|
||||
self.assertIsNotNone(usage.thermal_control.hvac_availability_schedules,
|
||||
'control hvac availability is none')
|
||||
|
|
Loading…
Reference in New Issue
Block a user