jsthermalcomfort 0.0.2 → 0.1.2

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 (228) hide show
  1. package/README.md +196 -6
  2. package/lib/cjs/index.js +7 -434
  3. package/lib/cjs/models/a_pmv.js +140 -0
  4. package/lib/cjs/models/adaptive_ashrae.js +290 -0
  5. package/lib/cjs/models/adaptive_en.js +300 -0
  6. package/lib/cjs/models/ankle_draft.js +82 -0
  7. package/lib/cjs/models/at.js +52 -0
  8. package/lib/cjs/models/athb.js +135 -0
  9. package/lib/cjs/models/clo_tout.js +58 -0
  10. package/lib/cjs/models/cooling_effect.js +164 -0
  11. package/lib/cjs/models/discomfort_index.js +115 -0
  12. package/lib/cjs/models/e_pmv.js +154 -0
  13. package/lib/cjs/models/heat_index.js +60 -0
  14. package/lib/cjs/models/humidex.js +63 -0
  15. package/lib/cjs/models/index.js +71 -0
  16. package/lib/cjs/models/net.js +50 -0
  17. package/lib/cjs/models/pet_steady.js +443 -0
  18. package/lib/cjs/models/phs.js +458 -0
  19. package/lib/cjs/models/pmv.js +200 -0
  20. package/lib/cjs/models/pmv_ppd.js +404 -0
  21. package/lib/cjs/models/set_tmp.js +203 -0
  22. package/lib/cjs/models/solar_gain.js +163 -0
  23. package/lib/cjs/models/two_nodes.js +790 -0
  24. package/lib/cjs/models/use_fans_heatwave.js +203 -0
  25. package/lib/cjs/models/utci.js +609 -0
  26. package/lib/cjs/models/vertical_tmp_grad_ppd.js +95 -0
  27. package/lib/cjs/models/wbgt.js +72 -0
  28. package/lib/cjs/models/wc.js +37 -0
  29. package/lib/cjs/psychrometrics/enthalpy.js +24 -0
  30. package/lib/cjs/psychrometrics/index.js +28 -0
  31. package/lib/cjs/psychrometrics/p_sat.js +46 -0
  32. package/lib/cjs/psychrometrics/p_sat_torr.js +34 -0
  33. package/lib/cjs/psychrometrics/psy_ta_rh.js +51 -0
  34. package/lib/cjs/psychrometrics/t_dp.js +19 -0
  35. package/lib/cjs/psychrometrics/t_mrt.js +117 -0
  36. package/lib/cjs/psychrometrics/t_o.js +82 -0
  37. package/lib/cjs/psychrometrics/t_wb.js +23 -0
  38. package/lib/cjs/types/index.d.ts +7 -79
  39. package/lib/cjs/types/index.d.ts.map +1 -1
  40. package/lib/cjs/types/models/a_pmv.d.ts +133 -0
  41. package/lib/cjs/types/models/a_pmv.d.ts.map +1 -0
  42. package/lib/cjs/types/models/adaptive_ashrae.d.ts +211 -0
  43. package/lib/cjs/types/models/adaptive_ashrae.d.ts.map +1 -0
  44. package/lib/cjs/types/models/adaptive_en.d.ts +217 -0
  45. package/lib/cjs/types/models/adaptive_en.d.ts.map +1 -0
  46. package/lib/cjs/types/models/ankle_draft.d.ts +60 -0
  47. package/lib/cjs/types/models/ankle_draft.d.ts.map +1 -0
  48. package/lib/cjs/types/models/at.d.ts +34 -0
  49. package/lib/cjs/types/models/at.d.ts.map +1 -0
  50. package/lib/cjs/types/models/athb.d.ts +96 -0
  51. package/lib/cjs/types/models/athb.d.ts.map +1 -0
  52. package/lib/cjs/types/models/clo_tout.d.ts +45 -0
  53. package/lib/cjs/types/models/clo_tout.d.ts.map +1 -0
  54. package/lib/cjs/types/models/cooling_effect.d.ts +49 -0
  55. package/lib/cjs/types/models/cooling_effect.d.ts.map +1 -0
  56. package/lib/cjs/types/models/discomfort_index.d.ts +91 -0
  57. package/lib/cjs/types/models/discomfort_index.d.ts.map +1 -0
  58. package/lib/cjs/types/models/e_pmv.d.ts +139 -0
  59. package/lib/cjs/types/models/e_pmv.d.ts.map +1 -0
  60. package/lib/cjs/types/models/heat_index.d.ts +27 -0
  61. package/lib/cjs/types/models/heat_index.d.ts.map +1 -0
  62. package/lib/cjs/types/models/humidex.d.ts +54 -0
  63. package/lib/cjs/types/models/humidex.d.ts.map +1 -0
  64. package/lib/cjs/types/models/index.d.ts +78 -0
  65. package/lib/cjs/types/models/index.d.ts.map +1 -0
  66. package/lib/cjs/types/models/net.d.ts +39 -0
  67. package/lib/cjs/types/models/net.d.ts.map +1 -0
  68. package/lib/cjs/types/models/pet_steady.d.ts +59 -0
  69. package/lib/cjs/types/models/pet_steady.d.ts.map +1 -0
  70. package/lib/cjs/types/models/phs.d.ts +242 -0
  71. package/lib/cjs/types/models/phs.d.ts.map +1 -0
  72. package/lib/cjs/types/models/pmv.d.ts +198 -0
  73. package/lib/cjs/types/models/pmv.d.ts.map +1 -0
  74. package/lib/cjs/types/models/pmv_ppd.d.ts +246 -0
  75. package/lib/cjs/types/models/pmv_ppd.d.ts.map +1 -0
  76. package/lib/cjs/types/models/set_tmp.d.ts +124 -0
  77. package/lib/cjs/types/models/set_tmp.d.ts.map +1 -0
  78. package/lib/cjs/types/models/solar_gain.d.ts +76 -0
  79. package/lib/cjs/types/models/solar_gain.d.ts.map +1 -0
  80. package/lib/cjs/types/models/two_nodes.d.ts +412 -0
  81. package/lib/cjs/types/models/two_nodes.d.ts.map +1 -0
  82. package/lib/cjs/types/models/use_fans_heatwave.d.ts +188 -0
  83. package/lib/cjs/types/models/use_fans_heatwave.d.ts.map +1 -0
  84. package/lib/cjs/types/models/utci.d.ts +79 -0
  85. package/lib/cjs/types/models/utci.d.ts.map +1 -0
  86. package/lib/cjs/types/models/vertical_tmp_grad_ppd.d.ts +58 -0
  87. package/lib/cjs/types/models/vertical_tmp_grad_ppd.d.ts.map +1 -0
  88. package/lib/cjs/types/models/wbgt.d.ts +51 -0
  89. package/lib/cjs/types/models/wbgt.d.ts.map +1 -0
  90. package/lib/cjs/types/models/wc.d.ts +29 -0
  91. package/lib/cjs/types/models/wc.d.ts.map +1 -0
  92. package/lib/cjs/types/psychrometrics/enthalpy.d.ts +12 -0
  93. package/lib/cjs/types/psychrometrics/enthalpy.d.ts.map +1 -0
  94. package/lib/cjs/types/psychrometrics/index.d.ts +26 -0
  95. package/lib/cjs/types/psychrometrics/index.d.ts.map +1 -0
  96. package/lib/cjs/types/psychrometrics/p_sat.d.ts +13 -0
  97. package/lib/cjs/types/psychrometrics/p_sat.d.ts.map +1 -0
  98. package/lib/cjs/types/psychrometrics/p_sat_torr.d.ts +26 -0
  99. package/lib/cjs/types/psychrometrics/p_sat_torr.d.ts.map +1 -0
  100. package/lib/cjs/types/psychrometrics/psy_ta_rh.d.ts +51 -0
  101. package/lib/cjs/types/psychrometrics/psy_ta_rh.d.ts.map +1 -0
  102. package/lib/cjs/types/psychrometrics/t_dp.d.ts +9 -0
  103. package/lib/cjs/types/psychrometrics/t_dp.d.ts.map +1 -0
  104. package/lib/cjs/types/psychrometrics/t_mrt.d.ts +43 -0
  105. package/lib/cjs/types/psychrometrics/t_mrt.d.ts.map +1 -0
  106. package/lib/cjs/types/psychrometrics/t_o.d.ts +31 -0
  107. package/lib/cjs/types/psychrometrics/t_o.d.ts.map +1 -0
  108. package/lib/cjs/types/psychrometrics/t_wb.d.ts +12 -0
  109. package/lib/cjs/types/psychrometrics/t_wb.d.ts.map +1 -0
  110. package/lib/cjs/types/utilities/index.d.ts +28 -0
  111. package/lib/cjs/types/utilities/index.d.ts.map +1 -0
  112. package/lib/cjs/types/utilities/utilities.d.ts +377 -0
  113. package/lib/cjs/types/utilities/utilities.d.ts.map +1 -0
  114. package/lib/cjs/utilities/index.js +27 -0
  115. package/lib/cjs/utilities/utilities.js +903 -0
  116. package/lib/esm/index.js +4 -0
  117. package/lib/esm/models/a_pmv.js +135 -0
  118. package/lib/esm/models/adaptive_ashrae.js +285 -0
  119. package/lib/esm/models/adaptive_en.js +294 -0
  120. package/lib/esm/models/ankle_draft.js +78 -0
  121. package/lib/esm/models/at.js +48 -0
  122. package/lib/esm/models/athb.js +130 -0
  123. package/lib/esm/models/clo_tout.js +53 -0
  124. package/lib/esm/models/cooling_effect.js +159 -0
  125. package/lib/esm/models/discomfort_index.js +110 -0
  126. package/lib/esm/models/e_pmv.js +149 -0
  127. package/lib/esm/models/heat_index.js +56 -0
  128. package/lib/esm/models/humidex.js +59 -0
  129. package/lib/esm/models/index.js +69 -0
  130. package/lib/esm/models/net.js +46 -0
  131. package/lib/esm/models/pet_steady.js +439 -0
  132. package/lib/esm/models/phs.js +454 -0
  133. package/lib/esm/models/pmv.js +195 -0
  134. package/lib/esm/models/pmv_ppd.js +398 -0
  135. package/lib/esm/models/set_tmp.js +198 -0
  136. package/lib/esm/models/solar_gain.js +158 -0
  137. package/lib/esm/models/two_nodes.js +784 -0
  138. package/lib/esm/models/use_fans_heatwave.js +199 -0
  139. package/lib/esm/models/utci.js +604 -0
  140. package/lib/esm/models/wbgt.js +68 -0
  141. package/lib/esm/models/wc.js +33 -0
  142. package/lib/esm/psychrometrics/enthalpy.js +20 -0
  143. package/lib/esm/psychrometrics/index.js +26 -0
  144. package/lib/esm/psychrometrics/p_sat.js +42 -0
  145. package/lib/esm/psychrometrics/p_sat_torr.js +29 -0
  146. package/lib/esm/psychrometrics/psy_ta_rh.js +47 -0
  147. package/lib/esm/psychrometrics/t_dp.js +15 -0
  148. package/lib/esm/psychrometrics/t_mrt.js +112 -0
  149. package/lib/esm/psychrometrics/t_o.js +77 -0
  150. package/lib/esm/psychrometrics/t_wb.js +19 -0
  151. package/lib/esm/types/index.d.ts +7 -79
  152. package/lib/esm/types/index.d.ts.map +1 -1
  153. package/lib/esm/types/models/a_pmv.d.ts +133 -0
  154. package/lib/esm/types/models/a_pmv.d.ts.map +1 -0
  155. package/lib/esm/types/models/adaptive_ashrae.d.ts +211 -0
  156. package/lib/esm/types/models/adaptive_ashrae.d.ts.map +1 -0
  157. package/lib/esm/types/models/adaptive_en.d.ts +217 -0
  158. package/lib/esm/types/models/adaptive_en.d.ts.map +1 -0
  159. package/lib/esm/types/models/ankle_draft.d.ts +60 -0
  160. package/lib/esm/types/models/ankle_draft.d.ts.map +1 -0
  161. package/lib/esm/types/models/at.d.ts +34 -0
  162. package/lib/esm/types/models/at.d.ts.map +1 -0
  163. package/lib/esm/types/models/athb.d.ts +96 -0
  164. package/lib/esm/types/models/athb.d.ts.map +1 -0
  165. package/lib/esm/types/models/clo_tout.d.ts +45 -0
  166. package/lib/esm/types/models/clo_tout.d.ts.map +1 -0
  167. package/lib/esm/types/models/cooling_effect.d.ts +49 -0
  168. package/lib/esm/types/models/cooling_effect.d.ts.map +1 -0
  169. package/lib/esm/types/models/discomfort_index.d.ts +91 -0
  170. package/lib/esm/types/models/discomfort_index.d.ts.map +1 -0
  171. package/lib/esm/types/models/e_pmv.d.ts +139 -0
  172. package/lib/esm/types/models/e_pmv.d.ts.map +1 -0
  173. package/lib/esm/types/models/heat_index.d.ts +27 -0
  174. package/lib/esm/types/models/heat_index.d.ts.map +1 -0
  175. package/lib/esm/types/models/humidex.d.ts +54 -0
  176. package/lib/esm/types/models/humidex.d.ts.map +1 -0
  177. package/lib/esm/types/models/index.d.ts +77 -0
  178. package/lib/esm/types/models/index.d.ts.map +1 -0
  179. package/lib/esm/types/models/net.d.ts +39 -0
  180. package/lib/esm/types/models/net.d.ts.map +1 -0
  181. package/lib/esm/types/models/pet_steady.d.ts +59 -0
  182. package/lib/esm/types/models/pet_steady.d.ts.map +1 -0
  183. package/lib/esm/types/models/phs.d.ts +242 -0
  184. package/lib/esm/types/models/phs.d.ts.map +1 -0
  185. package/lib/esm/types/models/pmv.d.ts +198 -0
  186. package/lib/esm/types/models/pmv.d.ts.map +1 -0
  187. package/lib/esm/types/models/pmv_ppd.d.ts +246 -0
  188. package/lib/esm/types/models/pmv_ppd.d.ts.map +1 -0
  189. package/lib/esm/types/models/set_tmp.d.ts +124 -0
  190. package/lib/esm/types/models/set_tmp.d.ts.map +1 -0
  191. package/lib/esm/types/models/solar_gain.d.ts +76 -0
  192. package/lib/esm/types/models/solar_gain.d.ts.map +1 -0
  193. package/lib/esm/types/models/two_nodes.d.ts +412 -0
  194. package/lib/esm/types/models/two_nodes.d.ts.map +1 -0
  195. package/lib/esm/types/models/use_fans_heatwave.d.ts +188 -0
  196. package/lib/esm/types/models/use_fans_heatwave.d.ts.map +1 -0
  197. package/lib/esm/types/models/utci.d.ts +79 -0
  198. package/lib/esm/types/models/utci.d.ts.map +1 -0
  199. package/lib/esm/types/models/wbgt.d.ts +51 -0
  200. package/lib/esm/types/models/wbgt.d.ts.map +1 -0
  201. package/lib/esm/types/models/wc.d.ts +29 -0
  202. package/lib/esm/types/models/wc.d.ts.map +1 -0
  203. package/lib/esm/types/psychrometrics/enthalpy.d.ts +12 -0
  204. package/lib/esm/types/psychrometrics/enthalpy.d.ts.map +1 -0
  205. package/lib/esm/types/psychrometrics/index.d.ts +26 -0
  206. package/lib/esm/types/psychrometrics/index.d.ts.map +1 -0
  207. package/lib/esm/types/psychrometrics/p_sat.d.ts +13 -0
  208. package/lib/esm/types/psychrometrics/p_sat.d.ts.map +1 -0
  209. package/lib/esm/types/psychrometrics/p_sat_torr.d.ts +26 -0
  210. package/lib/esm/types/psychrometrics/p_sat_torr.d.ts.map +1 -0
  211. package/lib/esm/types/psychrometrics/psy_ta_rh.d.ts +51 -0
  212. package/lib/esm/types/psychrometrics/psy_ta_rh.d.ts.map +1 -0
  213. package/lib/esm/types/psychrometrics/t_dp.d.ts +9 -0
  214. package/lib/esm/types/psychrometrics/t_dp.d.ts.map +1 -0
  215. package/lib/esm/types/psychrometrics/t_mrt.d.ts +43 -0
  216. package/lib/esm/types/psychrometrics/t_mrt.d.ts.map +1 -0
  217. package/lib/esm/types/psychrometrics/t_o.d.ts +31 -0
  218. package/lib/esm/types/psychrometrics/t_o.d.ts.map +1 -0
  219. package/lib/esm/types/psychrometrics/t_wb.d.ts +12 -0
  220. package/lib/esm/types/psychrometrics/t_wb.d.ts.map +1 -0
  221. package/lib/esm/types/utilities/index.d.ts +28 -0
  222. package/lib/esm/types/utilities/index.d.ts.map +1 -0
  223. package/lib/esm/types/utilities/utilities.d.ts +377 -0
  224. package/lib/esm/types/utilities/utilities.d.ts.map +1 -0
  225. package/lib/esm/utilities/index.js +25 -0
  226. package/lib/esm/utilities/utilities.js +885 -0
  227. package/package.json +22 -15
  228. package/lib/esm/index.mjs +0 -430
