jsthermalcomfort 2.0.0-next.1 → 2.0.0-next.3

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 (212) hide show
  1. package/README.md +35 -16
  2. package/lib/esm/_internal/errors.js +1 -1
  3. package/lib/esm/clothing/_correction_clothing.js +20 -0
  4. package/lib/esm/clothing/clo_area_factor.js +24 -0
  5. package/lib/esm/clothing/clo_correction_factor_environment.js +35 -0
  6. package/lib/esm/clothing/clo_dynamic_ashrae.js +39 -0
  7. package/lib/esm/clothing/clo_dynamic_iso.js +93 -0
  8. package/lib/esm/clothing/clo_insulation_air_layer.js +25 -0
  9. package/lib/esm/clothing/clo_intrinsic_insulation_ensemble.js +31 -0
  10. package/lib/esm/clothing/clo_total_insulation.js +47 -0
  11. package/lib/esm/clothing/index.js +33 -0
  12. package/lib/esm/environment/f_svv.js +14 -13
  13. package/lib/esm/environment/index.js +12 -2
  14. package/lib/esm/environment/mean_radiant_tmp.js +64 -59
  15. package/lib/esm/environment/running_mean_outdoor_temperature.js +95 -33
  16. package/lib/esm/environment/scale_wind_speed_log.js +165 -0
  17. package/lib/esm/environment/v_relative.js +10 -20
  18. package/lib/esm/index.js +4 -2
  19. package/lib/esm/models/JOS3.js +182 -26
  20. package/lib/esm/models/_pmv_ppd_optimized.js +1 -1
  21. package/lib/esm/models/adaptive_ashrae.js +9 -7
  22. package/lib/esm/models/adaptive_en.js +12 -9
  23. package/lib/esm/models/ankle_draft.js +9 -6
  24. package/lib/esm/models/at.js +4 -2
  25. package/lib/esm/models/clo_tout.js +4 -2
  26. package/lib/esm/models/cooling_effect.js +7 -5
  27. package/lib/esm/models/discomfort_index.js +4 -2
  28. package/lib/esm/models/esi.js +5 -3
  29. package/lib/esm/models/heat_index_lu.js +7 -3
  30. package/lib/esm/models/heat_index_rothfusz.js +12 -6
  31. package/lib/esm/models/heat_index_schoen.js +7 -3
  32. package/lib/esm/models/humidex.js +7 -3
  33. package/lib/esm/models/index.js +39 -15
  34. package/lib/esm/models/ireq.js +10 -8
  35. package/lib/esm/models/net.js +5 -3
  36. package/lib/esm/models/pet_steady.js +5 -3
  37. package/lib/esm/models/phs.js +11 -9
  38. package/lib/esm/models/pmv_a.js +9 -5
  39. package/lib/esm/models/pmv_athb.js +10 -6
  40. package/lib/esm/models/pmv_e.js +11 -7
  41. package/lib/esm/models/pmv_ppd_ashrae.js +24 -12
  42. package/lib/esm/models/pmv_ppd_iso.js +18 -10
  43. package/lib/esm/models/ridge_regression_predict_t_re_t_sk.js +9 -7
  44. package/lib/esm/models/set_tmp.js +9 -5
  45. package/lib/esm/models/solar_gain.js +11 -4
  46. package/lib/esm/models/sports_heat_stress_risk.js +11 -9
  47. package/lib/esm/models/thi.js +7 -5
  48. package/lib/esm/models/two_nodes_gagge.js +55 -16
  49. package/lib/esm/models/two_nodes_gagge_ji.js +6 -4
  50. package/lib/esm/models/two_nodes_gagge_sleep.js +1 -0
  51. package/lib/esm/models/use_fans_heatwaves.js +12 -10
  52. package/lib/esm/models/utci.js +11 -9
  53. package/lib/esm/models/vertical_tmp_grad_ppd.js +11 -9
  54. package/lib/esm/models/wbgt.js +9 -5
  55. package/lib/esm/models/wci.js +5 -3
  56. package/lib/esm/models/wind_chill_temperature.js +12 -3
  57. package/lib/esm/models/work_capacity_dunne.js +5 -3
  58. package/lib/esm/models/work_capacity_hothaps.js +5 -3
  59. package/lib/esm/models/work_capacity_iso.js +5 -3
  60. package/lib/esm/models/work_capacity_niosh.js +5 -3
  61. package/lib/esm/psychrometrics/antoine.js +12 -0
  62. package/lib/esm/psychrometrics/enthalpy_air.js +1 -3
  63. package/lib/esm/psychrometrics/index.js +14 -4
  64. package/lib/esm/psychrometrics/p_sat.js +1 -1
  65. package/lib/esm/psychrometrics/psy_ta_rh.js +7 -7
  66. package/lib/esm/types/_internal/ashrae55.d.ts +1 -1
  67. package/lib/esm/types/clothing/_correction_clothing.d.ts +11 -0
  68. package/lib/esm/types/clothing/_correction_clothing.d.ts.map +1 -0
  69. package/lib/esm/types/clothing/clo_area_factor.d.ts +20 -0
  70. package/lib/esm/types/clothing/clo_area_factor.d.ts.map +1 -0
  71. package/lib/esm/types/clothing/clo_correction_factor_environment.d.ts +19 -0
  72. package/lib/esm/types/clothing/clo_correction_factor_environment.d.ts.map +1 -0
  73. package/lib/esm/types/clothing/clo_dynamic_ashrae.d.ts +25 -0
  74. package/lib/esm/types/clothing/clo_dynamic_ashrae.d.ts.map +1 -0
  75. package/lib/esm/types/clothing/clo_dynamic_iso.d.ts +59 -0
  76. package/lib/esm/types/clothing/clo_dynamic_iso.d.ts.map +1 -0
  77. package/lib/esm/types/clothing/clo_insulation_air_layer.d.ts +18 -0
  78. package/lib/esm/types/clothing/clo_insulation_air_layer.d.ts.map +1 -0
  79. package/lib/esm/types/clothing/clo_intrinsic_insulation_ensemble.d.ts +15 -0
  80. package/lib/esm/types/clothing/clo_intrinsic_insulation_ensemble.d.ts.map +1 -0
  81. package/lib/esm/types/clothing/clo_total_insulation.d.ts +28 -0
  82. package/lib/esm/types/clothing/clo_total_insulation.d.ts.map +1 -0
  83. package/lib/esm/types/clothing/index.d.ts +33 -0
  84. package/lib/esm/types/clothing/index.d.ts.map +1 -0
  85. package/lib/esm/types/environment/f_svv.d.ts +6 -11
  86. package/lib/esm/types/environment/f_svv.d.ts.map +1 -1
  87. package/lib/esm/types/environment/index.d.ts +15 -6
  88. package/lib/esm/types/environment/index.d.ts.map +1 -1
  89. package/lib/esm/types/environment/mean_radiant_tmp.d.ts +30 -18
  90. package/lib/esm/types/environment/mean_radiant_tmp.d.ts.map +1 -1
  91. package/lib/esm/types/environment/running_mean_outdoor_temperature.d.ts +72 -17
  92. package/lib/esm/types/environment/running_mean_outdoor_temperature.d.ts.map +1 -1
  93. package/lib/esm/types/environment/scale_wind_speed_log.d.ts +100 -0
  94. package/lib/esm/types/environment/scale_wind_speed_log.d.ts.map +1 -0
  95. package/lib/esm/types/environment/v_relative.d.ts +10 -10
  96. package/lib/esm/types/environment/v_relative.d.ts.map +1 -1
  97. package/lib/esm/types/index.d.ts +1237 -1199
  98. package/lib/esm/types/index.d.ts.map +1 -1
  99. package/lib/esm/types/models/JOS3.d.ts +179 -23
  100. package/lib/esm/types/models/JOS3.d.ts.map +1 -1
  101. package/lib/esm/types/models/adaptive_ashrae.d.ts +15 -9
  102. package/lib/esm/types/models/adaptive_ashrae.d.ts.map +1 -1
  103. package/lib/esm/types/models/adaptive_en.d.ts +18 -11
  104. package/lib/esm/types/models/adaptive_en.d.ts.map +1 -1
  105. package/lib/esm/types/models/ankle_draft.d.ts +15 -8
  106. package/lib/esm/types/models/ankle_draft.d.ts.map +1 -1
  107. package/lib/esm/types/models/at.d.ts +10 -4
  108. package/lib/esm/types/models/at.d.ts.map +1 -1
  109. package/lib/esm/types/models/clo_tout.d.ts +10 -4
  110. package/lib/esm/types/models/clo_tout.d.ts.map +1 -1
  111. package/lib/esm/types/models/cooling_effect.d.ts +13 -7
  112. package/lib/esm/types/models/cooling_effect.d.ts.map +1 -1
  113. package/lib/esm/types/models/discomfort_index.d.ts +10 -4
  114. package/lib/esm/types/models/discomfort_index.d.ts.map +1 -1
  115. package/lib/esm/types/models/esi.d.ts +11 -5
  116. package/lib/esm/types/models/esi.d.ts.map +1 -1
  117. package/lib/esm/types/models/heat_index_lu.d.ts +13 -5
  118. package/lib/esm/types/models/heat_index_lu.d.ts.map +1 -1
  119. package/lib/esm/types/models/heat_index_rothfusz.d.ts +18 -8
  120. package/lib/esm/types/models/heat_index_rothfusz.d.ts.map +1 -1
  121. package/lib/esm/types/models/heat_index_schoen.d.ts +11 -4
  122. package/lib/esm/types/models/heat_index_schoen.d.ts.map +1 -1
  123. package/lib/esm/types/models/humidex.d.ts +13 -5
  124. package/lib/esm/types/models/humidex.d.ts.map +1 -1
  125. package/lib/esm/types/models/index.d.ts +1222 -1186
  126. package/lib/esm/types/models/index.d.ts.map +1 -1
  127. package/lib/esm/types/models/ireq.d.ts +15 -9
  128. package/lib/esm/types/models/ireq.d.ts.map +1 -1
  129. package/lib/esm/types/models/net.d.ts +11 -5
  130. package/lib/esm/types/models/net.d.ts.map +1 -1
  131. package/lib/esm/types/models/pet_steady.d.ts +10 -4
  132. package/lib/esm/types/models/pet_steady.d.ts.map +1 -1
  133. package/lib/esm/types/models/phs.d.ts +16 -10
  134. package/lib/esm/types/models/phs.d.ts.map +1 -1
  135. package/lib/esm/types/models/pmv_a.d.ts +15 -7
  136. package/lib/esm/types/models/pmv_a.d.ts.map +1 -1
  137. package/lib/esm/types/models/pmv_athb.d.ts +15 -7
  138. package/lib/esm/types/models/pmv_athb.d.ts.map +1 -1
  139. package/lib/esm/types/models/pmv_e.d.ts +17 -9
  140. package/lib/esm/types/models/pmv_e.d.ts.map +1 -1
  141. package/lib/esm/types/models/pmv_ppd_ashrae.d.ts +30 -14
  142. package/lib/esm/types/models/pmv_ppd_ashrae.d.ts.map +1 -1
  143. package/lib/esm/types/models/pmv_ppd_iso.d.ts +24 -12
  144. package/lib/esm/types/models/pmv_ppd_iso.d.ts.map +1 -1
  145. package/lib/esm/types/models/ridge_regression_predict_t_re_t_sk.d.ts +15 -9
  146. package/lib/esm/types/models/ridge_regression_predict_t_re_t_sk.d.ts.map +1 -1
  147. package/lib/esm/types/models/set_tmp.d.ts +13 -6
  148. package/lib/esm/types/models/set_tmp.d.ts.map +1 -1
  149. package/lib/esm/types/models/solar_gain.d.ts +17 -6
  150. package/lib/esm/types/models/solar_gain.d.ts.map +1 -1
  151. package/lib/esm/types/models/sports_heat_stress_risk.d.ts +16 -10
  152. package/lib/esm/types/models/sports_heat_stress_risk.d.ts.map +1 -1
  153. package/lib/esm/types/models/thi.d.ts +13 -7
  154. package/lib/esm/types/models/thi.d.ts.map +1 -1
  155. package/lib/esm/types/models/two_nodes_gagge.d.ts +33 -7
  156. package/lib/esm/types/models/two_nodes_gagge.d.ts.map +1 -1
  157. package/lib/esm/types/models/two_nodes_gagge_ji.d.ts +12 -6
  158. package/lib/esm/types/models/two_nodes_gagge_ji.d.ts.map +1 -1
  159. package/lib/esm/types/models/two_nodes_gagge_sleep.d.ts +11 -5
  160. package/lib/esm/types/models/two_nodes_gagge_sleep.d.ts.map +1 -1
  161. package/lib/esm/types/models/use_fans_heatwaves.d.ts +18 -12
  162. package/lib/esm/types/models/use_fans_heatwaves.d.ts.map +1 -1
  163. package/lib/esm/types/models/utci.d.ts +17 -11
  164. package/lib/esm/types/models/utci.d.ts.map +1 -1
  165. package/lib/esm/types/models/vertical_tmp_grad_ppd.d.ts +17 -11
  166. package/lib/esm/types/models/vertical_tmp_grad_ppd.d.ts.map +1 -1
  167. package/lib/esm/types/models/wbgt.d.ts +15 -7
  168. package/lib/esm/types/models/wbgt.d.ts.map +1 -1
  169. package/lib/esm/types/models/wci.d.ts +11 -5
  170. package/lib/esm/types/models/wci.d.ts.map +1 -1
  171. package/lib/esm/types/models/wind_chill_temperature.d.ts +18 -5
  172. package/lib/esm/types/models/wind_chill_temperature.d.ts.map +1 -1
  173. package/lib/esm/types/models/work_capacity_dunne.d.ts +11 -5
  174. package/lib/esm/types/models/work_capacity_dunne.d.ts.map +1 -1
  175. package/lib/esm/types/models/work_capacity_hothaps.d.ts +9 -4
  176. package/lib/esm/types/models/work_capacity_hothaps.d.ts.map +1 -1
  177. package/lib/esm/types/models/work_capacity_iso.d.ts +9 -4
  178. package/lib/esm/types/models/work_capacity_iso.d.ts.map +1 -1
  179. package/lib/esm/types/models/work_capacity_niosh.d.ts +5 -3
  180. package/lib/esm/types/models/work_capacity_niosh.d.ts.map +1 -1
  181. package/lib/esm/types/psychrometrics/antoine.d.ts +8 -0
  182. package/lib/esm/types/psychrometrics/antoine.d.ts.map +1 -0
  183. package/lib/esm/types/psychrometrics/enthalpy_air.d.ts.map +1 -1
  184. package/lib/esm/types/psychrometrics/index.d.ts +12 -4
  185. package/lib/esm/types/psychrometrics/index.d.ts.map +1 -1
  186. package/lib/esm/types/psychrometrics/p_sat.d.ts.map +1 -1
  187. package/lib/esm/types/psychrometrics/psy_ta_rh.d.ts +8 -7
  188. package/lib/esm/types/psychrometrics/psy_ta_rh.d.ts.map +1 -1
  189. package/lib/esm/types/utilities/body_surface_area.d.ts +2 -1
  190. package/lib/esm/types/utilities/body_surface_area.d.ts.map +1 -1
  191. package/lib/esm/types/utilities/constants.d.ts +17 -0
  192. package/lib/esm/types/utilities/constants.d.ts.map +1 -0
  193. package/lib/esm/types/utilities/index.d.ts +28 -11
  194. package/lib/esm/types/utilities/index.d.ts.map +1 -1
  195. package/lib/esm/types/utilities/options.d.ts +13 -0
  196. package/lib/esm/types/utilities/options.d.ts.map +1 -1
  197. package/lib/esm/types/utilities/reference_tables.d.ts +131 -0
  198. package/lib/esm/types/utilities/reference_tables.d.ts.map +1 -0
  199. package/lib/esm/utilities/body_surface_area.js +10 -6
  200. package/lib/esm/utilities/constants.js +16 -0
  201. package/lib/esm/utilities/index.js +24 -10
  202. package/lib/esm/utilities/options.js +13 -0
  203. package/lib/esm/utilities/{utilities.js → reference_tables.js} +101 -39
  204. package/package.json +12 -4
  205. package/lib/esm/types/utilities/clothing.d.ts +0 -163
  206. package/lib/esm/types/utilities/clothing.d.ts.map +0 -1
  207. package/lib/esm/types/utilities/met_to_w_m2.d.ts +0 -3
  208. package/lib/esm/types/utilities/met_to_w_m2.d.ts.map +0 -1
  209. package/lib/esm/types/utilities/utilities.d.ts +0 -98
  210. package/lib/esm/types/utilities/utilities.d.ts.map +0 -1
  211. package/lib/esm/utilities/clothing.js +0 -258
  212. package/lib/esm/utilities/met_to_w_m2.js +0 -2
