forked from s_ranjbar/city_retrofit
Solved a bug in thermal_zone
This commit is contained in:
parent
e43c366036
commit
ea040e83df
|
@ -51,21 +51,26 @@ class ThermalZone:
|
|||
self._appliances = None
|
||||
self._internal_gains = None
|
||||
self._thermal_control = None
|
||||
self._usage_zones = None
|
||||
|
||||
@property
|
||||
def usage_zones(self):
|
||||
# example 70-office_30-residential
|
||||
if usage is None:
|
||||
self._usage_zones = copy.deepcopy(parent_internal_zone.usage_zones)
|
||||
if self._usage is None:
|
||||
self._usage_zones = copy.deepcopy(self._parent_internal_zone.usage_zones)
|
||||
else:
|
||||
values = usage.split('_')
|
||||
values = self._usage.split('_')
|
||||
usages = []
|
||||
for value in values:
|
||||
usages.append(value.split('-'))
|
||||
self._usage_zones = []
|
||||
for parent_usage_zone in parent_internal_zone.usage_zones:
|
||||
for parent_usage_zone in self._parent_internal_zone.usage_zones:
|
||||
for value in usages:
|
||||
if parent_usage_zone.usage == value[1]:
|
||||
new_usage_zone = copy.deepcopy(parent_usage_zone)
|
||||
new_usage_zone.percentage = float(value[0])/100
|
||||
self._usage_zones.append(new_usage_zone)
|
||||
return self._usage_zones
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
|
@ -255,11 +260,11 @@ class ThermalZone:
|
|||
Get thermal zone usage hours per day
|
||||
:return: None or float
|
||||
"""
|
||||
if self._usage_zones is None:
|
||||
if self.usage_zones is None:
|
||||
return None
|
||||
if self._hours_day is None:
|
||||
self._hours_day = 0
|
||||
for usage_zone in self._usage_zones:
|
||||
for usage_zone in self.usage_zones:
|
||||
self._hours_day += usage_zone.percentage * usage_zone.hours_day
|
||||
return self._hours_day
|
||||
|
||||
|
@ -269,11 +274,11 @@ class ThermalZone:
|
|||
Get thermal zone usage days per year
|
||||
:return: None or float
|
||||
"""
|
||||
if self._usage_zones is None:
|
||||
if self.usage_zones is None:
|
||||
return None
|
||||
if self._days_year is None:
|
||||
self._days_year = 0
|
||||
for usage_zone in self._usage_zones:
|
||||
for usage_zone in self.usage_zones:
|
||||
self._days_year += usage_zone.percentage * usage_zone.days_year
|
||||
return self._days_year
|
||||
|
||||
|
@ -283,11 +288,11 @@ 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.usage_zones is None:
|
||||
return None
|
||||
if self._mechanical_air_change is None:
|
||||
self._mechanical_air_change = 0
|
||||
for usage_zone in self._usage_zones:
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.mechanical_air_change is None:
|
||||
return None
|
||||
self._mechanical_air_change += usage_zone.percentage * usage_zone.mechanical_air_change
|
||||
|
@ -299,7 +304,7 @@ class ThermalZone:
|
|||
Get occupancy in the thermal zone
|
||||
:return: None or Occupancy
|
||||
"""
|
||||
if self._usage_zones is None:
|
||||
if self.usage_zones is None:
|
||||
return None
|
||||
if self._occupancy is None:
|
||||
self._occupancy = Occupancy()
|
||||
|
@ -307,7 +312,7 @@ class ThermalZone:
|
|||
_convective_part = 0
|
||||
_radiative_part = 0
|
||||
_latent_part = 0
|
||||
for usage_zone in self._usage_zones:
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.occupancy is None:
|
||||
return None
|
||||
_occupancy_density += usage_zone.percentage * usage_zone.occupancy.occupancy_density
|
||||
|
@ -320,7 +325,7 @@ class ThermalZone:
|
|||
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.usage_zones[0].occupancy
|
||||
if _occupancy_reference.occupancy_schedules is not None:
|
||||
_schedules = []
|
||||
for i_schedule in range(0, len(_occupancy_reference.occupancy_schedules)):
|
||||
|
@ -328,7 +333,7 @@ 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:
|
||||
for usage_zone in self.usage_zones:
|
||||
_new_value += usage_zone.percentage * usage_zone.occupancy.occupancy_schedules[i_schedule].values[i_value]
|
||||
new_values.append(_new_value)
|
||||
schedule.values = new_values
|
||||
|
@ -342,7 +347,7 @@ class ThermalZone:
|
|||
Get lighting information
|
||||
:return: None or Lighting
|
||||
"""
|
||||
if self._usage_zones is None:
|
||||
if self.usage_zones is None:
|
||||
return None
|
||||
if self._lighting is None:
|
||||
self._lighting = Lighting()
|
||||
|
@ -350,7 +355,7 @@ class ThermalZone:
|
|||
_convective_part = 0
|
||||
_radiative_part = 0
|
||||
_latent_part = 0
|
||||
for usage_zone in self._usage_zones:
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.lighting is None:
|
||||
return None
|
||||
_lighting_density += usage_zone.percentage * usage_zone.lighting.density
|
||||
|
@ -371,7 +376,7 @@ class ThermalZone:
|
|||
self._lighting.radiative_fraction = 0
|
||||
self._lighting.latent_fraction = 0
|
||||
|
||||
_lighting_reference = self._usage_zones[0].lighting
|
||||
_lighting_reference = self.usage_zones[0].lighting
|
||||
if _lighting_reference.schedules is not None:
|
||||
_schedules = []
|
||||
for i_schedule in range(0, len(_lighting_reference.schedules)):
|
||||
|
@ -379,7 +384,7 @@ 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:
|
||||
for usage_zone in self.usage_zones:
|
||||
_new_value += usage_zone.percentage * usage_zone.lighting.schedules[i_schedule].values[i_value]
|
||||
new_values.append(_new_value)
|
||||
schedule.values = new_values
|
||||
|
@ -393,7 +398,7 @@ class ThermalZone:
|
|||
Get appliances information
|
||||
:return: None or Appliances
|
||||
"""
|
||||
if self._usage_zones is None:
|
||||
if self.usage_zones is None:
|
||||
return None
|
||||
if self._appliances is None:
|
||||
self._appliances = Appliances()
|
||||
|
@ -401,7 +406,7 @@ class ThermalZone:
|
|||
_convective_part = 0
|
||||
_radiative_part = 0
|
||||
_latent_part = 0
|
||||
for usage_zone in self._usage_zones:
|
||||
for usage_zone in self.usage_zones:
|
||||
if usage_zone.appliances is None:
|
||||
return None
|
||||
_appliances_density += usage_zone.percentage * usage_zone.appliances.density
|
||||
|
@ -422,7 +427,7 @@ class ThermalZone:
|
|||
self._appliances.radiative_fraction = 0
|
||||
self._appliances.latent_fraction = 0
|
||||
|
||||
_appliances_reference = self._usage_zones[0].appliances
|
||||
_appliances_reference = self.usage_zones[0].appliances
|
||||
if _appliances_reference.schedules is not None:
|
||||
_schedules = []
|
||||
for i_schedule in range(0, len(_appliances_reference.schedules)):
|
||||
|
@ -430,7 +435,7 @@ 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:
|
||||
for usage_zone in self.usage_zones:
|
||||
_new_value += usage_zone.percentage * usage_zone.appliances.schedules[i_schedule].values[i_value]
|
||||
new_values.append(_new_value)
|
||||
schedule.values = new_values
|
||||
|
@ -444,7 +449,7 @@ class ThermalZone:
|
|||
Calculates and returns the list of all internal gains defined
|
||||
:return: [InternalGain]
|
||||
"""
|
||||
if self._usage_zones is None:
|
||||
if self.usage_zones is None:
|
||||
return None
|
||||
if self._internal_gains is None:
|
||||
_internal_gain = InternalGain()
|
||||
|
@ -461,7 +466,7 @@ 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 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 \
|
||||
|
@ -470,7 +475,7 @@ class ThermalZone:
|
|||
* internal_gain.radiative_fraction
|
||||
_latent_fraction += internal_gain.average_internal_gain * usage_zone.percentage \
|
||||
* internal_gain.latent_fraction
|
||||
for usage_zone in self._usage_zones:
|
||||
for usage_zone in self.usage_zones:
|
||||
for internal_gain in usage_zone.internal_gains:
|
||||
if len(internal_gain.schedules) == 0:
|
||||
_schedules_defined = False
|
||||
|
@ -502,14 +507,14 @@ class ThermalZone:
|
|||
Get thermal control of this thermal zone
|
||||
:return: None or ThermalControl
|
||||
"""
|
||||
if self._usage_zones is None:
|
||||
if self.usage_zones is None:
|
||||
return None
|
||||
if self._thermal_control is None:
|
||||
self._thermal_control = ThermalControl()
|
||||
_mean_heating_set_point = 0
|
||||
_heating_set_back = 0
|
||||
_mean_cooling_set_point = 0
|
||||
for usage_zone in self._usage_zones:
|
||||
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
|
||||
|
@ -517,7 +522,7 @@ class ThermalZone:
|
|||
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.usage_zones[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])
|
||||
|
@ -534,7 +539,7 @@ 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_zone in self.usage_zones:
|
||||
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]
|
||||
|
|
Loading…
Reference in New Issue
Block a user