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.
- package/README.md +196 -6
- package/lib/cjs/index.js +7 -434
- package/lib/cjs/models/a_pmv.js +140 -0
- package/lib/cjs/models/adaptive_ashrae.js +290 -0
- package/lib/cjs/models/adaptive_en.js +300 -0
- package/lib/cjs/models/ankle_draft.js +82 -0
- package/lib/cjs/models/at.js +52 -0
- package/lib/cjs/models/athb.js +135 -0
- package/lib/cjs/models/clo_tout.js +58 -0
- package/lib/cjs/models/cooling_effect.js +164 -0
- package/lib/cjs/models/discomfort_index.js +115 -0
- package/lib/cjs/models/e_pmv.js +154 -0
- package/lib/cjs/models/heat_index.js +60 -0
- package/lib/cjs/models/humidex.js +63 -0
- package/lib/cjs/models/index.js +71 -0
- package/lib/cjs/models/net.js +50 -0
- package/lib/cjs/models/pet_steady.js +443 -0
- package/lib/cjs/models/phs.js +458 -0
- package/lib/cjs/models/pmv.js +200 -0
- package/lib/cjs/models/pmv_ppd.js +404 -0
- package/lib/cjs/models/set_tmp.js +203 -0
- package/lib/cjs/models/solar_gain.js +163 -0
- package/lib/cjs/models/two_nodes.js +790 -0
- package/lib/cjs/models/use_fans_heatwave.js +203 -0
- package/lib/cjs/models/utci.js +609 -0
- package/lib/cjs/models/vertical_tmp_grad_ppd.js +95 -0
- package/lib/cjs/models/wbgt.js +72 -0
- package/lib/cjs/models/wc.js +37 -0
- package/lib/cjs/psychrometrics/enthalpy.js +24 -0
- package/lib/cjs/psychrometrics/index.js +28 -0
- package/lib/cjs/psychrometrics/p_sat.js +46 -0
- package/lib/cjs/psychrometrics/p_sat_torr.js +34 -0
- package/lib/cjs/psychrometrics/psy_ta_rh.js +51 -0
- package/lib/cjs/psychrometrics/t_dp.js +19 -0
- package/lib/cjs/psychrometrics/t_mrt.js +117 -0
- package/lib/cjs/psychrometrics/t_o.js +82 -0
- package/lib/cjs/psychrometrics/t_wb.js +23 -0
- package/lib/cjs/types/index.d.ts +7 -79
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/models/a_pmv.d.ts +133 -0
- package/lib/cjs/types/models/a_pmv.d.ts.map +1 -0
- package/lib/cjs/types/models/adaptive_ashrae.d.ts +211 -0
- package/lib/cjs/types/models/adaptive_ashrae.d.ts.map +1 -0
- package/lib/cjs/types/models/adaptive_en.d.ts +217 -0
- package/lib/cjs/types/models/adaptive_en.d.ts.map +1 -0
- package/lib/cjs/types/models/ankle_draft.d.ts +60 -0
- package/lib/cjs/types/models/ankle_draft.d.ts.map +1 -0
- package/lib/cjs/types/models/at.d.ts +34 -0
- package/lib/cjs/types/models/at.d.ts.map +1 -0
- package/lib/cjs/types/models/athb.d.ts +96 -0
- package/lib/cjs/types/models/athb.d.ts.map +1 -0
- package/lib/cjs/types/models/clo_tout.d.ts +45 -0
- package/lib/cjs/types/models/clo_tout.d.ts.map +1 -0
- package/lib/cjs/types/models/cooling_effect.d.ts +49 -0
- package/lib/cjs/types/models/cooling_effect.d.ts.map +1 -0
- package/lib/cjs/types/models/discomfort_index.d.ts +91 -0
- package/lib/cjs/types/models/discomfort_index.d.ts.map +1 -0
- package/lib/cjs/types/models/e_pmv.d.ts +139 -0
- package/lib/cjs/types/models/e_pmv.d.ts.map +1 -0
- package/lib/cjs/types/models/heat_index.d.ts +27 -0
- package/lib/cjs/types/models/heat_index.d.ts.map +1 -0
- package/lib/cjs/types/models/humidex.d.ts +54 -0
- package/lib/cjs/types/models/humidex.d.ts.map +1 -0
- package/lib/cjs/types/models/index.d.ts +78 -0
- package/lib/cjs/types/models/index.d.ts.map +1 -0
- package/lib/cjs/types/models/net.d.ts +39 -0
- package/lib/cjs/types/models/net.d.ts.map +1 -0
- package/lib/cjs/types/models/pet_steady.d.ts +59 -0
- package/lib/cjs/types/models/pet_steady.d.ts.map +1 -0
- package/lib/cjs/types/models/phs.d.ts +242 -0
- package/lib/cjs/types/models/phs.d.ts.map +1 -0
- package/lib/cjs/types/models/pmv.d.ts +198 -0
- package/lib/cjs/types/models/pmv.d.ts.map +1 -0
- package/lib/cjs/types/models/pmv_ppd.d.ts +246 -0
- package/lib/cjs/types/models/pmv_ppd.d.ts.map +1 -0
- package/lib/cjs/types/models/set_tmp.d.ts +124 -0
- package/lib/cjs/types/models/set_tmp.d.ts.map +1 -0
- package/lib/cjs/types/models/solar_gain.d.ts +76 -0
- package/lib/cjs/types/models/solar_gain.d.ts.map +1 -0
- package/lib/cjs/types/models/two_nodes.d.ts +412 -0
- package/lib/cjs/types/models/two_nodes.d.ts.map +1 -0
- package/lib/cjs/types/models/use_fans_heatwave.d.ts +188 -0
- package/lib/cjs/types/models/use_fans_heatwave.d.ts.map +1 -0
- package/lib/cjs/types/models/utci.d.ts +79 -0
- package/lib/cjs/types/models/utci.d.ts.map +1 -0
- package/lib/cjs/types/models/vertical_tmp_grad_ppd.d.ts +58 -0
- package/lib/cjs/types/models/vertical_tmp_grad_ppd.d.ts.map +1 -0
- package/lib/cjs/types/models/wbgt.d.ts +51 -0
- package/lib/cjs/types/models/wbgt.d.ts.map +1 -0
- package/lib/cjs/types/models/wc.d.ts +29 -0
- package/lib/cjs/types/models/wc.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/enthalpy.d.ts +12 -0
- package/lib/cjs/types/psychrometrics/enthalpy.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/index.d.ts +26 -0
- package/lib/cjs/types/psychrometrics/index.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/p_sat.d.ts +13 -0
- package/lib/cjs/types/psychrometrics/p_sat.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/p_sat_torr.d.ts +26 -0
- package/lib/cjs/types/psychrometrics/p_sat_torr.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/psy_ta_rh.d.ts +51 -0
- package/lib/cjs/types/psychrometrics/psy_ta_rh.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/t_dp.d.ts +9 -0
- package/lib/cjs/types/psychrometrics/t_dp.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/t_mrt.d.ts +43 -0
- package/lib/cjs/types/psychrometrics/t_mrt.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/t_o.d.ts +31 -0
- package/lib/cjs/types/psychrometrics/t_o.d.ts.map +1 -0
- package/lib/cjs/types/psychrometrics/t_wb.d.ts +12 -0
- package/lib/cjs/types/psychrometrics/t_wb.d.ts.map +1 -0
- package/lib/cjs/types/utilities/index.d.ts +28 -0
- package/lib/cjs/types/utilities/index.d.ts.map +1 -0
- package/lib/cjs/types/utilities/utilities.d.ts +377 -0
- package/lib/cjs/types/utilities/utilities.d.ts.map +1 -0
- package/lib/cjs/utilities/index.js +27 -0
- package/lib/cjs/utilities/utilities.js +903 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/models/a_pmv.js +135 -0
- package/lib/esm/models/adaptive_ashrae.js +285 -0
- package/lib/esm/models/adaptive_en.js +294 -0
- package/lib/esm/models/ankle_draft.js +78 -0
- package/lib/esm/models/at.js +48 -0
- package/lib/esm/models/athb.js +130 -0
- package/lib/esm/models/clo_tout.js +53 -0
- package/lib/esm/models/cooling_effect.js +159 -0
- package/lib/esm/models/discomfort_index.js +110 -0
- package/lib/esm/models/e_pmv.js +149 -0
- package/lib/esm/models/heat_index.js +56 -0
- package/lib/esm/models/humidex.js +59 -0
- package/lib/esm/models/index.js +69 -0
- package/lib/esm/models/net.js +46 -0
- package/lib/esm/models/pet_steady.js +439 -0
- package/lib/esm/models/phs.js +454 -0
- package/lib/esm/models/pmv.js +195 -0
- package/lib/esm/models/pmv_ppd.js +398 -0
- package/lib/esm/models/set_tmp.js +198 -0
- package/lib/esm/models/solar_gain.js +158 -0
- package/lib/esm/models/two_nodes.js +784 -0
- package/lib/esm/models/use_fans_heatwave.js +199 -0
- package/lib/esm/models/utci.js +604 -0
- package/lib/esm/models/wbgt.js +68 -0
- package/lib/esm/models/wc.js +33 -0
- package/lib/esm/psychrometrics/enthalpy.js +20 -0
- package/lib/esm/psychrometrics/index.js +26 -0
- package/lib/esm/psychrometrics/p_sat.js +42 -0
- package/lib/esm/psychrometrics/p_sat_torr.js +29 -0
- package/lib/esm/psychrometrics/psy_ta_rh.js +47 -0
- package/lib/esm/psychrometrics/t_dp.js +15 -0
- package/lib/esm/psychrometrics/t_mrt.js +112 -0
- package/lib/esm/psychrometrics/t_o.js +77 -0
- package/lib/esm/psychrometrics/t_wb.js +19 -0
- package/lib/esm/types/index.d.ts +7 -79
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/models/a_pmv.d.ts +133 -0
- package/lib/esm/types/models/a_pmv.d.ts.map +1 -0
- package/lib/esm/types/models/adaptive_ashrae.d.ts +211 -0
- package/lib/esm/types/models/adaptive_ashrae.d.ts.map +1 -0
- package/lib/esm/types/models/adaptive_en.d.ts +217 -0
- package/lib/esm/types/models/adaptive_en.d.ts.map +1 -0
- package/lib/esm/types/models/ankle_draft.d.ts +60 -0
- package/lib/esm/types/models/ankle_draft.d.ts.map +1 -0
- package/lib/esm/types/models/at.d.ts +34 -0
- package/lib/esm/types/models/at.d.ts.map +1 -0
- package/lib/esm/types/models/athb.d.ts +96 -0
- package/lib/esm/types/models/athb.d.ts.map +1 -0
- package/lib/esm/types/models/clo_tout.d.ts +45 -0
- package/lib/esm/types/models/clo_tout.d.ts.map +1 -0
- package/lib/esm/types/models/cooling_effect.d.ts +49 -0
- package/lib/esm/types/models/cooling_effect.d.ts.map +1 -0
- package/lib/esm/types/models/discomfort_index.d.ts +91 -0
- package/lib/esm/types/models/discomfort_index.d.ts.map +1 -0
- package/lib/esm/types/models/e_pmv.d.ts +139 -0
- package/lib/esm/types/models/e_pmv.d.ts.map +1 -0
- package/lib/esm/types/models/heat_index.d.ts +27 -0
- package/lib/esm/types/models/heat_index.d.ts.map +1 -0
- package/lib/esm/types/models/humidex.d.ts +54 -0
- package/lib/esm/types/models/humidex.d.ts.map +1 -0
- package/lib/esm/types/models/index.d.ts +77 -0
- package/lib/esm/types/models/index.d.ts.map +1 -0
- package/lib/esm/types/models/net.d.ts +39 -0
- package/lib/esm/types/models/net.d.ts.map +1 -0
- package/lib/esm/types/models/pet_steady.d.ts +59 -0
- package/lib/esm/types/models/pet_steady.d.ts.map +1 -0
- package/lib/esm/types/models/phs.d.ts +242 -0
- package/lib/esm/types/models/phs.d.ts.map +1 -0
- package/lib/esm/types/models/pmv.d.ts +198 -0
- package/lib/esm/types/models/pmv.d.ts.map +1 -0
- package/lib/esm/types/models/pmv_ppd.d.ts +246 -0
- package/lib/esm/types/models/pmv_ppd.d.ts.map +1 -0
- package/lib/esm/types/models/set_tmp.d.ts +124 -0
- package/lib/esm/types/models/set_tmp.d.ts.map +1 -0
- package/lib/esm/types/models/solar_gain.d.ts +76 -0
- package/lib/esm/types/models/solar_gain.d.ts.map +1 -0
- package/lib/esm/types/models/two_nodes.d.ts +412 -0
- package/lib/esm/types/models/two_nodes.d.ts.map +1 -0
- package/lib/esm/types/models/use_fans_heatwave.d.ts +188 -0
- package/lib/esm/types/models/use_fans_heatwave.d.ts.map +1 -0
- package/lib/esm/types/models/utci.d.ts +79 -0
- package/lib/esm/types/models/utci.d.ts.map +1 -0
- package/lib/esm/types/models/wbgt.d.ts +51 -0
- package/lib/esm/types/models/wbgt.d.ts.map +1 -0
- package/lib/esm/types/models/wc.d.ts +29 -0
- package/lib/esm/types/models/wc.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/enthalpy.d.ts +12 -0
- package/lib/esm/types/psychrometrics/enthalpy.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/index.d.ts +26 -0
- package/lib/esm/types/psychrometrics/index.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/p_sat.d.ts +13 -0
- package/lib/esm/types/psychrometrics/p_sat.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/p_sat_torr.d.ts +26 -0
- package/lib/esm/types/psychrometrics/p_sat_torr.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/psy_ta_rh.d.ts +51 -0
- package/lib/esm/types/psychrometrics/psy_ta_rh.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/t_dp.d.ts +9 -0
- package/lib/esm/types/psychrometrics/t_dp.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/t_mrt.d.ts +43 -0
- package/lib/esm/types/psychrometrics/t_mrt.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/t_o.d.ts +31 -0
- package/lib/esm/types/psychrometrics/t_o.d.ts.map +1 -0
- package/lib/esm/types/psychrometrics/t_wb.d.ts +12 -0
- package/lib/esm/types/psychrometrics/t_wb.d.ts.map +1 -0
- package/lib/esm/types/utilities/index.d.ts +28 -0
- package/lib/esm/types/utilities/index.d.ts.map +1 -0
- package/lib/esm/types/utilities/utilities.d.ts +377 -0
- package/lib/esm/types/utilities/utilities.d.ts.map +1 -0
- package/lib/esm/utilities/index.js +25 -0
- package/lib/esm/utilities/utilities.js +885 -0
- package/package.json +22 -15
- package/lib/esm/index.mjs +0 -430
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
import { p_sat } from "../psychrometrics/p_sat.js";
|
|
2
|
+
import { t_o_array } from "../psychrometrics/t_o.js";
|
|
3
|
+
/**
|
|
4
|
+
* Rounds a number to the given precision.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} number - the number to round
|
|
7
|
+
* @param {number} precision - the number of decimal places to round to
|
|
8
|
+
* @returns {number} the rounded result
|
|
9
|
+
*/
|
|
10
|
+
export function round(number, precision) {
|
|
11
|
+
const smudge = 10 ** precision;
|
|
12
|
+
return Math.round(number * smudge) / smudge;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {Object} ComplianceKwargs
|
|
16
|
+
* @property {number} [met]
|
|
17
|
+
* @property {number} [clo]
|
|
18
|
+
* @property {number} [tdb]
|
|
19
|
+
* @property {number} [tr]
|
|
20
|
+
* @property {number} [v]
|
|
21
|
+
* @property {number} [vr]
|
|
22
|
+
* @property {number} [v_limited]
|
|
23
|
+
* @property {number} [rh]
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {Object} ComplianceKwargsArray
|
|
27
|
+
* @property {number[]} [met]
|
|
28
|
+
* @property {number[]} [clo]
|
|
29
|
+
* @property {number[]} [tdb]
|
|
30
|
+
* @property {number[]} [tr]
|
|
31
|
+
* @property {number[]} [v]
|
|
32
|
+
* @property {number[]} [v_limited]
|
|
33
|
+
* @property {number[]} [rh]
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {"ANKLE_DRAFT" | "ASHRAE" | "ISO" | "ISO7933"} Standard
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Converts degrees to radians
|
|
40
|
+
*
|
|
41
|
+
* @param {number} degrees
|
|
42
|
+
*
|
|
43
|
+
* @returns {number} - radians
|
|
44
|
+
*/
|
|
45
|
+
function degrees_to_radians(degrees) {
|
|
46
|
+
return degrees * (Math.PI / 180);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Converts radians to degree unit
|
|
50
|
+
*
|
|
51
|
+
* @param {number} radians
|
|
52
|
+
*
|
|
53
|
+
* @returns {number} - degrees
|
|
54
|
+
*/
|
|
55
|
+
function radians_to_degrees(radians) {
|
|
56
|
+
return radians * (180 / Math.PI);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Converts sharp and altittude from radians to degree unit
|
|
60
|
+
* @param {number} sharp
|
|
61
|
+
* @param {number} altitude
|
|
62
|
+
* @returns {[number, number]}
|
|
63
|
+
*/
|
|
64
|
+
export function transpose_sharp_altitude(sharp, altitude) {
|
|
65
|
+
const altitude_new = radians_to_degrees(Math.asin(Math.sin(degrees_to_radians(Math.abs(sharp - 90))) *
|
|
66
|
+
Math.cos(degrees_to_radians(altitude))));
|
|
67
|
+
sharp = radians_to_degrees(Math.atan(Math.sin(degrees_to_radians(sharp)) *
|
|
68
|
+
Math.tan(degrees_to_radians(90 - altitude))));
|
|
69
|
+
return [round(sharp, 3), round(altitude_new, 3)];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check that the values comply with the standard provided
|
|
73
|
+
*
|
|
74
|
+
* @param {Standard} standard
|
|
75
|
+
* @param {ComplianceKwargs} kwargs
|
|
76
|
+
*
|
|
77
|
+
* @returns {string[]} strings with warnings emitted
|
|
78
|
+
*/
|
|
79
|
+
export function check_standard_compliance(standard, kwargs) {
|
|
80
|
+
switch (standard) {
|
|
81
|
+
case "ANKLE_DRAFT":
|
|
82
|
+
return _ankle_draft_compliance(kwargs);
|
|
83
|
+
case "ASHRAE":
|
|
84
|
+
return _ashrae_compliance(kwargs);
|
|
85
|
+
case "ISO":
|
|
86
|
+
return _iso_compliance(kwargs);
|
|
87
|
+
case "ISO7933":
|
|
88
|
+
return _iso7933_compliance(kwargs);
|
|
89
|
+
default:
|
|
90
|
+
throw new Error("Unknown standard");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {Object.<string, number[]>} CheckStandardComplianceResult
|
|
95
|
+
* @property {number[]} tdb
|
|
96
|
+
* @property {number[]} tr
|
|
97
|
+
* @property {number[]} v
|
|
98
|
+
* @property {number[]} [met]
|
|
99
|
+
* @property {number[]} [clo]
|
|
100
|
+
* @property {number[]} [rh]
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* Check that the values as an array comply with the standard provided and returns arrays where
|
|
104
|
+
* the values that do not comply are NaN
|
|
105
|
+
* @see {@link check_standard_compliance} for scalar variant that returns warnings
|
|
106
|
+
*
|
|
107
|
+
* @param {Standard | "FAN_HEATWAVES"} standard - standard to check compliance with
|
|
108
|
+
* @param {ComplianceKwargsArray & {airspeed_control?: boolean}} kwargs - values to check compliance against
|
|
109
|
+
*
|
|
110
|
+
* @returns {CheckStandardComplianceResult} filtered arrays based on compliance limits
|
|
111
|
+
*/
|
|
112
|
+
export function check_standard_compliance_array(standard, kwargs) {
|
|
113
|
+
const default_kwargs = { airspeed_control: true };
|
|
114
|
+
kwargs = Object.assign(default_kwargs, kwargs);
|
|
115
|
+
switch (standard) {
|
|
116
|
+
case "ISO7933":
|
|
117
|
+
case "ANKLE_DRAFT":
|
|
118
|
+
throw new Error(`Unsupported standard ${standard}`);
|
|
119
|
+
case "ASHRAE": {
|
|
120
|
+
// based on table 7.3.4 ashrae 55 2020
|
|
121
|
+
const tdb = valid_range(kwargs.tdb, [10.0, 40.0]);
|
|
122
|
+
const tr = valid_range(kwargs.tr, [10.0, 40.0]);
|
|
123
|
+
let original_v = kwargs.v || [];
|
|
124
|
+
let v = valid_range(kwargs.v, [0.0, 2.0]);
|
|
125
|
+
if (!kwargs.airspeed_control) {
|
|
126
|
+
const met_aux = kwargs.met || [];
|
|
127
|
+
const clo_aux = kwargs.clo || [];
|
|
128
|
+
v = v.map((_v, index) => original_v[index] > 0.8 &&
|
|
129
|
+
clo_aux[index] < 0.7 &&
|
|
130
|
+
met_aux[index] < 1.3
|
|
131
|
+
? NaN
|
|
132
|
+
: _v);
|
|
133
|
+
const to = t_o_array(tdb, tr, original_v);
|
|
134
|
+
v = v.map((_v, index) => {
|
|
135
|
+
const limit = 50.49 - 4.4047 * to[index] + 0.096425 * to[index] * to[index];
|
|
136
|
+
return (23 < to[index] &&
|
|
137
|
+
to[index] < 25.5 &&
|
|
138
|
+
original_v[index] > limit &&
|
|
139
|
+
clo_aux[index] < 0.7 &&
|
|
140
|
+
met_aux[index] < 1.3) ||
|
|
141
|
+
(to[index] <= 23 &&
|
|
142
|
+
original_v[index] > 0.2 &&
|
|
143
|
+
clo_aux[index] < 0.7 &&
|
|
144
|
+
met_aux[index] < 1.3)
|
|
145
|
+
? NaN
|
|
146
|
+
: _v;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (kwargs.met !== undefined) {
|
|
150
|
+
const met = valid_range(kwargs.met, [1.0, 4.0]);
|
|
151
|
+
const clo = valid_range(kwargs.clo, [0.0, 1.5]);
|
|
152
|
+
return { tdb, tr, v, met, clo };
|
|
153
|
+
}
|
|
154
|
+
return { tdb, tr, v };
|
|
155
|
+
}
|
|
156
|
+
case "FAN_HEATWAVES": {
|
|
157
|
+
const tdb = valid_range(kwargs.tdb, [20.0, 50.0]);
|
|
158
|
+
const tr = valid_range(kwargs.tr, [20.0, 50.0]);
|
|
159
|
+
const v = valid_range(kwargs.v, [0.1, 4.5]);
|
|
160
|
+
const rh = valid_range(kwargs.rh, [0, 100]);
|
|
161
|
+
const met = valid_range(kwargs.met, [0.7, 2]);
|
|
162
|
+
const clo = valid_range(kwargs.clo, [0.0, 1]);
|
|
163
|
+
return { tdb, tr, v, rh, met, clo };
|
|
164
|
+
}
|
|
165
|
+
case "ISO": {
|
|
166
|
+
// based on ISO 7730:2005 page 3
|
|
167
|
+
const tdb = valid_range(kwargs.tdb, [10.0, 30.0]);
|
|
168
|
+
const tr = valid_range(kwargs.tr, [10.0, 40.0]);
|
|
169
|
+
const v = valid_range(kwargs.v, [0.0, 1.0]);
|
|
170
|
+
const met = valid_range(kwargs.met, [0.8, 4.0]);
|
|
171
|
+
const clo = valid_range(kwargs.clo, [0.0, 2]);
|
|
172
|
+
return { tdb, tr, v, met, clo };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @param {ComplianceKwargs} kwargs
|
|
178
|
+
*
|
|
179
|
+
* @returns {string[]} strings with warnings emitted
|
|
180
|
+
*/
|
|
181
|
+
function _ankle_draft_compliance(kwargs) {
|
|
182
|
+
/** @type {string[]} */
|
|
183
|
+
let warnings = [];
|
|
184
|
+
for (const [key, value] of Object.entries(kwargs)) {
|
|
185
|
+
if (value === undefined)
|
|
186
|
+
continue;
|
|
187
|
+
if (key === "met" && value > 1.3)
|
|
188
|
+
warnings.push("The ankle draft model is only valid for met <= 1.3");
|
|
189
|
+
if (key === "clo" && value > 0.7)
|
|
190
|
+
warnings.push("The ankle draft model is only valid for clo <= 0.7");
|
|
191
|
+
}
|
|
192
|
+
return warnings;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @param {ComplianceKwargs} kwargs
|
|
196
|
+
*
|
|
197
|
+
* @returns {string[]} strings with warnings emitted
|
|
198
|
+
*/
|
|
199
|
+
function _ashrae_compliance(kwargs) {
|
|
200
|
+
/** @type {string[]} */
|
|
201
|
+
let warnings = [];
|
|
202
|
+
for (const [key, value] of Object.entries(kwargs)) {
|
|
203
|
+
if (value === undefined)
|
|
204
|
+
continue;
|
|
205
|
+
switch (key) {
|
|
206
|
+
case "tdb":
|
|
207
|
+
case "tr":
|
|
208
|
+
let parameter = key === "tdb" ? "dry-bulb" : "mean radiant";
|
|
209
|
+
if (value > 40 || value < 10)
|
|
210
|
+
warnings.push(`ASHRAE ${parameter} temperature application limits between 10 and 40 ºC`);
|
|
211
|
+
break;
|
|
212
|
+
case "v":
|
|
213
|
+
case "vr":
|
|
214
|
+
if (value > 2 || value < 0)
|
|
215
|
+
warnings.push("ASHRAE air speed applicability limits between 0 and 2 m/s");
|
|
216
|
+
break;
|
|
217
|
+
case "met":
|
|
218
|
+
if (value > 4 || value < 1)
|
|
219
|
+
warnings.push("ASHRAE met applicability limits between 1.0 and 4.0 met");
|
|
220
|
+
break;
|
|
221
|
+
case "clo":
|
|
222
|
+
if (value > 1.5 || value < 0)
|
|
223
|
+
warnings.push("ASHRAE clo applicability limits between 0.0 and 1.5 clo");
|
|
224
|
+
break;
|
|
225
|
+
case "v_limited":
|
|
226
|
+
if (value > 0.2)
|
|
227
|
+
throw new Error("This equation is only applicable for air speed lower than 0.2 m/s");
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return warnings;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @param {ComplianceKwargs} kwargs
|
|
235
|
+
*
|
|
236
|
+
* @returns {string[]} strings with warnings emitted
|
|
237
|
+
*/
|
|
238
|
+
function _iso_compliance(kwargs) {
|
|
239
|
+
/** @type {string[]} */
|
|
240
|
+
let warnings = [];
|
|
241
|
+
for (const [key, value] of Object.entries(kwargs)) {
|
|
242
|
+
if (value === undefined)
|
|
243
|
+
continue;
|
|
244
|
+
if (key === "tdb" && (value > 30 || value < 10))
|
|
245
|
+
warnings.push("ISO air temperature applicability limits between 10 and 30 ºC");
|
|
246
|
+
if (key === "tr" && (value > 40 || value < 10))
|
|
247
|
+
warnings.push("ISO mean radiant temperature applicability limits between 10 and 40 ºC");
|
|
248
|
+
if (key === "v" || (key === "vr" && (value > 1 || value < 0)))
|
|
249
|
+
warnings.push("ISO air speed applicability limits between 0 and 1 m/s");
|
|
250
|
+
if (key === "met" && (value > 4 || value < 0))
|
|
251
|
+
warnings.push("ISO met applicability limits between 0.8 and 4.0 met");
|
|
252
|
+
if (key === "clo" && (value > 2 || value < 0))
|
|
253
|
+
warnings.push("ISO clo applicability limits between 0.0 and 2 clo");
|
|
254
|
+
}
|
|
255
|
+
return warnings;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @param {ComplianceKwargs} kwargs
|
|
259
|
+
*
|
|
260
|
+
* @returns {string[]} strings with warnings emitted
|
|
261
|
+
*/
|
|
262
|
+
function _iso7933_compliance(kwargs) {
|
|
263
|
+
if (kwargs.tdb === undefined ||
|
|
264
|
+
kwargs.rh === undefined ||
|
|
265
|
+
kwargs.tr === undefined ||
|
|
266
|
+
kwargs.v === undefined ||
|
|
267
|
+
kwargs.met === undefined ||
|
|
268
|
+
kwargs.clo === undefined) {
|
|
269
|
+
throw new Error(`Missing arguments for ISO7933 compliance check, got: ${kwargs} and requires tdb, rh, tr, v, met and clo`);
|
|
270
|
+
}
|
|
271
|
+
/** @type {string[]} */
|
|
272
|
+
let warnings = [];
|
|
273
|
+
if (kwargs.tdb > 50 || kwargs.tdb < 15)
|
|
274
|
+
warnings.push("ISO 7933:2004 air temperature applicability limits between 15 and 50 ºC");
|
|
275
|
+
const p_sat_result = p_sat(kwargs.tdb);
|
|
276
|
+
const p_a = ((p_sat_result / 1000) * kwargs.rh) / 100;
|
|
277
|
+
const rh_max = (4.5 * 100 * 1000) / p_sat_result;
|
|
278
|
+
if (p_a > rh_max || p_a < 0)
|
|
279
|
+
warnings.push(`ISO 7933:2004 rh applicability limits between 0 and ${rh_max} %`);
|
|
280
|
+
if (kwargs.tr - kwargs.tdb > 60 || kwargs.tr - kwargs.tdb < 0)
|
|
281
|
+
warnings.push("ISO 7933:2004 t_r - t_db applicability limits between 0 and 60 ºC");
|
|
282
|
+
if (kwargs.v > 3 || kwargs.v < 0)
|
|
283
|
+
warnings.push("ISO 7933:2004 air speed applicability limits between 0 and 3 m/s");
|
|
284
|
+
if (kwargs.met > 450 || kwargs.met < 100)
|
|
285
|
+
warnings.push("ISO 7933:2004 met applicability limits between 100 and 450 met");
|
|
286
|
+
if (kwargs.clo > 1 || kwargs.clo < 0.1)
|
|
287
|
+
warnings.push("ISO 7933:2004 clo applicability limits between 0.1 and 1 clo");
|
|
288
|
+
return warnings;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Returns the body surface area in square meters
|
|
292
|
+
*
|
|
293
|
+
* @public
|
|
294
|
+
* @memberof utilities
|
|
295
|
+
* @docname Body Surface Area
|
|
296
|
+
*
|
|
297
|
+
* @param {number} weight - body weight, [kg]
|
|
298
|
+
* @param {number} height - height, [m]
|
|
299
|
+
* @param {("dubois" | "takahira" | "fujimoto" | "kurazumi")} [formula="dubois"] - formula used to calculate the body surface area. default="dubois"
|
|
300
|
+
* @returns {number} body surface area, [m2]
|
|
301
|
+
*
|
|
302
|
+
* @category Utilities
|
|
303
|
+
*/
|
|
304
|
+
export function body_surface_area(weight, height, formula = "dubois") {
|
|
305
|
+
if (formula === "dubois")
|
|
306
|
+
return 0.202 * Math.pow(weight, 0.425) * Math.pow(height, 0.725);
|
|
307
|
+
if (formula === "takahira")
|
|
308
|
+
return 0.2042 * Math.pow(weight, 0.425) * Math.pow(height, 0.725);
|
|
309
|
+
if (formula === "fujimoto")
|
|
310
|
+
return 0.1882 * Math.pow(weight, 0.444) * Math.pow(height, 0.663);
|
|
311
|
+
if (formula === "kurazumi")
|
|
312
|
+
return 0.244 * Math.pow(weight, 0.383) * Math.pow(height, 0.693);
|
|
313
|
+
throw new Error(`This ${formula} to calculate the body_surface_area does not exists.`);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Estimates the relative air speed which combines the average air speed of the
|
|
317
|
+
* space plus the relative air speed caused by the body movement. Vag is assumed
|
|
318
|
+
* to be 0 for metabolic rates equal and lower than 1 met and otherwise equal to
|
|
319
|
+
* Vag = 0.3 (M - 1) (m/s)
|
|
320
|
+
*
|
|
321
|
+
* @public
|
|
322
|
+
* @memberof utilities
|
|
323
|
+
* @docname Relative air speed
|
|
324
|
+
*
|
|
325
|
+
* @see {@link v_relative_array} for a version that supports array arguments
|
|
326
|
+
*
|
|
327
|
+
* @param {number} v - air spped measured by the sensor, [m/s]
|
|
328
|
+
* @param {number} met - metabolic rate, [met]
|
|
329
|
+
* @returns {number} relative air speed, [m/s]
|
|
330
|
+
*/
|
|
331
|
+
export function v_relative(v, met) {
|
|
332
|
+
if (met <= 1)
|
|
333
|
+
return v;
|
|
334
|
+
return _v_relative_single(v, met);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Estimates the relative air speed which combines the average air speed of the
|
|
338
|
+
* space plus the relative air speed caused by the body movement. Vag is assumed
|
|
339
|
+
* to be 0 for metabolic rates equal and lower than 1 met and otherwise equal to
|
|
340
|
+
* Vag = 0.3 (M - 1) (m/s)
|
|
341
|
+
*
|
|
342
|
+
* @public
|
|
343
|
+
* @memberof utilities
|
|
344
|
+
* @docname Relative air speed (array version)
|
|
345
|
+
*
|
|
346
|
+
* @see {@link v_relative} for a version that supports scalar arguments
|
|
347
|
+
*
|
|
348
|
+
* @param {number[]} v - air spped measured by the sensor, [m/s]
|
|
349
|
+
* @param {number[]} met - metabolic rate, [met]
|
|
350
|
+
* @returns {number[]} relative air speed, [m/s]
|
|
351
|
+
*/
|
|
352
|
+
export function v_relative_array(v, met) {
|
|
353
|
+
if (met <= 1)
|
|
354
|
+
return v;
|
|
355
|
+
return v.map((_v, index) => _v_relative_single(_v, met[index]));
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* @param {number} v
|
|
359
|
+
* @param {number} met
|
|
360
|
+
* @returns {number}
|
|
361
|
+
*/
|
|
362
|
+
function _v_relative_single(v, met) {
|
|
363
|
+
return Math.round((v + 0.3 * (met - 1) + Number.EPSILON) * 1000) / 1000;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Estimates the dynamic clothing insulation of a moving occupant. The activity as
|
|
367
|
+
* well as the air speed modify the insulation characteristics of the clothing and the
|
|
368
|
+
* adjacent air layer. Consequently, the ISO 7730 states that the clothing insulation
|
|
369
|
+
* shall be corrected {@link #ref_2|[2]}. The ASHRAE 55 Standard corrects for the effect
|
|
370
|
+
* of the body movement for met equal or higher than 1.2 met using the equation
|
|
371
|
+
* clo = Icl × (0.6 + 0.4/met)
|
|
372
|
+
*
|
|
373
|
+
* @public
|
|
374
|
+
* @memberof utilities
|
|
375
|
+
* @docname Dynamic clothing
|
|
376
|
+
*
|
|
377
|
+
* @see {@link clo_dynamic_array} for a version that supports array arguments
|
|
378
|
+
*
|
|
379
|
+
* @param {number} clo - clothing insulation, [clo]
|
|
380
|
+
* @param {number} met - metabolic rate, [met]
|
|
381
|
+
* @param {("ASHRAE" | "ISO")} [standard="ASHRAE"] - If "ASHRAE", uses Equation provided in Section 5.2.2.2 of ASHRAE 55 2020
|
|
382
|
+
* @returns {number} dunamic clothing insulation, [clo]
|
|
383
|
+
*/
|
|
384
|
+
export function clo_dynamic(clo, met, standard = "ASHRAE") {
|
|
385
|
+
if (standard !== "ASHRAE" && standard !== "ISO")
|
|
386
|
+
throw new Error("only the ISO 7730 and ASHRAE 55 2020 models have been implemented");
|
|
387
|
+
if ((standard === "ASHRAE" && met <= 1.2) || (standard === "ISO" && met <= 1))
|
|
388
|
+
return clo;
|
|
389
|
+
return _clo_dynamic_single(clo, met);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Estimates the dynamic clothing insulation of a moving occupant. The activity as
|
|
393
|
+
* well as the air speed modify the insulation characteristics of the clothing and the
|
|
394
|
+
* adjacent air layer. Consequently, the ISO 7730 states that the clothing insulation
|
|
395
|
+
* shall be corrected {@link #ref_2|[2]}. The ASHRAE 55 Standard corrects for the effect
|
|
396
|
+
* of the body movement for met equal or higher than 1.2 met using the equation
|
|
397
|
+
* clo = Icl × (0.6 + 0.4/met)
|
|
398
|
+
*
|
|
399
|
+
* @public
|
|
400
|
+
* @memberof utilities
|
|
401
|
+
* @docname Dynamic clothing (array version)
|
|
402
|
+
*
|
|
403
|
+
* @see {@link clo_dynamic} for a version that supports scalar arguments
|
|
404
|
+
*
|
|
405
|
+
* @param {number[]} clo - clothing insulation, [clo]
|
|
406
|
+
* @param {number[]} met - metabolic rate, [met]
|
|
407
|
+
* @param {("ASHRAE" | "ISO")} [standard="ASHRAE"] - If "ASHRAE", uses Equation provided in Section 5.2.2.2 of ASHRAE 55 2020
|
|
408
|
+
* @returns {number[]} dunamic clothing insulation, [clo]
|
|
409
|
+
*/
|
|
410
|
+
export function clo_dynamic_array(clo, met, standard = "ASHRAE") {
|
|
411
|
+
if (standard === "ASHRAE")
|
|
412
|
+
return met.map((_met, index) => _met > 1.2 ? _clo_dynamic_single(clo[index], _met) : clo[index]);
|
|
413
|
+
if (standard === "ISO")
|
|
414
|
+
return met.map((_met, index) => _met > 1 ? _clo_dynamic_single(clo[index], _met) : clo[index]);
|
|
415
|
+
throw new Error("only the ISO 7730 and ASHRAE 55 2020 models have been implemented");
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* @param {number} clo
|
|
419
|
+
* @param {number} met
|
|
420
|
+
* @returns {number}
|
|
421
|
+
*/
|
|
422
|
+
function _clo_dynamic_single(clo, met) {
|
|
423
|
+
return Math.round((clo * (0.6 + 0.4 / met) + Number.EPSILON) * 1000) / 1000;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Converts IP values to SI units
|
|
427
|
+
*
|
|
428
|
+
* @memberof utilities
|
|
429
|
+
* @docname Units converter
|
|
430
|
+
* @public
|
|
431
|
+
*
|
|
432
|
+
* @template {Object.<string, number>} T
|
|
433
|
+
* @param {T} kwargs - [t, v] units to convert
|
|
434
|
+
* @param {"IP" | "SI"} [from_units="IP"] - specify system to convert from
|
|
435
|
+
* @returns {T} converted values in SI units
|
|
436
|
+
*
|
|
437
|
+
* @see {@link units_converter_array} for a version that supports array parameters
|
|
438
|
+
*/
|
|
439
|
+
export function units_converter(kwargs, from_units = "IP") {
|
|
440
|
+
let result = { ...kwargs };
|
|
441
|
+
if (from_units === "IP") {
|
|
442
|
+
for (const [key, value] of Object.entries(result)) {
|
|
443
|
+
if (key.includes("tmp") || key === "tr" || key === "tdb")
|
|
444
|
+
result[key] = _temp_ip_to_si(value);
|
|
445
|
+
else if (key === "v" || key === "vr" || key === "vel")
|
|
446
|
+
result[key] = _vel_ip_to_si(value);
|
|
447
|
+
else if (key === "area")
|
|
448
|
+
result[key] = _area_ip_to_si(value);
|
|
449
|
+
else if (key === "pressure")
|
|
450
|
+
result[key] = _pressure_ip_to_si(value);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
else if (from_units === "SI") {
|
|
454
|
+
for (const [key, value] of Object.entries(result)) {
|
|
455
|
+
if (key.includes("tmp") || key === "tr" || key === "tdb")
|
|
456
|
+
result[key] = _temp_si_to_ip(value);
|
|
457
|
+
else if (key === "v" || key === "vr" || key === "vel")
|
|
458
|
+
result[key] = _vel_si_to_ip(value);
|
|
459
|
+
else if (key === "area")
|
|
460
|
+
result[key] = _area_si_to_ip(value);
|
|
461
|
+
else if (key === "pressure")
|
|
462
|
+
result[key] = _pressure_si_to_ip(value);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
throw new Error(`Unknown system ${from_units}`);
|
|
467
|
+
}
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Converts IP values to SI units
|
|
472
|
+
*
|
|
473
|
+
* @memberof utilities
|
|
474
|
+
* @docname Units converter (array version)
|
|
475
|
+
* @public
|
|
476
|
+
*
|
|
477
|
+
* @template {Object.<string, number[]>} T
|
|
478
|
+
* @param {T} kwargs - [t, v] units to convert
|
|
479
|
+
* @param {"IP" | "SI"} [from_units="IP"] - specify system to convert from
|
|
480
|
+
* @returns {T} converted values in SI units
|
|
481
|
+
*
|
|
482
|
+
* @see {@link units_converter} for a version that supports scalar parameters
|
|
483
|
+
*/
|
|
484
|
+
export function units_converter_array(kwargs, from_units = "IP") {
|
|
485
|
+
let result = {};
|
|
486
|
+
if (from_units === "IP") {
|
|
487
|
+
for (const [key, value] of Object.entries(kwargs)) {
|
|
488
|
+
if (key.includes("tmp") || key === "tr" || key === "tdb")
|
|
489
|
+
result[key] = value.map(_temp_ip_to_si);
|
|
490
|
+
else if (key === "v" || key === "vr" || key === "vel")
|
|
491
|
+
result[key] = value.map(_vel_ip_to_si);
|
|
492
|
+
else if (key === "area")
|
|
493
|
+
result[key] = value.map(_area_ip_to_si);
|
|
494
|
+
else if (key === "pressure")
|
|
495
|
+
result[key] = value.map(_pressure_ip_to_si);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else if (from_units === "SI") {
|
|
499
|
+
for (const [key, value] of Object.entries(kwargs)) {
|
|
500
|
+
if (key.includes("tmp") || key === "tr" || key === "tdb")
|
|
501
|
+
result[key] = value.map(_temp_si_to_ip);
|
|
502
|
+
else if (key === "v" || key === "vr" || key === "vel")
|
|
503
|
+
result[key] = value.map(_vel_si_to_ip);
|
|
504
|
+
else if (key === "area")
|
|
505
|
+
result[key] = value.map(_area_si_to_ip);
|
|
506
|
+
else if (key === "pressure")
|
|
507
|
+
result[key] = value.map(_pressure_si_to_ip);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
throw new Error(`Unknown system ${from_units}`);
|
|
512
|
+
}
|
|
513
|
+
return result;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* @param {number} pressure
|
|
517
|
+
* @returns {number}
|
|
518
|
+
*/
|
|
519
|
+
function _pressure_ip_to_si(pressure) {
|
|
520
|
+
return pressure * 101325;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* @param {number} pressure
|
|
524
|
+
* @returns {number}
|
|
525
|
+
*/
|
|
526
|
+
function _pressure_si_to_ip(pressure) {
|
|
527
|
+
return pressure / 101325;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* @param {number} area
|
|
531
|
+
* @returns {number}
|
|
532
|
+
*/
|
|
533
|
+
function _area_ip_to_si(area) {
|
|
534
|
+
return area / 10.764;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* @param {number} area
|
|
538
|
+
* @returns {number}
|
|
539
|
+
*/
|
|
540
|
+
function _area_si_to_ip(area) {
|
|
541
|
+
return area * 10.764;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* @param {number} vel
|
|
545
|
+
* @returns {number}
|
|
546
|
+
*/
|
|
547
|
+
function _vel_ip_to_si(vel) {
|
|
548
|
+
return vel / 3.281;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* @param {number} vel
|
|
552
|
+
* @returns {number}
|
|
553
|
+
*/
|
|
554
|
+
function _vel_si_to_ip(vel) {
|
|
555
|
+
return vel * 3.281;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* @param {number} temp
|
|
559
|
+
* @returns {number}
|
|
560
|
+
*/
|
|
561
|
+
function _temp_ip_to_si(temp) {
|
|
562
|
+
return ((temp - 32) * 5) / 9;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* @param {number} temp
|
|
566
|
+
* @returns {number}
|
|
567
|
+
*/
|
|
568
|
+
function _temp_si_to_ip(temp) {
|
|
569
|
+
return (temp * 9) / 5 + 32;
|
|
570
|
+
}
|
|
571
|
+
// FIXME: find how to write math notation inside JSDocs
|
|
572
|
+
/**
|
|
573
|
+
* Estimates the running mean temperature also known as prevailing mean outdoor temperature
|
|
574
|
+
*
|
|
575
|
+
* @public
|
|
576
|
+
* @memberof utilities
|
|
577
|
+
* @docname Running mean outdoor temperature
|
|
578
|
+
*
|
|
579
|
+
* @param {number[]} temp_array - array containing the mean daily temperature in descending order (i.e. from
|
|
580
|
+
* newest/yestedayr to oldest) :math:`[t_{day-1}, t_{day-2}, ... , t_{day-n}]`,
|
|
581
|
+
* Where :math:`t_{day-1}` is yesterday's daily mean temperature. The EN
|
|
582
|
+
* 16798-1 2019 {@link #ref_3|[3]} states that n should be equal to 7
|
|
583
|
+
*
|
|
584
|
+
* @param {number} [alpha=0.8] - constant between 0 and 1. The EN 16798-1 2019 {@link #ref_3|[3]} recommends a value of 0.8,
|
|
585
|
+
* while the ASHRAE 55 2020 recommends to choose values between 0.9 and 0.6,
|
|
586
|
+
* corresponding to a slow- and fast- response running mean, respectively.
|
|
587
|
+
* Adaptive comfort theory suggest that a slow-response running mean (alpha = 0.9)
|
|
588
|
+
* could be more appropriate for climates in which synoptic-scale (day-to-day)
|
|
589
|
+
* temperature dynamics are relatively minor, sich as the humid tropics.
|
|
590
|
+
*
|
|
591
|
+
* @param {"IP" | "SI"} [units="SI"] - select the SI (International System of Units) or the IP (Imperial Units) system.
|
|
592
|
+
*
|
|
593
|
+
* @returns {number} running mean outdoor temperature
|
|
594
|
+
*/
|
|
595
|
+
export function running_mean_outdoor_temperature(temp_array, alpha = 0.8, units = "SI") {
|
|
596
|
+
if (units === "IP")
|
|
597
|
+
temp_array = temp_array.map((tdb) => units_converter({ tdb }).tdb);
|
|
598
|
+
let coeff = temp_array.map((_tdb, index) => Math.pow(alpha, index));
|
|
599
|
+
let summ_t_rm = temp_array.reduce((acum, curr, index) => acum + curr * coeff[index]);
|
|
600
|
+
let summ_coeff = coeff.reduce((acum, curr) => acum + curr);
|
|
601
|
+
let t_rm = summ_t_rm / summ_coeff;
|
|
602
|
+
if (units === "IP")
|
|
603
|
+
t_rm = units_converter({ tmp: t_rm }, "SI").tmp;
|
|
604
|
+
return Math.round(t_rm * 10 + Number.EPSILON) / 10;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Calculates the sky-vault view fraction
|
|
608
|
+
*
|
|
609
|
+
* @public
|
|
610
|
+
* @memberof utilities
|
|
611
|
+
* @docname Sky-vault view fraction
|
|
612
|
+
*
|
|
613
|
+
* @param {number} w - width of the window, [m]
|
|
614
|
+
* @param {number} h - height of the window, [m]
|
|
615
|
+
* @param {number} d - distance between the occupant and the window, [m]
|
|
616
|
+
*
|
|
617
|
+
* @returns {number} sky-vault view faction ranges between 0 and 1
|
|
618
|
+
*/
|
|
619
|
+
export function f_svv(w, h, d) {
|
|
620
|
+
let h_degrees = Math.atan(h / (2 * d)) * (180 / Math.PI);
|
|
621
|
+
let w_degrees = Math.atan(w / (2 * d)) * (180 / Math.PI);
|
|
622
|
+
return (h_degrees * w_degrees) / 16200;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Filter values based on a valid range (It turns the filtered values to NaNs)
|
|
626
|
+
*
|
|
627
|
+
* @param {number[]} [range] - the range to limit
|
|
628
|
+
* @param {[number, number]} valid - the [min, max] to constrian the range to
|
|
629
|
+
* @returns {number[]} the constrained range with NaNs for values that are outside the min, max range
|
|
630
|
+
*/
|
|
631
|
+
export function valid_range(range, [min, max]) {
|
|
632
|
+
if (range === undefined)
|
|
633
|
+
return [];
|
|
634
|
+
return range.map((n) => (n >= min && n <= max ? n : NaN));
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Met values of typical tasks.
|
|
638
|
+
* @public
|
|
639
|
+
* @memberof reference_values
|
|
640
|
+
* @docname Met typical tasks, [met]
|
|
641
|
+
* @constant
|
|
642
|
+
* @type {Object}
|
|
643
|
+
* @property {number} Sleeping - 0.7
|
|
644
|
+
* @property {number} Reclining - 0.8
|
|
645
|
+
* @property {number} Seated_Cquiet - 1.0
|
|
646
|
+
* @property {number} Reading_seated - 1.0
|
|
647
|
+
* @property {number} Writing - 1.0
|
|
648
|
+
* @property {number} Reading_seatedTyping - 1.1
|
|
649
|
+
* @property {number} Standing_relaxed - 1.2
|
|
650
|
+
* @property {number} Filing_seated - 1.2
|
|
651
|
+
* @property {number} Flying_aircraft_routine - 1.2
|
|
652
|
+
* @property {number} Filing_standing - 1.4
|
|
653
|
+
* @property {number} Driving_a_car - 1.5
|
|
654
|
+
* @property {number} Walking_about - 1.7
|
|
655
|
+
* @property {number} Cooking - 1.8
|
|
656
|
+
* @property {number} Table_sawing - 1.8
|
|
657
|
+
* @property {number} Walking_2mph_3_2kmh - 2.0
|
|
658
|
+
* @property {number} Lifting_packing - 2.1
|
|
659
|
+
* @property {number} Seated_heavy_limb_movement - 2.2
|
|
660
|
+
* @property {number} Light_machine_work - 2.2
|
|
661
|
+
* @property {number} Flying_aircraft_combat - 2.4
|
|
662
|
+
* @property {number} Walking_3mph_4_8kmh - 2.6
|
|
663
|
+
* @property {number} House_cleaning - 2.7
|
|
664
|
+
* @property {number} Driving_heavy_vehicle - 3.2
|
|
665
|
+
* @property {number} Dancing - 3.4
|
|
666
|
+
* @property {number} Calisthenics - 3.5
|
|
667
|
+
* @property {number} Walking_4mph_6_4kmh - 3.8
|
|
668
|
+
* @property {number} Tennis - 3.8
|
|
669
|
+
* @property {number} Heavy_machine_work - 4.0
|
|
670
|
+
* @property {number} Handling_100lb_45_kg_bags - 4.0
|
|
671
|
+
* @property {number} Pick_and_shovel_work - 4.4
|
|
672
|
+
* @property {number} Basketball - 6.3
|
|
673
|
+
* @property {number} Wrestling - 7.8
|
|
674
|
+
* @example
|
|
675
|
+
* import { met_typical_tasks } from "jsthermalcomfort/utilities"; //The path to utilities
|
|
676
|
+
* console.log(met_typical_tasks['Seated_Cquiet']);
|
|
677
|
+
* // output 1.0
|
|
678
|
+
*/
|
|
679
|
+
export const met_typical_tasks = {
|
|
680
|
+
Sleeping: 0.7,
|
|
681
|
+
Reclining: 0.8,
|
|
682
|
+
Seated_Cquiet: 1.0,
|
|
683
|
+
Reading_seated: 1.0,
|
|
684
|
+
Writing: 1.0,
|
|
685
|
+
Typing: 1.1,
|
|
686
|
+
Standing_relaxed: 1.2,
|
|
687
|
+
Filing_seated: 1.2,
|
|
688
|
+
Flying_aircraft_routine: 1.2,
|
|
689
|
+
Filing_standing: 1.4,
|
|
690
|
+
Driving_a_car: 1.5,
|
|
691
|
+
Walking_about: 1.7,
|
|
692
|
+
Cooking: 1.8,
|
|
693
|
+
Table_sawing: 1.8,
|
|
694
|
+
Walking_2mph_3_2kmh: 2.0,
|
|
695
|
+
Lifting_packing: 2.1,
|
|
696
|
+
Seated_heavy_limb_movement: 2.2,
|
|
697
|
+
Light_machine_work: 2.2,
|
|
698
|
+
Flying_aircraft_combat: 2.4,
|
|
699
|
+
Walking_3mph_4_8kmh: 2.6,
|
|
700
|
+
House_cleaning: 2.7,
|
|
701
|
+
Driving_heavy_vehicle: 3.2,
|
|
702
|
+
Dancing: 3.4,
|
|
703
|
+
Calisthenics: 3.5,
|
|
704
|
+
Walking_4mph_6_4kmh: 3.8,
|
|
705
|
+
Tennis: 3.8,
|
|
706
|
+
Heavy_machine_work: 4.0,
|
|
707
|
+
Handling_100lb_45_kg_bags: 4.0,
|
|
708
|
+
Pick_and_shovel_work: 4.4,
|
|
709
|
+
Basketball: 6.3,
|
|
710
|
+
Wrestling: 7.8,
|
|
711
|
+
};
|
|
712
|
+
/**
|
|
713
|
+
* Total Clothing insulation of typical ensembles
|
|
714
|
+
* @public
|
|
715
|
+
* @memberof reference_values
|
|
716
|
+
* @docname Typical ensembles insulation, [clo]
|
|
717
|
+
*
|
|
718
|
+
* @param {"Walking shorts, short-sleeve shirt" | "Typical summer indoor clothing" |
|
|
719
|
+
* "Knee-length skirt, short-sleeve shirt, sandals, underwear" | "Trousers, long-sleeve shirt" |
|
|
720
|
+
* "Knee-length skirt, long-sleeve shirt, full slip" | "Sweat pants, long-sleeve sweatshirt" |
|
|
721
|
+
* "Jacket, Trousers, long-sleeve shirt" | "Typical winter indoor clothing"} ensembles - Typical ensembles. One of:
|
|
722
|
+
* - "Walking shorts, short-sleeve shirt"
|
|
723
|
+
* - "Typical summer indoor clothing"
|
|
724
|
+
* - "Knee-length skirt, short-sleeve shirt, sandals, underwear"
|
|
725
|
+
* - "Trousers, short-sleeve shirt, socks, shoes, underwear"
|
|
726
|
+
* - "Trousers, long-sleeve shirt"
|
|
727
|
+
* - "Knee-length skirt, long-sleeve shirt, full slip"
|
|
728
|
+
* - "Sweat pants, long-sleeve sweatshirt"
|
|
729
|
+
* - "Jacket, Trousers, long-sleeve shirt"
|
|
730
|
+
* - "Typical winter indoor clothing"
|
|
731
|
+
*
|
|
732
|
+
* @returns {number} - Clothing insulation of the given ensembles
|
|
733
|
+
* @example
|
|
734
|
+
* const result = clo_typical_ensembles("Trousers, long-sleeve shirt"); // returns 0.61
|
|
735
|
+
*/
|
|
736
|
+
export function clo_typical_ensembles(ensembles) {
|
|
737
|
+
switch (ensembles) {
|
|
738
|
+
case "Walking shorts, short-sleeve shirt":
|
|
739
|
+
return 0.36;
|
|
740
|
+
case "Typical summer indoor clothing":
|
|
741
|
+
return 0.5;
|
|
742
|
+
case "Knee-length skirt, short-sleeve shirt, sandals, underwear":
|
|
743
|
+
return 0.54;
|
|
744
|
+
case "Trousers, short-sleeve shirt, socks, shoes, underwear":
|
|
745
|
+
return 0.57;
|
|
746
|
+
case "Trousers, long-sleeve shirt":
|
|
747
|
+
return 0.61;
|
|
748
|
+
case "Knee-length skirt, long-sleeve shirt, full slip":
|
|
749
|
+
return 0.67;
|
|
750
|
+
case "Sweat pants, long-sleeve sweatshirt":
|
|
751
|
+
return 0.74;
|
|
752
|
+
case "Jacket, Trousers, long-sleeve shirt":
|
|
753
|
+
return 0.96;
|
|
754
|
+
case "Typical winter indoor clothing":
|
|
755
|
+
return 1.0;
|
|
756
|
+
default:
|
|
757
|
+
throw new Error("No such ensemble");
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Clo values of individual clothing elements. To calculate the total clothing insulation you need to add these values together.
|
|
762
|
+
* @public
|
|
763
|
+
* @memberof reference_values
|
|
764
|
+
* @docname Insulation of individual garments, [clo]
|
|
765
|
+
* @constant
|
|
766
|
+
* @type {Object}
|
|
767
|
+
* @property {number} Metal_chair - 0.0
|
|
768
|
+
* @property {number} Bra - 0.01
|
|
769
|
+
* @property {number} Wooden_stool - 0.01
|
|
770
|
+
* @property {number} Ankle_socks - 0.02
|
|
771
|
+
* @property {number} Shoes_or_sandals - 0.02
|
|
772
|
+
* @property {number} Slippers - 0.03
|
|
773
|
+
* @property {number} Panty_hose - 0.02
|
|
774
|
+
* @property {number} Calf_length_socks - 0.03
|
|
775
|
+
* @property {number} Women_underwear - 0.03
|
|
776
|
+
* @property {number} Men_underwear - 0.04
|
|
777
|
+
* @property {number} Knee_socks_thick - 0.06
|
|
778
|
+
* @property {number} Short_shorts - 0.06
|
|
779
|
+
* @property {number} Walking_shorts: 0.08,
|
|
780
|
+
* @property {number} T_shirt - 0.08
|
|
781
|
+
* @property {number} Standard_office_chair - 0.1
|
|
782
|
+
* @property {number} Executive_chair - 0.15
|
|
783
|
+
* @property {number} Boots - 0.1
|
|
784
|
+
* @property {number} Sleeveless_scoop_neck_blouse - 0.12
|
|
785
|
+
* @property {number} Half_slip - 0.14
|
|
786
|
+
* @property {number} Long_underwear_bottoms - 0.15
|
|
787
|
+
* @property {number} Full_slip - 0.16
|
|
788
|
+
* @property {number} Short_sleeve_knit_shirt - 0.17
|
|
789
|
+
* @property {number} Sleeveless_vest_thin - 0.1
|
|
790
|
+
* @property {number} Sleeveless_vest_thick - 0.17
|
|
791
|
+
* @property {number} Sleeveless_short_gown_thin - 0.18
|
|
792
|
+
* @property {number} Short_sleeve_dress_shirt - 0.19
|
|
793
|
+
* @property {number} Sleeveless_long_gown_thin - 0.2
|
|
794
|
+
* @property {number} Long_underwear_top - 0.2
|
|
795
|
+
* @property {number} Thick_skirt - 0.23
|
|
796
|
+
* @property {number} Long_sleeve_dress_shirt - 0.25
|
|
797
|
+
* @property {number} Long_sleeve_flannel_shirt - 0.34
|
|
798
|
+
* @property {number} Long_sleeve_sweat_shirt - 0.34
|
|
799
|
+
* @property {number} Short_sleeve_hospital_gown - 0.31
|
|
800
|
+
* @property {number} Short_sleeve_short_robe_thin - 0.34
|
|
801
|
+
* @property {number} Short_sleeve_pajamas - 0.42
|
|
802
|
+
* @property {number} Long_sleeve_long_gown - 0.46
|
|
803
|
+
* @property {number} Long_sleeve_short_wrap_robe_thick - 0.48
|
|
804
|
+
* @property {number} Long_sleeve_pajamas_thick - 0.57
|
|
805
|
+
* @property {number} Long_sleeve_long_wrap_robe_thick - 0.69
|
|
806
|
+
* @property {number} Thin_trousers - 0.15
|
|
807
|
+
* @property {number} Thick_trousers - 0.24
|
|
808
|
+
* @property {number} Sweatpants - 0.28
|
|
809
|
+
* @property {number} Overalls - 0.3
|
|
810
|
+
* @property {number} Coveralls - 0.49
|
|
811
|
+
* @property {number} Thin_skirt - 0.14
|
|
812
|
+
* @property {number} Long_sleeve_shirt_dress_thin - 0.33
|
|
813
|
+
* @property {number} Long_sleeve_shirt_dress_thick - 0.47
|
|
814
|
+
* @property {number} Short_sleeve_shirt_dress - 0.29
|
|
815
|
+
* @property {number} Sleeveless_scoop_neck_shirt_thin - 0.23
|
|
816
|
+
* @property {number} Sleeveless_scoop_neck_shirt_thick - 0.27
|
|
817
|
+
* @property {number} Long_sleeve_shirt_thin - 0.25
|
|
818
|
+
* @property {number} Long_sleeve_shirt_thick - 0.36
|
|
819
|
+
* @property {number} Single_breasted_coat_thin - 0.36
|
|
820
|
+
* @property {number} Single_breasted_coat_thick - 0.44
|
|
821
|
+
* @property {number} Double_breasted_coat_thin - 0.42
|
|
822
|
+
* @property {number} Double_breasted_coat_thick - 0.48
|
|
823
|
+
* @example
|
|
824
|
+
* import { clo_individual_garments } from "jsthermalcomfort/utilities"; //The path to utilities
|
|
825
|
+
* console.log(clo_individual_garments['Metal_chair']);
|
|
826
|
+
* // output 0.0
|
|
827
|
+
*/
|
|
828
|
+
export const clo_individual_garments = {
|
|
829
|
+
Metal_chair: 0.0,
|
|
830
|
+
Bra: 0.01,
|
|
831
|
+
Wooden_stool: 0.01,
|
|
832
|
+
Ankle_socks: 0.02,
|
|
833
|
+
Shoes_or_sandals: 0.02,
|
|
834
|
+
Slippers: 0.03,
|
|
835
|
+
Panty_hose: 0.02,
|
|
836
|
+
Calf_length_socks: 0.03,
|
|
837
|
+
Women_underwear: 0.03,
|
|
838
|
+
Men_underwear: 0.04,
|
|
839
|
+
Knee_socks_thick: 0.06,
|
|
840
|
+
Short_shorts: 0.06,
|
|
841
|
+
Walking_shorts: 0.08,
|
|
842
|
+
T_shirt: 0.08,
|
|
843
|
+
Standard_office_chair: 0.1,
|
|
844
|
+
Executive_chair: 0.15,
|
|
845
|
+
Boots: 0.1,
|
|
846
|
+
Sleeveless_scoop_neck_blouse: 0.12,
|
|
847
|
+
Half_slip: 0.14,
|
|
848
|
+
Long_underwear_bottoms: 0.15,
|
|
849
|
+
Full_slip: 0.16,
|
|
850
|
+
Short_sleeve_knit_shirt: 0.17,
|
|
851
|
+
Sleeveless_vest_thin: 0.1,
|
|
852
|
+
Sleeveless_vest_thick: 0.17,
|
|
853
|
+
Sleeveless_short_gown_thin: 0.18,
|
|
854
|
+
Short_sleeve_dress_shirt: 0.19,
|
|
855
|
+
Sleeveless_long_gown_thin: 0.2,
|
|
856
|
+
Long_underwear_top: 0.2,
|
|
857
|
+
Thick_skirt: 0.23,
|
|
858
|
+
Long_sleeve_dress_shirt: 0.25,
|
|
859
|
+
Long_sleeve_flannel_shirt: 0.34,
|
|
860
|
+
Long_sleeve_sweat_shirt: 0.34,
|
|
861
|
+
Short_sleeve_hospital_gown: 0.31,
|
|
862
|
+
Short_sleeve_short_robe_thin: 0.34,
|
|
863
|
+
Short_sleeve_pajamas: 0.42,
|
|
864
|
+
Long_sleeve_long_gown: 0.46,
|
|
865
|
+
Long_sleeve_short_wrap_robe_thick: 0.48,
|
|
866
|
+
Long_sleeve_pajamas_thick: 0.57,
|
|
867
|
+
Long_sleeve_long_wrap_robe_thick: 0.69,
|
|
868
|
+
Thin_trousers: 0.15,
|
|
869
|
+
Thick_trousers: 0.24,
|
|
870
|
+
Sweatpants: 0.28,
|
|
871
|
+
Overalls: 0.3,
|
|
872
|
+
Coveralls: 0.49,
|
|
873
|
+
Thin_skirt: 0.14,
|
|
874
|
+
Long_sleeve_shirt_dress_thin: 0.33,
|
|
875
|
+
Long_sleeve_shirt_dress_thick: 0.47,
|
|
876
|
+
Short_sleeve_shirt_dress: 0.29,
|
|
877
|
+
Sleeveless_scoop_neck_shirt_thin: 0.23,
|
|
878
|
+
Sleeveless_scoop_neck_shirt_thick: 0.27,
|
|
879
|
+
Long_sleeve_shirt_thin: 0.25,
|
|
880
|
+
Long_sleeve_shirt_thick: 0.36,
|
|
881
|
+
Single_breasted_coat_thin: 0.36,
|
|
882
|
+
Single_breasted_coat_thick: 0.44,
|
|
883
|
+
Double_breasted_coat_thin: 0.42,
|
|
884
|
+
Double_breasted_coat_thick: 0.48,
|
|
885
|
+
};
|