From a15ee2981cbdd03b7a245eaa396451515bbbdc7b Mon Sep 17 00:00:00 2001 From: Nicolas Mounet Date: Mon, 23 Nov 2020 15:29:23 +0100 Subject: [PATCH] Adding hinged windows in models (WindowOpening class) --- cara/models.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/cara/models.py b/cara/models.py index 8fcf242b..801a38d3 100644 --- a/cara/models.py +++ b/cara/models.py @@ -195,16 +195,40 @@ class WindowOpening(Ventilation): #: The length of the opening-gap when the window is open opening_length: float + #: The type of the window ('sliding' or 'hinged') + window_type: str = 'sliding' + + #: The width of the window (used only to get cd_b of a hinged window). + window_width: float = None + #: The number of windows of the given dimensions. number_of_windows: int = 1 #: Discharge coefficient: what portion effective area is - #: used to exchange air (0 <= cd_b <= 1) - cd_b: float = 0.6 + #: used to exchange air (0 <= cd_b <= 1). Overrides the value + #: obtained from the window parameters + cd_b: float = None #: Minimum difference between inside and outside temperature min_deltaT: float = 0.1 + @property + def _cd_b(self): + if self.cd_b is not None: + return self.cd_b + elif self.window_type == 'sliding': + return 0.6 + elif self.window_type == 'hinged': + window_ratio = self.window_width / self.window_height + M = (0.06 if window_ratio < 0.5 else 0.048 if window_ratio < 1 else + 0.04 if window_ratio < 2 else 0.038) + cd_max = (0.612 if window_ratio < 0.5 else 0.589 if window_ratio < 1 + else 0.563 if window_ratio < 2 else 0.548) + window_angle = np.arccos(1-self.opening_length**2/(2.*self.window_height**2)) + return cd_max*(1-np.exp(-M*window_angle)) + else: + raise ValueError("Unknown window type; please specify cd_b") + def transition_times(self) -> typing.Set[float]: transitions = super().transition_times() transitions.update(self.inside_temp.transition_times) @@ -228,7 +252,7 @@ class WindowOpening(Ventilation): temp_gradient = (inside_temp - outside_temp) / outside_temp root = np.sqrt(9.81 * self.window_height * temp_gradient) window_area = self.window_height * self.opening_length * self.number_of_windows - return (3600 / (3 * room.volume)) * self.cd_b * window_area * root + return (3600 / (3 * room.volume)) * self._cd_b * window_area * root @dataclass(frozen=True)