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