@@ -0,0 +1,784 @@
1
+ import { round } from "../utilities/utilities.js";
2
+ import { p_sat_torr } from "../psychrometrics/p_sat_torr.js";
3
+ /**
4
+ * @typedef {Object} TwoNodesReturnType
5
+ * @property {number} e_skin – Total rate of evaporative heat loss from skin, [W/m2]. Equal to e_rsw + e_diff
6
+ * @property {number} e_rsw – Rate of evaporative heat loss from sweat evaporation, [W/m2]
7
+ * @property {number} e_max – Maximum rate of evaporative heat loss from skin, [W/m2]
8
+ * @property {number} q_sensible – Sensible heat loss from skin, [W/m2]
9
+ * @property {number} q_skin – Total rate of heat loss from skin, [W/m2]. Equal to q_sensible + e_skin
10
+ * @property {number} q_res – Total rate of heat loss through respiration, [W/m2]
11
+ * @property {number} t_core – Core temperature, [°C]
12
+ * @property {number} t_skin – Skin temperature, [°C]
13
+ * @property {number} m_bl – Skin blood flow, [kg/h/m2]
14
+ * @property {number} m_rsw – Rate at which regulatory sweat is generated, [kg/h/m2]
15
+ * @property {number} w – Skin wettedness, adimensional. Ranges from 0 and 1.
16
+ * @property {number} w_max – Skin wettedness (w) practical upper limit, adimensional. Ranges from 0 and 1.
17
+ * @property {number} set – Standard Effective Temperature (SET)
18
+ * @property {number} et – New Effective Temperature (ET)
19
+ * @property {number} pmv_gagge – PMV Gagge
20
+ * @property {number} pmv_set – PMV SET
21
+ * @property {number} disc – Thermal discomfort
22
+ * @property {number} t_sens – Predicted Thermal Sensation
23
+ * @public
24
+ */
25
+ /**
26
+ * @typedef {Object} TwoNodesKwargs - a keywords argument set containing the additional arguments for Two nodes model calculation
27
+ * @property {boolean} [round=true] - round the result of two nodes model
28
+ * @property {boolean} [calculate_ce=false] - select if SET is used to calculate Cooling Effect
29
+ * @property {number} [max_sweating] - maximum rate at which regulatory sweat is generated, [kg/h/m2]
30
+ * @property {number} [w_max] – maximum skin wettedness (w) adimensional. Ranges from 0 and 1
31
+ * @public
32
+ */
33
+ /**
34
+ * @typedef {Object} TwoNodesKwargsRequired
35
+ * @property {boolean} round
36
+ * @property {boolean} calculate_ce
37
+ * @property {number} max_sweating
38
+ * @property {number} w_max
39
+ */
40
+ /**
41
+ *
42
+ * Two-node model of human temperature regulation Gagge et al. (1986).
43
+ *
44
+ * {@link #ref_10|[10]} This model can be used to calculate a variety of indices, including:
45
+ *
46
+ * - Gagge’s version of Fanger’s Predicted Mean Vote (PMV). This function uses
47
+ * the Fanger’s PMV equations but it replaces the heat loss and gain terms
48
+ * with those calculated by the two node model developed by Gagge et al. (1986) {@link #ref_10|[10]}.
49
+ * - PMV SET and the predicted thermal sensation based on SET {@link #ref_10|[10]}. This function is
50
+ * similar in all aspects to the pythermalcomfort.models.pmv_gagge(). However, it uses the
51
+ * pythermalcomfort.models.set() equation to calculate the dry heat loss by convection.
52
+ * - Thermal discomfort (DISC) as the relative thermoregulatory strain necessary
53
+ * to restore a state of comfort and thermal equilibrium by sweating {@link #ref_10|[10]}. DISC is
54
+ * described numerically as: comfortable and pleasant (0), slightly uncomfortable but acceptable (1),
55
+ * uncomfortable and unpleasant (2), very uncomfortable (3), limited tolerance (4), and intolerable (S).
56
+ * The range of each category is ± 0.5 numerically. In the cold, the classical negative category
57
+ * descriptions used for Fanger’s PMV apply {@link #ref_10|[10]}.
58
+ * - Heat gains and losses via convection, radiation and conduction.
59
+ * - The Standard Effective Temperature (SET)
60
+ * - The New Effective Temperature (ET)
61
+ * - The Predicted Thermal Sensation (TSENS)
62
+ * - The Predicted Percent Dissatisfied Due to Draft (PD)
63
+ * - Predicted Percent Satisfied With the Level of Air Movement” (PS)
64
+ *
65
+ * @public
66
+ * @memberof models
67
+ * @docname Gagge et al. two-node model
68
+ *
69
+ * @see {@link two_nodes_array} for a version that supports arrays
70
+ *
71
+ * @param {number} tdb Dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'.
72
+ * @param {number} tr Mean radiant temperature, default in [°C]
73
+ * @param {number} v Air speed, default in [m/s]
74
+ * @param {number} rh Relative humidity, [%].
75
+ * @param {number} met Metabolic rate, [W/(m2)]
76
+ * @param {number} clo Clothing insulation, [clo]
77
+ * @param {number} [wme=0] External work, [W/(m2)] default 0
78
+ * @param {number} [body_surface_area=1.8258] Body surface area, default value 1.8258 [m2] in [ft2] if units = ‘IP’
79
+ * @param {number} [p_atmospheric=101325] Atmospheric pressure, default value 101325 [Pa] in [atm] if units = ‘IP’
80
+ * @param {"standing" | "sitting"} [body_position="standing"] Select either “sitting” or “standing”
81
+ * @param {number} [max_skin_blood_flow=90] Maximum blood flow from the core to the skin, [kg/h/m2] default 90
82
+ * @param {TwoNodesKwargs} [kwargs]
83
+ *
84
+ * @returns {TwoNodesReturnType} object with results of two_nodes
85
+ *
86
+ * @example
87
+ * const results = two_nodes(25, 25, 0.3, 50, 1.2, 0.5);
88
+ * console.log(results); // {
89
+ e_skin: 16.2,
90
+ e_rsw: 7,
91
+ e_max: 159.9,
92
+ q_sensible: 47.6,
93
+ q_skin: 63.8,
94
+ q_res: 5.2,
95
+ t_core: 36.9,
96
+ t_skin: 33.7,
97
+ m_bl: 12.9,
98
+ m_rsw: 10.3,
99
+ w: 0.1,
100
+ w_max: 0.6,
101
+ set: 23.6,
102
+ et: 25,
103
+ pmv_gagge: 0.1,
104
+ pmv_set: -0,
105
+ disc: 0.1,
106
+ t_sens: 0.1
107
+ }
108
+ *
109
+ */
110
+ export function two_nodes(tdb, tr, v, rh, met, clo, wme = 0, body_surface_area = 1.8258, p_atmospheric = 101325, body_position = "standing", max_skin_blood_flow = 90, kwargs = {}) {
111
+ const defaults_kwargs = {
112
+ calculate_ce: false,
113
+ round: true,
114
+ max_sweating: 500,
115
+ w_max: false,
116
+ };
117
+ let joint_kwargs = Object.assign(defaults_kwargs, kwargs);
118
+ const vapor_pressure = cal_vapor_pressure(tdb, rh);
119
+ if (joint_kwargs.calculate_ce) {
120
+ const ce_set_result = calculate_two_nodes(tdb, tr, v, met, clo, vapor_pressure, wme, body_surface_area, p_atmospheric, body_position, max_skin_blood_flow, { calculate_ce: true });
121
+ return {
122
+ set: ce_set_result.set,
123
+ };
124
+ }
125
+ const result = calculate_two_nodes(tdb, tr, v, met, clo, vapor_pressure, wme, body_surface_area, p_atmospheric, body_position, max_skin_blood_flow, joint_kwargs);
126
+ if (joint_kwargs.round) {
127
+ return {
128
+ e_skin: round(result.eSkin, 1),
129
+ e_rsw: round(result.eRsw, 1),
130
+ e_max: round(result.eMax, 1),
131
+ q_sensible: round(result.qSensible, 1),
132
+ q_skin: round(result.qSkin, 1),
133
+ q_res: round(result.qRes, 1),
134
+ t_core: round(result.tCore, 1),
135
+ t_skin: round(result.tSkin, 1),
136
+ m_bl: round(result.mBl, 1),
137
+ m_rsw: round(result.mRsw, 1),
138
+ w: round(result.w, 1),
139
+ w_max: round(result.wMax, 1),
140
+ set: round(result.set, 1),
141
+ et: round(result.et, 1),
142
+ pmv_gagge: round(result.pmvGagge, 1),
143
+ pmv_set: round(result.pmvSet, 1),
144
+ disc: round(result.disc, 1),
145
+ t_sens: round(result.tSens, 1),
146
+ };
147
+ }
148
+ return result;
149
+ }
150
+ const kClo = 0.25;
151
+ const bodyWeight = 70;
152
+ const metFactor = 58.2;
153
+ const sbc = 0.000000056697;
154
+ const cSw = 170;
155
+ const cDil = 120;
156
+ const cStr = 0.5;
157
+ const tempSkinNeutral = 33.7;
158
+ const tempCoreNeutral = 36.8;
159
+ const skinBloodFlowNeutral = 6.3;
160
+ /**
161
+ * @typedef {Object} TwoNodesArrayReturnType
162
+ * @property {number[]} e_skin – Array of total rate of evaporative heat loss from skin, [W/m2]. Equal to e_rsw + e_diff
163
+ * @property {number[]} e_rsw – Array of rate of evaporative heat loss from sweat evaporation, [W/m2]
164
+ * @property {number[]} e_max – Array of maximum rate of evaporative heat loss from skin, [W/m2]
165
+ * @property {number[]} q_sensible – Array of sensible heat loss from skin, [W/m2]
166
+ * @property {number[]} q_skin – Array of total rate of heat loss from skin, [W/m2]. Equal to q_sensible + e_skin
167
+ * @property {number[]} q_res – Array of total rate of heat loss through respiration, [W/m2]
168
+ * @property {number[]} t_core – Array of core temperature, [°C]
169
+ * @property {number[]} t_skin – Array of skin temperature, [°C]
170
+ * @property {number[]} m_bl – Array of skin blood flow, [kg/h/m2]
171
+ * @property {number[]} m_rsw – Array of rate at which regulatory sweat is generated, [kg/h/m2]
172
+ * @property {number[]} w – Array of skin wettedness, adimensional. Ranges from 0 and 1.
173
+ * @property {number[]} w_max – Array of skin wettedness (w) practical upper limit, adimensional. Ranges from 0 and 1.
174
+ * @property {number[]} set – Array of standard Effective Temperature (SET)
175
+ * @property {number[]} et – Array of new Effective Temperature (ET)
176
+ * @property {number[]} pmv_gagge – Array of PMV Gagge
177
+ * @property {number[]} pmv_set – Array of PMV SET
178
+ * @property {number[]} disc – Array of Thermal discomfort
179
+ * @property {number[]} t_sens – Array of Predicted Thermal Sensation
180
+ * @public
181
+ */
182
+ /**
183
+ * @typedef {Object} TwoNodesArrayKwargs
184
+ * @property {boolean} [round=true]
185
+ * @property {boolean} [calculate_ce=false]
186
+ * @property {number[]} [max_sweating]
187
+ * @property {number[]} [w_max]
188
+ * @public
189
+ */
190
+ /**
191
+ * @typedef {Object} TwoNodesArrayKwargsRequired
192
+ * @property {boolean} round
193
+ * @property {boolean} calculate_ce
194
+ * @property {number[]} max_sweating
195
+ * @property {number[]} w_max
196
+ */
197
+ /**
198
+ *
199
+ * Two nodes model of human temperature regulation Gagge et al. when the input parameters are arrays.
200
+ *
201
+ * {@link #ref_10|[10]} This model can be used to calculate a variety of indices, including:
202
+ *
203
+ * - Gagge’s version of Fanger’s Predicted Mean Vote (PMV). This function uses
204
+ * the Fanger’s PMV equations but it replaces the heat loss and gain terms
205
+ * with those calculated by the two node model developed by Gagge et al. (1986) {@link #ref_10|[10]}.
206
+ * - PMV SET and the predicted thermal sensation based on SET {@link #ref_10|[10]}. This function is
207
+ * similar in all aspects to the pythermalcomfort.models.pmv_gagge(). However, it uses the
208
+ * pythermalcomfort.models.set() equation to calculate the dry heat loss by convection.
209
+ * - Thermal discomfort (DISC) as the relative thermoregulatory strain necessary
210
+ * to restore a state of comfort and thermal equilibrium by sweating {@link #ref_10|[10]}. DISC is
211
+ * described numerically as: comfortable and pleasant (0), slightly uncomfortable but acceptable (1),
212
+ * uncomfortable and unpleasant (2), very uncomfortable (3), limited tolerance (4), and intolerable (S).
213
+ * The range of each category is ± 0.5 numerically. In the cold, the classical negative category
214
+ * descriptions used for Fanger’s PMV apply {@link #ref_10|[10]}.
215
+ * - Heat gains and losses via convection, radiation and conduction.
216
+ * - The Standard Effective Temperature (SET)
217
+ * - The New Effective Temperature (ET)
218
+ * - The Predicted Thermal Sensation (TSENS)
219
+ * - The Predicted Percent Dissatisfied Due to Draft (PD)
220
+ * - Predicted Percent Satisfied With the Level of Air Movement” (PS)
221
+ *
222
+ * @public
223
+ * @memberof models
224
+ * @docname Gagge et al. two-node model (array version)
225
+ *
226
+ * @see {@link two_nodes} for a version that supports scalar arguments
227
+ *
228
+ * @param {number[]} tdbArray Dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'.
229
+ * @param {number[]} trArray Mean radiant temperature, default in [°C]
230
+ * @param {number[]} vArray Air speed, default in [m/s]
231
+ * @param {number[]} rhArray Relative humidity, [%].
232
+ * @param {number[]} metArray Metabolic rate, [W/(m2)]
233
+ * @param {number[]} cloArray Clothing insulation, [clo]
234
+ * @param {number[]} wmeArray External work, [W/(m2)] default 0
235
+ * @param {number[]} bodySurfaceArray Body surface area, default value 1.8258 [m2] in [ft2] if units = ‘IP’
236
+ * @param {number[]} pAtmArray Atmospheric pressure, default value 101325 [Pa] in [atm] if units = ‘IP’
237
+ * @param {"standing" | "sitting"} bodyPositionArray Select either “sitting” or “standing”
238
+ * @param {number[]} maxSkinBloodFlowArray Maximum blood flow from the core to the skin, [kg/h/m2] default 90
239
+ * @param {TwoNodesKwargs} [kwargs]
240
+ *
241
+ * @returns {TwoNodesArrayReturnType} object with results of two_nodes_array
242
+ *
243
+ * @example
244
+ * const results = two_nodes_array([25,30], [25,35], [0.3,0.5], [50,60], [1.2,1.5], [0.5, 0.3], [0,0], [1.8258,1.8258], [101325,101325], ["standing","standing"], [90,90])
245
+ * console.log(results); // {
246
+ e_skin: [ 16.2, 60.4 ],
247
+ e_rsw: [ 7, 51.9 ],
248
+ e_max: [ 159.9, 193.8 ],
249
+ q_sensible: [ 47.6, 21.1 ],
250
+ q_skin: [ 63.8, 81.5 ],
251
+ q_res: [ 5.2, 5 ],
252
+ t_core: [ 36.9, 37 ],
253
+ t_skin: [ 33.7, 35.1 ],
254
+ m_bl: [ 12.9, 31.6 ],
255
+ m_rsw: [ 10.3, 76.3 ],
256
+ w: [ 0.1, 0.3 ],
257
+ w_max: [ 0.6, 0.6 ],
258
+ set: [ 23.6, 29.3 ],
259
+ et: [ 25, 32.5 ],
260
+ pmv_gagge: [ 0.1, 1.6 ],
261
+ pmv_set: [ -0, 1.1 ],
262
+ disc: [ 0.1, 1.9 ],
263
+ t_sens: [ 0.1, 1.4 ]
264
+ }
265
+ *
266
+ */
267
+ export function two_nodes_array(tdbArray, trArray, vArray, rhArray, metArray, cloArray, wmeArray, bodySurfaceArray, pAtmArray, bodyPositionArray, maxSkinBloodFlowArray, kwargs = {}) {
268
+ const defaults_kwargs = {
269
+ calculate_ce: false,
270
+ round: true,
271
+ max_sweating: 500,
272
+ w_max: false,
273
+ };
274
+ let joint_kwargs = Object.assign(defaults_kwargs, kwargs);
275
+ const vaporPressureArray = rhArray.map((_rh, index) => cal_vapor_pressure(tdbArray[index], _rh));
276
+ if (wmeArray === undefined) {
277
+ wmeArray = tdbArray.map((_) => 0);
278
+ }
279
+ if (bodySurfaceArray === undefined) {
280
+ bodySurfaceArray = tdbArray.map((_) => 1.8258);
281
+ }
282
+ if (pAtmArray === undefined) {
283
+ pAtmArray = tdbArray.map((_) => 101325);
284
+ }
285
+ if (bodyPositionArray === undefined) {
286
+ bodyPositionArray = tdbArray.map((_) => "standing");
287
+ }
288
+ if (maxSkinBloodFlowArray === undefined) {
289
+ maxSkinBloodFlowArray = tdbArray.map((_) => 90);
290
+ }
291
+ if (joint_kwargs.calculate_ce) {
292
+ const ceSetArray = new Array(tdbArray.length);
293
+ for (let index = 0; index < tdbArray.length; index++) {
294
+ const ceSetResult = calculate_two_nodes(tdbArray[index], trArray[index], vArray[index], metArray[index], cloArray[index], vaporPressureArray[index], wmeArray[index], bodySurfaceArray[index], pAtmArray[index], bodyPositionArray[index], maxSkinBloodFlowArray[index], { calculate_ce: true });
295
+ ceSetArray[index] = ceSetResult.set;
296
+ }
297
+ return {
298
+ set: ceSetArray,
299
+ };
300
+ }
301
+ const setArray = new Array(tdbArray.length);
302
+ const eSkinArray = new Array(tdbArray.length);
303
+ const eRswArray = new Array(tdbArray.length);
304
+ const eMaxArray = new Array(tdbArray.length);
305
+ const qSensArray = new Array(tdbArray.length);
306
+ const qSkinArray = new Array(tdbArray.length);
307
+ const qResArray = new Array(tdbArray.length);
308
+ const tCoreArray = new Array(tdbArray.length);
309
+ const tSkinArray = new Array(tdbArray.length);
310
+ const mBlArray = new Array(tdbArray.length);
311
+ const mRswArray = new Array(tdbArray.length);
312
+ const wArray = new Array(tdbArray.length);
313
+ const wMaxArray = new Array(tdbArray.length);
314
+ const etArray = new Array(tdbArray.length);
315
+ const pmvGaggeArray = new Array(tdbArray.length);
316
+ const pmvSetArray = new Array(tdbArray.length);
317
+ const discArray = new Array(tdbArray.length);
318
+ const tSensArray = new Array(tdbArray.length);
319
+ for (let index = 0; index < tdbArray.length; index++) {
320
+ const result = calculate_two_nodes(tdbArray[index], trArray[index], vArray[index], metArray[index], cloArray[index], vaporPressureArray[index], wmeArray[index], bodySurfaceArray[index], pAtmArray[index], bodyPositionArray[index], maxSkinBloodFlowArray[index], joint_kwargs);
321
+ setArray[index] = result.set;
322
+ eSkinArray[index] = result.eSkin;
323
+ eRswArray[index] = result.eRsw;
324
+ eMaxArray[index] = result.eMax;
325
+ qSensArray[index] = result.qSensible;
326
+ qSkinArray[index] = result.qSkin;
327
+ qResArray[index] = result.qRes;
328
+ tCoreArray[index] = result.tCore;
329
+ tSkinArray[index] = result.tSkin;
330
+ mBlArray[index] = result.mBl;
331
+ mRswArray[index] = result.mRsw;
332
+ wArray[index] = result.w;
333
+ wMaxArray[index] = result.wMax;
334
+ etArray[index] = result.et;
335
+ pmvGaggeArray[index] = result.pmvGagge;
336
+ pmvSetArray[index] = result.pmvSet;
337
+ discArray[index] = result.disc;
338
+ tSensArray[index] = result.tSens;
339
+ }
340
+ if (joint_kwargs.round) {
341
+ return {
342
+ e_skin: roundArray(eSkinArray, 1),
343
+ e_rsw: roundArray(eRswArray, 1),
344
+ e_max: roundArray(eMaxArray, 1),
345
+ q_sensible: roundArray(qSensArray, 1),
346
+ q_skin: roundArray(qSkinArray, 1),
347
+ q_res: roundArray(qResArray, 1),
348
+ t_core: roundArray(tCoreArray, 1),
349
+ t_skin: roundArray(tSkinArray, 1),
350
+ m_bl: roundArray(mBlArray, 1),
351
+ m_rsw: roundArray(mRswArray, 1),
352
+ w: roundArray(wArray, 1),
353
+ w_max: roundArray(wMaxArray, 1),
354
+ set: roundArray(setArray, 1),
355
+ et: roundArray(etArray, 1),
356
+ pmv_gagge: roundArray(pmvGaggeArray, 1),
357
+ pmv_set: roundArray(pmvSetArray, 1),
358
+ disc: roundArray(discArray, 1),
359
+ t_sens: roundArray(tSensArray, 1),
360
+ };
361
+ }
362
+ else {
363
+ return {
364
+ e_skin: eSkinArray,
365
+ e_rsw: eRswArray,
366
+ e_max: eMaxArray,
367
+ q_sensible: qSensArray,
368
+ q_skin: qSkinArray,
369
+ q_res: qResArray,
370
+ t_core: tCoreArray,
371
+ t_skin: tSkinArray,
372
+ m_bl: mBlArray,
373
+ m_rsw: mRswArray,
374
+ w: wArray,
375
+ w_max: wMaxArray,
376
+ set: setArray,
377
+ et: etArray,
378
+ pmv_gagge: pmvGaggeArray,
379
+ pmv_set: pmvSetArray,
380
+ disc: discArray,
381
+ t_sens: tSensArray,
382
+ };
383
+ }
384
+ }
385
+ /**
386
+ * Round all elments in a given array to the given precision.
387
+ *
388
+ * @param {number[]} array - the array to round
389
+ * @param {number} precision - the number of decimal places to round to
390
+ * @returns the rounded result
391
+ */
392
+ export function roundArray(array, precision) {
393
+ for (let index = 0; index < array.length; ++index) {
394
+ array[index] = round(array[index], precision);
395
+ }
396
+ return array;
397
+ }
398
+ /**
399
+ * Calculate vapor pressure based on air temperature and relative humidity.
400
+ *
401
+ * @param {number} tdb - air temperature [C]
402
+ * @param {number} rh - relative humidity [%]
403
+ * @returns {number} vapor pressure
404
+ */
405
+ function cal_vapor_pressure(tdb, rh) {
406
+ return (rh * p_sat_torr(tdb)) / 100;
407
+ }
408
+ /**
409
+ * Calculate metabolic rate based on metabolic [W/(m2)] and external work.
410
+ *
411
+ * @param {number} met - Metabolic rate, [W/(m2)]
412
+ * @param {number} wme - External work, default 0
413
+ * @returns {number} metabolic rate
414
+ */
415
+ function calculate_metabolic_rate(met, wme) {
416
+ return (met - wme) * metFactor;
417
+ }
418
+ /**
419
+ * Calculate wettedness (w) practical upper limit based on airspeed and clothing insulation
420
+ *
421
+ * @param {number} airSpeed Airspeed
422
+ * @param {number} clo Clothing insulation, [clo]
423
+ * @param {TwoNodesKwargs} [kwargs]
424
+ * @returns {number} wettedness practical upper limit
425
+ */
426
+ function calculate_w_max(airSpeed, clo, kwargs) {
427
+ let wMax = 0;
428
+ if (!kwargs.w_max) {
429
+ wMax = 0.38 * Math.pow(airSpeed, -0.29);
430
+ if (clo > 0) {
431
+ wMax = 0.59 * Math.pow(airSpeed, -0.08);
432
+ }
433
+ }
434
+ return wMax;
435
+ }
436
+ /**
437
+ * Calculate Predicted Thermal Sensation based on max wettedness, metabolic rate and mean body temperature
438
+ *
439
+ * @param {number} tBody mean body temperature
440
+ * @param {number} rm retabolic rate
441
+ * @param {number} wMax wettedness practical upper limit
442
+ * @returns {number} thermal sansation
443
+ */
444
+ function calculate_thermal_sansation(tBody, rm, wMax) {
445
+ const tbmL = (0.194 / 58.15) * rm + 36.301;
446
+ const tbmH = (0.347 / 58.15) * rm + 36.669;
447
+ let tSens = 0.4685 * (tBody - tbmL);
448
+ if (tBody >= tbmL && tBody < tbmH) {
449
+ tSens = (wMax * 4.7 * (tBody - tbmL)) / (tbmH - tbmL);
450
+ }
451
+ else if (tBody >= tbmH) {
452
+ tSens = wMax * 4.7 + 0.4685 * (tBody - tbmH);
453
+ }
454
+ return tSens;
455
+ }
456
+ /**
457
+ * Calculate standard effective temperature
458
+ *
459
+ * @param {number} tSkin skin temperature
460
+ * @param {number} qSkin total heat loss from skin
461
+ * @param {number} hDS
462
+ * @param {number} pSSk saturation vapour pressure of water of the skin
463
+ * @param {number} w skin wettness
464
+ * @param {number} hES
465
+ * @returns {number} SET
466
+ */
467
+ function calculate_set(tSkin, qSkin, hDS, pSSk, w, hES) {
468
+ let delta = 0.0001;
469
+ let dx = 100.0;
470
+ let setOld = tSkin - qSkin / hDS;
471
+ let set = 0;
472
+ while (Math.abs(dx) > 0.01) {
473
+ const err1 = qSkin -
474
+ hDS * (tSkin - setOld) -
475
+ w * hES * (pSSk - 0.5 * Math.exp(18.6686 - 4030.183 / (setOld + 235.0)));
476
+ const err2 = qSkin -
477
+ hDS * (tSkin - (setOld + delta)) -
478
+ w *
479
+ hES *
480
+ (pSSk - 0.5 * Math.exp(18.6686 - 4030.183 / (setOld + delta + 235.0)));
481
+ set = setOld - (delta * err1) / (err2 - err1);
482
+ dx = set - setOld;
483
+ setOld = set;
484
+ }
485
+ return set;
486
+ }
487
+ /**
488
+ * Calculate effective temperature
489
+ *
490
+ * @param {number} tSkin skin temperature
491
+ * @param {number} qSkin total heat loss from skin
492
+ * @param {number} pSSk saturation vapour pressure of water of the skin
493
+ * @param {number} w skin wettness
494
+ * @param {number} rA
495
+ * @param {number} rA
496
+ * @param {number} rEa
497
+ * @param {number} rEcl
498
+ * @returns {number} ET
499
+ */
500
+ function calculate_et(tSkin, qSkin, pSSk, w, rA, rClo, rEa, rEcl) {
501
+ const hD = 1 / (rA + rClo);
502
+ const hE = 1 / (rEa + rEcl);
503
+ let etOld = tSkin - qSkin / hD;
504
+ let delta = 0.0001;
505
+ let dx = 100.0;
506
+ let et = 0;
507
+ while (Math.abs(dx) > 0.01) {
508
+ const err1 = qSkin -
509
+ hD * (tSkin - etOld) -
510
+ w * hE * (pSSk - 0.5 * Math.exp(18.6686 - 4030.183 / (etOld + 235.0)));
511
+ const err2 = qSkin -
512
+ hD * (tSkin - (etOld + delta)) -
513
+ w *
514
+ hE *
515
+ (pSSk - 0.5 * Math.exp(18.6686 - 4030.183 / (etOld + delta + 235.0)));
516
+ et = etOld - (delta * err1) / (err2 - err1);
517
+ dx = et - etOld;
518
+ etOld = et;
519
+ }
520
+ return et;
521
+ }
522
+ /**
523
+ * Calculate thermal discomfort
524
+ *
525
+ * @param {number} eRsw rate of evaporative heat loss from sweat evaporation
526
+ * @param {number} eComfort evaporative heat loss during comfort
527
+ * @param {number} eMax maximum rate of evaporative heat loss from skin
528
+ * @param {number} wMax maximum skin wettness
529
+ * @param {number} eDiff rate of evaporative heat loss from moisture diffused through the skin
530
+ * @param {number} tSens thermal sansation
531
+ * @returns {number} Thermal discomfort
532
+ */
533
+ function calculate_discomfort(eRsw, eComfort, eMax, wMax, eDiff, tSens) {
534
+ let disc = (4.7 * (eRsw - eComfort)) / (eMax * wMax - eComfort - eDiff);
535
+ if (disc <= 0) {
536
+ disc = tSens;
537
+ }
538
+ return disc;
539
+ }
540
+ /**
541
+ * Calculate PMV Gagge
542
+ *
543
+ * @param {number} m metabolic rate
544
+ * @param {number} eReq evaporative heat loss required for tmp regulation
545
+ * @param {number} eComfort evaporative heat loss during comfort
546
+ * @param {number} eDiff rate of evaporative heat loss from moisture diffused through the skin
547
+ * @returns {number} PMV Gagge
548
+ */
549
+ function calculate_pmv_gagge(m, eReq, eComfort, eDiff) {
550
+ return (0.303 * Math.exp(-0.036 * m) + 0.028) * (eReq - eComfort - eDiff);
551
+ }
552
+ /**
553
+ * Calculate PMV SET
554
+ *
555
+ * @param {number} m metabolic rate
556
+ * @param {number} eComfort evaporative heat loss during comfort
557
+ * @param {number} eDiff rate of evaporative heat loss from moisture diffused through the skin
558
+ * @param {number} hDS
559
+ * @param {number} tSkin skin temperature
560
+ * @param {number} set SET
561
+ * @param {number} rm metabolic rate
562
+ * @param {number} cRes convective heat loss respiration
563
+ * @param {number} qRes heat loss due to respiration
564
+ * @returns {number} PMV SET
565
+ */
566
+ function calculate_pmv_set(m, eComfort, eDiff, hDS, tSkin, set, rm, cRes, qRes) {
567
+ const drySet = hDS * (tSkin - set);
568
+ const eReqSet = rm - cRes - qRes - drySet;
569
+ return (0.303 * Math.exp(-0.036 * m) + 0.028) * (eReqSet - eComfort - eDiff);
570
+ }
571
+ /**
572
+ * Calculate Predicted Percent Satisfied With the Level of Air Movement
573
+ *
574
+ * @param {number} tOp operative temperature
575
+ * @param {number} v Air speed, default in [m/s]
576
+ * @returns {number} predicted percent satisfied
577
+ */
578
+ function calculate_percent_satisfied(tOp, v) {
579
+ return (100 * (1.13 * Math.sqrt(tOp) - 0.24 * tOp + 2.7 * Math.sqrt(v) - 0.99 * v));
580
+ }
581
+ /**
582
+ * @param {number} tdb Dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'.
583
+ * @param {number} tr Mean radiant temperature, default in [°C]
584
+ * @param {number} v Air speed, default in [m/s]
585
+ * @param {number} met Metabolic rate, [W/(m2)]
586
+ * @param {number} clo Clothing insulation, [clo]
587
+ * @param {number} vaporPressure Vapor pressure
588
+ * @param {number} wme External work, [W/(m2)] default 0
589
+ * @param {number} bodySurfaceArea Body surface area, default value 1.8258 [m2] in [ft2] if units = ‘IP’
590
+ * @param {number} pAtmospheric Atmospheric pressure, default value 101325 [Pa] in [atm] if units = ‘IP’
591
+ * @param {"standing" | "sitting"} bodyPosition Select either “sitting” or “standing”
592
+ * @param {number} maxSkinBloodFlow Maximum blood flow from the core to the skin, [kg/h/m2] default 90
593
+ * @param {TwoNodesKwargs} [kwargs]
594
+ *
595
+ */
596
+ function calculate_two_nodes(tdb, tr, v, met, clo, vaporPressure, wme, bodySurfaceArea, pAtmospheric, bodyPosition, maxSkinBloodFlow, kwargs) {
597
+ const airSpeed = Math.max(v, 0.1);
598
+ let alfa = 0.1;
599
+ const tempBodyNeutral = alfa * tempSkinNeutral + (1 - alfa) * tempCoreNeutral;
600
+ let tSkin = tempSkinNeutral;
601
+ let tCore = tempCoreNeutral;
602
+ let mBl = skinBloodFlowNeutral;
603
+ let eSkin = 0.1 * met; // total evaporative heat loss, W
604
+ let qSensible = 0; // total sensible heat loss, W
605
+ let w = 0; // skin wettedness
606
+ let set = 0; // standard effective temperature
607
+ let eRsw = 0; // heat lost by vaporization sweat
608
+ let eDiff = 0; // vapor diffusion through skin
609
+ let eMax = 0; // maximum evaporative capacity
610
+ let mRsw = 0; // regulatory sweating
611
+ let qRes = 0; // heat loss due to respiration
612
+ let et = 0; // effective temperature
613
+ let eReq = 0; // evaporative heat loss required for tmp regulation
614
+ let rEa = 0;
615
+ let rEcl = 0;
616
+ let cRes = 0; // convective heat loss respiration
617
+ const pressureInAtmospheres = pAtmospheric / 101325;
618
+ const lengthTimeSimulation = 60;
619
+ let nSimulation = 0;
620
+ const rClo = 0.155 * clo; // thermal resistance of clothing, C M^2 /W
621
+ const fACl = 1.0 + 0.15 * clo; // increase in body surface area due to clothing
622
+ const lr = 2.2 / pressureInAtmospheres; // Lewis ratio
623
+ let rm = calculate_metabolic_rate(met, wme);
624
+ let m = met * metFactor;
625
+ let eComfort = 0.42 * (rm - metFactor);
626
+ if (eComfort < 0) {
627
+ eComfort = 0;
628
+ }
629
+ let iCl = 1.0;
630
+ if (clo > 0) {
631
+ iCl = 0.45;
632
+ }
633
+ const wMax = calculate_w_max(airSpeed, clo, kwargs);
634
+ let hCc = 3.0 * Math.pow(pressureInAtmospheres, 0.53);
635
+ const hFc = 8.600001 * Math.pow(airSpeed * pressureInAtmospheres, 0.53);
636
+ hCc = Math.max(hCc, hFc);
637
+ if (!kwargs.calculate_ce && met > 0.85) {
638
+ const hCMet = 5.66 * Math.pow(met - 0.85, 0.39);
639
+ hCc = Math.max(hCc, hCMet);
640
+ }
641
+ let hR = 4.7;
642
+ let hT = hR + hCc;
643
+ let rA = 1.0 / (fACl * hT);
644
+ let tOp = (hR * tr + hCc * tdb) / hT;
645
+ let tBody = alfa * tSkin + (1 - alfa) * tCore;
646
+ qRes = 0.0023 * m * (44.0 - vaporPressure);
647
+ cRes = 0.0014 * m * (34.0 - tdb);
648
+ while (nSimulation < lengthTimeSimulation) {
649
+ nSimulation += 1;
650
+ const iterationLimit = 150;
651
+ let tCl = (rA * tSkin + rClo * tOp) / (rA + rClo);
652
+ let nIterations = 0;
653
+ let tcConverged = false;
654
+ while (!tcConverged) {
655
+ if (bodyPosition === "sitting") {
656
+ hR = 4.0 * 0.95 * sbc * ((tCl + tr) / 2.0 + 273.15) ** 3.0 * 0.7;
657
+ }
658
+ else {
659
+ hR = 4.0 * 0.95 * sbc * ((tCl + tr) / 2.0 + 273.15) ** 3.0 * 0.73;
660
+ }
661
+ hT = hR + hCc;
662
+ rA = 1.0 / (fACl * hT);
663
+ tOp = (hR * tr + hCc * tdb) / hT;
664
+ const tClNew = (rA * tSkin + rClo * tOp) / (rA + rClo);
665
+ if (Math.abs(tClNew - tCl) <= 0.01) {
666
+ tcConverged = true;
667
+ }
668
+ tCl = tClNew;
669
+ nIterations += 1;
670
+ if (nIterations > iterationLimit) {
671
+ throw new Error("Max iterations exceeded");
672
+ }
673
+ }
674
+ qSensible = (tSkin - tOp) / (rA + rClo);
675
+ const hfCs = (tCore - tSkin) * (5.28 + 1.163 * mBl);
676
+ const sCore = m - hfCs - qRes - cRes - wme; // rate of energy storage in the core
677
+ const sSkin = hfCs - qSensible - eSkin; // rate of energy storage in the skin
678
+ const tcSk = 0.97 * alfa * bodyWeight; // thermal capacity skin
679
+ const tcCr = 0.97 * (1 - alfa) * bodyWeight; // thermal capacity core
680
+ const dTSk = (sSkin * bodySurfaceArea) / (tcSk * 60.0); // rate of change skin temperature °C per minute
681
+ const dTCr = (sCore * bodySurfaceArea) / (tcCr * 60.0); // rate of change core temperature °C per minute
682
+ tSkin = tSkin + dTSk;
683
+ tCore = tCore + dTCr;
684
+ tBody = alfa * tSkin + (1 - alfa) * tCore;
685
+ const skSig = tSkin - tempSkinNeutral;
686
+ const warmSk = (skSig > 0) * skSig; // vasodilation signal
687
+ const colds = (-1.0 * skSig > 0) * (-1.0 * skSig); // vasoconstriction signal
688
+ const cRegSig = tCore - tempCoreNeutral;
689
+ const cWarm = (cRegSig > 0) * cRegSig;
690
+ const cCold = (-1.0 * cRegSig > 0) * (-1.0 * cRegSig);
691
+ const bdSig = tBody - tempBodyNeutral;
692
+ const warmB = (bdSig > 0) * bdSig;
693
+ mBl = (skinBloodFlowNeutral + cDil * cWarm) / (1 + cStr * colds);
694
+ if (mBl > maxSkinBloodFlow) {
695
+ mBl = maxSkinBloodFlow;
696
+ }
697
+ if (mBl < 0.5) {
698
+ mBl = 0.5;
699
+ }
700
+ mRsw = cSw * warmB * Math.exp(warmSk / 10.7);
701
+ if (mRsw > kwargs.max_sweating) {
702
+ mRsw = kwargs.max_sweating;
703
+ }
704
+ eRsw = 0.68 * mRsw;
705
+ rEa = 1.0 / (lr * fACl * hCc);
706
+ rEcl = rClo / (lr * iCl);
707
+ eReq = rm - qRes - cRes - qSensible;
708
+ eMax =
709
+ (Math.exp(18.6686 - 4030.183 / (tSkin + 235.0)) - vaporPressure) /
710
+ (rEa + rEcl);
711
+ if (eMax == 0) {
712
+ eMax = 0.001;
713
+ }
714
+ const pRsw = eRsw / eMax;
715
+ w = 0.06 + 0.94 * pRsw;
716
+ eDiff = w * eMax - eRsw;
717
+ if (w > wMax) {
718
+ w = wMax;
719
+ const pRsw = wMax / 0.94;
720
+ eRsw = pRsw * eMax;
721
+ eDiff = 0.06 * (1.0 - pRsw) * eMax;
722
+ }
723
+ if (eMax < 0) {
724
+ eDiff = 0;
725
+ eRsw = 0;
726
+ w = wMax;
727
+ }
728
+ eSkin = eRsw + eDiff;
729
+ mRsw = eRsw / 0.68;
730
+ const metShivering = 19.4 * colds * cCold;
731
+ m = rm + metShivering;
732
+ alfa = 0.0417737 + 0.7451833 / (mBl + 0.585417);
733
+ }
734
+ const qSkin = qSensible + eSkin;
735
+ const pSSk = Math.exp(18.6686 - 4030.183 / (tSkin + 235.0));
736
+ const hRS = hR;
737
+ let hCS = 3.0 * Math.pow(pressureInAtmospheres, 0.53);
738
+ if (!kwargs.calculate_ce && met > 0.85) {
739
+ const hCMet = 5.66 * Math.pow(met - 0.85, 0.39);
740
+ hCS = Math.max(hCS, hCMet);
741
+ }
742
+ if (hCS < 3.0) {
743
+ hCS = 3.0;
744
+ }
745
+ const hTS = hCS + hRS; // sum of convective and radiant heat transfer coefficient W/(m2*K)
746
+ const rCloS = 1.52 / (met - wme / metFactor + 0.6944) - 0.1835; // thermal resistance of clothing, °C M^2 /W
747
+ const rClS = 0.155 * rCloS; // thermal insulation of the clothing in M2K/W
748
+ const fAClS = 1.0 + kClo * rCloS; // increase in body surface area due to clothing
749
+ const fClS = 1.0 / (1.0 + 0.155 * fAClS * hTS * rCloS); // ratio of surface clothed body over nude body
750
+ const iMS = 0.45; // permeation efficiency of water vapour through the clothing layer
751
+ const iClS = iMS * (hCS / hTS) * ((1 - fClS) / (hCS / hTS - fClS * iMS)); // clothing vapor permeation efficiency
752
+ const rAS = 1.0 / (fAClS * hTS); // resistance of air layer to dry heat
753
+ const rEaS = 1.0 / (lr * fAClS * hCS);
754
+ const rEclS = rClS / (lr * iClS);
755
+ const hDS = 1.0 / (rAS + rClS);
756
+ const hES = 1.0 / (rEaS + rEclS);
757
+ set = calculate_set(tSkin, qSkin, hDS, pSSk, w, hES);
758
+ et = calculate_et(tSkin, qSkin, pSSk, w, rA, rClo, rEa, rEcl);
759
+ const tSens = calculate_thermal_sansation(tBody, rm, wMax);
760
+ const disc = calculate_discomfort(eRsw, eComfort, eMax, wMax, eDiff, tSens);
761
+ const pmvGagge = calculate_pmv_gagge(m, eReq, eComfort, eDiff);
762
+ const pmvSet = calculate_pmv_set(m, eComfort, eDiff, hDS, tSkin, set, rm, cRes, qRes);
763
+ const ps = calculate_percent_satisfied(tOp, v);
764
+ return {
765
+ set,
766
+ eSkin,
767
+ eRsw,
768
+ eMax,
769
+ qSensible,
770
+ qSkin,
771
+ qRes,
772
+ tCore,
773
+ tSkin,
774
+ mBl,
775
+ mRsw,
776
+ w,
777
+ wMax,
778
+ et,
779
+ pmvGagge,
780
+ pmvSet,
781
+ disc,
782
+ tSens,
783
+ };
784
+ }