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,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.find_span = exports.solar_gain = void 0;
4
+ const utilities_js_1 = require("../utilities/utilities.js");
5
+ const utilities_js_2 = require("../utilities/utilities.js");
6
+ // avoid reallocating these arrays accross function calls
7
+ const _alt_range = [0, 15, 30, 45, 60, 75, 90];
8
+ const _az_range = [0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180];
9
+ // avoid reallocating these table across function calls
10
+ const _fp_table_seated = [
11
+ [0.29, 0.324, 0.305, 0.303, 0.262, 0.224, 0.177],
12
+ [0.292, 0.328, 0.294, 0.288, 0.268, 0.227, 0.177],
13
+ [0.288, 0.332, 0.298, 0.29, 0.264, 0.222, 0.177],
14
+ [0.274, 0.326, 0.294, 0.289, 0.252, 0.214, 0.177],
15
+ [0.254, 0.308, 0.28, 0.276, 0.241, 0.202, 0.177],
16
+ [0.23, 0.282, 0.262, 0.26, 0.233, 0.193, 0.177],
17
+ [0.216, 0.26, 0.248, 0.244, 0.22, 0.186, 0.177],
18
+ [0.234, 0.258, 0.236, 0.227, 0.208, 0.18, 0.177],
19
+ [0.262, 0.26, 0.224, 0.208, 0.196, 0.176, 0.177],
20
+ [0.28, 0.26, 0.21, 0.192, 0.184, 0.17, 0.177],
21
+ [0.298, 0.256, 0.194, 0.174, 0.168, 0.168, 0.177],
22
+ [0.306, 0.25, 0.18, 0.156, 0.156, 0.166, 0.177],
23
+ [0.3, 0.24, 0.168, 0.152, 0.152, 0.164, 0.177],
24
+ ];
25
+ const _fp_table = [
26
+ [0.35, 0.35, 0.314, 0.258, 0.206, 0.144, 0.082],
27
+ [0.342, 0.342, 0.31, 0.252, 0.2, 0.14, 0.082],
28
+ [0.33, 0.33, 0.3, 0.244, 0.19, 0.132, 0.082],
29
+ [0.31, 0.31, 0.275, 0.228, 0.175, 0.124, 0.082],
30
+ [0.283, 0.283, 0.251, 0.208, 0.16, 0.114, 0.082],
31
+ [0.252, 0.252, 0.228, 0.188, 0.15, 0.108, 0.082],
32
+ [0.23, 0.23, 0.214, 0.18, 0.148, 0.108, 0.082],
33
+ [0.242, 0.242, 0.222, 0.18, 0.153, 0.112, 0.082],
34
+ [0.274, 0.274, 0.245, 0.203, 0.165, 0.116, 0.082],
35
+ [0.304, 0.304, 0.27, 0.22, 0.174, 0.121, 0.082],
36
+ [0.328, 0.328, 0.29, 0.234, 0.183, 0.125, 0.082],
37
+ [0.344, 0.344, 0.304, 0.244, 0.19, 0.128, 0.082],
38
+ [0.347, 0.347, 0.308, 0.246, 0.191, 0.128, 0.082],
39
+ ];
40
+ /**
41
+ * @typedef {object} SolarGainReturnType
42
+ * @property {number} erf - Solar gain to the human body using the Effective Radiant Field [W/m2]
43
+ * @property {number} delta_mrt - Delta mean radiant temperature. The amount by which the mean radiant
44
+ * temperature of the space should be increased if no solar radiation is present.
45
+ * @public
46
+ */
47
+ /**
48
+ * Calculates the solar gain to the human body using the Effective Radiant
49
+ * Field ( ERF) {@link #ref_1|[1]}. The ERF is a measure of the net energy flux to or from
50
+ * the human body. ERF is expressed in W over human body surface area [w/m2].
51
+ *
52
+ * In addition, it calculates the delta mean radiant temperature. Which is the
53
+ * amount by which the mean radiant temperature of the space should be
54
+ * increased if no solar radiation is present.
55
+ *
56
+ * More information on the calculation procedure can be found in Appendix C of {@link #ref_1|[1]}.
57
+ *
58
+ * @memberof models
59
+ * @public
60
+ * @docname Solar gain on people
61
+ *
62
+ * @param {number} sol_altitude - Solar altitude, degrees from horizontal [deg]. Ranges between 0 and 90.
63
+ * @param {number} sharp - Solar horizontal angle relative to the front of the person (SHARP) [deg].
64
+ * Ranges between 0 and 180 and is symmetrical on either side. Zero (0) degrees
65
+ * represents direct-beam radiation from the front, 90 degrees represents
66
+ * direct-beam radiation from the side, and 180 degrees rep- resent direct-beam
67
+ * radiation from the back. SHARP is the angle between the sun and the person
68
+ * only. Orientation relative to compass or to room is not included in SHARP.
69
+ * @param {number} sol_radiation_dir - Direct-beam solar radiation, [W/m2]. Ranges between 200 and 1000. See Table C2-3 of ASHRAE 55 2020 {@link #ref_1|[1]}.
70
+ * @param {number} sol_transmittance - Total solar transmittance, ranges from 0 to 1. The total solar
71
+ * transmittance of window systems, including glazing unit, blinds, and other
72
+ * façade treatments, shall be determined using one of the following methods:
73
+ * - i) Provided by manufacturer or from the National Fenestration Rating Council approved Lawrence Berkeley National Lab International Glazing Database.
74
+ * - ii) Glazing unit plus venetian blinds or other complex or unique shades shall be calculated using National Fenestration Rating Council approved software or Lawrence Berkeley National Lab Complex Glazing Database.
75
+ * @param {number} f_svv - Fraction of sky-vault view fraction exposed to body, ranges from 0 to 1. It can be calculated using the function {@link #f_svv|f_svv} in utilities.
76
+ * @param {number} f_bes - Fraction of the possible body surface exposed to sun, ranges from 0 to 1. See Table C2-2 and equation C-7 ASHRAE 55 2020 {@link #ref_1|[1]}.
77
+ * @param {number} [asw=0.7] - The average short-wave absorptivity of the occupant. It will range widely,
78
+ * depending on the color of the occupant’s skin as well as the color and
79
+ * amount of clothing covering the body.
80
+ *
81
+ * A value of 0.7 shall be used unless more specific information about the
82
+ * clothing or skin color of the occupants is available.
83
+ * Note: Short-wave absorptivity typically ranges from 0.57 to 0.84, depending
84
+ * on skin and clothing color. More information is available in Blum (1945).
85
+ * @param {"standing" | "supine" | "seated"} [posture="seated"] - Default 'seated' list of available options 'standing', 'supine' or 'seated'
86
+ * @param {number} [floor_reflectance=0.7] - Floor refectance. It is assumed to be constant and equal to 0.6.
87
+ *
88
+ * @returns {SolarGainReturnType}
89
+ *
90
+ * @example
91
+ * import {solar_gain} from "jsthermalcomfort/models";
92
+ * const results = solar_gain(0, 120, 800, 0.5, 0.7, "seated");
93
+ * console.log(results); // {erf: 42.9, delta_mrt: 10.3}
94
+ */
95
+ function solar_gain(sol_altitude, sharp, sol_radiation_dir, sol_transmittance, f_svv, f_bes, asw = 0.7, posture = "seated", floor_reflectance = 0.6) {
96
+ posture = posture.toLowerCase();
97
+ if (posture !== "standing" && posture !== "supine" && posture !== "seated")
98
+ throw new Error("Posture has to be either standing, supine or seated");
99
+ const deg_to_rad = 0.0174532925;
100
+ const hr = 6;
101
+ const i_diff = 0.2 * sol_radiation_dir;
102
+ // fp is the projected area factor
103
+ const fp_table = posture === "seated" ? _fp_table_seated : _fp_table;
104
+ if (posture === "supine") {
105
+ [sharp, sol_altitude] = (0, utilities_js_2.transpose_sharp_altitude)(sharp, sol_altitude);
106
+ }
107
+ const alt_i = find_span(_alt_range, sol_altitude);
108
+ const az_i = find_span(_az_range, sharp);
109
+ const fp11 = fp_table[az_i][alt_i];
110
+ const fp12 = fp_table[az_i][alt_i + 1];
111
+ const fp21 = fp_table[az_i + 1][alt_i];
112
+ const fp22 = fp_table[az_i + 1][alt_i + 1];
113
+ const az1 = _az_range[az_i];
114
+ const az2 = _az_range[az_i + 1];
115
+ const alt1 = _alt_range[alt_i];
116
+ const alt2 = _alt_range[alt_i + 1];
117
+ let fp = fp11 * (az2 - sharp) * (alt2 - sol_altitude);
118
+ fp += fp21 * (sharp - az1) * (alt2 - sol_altitude);
119
+ fp += fp12 * (az2 - sharp) * (sol_altitude - alt1);
120
+ fp += fp22 * (sharp - az1) * (sol_altitude - alt1);
121
+ fp /= (az2 - az1) * (alt2 - alt1);
122
+ const f_eff = posture === "seated" ? 0.696 : 0.725; // fraction of the body surface exposed to environmental radiation
123
+ const sw_abs = asw;
124
+ const lw_abs = 0.95;
125
+ const e_diff = f_eff * f_svv * 0.5 * sol_transmittance * i_diff;
126
+ const e_direct = f_eff * fp * sol_transmittance * f_bes * sol_radiation_dir;
127
+ const e_reflected = f_eff *
128
+ f_svv *
129
+ 0.5 *
130
+ sol_transmittance *
131
+ (sol_radiation_dir * Math.sin(sol_altitude * deg_to_rad) + i_diff) *
132
+ floor_reflectance;
133
+ const e_solar = e_diff + e_direct + e_reflected;
134
+ const erf = e_solar * (sw_abs / lw_abs);
135
+ const d_mrt = erf / (hr * f_eff);
136
+ return { erf: (0, utilities_js_1.round)(erf, 1), delta_mrt: (0, utilities_js_1.round)(d_mrt, 1) };
137
+ }
138
+ exports.solar_gain = solar_gain;
139
+ /**
140
+ *
141
+ * @param {number[]} arr
142
+ * @param {number} x
143
+ *
144
+ * @returns {number}
145
+ */
146
+ function find_span(arr, x) {
147
+ let left = 0;
148
+ let right = arr.length - 1;
149
+ while (left <= right) {
150
+ let mid = left + Math.floor((right - left) / 2);
151
+ if (arr[mid + 1] >= x && x > arr[mid]) {
152
+ return mid;
153
+ }
154
+ if (x <= arr[mid]) {
155
+ right = mid - 1;
156
+ }
157
+ else if (x > arr[mid]) {
158
+ left = mid + 1;
159
+ }
160
+ }
161
+ return x === arr[0] ? 0 : -1;
162
+ }
163
+ exports.find_span = find_span;