OpenSimula 0.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. opensimula/Child.py +19 -0
  2. opensimula/Component.py +214 -0
  3. opensimula/Iterative_process.py +47 -0
  4. opensimula/Message.py +19 -0
  5. opensimula/Parameter_container.py +80 -0
  6. opensimula/Parameters.py +755 -0
  7. opensimula/Project.py +674 -0
  8. opensimula/Simulation.py +212 -0
  9. opensimula/Variable.py +37 -0
  10. opensimula/__init__.py +8 -0
  11. opensimula/components/Building.py +511 -0
  12. opensimula/components/Building_surface.py +318 -0
  13. opensimula/components/Calculator.py +51 -0
  14. opensimula/components/Construction.py +309 -0
  15. opensimula/components/Day_schedule.py +64 -0
  16. opensimula/components/File_data.py +117 -0
  17. opensimula/components/File_met.py +1035 -0
  18. opensimula/components/Frame.py +35 -0
  19. opensimula/components/Glazing.py +122 -0
  20. opensimula/components/HVAC_DX_equipment.py +210 -0
  21. opensimula/components/HVAC_DX_system.py +254 -0
  22. opensimula/components/HVAC_MZW_system.py +554 -0
  23. opensimula/components/HVAC_SZW_system.py +338 -0
  24. opensimula/components/HVAC_coil_equipment.py +206 -0
  25. opensimula/components/HVAC_fan_equipment.py +44 -0
  26. opensimula/components/HVAC_perfect_system.py +137 -0
  27. opensimula/components/Material.py +14 -0
  28. opensimula/components/Opening.py +409 -0
  29. opensimula/components/Opening_type.py +90 -0
  30. opensimula/components/Solar_surface.py +114 -0
  31. opensimula/components/Space.py +388 -0
  32. opensimula/components/Space_type.py +81 -0
  33. opensimula/components/Surface.py +129 -0
  34. opensimula/components/Test_component.py +76 -0
  35. opensimula/components/Week_schedule.py +30 -0
  36. opensimula/components/Year_schedule.py +65 -0
  37. opensimula/components/__init__.py +40 -0
  38. opensimula/visual_3D/Environment_3D.py +257 -0
  39. opensimula/visual_3D/Polygon_3D.py +262 -0
  40. opensimula-0.5.1.dist-info/METADATA +49 -0
  41. opensimula-0.5.1.dist-info/RECORD +44 -0
  42. opensimula-0.5.1.dist-info/WHEEL +5 -0
  43. opensimula-0.5.1.dist-info/licenses/LICENSE +21 -0
  44. opensimula-0.5.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,511 @@