package/README.md CHANGED
@@ -33,32 +33,51 @@ Please cite us if you use this package: [Tartarini, F., Schiavon, S., 2020. pyth
33
33
  npm install jsthermalcomfort
34
34
  ```
35
35
 
36
- If you want to use jsthermalcomfort package without installing it on your local machine, you can import with:
37
-
38
- [`https://cdn.jsdelivr.net/npm/jsthermalcomfort/lib/esm/`](https://cdn.jsdelivr.net/npm/jsthermalcomfort/lib/esm/)
39
-
40
- Example:
36
+ Import functions by name, from the package root or from a subpath: `jsthermalcomfort/models`, `jsthermalcomfort/environment`, `jsthermalcomfort/clothing`, `jsthermalcomfort/psychrometrics` or `jsthermalcomfort/utilities`.
41
37
 
42
38
  ```javascript
43
- import {
44
- models,
45
- utilities,
46
- psychrometrics,
47
- } from "https://cdn.jsdelivr.net/npm/jsthermalcomfort/lib/esm/index.js";
39
+ import { pmv_ppd_iso } from "jsthermalcomfort";
40
+ import { utci } from "jsthermalcomfort/models";
41
+
42
+ const { pmv, ppd } = pmv_ppd_iso({
43
+ tdb: 25,
44
+ tr: 25,
45
+ vr: 0.1,
46
+ rh: 50,
47
+ met: 1.2,
48
+ clo: 0.5,
49
+ });
50
+ console.log(pmv, ppd); // 0.08 5.1
51
+
52
+ const result = utci({ tdb: 25, tr: 25, v: 1, rh: 50 });
53
+ console.log(result.utci, result.stress_category); // 24.6 no thermal stress
48
54
  ```
49
55
 
50
- You can also import it in the website directly, and caution that you need to mark the script as module:
56
+ In a browser without a bundler, import from jsDelivr in a module script:
51
57
 
52
58
  ```html
53
59
  <script type="module">
54
- import {
55
- models,
56
- utilities,
57
- psychrometrics,
58
- } from "https://cdn.jsdelivr.net/npm/jsthermalcomfort/lib/esm/index.js";
60
+ import { pmv_ppd_iso } from "https://cdn.jsdelivr.net/npm/jsthermalcomfort@2/+esm";
61
+
62
+ const { pmv, ppd } = pmv_ppd_iso({
63
+ tdb: 25,
64
+ tr: 25,
65
+ vr: 0.1,
66
+ rh: 50,
67
+ met: 1.2,
68
+ clo: 0.5,
69
+ });
70
+ console.log(pmv, ppd); // 0.08 5.1
59
71
  </script>
60
72
  ```
61
73
 
74
+ # Migrating from 1.4.0
75
+
76
+ 2.0.0 changes how every function is called and imported. The migration guide gives the rules that apply to every function, then each 1.4.0 function's before and after.
77
+
78
+ - Guide: [`docs/migration-v2.md`](docs/migration-v2.md)
79
+ - Online docs version: [Migrating from 1.4.0 to 2.0.0](https://federicotartarini.github.io/jsthermalcomfort/documents/migration-v2.html)
80
+
62
81
  # Contributing
63
82
 
64
83
  Contributions are welcome.
@@ -1,7 +1,7 @@
1
1
  // The messages the library's checks throw (ADR 0022). Upstream's own message
2
2
  // about a value stays verbatim, in the model's INFO entry for a string option
3
3
  // (`ChoiceField.message`), such as `BaseInputs`' for `units`
4
- // (`classes_input.py:120` at v4.8.0). Every other message is the library's
4
+ // (`classes_input.py:120` at v4.8.1). Every other message is the library's
5
5
  // and starts with the key, in the `<key> must be …` form or a like one, or with
6
6
  // the model's name for a call with no inputs object; it replaces each upstream
7
7
  // message that names Python's types or Python's call binding (deviations
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Correction factor for the insulation of a nude person, ISO 9920.
3
+ * pythermalcomfort's `_correction_nude`.
4
+ */
5
+ export function _correction_nude(_vr, _vw) {
6
+ return Math.exp(-0.533 * (_vr - 0.15) +
7
+ 0.069 * (_vr - 0.15) ** 2 -
8
+ 0.462 * _vw +
9
+ 0.201 * _vw ** 2);
10
+ }
11
+ /**
12
+ * Correction factor for normal clothing, ISO 9920. pythermalcomfort's
13
+ * `_correction_normal_clothing`.
14
+ */
15
+ export function _correction_normal_clothing(_vr, _vw) {
16
+ return Math.exp(-0.281 * (_vr - 0.15) +
17
+ 0.044 * (_vr - 0.15) ** 2 -
18
+ 0.492 * _vw +
19
+ 0.176 * _vw ** 2);
20
+ }
@@ -0,0 +1,24 @@
1
+ import { notOfType } from "../_internal/errors.js";
2
+ /**
3
+ * Calculates the clothing area factor (f_cl) of the clothing ensemble as a
4
+ * function of the intrinsic insulation of the clothing ensemble. This equation
5
+ * is in accordance with the ISO 9920:2009 standard, Section 5. The standard
6
+ * warns that the correlation between f_cl and i_cl is low, especially for
7
+ * non-western clothing ensembles. The application of this equation is limited
8
+ * to clothing ensembles with clo values between 0.2 and 1.7 clo.
9
+ *
10
+ * Same name, parameters and values as pythermalcomfort's
11
+ * `clothing.clo_area_factor`.
12
+ *
13
+ * @param {number} i_cl - intrinsic insulation of the clothing ensemble, [clo]
14
+ * @returns {number} area factor of the clothing ensemble, [m2]
15
+ *
16
+ * @example
17
+ * import { clo_area_factor } from "jsthermalcomfort";
18
+ * console.log(clo_area_factor(1)); // 1.28
19
+ */
20
+ export function clo_area_factor(i_cl) {
21
+ if (typeof i_cl !== "number")
22
+ throw notOfType("i_cl", "a number");
23
+ return 1 + 0.28 * i_cl;
24
+ }
@@ -0,0 +1,35 @@
1
+ import { notOfType } from "../_internal/errors.js";
2
+ import { _correction_normal_clothing, _correction_nude, } from "./_correction_clothing.js";
3
+ /**
4
+ * Return the correction factor for the total insulation of the clothing ensemble
5
+ * (`I`<sub>T</sub>) or the basic/intrinsic insulation (`I`<sub>cl</sub>).
6
+ *
7
+ * This correction factor takes into account of the fact that the values of
8
+ * (`I`<sub>T</sub>) and (`I`<sub>cl</sub>) are estimated in static conditions. In real
9
+ * environments the person may be walking, activity may pump air through the clothing,
10
+ * etc.
11
+ *
12
+ * @param vr - relative air speed, [m/s]
13
+ * @param v_walk - walking speed, [m/s]
14
+ * @param i_cl - intrinsic insulation of the clothing ensemble, this is the thermal insulation
15
+ * from the skin surface to the outer clothing surface [clo]
16
+ * @returns correction factor for the total insulation of the clothing ensemble
17
+ * (`I`<sub>T,r</sub> / (`I`<sub>T</sub>)) or the basic/intrinsic insulation
18
+ * (`I`<sub>cl,r</sub> / (`I`<sub>cl</sub>))
19
+ */
20
+ export function clo_correction_factor_environment(vr, v_walk, i_cl) {
21
+ for (const [key, value] of Object.entries({ vr, v_walk, i_cl })) {
22
+ if (typeof value !== "number")
23
+ throw notOfType(key, "a number");
24
+ }
25
+ function correction_low_clothing(_vr, _vw, _i_cl) {
26
+ return (((0.6 - _i_cl) * _correction_nude(_vr, _vw) +
27
+ _i_cl * _correction_normal_clothing(_vr, _vw)) /
28
+ 0.6);
29
+ }
30
+ if (i_cl === 0)
31
+ return _correction_nude(vr, v_walk);
32
+ if (i_cl <= 0.6)
33
+ return correction_low_clothing(vr, v_walk, i_cl);
34
+ return _correction_normal_clothing(vr, v_walk);
35
+ }
@@ -0,0 +1,39 @@
1
+ import { Standard } from "../utilities/options.js";
2
+ import { notOfType } from "../_internal/errors.js";
3
+ import { round } from "../_internal/round.js";
4
+ /**
5
+ * Estimates the dynamic intrinsic clothing insulation (I<sub>cl,r</sub>).
6
+ *
7
+ * The ASHRAE 55:2023 refers to it as (I<sub>cl,active</sub>). The activity as well as the air speed
8
+ * modify the insulation characteristics of the clothing. Consequently, the ASHRAE 55
9
+ * standard provides a correction factor for the clothing insulation (I<sub>cl</sub>)
10
+ * based on the metabolic rate.
11
+ *
12
+ * The ASHRAE 55 Standard corrects for the effect of the body movement for met
13
+ * higher than 1.2 met using the equation
14
+ * clo = I<sub>cl</sub> × (0.6 + 0.4 / met).
15
+ *
16
+ * @param clo - clothing insulation, [clo]
17
+ *
18
+ * > [!NOTE]
19
+ * > this is the basic insulation (I<sub>cl</sub>) also known as the intrinsic
20
+ * > clothing insulation value under reference conditions
21
+ * @param met - metabolic rate, [met]
22
+ * @param standard - Select the version of the ASHRAE 55 Standard to use. Currently, the only
23
+ * option available is "55-2023".
24
+ * @returns dynamic clothing insulation (I<sub>cl,r</sub>), [clo]
25
+ */
26
+ export function clo_dynamic_ashrae(clo, met,
27
+ // Upstream's `model`; this library names the option `standard` (ADR 0003).
28
+ standard = Standard.ashrae_55_2023) {
29
+ for (const [key, value] of Object.entries({ clo, met })) {
30
+ if (typeof value !== "number")
31
+ throw notOfType(key, "a number");
32
+ }
33
+ if (typeof standard !== "string") {
34
+ throw notOfType("standard", "a string");
35
+ }
36
+ if (standard.toLowerCase() !== Standard.ashrae_55_2023)
37
+ throw new RangeError(`Dynamic clothing insulation calculations can only be performed in compliance with ASHRAE ${Standard.ashrae_55_2023}`);
38
+ return met > 1.2 ? round(clo * (0.6 + 0.4 / met), 3) : clo;
39
+ }
@@ -0,0 +1,93 @@
1
+ import { v_relative } from "../environment/v_relative.js";
2
+ import { met_to_w_m2 } from "../utilities/constants.js";
3
+ import { Standard } from "../utilities/options.js";
4
+ import { notOfType } from "../_internal/errors.js";
5
+ import { clo_area_factor } from "./clo_area_factor.js";
6
+ import { clo_insulation_air_layer } from "./clo_insulation_air_layer.js";
7
+ import { clo_total_insulation } from "./clo_total_insulation.js";
8
+ /**
9
+ * Estimates the dynamic intrinsic clothing insulation (I<sub>cl,r</sub>).
10
+ *
11
+ * The activity as well as the air speed modify the insulation characteristics of the
12
+ * clothing. Consequently, ISO 7730 states that (I<sub>cl</sub>) shall be corrected
13
+ * [7730ISO2005](../../docs/references.md#7730iso2005)
14
+ * [7730ISO2025](../../docs/references.md#7730iso2025). Both editions of ISO 7730 give the correction
15
+ * equations in their (informative) Annex C, adapted from the ISO 9920:2007 standard
16
+ * [ISO9920](../../docs/references.md#iso9920), which is what we have implemented here.
17
+ *
18
+ * > [!NOTE]
19
+ * > The walking speed is not a function input; it is estimated from the metabolic
20
+ * > rate using the formula given in ISO 7730 Annex C / ISO 9920 for when the actual
21
+ * > walking speed is undefined: v_walk = 0.0052 * (M - 58), clipped to 0-0.7 m/s,
22
+ * > where M is the metabolic rate in W/m2. This is a different formula from
23
+ * > {@link environment!v_relative}'s activity-generated air speed
24
+ * > (0.3 * (met - 1)), which is used in the whole-body PMV heat balance rather than
25
+ * > for the clothing dynamic insulation correction.
26
+ *
27
+ * @param clo - clothing insulation, [clo]
28
+ * @param met - metabolic rate, [met]
29
+ * @param v - air speed, [m/s]
30
+ * @param i_a - thermal insulation of the boundary (surface) air layer around the outer clothing
31
+ * or, when nude, around the skin surface, [clo]
32
+ * @param standard - Select the version of the ISO standard to use. Currently, the only
33
+ * option available is "9920-2007".
34
+ * @returns dynamic clothing insulation, [clo]
35
+ */
36
+ export function clo_dynamic_iso(clo, met, v, i_a = 0.7,
37
+ // Upstream's `model`; this library names the option `standard` (ADR 0003).
38
+ standard = Standard.iso_9920_2007) {
39
+ for (const [key, value] of Object.entries({ clo, met, v, i_a })) {
40
+ if (typeof value !== "number")
41
+ throw notOfType(key, "a number");
42
+ }
43
+ if (typeof standard !== "string") {
44
+ throw notOfType("standard", "a string");
45
+ }
46
+ return clo_dynamic_iso_vr(clo, met, v_relative(v, met), i_a, standard);
47
+ }
48
+ /**
49
+ * Estimates the dynamic intrinsic clothing insulation (I<sub>cl,r</sub>) by ISO 7730
50
+ * Annex C / ISO 9920, from the relative air speed. This is
51
+ * {@link clo_dynamic_iso} for a caller that holds the
52
+ * relative air speed `vr` and not the air speed `v`:
53
+ * `clo_dynamic_iso(clo, met, v)` is
54
+ * `clo_dynamic_iso_vr(clo, met, v_relative(v, met))`. The walking speed is
55
+ * estimated from the metabolic rate as it is there.
56
+ *
57
+ * pythermalcomfort has no counterpart: its `clo_dynamic_iso` takes `v` and
58
+ * derives `vr` inside. This is everything that function does after that step,
59
+ * exported because the CBE Thermal Comfort Tool lets a person enter `vr`
60
+ * (ADR 0001: a deviation may add an export).
61
+ *
62
+ * @param clo - clothing insulation, [clo]
63
+ * @param met - metabolic rate, [met]
64
+ * @param vr - relative air speed, [m/s]
65
+ * @param i_a - thermal insulation of the boundary (surface) air layer around the outer clothing
66
+ * or, when nude, around the skin surface, [clo]
67
+ * @param standard - version of the ISO standard to use. Currently, the only
68
+ * option available is "9920-2007"; any other value throws
69
+ * @returns dynamic clothing insulation, [clo]
70
+ *
71
+ * @example
72
+ * import { clo_dynamic_iso_vr } from "jsthermalcomfort";
73
+ * console.log(clo_dynamic_iso_vr(1, 1.2, 0.26)); // 0.9548...
74
+ */
75
+ export function clo_dynamic_iso_vr(clo, met, vr, i_a = 0.7, standard = Standard.iso_9920_2007) {
76
+ for (const [key, value] of Object.entries({ clo, met, vr, i_a })) {
77
+ if (typeof value !== "number")
78
+ throw notOfType(key, "a number");
79
+ }
80
+ if (typeof standard !== "string") {
81
+ throw notOfType("standard", "a string");
82
+ }
83
+ if (standard.toLowerCase() !== Standard.iso_9920_2007)
84
+ throw new RangeError(`Dynamic clothing insulation calculations can only be performed in compliance with ISO ${Standard.iso_9920_2007}`);
85
+ const f_cl = clo_area_factor(clo);
86
+ const i_t = clo + i_a / f_cl;
87
+ // walking speed when undefined, per ISO 7730 Annex C / ISO 9920: vw = 0.0052 * (M - 58),
88
+ // clipped to [0, 0.7] m/s; M is the metabolic rate in W/m2
89
+ const v_walk = Math.min(Math.max(0.0052 * (met * met_to_w_m2 - 58), 0), 0.7);
90
+ const i_t_r = clo_total_insulation(i_t, vr, v_walk, i_a, clo);
91
+ const i_a_r = clo_insulation_air_layer(vr, v_walk, i_a);
92
+ return i_t_r - i_a_r / f_cl;
93
+ }
@@ -0,0 +1,25 @@
1
+ import { notOfType } from "../_internal/errors.js";
2
+ import { _correction_nude } from "./_correction_clothing.js";
3
+ /**
4
+ * Calculate the insulation of the boundary air layer (`I`<sub>a,r</sub>).
5
+ *
6
+ * The static
7
+ * boundary air value is 0.7 clo (0.109 m2K/W) for air velocities around 0.1 m/s to
8
+ * 0.15 m/s. Thus, for static conditions, the standard recommends using the value of
9
+ * 0.7 clo (0.109 m2K/W) for the boundary air layer insulation. For walking conditions,
10
+ * the boundary air layer insulation is calculated based on the walking speed (v_walk)
11
+ * and the relative air speed (vr). This equation is extracted from the ISO 9920:2009
12
+ * standard [ISO9920](../../docs/references.md#iso9920) Section 6.
13
+ *
14
+ * @param vr - relative air speed, [m/s]
15
+ * @param v_walk - walking speed, [m/s]
16
+ * @param i_a_static - static boundary air layer insulation, [clo]
17
+ * @returns boundary air layer insulation, [clo]
18
+ */
19
+ export function clo_insulation_air_layer(vr, v_walk, i_a_static) {
20
+ for (const [key, value] of Object.entries({ vr, v_walk, i_a_static })) {
21
+ if (typeof value !== "number")
22
+ throw notOfType(key, "a number");
23
+ }
24
+ return _correction_nude(vr, v_walk) * i_a_static;
25
+ }
@@ -0,0 +1,31 @@
1
+ import dsumpw from "@stdlib/blas-ext-base-dsumpw";
2
+ import { notOfType } from "../_internal/errors.js";
3
+ /**
4
+ * Calculate the intrinsic insulation of a clothing ensemble based on individual
5
+ * garments.
6
+ *
7
+ * This equation is in accordance with the ISO 9920:2009 standard
8
+ * [ISO9920](../../docs/references.md#iso9920) Section 4.3. It should be noted
9
+ * that this equation is only valid for clothing ensembles with rather uniform
10
+ * insulation values across the body.
11
+ *
12
+ * @param clo_garments - list of floats containing the clothing insulation for
13
+ * each individual garment
14
+ * @returns intrinsic insulation of the clothing ensemble, [clo]
15
+ */
16
+ export function clo_intrinsic_insulation_ensemble(clo_garments) {
17
+ const garments = typeof clo_garments === "number"
18
+ ? [clo_garments]
19
+ : clo_garments;
20
+ if (!Array.isArray(garments)) {
21
+ throw notOfType("clo_garments", "a number or an array of numbers");
22
+ }
23
+ for (const clo of garments) {
24
+ if (typeof clo !== "number")
25
+ throw notOfType("clo_garments", "a number or an array of numbers");
26
+ }
27
+ // numpy's add.reduce starts from its identity 0.0, where dsumpw starts from
28
+ // the first element (ADR 0026; the note in docs/deviations/_shared.md).
29
+ const sum = 0 + dsumpw(garments.length, Float64Array.from(garments), 1);
30
+ return sum * 0.835 + 0.161;
31
+ }
@@ -0,0 +1,47 @@
1
+ import { notOfType } from "../_internal/errors.js";
2
+ import { _correction_normal_clothing, _correction_nude, } from "./_correction_clothing.js";
3
+ /**
4
+ * Calculate the total insulation of the clothing ensemble (`I`<sub>T,r</sub>).
5
+ *
6
+ * The clothing ensemble (`I`<sub>T,r</sub>) which is
7
+ * the actual thermal insulation from the body surface to the environment, considering
8
+ * all clothing, enclosed air layers, and boundary air layers under given environmental
9
+ * conditions and activities. It accounts for the effects of movements and wind. The
10
+ * ISO 9920 standard [ISO9920](../../docs/references.md#iso9920) provides different equations to calculate it as a
11
+ * function of the total thermal insulation of clothing (`I`<sub>T</sub>), the insulation
12
+ * of the boundary air layer (`I`<sub>a</sub>), the walking speed (`v`<sub>walk</sub>), and the
13
+ * relative air speed (`v`<sub>r</sub>). These different equations are used if the person
14
+ * is clothed in normal clothing (0.6 clo < (`I`<sub>cl</sub>) < 1.4 clo or 1.2 clo <
15
+ * (`I`<sub>T</sub>) < 2.0 clo), nude (`I`<sub>cl</sub> = 0 clo), and if the person is clothed
16
+ * in very light clothing (`I`<sub>cl</sub> < 0.6 clo). Here we have not implemented the
17
+ * equation for high clothing (`I`<sub>T</sub> > 2.0 clo). Hence the applicability of this
18
+ * function is limited to 0 clo < (`I`<sub>T</sub>) < 2.0 clo. You can find all the inputs
19
+ * required in this function in the ISO 9920:2009 standard [ISO9920](../../docs/references.md#iso9920) Annex A.
20
+ *
21
+ * @param i_t - total thermal insulation of clothing under static reference conditions [clo]
22
+ * @param vr - relative air speed, [m/s]
23
+ * @param v_walk - walking speed, [m/s]
24
+ * @param i_a_static - static boundary air layer insulation, [clo]
25
+ * @param i_cl - intrinsic insulation of the clothing ensemble, this is the thermal insulation
26
+ * from the skin surface to the outer clothing surface [clo]
27
+ * @returns total insulation of the clothing ensemble, [clo]
28
+ */
29
+ export function clo_total_insulation(i_t, vr, v_walk, i_a_static, i_cl) {
30
+ for (const [key, value] of Object.entries({
31
+ i_t,
32
+ vr,
33
+ v_walk,
34
+ i_a_static,
35
+ i_cl,
36
+ })) {
37
+ if (typeof value !== "number")
38
+ throw notOfType(key, "a number");
39
+ }
40
+ const nude = i_a_static * _correction_nude(vr, v_walk);
41
+ if (i_cl === 0)
42
+ return nude;
43
+ const normal_clothing = i_t * _correction_normal_clothing(vr, v_walk);
44
+ if (i_cl <= 0.6)
45
+ return ((0.6 - i_cl) * nude + i_cl * normal_clothing) / 0.6;
46
+ return normal_clothing;
47
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * There are several key variables related to the thermal insulation and water
3
+ * vapour resistance of clothing ensembles.
4
+ *
5
+ * @sortStrategy kind
6
+ * @packageDocumentation
7
+ */
8
+ // `kind` keeps the export order below, whose functions follow the page
9
+ // order of pythermalcomfort v4.8.1's `docs/documentation/clothing.rst`.
10
+ import { clo_area_factor } from "./clo_area_factor.js";
11
+ import { clo_correction_factor_environment } from "./clo_correction_factor_environment.js";
12
+ import { clo_dynamic_ashrae } from "./clo_dynamic_ashrae.js";
13
+ import { clo_dynamic_iso, clo_dynamic_iso_vr } from "./clo_dynamic_iso.js";
14
+ import { clo_insulation_air_layer } from "./clo_insulation_air_layer.js";
15
+ import { clo_intrinsic_insulation_ensemble } from "./clo_intrinsic_insulation_ensemble.js";
16
+ import { clo_total_insulation } from "./clo_total_insulation.js";
17
+ export { clo_insulation_air_layer, clo_correction_factor_environment, clo_area_factor, clo_dynamic_iso, clo_dynamic_iso_vr, clo_dynamic_ashrae, clo_intrinsic_insulation_ensemble, clo_total_insulation, };
18
+ /**
19
+ * The named exports as one object, for `import pkg from "jsthermalcomfort"`.
20
+ * Each member is documented under its own name.
21
+ *
22
+ * @hidden
23
+ */
24
+ export default {
25
+ clo_insulation_air_layer,
26
+ clo_correction_factor_environment,
27
+ clo_area_factor,
28
+ clo_dynamic_iso,
29
+ clo_dynamic_iso_vr,
30
+ clo_dynamic_ashrae,
31
+ clo_intrinsic_insulation_ensemble,
32
+ clo_total_insulation,
33
+ };
@@ -1,23 +1,24 @@
1
1
  import { notOfType } from "../_internal/errors.js";
2
2
  /**
3
- * Calculates the sky-vault view fraction
3
+ * Calculate the sky-vault view fraction.
4
4
  *
5
- * @public
6
- * @memberof environment
7
- * @docname Sky-vault view fraction
8
- *
9
- * @param {number} w - width of the window, [m]
10
- * @param {number} h - height of the window, [m]
11
- * @param {number} d - distance between the occupant and the window, [m]
12
- *
13
- * @returns {number} sky-vault view faction ranges between 0 and 1
5
+ * @param w - width of the window, [m]
6
+ * @param h - height of the window, [m]
7
+ * @param d - distance between the occupant and the window, [m]
8
+ * @returns sky-vault view fraction ranges between 0 and 1
14
9
  */
15
10
  export function f_svv(w, h, d) {
16
11
  for (const [key, value] of Object.entries({ w, h, d })) {
17
12
  if (typeof value !== "number")
18
13
  throw notOfType(key, "a number");
19
14
  }
20
- let h_degrees = Math.atan(h / (2 * d)) * (180 / Math.PI);
21
- let w_degrees = Math.atan(w / (2 * d)) * (180 / Math.PI);
22
- return (h_degrees * w_degrees) / 16200;
15
+ if (d === 0) {
16
+ // Python's message for h / (2 * d), an integral number read as an int (deviation _shared-146, deviation _shared-151).
17
+ const isInt = (x) => Number.isInteger(x) && !Object.is(x, -0);
18
+ throw new RangeError(isInt(h) && isInt(d) ? "division by zero" : "float division by zero");
19
+ }
20
+ return ((Math.atan(h / (2 * d)) *
21
+ (180 / Math.PI) *
22
+ (Math.atan(w / (2 * d)) * (180 / Math.PI))) /
23
+ 16200);
23
24
  }
@@ -1,10 +1,19 @@
1
+ /**
2
+ * Functions for environmental calculations.
3
+ *
4
+ * @sortStrategy kind
5
+ * @packageDocumentation
6
+ */
7
+ // `kind` keeps the export order below, whose functions follow the page
8
+ // order of pythermalcomfort v4.8.1's `docs/documentation/environment.rst`.
1
9
  import { f_svv } from "./f_svv.js";
2
10
  import { mean_radiant_tmp } from "./mean_radiant_tmp.js";
3
11
  import { operative_tmp } from "./operative_tmp.js";
4
12
  import { running_mean_outdoor_temperature } from "./running_mean_outdoor_temperature.js";
13
+ import { scale_wind_speed_log } from "./scale_wind_speed_log.js";
5
14
  import { transpose_sharp_altitude } from "./transpose_sharp_altitude.js";
6
15
  import { v_relative } from "./v_relative.js";
7
- export { f_svv, mean_radiant_tmp, operative_tmp, running_mean_outdoor_temperature, transpose_sharp_altitude, v_relative, };
16
+ export { mean_radiant_tmp, operative_tmp, running_mean_outdoor_temperature, transpose_sharp_altitude, f_svv, v_relative, scale_wind_speed_log, };
8
17
  /**
9
18
  * The named exports as one object, for `import pkg from "jsthermalcomfort"`.
10
19
  * Each member is documented under its own name.
@@ -12,10 +21,11 @@ export { f_svv, mean_radiant_tmp, operative_tmp, running_mean_outdoor_temperatur
12
21
  * @hidden
13
22
  */
14
23
  export default {
15
- f_svv,
16
24
  mean_radiant_tmp,
17
25
  operative_tmp,
18
26
  running_mean_outdoor_temperature,
19
27
  transpose_sharp_altitude,
28
+ f_svv,
20
29
  v_relative,
30
+ scale_wind_speed_log,
21
31
  };
@@ -1,78 +1,83 @@
1
1
  import { notOfType } from "../_internal/errors.js";
2
- const g = 9.81;
3
- const c_to_k = 273.15;
4
- const cp_air = 1004;
5
- const mu = 0.0000181; // Pa s
6
- const k_air = 0.02662; // W/m-K
7
- const beta = 0.0034; // 1/K
8
- const nu = 0.0000148; // m2/s
9
- const alpha = 0.00002591; // m2/s
10
- const pr = (cp_air * mu) / k_air; // Prandtl constants, number
11
- const o = 0.0000000567;
2
+ import { c_to_k, cp_air, g } from "../utilities/constants.js";
12
3
  /**
13
- * Converts globe temperature reading into mean radiant temperature in accordance with either the Mixed Convection
14
- * developed by Teitelbaum E. et al. (2022) or the ISO 7726:1998 Standard {@link #ref_5|[5]}.
4
+ * Convert the globe temperature reading into mean radiant temperature in accordance
5
+ * with either the Mixed Convection developed by Teitelbaum E. et al. (2022) or the ISO
6
+ * 7726:1998 Standard [7726ISO1998](../../docs/references.md#7726iso1998).
15
7
  *
16
- * @public
17
- * @memberof environment
8
+ * @param tg - globe temperature, [°C]
9
+ * @param tdb - air temperature, [°C]
10
+ * @param v - air speed, [m/s]
11
+ * @param d - diameter of the globe, [m] default 0.15 m
12
+ * @param emissivity - emissivity of the globe temperature sensor, default 0.95
13
+ * @param standard - Supported values are 'Mixed Convection' and 'ISO'. Defaults to 'Mixed Convection'.
14
+ * either choose between the Mixed Convection and ISO formulations.
15
+ * The Mixed Convection formulation has been proposed by Teitelbaum E. et al. (2022)
16
+ * to better determine the free and forced convection coefficient used in the
17
+ * calculation of the mean radiant temperature. They also showed that mean radiant
18
+ * temperature measured with ping-pong ball-sized globe thermometers is not reliable
19
+ * due to a stochastic convective bias [Teitelbaum2022](../../docs/references.md#teitelbaum2022). The Mixed Convection model has only
20
+ * been validated for globe sensors with a diameter between 0.04 and 0.15 m.
21
+ * @returns mean radiant temperature, [°C]
22
+ * @throws `RangeError` If the standard is not recognized. Please choose either 'Mixed Convection' or 'ISO'.
18
23
  *
19
- * @param {number} tg - globe temperature, [°C]
20
- * @param {number} tdb - air temperature, [°C]
21
- * @param {number} v - air speed, [m/s]
22
- * @param {number} d - diameter of the globe, [m] default 0.15 m
23
- * @param {number} emissivity - emissivity of the globe temperature sensor, default 0.95
24
- * @param {"Mixed Convection" | "ISO"} standard - either choose between the Mixed Convection and ISO formulations.
25
- * The Mixed Convection formulation has been proposed by Teitelbaum E. et al. (2022)
26
- * to better determine the free and forced convection coefficient used in the
27
- * calculation of the mean radiant temperature. They also showed that mean radiant
28
- * temperature measured with ping-pong ball-sized globe thermometers is not reliable
29
- * due to a stochastic convective bias {@link #ref_22|[22]}. The Mixed Convection model has only
30
- * been validated for globe sensors with a diameter between 0.04 and 0.15 m.
31
- * @returns {number}
24
+ * @example
25
+ * ```ts
26
+ * import { mean_radiant_tmp } from "jsthermalcomfort/environment";
27
+ *
28
+ * const tg = 53.2; // globe temperature in °C
29
+ * const tdb = 30.0; // dry bulb temperature in °C
30
+ * const v = 0.3; // air speed in m/s
31
+ * const d = 0.1; // diameter of the globe in m
32
+ * const tr = mean_radiant_tmp(tg, tdb, v, d, undefined, "ISO");
33
+ * console.log(tr); // 74.8
34
+ * ```
32
35
  */
33
36
  export function mean_radiant_tmp(tg, tdb, v, d = 0.15, emissivity = 0.95, standard = "Mixed Convection") {
34
37
  for (const [key, value] of Object.entries({ tg, tdb, v, d, emissivity })) {
35
38
  if (typeof value !== "number")
36
39
  throw notOfType(key, "a number");
37
40
  }
38
- if (typeof standard !== "string")
41
+ if (typeof standard !== "string") {
39
42
  throw notOfType("standard", "a string");
43
+ }
40
44
  standard = standard.toLowerCase();
41
45
  if (standard === "mixed convection") {
42
- const tr = get_tr_mixed_convection(tg, tdb, v, d, emissivity);
46
+ const mu = 0.0000181; // Pa s
47
+ const k_air = 0.02662; // W/m-K
48
+ const beta = 0.0034; // 1/K
49
+ const nu = 0.0000148; // m2/s
50
+ const alpha = 0.00002591; // m2/s
51
+ const pr = (cp_air * mu) / k_air; // Prandtl constants
52
+ const o = 0.0000000567;
53
+ const n = 1.27 * d + 0.57;
54
+ const ra = (g * beta * Math.abs(tg - tdb) * d * d * d) / nu / alpha;
55
+ const re = (v * d) / nu;
56
+ const nu_natural = 2 +
57
+ (0.589 * Math.pow(ra, 1 / 4)) /
58
+ Math.pow(1 + Math.pow(0.469 / pr, 9 / 16), 4 / 9);
59
+ const nu_forced = 2 +
60
+ (0.4 * Math.pow(re, 0.5) + 0.06 * Math.pow(re, 2 / 3)) *
61
+ Math.pow(pr, 0.4);
62
+ const tr = Math.pow(Math.pow(tg + 273.15, 4) -
63
+ (((Math.pow(Math.pow(nu_forced, n) + Math.pow(nu_natural, n), 1 / n) *
64
+ k_air) /
65
+ d) *
66
+ (-tg + tdb)) /
67
+ emissivity /
68
+ o, 0.25) - 273.15;
69
+ // Out of range is NaN without upstream's UserWarning (deviation _shared-147).
43
70
  return d >= 0.04 && d <= 0.15 ? tr : NaN;
44
71
  }
45
72
  if (standard === "iso") {
46
- return get_tr_iso(tg, tdb, v, d, emissivity);
73
+ tg = tg + c_to_k;
74
+ tdb = tdb + c_to_k;
75
+ // calculate heat transfer coefficient
76
+ const h_n = 1.4 * Math.pow(Math.abs(tg - tdb) / d, 0.25); // natural convection
77
+ const h_f = (6.3 * Math.pow(v, 0.6)) / Math.pow(d, 0.4); // forced convection
78
+ // get the biggest between the two coefficients
79
+ const h = Math.max(h_f, h_n);
80
+ return (Math.pow(Math.pow(tg, 4) + (h * (tg - tdb)) / (emissivity * (5.67 * 10 ** -8)), 0.25) - c_to_k);
47
81
  }
48
82
  throw new RangeError("Standard not recognized. Please choose either 'Mixed Convection' or 'ISO'.");
49
83
  }
50
- function get_tr_mixed_convection(_tg, _tdb, _v, _d, _emissivity) {
51
- const ra = (g * beta * Math.abs(_tg - _tdb) * _d * _d * _d) / nu / alpha;
52
- const re = (_v * _d) / nu;
53
- const n = 1.27 * _d + 0.57;
54
- const nu_natural = 2 +
55
- (0.589 * Math.pow(ra, 1 / 4)) /
56
- Math.pow(1 + Math.pow(0.469 / pr, 9 / 16), 4 / 9);
57
- const nu_forced = 2 +
58
- (0.4 * Math.pow(re, 0.5) + 0.06 * Math.pow(re, 2 / 3)) * Math.pow(pr, 0.4);
59
- const tr = Math.pow(Math.pow(_tg + 273.15, 4) -
60
- (((Math.pow(Math.pow(nu_forced, n) + Math.pow(nu_natural, n), 1 / n) *
61
- k_air) /
62
- _d) *
63
- (-_tg + _tdb)) /
64
- _emissivity /
65
- o, 0.25) - 273.15;
66
- return tr;
67
- }
68
- function get_tr_iso(_tg, _tdb, _v, _d, _emissivity) {
69
- _tg += c_to_k;
70
- _tdb += c_to_k;
71
- // calculate heat transfer coefficient
72
- const h_n = 1.4 * Math.pow(Math.abs(_tg - _tdb) / _d, 0.25); // natural convection
73
- const h_f = (6.3 * Math.pow(_v, 0.6)) / Math.pow(_d, 0.4); // forced convection
74
- // get the biggest between the two coefficients
75
- const h = Math.max(h_f, h_n);
76
- const tr = Math.pow(Math.pow(_tg, 4) + (h * (_tg - _tdb)) / (_emissivity * (5.67 * 10 ** -8)), 0.25) - c_to_k;
77
- return tr;
78
- }