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,443 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pet_steady = void 0;
|
|
4
|
+
const utilities_js_1 = require("../utilities/utilities.js");
|
|
5
|
+
const p_sat_js_1 = require("../psychrometrics/p_sat.js");
|
|
6
|
+
const utilities_js_2 = require("../utilities/utilities.js");
|
|
7
|
+
/**
|
|
8
|
+
* The steady physiological equivalent temperature (PET) is calculated using the Munich
|
|
9
|
+
* Energy-balance Model for Individuals (MEMI), which simulates the human body's thermal
|
|
10
|
+
* circumstances in a medically realistic manner. PET is defined as the air temperature
|
|
11
|
+
* at which, in a typical indoor setting the heat budget of the human body is balanced
|
|
12
|
+
* with the same core and skin temperature as under the complex outdoor conditions to be
|
|
13
|
+
* assessed {@link #ref_20|[20]}.
|
|
14
|
+
*
|
|
15
|
+
* The following assumptions are made for the indoor reference climate: tdb = tr, v = 0.1
|
|
16
|
+
* m/s, water vapour pressure = 12 hPa, clo = 0.9 clo, and met = 1.37 met + basic
|
|
17
|
+
* metabolism.
|
|
18
|
+
*
|
|
19
|
+
* PET allows a layperson to compare the total effects of complex thermal circumstances
|
|
20
|
+
* outside with his or her own personal experience indoors in this way. This function
|
|
21
|
+
* solves the heat balances without accounting for heat storage in the human body.
|
|
22
|
+
*
|
|
23
|
+
* The PET was originally proposed by Hoppe {@link #ref_20|[20]}. In 2018, Walther and Goestchel {@link #ref_21|[21]}
|
|
24
|
+
* proposed a correction of the original model, purging the errors in the
|
|
25
|
+
* PET calculation routine, and implementing a state-of-the-art vapour diffusion model.
|
|
26
|
+
* Walther and Goestchel (2018) model is therefore used to calculate the PET.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
* @memberof models
|
|
30
|
+
* @docname Physiological Equivalent Temperature (PET)
|
|
31
|
+
*
|
|
32
|
+
* @param {number} tdb - dry bulb air temperature, [°C]
|
|
33
|
+
* @param {number} tr - mean radiant temperature, [°C]
|
|
34
|
+
* @param {number} v - air speed, [m/s]
|
|
35
|
+
* @param {number} rh - relative humidity, [%]
|
|
36
|
+
* @param {number} met - metabolic rate, [met]
|
|
37
|
+
* @param {number} clo - clothing insulation, [clo]
|
|
38
|
+
* @param {number} [p_atm=1013.25] - atmospheric pressure, default value 1013.25 [hPa]
|
|
39
|
+
* @param {1 | 2 | 3} [position=1] - position of the individual (1=sitting, 2=standing, 3=standing, forced convection)
|
|
40
|
+
* @param {number} [age=23] - age in years
|
|
41
|
+
* @param {1 | 2} [sex=1] - male (1) or female (2).
|
|
42
|
+
* @param {number} [weight=75] - body mass, [kg]
|
|
43
|
+
* @param {number} [height=1.8] - height, [m]
|
|
44
|
+
* @param {number} [wme=0] - external work, [W/(m2)]
|
|
45
|
+
*
|
|
46
|
+
* @returns {number} Steady-state PET under the given ambient conditions
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const result = pet_steady(20, 20, 50, 0.15, 1.37, 0.5);
|
|
50
|
+
* console.log(result); // 18.85
|
|
51
|
+
*/
|
|
52
|
+
function pet_steady(tdb, tr, v, rh, met, clo, p_atm = 1013.25, position = 1, age = 23, sex = 1, weight = 75, height = 1.8, wme = 0) {
|
|
53
|
+
const met_factor = 58.2; // met conversion factor
|
|
54
|
+
met = met * met_factor; // metabolic rate
|
|
55
|
+
// initial guess
|
|
56
|
+
const t_guess = [36.7, 34, 0.5 * (tdb + tr)];
|
|
57
|
+
// solve for Tc, Tsk, Tcl temperatures
|
|
58
|
+
const t_stable = newtonRaphson((tx) => solve_pet(tx, tdb, tr, v, rh, met, clo, true, p_atm, position, age, sex, weight, height, wme), t_guess);
|
|
59
|
+
return pet_fc(t_stable);
|
|
60
|
+
}
|
|
61
|
+
exports.pet_steady = pet_steady;
|
|
62
|
+
/**
|
|
63
|
+
* Function to find the solution.
|
|
64
|
+
*
|
|
65
|
+
* @param {[number,number,number]} _t_stable
|
|
66
|
+
* @returns {number}
|
|
67
|
+
*/
|
|
68
|
+
function pet_fc(_t_stable) {
|
|
69
|
+
// solving for PET
|
|
70
|
+
const pet_guess = _t_stable[2]; // start with the clothing temperature
|
|
71
|
+
const result = newtonRaphsonSingleEquation((tx) => {
|
|
72
|
+
const result = solve_pet(_t_stable, tx[0], tx[0], undefined, undefined, undefined, undefined, false);
|
|
73
|
+
return [result];
|
|
74
|
+
}, [pet_guess]);
|
|
75
|
+
return (0, utilities_js_2.round)(result[0], 2);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @typedef {Object} VasomotricitytRet
|
|
79
|
+
* @property {number} m_blood - Blood flow rate, [kg/m2/h]
|
|
80
|
+
* @property {number} alpha - repartition of body mass between core and skin [].
|
|
81
|
+
*/
|
|
82
|
+
// skin and core temperatures set values
|
|
83
|
+
const tc_set = 36.6;
|
|
84
|
+
const tsk_set = 34;
|
|
85
|
+
/**
|
|
86
|
+
* Defines the vasomotricity (blood flow) in function of the core and skin temperatures.
|
|
87
|
+
* @param {number} t_cr - The body core temperature, [°C]
|
|
88
|
+
* @param {number} t_sk - The body skin temperature, [°C]
|
|
89
|
+
* @returns {VasomotricitytRet}
|
|
90
|
+
*/
|
|
91
|
+
function vasomotricity(t_cr, t_sk) {
|
|
92
|
+
// Set value signals
|
|
93
|
+
let sig_skin = tsk_set - t_sk;
|
|
94
|
+
let sig_core = t_cr - tc_set;
|
|
95
|
+
if (sig_core < 0) {
|
|
96
|
+
// In this case, T_core<Tc_set --> the blood flow is reduced
|
|
97
|
+
sig_core = 0.0;
|
|
98
|
+
}
|
|
99
|
+
if (sig_skin < 0) {
|
|
100
|
+
// In this case, Tsk>Tsk_set --> the blood flow is increased
|
|
101
|
+
sig_skin = 0.0;
|
|
102
|
+
}
|
|
103
|
+
// 6.3 L/m^2/h is the set value of the blood flow
|
|
104
|
+
let m_blood = (6.3 + 75.0 * sig_core) / (1.0 + 0.5 * sig_skin);
|
|
105
|
+
// 90 L/m^2/h is the blood flow upper limit
|
|
106
|
+
if (m_blood > 90) {
|
|
107
|
+
m_blood = 90.0;
|
|
108
|
+
}
|
|
109
|
+
// in other models, alpha is used to update tbody
|
|
110
|
+
const alpha = 0.0417737 + 0.7451833 / (m_blood + 0.585417);
|
|
111
|
+
return { m_blood: m_blood, alpha: alpha };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Defines the sweating mechanism depending on the body and core temperatures.
|
|
115
|
+
* @param {number} t_body - weighted average between skin and core temperatures, [°C]
|
|
116
|
+
* @returns {number} m_rsw - The sweating flow rate, [g/m2/h].
|
|
117
|
+
*/
|
|
118
|
+
function sweat_rate(t_body) {
|
|
119
|
+
const tbody_set = 0.1 * tsk_set + 0.9 * tc_set; // Calculation of the body temperature through a weighted average
|
|
120
|
+
let sig_body = t_body - tbody_set;
|
|
121
|
+
if (sig_body < 0) {
|
|
122
|
+
// In this case, Tbody < Tbody_set --> The sweat flow is 0 from Gagge's model
|
|
123
|
+
sig_body = 0.0;
|
|
124
|
+
}
|
|
125
|
+
let m_rsw = 304.94 * Math.pow(10, -3) * sig_body;
|
|
126
|
+
// 500 g/m^2/h is the upper sweat rate limit
|
|
127
|
+
if (m_rsw > 500) {
|
|
128
|
+
m_rsw = 500;
|
|
129
|
+
}
|
|
130
|
+
return m_rsw;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* This function allows solving for the PET : either it solves the vectorial balance
|
|
134
|
+
of the 3 unknown temperatures (T_core, T_sk, T_clo) or it solves for the
|
|
135
|
+
environment operative temperature that would yield the same energy balance as the
|
|
136
|
+
actual environment.
|
|
137
|
+
* @param {[number, number, number]} t_arr - [T_core, T_sk, T_clo], [°C]
|
|
138
|
+
* @param {number} _tdb - dry bulb air temperature, [°C]
|
|
139
|
+
* @param {number} _tr - mean radiant temperature, [°C]
|
|
140
|
+
* @param {number} _v - default 0.1 m/s for the reference environment air speed, [m/s]
|
|
141
|
+
* @param {number} _rh - default 50 % for the reference environment relative humidity, [%]
|
|
142
|
+
* @param {number} _met - default 80 W for the reference environment metabolic rate, [W/m2]
|
|
143
|
+
* @param {number} _clo - default 0.9 clo for the reference environment clothing insulation, [clo]
|
|
144
|
+
* @param {boolean} actual_environment - default False. True=solve 3eqs/3unknowns, False=solve for PET
|
|
145
|
+
* @param {number} p_atm - atmospheric pressure, default value 1013.25 [hPa]
|
|
146
|
+
* @param {number} age - age in years. default=23
|
|
147
|
+
* @param {1 | 2 | 3} position - position of the individual (1=sitting, 2=standing, 3=standing, forced convection)
|
|
148
|
+
* @param {1 | 2} sex - default 1. male (1) or female (2).
|
|
149
|
+
* @param {number} weight - default 75. body mass, [kg]
|
|
150
|
+
* @param {number} height - default 1.8. height, [m]
|
|
151
|
+
* @param {number} wme - external work, [W/(m2)] default 0
|
|
152
|
+
* @returns {number | [number, number, number]} - PET (scalar) or energy balance (calculated core, skin, and clo temperatures).
|
|
153
|
+
*/
|
|
154
|
+
function solve_pet(t_arr, _tdb, _tr, _v = 0.1, _rh = 50, _met = 80, _clo = 0.9, actual_environment = false, p_atm = 1013.25, position = 1, age = 23, sex = 1, weight = 75, height = 1.8, wme = 0) {
|
|
155
|
+
// Constants
|
|
156
|
+
const e_skin = 0.99; // Skin emissivity
|
|
157
|
+
const e_clo = 0.95; // Clothing emissivity
|
|
158
|
+
const h_vap = 2.42 * Math.pow(10, 6); // Latent heat of evaporation [J/Kg]
|
|
159
|
+
const sbc = 5.67 * Math.pow(10, -8); // Stefan-Boltzmann constant [W/(m2*K^(-4))]
|
|
160
|
+
const cb = 3640; // Blood specific heat [J/kg/k]
|
|
161
|
+
// Initialize e_bal_vec and other variables
|
|
162
|
+
const e_bal_vec = [0, 0, 0]; // required for the vectorial expression of the balance
|
|
163
|
+
const a_dubois = (0, utilities_js_1.body_surface_area)(weight, height);
|
|
164
|
+
//Base metabolism for men and women in [W]
|
|
165
|
+
const met_female = 3.19 *
|
|
166
|
+
Math.pow(weight, 0.75) *
|
|
167
|
+
(1.0 +
|
|
168
|
+
0.004 * (30.0 - age) +
|
|
169
|
+
0.018 * ((height * 100.0) / Math.pow(weight, 1.0 / 3.0) - 42.1));
|
|
170
|
+
const met_male = 3.45 *
|
|
171
|
+
Math.pow(weight, 0.75) *
|
|
172
|
+
(1.0 +
|
|
173
|
+
0.004 * (30.0 - age) +
|
|
174
|
+
0.01 * ((height * 100.0) / Math.pow(weight, 1.0 / 3.0) - 43.4));
|
|
175
|
+
//Attribution of internal energy depending on the sex of the subject
|
|
176
|
+
const met_correction = sex === 1 ? met_male : met_female;
|
|
177
|
+
// Source term : metabolic activity
|
|
178
|
+
const he = (_met + met_correction) / a_dubois;
|
|
179
|
+
// impact of efficiency
|
|
180
|
+
const h = he * (1.0 - wme); // [W/m2]
|
|
181
|
+
// correction for wind
|
|
182
|
+
const i_m = 0.38; // Woodcock ratio for vapour transfer through clothing [-]
|
|
183
|
+
// Calculation of the Burton surface increase coefficient, k = 0.31 for Hoeppe:
|
|
184
|
+
const fcl = 1 + 0.31 * _clo; // Increase heat exchange surface depending on clothing level
|
|
185
|
+
const f_a_cl = (173.51 * _clo - 2.36 - 100.76 * _clo * _clo + 19.28 * Math.pow(_clo, 3.0)) / 100;
|
|
186
|
+
const a_clo = a_dubois * f_a_cl + a_dubois * (fcl - 1.0); // clothed body surface area
|
|
187
|
+
const f_eff = position === 2 ? 0.696 : 0.725; // effective radiation factor
|
|
188
|
+
const a_r_eff = a_dubois * f_eff; // Effective radiative area depending on the position of the subject
|
|
189
|
+
// Partial pressure of water in the air
|
|
190
|
+
let vpa = 12; // [hPa] vapour pressure of the standard environment
|
|
191
|
+
if (actual_environment) {
|
|
192
|
+
// mode=True means we are solving for 3eqs/3unknowns
|
|
193
|
+
vpa = ((_rh / 100.0) * (0, p_sat_js_1.p_sat)(_tdb)) / 100;
|
|
194
|
+
}
|
|
195
|
+
// Convection coefficient depending on wind velocity and subject position
|
|
196
|
+
let hc = 0;
|
|
197
|
+
switch (position) {
|
|
198
|
+
case 1:
|
|
199
|
+
hc = 2.67 + 6.5 * Math.pow(_v, 0.67); // sitting
|
|
200
|
+
break;
|
|
201
|
+
case 2:
|
|
202
|
+
// standing
|
|
203
|
+
hc = 2.26 + 7.42 * Math.pow(_v, 0.67);
|
|
204
|
+
break;
|
|
205
|
+
case 3:
|
|
206
|
+
// standing, forced convection
|
|
207
|
+
hc = 8.6 * Math.pow(_v, 0.513);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
// h_cc corrected convective heat transfer coefficient
|
|
211
|
+
const h_cc = 3.0 * Math.pow(p_atm / 1013.25, 0.53);
|
|
212
|
+
hc = Math.max(h_cc, hc);
|
|
213
|
+
// modification of hc with the total pressure
|
|
214
|
+
hc = hc * Math.pow(p_atm / 1013.25, 0.55);
|
|
215
|
+
// Respiratory energy losses
|
|
216
|
+
const t_exp = 0.47 * _tdb + 21.0; // Expired air temperature calculation [degC]
|
|
217
|
+
const d_vent_pulm = he * 1.44 * Math.pow(10.0, -6.0); // breathing flow rate
|
|
218
|
+
const c_res = 1010 * (_tdb - t_exp) * d_vent_pulm; // Sensible heat energy loss [W/m2]
|
|
219
|
+
const vpexp = (0, p_sat_js_1.p_sat)(t_exp) / 100; // Latent heat energy loss [hPa]
|
|
220
|
+
const q_res = ((0.623 * h_vap) / p_atm) * (vpa - vpexp) * d_vent_pulm; // [W/m2]
|
|
221
|
+
const ere = c_res + q_res; // [W/m2]
|
|
222
|
+
// Calculation of the equivalent thermal resistance of body tissues
|
|
223
|
+
let alpha = vasomotricity(t_arr[0], t_arr[1]).alpha;
|
|
224
|
+
let tbody = alpha * t_arr[1] + (1 - alpha) * t_arr[0];
|
|
225
|
+
// Clothed fraction of the body approximation
|
|
226
|
+
const r_cl = _clo / 6.45; // Conversion in [m2.K/W]
|
|
227
|
+
let y = 0;
|
|
228
|
+
if (f_a_cl > 1.0) {
|
|
229
|
+
f_a_cl = 1.0;
|
|
230
|
+
}
|
|
231
|
+
if (_clo >= 2.0) {
|
|
232
|
+
y = 1.0;
|
|
233
|
+
}
|
|
234
|
+
if (0.6 < _clo < 2.0) {
|
|
235
|
+
y = (height - 0.2) / height;
|
|
236
|
+
}
|
|
237
|
+
if (0.6 >= _clo > 0.3) {
|
|
238
|
+
y = 0.5;
|
|
239
|
+
}
|
|
240
|
+
if (0.3 >= _clo > 0.0) {
|
|
241
|
+
y = 0.1;
|
|
242
|
+
}
|
|
243
|
+
// calculation of the clothing radius depending on the clothing level (6.28 = 2*
|
|
244
|
+
// pi !)
|
|
245
|
+
const r2 = (a_dubois * (fcl - 1.0 + f_a_cl)) / (6.28 * height * y); // External radius
|
|
246
|
+
const r1 = (f_a_cl * a_dubois) / (6.28 * height * y); // Internal radius
|
|
247
|
+
const di = r2 - r1;
|
|
248
|
+
// Calculation of the equivalent thermal resistance of body tissues
|
|
249
|
+
const htcl = (6.28 * height * y * di) / (r_cl * Math.log(r2 / r1) * a_clo); // [W/(m2.K)]
|
|
250
|
+
// Calculation of sweat losses
|
|
251
|
+
const qmsw = sweat_rate(tbody);
|
|
252
|
+
// h_vap/1000 = 2400 000[J/kg] divided by 1000 = [J/g] // qwsw/3600 for [g/m2/h]
|
|
253
|
+
// to [
|
|
254
|
+
// g/m2/s]
|
|
255
|
+
let esw = ((h_vap / 1000) * qmsw) / 3600; // [W/m2]
|
|
256
|
+
// Saturation vapor pressure at temperature Tsk
|
|
257
|
+
const p_v_sk = (0, p_sat_js_1.p_sat)(t_arr[1]) / 100; // hPa
|
|
258
|
+
// Calculation of vapour transfer
|
|
259
|
+
const lr = 16.7 * Math.pow(10, -1); // [K/hPa] Lewis ratio
|
|
260
|
+
const he_diff = hc * lr; // diffusion coefficient of air layer
|
|
261
|
+
const fecl = 1 / (1 + 0.92 * hc * r_cl); // Burton efficiency factor
|
|
262
|
+
let e_max = he_diff * fecl * (p_v_sk - vpa); // maximum diffusion at skin surface
|
|
263
|
+
if (e_max < 0.001 && e_max >= 0) {
|
|
264
|
+
// added this otherwise e_req / e_max cannot be calculated
|
|
265
|
+
e_max = 0.001;
|
|
266
|
+
}
|
|
267
|
+
let w = esw / e_max; // skin wetness
|
|
268
|
+
if (w > 1) {
|
|
269
|
+
w = 1;
|
|
270
|
+
if (esw - e_max < 0) {
|
|
271
|
+
esw = e_max;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (esw < 0) {
|
|
275
|
+
esw = 0;
|
|
276
|
+
}
|
|
277
|
+
// i_m= Woodcock's ratio (see above)
|
|
278
|
+
const r_ecl = (1 / (fcl * hc) + r_cl) / (lr * i_m); // clothing vapour transfer resistance after Woodcock's method
|
|
279
|
+
const ediff = ((1 - w) * (p_v_sk - vpa)) / r_ecl; // diffusion heat transfer
|
|
280
|
+
const evap = -(ediff + esw); // [W/m2]
|
|
281
|
+
// Radiation losses bare skin
|
|
282
|
+
const r_bare = (a_r_eff *
|
|
283
|
+
(1.0 - f_a_cl) *
|
|
284
|
+
e_skin *
|
|
285
|
+
sbc *
|
|
286
|
+
(Math.pow((_tr + 273.15), 4.0) - Math.pow((t_arr[1] + 273.15), 4.0))) /
|
|
287
|
+
a_dubois;
|
|
288
|
+
// ... for clothed area
|
|
289
|
+
const r_clo = (f_eff *
|
|
290
|
+
a_clo *
|
|
291
|
+
e_clo *
|
|
292
|
+
sbc *
|
|
293
|
+
(Math.pow((_tr + 273.15), 4.0) - Math.pow((t_arr[2] + 273.15), 4.0))) /
|
|
294
|
+
a_dubois;
|
|
295
|
+
const r_sum = r_clo + r_bare; // radiation total
|
|
296
|
+
// Convection losses for bare skin
|
|
297
|
+
const c_bare = (hc * (_tdb - t_arr[1]) * a_dubois * (1.0 - f_a_cl)) / a_dubois; // [W/m^2]
|
|
298
|
+
// ... for clothed area
|
|
299
|
+
const c_clo = (hc * (_tdb - t_arr[2]) * a_clo) / a_dubois; // [W/m^2]
|
|
300
|
+
const csum = c_clo + c_bare; // convection total
|
|
301
|
+
// Balance equations of the 3-nodes model
|
|
302
|
+
e_bal_vec[0] =
|
|
303
|
+
h +
|
|
304
|
+
ere -
|
|
305
|
+
((vasomotricity(t_arr[0], t_arr[1]).m_blood / 3600) * cb + 5.28) *
|
|
306
|
+
(t_arr[0] - t_arr[1]); // Core balance [W/m^2]
|
|
307
|
+
e_bal_vec[1] =
|
|
308
|
+
r_bare +
|
|
309
|
+
c_bare +
|
|
310
|
+
evap +
|
|
311
|
+
((vasomotricity(t_arr[0], t_arr[1]).m_blood / 3600) * cb + 5.28) *
|
|
312
|
+
(t_arr[0] - t_arr[1]) -
|
|
313
|
+
htcl * (t_arr[1] - t_arr[2]); // Skin balance [W/m^2]
|
|
314
|
+
e_bal_vec[2] = c_clo + r_clo + htcl * (t_arr[1] - t_arr[2]); // Clothes balance [W/m^2]
|
|
315
|
+
const e_bal_scal = h + ere + r_sum + csum + evap;
|
|
316
|
+
// Return either the calculated core, skin, and clo temperatures or the PET
|
|
317
|
+
if (actual_environment) {
|
|
318
|
+
return e_bal_vec;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
return e_bal_scal;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* @param {NewtonRaphsonSingleFunction} func
|
|
327
|
+
* @param {[number]} initialGuess
|
|
328
|
+
* @param {number} [tolerance=1e-3]
|
|
329
|
+
* @param {number} [maxIterations=1000]
|
|
330
|
+
*
|
|
331
|
+
* @returns {[number]}
|
|
332
|
+
*/
|
|
333
|
+
function newtonRaphsonSingleEquation(func, initialGuess, tolerance = 1e-3, maxIterations = 1000) {
|
|
334
|
+
let solution = [...initialGuess];
|
|
335
|
+
let iteration = 0;
|
|
336
|
+
const n = solution.length;
|
|
337
|
+
let J = createMatrix(n);
|
|
338
|
+
while (iteration < maxIterations) {
|
|
339
|
+
const fValue = func(solution);
|
|
340
|
+
if (Math.abs(fValue[0]) < tolerance) {
|
|
341
|
+
return solution;
|
|
342
|
+
}
|
|
343
|
+
const dfdx = numericalDerivatives(func, solution, fValue, undefined, J);
|
|
344
|
+
solution[0] -= fValue[0] / dfdx[0][0];
|
|
345
|
+
iteration++;
|
|
346
|
+
}
|
|
347
|
+
throw new Error("Newton Raphson Single equation did not converged");
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Derived from this method: {@link https://en.wikipedia.org/wiki/Newton's_method}
|
|
351
|
+
* We approximate the derivatives so not truly Newton's method.
|
|
352
|
+
*
|
|
353
|
+
* @param {NewtonRaphsonFunction} f
|
|
354
|
+
* @param {[number, number, number]} initialGuess
|
|
355
|
+
* @param {number} [tolerance=1e-3]
|
|
356
|
+
* @param {number} [maxIterations=1000]
|
|
357
|
+
*
|
|
358
|
+
* @returns {[number, number, number]}
|
|
359
|
+
*/
|
|
360
|
+
function newtonRaphson(f, initialGuess, tolerance = 1e-3, maxIterations = 1000) {
|
|
361
|
+
let iteration = 0;
|
|
362
|
+
let solution = [...initialGuess];
|
|
363
|
+
const n = solution.length;
|
|
364
|
+
let J = createMatrix(n);
|
|
365
|
+
while (iteration < maxIterations) {
|
|
366
|
+
const fValue = f(solution);
|
|
367
|
+
if (Math.abs(fValue[0]) < tolerance &&
|
|
368
|
+
Math.abs(fValue[1]) < tolerance &&
|
|
369
|
+
Math.abs(fValue[2]) < tolerance) {
|
|
370
|
+
return solution;
|
|
371
|
+
}
|
|
372
|
+
J = numericalDerivatives(f, solution, fValue, undefined, J);
|
|
373
|
+
const jacobian00SemiDeterminant = J[1][1] * J[2][2] - J[1][2] * J[2][1];
|
|
374
|
+
const jacobian10SemiDeterminant = J[1][0] * J[2][2] - J[1][2] * J[2][0];
|
|
375
|
+
const jacobian20SemiDeterminant = J[1][0] * J[2][1] - J[1][1] * J[2][0];
|
|
376
|
+
const detJ = J[0][0] * jacobian00SemiDeterminant -
|
|
377
|
+
J[0][1] * jacobian10SemiDeterminant +
|
|
378
|
+
J[0][2] * jacobian20SemiDeterminant;
|
|
379
|
+
const d0 = jacobian00SemiDeterminant * fValue[0] -
|
|
380
|
+
(J[0][1] * J[2][2] - J[0][2] * J[2][1]) * fValue[1] +
|
|
381
|
+
(J[0][1] * J[1][2] - J[0][2] * J[1][1]) * fValue[2];
|
|
382
|
+
const d1 = -jacobian10SemiDeterminant * fValue[0] +
|
|
383
|
+
(J[0][0] * J[2][2] - J[0][2] * J[2][0]) * fValue[1] -
|
|
384
|
+
(J[0][0] * J[1][2] - J[0][2] * J[1][0]) * fValue[2];
|
|
385
|
+
const d2 = jacobian20SemiDeterminant * fValue[0] -
|
|
386
|
+
(J[0][0] * J[2][1] - J[0][1] * J[2][0]) * fValue[1] +
|
|
387
|
+
(J[0][0] * J[1][1] - J[0][1] * J[1][0]) * fValue[2];
|
|
388
|
+
solution[0] -= d0 / detJ;
|
|
389
|
+
solution[1] -= d1 / detJ;
|
|
390
|
+
solution[2] -= d2 / detJ;
|
|
391
|
+
++iteration;
|
|
392
|
+
}
|
|
393
|
+
throw new Error("Newton Raphson did not converged");
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
* @param {NewtonRaphsonFunction} f
|
|
398
|
+
* @param {[number, number, number]} values
|
|
399
|
+
* @param {[number, number, number]} [evaluated] - result of f(values)
|
|
400
|
+
* @param {number} [h=1e-2]
|
|
401
|
+
* @param {number[][]} [matrix]
|
|
402
|
+
* @returns {number[][]}
|
|
403
|
+
*/
|
|
404
|
+
function numericalDerivatives(f, values, evaluated, h = 1e-2, matrix) {
|
|
405
|
+
const n = values.length;
|
|
406
|
+
let aux = [...values];
|
|
407
|
+
if (evaluated === undefined) {
|
|
408
|
+
evaluated = f(values);
|
|
409
|
+
}
|
|
410
|
+
if (matrix === undefined) {
|
|
411
|
+
matrix = createMatrix(n);
|
|
412
|
+
}
|
|
413
|
+
for (let i = 0; i < n; ++i) {
|
|
414
|
+
aux[i] += h;
|
|
415
|
+
const iWithH = f(aux);
|
|
416
|
+
aux[i] = values[i];
|
|
417
|
+
for (let j = 0; j < n; ++j) {
|
|
418
|
+
matrix[j][i] = (iWithH[j] - evaluated[j]) / h;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return matrix;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* @callback NewtonRaphsonFunction
|
|
425
|
+
* @param {[number, number, number]}
|
|
426
|
+
* @returns {[number, number, number]}
|
|
427
|
+
*/
|
|
428
|
+
/**
|
|
429
|
+
* @callback NewtonRaphsonSingleFunction
|
|
430
|
+
* @param {[number]}
|
|
431
|
+
* @returns {[number]}
|
|
432
|
+
*/
|
|
433
|
+
function createMatrix(n) {
|
|
434
|
+
const matrix = [];
|
|
435
|
+
for (let i = 0; i < n; ++i) {
|
|
436
|
+
const row = [];
|
|
437
|
+
for (let j = 0; j < n; ++j) {
|
|
438
|
+
row.push(NaN);
|
|
439
|
+
}
|
|
440
|
+
matrix.push(row);
|
|
441
|
+
}
|
|
442
|
+
return matrix;
|
|
443
|
+
}
|