1
+ import numpy as np
2
+ from opensimula.Component import Component
3
+ from opensimula.Parameters import Parameter_float,Parameter_float_list
4
+ from opensimula.Message import Message
5
+
6
+ class Building(Component):
7
+ def __init__(self, name, project):
8
+ Component.__init__(self, name, project)
9
+ self.parameter("type").value = "Building"
10
+ self.parameter("description").value = "Building description"
11
+ # Parameters
12
+ # X-axe vs East angle (0: X->East, 90: x->North)
13
+ self.add_parameter(Parameter_float("azimuth", 0, "°", min=-180, max=180))
14
+ self.add_parameter(Parameter_float_list("ref_point", [0,0,0], "m"))
15
+ self.add_parameter(Parameter_float("initial_temperature", 20, "°C"))
16
+ self.add_parameter(Parameter_float("initial_humidity", 7.3, "g/kg"))
17
+
18
+ def check(self):
19
+ errors = super().check()
20
+ file_met = self.project().parameter("simulation_file_met").value
21
+ if file_met == "not_defined":
22
+ msg = Message(f"{self.parameter('name').value}, file_met must be defined in the project 'simulation_file_met'.", "ERROR")
23
+ errors.append(msg)
24
+ #self._create_lists_() # Es necesario crear las listas aquí ???
25
+ return errors
26
+
27
+
28
+ # _______________ pre_simulation _______________
29
+ def pre_simulation(self, n_time_steps, delta_t):
30
+ super().pre_simulation(n_time_steps, delta_t)
31
+ self._file_met_ = self.project().parameter("simulation_file_met").component
32
+ self.props = self._sim_.props
33
+ self._create_lists_()
34
+ self._create_ff_matrix_() # View Factors ff_matrix
35
+ self._create_B_matrix_() # Conectivity B_matrix
36
+ self._create_SW_matrices_() # SWDIF_matrix, SWDIR_matrix, SWIG_matrix
37
+ self._create_LW_matrices_() # LWIG_matrix, LWSUR_matrix
38
+ self._create_K_matrices_() # KS_matrix, KS_inv_matrix, KSZ_matrix, KZS_matrix, KZ_matrix
39
+
40
+ def _create_lists_(self):
41
+ project_spaces_list = self.project().component_list(comp_type="Space")
42
+ self.spaces = []
43
+ self.surfaces = []
44
+ self.sides = []
45
+ for space in project_spaces_list:
46
+ if space.parameter("building").component == self:
47
+ self.spaces.append(space)
48
+ for surface in space.surfaces:
49
+ self.surfaces.append(surface)
50
+ for side in space.sides:
51
+ self.sides.append(side)
52
+ self._n_spaces = len(self.spaces)
53
+ self._n_surfaces = len(self.surfaces)
54
+
55
+
56
+ def _create_ff_matrix_(self):
57
+ self.ff_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
58
+ i = 0
59
+ for space in self.spaces:
60
+ n_i = len(space.surfaces)
61
+ self.ff_matrix[i : i + n_i, i : i + n_i] = space.ff_matrix
62
+ i += n_i
63
+
64
+ def _create_B_matrix_(self):
65
+ self.B_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
66
+ for i in range(self._n_surfaces):
67
+ for j in range(self._n_surfaces):
68
+ if i != j and self.surfaces[i] == self.surfaces[j]:
69
+ self.B_matrix[i][j] = 1
70
+
71
+ def _create_SW_matrices_(self):
72
+ SWR_matrix = np.identity(self._n_surfaces)
73
+ rho_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
74
+ tau_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
75
+ alpha_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
76
+ area_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
77
+
78
+ for i in range(self._n_surfaces):
79
+ rho_matrix[i][i] = self.surfaces[i].radiant_property("rho", "solar_diffuse", self.sides[i])
80
+ tau_matrix[i][i] = self.surfaces[i].radiant_property("tau", "solar_diffuse", self.sides[i])
81
+ # Negative (absortion)
82
+ alpha_matrix[i][i] = -1 * self.surfaces[i].radiant_property("alpha", "solar_diffuse", self.sides[i])
83
+ area_matrix[i][i] = self.surfaces[i].area
84
+
85
+ SWR_matrix = (SWR_matrix - np.matmul(self.ff_matrix, rho_matrix)
86
+ - np.matmul(self.ff_matrix, np.matmul(tau_matrix, self.B_matrix)))
87
+
88
+ SWR_matrix = np.linalg.inv(SWR_matrix)
89
+ aux_matrix = np.matmul(area_matrix, np.matmul(alpha_matrix, SWR_matrix))
90
+ self.SWDIF_matrix = np.matmul(aux_matrix, np.matmul(self.ff_matrix, tau_matrix)) # SW Solar Diffuse
91
+
92
+
93
+ dsr_dist_matrix = np.zeros((self._n_surfaces, self._n_spaces))
94
+ ig_dist_matrix = np.zeros((self._n_surfaces, self._n_spaces))
95
+ i_glob = 0
96
+ for j in range(self._n_spaces):
97
+ for i in range(len(self.spaces[j].surfaces)):
98
+ dsr_dist_matrix[i_glob][j] = self.spaces[j].dsr_dist_vector[i]
99
+ ig_dist_matrix[i_glob][j] = self.spaces[j].ig_dist_vector[i]
100
+ i_glob += 1
101
+
102
+ self.SWDIR_matrix = np.matmul(aux_matrix, dsr_dist_matrix)
103
+ self.SWIG_matrix = np.matmul(aux_matrix, ig_dist_matrix)
104
+
105
+ def _create_LW_matrices_(self):
106
+ LWR_matrix = np.identity(self._n_surfaces)
107
+ rho_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
108
+ tau_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
109
+ alpha_matrix = np.zeros((self._n_surfaces, self._n_surfaces))
110
+ area_matrix = np.zeros((self._n_surfaces,self._n_surfaces))
111
+
112
+ for i in range(self._n_surfaces):
113
+ rho_matrix[i][i] = self.surfaces[i].radiant_property("rho", "long_wave", self.sides[i])
114
+ tau_matrix[i][i] = self.surfaces[i].radiant_property("tau", "long_wave", self.sides[i])
115
+ # Negative (absortion)
116
+ alpha_matrix[i][i] = -1 * self.surfaces[i].radiant_property("alpha", "long_wave", self.sides[i])
117
+ area_matrix[i][i] = self.surfaces[i].area
118
+
119
+ LWR_matrix = (LWR_matrix - np.matmul(self.ff_matrix, rho_matrix)
120
+ - np.matmul(self.ff_matrix, np.matmul(tau_matrix, self.B_matrix)))
121
+
122
+ LWR_matrix = np.linalg.inv(LWR_matrix)
123
+ aux_matrix = np.matmul(area_matrix, np.matmul(alpha_matrix,LWR_matrix))
124
+
125
+ ig_dist_matrix = np.zeros((self._n_surfaces, self._n_spaces))
126
+ i_glob = 0
127
+ for j in range(self._n_spaces):
128
+ for i in range(len(self.spaces[j].surfaces)):
129
+ ig_dist_matrix[i_glob][j] = self.spaces[j].ig_dist_vector[i]
130
+ i_glob += 1
131
+
132
+ self.LWIG_matrix = np.matmul(aux_matrix, ig_dist_matrix)
133
+
134
+ # Temperature matrix
135
+ self.LWSUR_matrix = np.matmul(area_matrix, -1 * alpha_matrix) - np.matmul(
136
+ aux_matrix, np.matmul(self.ff_matrix, alpha_matrix)
137
+ )
138
+
139
+ H_RD = 5.705 # 4*sigma*(293^3)
140
+ self.LWSUR_matrix = H_RD * self.LWSUR_matrix
141
+
142
+ def _create_K_matrices_(self):
143
+ self.KS_matrix = np.copy(-self.LWSUR_matrix)
144
+ self.KSZ_matrix = np.zeros((self._n_surfaces, self._n_spaces))
145
+ self.KZ_matrix = np.zeros((self._n_spaces, self._n_spaces))
146
+
147
+ # KS_matriz, KSZ_matrix
148
+ for i in range(self._n_surfaces):
149
+ s_type = self.surfaces[i].parameter("type").value
150
+
151
+ if s_type == "Building_surface":
152
+ surface_type = self.surfaces[i].parameter("surface_type").value
153
+ if surface_type == "EXTERIOR":
154
+ k = self.surfaces[i].k
155
+ k_01 = self.surfaces[i].k_01
156
+ self.KS_matrix[i][i] += k[1] - (k_01**2) / k[0]
157
+ for j in range(self._n_spaces):
158
+ if self.spaces[j] == self.surfaces[i].get_space():
159
+ self.KSZ_matrix[i][j] = (
160
+ self.surfaces[i].area
161
+ * self.surfaces[i].parameter("h_cv").value[self.sides[i]]
162
+ )
163
+ elif surface_type == "UNDERGROUND":
164
+ k = self.surfaces[i].k
165
+ k_01 = self.surfaces[i].k_01
166
+ self.KS_matrix[i][i] += k[1]
167
+ for j in range(self._n_spaces):
168
+ if self.spaces[j] == self.surfaces[i].get_space():
169
+ self.KSZ_matrix[i][j] = (
170
+ self.surfaces[i].area
171
+ * self.surfaces[i].parameter("h_cv").value[0]
172
+ )
173
+ elif surface_type == "INTERIOR":
174
+ k = self.surfaces[i].k
175
+ k_01 = self.surfaces[i].k_01
176
+ self.KS_matrix[i][i] += k[self.sides[i]]
177
+ for j in range(self._n_surfaces):
178
+ if self.B_matrix[i][j] == 1:
179
+ self.KS_matrix[i][j] += k_01
180
+ for j in range(self._n_spaces):
181
+ if (self.spaces[j]== self.surfaces[i].get_space(self.sides[i])):
182
+ self.KSZ_matrix[i][j] = (
183
+ self.surfaces[i].area
184
+ * self.surfaces[i].parameter("h_cv").value[self.sides[i]]
185
+ )
186
+ elif surface_type == "VIRTUAL":
187
+ self.KS_matrix[i][i] += 1.0
188
+ for j in range(self._n_spaces):
189
+ if (self.spaces[j] == self.surfaces[i].parameter("spaces").component[self.sides[i]]):
190
+ self.KSZ_matrix[i][j] = 0
191
+ elif s_type == "Opening":
192
+ k = self.surfaces[i].k
193
+ k_01 = self.surfaces[i].k_01
194
+ if self.surfaces[i].is_exterior():
195
+ self.KS_matrix[i][i] += k[1] - (k_01**2) / k[0]
196
+ for j in range(self._n_spaces):
197
+ if (self.spaces[j] == self.surfaces[i].get_space()):
198
+ self.KSZ_matrix[i][j] = (
199
+ self.surfaces[i].area
200
+ * self.surfaces[i].parameter("h_cv").value[self.sides[i]]
201
+ )
202
+ else:
203
+ self.KS_matrix[i][i] += k[self.sides[i]]
204
+ for j in range(self._n_surfaces):
205
+ if self.B_matrix[i][j] == 1:
206
+ self.KS_matrix[i][j] += k_01
207
+ for j in range(self._n_spaces):
208
+ if (self.spaces[j]== self.surfaces[i].get_space(self.sides[i])):
209
+ self.KSZ_matrix[i][j] = (
210
+ self.surfaces[i].area
211
+ * self.surfaces[i].parameter("h_cv").value[self.sides[i]]
212
+ )
213
+
214
+ self.KS_inv_matrix = np.linalg.inv(self.KS_matrix)
215
+ # KZS
216
+ self.KZS_matrix = -1 * self.KSZ_matrix.transpose()
217
+
218
+ # KZ_matrix without air movement or systems
219
+ for i in range(self._n_spaces):
220
+ self.KZ_matrix[i][i] = (
221
+ self.spaces[i].parameter("volume").value * self.props["RHO_A"] * self.props["C_PA"]
222
+ + self.spaces[i].parameter("furniture_weight").value
223
+ * self.props["C_P_FURNITURE"]
224
+ ) / self.project().parameter("time_step").value
225
+ for j in range(self._n_surfaces):
226
+ self.KZ_matrix[i][i] += self.KSZ_matrix[j][i]
227
+
228
+
229
+ # _______________ pre_iteration _______________
230
+ def pre_iteration(self, time_index, date, daylight_saving):
231
+ super().pre_iteration(time_index, date, daylight_saving)
232
+ self._calculate_Q_igsw_(time_index)
233
+ self._calculate_Q_iglw_(time_index)
234
+ self._calculate_Q_dif_(time_index)
235
+ self._calculate_FZ_vector_(time_index)
236
+ self._update_K_matrices_(time_index)
237
+ self._calculate_Q_dir_(time_index)
238
+ self._calculate_FS_vector_(time_index)
239
+ self._calculate_FIN_WS_matrices_(time_index)
240
+ self._update_space_K_F_(time_index)
241
+
242
+ def _calculate_Q_igsw_(self, time_i):
243
+ E_ig = np.zeros(self._n_spaces)
244
+ for i in range(self._n_spaces):
245
+ E_ig[i] = self.spaces[i].variable("light_radiant").values[time_i]
246
+ self.Q_igsw = np.matmul(self.SWIG_matrix, E_ig)
247
+
248
+ def _calculate_Q_iglw_(self, time_i):
249
+ E_ig = np.zeros(self._n_spaces)
250
+ for i in range(self._n_spaces):
251
+ E_ig[i] = (
252
+ self.spaces[i].variable("people_radiant").values[time_i]
253
+ + self.spaces[i].variable("other_gains_radiant").values[time_i]
254
+ )
255
+ self.Q_iglw = np.matmul(self.LWIG_matrix, E_ig)
256
+
257
+ def _calculate_Q_dif_(self, time_i):
258
+ E_dif = np.zeros(self._n_surfaces)
259
+ for i in range(self._n_surfaces):
260
+ s_type = self.surfaces[i].parameter("type").value
261
+ if s_type == "Opening":
262
+ if self.surfaces[i].is_exterior():
263
+ E_dif[i] = self.surfaces[i].variable("E_dif").values[time_i]
264
+ elif s_type == "Building_surface":
265
+ surface_type = self.surfaces[i].parameter("surface_type").value
266
+ if surface_type == "EXTERIOR":
267
+ E_dif[i] = self.surfaces[i].variable("E_dif").values[time_i]
268
+ self.Q_dif = np.matmul(self.SWDIF_matrix, E_dif)
269
+
270
+ def _calculate_FZ_vector_(self, time_i):
271
+ self.FZ_vector = np.zeros(self._n_spaces)
272
+
273
+ for i in range(self._n_spaces):
274
+ if time_i == 0:
275
+ T_pre = self.parameter("initial_temperature").value
276
+ else:
277
+ T_pre = self.spaces[i].variable("temperature").values[time_i - 1]
278
+ self.FZ_vector[i] = (
279
+ self.spaces[i].variable("people_convective").values[time_i]
280
+ + self.spaces[i].variable("other_gains_convective").values[time_i]
281
+ + self.spaces[i].variable("light_convective").values[time_i]
282
+ )
283
+ self.FZ_vector[i] += (
284
+ (
285
+ self.spaces[i].parameter("volume").value * self.props["RHO_A"] * self.props["C_PA"]
286
+ + self.spaces[i].parameter("furniture_weight").value
287
+ * self.props["C_P_FURNITURE"]
288
+ )
289
+ * T_pre
290
+ / self.project().parameter("time_step").value
291
+ )
292
+ self.FZ_vector[i] += (
293
+ self.spaces[i].variable("infiltration_flow").values[time_i]
294
+ * self.props["RHO_A"]
295
+ * self.props["C_PA"]
296
+ * self._file_met_.variable("temperature").values[time_i]
297
+ )
298
+
299
+ def _update_K_matrices_(self, time_i):
300
+ self.KZFIN_matrix = self.KZ_matrix.copy()
301
+
302
+ # Add infiltration
303
+ for i in range(self._n_spaces):
304
+ self.KZFIN_matrix[i][i] += (
305
+ self.spaces[i].variable("infiltration_flow").values[time_i]
306
+ * self.props["RHO_A"]
307
+ * self.props["C_PA"]
308
+ )
309
+
310
+ def _calculate_Q_dir_(self, time_i):
311
+ E_dir = np.zeros(self._n_spaces)
312
+ for i in range(self._n_spaces):
313
+ self.spaces[i].calculate_solar_direct(time_i)
314
+ E_dir[i] = self.spaces[i].variable("solar_direct_gains").values[time_i]
315
+ self.Q_dir = np.matmul(self.SWDIR_matrix, E_dir)
316
+
317
+ def _calculate_FS_vector_(self, time_i):
318
+ self.FS_vector = np.zeros(self._n_surfaces)
319
+
320
+ for i in range(self._n_surfaces):
321
+ # positive surface incoming
322
+ Q_rad = -(self.Q_dir[i] + self.Q_dif[i] + self.Q_igsw[i] + self.Q_iglw[i])
323
+ s_type = self.surfaces[i].parameter("type").value
324
+ area = self.surfaces[i].area
325
+ if s_type == "Building_surface":
326
+ surface_type = self.surfaces[i].parameter("surface_type").value
327
+ if surface_type == "EXTERIOR":
328
+ self.surfaces[i].variable("q_sol1").values[time_i] = (
329
+ -(self.Q_dir[i] + self.Q_dif[i]) / area
330
+ )
331
+ self.surfaces[i].variable("q_swig1").values[time_i] = (
332
+ -self.Q_igsw[i] / area
333
+ )
334
+ self.surfaces[i].variable("q_lwig1").values[time_i] = (
335
+ -(self.Q_iglw[i]) / area
336
+ )
337
+ f = (
338
+ -area * self.surfaces[i].variable("p_1").values[time_i]
339
+ - Q_rad
340
+ - self.surfaces[i].f_0
341
+ * self.surfaces[i].k_01
342
+ / self.surfaces[i].k[0]
343
+ )
344
+ self.FS_vector[i] = f
345
+ elif surface_type == "UNDERGROUND":
346
+ self.surfaces[i].variable("q_sol1").values[time_i] = (
347
+ -(self.Q_dir[i] + self.Q_dif[i]) / area
348
+ )
349
+ self.surfaces[i].variable("q_swig1").values[time_i] = (
350
+ -self.Q_igsw[i] / area
351
+ )
352
+ self.surfaces[i].variable("q_lwig1").values[time_i] = (
353
+ -(self.Q_iglw[i]) / area
354
+ )
355
+ f = (
356
+ -area * self.surfaces[i].variable("p_1").values[time_i]
357
+ - Q_rad
358
+ - self.surfaces[i].k_01
359
+ * self.surfaces[i].variable("T_s0").values[time_i]
360
+ )
361
+ self.FS_vector[i] = f
362
+ elif surface_type == "INTERIOR":
363
+ if self.sides[i] == 0:
364
+ self.surfaces[i].variable("q_sol0").values[time_i] = (
365
+ -(self.Q_dir[i] + self.Q_dif[i]) / area
366
+ )
367
+ self.surfaces[i].variable("q_swig0").values[time_i] = (
368
+ -self.Q_igsw[i] / area
369
+ )
370
+ self.surfaces[i].variable("q_lwig0").values[time_i] = (
371
+ -(self.Q_iglw[i]) / area
372
+ )
373
+ f = (
374
+ -self.surfaces[i].area
375
+ * self.surfaces[i].variable("p_0").values[time_i]
376
+ - Q_rad
377
+ )
378
+ self.FS_vector[i] = f
379
+ else:
380
+ self.surfaces[i].variable("q_sol1").values[time_i] = (
381
+ -(self.Q_dir[i] + self.Q_dif[i]) / area
382
+ )
383
+ self.surfaces[i].variable("q_swig1").values[time_i] = (
384
+ -self.Q_igsw[i] / area
385
+ )
386
+ self.surfaces[i].variable("q_lwig1").values[time_i] = (
387
+ -(self.Q_iglw[i]) / area
388
+ )
389
+ f = (
390
+ -self.surfaces[i].area
391
+ * self.surfaces[i].variable("p_1").values[time_i]
392
+ - Q_rad
393
+ )
394
+ self.FS_vector[i] = f
395
+ elif surface_type == "VIRTUAL":
396
+ self.FS_vector[i] = 0.0
397
+ elif s_type == "Opening":
398
+ if self.surfaces[i].is_exterior():
399
+ q_sol_10 = -(self.Q_dir[i] + self.Q_dif[i]) / area
400
+ E_sol_int = q_sol_10 / self.surfaces[i].radiant_property("alpha", "solar_diffuse", 1)
401
+ E_swig_int = -self.Q_igsw[i] / (
402
+ area
403
+ * self.surfaces[i].radiant_property("alpha", "solar_diffuse", 1)
404
+ )
405
+ self.surfaces[i].variable("E_ref").values[time_i] = E_sol_int
406
+ self.surfaces[i].variable("E_ref_tra").values[time_i] = (
407
+ E_sol_int
408
+ * self.surfaces[i].radiant_property("tau", "solar_diffuse", 1)
409
+ )
410
+ self.surfaces[i].variable("q_sol1").values[time_i] += q_sol_10
411
+ self.surfaces[i].variable("q_sol0").values[
412
+ time_i
413
+ ] += E_sol_int * self.surfaces[i].radiant_property(
414
+ "alpha_other_side", "solar_diffuse", 1
415
+ )
416
+ self.surfaces[i].variable("q_swig1").values[time_i] = (
417
+ -self.Q_igsw[i] / area
418
+ )
419
+ self.surfaces[i].variable("q_swig0").values[time_i] = (
420
+ E_swig_int
421
+ * self.surfaces[i].radiant_property(
422
+ "alpha_other_side", "solar_diffuse", 1
423
+ )
424
+ )
425
+ self.surfaces[i].variable("q_lwig1").values[time_i] = (
426
+ -(self.Q_iglw[i]) / area
427
+ )
428
+ f_0 = (
429
+ self.surfaces[i].f_0
430
+ - (
431
+ self.surfaces[i].variable("q_sol0").values[time_i]
432
+ + self.surfaces[i].variable("q_swig0").values[time_i]
433
+ )
434
+ * area
435
+ )
436
+ f = (
437
+ -Q_rad
438
+ - (self.surfaces[i].variable("q_sol1").values[time_i] - q_sol_10)
439
+ * area
440
+ - f_0 * self.surfaces[i].k_01 / self.surfaces[i].k[0]
441
+ )
442
+ else:
443
+ if self.sides[i] == 0:
444
+ self.surfaces[i].variable("q_sol0").values[time_i] = (
445
+ -(self.Q_dir[i] + self.Q_dif[i]) / area
446
+ )
447
+ self.surfaces[i].variable("q_swig0").values[time_i] = (
448
+ -self.Q_igsw[i] / area
449
+ )
450
+ self.surfaces[i].variable("q_lwig0").values[time_i] = (
451
+ -(self.Q_iglw[i]) / area
452
+ )
453
+ f = - Q_rad
454
+ else:
455
+ self.surfaces[i].variable("q_sol1").values[time_i] = (
456
+ -(self.Q_dir[i] + self.Q_dif[i]) / area
457
+ )
458
+ self.surfaces[i].variable("q_swig1").values[time_i] = (
459
+ -self.Q_igsw[i] / area
460
+ )
461
+ self.surfaces[i].variable("q_lwig1").values[time_i] = (
462
+ -(self.Q_iglw[i]) / area
463
+ )
464
+ f = - Q_rad
465
+ self.FS_vector[i] = f
466
+
467
+ def _calculate_FIN_WS_matrices_(self, time_i): # Without Systems
468
+ self.KFIN_WS_matrix = self.KZFIN_matrix - np.matmul(
469
+ self.KZS_matrix, np.matmul(self.KS_inv_matrix, self.KSZ_matrix)
470
+ )
471
+ self.FFIN_WS_vector = self.FZ_vector - np.matmul(
472
+ self.KZS_matrix, np.matmul(self.KS_inv_matrix, self.FS_vector)
473
+ )
474
+
475
+ # _______________ iteration _______________
476
+ def iteration(self, time_index, date, daylight_saving, n_iter):
477
+ super().iteration(time_index, date, daylight_saving, n_iter)
478
+ self._update_space_K_F_(time_index)
479
+ self._store_surfaces_values_(time_index)
480
+ return True
481
+
482
+ def _update_space_K_F_(self, time_i):
483
+ for i in range(self._n_spaces):
484
+ F_spaces = 0
485
+ for j in range(self._n_spaces):
486
+ if i != j:
487
+ F_spaces -= self.KFIN_WS_matrix[i][j]* self.spaces[j].variable("temperature").values[time_i]
488
+ K_F={"K": self.KFIN_WS_matrix[i][i], "F":self.FFIN_WS_vector[i], "F_OS": F_spaces}
489
+ self.spaces[i].update_K_F(K_F)
490
+
491
+ def _store_surfaces_values_(self, time_i):
492
+ # T_spaces
493
+ T_spaces = np.zeros(self._n_spaces)
494
+ for i in range(self._n_spaces):
495
+ T_spaces[i] = self.spaces[i].variable("temperature").values[time_i]
496
+
497
+ # Calculate TS,
498
+ self.TS_vector = np.matmul(self.KS_inv_matrix, self.FS_vector) - np.matmul(self.KS_inv_matrix, np.matmul(self.KSZ_matrix,T_spaces))
499
+
500
+ # Store TS
501
+ for i in range(self._n_surfaces):
502
+ if self.surfaces[i].parameter("type").value == "Building_surface" and self.surfaces[i].parameter("surface_type").value != "VIRTUAL":
503
+ if self.sides[i] == 0:
504
+ self.surfaces[i].variable("T_s0").values[time_i] = self.TS_vector[i]
505
+ else:
506
+ self.surfaces[i].variable("T_s1").values[time_i] = self.TS_vector[i]
507
+
508
+
509
+ # _______________ post_iteration _______________
510
+ def post_iteration(self, time_index, date, daylight_saving, converged):
511
+ super().post_iteration(time_index, date, daylight_saving, converged)