diff --git a/lib/cjs/jos3_functions/JOS3Defaults.js b/lib/cjs/jos3_functions/JOS3Defaults.js new file mode 100644 index 0000000..78dd8c5 --- /dev/null +++ b/lib/cjs/jos3_functions/JOS3Defaults.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const JOS3Defaults = { + // Body information + height: 1.72, + weight: 74.43, + age: 20, + body_fat: 15, + cardiac_index: 2.59, + blood_flow_rate: 290, + physical_activity_ratio: 1.25, + metabolic_rate: 1.0, + sex: "male", + posture: "standing", + bmr_equation: "harris-benedict", + bsa_equation: "dubois", + local_bsa: [ + 0.11, 0.029, 0.175, 0.161, 0.221, 0.096, 0.063, 0.05, 0.096, 0.063, 0.05, + 0.209, 0.112, 0.056, 0.209, 0.112, 0.056, + ], + // Environment information + core_temperature: 37, + skin_temperature: 34, + other_body_temperature: 36, + dry_bulb_air_temperature: 28.8, + mean_radiant_temperature: 28.8, + relative_humidity: 50, + air_speed: 0.1, + // Clothing information + clothing_insulation: 0, + clothing_vapor_permeation_efficiency: 0.45, + lewis_rate: 16.5, // [K/kPa] +}; +exports.default = JOS3Defaults; diff --git a/lib/cjs/jos3_functions/bfb_rate.js b/lib/cjs/jos3_functions/bfb_rate.js new file mode 100644 index 0000000..afb62fe --- /dev/null +++ b/lib/cjs/jos3_functions/bfb_rate.js @@ -0,0 +1,66 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bfb_rate = void 0; +const JOS3Defaults_js_1 = __importDefault(require("./JOS3Defaults.js")); +const bsa_rate_js_1 = require("./bsa_rate.js"); +const validate_body_parameters_js_1 = require("./validate_body_parameters.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate the ratio of basal blood flow (BFB) of the standard body (290 L/h). + * + * @param {number} height - Body height [m]. The default is 1.72. + * @param {number} weight - Body weight [kg]. The default is 74.43. + * @param {string} bsa_equation - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". The default is "dubois". + * @param {number} age - age [years]. The default is 20. + * @param {number} ci - Cardiac index [L/min/㎡]. The default is 2.59. + * + * @returns {number} - Basal blood flow rate. + */ +function bfb_rate(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age, ci = JOS3Defaults_js_1.default.cardiac_index) { + (0, validate_body_parameters_js_1.validate_body_parameters)(height, weight, age); + ci *= 60; + if (age < 50) { + ci *= 1; + } + else if (age < 60) { + ci *= 0.85; + } + else if (age < 70) { + ci *= 0.75; + } + else { + // age >= 70 + ci *= 0.7; + } + const bfb_all = ci * + (0, bsa_rate_js_1.bsa_rate)(height, weight, bsa_equation) * + math.sum(JOS3Defaults_js_1.default.local_bsa); + return bfb_all / JOS3Defaults_js_1.default.blood_flow_rate; +} +exports.bfb_rate = bfb_rate; diff --git a/lib/cjs/jos3_functions/bsa_rate.js b/lib/cjs/jos3_functions/bsa_rate.js new file mode 100644 index 0000000..be2dbb2 --- /dev/null +++ b/lib/cjs/jos3_functions/bsa_rate.js @@ -0,0 +1,28 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bsa_rate = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../jos3_functions/JOS3Defaults.js")); +const validate_body_parameters_js_1 = require("./validate_body_parameters.js"); +const utilities_js_1 = require("../utilities/utilities.js"); +/** + * Calculates the body surface area rate based on the given height, weight and + * BSA equation. + * + * @param {number} [height=JOS3Defaults.height] - The height of the person in + * meters. + * @param {number} [weight=JOS3Defaults.weight] - The weight of the person in + * kilograms. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The BSA equation + * to use for calculation. + * + * @returns {number} The body surface area rate. + */ +function bsa_rate(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation) { + (0, validate_body_parameters_js_1.validate_body_parameters)(height, weight, bsa_equation); + const bsa_all = (0, utilities_js_1.body_surface_area)(weight, height, bsa_equation); + return bsa_all / JOS3Defaults_js_1.default.local_bsa.reduce((t, c) => t + c, 0); +} +exports.bsa_rate = bsa_rate; diff --git a/lib/cjs/jos3_functions/capacity.js b/lib/cjs/jos3_functions/capacity.js new file mode 100644 index 0000000..65d6541 --- /dev/null +++ b/lib/cjs/jos3_functions/capacity.js @@ -0,0 +1,103 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.capacity = void 0; +const JOS3Defaults_js_1 = __importDefault(require("./JOS3Defaults.js")); +const validate_body_parameters_js_1 = require("./validate_body_parameters.js"); +const bfb_rate_js_1 = require("./bfb_rate.js"); +const weight_rate_js_1 = require("./weight_rate.js"); +const matrix_js_1 = require("./matrix.js"); +/** + * Calculate thermal capacity in Joules per Kelvin (J/K). + * Derived from Yokoyama's model, assuming blood's heat as 1.0 [kcal/L.K]. + * + * @param {number} [height=JOS3Defaults.height] - Body height in meters. Default + * is 1.72. + * @param {number} [weight=JOS3Defaults.weight] - Body weight in kg. Default is + * 74.43. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - Equation name for + * bsa calc. Must be from "dubois","takahira", "fujimoto", "kurazumi". + * Default is "dubois". + * @param {number} [age=JOS3Defaults.age] - Age in years. Default is 20. + * @param {number} [ci=JOS3Defaults.cardiac_index] - Cardiac index in L/min/㎡. + * Default is 2.59. + + * @returns {number[]} - Thermal capacity in W/K. Shape is (NUM_NODES). + */ +function capacity(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age, ci = JOS3Defaults_js_1.default.cardiac_index) { + (0, validate_body_parameters_js_1.validate_body_parameters)(height, weight, age); + // artery [Wh/K] + let cap_art = [ + 0.096, 0.025, 0.12, 0.111, 0.265, 0.0186, 0.0091, 0.0044, 0.0186, 0.0091, + 0.0044, 0.0813, 0.04, 0.0103, 0.0813, 0.04, 0.0103, + ]; + // vein [Wh/K] + let cap_vein = [ + 0.321, 0.085, 0.424, 0.39, 0.832, 0.046, 0.024, 0.01, 0.046, 0.024, 0.01, + 0.207, 0.1, 0.024, 0.207, 0.1, 0.024, + ]; + // superficial vein [Wh/K] + let cap_sfv = [ + 0, 0, 0, 0, 0, 0.025, 0.015, 0.011, 0.025, 0.015, 0.011, 0.074, 0.05, 0.021, + 0.074, 0.05, 0.021, + ]; + // central blood [Wh/K] + let cap_cb = 1.999; + // core [Wh/K] + let cap_cr = [ + 1.7229, 0.564, 10.2975, 9.3935, 4.488, 1.6994, 1.1209, 0.1536, 1.6994, + 1.1209, 0.1536, 5.3117, 2.867, 0.2097, 5.3117, 2.867, 0.2097, + ]; + // muscle [Wh/K] + let cap_ms = [ + 0.305, 0.0, 0.0, 0.0, 7.409, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]; + // fat [Wh/K] + let cap_fat = [ + 0.203, 0.0, 0.0, 0.0, 1.947, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]; + // skin [Wh/K] + let cap_sk = [ + 0.1885, 0.058, 0.441, 0.406, 0.556, 0.126, 0.084, 0.088, 0.126, 0.084, + 0.088, 0.334, 0.169, 0.107, 0.334, 0.169, 0.107, + ]; + // Changes the values based on the standard body + const bfbr = (0, bfb_rate_js_1.bfb_rate)(height, weight, bsa_equation, age, ci); + const wr = (0, weight_rate_js_1.weight_rate)(weight); + cap_art = cap_art.map((x) => x * bfbr); + cap_vein = cap_vein.map((x) => x * bfbr); + cap_sfv = cap_sfv.map((x) => x * bfbr); + cap_cb = cap_cb * bfbr; + cap_cr = cap_cr.map((x) => x * wr); + cap_ms = cap_ms.map((x) => x * wr); + cap_fat = cap_fat.map((x) => x * wr); + cap_sk = cap_sk.map((x) => x * wr); + let cap_whole = Array(matrix_js_1.NUM_NODES).fill(0); + cap_whole[0] = cap_cb; + for (let i = 0; i < matrix_js_1.BODY_NAMES.length; i++) { + // Dictionary of indices in each body segment + // key = layer name, value = index of matrix + let bn = matrix_js_1.BODY_NAMES[i]; + let index_of = matrix_js_1.IDICT[bn]; + // Common + cap_whole[index_of["artery"]] = cap_art[i]; + cap_whole[index_of["vein"]] = cap_vein[i]; + cap_whole[index_of["core"]] = cap_cr[i]; + cap_whole[index_of["skin"]] = cap_sk[i]; + // Only limbs + if (i >= 5) { + cap_whole[index_of["sfvein"]] = cap_sfv[i]; + } + // If the segment has a muscle or fat layer + if (index_of["muscle"] !== null || index_of["fat"] !== null) { + cap_whole[index_of["muscle"]] = cap_ms[i]; + cap_whole[index_of["fat"]] = cap_fat[i]; + } + } + return cap_whole.map((x) => x * 3600); +} +exports.capacity = capacity; diff --git a/lib/cjs/jos3_functions/conductance.js b/lib/cjs/jos3_functions/conductance.js new file mode 100644 index 0000000..f69be5d --- /dev/null +++ b/lib/cjs/jos3_functions/conductance.js @@ -0,0 +1,171 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.conductance = void 0; +const JOS3Defaults_js_1 = __importDefault(require("./JOS3Defaults.js")); +const validate_body_parameters_js_1 = require("./validate_body_parameters.js"); +const weight_rate_js_1 = require("./weight_rate.js"); +const bsa_rate_js_1 = require("./bsa_rate.js"); +const matrix_js_1 = require("./matrix.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate thermal conductance between layers. + + * @param {number} height - Body height in [m]. Default is 1.72. + * @param {number} weight - Body weight in [kg]. Default is 74.43. + * @param {string} bsa_equation - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". Default is "dubois". + * @param {number} fat - Body fat rate in [%]. Default is 15. + + * @returns {math.Matrix} conductance - Thermal conductance between layers in [W/K]. The shape is (NUM_NODES, NUM_NODES). + */ +function conductance(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, fat = JOS3Defaults_js_1.default.body_fat) { + (0, validate_body_parameters_js_1.validate_body_parameters)(height, weight, undefined, fat); + let cdt_cr_sk; + if (fat < 12.5) { + cdt_cr_sk = math.matrix([ + 1.341, 0.93, 1.879, 1.729, 2.37, 1.557, 1.018, 2.21, 1.557, 1.018, 2.21, + 2.565, 1.378, 3.404, 2.565, 1.378, 3.404, + ]); + } + else if (fat < 17.5) { + cdt_cr_sk = math.matrix([ + 1.311, 0.909, 1.785, 1.643, 2.251, 1.501, 0.982, 2.183, 1.501, 0.982, + 2.183, 2.468, 1.326, 3.37, 2.468, 1.326, 3.37, + ]); + } + else if (fat < 22.5) { + cdt_cr_sk = math.matrix([ + 1.282, 0.889, 1.698, 1.563, 2.142, 1.448, 0.947, 2.156, 1.448, 0.947, + 2.156, 2.375, 1.276, 3.337, 2.375, 1.276, 3.337, + ]); + } + else if (fat < 27.5) { + cdt_cr_sk = math.matrix([ + 1.255, 0.87, 1.618, 1.488, 2.04, 1.396, 0.913, 2.13, 1.396, 0.913, 2.13, + 2.285, 1.227, 3.304, 2.285, 1.227, 3.304, + ]); + } + else { + // fat >= 27.5 + cdt_cr_sk = math.matrix([ + 1.227, 0.852, 1.542, 1.419, 1.945, 1.346, 0.88, 1.945, 1.346, 0.88, 1.945, + 2.198, 1.181, 3.271, 2.198, 1.181, 3.271, + ]); + } + let cdt_cr_ms = math.zeros(17); // core to muscle [W/K] + let cdt_ms_fat = math.zeros(17); // muscle to fat [W/K] + let cdt_fat_sk = math.zeros(17); // fat to skin [W/K] + // head and pelvis consists of 65MN's conductances + cdt_cr_ms.set([0], 1.601); // head + cdt_ms_fat.set([0], 13.222); + cdt_fat_sk.set([0], 16.008); + cdt_cr_ms.set([4], 3.0813); // pelvis + cdt_ms_fat.set([4], 10.3738); + cdt_fat_sk.set([4], 41.4954); + // vessel to core + // The shape is a cylinder. + // It is assumed that the inner is vascular radius, 2.5mm and the outer is + // stolwijk's core radius. + // The heat transfer coefficient of the core is assumed as the Michel's + // counter-flow model 0.66816 [W/(m・K)]. + let cdt_ves_cr = math.matrix([ + 0, 0, 0, 0, 0, 0.586, 0.383, 1.534, 0.586, 0.383, 1.534, 0.81, 0.435, 1.816, + 0.81, 0.435, 1.816, + ]); + // superficial vein to skin + let cdt_sfv_sk = math.matrix([ + 0, 0, 0, 0, 0, 57.735, 37.768, 16.634, 57.735, 37.768, 16.634, 102.012, + 54.784, 24.277, 102.012, 54.784, 24.277, + ]); + // art to vein (counter-flow) [W/K] + // The data has been derived Mitchell's model. + // The values = 15.869 [W/(m・K)] * the segment length [m] + let cdt_art_vein = math.matrix([ + 0, 0, 0, 0, 0, 0.537, 0.351, 0.762, 0.537, 0.351, 0.762, 0.826, 0.444, + 0.992, 0.826, 0.444, 0.992, + ]); + // Changes values by body size based on the standard body. + const wr = (0, weight_rate_js_1.weight_rate)(weight); + const bsar = (0, bsa_rate_js_1.bsa_rate)(height, weight, bsa_equation); + const adjustSphere = (matrix, range) => { + let index = math.index(math.range(0, 2)); + let subset = math.subset(matrix, index); + subset = math.dotDivide(math.dotMultiply(subset, wr), bsar); + return math.subset(matrix, index, subset); + }; + const adjustCylinder = (matrix) => { + let index = math.index(math.range(2, matrix.size()[0])); + let subset = math.subset(matrix, index); + subset = math.dotDivide(math.dotMultiply(subset, Math.pow(bsar, 2)), wr); + return math.subset(matrix, index, subset); + }; + // head, neck (Sphere shape) + cdt_cr_sk = adjustSphere(cdt_cr_sk); + cdt_cr_ms = adjustSphere(cdt_cr_ms); + cdt_ms_fat = adjustSphere(cdt_ms_fat); + cdt_fat_sk = adjustSphere(cdt_fat_sk); + cdt_ves_cr = adjustSphere(cdt_ves_cr); + cdt_sfv_sk = adjustSphere(cdt_sfv_sk); + cdt_art_vein = adjustSphere(cdt_art_vein); + // Others (Cylinder shape) + cdt_cr_sk = adjustCylinder(cdt_cr_sk); + cdt_cr_ms = adjustCylinder(cdt_cr_ms); + cdt_ms_fat = adjustCylinder(cdt_ms_fat); + cdt_fat_sk = adjustCylinder(cdt_fat_sk); + cdt_ves_cr = adjustCylinder(cdt_ves_cr); + cdt_sfv_sk = adjustCylinder(cdt_sfv_sk); + cdt_art_vein = adjustCylinder(cdt_art_vein); + const cdt_whole = math.zeros(matrix_js_1.NUM_NODES, matrix_js_1.NUM_NODES); + for (let i = 0; i < matrix_js_1.BODY_NAMES.length; i++) { + const bn = matrix_js_1.BODY_NAMES[i]; + // Dictionary of indices in each body segment + // key = layer name, value = index of matrix + const index_of = matrix_js_1.IDICT[bn]; + // Common + cdt_whole.set([index_of["artery"], index_of["vein"]], cdt_art_vein.get([i])); // art to vein + cdt_whole.set([index_of["artery"], index_of["core"]], cdt_ves_cr.get([i])); // art to cr + cdt_whole.set([index_of["vein"], index_of["core"]], cdt_ves_cr.get([i])); // vein to cr + // Only limbs + if (i >= 5) { + cdt_whole.set([index_of["sfvein"], index_of["skin"]], cdt_sfv_sk.get([i])); // sfv to sk + } + // If the segment has a muscle or fat layer + if (index_of["muscle"] !== null) { + // or not indexof["fat"] is None + cdt_whole.set([index_of["core"], index_of["muscle"]], cdt_cr_ms.get([i])); // cr to ms + cdt_whole.set([index_of["muscle"], index_of["fat"]], cdt_ms_fat.get([i])); // ms to fat + cdt_whole.set([index_of["fat"], index_of["skin"]], cdt_fat_sk.get([i])); // fat to sk + } + else { + cdt_whole.set([index_of["core"], index_of["skin"]], cdt_cr_sk.get([i])); // cr to sk + } + } + // Creates a symmetrical matrix + return math.add(cdt_whole, math.transpose(cdt_whole)); +} +exports.conductance = conductance; diff --git a/lib/cjs/jos3_functions/local_bsa.js b/lib/cjs/jos3_functions/local_bsa.js new file mode 100644 index 0000000..da90a49 --- /dev/null +++ b/lib/cjs/jos3_functions/local_bsa.js @@ -0,0 +1,55 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.local_bsa = void 0; +const JOS3Defaults_js_1 = __importDefault(require("./JOS3Defaults.js")); +const validate_body_parameters_js_1 = require("./validate_body_parameters.js"); +const bsa_rate_js_1 = require("./bsa_rate.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate local body surface area (bsa) [m2]. + * + * The local body surface area has been derived from 65MN. + * The head have been divided to head and neck based on Smith's model. + * head = 0.1396*0.1117/0.1414 (65MN_Head * Smith_Head / Smith_Head+neck) + * neck = 0.1396*0.0297/0.1414 (65MN_Head * Smith_Neck / Smith_Head+neck) + * + * @param {number} [height=JOS3Defaults.height] - Body height [m] + * @param {number} [weight=JOS3Defaults.weight] - Body weight [kg] + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The equation name + * of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", + * or "kurazumi". + * + * @returns {math.Matrix} local_bsa of length 17 - Local body surface area (bsa) [m2] + */ +function local_bsa(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation) { + (0, validate_body_parameters_js_1.validate_body_parameters)(height, weight); + const bsa = (0, bsa_rate_js_1.bsa_rate)(height, weight, bsa_equation); + return math.matrix(math.dotMultiply(JOS3Defaults_js_1.default.local_bsa, bsa)); +} +exports.local_bsa = local_bsa; diff --git a/lib/cjs/jos3_functions/matrix.js b/lib/cjs/jos3_functions/matrix.js new file mode 100644 index 0000000..588a183 --- /dev/null +++ b/lib/cjs/jos3_functions/matrix.js @@ -0,0 +1,341 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var _a, _b; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VINDEX = exports.INDEX = exports.whole_body = exports.local_arr = exports.vessel_blood_flow = exports.NUM_NODES = exports.IDICT = exports.LAYER_NAMES = exports.BODY_NAMES = void 0; +const math = __importStar(require("mathjs")); +exports.BODY_NAMES = [ + "head", + "neck", + "chest", + "back", + "pelvis", + "left_shoulder", + "left_arm", + "left_hand", + "right_shoulder", + "right_arm", + "right_hand", + "left_thigh", + "left_leg", + "left_foot", + "right_thigh", + "right_leg", + "right_foot", +]; +exports.LAYER_NAMES = [ + "artery", + "vein", + "sfvein", + "core", + "muscle", + "fat", + "skin", +]; +_a = (() => { + // Defines existing layers as 1 or null + let index_dict = {}; + ["head", "pelvis"].forEach((key) => { + index_dict[key] = { + artery: 1, + vein: 1, + sfvein: null, + core: 1, + muscle: 1, + fat: 1, + skin: 1, + }; + }); + ["neck", "chest", "back"].forEach((key) => { + index_dict[key] = { + artery: 1, + vein: 1, + sfvein: null, + core: 1, + muscle: null, + fat: null, + skin: 1, + }; + }); + exports.BODY_NAMES.slice(5).forEach((key) => { + // limb segments + index_dict[key] = { + artery: 1, + vein: 1, + sfvein: 1, + core: 1, + muscle: null, + fat: null, + skin: 1, + }; + }); + // Sets ordered indices in the matrix + index_dict["CB"] = 0; + let order_count = 1; + exports.BODY_NAMES.forEach((bn) => { + exports.LAYER_NAMES.forEach((ln) => { + if (index_dict[bn][ln] !== null) { + index_dict[bn][ln] = order_count; + order_count += 1; + } + }); + }); + return [index_dict, order_count]; +})(), exports.IDICT = _a[0], exports.NUM_NODES = _a[1]; +/** + * @typedef VesselBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_art - Artery blood flow rate [l/h]. + * @property {math.MathCollection} bf_vein - Vein blood flow rate [l/h]. + */ +/** + * Get artery and vein blood flow rate [l/h]. + * + * @param {math.MathCollection} bf_core - Core blood flow rate [l/h]. + * @param {math.MathCollection} bf_muscle - Muscle blood flow rate [l/h]. + * @param {math.MathCollection} bf_fat - Fat blood flow rate [l/h]. + * @param {math.MathCollection} bf_skin - Skin blood flow rate [l/h]. + * @param {number} bf_ava_hand - AVA blood flow rate at hand [l/h]. + * @param {number} bf_ava_foot - AVA blood flow rate at foot [l/h]. + * + * @returns {VesselBloodFlowResult} bf_artery, bf_vein - Artery and vein blood flow rate [l/h]. + */ +function vessel_blood_flow(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot) { + let xbf = math.add(bf_core, bf_muscle, bf_fat, bf_skin); + let bf_art = math.zeros(17); + let bf_vein = math.zeros(17); + // head + bf_art.set([0], xbf.get([0])); + bf_vein.set([0], xbf.get([0])); + // neck (+head) + bf_art.set([1], xbf.get([1]) + xbf.get([0])); + bf_vein.set([1], xbf.get([1]) + xbf.get([0])); + // chest + bf_art.set([2], xbf.get([2])); + bf_vein.set([2], xbf.get([2])); + // back + bf_art.set([3], xbf.get([3])); + bf_vein.set([3], xbf.get([3])); + // pelvis (+Thighs, Legs, Feet, AVA_Feet) + bf_art.set([4], xbf.get([4]) + + math.sum(xbf.subset(math.index(math.range(11, 17)))) + + 2 * bf_ava_foot); + bf_vein.set([4], xbf.get([4]) + + math.sum(xbf.subset(math.index(math.range(11, 17)))) + + 2 * bf_ava_foot); + // L.Shoulder (+Arm, Hand, (arteryのみAVA_Hand)) + bf_art.set([5], math.sum(xbf.subset(math.index(math.range(5, 8)))) + bf_ava_hand); + bf_vein.set([5], math.sum(xbf.subset(math.index(math.range(5, 8))))); + // L.Arm (+Hand) + bf_art.set([6], math.sum(xbf.subset(math.index(math.range(6, 8)))) + bf_ava_hand); + bf_vein.set([6], math.sum(xbf.subset(math.index(math.range(6, 8))))); + // L.Hand + bf_art.set([7], xbf.get([7]) + bf_ava_hand); + bf_vein.set([7], xbf.get([7])); + // R.Shoulder (+Arm, Hand, (arteryのみAVA_Hand)) + bf_art.set([8], math.sum(xbf.subset(math.index(math.range(8, 11)))) + bf_ava_hand); + bf_vein.set([8], math.sum(xbf.subset(math.index(math.range(8, 11))))); + // R.Arm (+Hand) + bf_art.set([9], math.sum(xbf.subset(math.index(math.range(9, 11)))) + bf_ava_hand); + bf_vein.set([9], math.sum(xbf.subset(math.index(math.range(9, 11))))); + // R.Hand + bf_art.set([10], xbf.get([10]) + bf_ava_hand); + bf_vein.set([10], xbf.get([10])); + // L.Thigh (+Leg, Foot, (arteryのみAVA_Foot)) + bf_art.set([11], math.sum(xbf.subset(math.index(math.range(11, 14)))) + bf_ava_foot); + bf_vein.set([11], math.sum(xbf.subset(math.index(math.range(11, 14))))); + // L.Leg (+Foot) + bf_art.set([12], math.sum(xbf.subset(math.index(math.range(12, 14)))) + bf_ava_foot); + bf_vein.set([12], math.sum(xbf.subset(math.index(math.range(12, 14))))); + // L.Foot + bf_art.set([13], xbf.get([13]) + bf_ava_foot); + bf_vein.set([13], xbf.get([13])); + // R.Thigh (+Leg, Foot, (arteryのみAVA_Foot)) + bf_art.set([14], math.sum(xbf.subset(math.index(math.range(14, 17)))) + bf_ava_foot); + bf_vein.set([14], math.sum(xbf.subset(math.index(math.range(14, 17))))); + // R.Leg (+Foot) + bf_art.set([15], math.sum(xbf.subset(math.index(math.range(15, 17)))) + bf_ava_foot); + bf_vein.set([15], math.sum(xbf.subset(math.index(math.range(15, 17))))); + // R.Foot + bf_art.set([16], xbf.get([16]) + bf_ava_foot); + bf_vein.set([16], xbf.get([16])); + return { bf_art, bf_vein }; +} +exports.vessel_blood_flow = vessel_blood_flow; +/** + * Create matrix to calculate heat exchange by blood flow in each segment. + * + * @param {math.MathCollection} bf_core + * @param {math.MathCollection} bf_muscle + * @param {math.MathCollection} bf_fat + * @param {math.MathCollection} bf_skin + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @returns {math.Matrix} The heat exchange by blood flow in each segment. + */ +function local_arr(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot) { + let bf_local = math.zeros(exports.NUM_NODES, exports.NUM_NODES); + for (let i = 0; i < exports.BODY_NAMES.length; i++) { + // Dictionary of indicies in each body segment + // key = layer name, value = index of matrix + let bn = exports.BODY_NAMES[i]; + let index_of = exports.IDICT[bn]; + // Common + bf_local.set([index_of["core"], index_of["artery"]], 1.067 * bf_core.get([i])); // art to cr + bf_local.set([index_of["skin"], index_of["artery"]], 1.067 * bf_skin.get([i])); // art to sk + bf_local.set([index_of["vein"], index_of["core"]], 1.067 * bf_core.get([i])); // vein to cr + bf_local.set([index_of["vein"], index_of["skin"]], 1.067 * bf_skin.get([i])); // vein to sk + // If the segment has a muscle or fat layer + if (index_of["muscle"] !== null) { + bf_local.set([index_of["muscle"], index_of["artery"]], 1.067 * bf_muscle.get([i])); // art to ms + bf_local.set([index_of["vein"], index_of["muscle"]], 1.067 * bf_muscle.get([i])); // vein to ms + } + if (index_of["fat"] !== null) { + bf_local.set([index_of["fat"], index_of["artery"]], 1.067 * bf_fat.get([i])); // art to ft + bf_local.set([index_of["vein"], index_of["fat"]], 1.067 * bf_fat.get([i])); // vein to ft + } + // Only hand + if (i === 7 || i === 10) { + bf_local.set([index_of["sfvein"], index_of["artery"]], 1.067 * bf_ava_hand); // art to sfv + } + // Only foot + if (i === 13 || i === 16) { + bf_local.set([index_of["sfvein"], index_of["artery"]], 1.067 * bf_ava_foot); // art to sfv + } + } + return bf_local; +} +exports.local_arr = local_arr; +/** + * Create matrix to calculate heat exchange by blood flow between segments. [W/K] + * + * @param {math.MathCollection} bf_art + * @param {math.MathCollection} bf_vein + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @return {math.Matrix} + */ +function whole_body(bf_art, bf_vein, bf_ava_hand, bf_ava_foot) { + let arr83 = math.zeros(exports.NUM_NODES, exports.NUM_NODES); + const flow = (up, down, bloodflow) => arr83.set([down, up], bloodflow * 1.067); // Coefficient = 1.067 [Wh/L.K] Change units [L/h] to [W/K] + const CB = exports.IDICT["CB"]; + const head = exports.IDICT["head"]["artery"]; + const neck = exports.IDICT["neck"]["artery"]; + const chest = exports.IDICT["chest"]["artery"]; + const back = exports.IDICT["back"]["artery"]; + const pelvis = exports.IDICT["pelvis"]["artery"]; + const left_shoulder = exports.IDICT["left_shoulder"]["artery"]; + const left_arm = exports.IDICT["left_arm"]["artery"]; + const left_hand = exports.IDICT["left_hand"]["artery"]; + const right_shoulder = exports.IDICT["right_shoulder"]["artery"]; + const right_arm = exports.IDICT["right_arm"]["artery"]; + const right_hand = exports.IDICT["right_hand"]["artery"]; + const left_thigh = exports.IDICT["left_thigh"]["artery"]; + const left_leg = exports.IDICT["left_leg"]["artery"]; + const left_foot = exports.IDICT["left_foot"]["artery"]; + const right_thigh = exports.IDICT["right_thigh"]["artery"]; + const right_leg = exports.IDICT["right_leg"]["artery"]; + const right_foot = exports.IDICT["right_foot"]["artery"]; + flow(CB, neck, bf_art.get([1])); // CB to neck.art + flow(neck, head, bf_art.get([0])); // neck.art to head.art + flow(head + 1, neck + 1, bf_vein.get([0])); // head.vein to neck.vein + flow(neck + 1, CB, bf_vein.get([1])); // neck.vein to CB + flow(CB, chest, bf_art.get([2])); // CB to chest.art + flow(chest + 1, CB, bf_vein.get([2])); // chest.vein to CB + flow(CB, back, bf_art.get([3])); // CB to back.art + flow(back + 1, CB, bf_vein.get([3])); // back.vein to CB + flow(CB, pelvis, bf_art.get([4])); // CB to pelvis.art + flow(pelvis + 1, CB, bf_vein.get([4])); // pelvis.vein to CB + flow(CB, left_shoulder, bf_art.get([5])); // CB to left_shoulder.art + flow(left_shoulder, left_arm, bf_art.get([6])); // left_shoulder.art to left_arm.art + flow(left_arm, left_hand, bf_art.get([7])); // left_arm.art to left_hand.art + flow(left_hand + 1, left_arm + 1, bf_vein.get([7])); // left_hand.vein to left_arm.vein + flow(left_arm + 1, left_shoulder + 1, bf_vein.get([6])); // left_arm.vein to left_shoulder.vein + flow(left_shoulder + 1, CB, bf_vein.get([5])); // left_shoulder.vein to CB + flow(left_hand + 2, left_arm + 2, bf_ava_hand); // left_hand.sfvein to left_arm.sfvein + flow(left_arm + 2, left_shoulder + 2, bf_ava_hand); // left_arm.sfvein to left_shoulder.sfvein + flow(left_shoulder + 2, CB, bf_ava_hand); // left_shoulder.sfvein to CB + flow(CB, right_shoulder, bf_art.get([8])); // CB to right_shoulder.art + flow(right_shoulder, right_arm, bf_art.get([9])); // right_shoulder.art to right_arm.art + flow(right_arm, right_hand, bf_art.get([10])); // right_arm.art to right_hand.art + flow(right_hand + 1, right_arm + 1, bf_vein.get([10])); // right_hand.vein to right_arm.vein + flow(right_arm + 1, right_shoulder + 1, bf_vein.get([9])); // right_arm.vein to right_shoulder.vein + flow(right_shoulder + 1, CB, bf_vein.get([8])); // right_shoulder.vein to CB + flow(right_hand + 2, right_arm + 2, bf_ava_hand); // right_hand.sfvein to right_arm.sfvein + flow(right_arm + 2, right_shoulder + 2, bf_ava_hand); // right_arm.sfvein to right_shoulder.sfvein + flow(right_shoulder + 2, CB, bf_ava_hand); // right_shoulder.sfvein to CB + flow(pelvis, left_thigh, bf_art.get([11])); // pelvis to left_thigh.art + flow(left_thigh, left_leg, bf_art.get([12])); // left_thigh.art to left_leg.art + flow(left_leg, left_foot, bf_art.get([13])); // left_leg.art to left_foot.art + flow(left_foot + 1, left_leg + 1, bf_vein.get([13])); // left_foot.vein to left_leg.vein + flow(left_leg + 1, left_thigh + 1, bf_vein.get([12])); // left_leg.vein to left_thigh.vein + flow(left_thigh + 1, pelvis + 1, bf_vein.get([11])); // left_thigh.vein to pelvis + flow(left_foot + 2, left_leg + 2, bf_ava_foot); // left_foot.sfvein to left_leg.sfvein + flow(left_leg + 2, left_thigh + 2, bf_ava_foot); // left_leg.sfvein to left_thigh.sfvein + flow(left_thigh + 2, pelvis + 1, bf_ava_foot); // left_thigh.vein to pelvis + flow(pelvis, right_thigh, bf_art.get([14])); // pelvis to right_thigh.art + flow(right_thigh, right_leg, bf_art.get([15])); // right_thigh.art to right_leg.art + flow(right_leg, right_foot, bf_art.get([16])); // right_leg.art to right_foot.art + flow(right_foot + 1, right_leg + 1, bf_vein.get([16])); // right_foot.vein to right_leg.vein + flow(right_leg + 1, right_thigh + 1, bf_vein.get([15])); // right_leg.vein to right_thigh.vein + flow(right_thigh + 1, pelvis + 1, bf_vein.get([14])); // right_thigh.vein to pelvis + flow(right_foot + 2, right_leg + 2, bf_ava_foot); // right_foot.sfvein to right_leg.sfvein + flow(right_leg + 2, right_thigh + 2, bf_ava_foot); // right_leg.sfvein to right_thigh.sfvein + flow(right_thigh + 2, pelvis + 1, bf_ava_foot); // right_thigh.vein to pelvis + return arr83; +} +exports.whole_body = whole_body; +_b = (function () { + const index_by_layer = (layer) => { + const out_index = []; + for (const bn of exports.BODY_NAMES) { + for (const ln of exports.LAYER_NAMES) { + if (layer.toLowerCase() === ln && exports.IDICT[bn][ln] !== null) { + out_index.push(exports.IDICT[bn][ln]); + } + } + } + return out_index; + }; + const valid_index_by_layer = (key) => { + const out_index = []; + for (let i = 0; i < exports.BODY_NAMES.length; i++) { + const bn = exports.BODY_NAMES[i]; + if (exports.IDICT[bn][key] !== null) { + out_index.push(i); + } + } + return out_index; + }; + const index = {}; + const vindex = {}; + for (const key of exports.LAYER_NAMES) { + index[key] = index_by_layer(key); + vindex[key] = valid_index_by_layer(key); + } + return [index, vindex]; +})(), exports.INDEX = _b[0], exports.VINDEX = _b[1]; diff --git a/lib/cjs/jos3_functions/thermoregulation/ava_blood_flow.js b/lib/cjs/jos3_functions/thermoregulation/ava_blood_flow.js new file mode 100644 index 0000000..bac3bb7 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/ava_blood_flow.js @@ -0,0 +1,75 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ava_blood_flow = void 0; +const supa_js_1 = require("../../supa.js"); +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const bfb_rate_js_1 = require("../bfb_rate.js"); +const math = __importStar(require("mathjs")); +/** + * @typedef AvaBloodFlowResult + * @type {object} + * @property {number} bf_ava_hand - AVA blood flow rate at hand [L/h]. + * @property {number} bf_ava_foot - AVA blood flow rate at foot [L/h]. + */ +/** + * Calculate areteriovenous anastmoses (AVA) blood flow rate [L/h] based on + * Takemori's model, 1995. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m] + * @param {number} [weight=74.43] - Body weight [kg] + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi" + * @param {number} [age=20] - age [years] + * @param {number} [ci=2.59] - Cardiac index [L/min/m2] + * + * @returns {AvaBloodFlowResult} AVA blood flow rate at hand and foot [L/h] + */ +function ava_blood_flow(err_cr, err_sk, height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age, ci = JOS3Defaults_js_1.default.cardiac_index) { + // Cal. mean error body core temp. + let cap_bcr = [10.2975, 9.3935, 4.488]; + let err_bcr = math.sum(math.dotMultiply(err_cr.subset(math.index(math.range(2, 5))), cap_bcr)) / math.sum(cap_bcr); + // Cal. mean error skin temp. + let err_msk = math.sum(math.dotMultiply(err_sk, JOS3Defaults_js_1.default.local_bsa)) / + math.sum(JOS3Defaults_js_1.default.local_bsa); + // Openness of AVA [-] + let sig_ava_hand = 0.265 * (err_msk + 0.43) + 0.953 * (err_bcr + 0.1905) + 0.9126; + let sig_ava_foot = 0.265 * (err_msk - 0.997) + 0.953 * (err_bcr + 0.0095) + 0.9126; + sig_ava_hand = Math.min(sig_ava_hand, 1); + sig_ava_hand = Math.max(sig_ava_hand, 0); + sig_ava_foot = Math.min(sig_ava_foot, 1); + sig_ava_foot = Math.max(sig_ava_foot, 0); + // Basal blood flow rate to the standard body [-] + let bfbrate = (0, bfb_rate_js_1.bfb_rate)(height, weight, bsa_equation, age, ci); + // AVA blood flow rate [L/h] + let bf_ava_hand = 1.71 * bfbrate * sig_ava_hand; + let bf_ava_foot = 2.16 * bfbrate * sig_ava_foot; + return { bf_ava_hand, bf_ava_foot }; +} +exports.ava_blood_flow = ava_blood_flow; diff --git a/lib/cjs/jos3_functions/thermoregulation/basal_met.js b/lib/cjs/jos3_functions/thermoregulation/basal_met.js new file mode 100644 index 0000000..fa870b2 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/basal_met.js @@ -0,0 +1,55 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.basal_met = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +/** + * Calculate basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {string} [bmr_equation="harris-benedict"] - Choose harris-benedict or ganpule. + * + * @returns {number} Basal metabolic rate [W]. + */ +function basal_met(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, age = JOS3Defaults_js_1.default.age, sex = JOS3Defaults_js_1.default.sex, bmr_equation = JOS3Defaults_js_1.default.bmr_equation) { + const valid_equations = [ + "harris-benedict", + "harris-benedict_origin", + "japanese", + "ganpule", + ]; + if (!valid_equations.includes(bmr_equation)) { + throw new Error(`Invalid BMR equation. Must be one of ${valid_equations.join(", ")}`); + } + let bmr; + switch (bmr_equation) { + case "harris-benedict": + bmr = + sex === "male" + ? 88.362 + 13.397 * weight + 500.3 * height - 5.677 * age + : 447.593 + 9.247 * weight + 479.9 * height - 4.33 * age; + break; + case "harris-benedict_origin": + bmr = + sex === "male" + ? 66.473 + 13.7516 * weight + 500.33 * height - 6.755 * age + : 655.0955 + 9.5634 * weight + 184.96 * height - 4.6756 * age; + break; + case "japanese": + case "ganpule": + // Ganpule et al., 2007, https://doi.org/10.1038/sj.ejcn.1602645 + bmr = + sex === "male" + ? 0.0481 * weight + 2.34 * height - 0.0138 * age - 0.4235 + : 0.0481 * weight + 2.34 * height - 0.0138 * age - 0.9708; + bmr *= 1000 / 4.186; + break; + } + return bmr * 0.048; // [kcal/day] to [W] +} +exports.basal_met = basal_met; diff --git a/lib/cjs/jos3_functions/thermoregulation/clo_area_factor.js b/lib/cjs/jos3_functions/thermoregulation/clo_area_factor.js new file mode 100644 index 0000000..2f50c08 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/clo_area_factor.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.clo_area_factor = void 0; +/** + * Calculate clothing area factor + * + * @param {math.Matrix} clo - Clothing insulation. + * + * @returns {math.Matrix} clothing area factor. + */ +function clo_area_factor(clo) { + return clo.map((clo) => (clo < 0.5 ? clo * 0.2 + 1 : clo * 0.1 + 1.05)); +} +exports.clo_area_factor = clo_area_factor; diff --git a/lib/cjs/jos3_functions/thermoregulation/conv_coef.js b/lib/cjs/jos3_functions/thermoregulation/conv_coef.js new file mode 100644 index 0000000..cea4d8f --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/conv_coef.js @@ -0,0 +1,127 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.conv_coef = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const math = __importStar(require("mathjs")); +/** + * Calculate convective heat transfer coefficient (hc) [W/(m2*K)] + * + * @param {string} [posture=JOS3Defaults.posture] - Select posture from standing, sitting, lying, sedentary or supine. The default is "standing". + * @param {math.Matrix} [v=JOS3Defaults.air_speed] - Air velocity [m/s]. If Iterable is input, its length should be 17. The default is 0.1. + * @param {math.Matrix} [tdb=JOS3Defaults.dry_bulb_air_temperature] - Air temperature [°C]. If Iterable is input, its length should be 17. The default is 28.8. + * @param {math.Matrix} [t_skin=JOS3Defaults.skin_temperature] - Skin temperature [°C]. If Iterable is input, its length should be 17. The default is 34.0. + * + * @returns {math.Matrix} Convective heat transfer coefficient (hc) [W/(m2*K)]. + * + * @see {@link https://doi.org/10.3130/aija.62.45_5 | Ichihara et al., 1997} + * @see {@link https://doi.org/10.20718/jjpa.13.1_17 | Kurazumi et al., 2008} + */ +function conv_coef(posture = JOS3Defaults_js_1.default.posture, v = math.multiply(math.ones(17), JOS3Defaults_js_1.default.air_speed), tdb = math.multiply(math.ones(17), JOS3Defaults_js_1.default.dry_bulb_air_temperature), t_skin = math.multiply(math.ones(17), JOS3Defaults_js_1.default.skin_temperature)) { + // Convert v to math.matrix + v = math.isMatrix(v) ? v : math.matrix(v); + /** + * Natural convection + * + * @param {string} posture + * @param {math.Matrix} tdb + * @param {math.Matrix} t_skin + * + * @return {math.Matrix} + */ + const natural_convection = (posture, tdb, t_skin) => { + posture = posture.toLowerCase(); + const valid_postures = [ + "standing", + "sitting", + "lying", + "sedentary", + "supine", + ]; + if (!valid_postures.includes(posture)) { + let postures = valid_postures.join(", "); + throw new Error(`Invalid posture ${posture}. Must be one of ${postures}.`); + } + let hc_natural; + switch (posture) { + case "standing": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + hc_natural = math.matrix([ + 4.48, 4.48, 2.97, 2.91, 2.85, 3.61, 3.55, 3.67, 3.61, 3.55, 3.67, 2.8, + 2.04, 2.04, 2.8, 2.04, 2.04, + ]); + break; + case "sitting": + case "sedentary": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + hc_natural = math.matrix([ + 4.75, 4.75, 3.12, 2.48, 1.84, 3.76, 3.62, 2.06, 3.76, 3.62, 2.06, + 2.98, 2.98, 2.62, 2.98, 2.98, 2.62, + ]); + break; + case "lying": + case "supine": + // Kurazumi et al., 2008, https://doi.org/10.20718/jjpa.13.1_17 + // The values are applied under cold environment. + let hc_a = math.matrix([ + 1.105, 1.105, 1.211, 1.211, 1.211, 0.913, 2.081, 2.178, 0.913, 2.081, + 2.178, 0.945, 0.385, 0.2, 0.945, 0.385, 0.2, + ]); + let hc_b = math.matrix([ + 0.345, 0.345, 0.046, 0.046, 0.046, 0.373, 0.85, 0.297, 0.373, 0.85, + 0.297, 0.447, 0.58, 0.966, 0.447, 0.58, 0.966, + ]); + hc_natural = math.dotMultiply(hc_a, math.dotPow(math.abs(math.subtract(tdb, t_skin)), hc_b)); + break; + } + return hc_natural; + }; + /** + * Forced convection + * + * @param v {math.Matrix} + * + * @return {math.Matrix} + */ + const forced_convection = (v) => { + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + let hc_a = math.matrix([ + 15.0, 15.0, 11.0, 17.0, 13.0, 17.0, 17.0, 20.0, 17.0, 17.0, 20.0, 14.0, + 15.8, 15.1, 14.0, 15.8, 15.1, + ]); + let hc_b = math.matrix([ + 0.62, 0.62, 0.67, 0.49, 0.6, 0.59, 0.61, 0.6, 0.59, 0.61, 0.6, 0.61, 0.74, + 0.62, 0.61, 0.74, 0.62, + ]); + return math.dotMultiply(hc_a, math.dotPow(v, hc_b)); + }; + let hc_natural = natural_convection(posture, tdb, t_skin); + let hc_forced = forced_convection(v); + return v.map((z, idx) => z < 0.2 ? hc_natural.get(idx) : hc_forced.get(idx)); +} +exports.conv_coef = conv_coef; diff --git a/lib/cjs/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js b/lib/cjs/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js new file mode 100644 index 0000000..ff58dc7 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js @@ -0,0 +1,86 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.cr_ms_fat_blood_flow = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const bfb_rate_js_1 = require("../bfb_rate.js"); +const matrix_js_1 = require("../matrix.js"); +const math = __importStar(require("mathjs")); +/** + * @typedef CrMsFatBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_core - Core blood flow rate [L/h]. + * @property {math.MathCollection} bf_muscle - Muscle blood flow rate [L/h]. + * @property {math.MathCollection} bf_fat - Fat blood flow rate [L/h]. + */ +/** + * Calculate core, muscle and fat blood flow rate [L/h]. + * + * @param {math.MathCollection} q_work - Heat production by work [W]. + * @param {math.MathCollection} q_shiv - Heat production by shivering [W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose from "dubois","takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - Age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {CrMsFatBloodFlowResult} - Core, muscle and fat blood flow rate [L/h]. + */ +function cr_ms_fat_blood_flow(q_work, q_shiv, height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age, ci = JOS3Defaults_js_1.default.cardiac_index) { + // Basal blood flow rate [L/h] + // core, CBFB + let bfb_core = math.matrix([ + 35.251, 15.24, 89.214, 87.663, 18.686, 1.808, 0.94, 0.217, 1.808, 0.94, + 0.217, 1.406, 0.164, 0.08, 1.406, 0.164, 0.08, + ]); + // muscle, MSBFB + let bfb_muscle = math.matrix([ + 0.682, 0.0, 0.0, 0.0, 12.614, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + // fat, FTBFB + let bfb_fat = math.matrix([ + 0.265, 0.0, 0.0, 0.0, 2.219, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + let bfbrate = (0, bfb_rate_js_1.bfb_rate)(height, weight, bsa_equation, age, ci); + let bf_core = math.dotMultiply(bfb_core, bfbrate); + let bf_muscle = math.dotMultiply(bfb_muscle, bfbrate); + let bf_fat = math.dotMultiply(bfb_fat, bfbrate); + for (let i = 0; i < matrix_js_1.BODY_NAMES.length; i++) { + let bn = matrix_js_1.BODY_NAMES[i]; + if (matrix_js_1.IDICT[bn]["muscle"] !== null) { + bf_muscle.set([i], bf_muscle.get([i]) + (q_work.get([i]) + q_shiv.get([i])) / 1.163); + } + else { + bf_core.set([i], bf_core.get([i]) + (q_work.get([i]) + q_shiv.get([i])) / 1.163); + } + } + return { bf_core, bf_muscle, bf_fat }; +} +exports.cr_ms_fat_blood_flow = cr_ms_fat_blood_flow; diff --git a/lib/cjs/jos3_functions/thermoregulation/dry_r.js b/lib/cjs/jos3_functions/thermoregulation/dry_r.js new file mode 100644 index 0000000..851908b --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/dry_r.js @@ -0,0 +1,47 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.dry_r = void 0; +const clo_area_factor_js_1 = require("./clo_area_factor.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate total sensible thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * + * @returns {math.Matrix} Total sensible thermal resistance between skin and ambient. + */ +function dry_r(hc, hr, clo) { + if (hc.toArray().some((x) => x < 0) || hr.toArray().some((x) => x < 0)) { + throw new Error("Input parameters hc and hr must be non-negative."); + } + let fcl = (0, clo_area_factor_js_1.clo_area_factor)(clo); + let r_a = math.dotDivide(1, math.add(hc, hr)); + let r_cl = math.dotMultiply(0.155, clo); + return math.add(math.dotDivide(r_a, fcl), r_cl); +} +exports.dry_r = dry_r; diff --git a/lib/cjs/jos3_functions/thermoregulation/error_signals.js b/lib/cjs/jos3_functions/thermoregulation/error_signals.js new file mode 100644 index 0000000..6dfa67e --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/error_signals.js @@ -0,0 +1,55 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.error_signals = void 0; +const math = __importStar(require("mathjs")); +/** + * @typedef ErrorSignalsResult + * @type {object} + * @property {number} wrms - Warm signal [°C]. + * @property {number} clds - Cold signal [°C]. + */ +/** + * Calculate WRMS and CLDS signals of thermoregulation. + * + * @param {math.MathCollection} [err_sk=0] - Difference between set-point and skin temperatures [°C]. + * If the provided value is an array, its length should be 17. + * + * @returns {ErrorSignalsResult} an object containing the results of the calculation. + */ +function error_signals(err_sk = math.zeros(17)) { + let receptor = math.matrix([ + 0.0549, 0.0146, 0.1492, 0.1321, 0.2122, 0.0227, 0.0117, 0.0923, 0.0227, + 0.0117, 0.0923, 0.0501, 0.0251, 0.0167, 0.0501, 0.0251, 0.0167, + ]); + let wrm = err_sk.map((n) => math.max(n, 0)); + wrm = math.dotMultiply(wrm, receptor); + let wrms = math.sum(wrm); + let cld = err_sk.map((n) => math.min(n, 0)); + cld = math.dotMultiply(cld, math.dotMultiply(receptor, -1)); + let clds = math.sum(cld); + return { wrms, clds }; +} +exports.error_signals = error_signals; diff --git a/lib/cjs/jos3_functions/thermoregulation/evaporation.js b/lib/cjs/jos3_functions/thermoregulation/evaporation.js new file mode 100644 index 0000000..38a97e3 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/evaporation.js @@ -0,0 +1,94 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.evaporation = exports.antoine = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const error_signals_js_1 = require("./error_signals.js"); +const bsa_rate_js_1 = require("../bsa_rate.js"); +const math = __importStar(require("mathjs")); +/** + * Calculates the Antoine equation for a given temperature value. + * + * @param {number} x - The temperature value in Kelvin. + * @returns {number} - The vapor pressure calculated using the Antoine equation. + */ +const antoine = (x) => Math.pow(Math.E, (16.6536 - 4030.183 / (x + 235))); +exports.antoine = antoine; +/** + * @typedef EvaporationResult + * @type {object} + * @property {math.MathCollection} wet - Local skin wettedness [-]. + * @property {math.MathCollection} e_sk - Evaporative heat loss at the skin by sweating and diffuse [W]. + * @property {math.MathCollection} e_max - Maximum evaporative heat loss at the skin [W]. + * @property {math.MathCollection} e_sweat - Evaporative heat loss at the skin by only sweating [W]. + */ +/** + * Calculate evaporative heat loss. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_skin - Skin temperatures [°C]. + * @param {math.MathCollection} tdb - Air temperatures at local body segments [°C]. + * @param {math.MathCollection} rh - Relative humidity at local body segments [%]. + * @param {math.MathCollection} ret - Total evaporative thermal resistances [m2.K/W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * + * @returns {EvaporationResult} an object containing the results of the calculation. + */ +function evaporation(err_cr, err_sk, t_skin, tdb, rh, ret, height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age) { + let { wrms, clds } = (0, error_signals_js_1.error_signals)(err_sk); + let bsar = (0, bsa_rate_js_1.bsa_rate)(height, weight, bsa_equation); + let bsa = math.dotMultiply(JOS3Defaults_js_1.default.local_bsa, bsar); + let p_a = math.dotDivide(math.dotMultiply(tdb.map(exports.antoine), rh), 100); + let p_sk_s = t_skin.map(exports.antoine); + let e_max = math.dotMultiply(math.dotDivide(math.subtract(p_sk_s, p_a), ret), bsa); + e_max = e_max.map((e_max) => (e_max === 0 ? 0.001 : e_max)); + let skin_sweat = [ + 0.064, 0.017, 0.146, 0.129, 0.206, 0.051, 0.026, 0.0155, 0.051, 0.026, + 0.0155, 0.073, 0.036, 0.0175, 0.073, 0.036, 0.0175, + ]; + let sig_sweat = 371.2 * err_cr.get([0]) + 33.64 * (wrms - clds); + sig_sweat = sig_sweat > 0 ? sig_sweat : 0; + sig_sweat *= bsar; + let sd_sweat = age < 60 + ? math.ones(17) + : math.matrix([ + 0.69, 0.69, 0.59, 0.52, 0.4, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.4, + 0.4, 0.4, 0.4, 0.4, 0.4, + ]); + let e_sweat = math.multiply(skin_sweat, sig_sweat, sd_sweat, math.dotPow(2, math.divide(err_sk, 10))); + let wet = math.add(0.06, math.multiply(0.94, math.dotDivide(e_sweat, e_max))); + wet = wet.map((n) => (n > 1 ? 1 : n)); + let e_sk = math.dotMultiply(wet, e_max); + e_sweat = math.dotMultiply(math.divide(math.subtract(wet, 0.06), 0.94), e_max); + return { wet, e_sk, e_max, e_sweat }; +} +exports.evaporation = evaporation; diff --git a/lib/cjs/jos3_functions/thermoregulation/fixed_hc.js b/lib/cjs/jos3_functions/thermoregulation/fixed_hc.js new file mode 100644 index 0000000..3645842 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/fixed_hc.js @@ -0,0 +1,42 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fixed_hc = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const math = __importStar(require("mathjs")); +/** + * Fixes hc values to fit two-node-model's values. + */ +function fixed_hc(hc, v) { + const local_bsa_sum = math.sum(JOS3Defaults_js_1.default.local_bsa); + let mean_hc = math.sum(math.dotMultiply(hc, JOS3Defaults_js_1.default.local_bsa)) / local_bsa_sum; + let mean_va = math.sum(math.dotMultiply(v, JOS3Defaults_js_1.default.local_bsa)) / local_bsa_sum; + let mean_hc_whole = Math.max(3, 8.600001 * Math.pow(mean_va, 0.53)); + return math.dotDivide(math.dotMultiply(hc, mean_hc_whole), mean_hc); +} +exports.fixed_hc = fixed_hc; diff --git a/lib/cjs/jos3_functions/thermoregulation/fixed_hr.js b/lib/cjs/jos3_functions/thermoregulation/fixed_hr.js new file mode 100644 index 0000000..1aa6876 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/fixed_hr.js @@ -0,0 +1,43 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fixed_hr = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const math = __importStar(require("mathjs")); +/** + * Fixes hr values to fit two-node-model's values. + * + * @param {math.MathCollection} hr + * @return {math.Matrix} + */ +function fixed_hr(hr) { + let mean_hr = math.sum(math.dotMultiply(hr, JOS3Defaults_js_1.default.local_bsa)) / + math.sum(JOS3Defaults_js_1.default.local_bsa); + return math.dotDivide(math.dotMultiply(hr, 4.7), mean_hr); +} +exports.fixed_hr = fixed_hr; diff --git a/lib/cjs/jos3_functions/thermoregulation/local_mbase.js b/lib/cjs/jos3_functions/thermoregulation/local_mbase.js new file mode 100644 index 0000000..c16be85 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/local_mbase.js @@ -0,0 +1,70 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.local_mbase = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const basal_met_js_1 = require("./basal_met.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate local basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex='male'] - Sex (male or female). + * @param {string} [bmr_equation='harris-benedict'] - BMR equation to use (harris-benedict or ganpule). + * + * @returns {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + */ +function local_mbase(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, age = JOS3Defaults_js_1.default.age, sex = JOS3Defaults_js_1.default.sex, bmr_equation = JOS3Defaults_js_1.default.bmr_equation) { + let mbase_all = (0, basal_met_js_1.basal_met)(height, weight, age, sex, bmr_equation); + let mbf_cr = math.matrix([ + 0.19551, 0.00324, 0.28689, 0.25677, 0.09509, 0.01435, 0.00409, 0.00106, + 0.01435, 0.00409, 0.00106, 0.01557, 0.00422, 0.0025, 0.01557, 0.00422, + 0.0025, + ]); + let mbf_ms = math.matrix([ + 0.00252, 0.0, 0.0, 0.0, 0.04804, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + ]); + let mbf_fat = math.matrix([ + 0.00127, 0.0, 0.0, 0.0, 0.0095, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + let mbf_sk = math.matrix([ + 0.00152, 0.00033, 0.00211, 0.00187, 0.003, 0.00059, 0.00031, 0.00059, + 0.00059, 0.00031, 0.00059, 0.00144, 0.00027, 0.00118, 0.00144, 0.00027, + 0.00118, + ]); + let mbase_cr = math.dotMultiply(mbf_cr, mbase_all); + let mbase_ms = math.dotMultiply(mbf_ms, mbase_all); + let mbase_fat = math.dotMultiply(mbf_fat, mbase_all); + let mbase_sk = math.dotMultiply(mbf_sk, mbase_all); + return [mbase_cr, mbase_ms, mbase_fat, mbase_sk]; +} +exports.local_mbase = local_mbase; diff --git a/lib/cjs/jos3_functions/thermoregulation/local_q_work.js b/lib/cjs/jos3_functions/thermoregulation/local_q_work.js new file mode 100644 index 0000000..32dbc86 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/local_q_work.js @@ -0,0 +1,48 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.local_q_work = void 0; +const math = __importStar(require("mathjs")); +/** + * Calculate local thermogenesis by work [W]. + * + * @param {number} bmr - Basal metabolic rate [W] + * @param {number} par - Physical activity ratio [-] + * @throws {Error} If par is less than 1 + * + * @return {math.MathCollection} q_work - Local thermogenesis by work [W] + */ +function local_q_work(bmr, par) { + if (par < 1) { + throw new Error("par must be greater than or equal to 1"); + } + let q_work_all = (par - 1) * bmr; + let workf = math.matrix([ + 0, 0, 0.091, 0.08, 0.129, 0.0262, 0.0139, 0.005, 0.0262, 0.0139, 0.005, + 0.201, 0.099, 0.005, 0.201, 0.099, 0.005, + ]); + return math.dotMultiply(workf, q_work_all); +} +exports.local_q_work = local_q_work; diff --git a/lib/cjs/jos3_functions/thermoregulation/nonshivering.js b/lib/cjs/jos3_functions/thermoregulation/nonshivering.js new file mode 100644 index 0000000..7fac480 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/nonshivering.js @@ -0,0 +1,95 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.nonshivering = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const error_signals_js_1 = require("./error_signals.js"); +const bsa_rate_js_1 = require("../bsa_rate.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate local metabolic rate by non-shivering [W] + * + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {boolean} [cold_acclimation=false] - Whether the subject acclimates cold environment or not. + * @param {boolean} [batpositive=true] - Whether BAT activity is positive or not. + * + * @returns {math.MathCollection} q_nst - Local metabolic rate by non-shivering [W]. + */ +function nonshivering(err_sk, height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age, cold_acclimation = false, batpositive = true) { + // NST (Non-Shivering Thermogenesis) model, Asaka, 2016 + let { clds } = (0, error_signals_js_1.error_signals)(err_sk); + // BMI (Body Mass Index) + let bmi = weight / Math.pow(height, 2); + // BAT: brown adipose tissue [SUV] + let bat = Math.pow(10, (-0.10502 * bmi + 2.7708)); + if (age < 30) { + bat *= 1.61; + } + else if (age < 40) { + bat *= 1.0; + } + else { + bat *= 0.8; + } + if (cold_acclimation) { + bat += 3.46; + } + if (!batpositive) { + // incidence age factor: T.Yoneshiro 2011 + if (age < 30) { + bat *= 44 / 83; + } + else if (age < 40) { + bat *= 15 / 38; + } + else if (age < 50) { + bat *= 7 / 26; + } + else if (age < 60) { + bat *= 1 / 8; + } + else { + bat *= 0; + } + } + // NST limit + let thres = 1.8 * bat + 2.43 + 5.62; // [W] + let sig_nst = 2.8 * clds; // [W] + sig_nst = Math.min(sig_nst, thres); + let nstf = math.matrix([ + 0.0, 0.19, 0.0, 0.19, 0.19, 0.215, 0.0, 0.0, 0.215, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + let bsar = (0, bsa_rate_js_1.bsa_rate)(height, weight, bsa_equation); + return math.dotMultiply(math.dotMultiply(bsar, nstf), sig_nst); +} +exports.nonshivering = nonshivering; diff --git a/lib/cjs/jos3_functions/thermoregulation/operative_temp.js b/lib/cjs/jos3_functions/thermoregulation/operative_temp.js new file mode 100644 index 0000000..6796af0 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/operative_temp.js @@ -0,0 +1,42 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.operative_temp = void 0; +const supa_js_1 = require("../../supa.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate operative temperature [°C] + * + * @param {math.MathCollection} tdb - Air temperature [°C] + * @param {math.MathCollection} tr - Mean radiant temperature [°C] + * @param {math.MathCollection} hc - Convective heat transfer coefficient [W/(m2*K)] + * @param {math.MathCollection} hr - Radiative heat transfer coefficient [W/(m2*K)] + + * @returns {math.MathCollection} Operative temperature [°C] + */ +function operative_temp(tdb, tr, hc, hr) { + return math.dotDivide(math.add(math.dotMultiply(hc, tdb), math.dotMultiply(hr, tr)), math.add(hc, hr)); +} +exports.operative_temp = operative_temp; diff --git a/lib/cjs/jos3_functions/thermoregulation/rad_coef.js b/lib/cjs/jos3_functions/thermoregulation/rad_coef.js new file mode 100644 index 0000000..058fbfa --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/rad_coef.js @@ -0,0 +1,74 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.rad_coef = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const math = __importStar(require("mathjs")); +/** + * Calculate radiative heat transfer coefficient (hr) [W/(m2*K)] + * + * @param {string} posture - Select posture from standing, sitting, lying, sedentary or supine. Default is "standing". + * + * @returns {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + */ +function rad_coef(posture = JOS3Defaults_js_1.default.posture) { + const valid_postures = [ + "standing", + "sitting", + "lying", + "sedentary", + "supine", + ]; + if (!valid_postures.includes(posture)) { + let postures = valid_postures.join(", "); + throw new Error(`Invalid posture ${posture}. Must be one of ${postures}.`); + } + switch (posture) { + case "standing": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + return math.matrix([ + 4.89, 4.89, 4.32, 4.09, 4.32, 4.55, 4.43, 4.21, 4.55, 4.43, 4.21, 4.77, + 5.34, 6.14, 4.77, 5.34, 6.14, + ]); + case "sitting": + case "sedentary": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + return math.matrix([ + 4.96, 4.96, 3.99, 4.64, 4.21, 4.96, 4.21, 4.74, 4.96, 4.21, 4.74, 4.1, + 4.74, 6.36, 4.1, 4.74, 6.36, + ]); + case "lying": + case "supine": + // Kurazumi et al., 2008, https://doi.org/10.20718/jjpa.13.1_17 + return math.matrix([ + 5.475, 5.475, 3.463, 3.463, 3.463, 4.249, 4.835, 4.119, 4.249, 4.835, + 4.119, 4.44, 5.547, 6.085, 4.44, 5.547, 6.085, + ]); + } +} +exports.rad_coef = rad_coef; diff --git a/lib/cjs/jos3_functions/thermoregulation/resp_heat_loss.js b/lib/cjs/jos3_functions/thermoregulation/resp_heat_loss.js new file mode 100644 index 0000000..d3226ae --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/resp_heat_loss.js @@ -0,0 +1,24 @@ +"use strict"; +/** + * @typedef RespHeatLossResult + * @type {object} + * @property {number} res_sh - Sensible heat loss by respiration [W]. + * @property {number} res_lh - Latent heat loss by respiration [W]. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.resp_heat_loss = void 0; +/** + * Calculate heat loss by respiration [W]. + * + * @param {number} tdb - Dry bulb air temperature [oC]. + * @param {number} p_a - Water vapor pressure in the ambient air [kPa]. + * @param {number} q_thermogenesis_total - Total thermogenesis [W]. + + * @return {RespHeatLossResult} res_sh, res_lh - Sensible and latent heat loss by respiration [W]. + */ +function resp_heat_loss(tdb, p_a, q_thermogenesis_total) { + let res_sh = 0.0014 * q_thermogenesis_total * (34 - tdb); // sensible heat loss + let res_lh = 0.0173 * q_thermogenesis_total * (5.87 - p_a); // latent heat loss + return { res_sh, res_lh }; +} +exports.resp_heat_loss = resp_heat_loss; diff --git a/lib/cjs/jos3_functions/thermoregulation/shivering.js b/lib/cjs/jos3_functions/thermoregulation/shivering.js new file mode 100644 index 0000000..30f69ef --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/shivering.js @@ -0,0 +1,133 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.shivering = exports.set_pre_shiv = exports.PRE_SHIV = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const error_signals_js_1 = require("./error_signals.js"); +const bsa_rate_js_1 = require("../bsa_rate.js"); +const math = __importStar(require("mathjs")); +exports.PRE_SHIV = 0; +/** + * Sets the value of PRE_SHIV. + * + * @param {number} value - the value to set PRE_SHIV to + */ +function set_pre_shiv(value) { + exports.PRE_SHIV = value; +} +exports.set_pre_shiv = set_pre_shiv; +/** + * Calculate local thermogenesis by shivering [W]. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_core - Core and skin temperatures [°C]. + * @param {math.MathCollection} t_skin - Core and skin temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {number} [dtime=60] - Interval of analysis time. + * @param {object} options - Additional options. + * + * @returns {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + */ +function shivering(err_cr, err_sk, t_core, t_skin, height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age, sex = JOS3Defaults_js_1.default.sex, dtime = 60, options = {}) { + // Integrated error signal in the warm and cold receptors + let { clds } = (0, error_signals_js_1.error_signals)(err_sk); + // Distribution coefficient of thermogenesis by shivering + let shivf = math.matrix([ + 0.0339, 0.0436, 0.27394, 0.24102, 0.38754, 0.00243, 0.00137, 0.0002, + 0.00243, 0.00137, 0.0002, 0.0039, 0.00175, 0.00035, 0.0039, 0.00175, + 0.00035, + ]); + // Integrated error signal of shivering + let sig_shiv = 24.36 * clds * -err_cr.get([0]); + sig_shiv = Math.max(sig_shiv, 0); + if (options["shivering_threshold"]) { + // Asaka, 2016 + // Threshold of starting shivering + let tskm = math.sum(math.dotMultiply(t_skin, JOS3Defaults_js_1.default.local_bsa)) / + math.sum(JOS3Defaults_js_1.default.local_bsa); + let thres; + if (tskm < 31) { + thres = 36.6; + } + else { + thres = sex === "male" ? -0.2436 * tskm + 44.1 : -0.225 * tskm + 43.05; + } + // Second threshold of starting shivering + if (thres < t_core.get([0])) { + sig_shiv = 0; + } + } + if (options["limit_dshiv/dt"]) { + let dshiv = sig_shiv - exports.PRE_SHIV; + let limit_dshiv = options["limit_dshiv/dt"] === true + ? 0.0077 * dtime + : options["limit_dshiv/dt"] * dtime; + if (dshiv > limit_dshiv) { + sig_shiv = limit_dshiv + exports.PRE_SHIV; + } + else if (dshiv < -limit_dshiv) { + sig_shiv = -limit_dshiv + exports.PRE_SHIV; + } + } + exports.PRE_SHIV = sig_shiv; + // Signal sd_shiv by aging + let sd_shiv; + if (age < 30) { + sd_shiv = math.ones(17); + } + else if (age < 40) { + sd_shiv = math.multiply(math.ones(17), 0.97514); + } + else if (age < 50) { + sd_shiv = math.multiply(math.ones(17), 0.95028); + } + else if (age < 60) { + sd_shiv = math.multiply(math.ones(17), 0.92818); + } + else if (age < 70) { + sd_shiv = math.multiply(math.ones(17), 0.90055); + } + else if (age < 80) { + sd_shiv = math.multiply(math.ones(17), 0.86188); + } + else { + sd_shiv = math.multiply(math.ones(17), 0.82597); + } + // Ratio of body surface area to the standard body [-] + let bsar = (0, bsa_rate_js_1.bsa_rate)(height, weight, bsa_equation); + // Local thermogenesis by shivering [W] + let q_shiv = math.dotMultiply(math.dotMultiply(math.dotMultiply(shivf, bsar), sd_shiv), sig_shiv); + let x = q_shiv + 1; + return q_shiv; +} +exports.shivering = shivering; diff --git a/lib/cjs/jos3_functions/thermoregulation/skin_blood_flow.js b/lib/cjs/jos3_functions/thermoregulation/skin_blood_flow.js new file mode 100644 index 0000000..64f8a22 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/skin_blood_flow.js @@ -0,0 +1,75 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.skin_blood_flow = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const error_signals_js_1 = require("./error_signals.js"); +const bfb_rate_js_1 = require("../bfb_rate.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate skin blood flow rate (bf_skin) [L/h]. + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {math.MathCollection} bf_skin - Skin blood flow rate [L/h]. + */ +function skin_blood_flow(err_cr, err_sk, height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, age = JOS3Defaults_js_1.default.age, ci = JOS3Defaults_js_1.default.cardiac_index) { + let { wrms, clds } = (0, error_signals_js_1.error_signals)(err_sk); + let bfb_sk = math.matrix([ + 1.754, 0.325, 1.967, 1.475, 2.272, 0.91, 0.508, 1.114, 0.91, 0.508, 1.114, + 1.456, 0.651, 0.934, 1.456, 0.651, 0.934, + ]); + let skin_dilat = math.matrix([ + 0.0692, 0.0992, 0.058, 0.0679, 0.0707, 0.04, 0.0373, 0.0632, 0.04, 0.0373, + 0.0632, 0.0736, 0.0411, 0.0623, 0.0736, 0.0411, 0.0623, + ]); + let skin_stric = math.matrix([ + 0.0213, 0.0213, 0.0638, 0.0638, 0.0638, 0.0213, 0.0213, 0.1489, 0.0213, + 0.0213, 0.1489, 0.0213, 0.0213, 0.1489, 0.0213, 0.0213, 0.1489, + ]); + let sig_dilat = 100.5 * err_cr.get([0]) + 6.4 * (wrms - clds); + sig_dilat = sig_dilat > 0 ? sig_dilat : 0; + let sig_stric = -10.8 * err_cr.get([0]) + -10.8 * (wrms - clds); + sig_stric = sig_stric > 0 ? sig_stric : 0; + let sd_stric = math.ones(17); + let sd_dilat = age < 60 + ? math.ones(17) + : math.matrix([ + 0.91, 0.91, 0.47, 0.47, 0.31, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, + 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, + ]); + let bf_skin = math.dotMultiply(math.dotMultiply(math.dotDivide(math.add(1, math.multiply(math.dotMultiply(skin_dilat, sd_dilat), sig_dilat)), math.add(1, math.multiply(math.dotMultiply(skin_stric, sd_stric), sig_stric))), bfb_sk), math.dotPow(2, math.divide(err_sk, 6))); + let bfb = (0, bfb_rate_js_1.bfb_rate)(height, weight, bsa_equation, age, ci); + return math.dotMultiply(bf_skin, bfb); +} +exports.skin_blood_flow = skin_blood_flow; diff --git a/lib/cjs/jos3_functions/thermoregulation/sum_bf.js b/lib/cjs/jos3_functions/thermoregulation/sum_bf.js new file mode 100644 index 0000000..b65b571 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/sum_bf.js @@ -0,0 +1,50 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sum_bf = void 0; +const math = __importStar(require("mathjs")); +/** + * Sum the total blood flow in various body parts. + * + * @param {math.MathCollection} bf_core - Blood flow rate in the core region [L/h]. + * @param {math.MathCollection} bf_muscle - Blood flow rate in the muscle region [L/h]. + * @param {math.MathCollection} bf_fat - Blood flow rate in the fat region [L/h]. + * @param {math.MathCollection} bf_skin - Blood flow rate in the skin region [L/h]. + * @param {number} bf_ava_hand - AVA blood flow rate in one hand [L/h]. + * @param {number} bf_ava_foot - AVA blood flow rate in one foot [L/h]. + * + * @returns {number} co - Cardiac output (the sum of the whole blood flow rate) [L/h]. + */ +function sum_bf(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot) { + let co = 0; + co += math.sum(bf_core); + co += math.sum(bf_muscle); + co += math.sum(bf_fat); + co += math.sum(bf_skin); + co += 2 * bf_ava_hand; + co += 2 * bf_ava_foot; + return co; +} +exports.sum_bf = sum_bf; diff --git a/lib/cjs/jos3_functions/thermoregulation/sum_m.js b/lib/cjs/jos3_functions/thermoregulation/sum_m.js new file mode 100644 index 0000000..57156c0 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/sum_m.js @@ -0,0 +1,66 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sum_m = void 0; +const matrix_js_1 = require("../matrix.js"); +const math = __importStar(require("mathjs")); +/** + * @typedef SumMResult + * @type {object} + * @property {math.MathCollection} q_thermogenesis_core - Total thermogenesis in core layer [W]. + * @property {math.MathCollection} q_thermogenesis_muscle - Total thermogenesis in muscle layer [W]. + * @property {math.MathCollection} q_thermogenesis_fat - Total thermogenesis in fat layer [W]. + * @property {math.MathCollection} q_thermogenesis_skin - Total thermogenesis in skin layer [W]. + */ +/** + * Calculate total thermogenesis in each layer [W]. + * + * @param {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + * @param {math.MathCollection} q_work - Local thermogenesis by work [W]. + * @param {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + * @param {math.MathCollection} q_nst - Local thermogenesis by non-shivering [W]. + * + * @return {SumMResult} Total thermogenesis in core, muscle, fat, skin layers [W]. + */ +function sum_m(mbase, q_work, q_shiv, q_nst) { + let [q_thermogenesis_core, q_thermogenesis_muscle, q_thermogenesis_fat, q_thermogenesis_skin,] = mbase; + for (let i = 0; i < matrix_js_1.BODY_NAMES.length; i++) { + let bn = matrix_js_1.BODY_NAMES[i]; + if (matrix_js_1.IDICT[bn]["muscle"] !== null) { + q_thermogenesis_muscle.set([i], q_thermogenesis_muscle.get([i]) + q_work.get([i]) + q_shiv.get([i])); + } + else { + q_thermogenesis_core.set([i], q_thermogenesis_core.get([i]) + q_work.get([i]) + q_shiv.get([i])); + } + } + q_thermogenesis_core = math.add(q_thermogenesis_core, q_nst); + return { + q_thermogenesis_core, + q_thermogenesis_muscle, + q_thermogenesis_fat, + q_thermogenesis_skin, + }; +} +exports.sum_m = sum_m; diff --git a/lib/cjs/jos3_functions/thermoregulation/wet_r.js b/lib/cjs/jos3_functions/thermoregulation/wet_r.js new file mode 100644 index 0000000..05b06d7 --- /dev/null +++ b/lib/cjs/jos3_functions/thermoregulation/wet_r.js @@ -0,0 +1,53 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.wet_r = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../JOS3Defaults.js")); +const clo_area_factor_js_1 = require("./clo_area_factor.js"); +const math = __importStar(require("mathjs")); +/** + * Calculate total evaporative thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * @param {number | math.Matrix} [i_clo=0.45] - Clothing vapor permeation efficiency [-]. + * @param {number} [lewis_rate=16.5] - Lewis rate [K/kPa]. + * + * @returns {math.Matrix} r_et - Total evaporative thermal resistance. + */ +function wet_r(hc, clo, i_clo = JOS3Defaults_js_1.default.clothing_vapor_permeation_efficiency, lewis_rate = JOS3Defaults_js_1.default.lewis_rate) { + if (hc.toArray().some((hc) => hc < 0)) { + throw new Error("Input parameter hc must be non-negative."); + } + let fcl = (0, clo_area_factor_js_1.clo_area_factor)(clo); + let r_cl = math.dotMultiply(0.155, clo); + let r_ea = math.dotDivide(1, math.dotMultiply(lewis_rate, hc)); + let r_ecl = math.dotDivide(r_cl, math.multiply(i_clo, lewis_rate)); + return math.add(math.dotDivide(r_ea, fcl), r_ecl); +} +exports.wet_r = wet_r; diff --git a/lib/cjs/jos3_functions/validate_body_parameters.js b/lib/cjs/jos3_functions/validate_body_parameters.js new file mode 100644 index 0000000..dd94036 --- /dev/null +++ b/lib/cjs/jos3_functions/validate_body_parameters.js @@ -0,0 +1,32 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validate_body_parameters = void 0; +const JOS3Defaults_js_1 = __importDefault(require("./JOS3Defaults.js")); +/** + * Validate the parameters: height, weight, age, and body fat percentage. + * + * @param {number} height - The height of the person in meters. + * @param {number} weight - The weight of the person in kilograms. + * @param {number} age - The age of the person in years. + * @param {number} body_fat - The body fat percentage as a fraction of total body mass. + + * @throws {Error} If any of the parameters are out of the specified range. + */ +function validate_body_parameters(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, age = JOS3Defaults_js_1.default.age, body_fat = JOS3Defaults_js_1.default.body_fat) { + if (height < 0.5 || height > 3.0) { + throw new Error("Height must be in the range [0.5, 3.0] meters."); + } + if (weight < 20 || weight > 200) { + throw new Error("Weight must be in the range [20, 200] kilograms."); + } + if (age < 5 || age > 100) { + throw new Error("Age must be in the range [5, 100] years."); + } + if (body_fat < 1 || body_fat > 90) { + throw new Error("Body Fat must be in the range [1, 90] (1% to 90%)."); + } +} +exports.validate_body_parameters = validate_body_parameters; diff --git a/lib/cjs/jos3_functions/weight_rate.js b/lib/cjs/jos3_functions/weight_rate.js new file mode 100644 index 0000000..1a1e8e9 --- /dev/null +++ b/lib/cjs/jos3_functions/weight_rate.js @@ -0,0 +1,31 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.weight_rate = void 0; +const JOS3Defaults_js_1 = __importDefault(require("./JOS3Defaults.js")); +const validate_body_parameters_js_1 = require("./validate_body_parameters.js"); +/** + * Calculate the ratio of the body weight to the standard body (74.43 kg). + * + * The standard values of local body weights are as as follows: + * weight_local = [ + * 3.18, 0.84, 12.4, 11.03, 17.57, + * 2.16, 1.37, 0.34, 2.16, 1.37, 0.34, + * 7.01, 3.34, 0.48, 7.01, 3.34, 0.48 + * ] + * + * The data have been derived from 65MN. + * The weight of neck is extracted from the weight of 65MN's head based on + * the local body surface area of Smith's model. + * + * @param {number} [weight=JOS3Defaults.weight] - The body weight [kg]. + * + * @returns {number} the ratio of the body weight to the standard body (74.43 kg). + */ +function weight_rate(weight = JOS3Defaults_js_1.default.weight) { + (0, validate_body_parameters_js_1.validate_body_parameters)(undefined, weight); + return weight / JOS3Defaults_js_1.default.weight; +} +exports.weight_rate = weight_rate; diff --git a/lib/cjs/models/JOS3.js b/lib/cjs/models/JOS3.js new file mode 100644 index 0000000..3d01912 --- /dev/null +++ b/lib/cjs/models/JOS3.js @@ -0,0 +1,953 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.JOS3 = void 0; +const JOS3Defaults_js_1 = __importDefault(require("../jos3_functions/JOS3Defaults.js")); +const bsa_rate_js_1 = require("../jos3_functions/bsa_rate.js"); +const local_bsa_js_1 = require("../jos3_functions/local_bsa.js"); +const bfb_rate_js_1 = require("../jos3_functions/bfb_rate.js"); +const conductance_js_1 = require("../jos3_functions/conductance.js"); +const capacity_js_1 = require("../jos3_functions/capacity.js"); +const math = __importStar(require("mathjs")); +const matrix_js_1 = require("../jos3_functions/matrix.js"); +const shivering_js_1 = require("../jos3_functions/thermoregulation/shivering.js"); +const basal_met_js_1 = require("../jos3_functions/thermoregulation/basal_met.js"); +const pmv_js_1 = require("./pmv.js"); +const fixed_hc_js_1 = require("../jos3_functions/thermoregulation/fixed_hc.js"); +const conv_coef_js_1 = require("../jos3_functions/thermoregulation/conv_coef.js"); +const fixed_hr_js_1 = require("../jos3_functions/thermoregulation/fixed_hr.js"); +const rad_coef_js_1 = require("../jos3_functions/thermoregulation/rad_coef.js"); +const operative_temp_js_1 = require("../jos3_functions/thermoregulation/operative_temp.js"); +const dry_r_js_1 = require("../jos3_functions/thermoregulation/dry_r.js"); +const wet_r_js_1 = require("../jos3_functions/thermoregulation/wet_r.js"); +const evaporation_js_1 = require("../jos3_functions/thermoregulation/evaporation.js"); +const skin_blood_flow_js_1 = require("../jos3_functions/thermoregulation/skin_blood_flow.js"); +const ava_blood_flow_js_1 = require("../jos3_functions/thermoregulation/ava_blood_flow.js"); +const nonshivering_js_1 = require("../jos3_functions/thermoregulation/nonshivering.js"); +const local_mbase_js_1 = require("../jos3_functions/thermoregulation/local_mbase.js"); +const sum_m_js_1 = require("../jos3_functions/thermoregulation/sum_m.js"); +const local_q_work_js_1 = require("../jos3_functions/thermoregulation/local_q_work.js"); +const cr_ms_fat_blood_flow_js_1 = require("../jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js"); +const resp_heat_loss_js_1 = require("../jos3_functions/thermoregulation/resp_heat_loss.js"); +const sum_bf_js_1 = require("../jos3_functions/thermoregulation/sum_bf.js"); +const object_js_1 = __importDefault(require("lodash/object.js")); +/** + * Create an array of shape (17,) with the given input. + * + * @param inp {number | number[] | object} + * @returns {math.Matrix} + */ +function _to17array(inp) { + if (typeof inp === "number") { + return math.multiply(math.ones(17), inp); + } + if (math.isCollection(inp)) { + const size = math.size(inp).toArray(); + if (!math.equal(size, [17])) { + throw new Error("Input list is not of length 17"); + } + return math.matrix(inp); + } + if (typeof inp === "object") { + return math.matrix(matrix_js_1.BODY_NAMES.map((name) => inp[name])); + } + throw new Error("Unsupported input type. Supported types: number"); +} +/** + * JOS-3 model simulates human thermal physiology including skin + * temperature, core temperature, sweating rate, etc. for the whole body and + * 17 local body parts. + * + * This model was developed at Shin-ichi Tanabe Laboratory, Waseda University + * and was derived from 65 Multi-Node model (https://doi.org/10.1016/S0378-7788(02)00014-2) + * and JOS-2 model (https://doi.org/10.1016/j.buildenv.2013.04.013). + * + * To use this model, create an instance of the JOS3 class with optional body parameters + * such as body height, weight, age, sex, etc. + * + * Environmental conditions such as air temperature, mean radiant temperature, air velocity, etc. + * can be set using the setter methods. (ex. X.tdb, X.tr X.v) + * If you want to set the different conditions in each body part, set them + * as a 17 lengths of list, dictionary, or numpy array format. + * + * List or numpy array format input must be 17 lengths and means the order of "head", "neck", "chest", + * "back", "pelvis", "left_shoulder", "left_arm", "left_hand", "right_shoulder", "right_arm", + * "right_hand", "left_thigh", "left_leg", "left_foot", "right_thigh", "right_leg" and "right_foot". + * + * The model output includes local and mean skin temperature, local core temperature, + * local and mean skin wettedness, and heat loss from the skin etc. + * The model output can be accessed using "dict_results()" method and be converted to a csv file + * using "to_csv" method. + * Each output parameter also can be accessed using getter methods. + * (ex. X.t_skin, X.t_skin_mean, X.t_core) + * + * If you use this package, please cite us as follows and mention the version of pythermalcomfort used: + * Y. Takahashi, A. Nomoto, S. Yoda, R. Hisayama, M. Ogata, Y. Ozeki, S. Tanabe, + * Thermoregulation Model JOS-3 with New Open Source Code, Energy & Buildings (2020), + * doi: https://doi.org/10.1016/j.enbuild.2020.110575 + * + * Note: To maintain consistency in variable names for jsthermalcomfort and pythermalcomfort, + * some variable names differ from those used in the original paper. + * + * @public + * @memberof models + * @docname JOS3 + */ +class JOS3 { + /** + * Initialize a new instance of JOS3 class, which is designed to model + * and simulate various physiological parameters related to human + * thermoregulation. + * + * This class uses mathematical models to calculate and predict + * body temperature, basal metabolic rate, body surface area, and + * other related parameters. + * + * @param {number} [height] - body height, in [m]. + * @param {number} [weight] - body weight, in [kg]. + * @param {number} [fat] - fat percentage, in [%]. + * @param {number} [age] - age, in [years]. + * @param {"male" | "female"} [sex] - sex. + * @param {number} [ci] - Cardiac index, in [L/min/m2]. + * @param {"harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule"} [bmr_equation] - The equation used + * to calculate basal metabolic rate (BMR). + * @param {"dubois" | "fujimoto" | "kruazumi" | "takahira"} [bsa_equation] - The equation used to calculate body + * surface area (bsa). + * @param {[] | "all"} [ex_output] - This is used when you want to display results other than the default output + * parameters (ex.skin temperature); by default, JOS outputs only the most necessary parameters in order to reduce + * the computational load. + */ + constructor(height = JOS3Defaults_js_1.default.height, weight = JOS3Defaults_js_1.default.weight, fat = JOS3Defaults_js_1.default.body_fat, age = JOS3Defaults_js_1.default.age, sex = JOS3Defaults_js_1.default.sex, ci = JOS3Defaults_js_1.default.cardiac_index, bmr_equation = JOS3Defaults_js_1.default.bmr_equation, bsa_equation = JOS3Defaults_js_1.default.bsa_equation, ex_output = []) { + // Initialize basic attributes + this._height = height; + this._weight = weight; + this._fat = fat; + this._age = age; + this._sex = sex; + this._ci = ci; + this._bmr_equation = bmr_equation; + this._bsa_equation = bsa_equation; + this._ex_output = ex_output; + // Calculate body surface area (bsa) rate + this._bsa_rate = (0, bsa_rate_js_1.bsa_rate)(height, weight, bsa_equation); + // Calculate local body surface area + this._bsa = (0, local_bsa_js_1.local_bsa)(height, weight, bsa_equation); + // Calculate basal blood flow (BFB) rate [-] + this._bfb_rate = (0, bfb_rate_js_1.bfb_rate)(height, weight, bsa_equation, age, ci); + // Calculate thermal conductance (CDT) [W/K] + this._cdt = (0, conductance_js_1.conductance)(height, weight, bsa_equation, fat); + // Calculate thermal capacity [J/K] + this._cap = (0, capacity_js_1.capacity)(height, weight, bsa_equation, age, ci); + // Set initial core and skin temperature set points [°C] + this.setpt_cr = math.multiply(math.ones(17), JOS3Defaults_js_1.default.core_temperature); + this.setpt_sk = math.multiply(math.ones(17), JOS3Defaults_js_1.default.skin_temperature); + // Initialize body temperature [°C] + this._bodytemp = math.multiply(math.ones(matrix_js_1.NUM_NODES), JOS3Defaults_js_1.default.other_body_temperature); + // Initialize environmental conditions and other factors + // (Default values of input conditions) + this._ta = math.multiply(math.ones(17), JOS3Defaults_js_1.default.dry_bulb_air_temperature); + this._tr = math.multiply(math.ones(17), JOS3Defaults_js_1.default.mean_radiant_temperature); + this._rh = math.multiply(math.ones(17), JOS3Defaults_js_1.default.relative_humidity); + this._va = math.multiply(math.ones(17), JOS3Defaults_js_1.default.air_speed); + this._clo = math.multiply(math.ones(17), JOS3Defaults_js_1.default.clothing_insulation); + this._iclo = math.multiply(math.ones(17), JOS3Defaults_js_1.default.clothing_vapor_permeation_efficiency); + this._par = JOS3Defaults_js_1.default.physical_activity_ratio; + this._posture = JOS3Defaults_js_1.default.posture; + this._hc = null; // Convective heat transfer coefficient + this._hr = null; // Radiative heat transfer coefficient + this.ex_q = math.zeros(matrix_js_1.NUM_NODES); // External heat gain + this._t = 0; // Elapsed time + this._cycle = 0; // Cycle time + this.model_name = "JOS3"; // Model name + this.options = { + nonshivering_thermogenesis: true, + cold_acclimated: false, + shivering_threshold: false, + "limit_dshiv/dt": false, + bat_positive: false, + ava_zero: false, + shivering: false, + }; + // Set shivering threshold = 0 + (0, shivering_js_1.set_pre_shiv)(0); + // Initialize history to store model parameters + this._history = []; + // Set elapsed time and cycle time to 0 + this._t = 0; // Elapsed time + this._cycle = 0; // Cycle time + // Reset set-point temperature and save the last model parameters + const dictout = this._reset_setpt(JOS3Defaults_js_1.default.physical_activity_ratio); + this._history.push(dictout); + } + /** + * Calculate operative temperature [°C] when PMV=0. + * + * @private + * + * @param va {number} - Air velocity [m/s]. + * @param rh {number} - Relative humidity [%]. + * @param met {number} - Metabolic rate [met]. + * @param clo {number} - Clothing insulation [clo]. + * + * @returns {number} + */ + _calculate_operative_temp_when_pmv_is_zero(va = JOS3Defaults_js_1.default.air_speed, rh = JOS3Defaults_js_1.default.relative_humidity, met = JOS3Defaults_js_1.default.metabolic_rate, clo = JOS3Defaults_js_1.default.clothing_insulation) { + let to = 28; // initial operative temperature + // Iterate until the PMV (Predicted Mean Vote) value is less than 0.001 + let vpmv; + for (let i = 0; i < 100; i++) { + vpmv = (0, pmv_js_1.pmv)(to, to, va, rh, met, clo); + // Break the loop if the absolute value of PMV is less than 0.001 + if (math.abs(vpmv) < 0.001) { + break; + } + // Update the temperature based on the PMV value + to = to - vpmv / 3; + } + return to; + } + /** + * Reset set-point temperatures under steady state calculation. + * Set-point temperatures are hypothetical core or skin temperatures in a thermally neutral state + * when at rest (similar to room set-point temperature for air conditioning). + * This function is used during initialization to calculate the set-point temperatures as a reference for thermoregulation. + * Be careful, input parameters (tdb, tr, rh, v, clo, par) and body temperatures are also reset. + * + * @private + * + * @param par {number} - Physical activity ratio. + */ + _reset_setpt(par = JOS3Defaults_js_1.default.physical_activity_ratio) { + // Set operative temperature under PMV=0 environment + // 1 met = 58.15 W/m2 + const w_per_m2_to_met = 1 / 58.15; // unit converter W/m2 to met + const met = this.bmr * par * w_per_m2_to_met; // [met] + this.to = this._calculate_operative_temp_when_pmv_is_zero(undefined, undefined, met, undefined); + this.rh = JOS3Defaults_js_1.default.relative_humidity; + this.v = JOS3Defaults_js_1.default.air_speed; + this.clo = JOS3Defaults_js_1.default.clothing_insulation; + this.par = par; + // Steady-calculatio + this.options["ava_zero"] = true; + let dict_out; + for (let i = 0; i < 10; i++) { + dict_out = this._run(60000, true); + } + // Set new set-point temperatures for core and skin + this.setpt_cr = this.t_core; + this.setpt_sk = this.t_skin; + this.options["ava_zero"] = false; + return dict_out; + } + /** + * Run JOS-3 model. + * + * @property {number} times - Number of loops of a simulation. + * @property {number} [dtime=60] - Time delta in seconds. + * @property {boolean} [output=true] - If you don't want to record parameters, set False. + */ + simulate(times, dtime = 60, output = true) { + // Loop through the simulation for the given number of times + for (let i = 0; i < times; i++) { + // Increment the elapsed time by the time delta + this._t += dtime; + // Increment the cycle counter + this._cycle += 1; + // Execute the simulation step + const dict_data = this._run(dtime, undefined, output); + // If output is True, append the results to the history + if (output) { + this._history.push(dict_data); + } + } + } + /** + * Runs the model once and gets the model parameters. + * + * The function then calculates several thermoregulation parameters using the input data, + * such as convective and radiative heat transfer coefficients, operative temperature, heat resistance, + * and blood flow rates. + * + * It also calculates the thermogenesis by shivering and non-shivering, basal thermogenesis, and thermogenesis by work. + * + * The function then calculates the total heat loss and gains, including respiratory, + * sweating, and extra heat gain, and builds the matrices required + * to solve for the new body temperature. + * + * It then calculates the new body temperature by solving the matrices using numpy's linalg library. + * + * Finally, the function returns a dictionary of the simulation results. + * The output parameters include cycle time, model time, t_skin_mean, t_skin, t_core, w_mean, w, weight_loss_by_evap_and_res, cardiac_output, q_thermogenesis_total, q_res, and q_skin_env. + * + * Additionally, if the _ex_output variable is set to "all" or is a list of keys, + * the function also returns a detailed dictionary of all the thermoregulation parameters + * and other variables used in the simulation. + * + * @private + * + * @param {number} dtime - Time delta [sec]. + * @param {boolean} passive - If you run a passive model. + * @param {boolean} output - If you don't need parameters. + * + * @returns {object} + */ + _run(dtime = 60, passive = false, output = true) { + // Compute convective and radiative heat transfer coefficient [W/(m2*K)] + // based on posture, air velocity, air temperature, and skin temperature. + // Manual setting is possible by setting self._hc and self._hr. + // Compute heat and evaporative heat resistance [m2.K/W], [m2.kPa/W] + // Get core and skin temperatures + let tcr = this.t_core; + let tsk = this.t_skin; + // Convective and radiative heat transfer coefficients [W/(m2*K)] + let hc = (0, fixed_hc_js_1.fixed_hc)((0, conv_coef_js_1.conv_coef)(this._posture, this._va, this._ta, tsk), this._va); + let hr = (0, fixed_hr_js_1.fixed_hr)((0, rad_coef_js_1.rad_coef)(this._posture)); + // Manually set convective and radiative heat transfer coefficients if necessary + if (this._hc !== null) { + hc = this._hc; + } + if (this._hr !== null) { + hr = this._hr; + } + // Compute operative temp. [°C], clothing heat and evaporative resistance [m2.K/W], [m2.kPa/W] + // Operative temp. [°C] + let to = (0, operative_temp_js_1.operative_temp)(this._ta, this._tr, hc, hr); + // Clothing heat resistance [m2.K/W] + let r_t = (0, dry_r_js_1.dry_r)(hc, hr, this._clo); + // Clothing evaporative resistance [m2.kPa/W] + let r_et = (0, wet_r_js_1.wet_r)(hc, this._clo, this._iclo); + // ------------------------------------------------------------------ + // Thermoregulation + // 1) Sweating + // 2) Vasoconstriction, Vasodilation + // 3) Shivering and non-shivering thermogenesis + // ------------------------------------------------------------------ + // Compute the difference between the set-point temperature and body temperatures + // and other thermoregulation parameters. + // If running a passive model, the set-point temperature of thermoregulation is + // set to the current body temperature. + // set-point temperature for thermoregulation + let setpt_cr = passive ? tcr.clone() : this.setpt_cr.clone(); + let setpt_sk = passive ? tsk.clone() : this.setpt_sk.clone(); + // Error signal = Difference between set-point and body temperatures + let err_cr = math.subtract(tcr, setpt_cr); + let err_sk = math.subtract(tsk, setpt_sk); + // SWEATING THERMOREGULATION + // Skin wettedness [-], e_skin, e_max, e_sweat [W] + // Calculate skin wettedness, sweating heat loss, maximum sweating rate, and total sweat rate + let { wet, e_sk, e_max, e_sweat } = (0, evaporation_js_1.evaporation)(err_cr, err_sk, tsk, this._ta, this._rh, r_et, this._height, this._weight, this._bsa_equation, this._age); + // VASOCONSTRICTION, VASODILATION + // Calculate skin blood flow and basal skin blood flow [L/h] + let bf_skin = (0, skin_blood_flow_js_1.skin_blood_flow)(err_cr, err_sk, this._height, this._weight, this._bsa_equation, this._age, this._ci); + // Calculate hands and feet's AVA blood flow [L/h] + let { bf_ava_hand, bf_ava_foot } = (0, ava_blood_flow_js_1.ava_blood_flow)(err_cr, err_sk, this._height, this._weight, this._bsa_equation, this._age, this._ci); + if (this.options["ava_zero"] && passive) { + bf_ava_hand = 0; + bf_ava_foot = 0; + } + // SHIVERING AND NON-SHIVERING + // Calculate shivering thermogenesis [W] + let q_shiv = (0, shivering_js_1.shivering)(err_cr, err_sk, tcr, tsk, this._height, this._weight, this._bsa_equation, this._age, this._sex, dtime, this.options); + // Calculate non-shivering thermogenesis (NST) [W] + let q_nst = this.options["nonshivering_thermogenesis"] + ? (0, nonshivering_js_1.nonshivering)(err_sk, this._height, this._weight, this._bsa_equation, this._age, this.options["cold_acclimated"], this.options["bat_positive"]) + : math.zeros(17); + // ------------------------------------------------------------------ + // Thermogenesis + // ------------------------------------------------------------------ + // Calculate local basal metabolic rate (BMR) [W] + let q_bmr_local = (0, local_mbase_js_1.local_mbase)(this._height, this._weight, this._age, this._sex, this._bmr_equation); + // Calculate overall basal metabolic rate (BMR) [W] + let q_bmr_total = math.sum(q_bmr_local.map((q) => math.sum(q))); + // Calculate thermogenesis by work [W] + let q_work = (0, local_q_work_js_1.local_q_work)(q_bmr_total, this._par); + // Calculate the sum of thermogenesis in core, muscle, fat, skin [W] + let { q_thermogenesis_core, q_thermogenesis_muscle, q_thermogenesis_fat, q_thermogenesis_skin, } = (0, sum_m_js_1.sum_m)(q_bmr_local.map((c) => c.clone()), q_work, q_shiv, q_nst); + let q_thermogenesis_total = math.sum(q_thermogenesis_core) + + math.sum(q_thermogenesis_muscle) + + math.sum(q_thermogenesis_fat) + + math.sum(q_thermogenesis_skin); + // ------------------------------------------------------------------ + // Others + // ------------------------------------------------------------------ + // Calculate blood flow in core, muscle, fat [L/h] + let { bf_core, bf_muscle, bf_fat } = (0, cr_ms_fat_blood_flow_js_1.cr_ms_fat_blood_flow)(q_work, q_shiv, this._height, this._weight, this._bsa_equation, this._age, this._ci); + // Calculate heat loss by respiratory + let p_a = math.dotDivide(math.dotMultiply(this._ta.map(evaporation_js_1.antoine), this._rh), 100); + let { res_sh, res_lh } = (0, resp_heat_loss_js_1.resp_heat_loss)(this._ta.get([0]), p_a.get([0]), q_thermogenesis_total); + // Calculate sensible heat loss [W] + let shl_sk = math.dotMultiply(math.dotDivide(math.subtract(tsk, to), r_t), this._bsa); + // Calculate cardiac output [L/h] + let co = (0, sum_bf_js_1.sum_bf)(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot); + // Calculate weight loss rate by evaporation [g/sec] + let wlesk = math.dotDivide(math.add(e_sweat, math.dotMultiply(0.06, e_max)), 2418); + let wleres = res_lh / 2418; + // ------------------------------------------------------------------ + // Matrix + // This code section is focused on constructing and calculating + // various matrices required for modeling the thermoregulation + // of the human body. + // Since JOS-3 has 85 thermal nodes, the determinant of 85*85 is to be solved. + // ------------------------------------------------------------------ + // Matrix A = Matrix for heat exchange due to blood flow and conduction occurring between tissues + // (85, 85,) ndarray + // Calculates the blood flow in arteries and veins for core, muscle, fat, skin, + // and arteriovenous anastomoses (AVA) in hands and feet, + // and combines them into two arrays: + // 1) bf_local for the local blood flow and 2) bf_whole for the whole-body blood flow. + // These arrays are then combined to form arr_bf. + let { bf_art, bf_vein } = (0, matrix_js_1.vessel_blood_flow)(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot); + let bf_local = (0, matrix_js_1.local_arr)(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot); + let bf_whole = (0, matrix_js_1.whole_body)(bf_art, bf_vein, bf_ava_hand, bf_ava_foot); + let arr_bf = math.zeros(matrix_js_1.NUM_NODES, matrix_js_1.NUM_NODES); + arr_bf = math.add(arr_bf, bf_local); + arr_bf = math.add(arr_bf, bf_whole); + // Adjusts the units of arr_bf from [W/K] to [/sec] and then to [-] + // by dividing by the heat capacity self._cap and multiplying by the time step dtime. + arr_bf = math.dotDivide(arr_bf, math.reshape(this._cap, [matrix_js_1.NUM_NODES, 1])); // Change unit [W/K] to [/sec] + arr_bf = math.dotMultiply(arr_bf, dtime); // Change unit [/sec] to [-] + // Performs similar unit conversions for the convective heat transfer coefficient array arr_cdt + // (also divided by self._cap and multiplied by dtime). + let arr_cdt = this._cdt.clone(); + arr_cdt = math.dotDivide(arr_cdt, math.reshape(this._cap, [matrix_js_1.NUM_NODES, 1])); // Change unit [W/K] to [/sec] + arr_cdt = math.dotMultiply(arr_cdt, dtime); // Change unit [/sec] to [-] + // Matrix B = Matrix for heat transfer between skin and environment + let arr_b = math.zeros(matrix_js_1.NUM_NODES); + arr_b = math.subset(arr_b, math.index(matrix_js_1.INDEX["skin"]), math.add(math.subset(arr_b, math.index(matrix_js_1.INDEX["skin"])), math.dotMultiply(math.dotDivide(1, r_t), this._bsa))); + arr_b = math.dotDivide(arr_b, this._cap); // Change unit [W/K] to [/sec] + arr_b = math.dotMultiply(arr_b, dtime); // Change unit [/sec] to [-] + // Calculates the off-diagonal and diagonal elements of the matrix A, + // which represents the heat transfer coefficients between different parts of the body, + // and combines them to form the full matrix A (arrA). + // Then, the inverse of matrix A is computed (arrA_inv). + let arr_a_tria = math.dotMultiply(math.add(arr_cdt, arr_bf), -1); + let arr_a_dia = math.add(arr_cdt, arr_bf); + arr_a_dia = math.add(math.sum(arr_a_dia, 1), arr_b); + arr_a_dia = math.diag(arr_a_dia); + arr_a_dia = math.add(arr_a_dia, math.identity(matrix_js_1.NUM_NODES)); + let arr_a = math.add(arr_a_tria, arr_a_dia); + let arr_a_inv = math.inv(arr_a); + // Matrix Q = Matrix for heat generation rate from thermogenesis, respiratory, sweating, + // and extra heat gain processes in different body parts. + // Matrix Q [W] / [J/K] * [sec] = [-] + // Thermogensis + let arr_q = math.zeros(matrix_js_1.NUM_NODES); + arr_q = math.subset(arr_q, math.index(matrix_js_1.INDEX["core"]), math.add(math.subset(arr_q, math.index(matrix_js_1.INDEX["core"])), q_thermogenesis_core)); + arr_q = math.subset(arr_q, math.index(matrix_js_1.INDEX["muscle"]), math.add(math.subset(arr_q, math.index(matrix_js_1.INDEX["muscle"])), math.subset(q_thermogenesis_muscle, math.index(matrix_js_1.VINDEX["muscle"])))); + arr_q = math.subset(arr_q, math.index(matrix_js_1.INDEX["fat"]), math.add(math.subset(arr_q, math.index(matrix_js_1.INDEX["fat"])), math.subset(q_thermogenesis_fat, math.index(matrix_js_1.VINDEX["fat"])))); + arr_q = math.subset(arr_q, math.index(matrix_js_1.INDEX["skin"]), math.add(math.subset(arr_q, math.index(matrix_js_1.INDEX["skin"])), q_thermogenesis_skin)); + // Respiratory [W] + arr_q.set([matrix_js_1.INDEX["core"][2]], arr_q.get([matrix_js_1.INDEX["core"][2]]) - (res_sh + res_lh)); // chest core + // Sweating [W] + arr_q = math.subset(arr_q, math.index(matrix_js_1.INDEX["skin"]), math.subtract(math.subset(arr_q, math.index(matrix_js_1.INDEX["skin"])), e_sk)); + // Extra heat gain [W] + arr_q = math.add(arr_q, this.ex_q.clone()); + arr_q = math.dotDivide(arr_q, this._cap); // Change unit [W]/[J/K] to [K/sec] + arr_q = math.dotMultiply(arr_q, dtime); // Change unit [K/sec] to [K] + // Boundary batrix [°C] + let arr_to = math.zeros(matrix_js_1.NUM_NODES); + arr_to = math.subset(arr_to, math.index(matrix_js_1.INDEX["skin"]), math.add(math.subset(arr_to, math.index(matrix_js_1.INDEX["skin"])), to)); + // Combines the current body temperature, the boundary matrix, and the heat generation matrix + // to calculate the new body temperature distribution (arr). + let arr = math.add(math.add(this._bodytemp, math.dotMultiply(arr_b, arr_to)), arr_q); + // ------------------------------------------------------------------ + // New body temp. [°C] + // ------------------------------------------------------------------ + this._bodytemp = math.multiply(arr_a_inv, arr); + // ------------------------------------------------------------------ + // Output parameters + // ------------------------------------------------------------------ + let dict_out = {}; + if (output) { + dict_out["cycle_time"] = this._cycle; + dict_out["simulation_time"] = this._t; + dict_out["dt"] = dtime; + dict_out["t_skin_mean"] = this.t_skin_mean; + dict_out["t_skin"] = this.t_skin.toArray(); + dict_out["t_core"] = this.t_core.toArray(); + dict_out["w_mean"] = + math.sum(math.dotMultiply(wet, JOS3Defaults_js_1.default.local_bsa)) / + math.sum(JOS3Defaults_js_1.default.local_bsa); + dict_out["w"] = wet.toArray(); + dict_out["weight_loss_by_evap_and_res"] = math.sum(wlesk) + wleres; + dict_out["cardiac_output"] = co; + dict_out["q_thermogenesis_total"] = q_thermogenesis_total; + dict_out["q_res"] = res_sh + res_lh; + dict_out["q_skin2env"] = math.add(shl_sk, e_sk).toArray(); + } + let detail_out = {}; + if (this._ex_output && output) { + detail_out["name"] = this.model_name; + detail_out["height"] = this._height; + detail_out["weight"] = this._weight; + detail_out["bsa"] = this._bsa.toArray(); + detail_out["fat"] = this._fat; + detail_out["sex"] = this._sex; + detail_out["age"] = this._age; + detail_out["t_core_set"] = setpt_cr.toArray(); + detail_out["t_skin_set"] = setpt_sk.toArray(); + detail_out["t_cb"] = this.t_cb; + detail_out["t_artery"] = this.t_artery.toArray(); + detail_out["t_vein"] = this.t_vein.toArray(); + detail_out["t_superficial_vein"] = this.t_superficial_vein.toArray(); + detail_out["t_muscle"] = this.t_muscle.toArray(); + detail_out["t_fat"] = this.t_fat.toArray(); + detail_out["to"] = to.toArray(); + detail_out["r_t"] = r_t.toArray(); + detail_out["r_et"] = r_et.toArray(); + detail_out["tdb"] = this._ta.clone().toArray(); + detail_out["tr"] = this._tr.clone().toArray(); + detail_out["rh"] = this._rh.clone().toArray(); + detail_out["v"] = this._va.clone().toArray(); + detail_out["par"] = this._par; + detail_out["clo"] = this._clo.clone().toArray(); + detail_out["e_skin"] = e_sk.toArray(); + detail_out["e_max"] = e_max.toArray(); + detail_out["e_sweat"] = e_sweat.toArray(); + detail_out["bf_core"] = bf_core.toArray(); + detail_out["bf_muscle"] = math + .subset(bf_muscle, math.index(matrix_js_1.VINDEX["muscle"])) + .toArray(); + detail_out["bf_fat"] = math + .subset(bf_fat, math.index(matrix_js_1.VINDEX["fat"])) + .toArray(); + detail_out["bf_skin"] = bf_skin.toArray(); + detail_out["bf_ava_hand"] = bf_ava_hand; + detail_out["bf_ava_foot"] = bf_ava_foot; + detail_out["q_bmr_core"] = q_bmr_local[0].toArray(); + detail_out["q_bmr_muscle"] = math + .subset(q_bmr_local[1], math.index(matrix_js_1.VINDEX["muscle"])) + .toArray(); + detail_out["q_bmr_fat"] = math + .subset(q_bmr_local[2], math.index(matrix_js_1.VINDEX["fat"])) + .toArray(); + detail_out["q_bmr_skin"] = q_bmr_local[3].toArray(); + detail_out["q_work"] = q_work.toArray(); + detail_out["q_shiv"] = q_shiv.toArray(); + detail_out["q_nst"] = q_nst.toArray(); + detail_out["q_thermogenesis_core"] = q_thermogenesis_core.toArray(); + detail_out["q_thermogenesis_muscle"] = math + .subset(q_thermogenesis_muscle, math.index(matrix_js_1.VINDEX["muscle"])) + .toArray(); + detail_out["q_thermogenesis_fat"] = math + .subset(q_thermogenesis_fat, math.index(matrix_js_1.VINDEX["fat"])) + .toArray(); + detail_out["q_thermogenesis_skin"] = q_thermogenesis_skin.toArray(); + dict_out["q_skin2env_sensible"] = shl_sk.toArray(); + dict_out["q_skin2env_latent"] = e_sk.toArray(); + dict_out["q_res_sensible"] = res_sh; + dict_out["q_res_latent"] = res_lh; + } + if (this._ex_output === "all") { + dict_out = Object.assign(Object.assign({}, dict_out), detail_out); + } + else if (Array.isArray(this._ex_output)) { + const out_keys = object_js_1.default.keys(detail_out); + for (const key in this._ex_output) { + if (out_keys.includes(key)) { + dict_out[key] = detail_out[key]; + } + } + } + return dict_out; + } + /** + * Get results as a dictionary with the model values. + * + * @returns {object} + */ + dict_results() { + if (!this._history || this._history.length === 0) { + console.log("The model has no data."); + return null; + } + const checkWordContain = (word, ...args) => { + return args.some((arg) => word.includes(arg)); + }; + let key2keys = {}; // Column keys + for (let [key, value] of object_js_1.default.entries(this._history[0])) { + let keys; + if (value.length !== undefined) { + if (typeof value === "string") { + keys = [key]; // string is iter. Convert to list without suffix + } + else if (checkWordContain(key, "sve", "sfv", "superficialvein")) { + keys = matrix_js_1.VINDEX["sfvein"].map((i) => `${key}_${matrix_js_1.BODY_NAMES[i]}`); + } + else if (checkWordContain(key, "ms", "muscle")) { + keys = matrix_js_1.VINDEX["muscle"].map((i) => `${key}_${matrix_js_1.BODY_NAMES[i]}`); + } + else if (checkWordContain(key, "fat")) { + keys = matrix_js_1.VINDEX["fat"].map((i) => `${key}_${matrix_js_1.BODY_NAMES[i]}`); + } + else if (value.length === 17) { + keys = matrix_js_1.BODY_NAMES.map((bn) => `${key}_${bn}`); + } + else { + keys = Array.from({ length: value.length }, (_, i) => `${key}_${matrix_js_1.BODY_NAMES[i]}`); + } + } + else { + keys = [key]; + } + key2keys[key] = keys; + } + let data = this._history.map((dictout) => { + let row = {}; + for (let [key, value] of object_js_1.default.entries(dictout)) { + let keys = key2keys[key]; + let values = keys.length === 1 ? [value] : value; + keys.forEach((k, i) => { + row[k] = values[i]; + }); + } + return row; + }); + let outDict = {}; + object_js_1.default.keys(data[0]).forEach((key) => { + outDict[key] = data.map((row) => row[key]); + }); + return outDict; + } + /** + * Set extra heat gain by tissue name. + * + * @private + * + * @param {string} tissue - Tissue name. "core", "skin", or "artery".... If you set value to head muscle and other segment's core, set "all_muscle". + * @param {number | math.MathCollection} value - Heat gain [W] + * + * @return {math.MathCollection} Extra heat gain of model. + */ + _set_ex_q(tissue, value) { + this.ex_q = math.subset(this.ex_q, math.index(matrix_js_1.INDEX[tissue]), value); + return this.ex_q; + } + /** + * Dry-bulb air temperature. + * + * @return {math.Matrix} + */ + get tdb() { + return this._ta; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tdb(inp) { + this._ta = _to17array(inp); + } + /** + * Mean radiant temperature [°C]. + * + * @return {math.Matrix} + */ + get tr() { + return this._tr; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tr(inp) { + this._tr = _to17array(inp); + } + /** + * Operative temperature [°C]. + * + * @return {math.Matrix} + */ + get to() { + const hc = (0, fixed_hc_js_1.fixed_hc)((0, conv_coef_js_1.conv_coef)(this._posture, this._va, this._ta, this.t_skin), this._va); + const hr = (0, fixed_hr_js_1.fixed_hr)((0, rad_coef_js_1.rad_coef)(this._posture)); + return (0, operative_temp_js_1.operative_temp)(this._ta, this._tr, hc, hr); + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set to(inp) { + this._ta = _to17array(inp); + this._tr = _to17array(inp); + } + /** + * Relative humidity [%]. + * + * @return {math.Matrix} + */ + get rh() { + return this._rh; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set rh(inp) { + this._rh = _to17array(inp); + } + /** + * Air velocity [m/s]. + * + * @return {math.Matrix} + */ + get v() { + return this._va; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set v(inp) { + this._va = _to17array(inp); + } + /** + * Current JOS3 posture. + * + * @return {string} + */ + get posture() { + return this._posture; + } + /** + * @param inp {number | string} + */ + set posture(inp) { + if (inp === 0) { + this._posture = "standing"; + } + else if (inp === 1) { + this._posture = "sitting"; + } + else if (inp === 2) { + this._posture = "lying"; + } + else if (inp.toLowerCase() === "standing") { + this._posture = "standing"; + } + else if (["sitting", "sedentary"].includes(inp.toLowerCase())) { + this._posture = "sitting"; + } + else if (["lying", "supine"].includes(inp.toLowerCase())) { + this._posture = "lying"; + } + else { + this._posture = "standing"; + console.log('posture must be 0="standing", 1="sitting" or 2="lying".'); + console.log('posture was set "standing".'); + } + } + /** + * Clothing insulation [clo]. + * + * @return {math.Matrix} + */ + get clo() { + return this._clo; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set clo(inp) { + this._clo = _to17array(inp); + } + /** + * Physical activity ratio [-].This equals the ratio of metabolic rate to basal metabolic rate. par of sitting quietly is 1.2. + * + * @return {number} + */ + get par() { + return this._par; + } + /** + * @param inp {number} + */ + set par(inp) { + this._par = inp; + } + /** + * All segment temperatures of JOS-3. + * + * @return {math.Matrix} + */ + get body_temp() { + return this._bodytemp; + } + /** + * @param inp {math.Matrix} + */ + set body_temp(inp) { + this._bodytemp = inp.clone(); + } + /** + * Body surface areas by local body segments [m2]. + * + * @return {math.Matrix} + */ + get bsa() { + return this._bsa.clone(); + } + /** + * Dry heat resistances between the skin and ambience areas by local body segments [(m2*K)/W]. + * + * @return {math.Matrix} + */ + get r_t() { + const hc = (0, fixed_hc_js_1.fixed_hc)((0, conv_coef_js_1.conv_coef)(this._posture, this._va, this._ta, this.t_skin), this._va); + const hr = (0, fixed_hr_js_1.fixed_hr)((0, rad_coef_js_1.rad_coef)(this._posture)); + return (0, dry_r_js_1.dry_r)(hc, hr, this._clo); + } + /** + * w (Evaporative) heat resistances between the skin and ambience areas by local body segments [(m2*kPa)/W]. + * + * @return {math.Matrix} + */ + get r_et() { + const hc = (0, fixed_hc_js_1.fixed_hc)((0, conv_coef_js_1.conv_coef)(this._posture, this._va, this._ta, this.t_skin), this._va); + return (0, wet_r_js_1.wet_r)(hc, this._clo, this._iclo); + } + /** + * Skin wettedness on local body segments [-]. + * + * @return {math.Matrix} + */ + get w() { + const err_cr = math.subtract(this.t_core, this.setpt_cr); + const err_sk = math.subtract(this.t_skin, this.setpt_sk); + const { wet } = (0, evaporation_js_1.evaporation)(err_cr, err_sk, this.t_skin, this._ta, this._rh, this.r_et, this._bsa_rate, this._age); + return wet; + } + /** + * Mean skin wettedness of the whole body [-]. + * + * @return {number} + */ + get w_mean() { + const wet = this.w; + const bsa_sum = math.sum(JOS3Defaults_js_1.default.local_bsa); + return math.sum(math.dotMultiply(wet, JOS3Defaults_js_1.default.local_bsa)) / bsa_sum; + } + /** + * Mean skin temperature of the whole body [°C]. + * + * @return {number} + */ + get t_skin_mean() { + return (math.sum(math.dotMultiply(math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["skin"])), JOS3Defaults_js_1.default.local_bsa)) / math.sum(JOS3Defaults_js_1.default.local_bsa)); + } + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_skin() { + return math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["skin"])); + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set t_skin(inp) { + this._bodytemp = math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["skin"]), _to17array(inp)); + } + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_core() { + return math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["core"])); + } + /** + * Temperature at central blood pool [°C]. + * + * @return {number} + */ + get t_cb() { + return this._bodytemp.get([0]); + } + /** + * Arterial temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_artery() { + return math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["artery"])); + } + /** + * Vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_vein() { + return math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["vein"])); + } + /** + * Superficial vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_superficial_vein() { + return math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["sfvein"])); + } + /** + * Muscle temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_muscle() { + return math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["muscle"])); + } + /** + * Fat temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_fat() { + return math.subset(this._bodytemp, math.index(matrix_js_1.INDEX["fat"])); + } + /** + * JOS3 body names + * + * @return {string[]} + */ + get body_names() { + return matrix_js_1.BODY_NAMES; + } + /** + * Results of the model. + * + * @return {object} + */ + get results() { + return this.dict_results(); + } + /** + * Basal metabolic rate. + * @returns {number} + */ + get bmr() { + const tcr = (0, basal_met_js_1.basal_met)(this._height, this._weight, this._age, this._sex, this._bmr_equation); + return tcr / math.sum(this._bsa); + } +} +exports.JOS3 = JOS3; diff --git a/lib/cjs/models/index.js b/lib/cjs/models/index.js index 7eee270..f603e0e 100644 --- a/lib/cjs/models/index.js +++ b/lib/cjs/models/index.js @@ -25,6 +25,7 @@ const use_fans_heatwave_js_1 = require("./use_fans_heatwave.js"); const clo_tout_js_1 = require("./clo_tout.js"); const utci_js_1 = require("./utci.js"); const pet_steady_js_1 = require("./pet_steady.js"); +const JOS3_js_1 = require("./JOS3.js"); /** * @public * @name models @@ -68,4 +69,5 @@ exports.default = { vertical_tmp_grad_ppd: vertical_tmp_grad_ppd_js_1.vertical_tmp_grad_ppd, wbgt: wbgt_js_1.wbgt, wc: wc_js_1.wc, + JOS3: JOS3_js_1.JOS3, }; diff --git a/lib/cjs/supa.js b/lib/cjs/supa.js new file mode 100644 index 0000000..2ffa0a3 --- /dev/null +++ b/lib/cjs/supa.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.$index = exports.$min = exports.$max = exports.$sum = exports.$lerp = exports.$average = exports.$reduce = exports.$array = exports.$map = void 0; +function $map(arrays, op) { + const mapLength = arrays[0].length; + if (!arrays.every((a) => a.length === mapLength)) { + throw new Error(`cannot $map over arrays of different lengths (${arrays[1].length} vs ${mapLength})`); + } + const result = []; + for (let i = 0; i < mapLength; i++) { + const items = arrays.map((a) => a[i]); + result.push(op(items, i)); + } + return result; +} +exports.$map = $map; +/** + * @template T + * @param {number} length + * @param {T} value + * + * @return {T[]} + */ +function $array(length, value) { + return Array(length).fill(value); +} +exports.$array = $array; +/** + * @template T + * @param arrays {T[][]} + * @param op {(reduced: T, items: T[]) => T} + * @param initial {T} + * + * @return {T} + */ +function $reduce(arrays, op, initial) { + const reduceLength = arrays[0].length; + if (!arrays.every((a) => a.length === reduceLength)) { + throw new Error(`cannot $reduce over arrays of different lengths (${a.length} vs ${reduceLength})`); + } + let reduced = initial; + for (let i = 0; i < reduceLength; i++) { + const items = arrays.map((a) => a[i]); + reduced = op(reduced, items); + } + return reduced; +} +exports.$reduce = $reduce; +function $average(array, weights) { + return ($reduce([array, weights], (reduced, [array, weights]) => reduced + array * weights, 0) / $sum(weights)); +} +exports.$average = $average; +function $lerp(length, min, max) { + return Array(length) + .fill(min) + .map((x, i) => x + i * ((max - min) / (length - 1))); +} +exports.$lerp = $lerp; +function $sum(array) { + return array.reduce((t, c) => t + c, 0); +} +exports.$sum = $sum; +function $max(array, sentinel) { + return array.map((array) => (array < sentinel ? sentinel : array)); +} +exports.$max = $max; +function $min(array, sentinel) { + return array.map((array) => (array > sentinel ? sentinel : array)); +} +exports.$min = $min; +function $index(array, indicies) { + return array.filter((_, i) => indicies.includes(i)); +} +exports.$index = $index; diff --git a/lib/cjs/types/jos3_functions/JOS3Defaults.d.ts b/lib/cjs/types/jos3_functions/JOS3Defaults.d.ts new file mode 100644 index 0000000..9b2b2f6 --- /dev/null +++ b/lib/cjs/types/jos3_functions/JOS3Defaults.d.ts @@ -0,0 +1,27 @@ +export default JOS3Defaults; +declare namespace JOS3Defaults { + let height: number; + let weight: number; + let age: number; + let body_fat: number; + let cardiac_index: number; + let blood_flow_rate: number; + let physical_activity_ratio: number; + let metabolic_rate: number; + let sex: string; + let posture: string; + let bmr_equation: string; + let bsa_equation: string; + let local_bsa: number[]; + let core_temperature: number; + let skin_temperature: number; + let other_body_temperature: number; + let dry_bulb_air_temperature: number; + let mean_radiant_temperature: number; + let relative_humidity: number; + let air_speed: number; + let clothing_insulation: number; + let clothing_vapor_permeation_efficiency: number; + let lewis_rate: number; +} +//# sourceMappingURL=JOS3Defaults.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/JOS3Defaults.d.ts.map b/lib/cjs/types/jos3_functions/JOS3Defaults.d.ts.map new file mode 100644 index 0000000..403bc99 --- /dev/null +++ b/lib/cjs/types/jos3_functions/JOS3Defaults.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"JOS3Defaults.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/JOS3Defaults.js"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/bfb_rate.d.ts b/lib/cjs/types/jos3_functions/bfb_rate.d.ts new file mode 100644 index 0000000..c6cf2be --- /dev/null +++ b/lib/cjs/types/jos3_functions/bfb_rate.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate the ratio of basal blood flow (BFB) of the standard body (290 L/h). + * + * @param {number} height - Body height [m]. The default is 1.72. + * @param {number} weight - Body weight [kg]. The default is 74.43. + * @param {string} bsa_equation - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". The default is "dubois". + * @param {number} age - age [years]. The default is 20. + * @param {number} ci - Cardiac index [L/min/㎡]. The default is 2.59. + * + * @returns {number} - Basal blood flow rate. + */ +export function bfb_rate(height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): number; +//# sourceMappingURL=bfb_rate.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/bfb_rate.d.ts.map b/lib/cjs/types/jos3_functions/bfb_rate.d.ts.map new file mode 100644 index 0000000..055199c --- /dev/null +++ b/lib/cjs/types/jos3_functions/bfb_rate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bfb_rate.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/bfb_rate.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,kCARW,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,MAAM,CA8BlB"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/bsa_rate.d.ts b/lib/cjs/types/jos3_functions/bsa_rate.d.ts new file mode 100644 index 0000000..5245cde --- /dev/null +++ b/lib/cjs/types/jos3_functions/bsa_rate.d.ts @@ -0,0 +1,15 @@ +/** + * Calculates the body surface area rate based on the given height, weight and + * BSA equation. + * + * @param {number} [height=JOS3Defaults.height] - The height of the person in + * meters. + * @param {number} [weight=JOS3Defaults.weight] - The weight of the person in + * kilograms. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The BSA equation + * to use for calculation. + * + * @returns {number} The body surface area rate. + */ +export function bsa_rate(height?: number, weight?: number, bsa_equation?: string): number; +//# sourceMappingURL=bsa_rate.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/bsa_rate.d.ts.map b/lib/cjs/types/jos3_functions/bsa_rate.d.ts.map new file mode 100644 index 0000000..4e848e2 --- /dev/null +++ b/lib/cjs/types/jos3_functions/bsa_rate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bsa_rate.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/bsa_rate.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,kCATW,MAAM,WAEN,MAAM,iBAEN,MAAM,GAGJ,MAAM,CAWlB"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/capacity.d.ts b/lib/cjs/types/jos3_functions/capacity.d.ts new file mode 100644 index 0000000..318ae68 --- /dev/null +++ b/lib/cjs/types/jos3_functions/capacity.d.ts @@ -0,0 +1,19 @@ +/** + * Calculate thermal capacity in Joules per Kelvin (J/K). + * Derived from Yokoyama's model, assuming blood's heat as 1.0 [kcal/L.K]. + * + * @param {number} [height=JOS3Defaults.height] - Body height in meters. Default + * is 1.72. + * @param {number} [weight=JOS3Defaults.weight] - Body weight in kg. Default is + * 74.43. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - Equation name for + * bsa calc. Must be from "dubois","takahira", "fujimoto", "kurazumi". + * Default is "dubois". + * @param {number} [age=JOS3Defaults.age] - Age in years. Default is 20. + * @param {number} [ci=JOS3Defaults.cardiac_index] - Cardiac index in L/min/㎡. + * Default is 2.59. + + * @returns {number[]} - Thermal capacity in W/K. Shape is (NUM_NODES). + */ +export function capacity(height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): number[]; +//# sourceMappingURL=capacity.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/capacity.d.ts.map b/lib/cjs/types/jos3_functions/capacity.d.ts.map new file mode 100644 index 0000000..032f726 --- /dev/null +++ b/lib/cjs/types/jos3_functions/capacity.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"capacity.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/capacity.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,kCAbW,MAAM,WAEN,MAAM,iBAEN,MAAM,QAGN,MAAM,OACN,MAAM,GAGJ,MAAM,EAAE,CAiGpB"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/conductance.d.ts b/lib/cjs/types/jos3_functions/conductance.d.ts new file mode 100644 index 0000000..19acd4f --- /dev/null +++ b/lib/cjs/types/jos3_functions/conductance.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate thermal conductance between layers. + + * @param {number} height - Body height in [m]. Default is 1.72. + * @param {number} weight - Body weight in [kg]. Default is 74.43. + * @param {string} bsa_equation - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". Default is "dubois". + * @param {number} fat - Body fat rate in [%]. Default is 15. + + * @returns {math.Matrix} conductance - Thermal conductance between layers in [W/K]. The shape is (NUM_NODES, NUM_NODES). + */ +export function conductance(height?: number, weight?: number, bsa_equation?: string, fat?: number): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=conductance.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/conductance.d.ts.map b/lib/cjs/types/jos3_functions/conductance.d.ts.map new file mode 100644 index 0000000..8ded809 --- /dev/null +++ b/lib/cjs/types/jos3_functions/conductance.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"conductance.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/conductance.js"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,qCAPW,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,GAEJ,KAAK,MAAM,CAqJvB;sBA/JqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/local_bsa.d.ts b/lib/cjs/types/jos3_functions/local_bsa.d.ts new file mode 100644 index 0000000..b03748a --- /dev/null +++ b/lib/cjs/types/jos3_functions/local_bsa.d.ts @@ -0,0 +1,19 @@ +/** + * Calculate local body surface area (bsa) [m2]. + * + * The local body surface area has been derived from 65MN. + * The head have been divided to head and neck based on Smith's model. + * head = 0.1396*0.1117/0.1414 (65MN_Head * Smith_Head / Smith_Head+neck) + * neck = 0.1396*0.0297/0.1414 (65MN_Head * Smith_Neck / Smith_Head+neck) + * + * @param {number} [height=JOS3Defaults.height] - Body height [m] + * @param {number} [weight=JOS3Defaults.weight] - Body weight [kg] + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The equation name + * of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", + * or "kurazumi". + * + * @returns {math.Matrix} local_bsa of length 17 - Local body surface area (bsa) [m2] + */ +export function local_bsa(height?: number, weight?: number, bsa_equation?: string): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=local_bsa.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/local_bsa.d.ts.map b/lib/cjs/types/jos3_functions/local_bsa.d.ts.map new file mode 100644 index 0000000..91afde9 --- /dev/null +++ b/lib/cjs/types/jos3_functions/local_bsa.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"local_bsa.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/local_bsa.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,mCARW,MAAM,WACN,MAAM,iBACN,MAAM,GAIJ,KAAK,MAAM,CAWvB;sBA3BqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/matrix.d.ts b/lib/cjs/types/jos3_functions/matrix.d.ts new file mode 100644 index 0000000..9ffcd07 --- /dev/null +++ b/lib/cjs/types/jos3_functions/matrix.d.ts @@ -0,0 +1,63 @@ +/** + * @typedef VesselBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_art - Artery blood flow rate [l/h]. + * @property {math.MathCollection} bf_vein - Vein blood flow rate [l/h]. + */ +/** + * Get artery and vein blood flow rate [l/h]. + * + * @param {math.MathCollection} bf_core - Core blood flow rate [l/h]. + * @param {math.MathCollection} bf_muscle - Muscle blood flow rate [l/h]. + * @param {math.MathCollection} bf_fat - Fat blood flow rate [l/h]. + * @param {math.MathCollection} bf_skin - Skin blood flow rate [l/h]. + * @param {number} bf_ava_hand - AVA blood flow rate at hand [l/h]. + * @param {number} bf_ava_foot - AVA blood flow rate at foot [l/h]. + * + * @returns {VesselBloodFlowResult} bf_artery, bf_vein - Artery and vein blood flow rate [l/h]. + */ +export function vessel_blood_flow(bf_core: math.MathCollection, bf_muscle: math.MathCollection, bf_fat: math.MathCollection, bf_skin: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): VesselBloodFlowResult; +/** + * Create matrix to calculate heat exchange by blood flow in each segment. + * + * @param {math.MathCollection} bf_core + * @param {math.MathCollection} bf_muscle + * @param {math.MathCollection} bf_fat + * @param {math.MathCollection} bf_skin + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @returns {math.Matrix} The heat exchange by blood flow in each segment. + */ +export function local_arr(bf_core: math.MathCollection, bf_muscle: math.MathCollection, bf_fat: math.MathCollection, bf_skin: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): math.Matrix; +/** + * Create matrix to calculate heat exchange by blood flow between segments. [W/K] + * + * @param {math.MathCollection} bf_art + * @param {math.MathCollection} bf_vein + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @return {math.Matrix} + */ +export function whole_body(bf_art: math.MathCollection, bf_vein: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): math.Matrix; +export const BODY_NAMES: string[]; +export const LAYER_NAMES: string[]; +export namespace IDICT { + let CB: number; +} +export const NUM_NODES: number; +export const INDEX: {}; +export const VINDEX: {}; +export type VesselBloodFlowResult = { + /** + * - Artery blood flow rate [l/h]. + */ + bf_art: math.MathCollection; + /** + * - Vein blood flow rate [l/h]. + */ + bf_vein: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=matrix.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/matrix.d.ts.map b/lib/cjs/types/jos3_functions/matrix.d.ts.map new file mode 100644 index 0000000..002068a --- /dev/null +++ b/lib/cjs/types/jos3_functions/matrix.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/matrix.js"],"names":[],"mappings":"AAwFA;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AACH,2CATW,KAAK,cAAc,aACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEJ,qBAAqB,CAsHjC;AAED;;;;;;;;;;;GAWG;AACH,mCATW,KAAK,cAAc,aACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEJ,KAAK,MAAM,CAkFvB;AAED;;;;;;;;;GASG;AACH,mCAPW,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEL,KAAK,MAAM,CAkFtB;AAvZD,kCAkBE;AAEF,mCAQE;;;;;;;;;;;YA6DY,KAAK,cAAc;;;;aACnB,KAAK,cAAc;;sBA5FX,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts new file mode 100644 index 0000000..256d2bc --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts @@ -0,0 +1,33 @@ +/** + * @typedef AvaBloodFlowResult + * @type {object} + * @property {number} bf_ava_hand - AVA blood flow rate at hand [L/h]. + * @property {number} bf_ava_foot - AVA blood flow rate at foot [L/h]. + */ +/** + * Calculate areteriovenous anastmoses (AVA) blood flow rate [L/h] based on + * Takemori's model, 1995. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m] + * @param {number} [weight=74.43] - Body weight [kg] + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi" + * @param {number} [age=20] - age [years] + * @param {number} [ci=2.59] - Cardiac index [L/min/m2] + * + * @returns {AvaBloodFlowResult} AVA blood flow rate at hand and foot [L/h] + */ +export function ava_blood_flow(err_cr: math.MathCollection, err_sk: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): AvaBloodFlowResult; +export type AvaBloodFlowResult = { + /** + * - AVA blood flow rate at hand [L/h]. + */ + bf_ava_hand: number; + /** + * - AVA blood flow rate at foot [L/h]. + */ + bf_ava_foot: number; +}; +import * as math from "mathjs"; +//# sourceMappingURL=ava_blood_flow.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts.map new file mode 100644 index 0000000..647d9b1 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ava_blood_flow.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/ava_blood_flow.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;;;;;;;;;;;;;GAaG;AACH,uCAVW,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,kBAAkB,CA0C9B;;;;;iBA1Da,MAAM;;;;iBACN,MAAM;;sBANE,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/basal_met.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/basal_met.d.ts new file mode 100644 index 0000000..0c96d17 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/basal_met.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {string} [bmr_equation="harris-benedict"] - Choose harris-benedict or ganpule. + * + * @returns {number} Basal metabolic rate [W]. + */ +export function basal_met(height?: number, weight?: number, age?: number, sex?: string, bmr_equation?: string): number; +//# sourceMappingURL=basal_met.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/basal_met.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/basal_met.d.ts.map new file mode 100644 index 0000000..bb4d754 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/basal_met.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"basal_met.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/basal_met.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,mCARW,MAAM,WACN,MAAM,QACN,MAAM,QACN,MAAM,iBACN,MAAM,GAEJ,MAAM,CAkDlB"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/clo_area_factor.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/clo_area_factor.d.ts new file mode 100644 index 0000000..88f31e4 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/clo_area_factor.d.ts @@ -0,0 +1,9 @@ +/** + * Calculate clothing area factor + * + * @param {math.Matrix} clo - Clothing insulation. + * + * @returns {math.Matrix} clothing area factor. + */ +export function clo_area_factor(clo: math.Matrix): math.Matrix; +//# sourceMappingURL=clo_area_factor.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/clo_area_factor.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/clo_area_factor.d.ts.map new file mode 100644 index 0000000..01729a5 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/clo_area_factor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"clo_area_factor.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/clo_area_factor.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qCAJW,KAAK,MAAM,GAET,KAAK,MAAM,CAIvB"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/conv_coef.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/conv_coef.d.ts new file mode 100644 index 0000000..34ec772 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/conv_coef.d.ts @@ -0,0 +1,16 @@ +/** + * Calculate convective heat transfer coefficient (hc) [W/(m2*K)] + * + * @param {string} [posture=JOS3Defaults.posture] - Select posture from standing, sitting, lying, sedentary or supine. The default is "standing". + * @param {math.Matrix} [v=JOS3Defaults.air_speed] - Air velocity [m/s]. If Iterable is input, its length should be 17. The default is 0.1. + * @param {math.Matrix} [tdb=JOS3Defaults.dry_bulb_air_temperature] - Air temperature [°C]. If Iterable is input, its length should be 17. The default is 28.8. + * @param {math.Matrix} [t_skin=JOS3Defaults.skin_temperature] - Skin temperature [°C]. If Iterable is input, its length should be 17. The default is 34.0. + * + * @returns {math.Matrix} Convective heat transfer coefficient (hc) [W/(m2*K)]. + * + * @see {@link https://doi.org/10.3130/aija.62.45_5 | Ichihara et al., 1997} + * @see {@link https://doi.org/10.20718/jjpa.13.1_17 | Kurazumi et al., 2008} + */ +export function conv_coef(posture?: string, v?: math.Matrix, tdb?: math.Matrix, t_skin?: math.Matrix): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=conv_coef.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/conv_coef.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/conv_coef.d.ts.map new file mode 100644 index 0000000..1be1dc6 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/conv_coef.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"conv_coef.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/conv_coef.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,oCAVW,MAAM,MACN,KAAK,MAAM,QACX,KAAK,MAAM,WACX,KAAK,MAAM,GAET,KAAK,MAAM,CAkHvB;sBA5HqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts new file mode 100644 index 0000000..971a9f4 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts @@ -0,0 +1,37 @@ +/** + * @typedef CrMsFatBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_core - Core blood flow rate [L/h]. + * @property {math.MathCollection} bf_muscle - Muscle blood flow rate [L/h]. + * @property {math.MathCollection} bf_fat - Fat blood flow rate [L/h]. + */ +/** + * Calculate core, muscle and fat blood flow rate [L/h]. + * + * @param {math.MathCollection} q_work - Heat production by work [W]. + * @param {math.MathCollection} q_shiv - Heat production by shivering [W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose from "dubois","takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - Age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {CrMsFatBloodFlowResult} - Core, muscle and fat blood flow rate [L/h]. + */ +export function cr_ms_fat_blood_flow(q_work: math.MathCollection, q_shiv: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): CrMsFatBloodFlowResult; +export type CrMsFatBloodFlowResult = { + /** + * - Core blood flow rate [L/h]. + */ + bf_core: math.MathCollection; + /** + * - Muscle blood flow rate [L/h]. + */ + bf_muscle: math.MathCollection; + /** + * - Fat blood flow rate [L/h]. + */ + bf_fat: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=cr_ms_fat_blood_flow.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts.map new file mode 100644 index 0000000..3259508 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cr_ms_fat_blood_flow.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,6CAVW,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,sBAAsB,CAoDlC;;;;;aApEa,KAAK,cAAc;;;;eACnB,KAAK,cAAc;;;;YACnB,KAAK,cAAc;;sBAPX,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/dry_r.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/dry_r.d.ts new file mode 100644 index 0000000..0829c1a --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/dry_r.d.ts @@ -0,0 +1,12 @@ +/** + * Calculate total sensible thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * + * @returns {math.Matrix} Total sensible thermal resistance between skin and ambient. + */ +export function dry_r(hc: math.Matrix, hr: math.Matrix, clo: math.Matrix): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=dry_r.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/dry_r.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/dry_r.d.ts.map new file mode 100644 index 0000000..6ca8ed9 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/dry_r.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"dry_r.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/dry_r.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,0BANW,KAAK,MAAM,MACX,KAAK,MAAM,OACX,KAAK,MAAM,GAET,KAAK,MAAM,CAWvB;sBApBqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/error_signals.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/error_signals.d.ts new file mode 100644 index 0000000..85b3efb --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/error_signals.d.ts @@ -0,0 +1,27 @@ +/** + * @typedef ErrorSignalsResult + * @type {object} + * @property {number} wrms - Warm signal [°C]. + * @property {number} clds - Cold signal [°C]. + */ +/** + * Calculate WRMS and CLDS signals of thermoregulation. + * + * @param {math.MathCollection} [err_sk=0] - Difference between set-point and skin temperatures [°C]. + * If the provided value is an array, its length should be 17. + * + * @returns {ErrorSignalsResult} an object containing the results of the calculation. + */ +export function error_signals(err_sk?: math.MathCollection): ErrorSignalsResult; +export type ErrorSignalsResult = { + /** + * - Warm signal [°C]. + */ + wrms: number; + /** + * - Cold signal [°C]. + */ + clds: number; +}; +import * as math from "mathjs"; +//# sourceMappingURL=error_signals.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/error_signals.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/error_signals.d.ts.map new file mode 100644 index 0000000..b6c6f9c --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/error_signals.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"error_signals.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/error_signals.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,uCALW,KAAK,cAAc,GAGjB,kBAAkB,CAiB9B;;;;;UA3Ba,MAAM;;;;UACN,MAAM;;sBANE,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/evaporation.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/evaporation.d.ts new file mode 100644 index 0000000..4e6f472 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/evaporation.d.ts @@ -0,0 +1,46 @@ +/** + * @typedef EvaporationResult + * @type {object} + * @property {math.MathCollection} wet - Local skin wettedness [-]. + * @property {math.MathCollection} e_sk - Evaporative heat loss at the skin by sweating and diffuse [W]. + * @property {math.MathCollection} e_max - Maximum evaporative heat loss at the skin [W]. + * @property {math.MathCollection} e_sweat - Evaporative heat loss at the skin by only sweating [W]. + */ +/** + * Calculate evaporative heat loss. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_skin - Skin temperatures [°C]. + * @param {math.MathCollection} tdb - Air temperatures at local body segments [°C]. + * @param {math.MathCollection} rh - Relative humidity at local body segments [%]. + * @param {math.MathCollection} ret - Total evaporative thermal resistances [m2.K/W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * + * @returns {EvaporationResult} an object containing the results of the calculation. + */ +export function evaporation(err_cr: math.MathCollection, err_sk: math.MathCollection, t_skin: math.MathCollection, tdb: math.MathCollection, rh: math.MathCollection, ret: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number): EvaporationResult; +export function antoine(x: number): number; +export type EvaporationResult = { + /** + * - Local skin wettedness [-]. + */ + wet: math.MathCollection; + /** + * - Evaporative heat loss at the skin by sweating and diffuse [W]. + */ + e_sk: math.MathCollection; + /** + * - Maximum evaporative heat loss at the skin [W]. + */ + e_max: math.MathCollection; + /** + * - Evaporative heat loss at the skin by only sweating [W]. + */ + e_sweat: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=evaporation.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/evaporation.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/evaporation.d.ts.map new file mode 100644 index 0000000..47b7faf --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/evaporation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"evaporation.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/evaporation.js"],"names":[],"mappings":"AAaA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,oCAbW,KAAK,cAAc,UACnB,KAAK,cAAc,UACnB,KAAK,cAAc,OACnB,KAAK,cAAc,MACnB,KAAK,cAAc,OACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,GAEJ,iBAAiB,CA+D7B;AAxFM,2BAHI,MAAM,GACJ,MAAM,CAEqD;;;;;SAK1D,KAAK,cAAc;;;;UACnB,KAAK,cAAc;;;;WACnB,KAAK,cAAc;;;;aACnB,KAAK,cAAc;;sBAhBX,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/fixed_hc.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hc.d.ts new file mode 100644 index 0000000..d8364fb --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hc.d.ts @@ -0,0 +1,5 @@ +/** + * Fixes hc values to fit two-node-model's values. + */ +export function fixed_hc(hc: any, v: any): any; +//# sourceMappingURL=fixed_hc.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/fixed_hc.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hc.d.ts.map new file mode 100644 index 0000000..c183e22 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hc.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"fixed_hc.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/fixed_hc.js"],"names":[],"mappings":"AAGA;;GAEG;AACH,+CAWC"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/fixed_hr.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hr.d.ts new file mode 100644 index 0000000..ecdd6a0 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hr.d.ts @@ -0,0 +1,9 @@ +/** + * Fixes hr values to fit two-node-model's values. + * + * @param {math.MathCollection} hr + * @return {math.Matrix} + */ +export function fixed_hr(hr: math.MathCollection): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=fixed_hr.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/fixed_hr.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hr.d.ts.map new file mode 100644 index 0000000..5ac832e --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/fixed_hr.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"fixed_hr.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/fixed_hr.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,6BAHW,KAAK,cAAc,GAClB,KAAK,MAAM,CAQtB;sBAdqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/local_mbase.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/local_mbase.d.ts new file mode 100644 index 0000000..d36f339 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/local_mbase.d.ts @@ -0,0 +1,14 @@ +/** + * Calculate local basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex='male'] - Sex (male or female). + * @param {string} [bmr_equation='harris-benedict'] - BMR equation to use (harris-benedict or ganpule). + * + * @returns {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + */ +export function local_mbase(height?: number, weight?: number, age?: number, sex?: string, bmr_equation?: string): [math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]; +import * as math from "mathjs"; +//# sourceMappingURL=local_mbase.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/local_mbase.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/local_mbase.d.ts.map new file mode 100644 index 0000000..ba89491 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/local_mbase.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"local_mbase.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/local_mbase.js"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,qCARW,MAAM,WACN,MAAM,QACN,MAAM,QACN,MAAM,iBACN,MAAM,GAEJ,CAAC,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,CAAC,CAuChG;sBAlDqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/local_q_work.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/local_q_work.d.ts new file mode 100644 index 0000000..07268c6 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/local_q_work.d.ts @@ -0,0 +1,12 @@ +/** + * Calculate local thermogenesis by work [W]. + * + * @param {number} bmr - Basal metabolic rate [W] + * @param {number} par - Physical activity ratio [-] + * @throws {Error} If par is less than 1 + * + * @return {math.MathCollection} q_work - Local thermogenesis by work [W] + */ +export function local_q_work(bmr: number, par: number): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=local_q_work.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/local_q_work.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/local_q_work.d.ts.map new file mode 100644 index 0000000..5ea31d9 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/local_q_work.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"local_q_work.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/local_q_work.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,kCANW,MAAM,OACN,MAAM,GAGL,KAAK,cAAc,CAe9B;sBAxBqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/nonshivering.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/nonshivering.d.ts new file mode 100644 index 0000000..d5f5a15 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/nonshivering.d.ts @@ -0,0 +1,16 @@ +/** + * Calculate local metabolic rate by non-shivering [W] + * + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {boolean} [cold_acclimation=false] - Whether the subject acclimates cold environment or not. + * @param {boolean} [batpositive=true] - Whether BAT activity is positive or not. + * + * @returns {math.MathCollection} q_nst - Local metabolic rate by non-shivering [W]. + */ +export function nonshivering(err_sk: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, cold_acclimation?: boolean, batpositive?: boolean): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=nonshivering.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/nonshivering.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/nonshivering.d.ts.map new file mode 100644 index 0000000..2706da7 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/nonshivering.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nonshivering.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/nonshivering.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,qCAVW,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,qBACN,OAAO,gBACP,OAAO,GAEL,KAAK,cAAc,CA4D/B;sBAzEqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/operative_temp.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/operative_temp.d.ts new file mode 100644 index 0000000..37a05ad --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/operative_temp.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate operative temperature [°C] + * + * @param {math.MathCollection} tdb - Air temperature [°C] + * @param {math.MathCollection} tr - Mean radiant temperature [°C] + * @param {math.MathCollection} hc - Convective heat transfer coefficient [W/(m2*K)] + * @param {math.MathCollection} hr - Radiative heat transfer coefficient [W/(m2*K)] + + * @returns {math.MathCollection} Operative temperature [°C] + */ +export function operative_temp(tdb: math.MathCollection, tr: math.MathCollection, hc: math.MathCollection, hr: math.MathCollection): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=operative_temp.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/operative_temp.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/operative_temp.d.ts.map new file mode 100644 index 0000000..5da01a2 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/operative_temp.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"operative_temp.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/operative_temp.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,oCAPW,KAAK,cAAc,MACnB,KAAK,cAAc,MACnB,KAAK,cAAc,MACnB,KAAK,cAAc,GAEjB,KAAK,cAAc,CAO/B;sBAjBqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/rad_coef.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/rad_coef.d.ts new file mode 100644 index 0000000..a474d21 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/rad_coef.d.ts @@ -0,0 +1,10 @@ +/** + * Calculate radiative heat transfer coefficient (hr) [W/(m2*K)] + * + * @param {string} posture - Select posture from standing, sitting, lying, sedentary or supine. Default is "standing". + * + * @returns {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + */ +export function rad_coef(posture?: string): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=rad_coef.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/rad_coef.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/rad_coef.d.ts.map new file mode 100644 index 0000000..f70836d --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/rad_coef.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"rad_coef.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/rad_coef.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,mCAJW,MAAM,GAEJ,KAAK,MAAM,CAsCvB;sBA7CqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts new file mode 100644 index 0000000..1b0beea --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts @@ -0,0 +1,27 @@ +/** + * @typedef RespHeatLossResult + * @type {object} + * @property {number} res_sh - Sensible heat loss by respiration [W]. + * @property {number} res_lh - Latent heat loss by respiration [W]. + */ +/** + * Calculate heat loss by respiration [W]. + * + * @param {number} tdb - Dry bulb air temperature [oC]. + * @param {number} p_a - Water vapor pressure in the ambient air [kPa]. + * @param {number} q_thermogenesis_total - Total thermogenesis [W]. + + * @return {RespHeatLossResult} res_sh, res_lh - Sensible and latent heat loss by respiration [W]. + */ +export function resp_heat_loss(tdb: number, p_a: number, q_thermogenesis_total: number): RespHeatLossResult; +export type RespHeatLossResult = { + /** + * - Sensible heat loss by respiration [W]. + */ + res_sh: number; + /** + * - Latent heat loss by respiration [W]. + */ + res_lh: number; +}; +//# sourceMappingURL=resp_heat_loss.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts.map new file mode 100644 index 0000000..ddb08a8 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"resp_heat_loss.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/resp_heat_loss.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,oCANW,MAAM,OACN,MAAM,yBACN,MAAM,GAEL,kBAAkB,CAM7B;;;;;YAjBa,MAAM;;;;YACN,MAAM"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/shivering.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/shivering.d.ts new file mode 100644 index 0000000..f2354c0 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/shivering.d.ts @@ -0,0 +1,27 @@ +/** + * Sets the value of PRE_SHIV. + * + * @param {number} value - the value to set PRE_SHIV to + */ +export function set_pre_shiv(value: number): void; +/** + * Calculate local thermogenesis by shivering [W]. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_core - Core and skin temperatures [°C]. + * @param {math.MathCollection} t_skin - Core and skin temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {number} [dtime=60] - Interval of analysis time. + * @param {object} options - Additional options. + * + * @returns {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + */ +export function shivering(err_cr: math.MathCollection, err_sk: math.MathCollection, t_core: math.MathCollection, t_skin: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, sex?: string, dtime?: number, options?: object): math.MathCollection; +export let PRE_SHIV: number; +import * as math from "mathjs"; +//# sourceMappingURL=shivering.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/shivering.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/shivering.d.ts.map new file mode 100644 index 0000000..4f77877 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/shivering.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"shivering.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/shivering.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,oCAFW,MAAM,QAIhB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,kCAdW,KAAK,cAAc,UACnB,KAAK,cAAc,UACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,QACN,MAAM,UACN,MAAM,YACN,MAAM,GAEJ,KAAK,cAAc,CA8F/B;AAxHD,4BAAwB;sBAFF,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts new file mode 100644 index 0000000..d2f3509 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts @@ -0,0 +1,15 @@ +/** + * Calculate skin blood flow rate (bf_skin) [L/h]. + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {math.MathCollection} bf_skin - Skin blood flow rate [L/h]. + */ +export function skin_blood_flow(err_cr: math.MathCollection, err_sk: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=skin_blood_flow.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts.map new file mode 100644 index 0000000..96a5e4f --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"skin_blood_flow.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/skin_blood_flow.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wCAVW,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,KAAK,cAAc,CA8D/B;sBA1EqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/sum_bf.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/sum_bf.d.ts new file mode 100644 index 0000000..fb3245b --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/sum_bf.d.ts @@ -0,0 +1,15 @@ +/** + * Sum the total blood flow in various body parts. + * + * @param {math.MathCollection} bf_core - Blood flow rate in the core region [L/h]. + * @param {math.MathCollection} bf_muscle - Blood flow rate in the muscle region [L/h]. + * @param {math.MathCollection} bf_fat - Blood flow rate in the fat region [L/h]. + * @param {math.MathCollection} bf_skin - Blood flow rate in the skin region [L/h]. + * @param {number} bf_ava_hand - AVA blood flow rate in one hand [L/h]. + * @param {number} bf_ava_foot - AVA blood flow rate in one foot [L/h]. + * + * @returns {number} co - Cardiac output (the sum of the whole blood flow rate) [L/h]. + */ +export function sum_bf(bf_core: math.MathCollection, bf_muscle: math.MathCollection, bf_fat: math.MathCollection, bf_skin: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): number; +import * as math from "mathjs"; +//# sourceMappingURL=sum_bf.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/sum_bf.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/sum_bf.d.ts.map new file mode 100644 index 0000000..cc3800e --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/sum_bf.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sum_bf.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/sum_bf.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,gCATW,KAAK,cAAc,aACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEJ,MAAM,CAkBlB;sBA9BqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/sum_m.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/sum_m.d.ts new file mode 100644 index 0000000..7ef7ce5 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/sum_m.d.ts @@ -0,0 +1,39 @@ +/** + * @typedef SumMResult + * @type {object} + * @property {math.MathCollection} q_thermogenesis_core - Total thermogenesis in core layer [W]. + * @property {math.MathCollection} q_thermogenesis_muscle - Total thermogenesis in muscle layer [W]. + * @property {math.MathCollection} q_thermogenesis_fat - Total thermogenesis in fat layer [W]. + * @property {math.MathCollection} q_thermogenesis_skin - Total thermogenesis in skin layer [W]. + */ +/** + * Calculate total thermogenesis in each layer [W]. + * + * @param {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + * @param {math.MathCollection} q_work - Local thermogenesis by work [W]. + * @param {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + * @param {math.MathCollection} q_nst - Local thermogenesis by non-shivering [W]. + * + * @return {SumMResult} Total thermogenesis in core, muscle, fat, skin layers [W]. + */ +export function sum_m(mbase: [math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection], q_work: math.MathCollection, q_shiv: math.MathCollection, q_nst: math.MathCollection): SumMResult; +export type SumMResult = { + /** + * - Total thermogenesis in core layer [W]. + */ + q_thermogenesis_core: math.MathCollection; + /** + * - Total thermogenesis in muscle layer [W]. + */ + q_thermogenesis_muscle: math.MathCollection; + /** + * - Total thermogenesis in fat layer [W]. + */ + q_thermogenesis_fat: math.MathCollection; + /** + * - Total thermogenesis in skin layer [W]. + */ + q_thermogenesis_skin: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=sum_m.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/sum_m.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/sum_m.d.ts.map new file mode 100644 index 0000000..02abade --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/sum_m.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sum_m.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/sum_m.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AACH,6BAPW,CAAC,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,CAAC,UACpF,KAAK,cAAc,UACnB,KAAK,cAAc,SACnB,KAAK,cAAc,GAElB,UAAU,CAkCrB;;;;;0BAhDa,KAAK,cAAc;;;;4BACnB,KAAK,cAAc;;;;yBACnB,KAAK,cAAc;;;;0BACnB,KAAK,cAAc;;sBARX,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/wet_r.d.ts b/lib/cjs/types/jos3_functions/thermoregulation/wet_r.d.ts new file mode 100644 index 0000000..6ac233d --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/wet_r.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate total evaporative thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * @param {number | math.Matrix} [i_clo=0.45] - Clothing vapor permeation efficiency [-]. + * @param {number} [lewis_rate=16.5] - Lewis rate [K/kPa]. + * + * @returns {math.Matrix} r_et - Total evaporative thermal resistance. + */ +export function wet_r(hc: math.Matrix, clo: math.Matrix, i_clo?: number | math.Matrix, lewis_rate?: number): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=wet_r.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/thermoregulation/wet_r.d.ts.map b/lib/cjs/types/jos3_functions/thermoregulation/wet_r.d.ts.map new file mode 100644 index 0000000..2123463 --- /dev/null +++ b/lib/cjs/types/jos3_functions/thermoregulation/wet_r.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wet_r.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/wet_r.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,0BAPW,KAAK,MAAM,OACX,KAAK,MAAM,UACX,MAAM,GAAG,KAAK,MAAM,eACpB,MAAM,GAEJ,KAAK,MAAM,CAiBvB;sBA3BqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/validate_body_parameters.d.ts b/lib/cjs/types/jos3_functions/validate_body_parameters.d.ts new file mode 100644 index 0000000..abd2fc0 --- /dev/null +++ b/lib/cjs/types/jos3_functions/validate_body_parameters.d.ts @@ -0,0 +1,12 @@ +/** + * Validate the parameters: height, weight, age, and body fat percentage. + * + * @param {number} height - The height of the person in meters. + * @param {number} weight - The weight of the person in kilograms. + * @param {number} age - The age of the person in years. + * @param {number} body_fat - The body fat percentage as a fraction of total body mass. + + * @throws {Error} If any of the parameters are out of the specified range. + */ +export function validate_body_parameters(height?: number, weight?: number, age?: number, body_fat?: number): void; +//# sourceMappingURL=validate_body_parameters.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/validate_body_parameters.d.ts.map b/lib/cjs/types/jos3_functions/validate_body_parameters.d.ts.map new file mode 100644 index 0000000..872c5c2 --- /dev/null +++ b/lib/cjs/types/jos3_functions/validate_body_parameters.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"validate_body_parameters.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/validate_body_parameters.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,kDAPW,MAAM,WACN,MAAM,QACN,MAAM,aACN,MAAM,QAyBhB"} \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/weight_rate.d.ts b/lib/cjs/types/jos3_functions/weight_rate.d.ts new file mode 100644 index 0000000..5f5f05c --- /dev/null +++ b/lib/cjs/types/jos3_functions/weight_rate.d.ts @@ -0,0 +1,20 @@ +/** + * Calculate the ratio of the body weight to the standard body (74.43 kg). + * + * The standard values of local body weights are as as follows: + * weight_local = [ + * 3.18, 0.84, 12.4, 11.03, 17.57, + * 2.16, 1.37, 0.34, 2.16, 1.37, 0.34, + * 7.01, 3.34, 0.48, 7.01, 3.34, 0.48 + * ] + * + * The data have been derived from 65MN. + * The weight of neck is extracted from the weight of 65MN's head based on + * the local body surface area of Smith's model. + * + * @param {number} [weight=JOS3Defaults.weight] - The body weight [kg]. + * + * @returns {number} the ratio of the body weight to the standard body (74.43 kg). + */ +export function weight_rate(weight?: number): number; +//# sourceMappingURL=weight_rate.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/jos3_functions/weight_rate.d.ts.map b/lib/cjs/types/jos3_functions/weight_rate.d.ts.map new file mode 100644 index 0000000..ec1714b --- /dev/null +++ b/lib/cjs/types/jos3_functions/weight_rate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"weight_rate.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/weight_rate.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,qCAJW,MAAM,GAEJ,MAAM,CAKlB"} \ No newline at end of file diff --git a/lib/cjs/types/models/JOS3.d.ts b/lib/cjs/types/models/JOS3.d.ts new file mode 100644 index 0000000..c4046c4 --- /dev/null +++ b/lib/cjs/types/models/JOS3.d.ts @@ -0,0 +1,385 @@ +/** + * JOS-3 model simulates human thermal physiology including skin + * temperature, core temperature, sweating rate, etc. for the whole body and + * 17 local body parts. + * + * This model was developed at Shin-ichi Tanabe Laboratory, Waseda University + * and was derived from 65 Multi-Node model (https://doi.org/10.1016/S0378-7788(02)00014-2) + * and JOS-2 model (https://doi.org/10.1016/j.buildenv.2013.04.013). + * + * To use this model, create an instance of the JOS3 class with optional body parameters + * such as body height, weight, age, sex, etc. + * + * Environmental conditions such as air temperature, mean radiant temperature, air velocity, etc. + * can be set using the setter methods. (ex. X.tdb, X.tr X.v) + * If you want to set the different conditions in each body part, set them + * as a 17 lengths of list, dictionary, or numpy array format. + * + * List or numpy array format input must be 17 lengths and means the order of "head", "neck", "chest", + * "back", "pelvis", "left_shoulder", "left_arm", "left_hand", "right_shoulder", "right_arm", + * "right_hand", "left_thigh", "left_leg", "left_foot", "right_thigh", "right_leg" and "right_foot". + * + * The model output includes local and mean skin temperature, local core temperature, + * local and mean skin wettedness, and heat loss from the skin etc. + * The model output can be accessed using "dict_results()" method and be converted to a csv file + * using "to_csv" method. + * Each output parameter also can be accessed using getter methods. + * (ex. X.t_skin, X.t_skin_mean, X.t_core) + * + * If you use this package, please cite us as follows and mention the version of pythermalcomfort used: + * Y. Takahashi, A. Nomoto, S. Yoda, R. Hisayama, M. Ogata, Y. Ozeki, S. Tanabe, + * Thermoregulation Model JOS-3 with New Open Source Code, Energy & Buildings (2020), + * doi: https://doi.org/10.1016/j.enbuild.2020.110575 + * + * Note: To maintain consistency in variable names for jsthermalcomfort and pythermalcomfort, + * some variable names differ from those used in the original paper. + * + * @public + * @memberof models + * @docname JOS3 + */ +export class JOS3 { + /** + * Initialize a new instance of JOS3 class, which is designed to model + * and simulate various physiological parameters related to human + * thermoregulation. + * + * This class uses mathematical models to calculate and predict + * body temperature, basal metabolic rate, body surface area, and + * other related parameters. + * + * @param {number} [height] - body height, in [m]. + * @param {number} [weight] - body weight, in [kg]. + * @param {number} [fat] - fat percentage, in [%]. + * @param {number} [age] - age, in [years]. + * @param {"male" | "female"} [sex] - sex. + * @param {number} [ci] - Cardiac index, in [L/min/m2]. + * @param {"harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule"} [bmr_equation] - The equation used + * to calculate basal metabolic rate (BMR). + * @param {"dubois" | "fujimoto" | "kruazumi" | "takahira"} [bsa_equation] - The equation used to calculate body + * surface area (bsa). + * @param {[] | "all"} [ex_output] - This is used when you want to display results other than the default output + * parameters (ex.skin temperature); by default, JOS outputs only the most necessary parameters in order to reduce + * the computational load. + */ + constructor(height?: number, weight?: number, fat?: number, age?: number, sex?: "male" | "female", ci?: number, bmr_equation?: "harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule", bsa_equation?: "dubois" | "fujimoto" | "kruazumi" | "takahira", ex_output?: [] | "all"); + _height: number; + _weight: number; + _fat: number; + _age: number; + _sex: "male" | "female"; + _ci: number; + _bmr_equation: "harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule"; + _bsa_equation: "dubois" | "takahira" | "fujimoto" | "kruazumi"; + _ex_output: [] | "all"; + _bsa_rate: number; + _bsa: math.Matrix; + _bfb_rate: number; + _cdt: math.Matrix; + _cap: number[]; + setpt_cr: math.MathType; + setpt_sk: math.MathType; + _bodytemp: math.MathType; + _ta: math.MathType; + _tr: math.MathType; + _rh: math.MathType; + _va: math.MathType; + _clo: math.MathType; + _iclo: math.MathType; + _par: number; + _posture: string; + _hc: any; + _hr: any; + ex_q: math.MathCollection; + _t: number; + _cycle: number; + model_name: string; + options: { + nonshivering_thermogenesis: boolean; + cold_acclimated: boolean; + shivering_threshold: boolean; + "limit_dshiv/dt": boolean; + bat_positive: boolean; + ava_zero: boolean; + shivering: boolean; + }; + _history: any[]; + /** + * Calculate operative temperature [°C] when PMV=0. + * + * @private + * + * @param va {number} - Air velocity [m/s]. + * @param rh {number} - Relative humidity [%]. + * @param met {number} - Metabolic rate [met]. + * @param clo {number} - Clothing insulation [clo]. + * + * @returns {number} + */ + private _calculate_operative_temp_when_pmv_is_zero; + /** + * Reset set-point temperatures under steady state calculation. + * Set-point temperatures are hypothetical core or skin temperatures in a thermally neutral state + * when at rest (similar to room set-point temperature for air conditioning). + * This function is used during initialization to calculate the set-point temperatures as a reference for thermoregulation. + * Be careful, input parameters (tdb, tr, rh, v, clo, par) and body temperatures are also reset. + * + * @private + * + * @param par {number} - Physical activity ratio. + */ + private _reset_setpt; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set to(arg: math.Matrix); + /** + * Operative temperature [°C]. + * + * @return {math.Matrix} + */ + get to(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set rh(arg: math.Matrix); + /** + * Relative humidity [%]. + * + * @return {math.Matrix} + */ + get rh(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set v(arg: math.Matrix); + /** + * Air velocity [m/s]. + * + * @return {math.Matrix} + */ + get v(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set clo(arg: math.Matrix); + /** + * Clothing insulation [clo]. + * + * @return {math.Matrix} + */ + get clo(): math.Matrix; + /** + * @param inp {number} + */ + set par(arg: number); + /** + * Physical activity ratio [-].This equals the ratio of metabolic rate to basal metabolic rate. par of sitting quietly is 1.2. + * + * @return {number} + */ + get par(): number; + /** + * Run JOS-3 model. + * + * @property {number} times - Number of loops of a simulation. + * @property {number} [dtime=60] - Time delta in seconds. + * @property {boolean} [output=true] - If you don't want to record parameters, set False. + */ + simulate(times: any, dtime?: number, output?: boolean): void; + /** + * Runs the model once and gets the model parameters. + * + * The function then calculates several thermoregulation parameters using the input data, + * such as convective and radiative heat transfer coefficients, operative temperature, heat resistance, + * and blood flow rates. + * + * It also calculates the thermogenesis by shivering and non-shivering, basal thermogenesis, and thermogenesis by work. + * + * The function then calculates the total heat loss and gains, including respiratory, + * sweating, and extra heat gain, and builds the matrices required + * to solve for the new body temperature. + * + * It then calculates the new body temperature by solving the matrices using numpy's linalg library. + * + * Finally, the function returns a dictionary of the simulation results. + * The output parameters include cycle time, model time, t_skin_mean, t_skin, t_core, w_mean, w, weight_loss_by_evap_and_res, cardiac_output, q_thermogenesis_total, q_res, and q_skin_env. + * + * Additionally, if the _ex_output variable is set to "all" or is a list of keys, + * the function also returns a detailed dictionary of all the thermoregulation parameters + * and other variables used in the simulation. + * + * @private + * + * @param {number} dtime - Time delta [sec]. + * @param {boolean} passive - If you run a passive model. + * @param {boolean} output - If you don't need parameters. + * + * @returns {object} + */ + private _run; + /** + * Get results as a dictionary with the model values. + * + * @returns {object} + */ + dict_results(): object; + /** + * Set extra heat gain by tissue name. + * + * @private + * + * @param {string} tissue - Tissue name. "core", "skin", or "artery".... If you set value to head muscle and other segment's core, set "all_muscle". + * @param {number | math.MathCollection} value - Heat gain [W] + * + * @return {math.MathCollection} Extra heat gain of model. + */ + private _set_ex_q; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tdb(arg: math.Matrix); + /** + * Dry-bulb air temperature. + * + * @return {math.Matrix} + */ + get tdb(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tr(arg: math.Matrix); + /** + * Mean radiant temperature [°C]. + * + * @return {math.Matrix} + */ + get tr(): math.Matrix; + /** + * @param inp {number | string} + */ + set posture(arg: string); + /** + * Current JOS3 posture. + * + * @return {string} + */ + get posture(): string; + /** + * @param inp {math.Matrix} + */ + set body_temp(arg: math.Matrix); + /** + * All segment temperatures of JOS-3. + * + * @return {math.Matrix} + */ + get body_temp(): math.Matrix; + /** + * Body surface areas by local body segments [m2]. + * + * @return {math.Matrix} + */ + get bsa(): math.Matrix; + /** + * Dry heat resistances between the skin and ambience areas by local body segments [(m2*K)/W]. + * + * @return {math.Matrix} + */ + get r_t(): math.Matrix; + /** + * w (Evaporative) heat resistances between the skin and ambience areas by local body segments [(m2*kPa)/W]. + * + * @return {math.Matrix} + */ + get r_et(): math.Matrix; + /** + * Skin wettedness on local body segments [-]. + * + * @return {math.Matrix} + */ + get w(): math.Matrix; + /** + * Mean skin wettedness of the whole body [-]. + * + * @return {number} + */ + get w_mean(): number; + /** + * Mean skin temperature of the whole body [°C]. + * + * @return {number} + */ + get t_skin_mean(): number; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set t_skin(arg: math.Matrix); + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_skin(): math.Matrix; + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_core(): math.Matrix; + /** + * Temperature at central blood pool [°C]. + * + * @return {number} + */ + get t_cb(): number; + /** + * Arterial temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_artery(): math.Matrix; + /** + * Vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_vein(): math.Matrix; + /** + * Superficial vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_superficial_vein(): math.Matrix; + /** + * Muscle temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_muscle(): math.Matrix; + /** + * Fat temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_fat(): math.Matrix; + /** + * JOS3 body names + * + * @return {string[]} + */ + get body_names(): string[]; + /** + * Results of the model. + * + * @return {object} + */ + get results(): any; + /** + * Basal metabolic rate. + * @returns {number} + */ + get bmr(): number; +} +import * as math from "mathjs"; +//# sourceMappingURL=JOS3.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/models/JOS3.d.ts.map b/lib/cjs/types/models/JOS3.d.ts.map new file mode 100644 index 0000000..666bf90 --- /dev/null +++ b/lib/cjs/types/models/JOS3.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"JOS3.d.ts","sourceRoot":"","sources":["../../../../src/models/JOS3.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;IACE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,qBAdW,MAAM,WACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,GAAG,QAAQ,OACjB,MAAM,iBACN,iBAAiB,GAAG,wBAAwB,GAAG,UAAU,GAAG,SAAS,iBAErE,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,cAE/C,EAAE,GAAG,KAAK,EAmGpB;IAnFC,gBAAqB;IACrB,gBAAqB;IACrB,aAAe;IACf,aAAe;IACf,wBAAe;IACf,YAAa;IACb,qFAAiC;IACjC,+DAAiC;IACjC,uBAA2B;IAG3B,kBAAuD;IAGvD,kBAAmD;IAGnD,kBAAgE;IAGhE,kBAA0D;IAG1D,eAA2D;IAG3D,wBAA2E;IAC3E,wBAA2E;IAG3E,yBAGC;IAID,mBAGC;IACD,mBAGC;IACD,mBAAuE;IACvE,mBAA+D;IAC/D,oBAA0E;IAC1E,qBAGC;IACD,aAAgD;IAChD,iBAAoC;IACpC,SAAe;IACf,SAAe;IACf,0BAAiC;IACjC,WAAW;IACX,eAAe;IACf,mBAAwB;IACxB;;;;;;;;MAQC;IAMD,gBAAkB;IAWpB;;;;;;;;;;;OAWG;IACH,mDAuBC;IAED;;;;;;;;;;OAUG;IACH,qBA+BC;IAopBD;;OAEG;IACH,yBAGC;IAtBD;;;;OAIG;IACH,sBASC;IAmBD;;OAEG;IACH,yBAEC;IAdD;;;;OAIG;IACH,sBAEC;IAkBD;;OAEG;IACH,wBAEC;IAdD;;;;OAIG;IACH,qBAEC;IAkDD;;OAEG;IACH,0BAEC;IAdD;;;;OAIG;IACH,uBAEC;IAkBD;;OAEG;IACH,qBAEC;IAdD;;;;OAIG;IACH,kBAEC;IAjvBD;;;;;;OAMG;IACH,6DAiBC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,aA2dC;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAyDlB;IAED;;;;;;;;;OASG;IACH,kBAGC;IAWD;;OAEG;IACH,0BAEC;IAdD;;;;OAIG;IACH,uBAEC;IAkBD;;OAEG;IACH,yBAEC;IAdD;;;;OAIG;IACH,sBAEC;IA0ED;;OAEG;IACH,yBAkBC;IA9BD;;;;OAIG;IACH,sBAEC;IAkED;;OAEG;IACH,gCAEC;IAdD;;;;OAIG;IACH,6BAEC;IASD;;;;OAIG;IACH,uBAEC;IAED;;;;OAIG;IACH,uBASC;IAED;;;;OAIG;IACH,wBAOC;IAED;;;;OAIG;IACH,qBAgBC;IAED;;;;OAIG;IACH,qBAIC;IAED;;;;OAIG;IACH,0BASC;IAWD;;OAEG;IACH,6BAMC;IAlBD;;;;OAIG;IACH,0BAEC;IAaD;;;;OAIG;IACH,0BAEC;IAED;;;;OAIG;IACH,mBAEC;IAED;;;;OAIG;IACH,4BAEC;IAED;;;;OAIG;IACH,0BAEC;IAED;;;;OAIG;IACH,sCAEC;IAED;;;;OAIG;IACH,4BAEC;IAED;;;;OAIG;IACH,yBAEC;IAED;;;;OAIG;IACH,2BAEC;IAED;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,kBAUC;CACF;sBA3wCqB,QAAQ"} \ No newline at end of file diff --git a/lib/cjs/types/models/index.d.ts b/lib/cjs/types/models/index.d.ts index 2e89339..c846f76 100644 --- a/lib/cjs/types/models/index.d.ts +++ b/lib/cjs/types/models/index.d.ts @@ -1,78 +1,80 @@ declare namespace _default { - export { heat_index }; - export { phs }; - export { humidex }; - export { net }; - export { wbgt }; - export { clo_tout }; - export { clo_tout_array }; - export { discomfort_index }; - export { discomfort_index_array }; - export { two_nodes }; - export { two_nodes_array }; - export { wc }; + export { adaptive_ashrae }; + export { adaptive_ashrae_array }; export { adaptive_en }; export { adaptive_en_array }; + export { a_pmv }; + export { a_pmv_array }; + export { athb }; + export { athb_array }; + export { e_pmv }; + export { e_pmv_array }; export { at }; - export { vertical_tmp_grad_ppd }; - export { set_tmp }; - export { set_tmp_array }; - export { adaptive_ashrae }; - export { adaptive_ashrae_array }; - export { solar_gain }; + export { ankle_draft }; + export { clo_tout }; + export { clo_tout_array }; export { cooling_effect }; + export { discomfort_index }; + export { discomfort_index_array }; + export { heat_index }; + export { humidex }; + export { net }; + export { phs }; + export { pet_steady }; export { pmv_ppd }; export { pmv_ppd_array }; export { pmv }; export { pmv_array }; - export { athb }; - export { athb_array }; - export { a_pmv }; - export { a_pmv_array }; - export { ankle_draft }; - export { e_pmv }; - export { e_pmv_array }; - export { use_fans_heatwaves }; + export { solar_gain }; + export { set_tmp }; + export { set_tmp_array }; + export { two_nodes }; + export { two_nodes_array }; export { utci }; export { utci_array }; - export { pet_steady }; + export { use_fans_heatwaves }; + export { vertical_tmp_grad_ppd }; + export { wbgt }; + export { wc }; + export { JOS3 }; } export default _default; -import { heat_index } from "./heat_index.js"; -import { phs } from "./phs.js"; -import { humidex } from "./humidex.js"; -import { net } from "./net.js"; -import { wbgt } from "./wbgt.js"; -import { clo_tout } from "./clo_tout.js"; -import { clo_tout_array } from "./clo_tout.js"; -import { discomfort_index } from "./discomfort_index.js"; -import { discomfort_index_array } from "./discomfort_index.js"; -import { two_nodes } from "./two_nodes.js"; -import { two_nodes_array } from "./two_nodes.js"; -import { wc } from "./wc.js"; +import { adaptive_ashrae } from "./adaptive_ashrae.js"; +import { adaptive_ashrae_array } from "./adaptive_ashrae.js"; import { adaptive_en } from "./adaptive_en.js"; import { adaptive_en_array } from "./adaptive_en.js"; +import { a_pmv } from "./a_pmv.js"; +import { a_pmv_array } from "./a_pmv.js"; +import { athb } from "./athb.js"; +import { athb_array } from "./athb.js"; +import { e_pmv } from "./e_pmv.js"; +import { e_pmv_array } from "./e_pmv.js"; import { at } from "./at.js"; -import { vertical_tmp_grad_ppd } from "./vertical_tmp_grad_ppd.js"; -import { set_tmp } from "./set_tmp.js"; -import { set_tmp_array } from "./set_tmp.js"; -import { adaptive_ashrae } from "./adaptive_ashrae.js"; -import { adaptive_ashrae_array } from "./adaptive_ashrae.js"; -import { solar_gain } from "./solar_gain.js"; +import { ankle_draft } from "./ankle_draft.js"; +import { clo_tout } from "./clo_tout.js"; +import { clo_tout_array } from "./clo_tout.js"; import { cooling_effect } from "./cooling_effect.js"; +import { discomfort_index } from "./discomfort_index.js"; +import { discomfort_index_array } from "./discomfort_index.js"; +import { heat_index } from "./heat_index.js"; +import { humidex } from "./humidex.js"; +import { net } from "./net.js"; +import { phs } from "./phs.js"; +import { pet_steady } from "./pet_steady.js"; import { pmv_ppd } from "./pmv_ppd.js"; import { pmv_ppd_array } from "./pmv_ppd.js"; import { pmv } from "./pmv.js"; import { pmv_array } from "./pmv.js"; -import { athb } from "./athb.js"; -import { athb_array } from "./athb.js"; -import { a_pmv } from "./a_pmv.js"; -import { a_pmv_array } from "./a_pmv.js"; -import { ankle_draft } from "./ankle_draft.js"; -import { e_pmv } from "./e_pmv.js"; -import { e_pmv_array } from "./e_pmv.js"; -import { use_fans_heatwaves } from "./use_fans_heatwave.js"; +import { solar_gain } from "./solar_gain.js"; +import { set_tmp } from "./set_tmp.js"; +import { set_tmp_array } from "./set_tmp.js"; +import { two_nodes } from "./two_nodes.js"; +import { two_nodes_array } from "./two_nodes.js"; import { utci } from "./utci.js"; import { utci_array } from "./utci.js"; -import { pet_steady } from "./pet_steady.js"; +import { use_fans_heatwaves } from "./use_fans_heatwave.js"; +import { vertical_tmp_grad_ppd } from "./vertical_tmp_grad_ppd.js"; +import { wbgt } from "./wbgt.js"; +import { wc } from "./wc.js"; +import { JOS3 } from "./JOS3.js"; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/models/index.d.ts.map b/lib/cjs/types/models/index.d.ts.map index 6deff00..4a5383d 100644 --- a/lib/cjs/types/models/index.d.ts.map +++ b/lib/cjs/types/models/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAA2B,iBAAiB;oBACxB,UAAU;wBACN,cAAc;oBAClB,UAAU;qBACT,WAAW;yBAqBS,eAAe;+BAAf,eAAe;iCAjBjD,uBAAuB;uCAAvB,uBAAuB;0BACa,gBAAgB;gCAAhB,gBAAgB;mBAExC,SAAS;4BACmB,kBAAkB;kCAAlB,kBAAkB;mBAC9C,SAAS;sCAUU,4BAA4B;wBAb3B,cAAc;8BAAd,cAAc;gCAKE,sBAAsB;sCAAtB,sBAAsB;2BAClD,iBAAiB;+BACb,qBAAqB;wBAHb,cAAc;8BAAd,cAAc;oBAKtB,UAAU;0BAAV,UAAU;qBADR,WAAW;2BAAX,WAAW;sBAET,YAAY;4BAAZ,YAAY;4BACnB,kBAAkB;sBACX,YAAY;4BAAZ,YAAY;mCAEZ,wBAAwB;qBAE1B,WAAW;2BAAX,WAAW;2BACjB,iBAAiB"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAeuD,sBAAsB;sCAAtB,sBAAsB;4BAH9B,kBAAkB;kCAAlB,kBAAkB;sBAQ9B,YAAY;4BAAZ,YAAY;qBAFd,WAAW;2BAAX,WAAW;sBAIT,YAAY;4BAAZ,YAAY;mBAT5B,SAAS;4BAQA,kBAAkB;yBAIL,eAAe;+BAAf,eAAe;+BARzB,qBAAqB;iCAT7C,uBAAuB;uCAAvB,uBAAuB;2BARH,iBAAiB;wBAEpB,cAAc;oBAClB,UAAU;oBAFV,UAAU;2BA0BH,iBAAiB;wBAbL,cAAc;8BAAd,cAAc;oBAKtB,UAAU;0BAAV,UAAU;2BAHd,iBAAiB;wBANL,cAAc;8BAAd,cAAc;0BADV,gBAAgB;gCAAhB,gBAAgB;qBAiB1B,WAAW;2BAAX,WAAW;mCAFT,wBAAwB;sCADrB,4BAA4B;qBAnB7C,WAAW;mBAOb,SAAS;qBAiBP,WAAW"} \ No newline at end of file diff --git a/lib/cjs/types/supa.d.ts b/lib/cjs/types/supa.d.ts new file mode 100644 index 0000000..913f5b6 --- /dev/null +++ b/lib/cjs/types/supa.d.ts @@ -0,0 +1,25 @@ +export function $map(arrays: any, op: any): any[]; +/** + * @template T + * @param {number} length + * @param {T} value + * + * @return {T[]} + */ +export function $array(length: number, value: T): T[]; +/** + * @template T + * @param arrays {T[][]} + * @param op {(reduced: T, items: T[]) => T} + * @param initial {T} + * + * @return {T} + */ +export function $reduce(arrays: T[][], op: (reduced: T, items: T[]) => T, initial: T): T; +export function $average(array: any, weights: any): number; +export function $lerp(length: any, min: any, max: any): any[]; +export function $sum(array: any): any; +export function $max(array: any, sentinel: any): any; +export function $min(array: any, sentinel: any): any; +export function $index(array: any, indicies: any): any; +//# sourceMappingURL=supa.d.ts.map \ No newline at end of file diff --git a/lib/cjs/types/supa.d.ts.map b/lib/cjs/types/supa.d.ts.map new file mode 100644 index 0000000..a8f38ce --- /dev/null +++ b/lib/cjs/types/supa.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"supa.d.ts","sourceRoot":"","sources":["../../../src/supa.js"],"names":[],"mappings":"AAAA,kDAeC;AAED;;;;;;GAMG;AACH,kCALW,MAAM,iBAOhB;AAED;;;;;;;GAOG;AACH,4FAeC;AAED,2DAQC;AAED,8DAIC;AAED,sCAEC;AAED,qDAEC;AAED,qDAEC;AAED,uDAEC"} \ No newline at end of file diff --git a/lib/esm/jos3_functions/JOS3Defaults.js b/lib/esm/jos3_functions/JOS3Defaults.js new file mode 100644 index 0000000..1a1e812 --- /dev/null +++ b/lib/esm/jos3_functions/JOS3Defaults.js @@ -0,0 +1,32 @@ +const JOS3Defaults = { + // Body information + height: 1.72, + weight: 74.43, + age: 20, + body_fat: 15, + cardiac_index: 2.59, + blood_flow_rate: 290, + physical_activity_ratio: 1.25, + metabolic_rate: 1.0, + sex: "male", + posture: "standing", + bmr_equation: "harris-benedict", + bsa_equation: "dubois", + local_bsa: [ + 0.11, 0.029, 0.175, 0.161, 0.221, 0.096, 0.063, 0.05, 0.096, 0.063, 0.05, + 0.209, 0.112, 0.056, 0.209, 0.112, 0.056, + ], + // Environment information + core_temperature: 37, + skin_temperature: 34, + other_body_temperature: 36, + dry_bulb_air_temperature: 28.8, + mean_radiant_temperature: 28.8, + relative_humidity: 50, + air_speed: 0.1, + // Clothing information + clothing_insulation: 0, + clothing_vapor_permeation_efficiency: 0.45, + lewis_rate: 16.5, // [K/kPa] +}; +export default JOS3Defaults; diff --git a/lib/esm/jos3_functions/bfb_rate.js b/lib/esm/jos3_functions/bfb_rate.js new file mode 100644 index 0000000..6b722ff --- /dev/null +++ b/lib/esm/jos3_functions/bfb_rate.js @@ -0,0 +1,36 @@ +import JOS3Defaults from "./JOS3Defaults.js"; +import { bsa_rate } from "./bsa_rate.js"; +import { validate_body_parameters } from "./validate_body_parameters.js"; +import * as math from "mathjs"; +/** + * Calculate the ratio of basal blood flow (BFB) of the standard body (290 L/h). + * + * @param {number} height - Body height [m]. The default is 1.72. + * @param {number} weight - Body weight [kg]. The default is 74.43. + * @param {string} bsa_equation - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". The default is "dubois". + * @param {number} age - age [years]. The default is 20. + * @param {number} ci - Cardiac index [L/min/㎡]. The default is 2.59. + * + * @returns {number} - Basal blood flow rate. + */ +export function bfb_rate(height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age, ci = JOS3Defaults.cardiac_index) { + validate_body_parameters(height, weight, age); + ci *= 60; + if (age < 50) { + ci *= 1; + } + else if (age < 60) { + ci *= 0.85; + } + else if (age < 70) { + ci *= 0.75; + } + else { + // age >= 70 + ci *= 0.7; + } + const bfb_all = ci * + bsa_rate(height, weight, bsa_equation) * + math.sum(JOS3Defaults.local_bsa); + return bfb_all / JOS3Defaults.blood_flow_rate; +} diff --git a/lib/esm/jos3_functions/bsa_rate.js b/lib/esm/jos3_functions/bsa_rate.js new file mode 100644 index 0000000..ce889ea --- /dev/null +++ b/lib/esm/jos3_functions/bsa_rate.js @@ -0,0 +1,21 @@ +import JOS3Defaults from "../jos3_functions/JOS3Defaults.js"; +import { validate_body_parameters } from "./validate_body_parameters.js"; +import { body_surface_area } from "../utilities/utilities.js"; +/** + * Calculates the body surface area rate based on the given height, weight and + * BSA equation. + * + * @param {number} [height=JOS3Defaults.height] - The height of the person in + * meters. + * @param {number} [weight=JOS3Defaults.weight] - The weight of the person in + * kilograms. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The BSA equation + * to use for calculation. + * + * @returns {number} The body surface area rate. + */ +export function bsa_rate(height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation) { + validate_body_parameters(height, weight, bsa_equation); + const bsa_all = body_surface_area(weight, height, bsa_equation); + return bsa_all / JOS3Defaults.local_bsa.reduce((t, c) => t + c, 0); +} diff --git a/lib/esm/jos3_functions/capacity.js b/lib/esm/jos3_functions/capacity.js new file mode 100644 index 0000000..4225857 --- /dev/null +++ b/lib/esm/jos3_functions/capacity.js @@ -0,0 +1,96 @@ +import JOS3Defaults from "./JOS3Defaults.js"; +import { validate_body_parameters } from "./validate_body_parameters.js"; +import { bfb_rate } from "./bfb_rate.js"; +import { weight_rate } from "./weight_rate.js"; +import { NUM_NODES, BODY_NAMES, IDICT } from "./matrix.js"; +/** + * Calculate thermal capacity in Joules per Kelvin (J/K). + * Derived from Yokoyama's model, assuming blood's heat as 1.0 [kcal/L.K]. + * + * @param {number} [height=JOS3Defaults.height] - Body height in meters. Default + * is 1.72. + * @param {number} [weight=JOS3Defaults.weight] - Body weight in kg. Default is + * 74.43. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - Equation name for + * bsa calc. Must be from "dubois","takahira", "fujimoto", "kurazumi". + * Default is "dubois". + * @param {number} [age=JOS3Defaults.age] - Age in years. Default is 20. + * @param {number} [ci=JOS3Defaults.cardiac_index] - Cardiac index in L/min/㎡. + * Default is 2.59. + + * @returns {number[]} - Thermal capacity in W/K. Shape is (NUM_NODES). + */ +export function capacity(height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age, ci = JOS3Defaults.cardiac_index) { + validate_body_parameters(height, weight, age); + // artery [Wh/K] + let cap_art = [ + 0.096, 0.025, 0.12, 0.111, 0.265, 0.0186, 0.0091, 0.0044, 0.0186, 0.0091, + 0.0044, 0.0813, 0.04, 0.0103, 0.0813, 0.04, 0.0103, + ]; + // vein [Wh/K] + let cap_vein = [ + 0.321, 0.085, 0.424, 0.39, 0.832, 0.046, 0.024, 0.01, 0.046, 0.024, 0.01, + 0.207, 0.1, 0.024, 0.207, 0.1, 0.024, + ]; + // superficial vein [Wh/K] + let cap_sfv = [ + 0, 0, 0, 0, 0, 0.025, 0.015, 0.011, 0.025, 0.015, 0.011, 0.074, 0.05, 0.021, + 0.074, 0.05, 0.021, + ]; + // central blood [Wh/K] + let cap_cb = 1.999; + // core [Wh/K] + let cap_cr = [ + 1.7229, 0.564, 10.2975, 9.3935, 4.488, 1.6994, 1.1209, 0.1536, 1.6994, + 1.1209, 0.1536, 5.3117, 2.867, 0.2097, 5.3117, 2.867, 0.2097, + ]; + // muscle [Wh/K] + let cap_ms = [ + 0.305, 0.0, 0.0, 0.0, 7.409, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]; + // fat [Wh/K] + let cap_fat = [ + 0.203, 0.0, 0.0, 0.0, 1.947, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]; + // skin [Wh/K] + let cap_sk = [ + 0.1885, 0.058, 0.441, 0.406, 0.556, 0.126, 0.084, 0.088, 0.126, 0.084, + 0.088, 0.334, 0.169, 0.107, 0.334, 0.169, 0.107, + ]; + // Changes the values based on the standard body + const bfbr = bfb_rate(height, weight, bsa_equation, age, ci); + const wr = weight_rate(weight); + cap_art = cap_art.map((x) => x * bfbr); + cap_vein = cap_vein.map((x) => x * bfbr); + cap_sfv = cap_sfv.map((x) => x * bfbr); + cap_cb = cap_cb * bfbr; + cap_cr = cap_cr.map((x) => x * wr); + cap_ms = cap_ms.map((x) => x * wr); + cap_fat = cap_fat.map((x) => x * wr); + cap_sk = cap_sk.map((x) => x * wr); + let cap_whole = Array(NUM_NODES).fill(0); + cap_whole[0] = cap_cb; + for (let i = 0; i < BODY_NAMES.length; i++) { + // Dictionary of indices in each body segment + // key = layer name, value = index of matrix + let bn = BODY_NAMES[i]; + let index_of = IDICT[bn]; + // Common + cap_whole[index_of["artery"]] = cap_art[i]; + cap_whole[index_of["vein"]] = cap_vein[i]; + cap_whole[index_of["core"]] = cap_cr[i]; + cap_whole[index_of["skin"]] = cap_sk[i]; + // Only limbs + if (i >= 5) { + cap_whole[index_of["sfvein"]] = cap_sfv[i]; + } + // If the segment has a muscle or fat layer + if (index_of["muscle"] !== null || index_of["fat"] !== null) { + cap_whole[index_of["muscle"]] = cap_ms[i]; + cap_whole[index_of["fat"]] = cap_fat[i]; + } + } + return cap_whole.map((x) => x * 3600); +} diff --git a/lib/esm/jos3_functions/conductance.js b/lib/esm/jos3_functions/conductance.js new file mode 100644 index 0000000..20f2b28 --- /dev/null +++ b/lib/esm/jos3_functions/conductance.js @@ -0,0 +1,141 @@ +import JOS3Defaults from "./JOS3Defaults.js"; +import { validate_body_parameters } from "./validate_body_parameters.js"; +import { weight_rate } from "./weight_rate.js"; +import { bsa_rate } from "./bsa_rate.js"; +import { NUM_NODES, BODY_NAMES, IDICT } from "./matrix.js"; +import * as math from "mathjs"; +/** + * Calculate thermal conductance between layers. + + * @param {number} height - Body height in [m]. Default is 1.72. + * @param {number} weight - Body weight in [kg]. Default is 74.43. + * @param {string} bsa_equation - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". Default is "dubois". + * @param {number} fat - Body fat rate in [%]. Default is 15. + + * @returns {math.Matrix} conductance - Thermal conductance between layers in [W/K]. The shape is (NUM_NODES, NUM_NODES). + */ +export function conductance(height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, fat = JOS3Defaults.body_fat) { + validate_body_parameters(height, weight, undefined, fat); + let cdt_cr_sk; + if (fat < 12.5) { + cdt_cr_sk = math.matrix([ + 1.341, 0.93, 1.879, 1.729, 2.37, 1.557, 1.018, 2.21, 1.557, 1.018, 2.21, + 2.565, 1.378, 3.404, 2.565, 1.378, 3.404, + ]); + } + else if (fat < 17.5) { + cdt_cr_sk = math.matrix([ + 1.311, 0.909, 1.785, 1.643, 2.251, 1.501, 0.982, 2.183, 1.501, 0.982, + 2.183, 2.468, 1.326, 3.37, 2.468, 1.326, 3.37, + ]); + } + else if (fat < 22.5) { + cdt_cr_sk = math.matrix([ + 1.282, 0.889, 1.698, 1.563, 2.142, 1.448, 0.947, 2.156, 1.448, 0.947, + 2.156, 2.375, 1.276, 3.337, 2.375, 1.276, 3.337, + ]); + } + else if (fat < 27.5) { + cdt_cr_sk = math.matrix([ + 1.255, 0.87, 1.618, 1.488, 2.04, 1.396, 0.913, 2.13, 1.396, 0.913, 2.13, + 2.285, 1.227, 3.304, 2.285, 1.227, 3.304, + ]); + } + else { + // fat >= 27.5 + cdt_cr_sk = math.matrix([ + 1.227, 0.852, 1.542, 1.419, 1.945, 1.346, 0.88, 1.945, 1.346, 0.88, 1.945, + 2.198, 1.181, 3.271, 2.198, 1.181, 3.271, + ]); + } + let cdt_cr_ms = math.zeros(17); // core to muscle [W/K] + let cdt_ms_fat = math.zeros(17); // muscle to fat [W/K] + let cdt_fat_sk = math.zeros(17); // fat to skin [W/K] + // head and pelvis consists of 65MN's conductances + cdt_cr_ms.set([0], 1.601); // head + cdt_ms_fat.set([0], 13.222); + cdt_fat_sk.set([0], 16.008); + cdt_cr_ms.set([4], 3.0813); // pelvis + cdt_ms_fat.set([4], 10.3738); + cdt_fat_sk.set([4], 41.4954); + // vessel to core + // The shape is a cylinder. + // It is assumed that the inner is vascular radius, 2.5mm and the outer is + // stolwijk's core radius. + // The heat transfer coefficient of the core is assumed as the Michel's + // counter-flow model 0.66816 [W/(m・K)]. + let cdt_ves_cr = math.matrix([ + 0, 0, 0, 0, 0, 0.586, 0.383, 1.534, 0.586, 0.383, 1.534, 0.81, 0.435, 1.816, + 0.81, 0.435, 1.816, + ]); + // superficial vein to skin + let cdt_sfv_sk = math.matrix([ + 0, 0, 0, 0, 0, 57.735, 37.768, 16.634, 57.735, 37.768, 16.634, 102.012, + 54.784, 24.277, 102.012, 54.784, 24.277, + ]); + // art to vein (counter-flow) [W/K] + // The data has been derived Mitchell's model. + // The values = 15.869 [W/(m・K)] * the segment length [m] + let cdt_art_vein = math.matrix([ + 0, 0, 0, 0, 0, 0.537, 0.351, 0.762, 0.537, 0.351, 0.762, 0.826, 0.444, + 0.992, 0.826, 0.444, 0.992, + ]); + // Changes values by body size based on the standard body. + const wr = weight_rate(weight); + const bsar = bsa_rate(height, weight, bsa_equation); + const adjustSphere = (matrix, range) => { + let index = math.index(math.range(0, 2)); + let subset = math.subset(matrix, index); + subset = math.dotDivide(math.dotMultiply(subset, wr), bsar); + return math.subset(matrix, index, subset); + }; + const adjustCylinder = (matrix) => { + let index = math.index(math.range(2, matrix.size()[0])); + let subset = math.subset(matrix, index); + subset = math.dotDivide(math.dotMultiply(subset, bsar ** 2), wr); + return math.subset(matrix, index, subset); + }; + // head, neck (Sphere shape) + cdt_cr_sk = adjustSphere(cdt_cr_sk); + cdt_cr_ms = adjustSphere(cdt_cr_ms); + cdt_ms_fat = adjustSphere(cdt_ms_fat); + cdt_fat_sk = adjustSphere(cdt_fat_sk); + cdt_ves_cr = adjustSphere(cdt_ves_cr); + cdt_sfv_sk = adjustSphere(cdt_sfv_sk); + cdt_art_vein = adjustSphere(cdt_art_vein); + // Others (Cylinder shape) + cdt_cr_sk = adjustCylinder(cdt_cr_sk); + cdt_cr_ms = adjustCylinder(cdt_cr_ms); + cdt_ms_fat = adjustCylinder(cdt_ms_fat); + cdt_fat_sk = adjustCylinder(cdt_fat_sk); + cdt_ves_cr = adjustCylinder(cdt_ves_cr); + cdt_sfv_sk = adjustCylinder(cdt_sfv_sk); + cdt_art_vein = adjustCylinder(cdt_art_vein); + const cdt_whole = math.zeros(NUM_NODES, NUM_NODES); + for (let i = 0; i < BODY_NAMES.length; i++) { + const bn = BODY_NAMES[i]; + // Dictionary of indices in each body segment + // key = layer name, value = index of matrix + const index_of = IDICT[bn]; + // Common + cdt_whole.set([index_of["artery"], index_of["vein"]], cdt_art_vein.get([i])); // art to vein + cdt_whole.set([index_of["artery"], index_of["core"]], cdt_ves_cr.get([i])); // art to cr + cdt_whole.set([index_of["vein"], index_of["core"]], cdt_ves_cr.get([i])); // vein to cr + // Only limbs + if (i >= 5) { + cdt_whole.set([index_of["sfvein"], index_of["skin"]], cdt_sfv_sk.get([i])); // sfv to sk + } + // If the segment has a muscle or fat layer + if (index_of["muscle"] !== null) { + // or not indexof["fat"] is None + cdt_whole.set([index_of["core"], index_of["muscle"]], cdt_cr_ms.get([i])); // cr to ms + cdt_whole.set([index_of["muscle"], index_of["fat"]], cdt_ms_fat.get([i])); // ms to fat + cdt_whole.set([index_of["fat"], index_of["skin"]], cdt_fat_sk.get([i])); // fat to sk + } + else { + cdt_whole.set([index_of["core"], index_of["skin"]], cdt_cr_sk.get([i])); // cr to sk + } + } + // Creates a symmetrical matrix + return math.add(cdt_whole, math.transpose(cdt_whole)); +} diff --git a/lib/esm/jos3_functions/local_bsa.js b/lib/esm/jos3_functions/local_bsa.js new file mode 100644 index 0000000..6fbc9c9 --- /dev/null +++ b/lib/esm/jos3_functions/local_bsa.js @@ -0,0 +1,25 @@ +import JOS3Defaults from "./JOS3Defaults.js"; +import { validate_body_parameters } from "./validate_body_parameters.js"; +import { bsa_rate } from "./bsa_rate.js"; +import * as math from "mathjs"; +/** + * Calculate local body surface area (bsa) [m2]. + * + * The local body surface area has been derived from 65MN. + * The head have been divided to head and neck based on Smith's model. + * head = 0.1396*0.1117/0.1414 (65MN_Head * Smith_Head / Smith_Head+neck) + * neck = 0.1396*0.0297/0.1414 (65MN_Head * Smith_Neck / Smith_Head+neck) + * + * @param {number} [height=JOS3Defaults.height] - Body height [m] + * @param {number} [weight=JOS3Defaults.weight] - Body weight [kg] + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The equation name + * of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", + * or "kurazumi". + * + * @returns {math.Matrix} local_bsa of length 17 - Local body surface area (bsa) [m2] + */ +export function local_bsa(height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation) { + validate_body_parameters(height, weight); + const bsa = bsa_rate(height, weight, bsa_equation); + return math.matrix(math.dotMultiply(JOS3Defaults.local_bsa, bsa)); +} diff --git a/lib/esm/jos3_functions/matrix.js b/lib/esm/jos3_functions/matrix.js new file mode 100644 index 0000000..1f6444e --- /dev/null +++ b/lib/esm/jos3_functions/matrix.js @@ -0,0 +1,311 @@ +import * as math from "mathjs"; +export const BODY_NAMES = [ + "head", + "neck", + "chest", + "back", + "pelvis", + "left_shoulder", + "left_arm", + "left_hand", + "right_shoulder", + "right_arm", + "right_hand", + "left_thigh", + "left_leg", + "left_foot", + "right_thigh", + "right_leg", + "right_foot", +]; +export const LAYER_NAMES = [ + "artery", + "vein", + "sfvein", + "core", + "muscle", + "fat", + "skin", +]; +export const [IDICT, NUM_NODES] = (() => { + // Defines existing layers as 1 or null + let index_dict = {}; + ["head", "pelvis"].forEach((key) => { + index_dict[key] = { + artery: 1, + vein: 1, + sfvein: null, + core: 1, + muscle: 1, + fat: 1, + skin: 1, + }; + }); + ["neck", "chest", "back"].forEach((key) => { + index_dict[key] = { + artery: 1, + vein: 1, + sfvein: null, + core: 1, + muscle: null, + fat: null, + skin: 1, + }; + }); + BODY_NAMES.slice(5).forEach((key) => { + // limb segments + index_dict[key] = { + artery: 1, + vein: 1, + sfvein: 1, + core: 1, + muscle: null, + fat: null, + skin: 1, + }; + }); + // Sets ordered indices in the matrix + index_dict["CB"] = 0; + let order_count = 1; + BODY_NAMES.forEach((bn) => { + LAYER_NAMES.forEach((ln) => { + if (index_dict[bn][ln] !== null) { + index_dict[bn][ln] = order_count; + order_count += 1; + } + }); + }); + return [index_dict, order_count]; +})(); +/** + * @typedef VesselBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_art - Artery blood flow rate [l/h]. + * @property {math.MathCollection} bf_vein - Vein blood flow rate [l/h]. + */ +/** + * Get artery and vein blood flow rate [l/h]. + * + * @param {math.MathCollection} bf_core - Core blood flow rate [l/h]. + * @param {math.MathCollection} bf_muscle - Muscle blood flow rate [l/h]. + * @param {math.MathCollection} bf_fat - Fat blood flow rate [l/h]. + * @param {math.MathCollection} bf_skin - Skin blood flow rate [l/h]. + * @param {number} bf_ava_hand - AVA blood flow rate at hand [l/h]. + * @param {number} bf_ava_foot - AVA blood flow rate at foot [l/h]. + * + * @returns {VesselBloodFlowResult} bf_artery, bf_vein - Artery and vein blood flow rate [l/h]. + */ +export function vessel_blood_flow(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot) { + let xbf = math.add(bf_core, bf_muscle, bf_fat, bf_skin); + let bf_art = math.zeros(17); + let bf_vein = math.zeros(17); + // head + bf_art.set([0], xbf.get([0])); + bf_vein.set([0], xbf.get([0])); + // neck (+head) + bf_art.set([1], xbf.get([1]) + xbf.get([0])); + bf_vein.set([1], xbf.get([1]) + xbf.get([0])); + // chest + bf_art.set([2], xbf.get([2])); + bf_vein.set([2], xbf.get([2])); + // back + bf_art.set([3], xbf.get([3])); + bf_vein.set([3], xbf.get([3])); + // pelvis (+Thighs, Legs, Feet, AVA_Feet) + bf_art.set([4], xbf.get([4]) + + math.sum(xbf.subset(math.index(math.range(11, 17)))) + + 2 * bf_ava_foot); + bf_vein.set([4], xbf.get([4]) + + math.sum(xbf.subset(math.index(math.range(11, 17)))) + + 2 * bf_ava_foot); + // L.Shoulder (+Arm, Hand, (arteryのみAVA_Hand)) + bf_art.set([5], math.sum(xbf.subset(math.index(math.range(5, 8)))) + bf_ava_hand); + bf_vein.set([5], math.sum(xbf.subset(math.index(math.range(5, 8))))); + // L.Arm (+Hand) + bf_art.set([6], math.sum(xbf.subset(math.index(math.range(6, 8)))) + bf_ava_hand); + bf_vein.set([6], math.sum(xbf.subset(math.index(math.range(6, 8))))); + // L.Hand + bf_art.set([7], xbf.get([7]) + bf_ava_hand); + bf_vein.set([7], xbf.get([7])); + // R.Shoulder (+Arm, Hand, (arteryのみAVA_Hand)) + bf_art.set([8], math.sum(xbf.subset(math.index(math.range(8, 11)))) + bf_ava_hand); + bf_vein.set([8], math.sum(xbf.subset(math.index(math.range(8, 11))))); + // R.Arm (+Hand) + bf_art.set([9], math.sum(xbf.subset(math.index(math.range(9, 11)))) + bf_ava_hand); + bf_vein.set([9], math.sum(xbf.subset(math.index(math.range(9, 11))))); + // R.Hand + bf_art.set([10], xbf.get([10]) + bf_ava_hand); + bf_vein.set([10], xbf.get([10])); + // L.Thigh (+Leg, Foot, (arteryのみAVA_Foot)) + bf_art.set([11], math.sum(xbf.subset(math.index(math.range(11, 14)))) + bf_ava_foot); + bf_vein.set([11], math.sum(xbf.subset(math.index(math.range(11, 14))))); + // L.Leg (+Foot) + bf_art.set([12], math.sum(xbf.subset(math.index(math.range(12, 14)))) + bf_ava_foot); + bf_vein.set([12], math.sum(xbf.subset(math.index(math.range(12, 14))))); + // L.Foot + bf_art.set([13], xbf.get([13]) + bf_ava_foot); + bf_vein.set([13], xbf.get([13])); + // R.Thigh (+Leg, Foot, (arteryのみAVA_Foot)) + bf_art.set([14], math.sum(xbf.subset(math.index(math.range(14, 17)))) + bf_ava_foot); + bf_vein.set([14], math.sum(xbf.subset(math.index(math.range(14, 17))))); + // R.Leg (+Foot) + bf_art.set([15], math.sum(xbf.subset(math.index(math.range(15, 17)))) + bf_ava_foot); + bf_vein.set([15], math.sum(xbf.subset(math.index(math.range(15, 17))))); + // R.Foot + bf_art.set([16], xbf.get([16]) + bf_ava_foot); + bf_vein.set([16], xbf.get([16])); + return { bf_art, bf_vein }; +} +/** + * Create matrix to calculate heat exchange by blood flow in each segment. + * + * @param {math.MathCollection} bf_core + * @param {math.MathCollection} bf_muscle + * @param {math.MathCollection} bf_fat + * @param {math.MathCollection} bf_skin + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @returns {math.Matrix} The heat exchange by blood flow in each segment. + */ +export function local_arr(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot) { + let bf_local = math.zeros(NUM_NODES, NUM_NODES); + for (let i = 0; i < BODY_NAMES.length; i++) { + // Dictionary of indicies in each body segment + // key = layer name, value = index of matrix + let bn = BODY_NAMES[i]; + let index_of = IDICT[bn]; + // Common + bf_local.set([index_of["core"], index_of["artery"]], 1.067 * bf_core.get([i])); // art to cr + bf_local.set([index_of["skin"], index_of["artery"]], 1.067 * bf_skin.get([i])); // art to sk + bf_local.set([index_of["vein"], index_of["core"]], 1.067 * bf_core.get([i])); // vein to cr + bf_local.set([index_of["vein"], index_of["skin"]], 1.067 * bf_skin.get([i])); // vein to sk + // If the segment has a muscle or fat layer + if (index_of["muscle"] !== null) { + bf_local.set([index_of["muscle"], index_of["artery"]], 1.067 * bf_muscle.get([i])); // art to ms + bf_local.set([index_of["vein"], index_of["muscle"]], 1.067 * bf_muscle.get([i])); // vein to ms + } + if (index_of["fat"] !== null) { + bf_local.set([index_of["fat"], index_of["artery"]], 1.067 * bf_fat.get([i])); // art to ft + bf_local.set([index_of["vein"], index_of["fat"]], 1.067 * bf_fat.get([i])); // vein to ft + } + // Only hand + if (i === 7 || i === 10) { + bf_local.set([index_of["sfvein"], index_of["artery"]], 1.067 * bf_ava_hand); // art to sfv + } + // Only foot + if (i === 13 || i === 16) { + bf_local.set([index_of["sfvein"], index_of["artery"]], 1.067 * bf_ava_foot); // art to sfv + } + } + return bf_local; +} +/** + * Create matrix to calculate heat exchange by blood flow between segments. [W/K] + * + * @param {math.MathCollection} bf_art + * @param {math.MathCollection} bf_vein + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @return {math.Matrix} + */ +export function whole_body(bf_art, bf_vein, bf_ava_hand, bf_ava_foot) { + let arr83 = math.zeros(NUM_NODES, NUM_NODES); + const flow = (up, down, bloodflow) => arr83.set([down, up], bloodflow * 1.067); // Coefficient = 1.067 [Wh/L.K] Change units [L/h] to [W/K] + const CB = IDICT["CB"]; + const head = IDICT["head"]["artery"]; + const neck = IDICT["neck"]["artery"]; + const chest = IDICT["chest"]["artery"]; + const back = IDICT["back"]["artery"]; + const pelvis = IDICT["pelvis"]["artery"]; + const left_shoulder = IDICT["left_shoulder"]["artery"]; + const left_arm = IDICT["left_arm"]["artery"]; + const left_hand = IDICT["left_hand"]["artery"]; + const right_shoulder = IDICT["right_shoulder"]["artery"]; + const right_arm = IDICT["right_arm"]["artery"]; + const right_hand = IDICT["right_hand"]["artery"]; + const left_thigh = IDICT["left_thigh"]["artery"]; + const left_leg = IDICT["left_leg"]["artery"]; + const left_foot = IDICT["left_foot"]["artery"]; + const right_thigh = IDICT["right_thigh"]["artery"]; + const right_leg = IDICT["right_leg"]["artery"]; + const right_foot = IDICT["right_foot"]["artery"]; + flow(CB, neck, bf_art.get([1])); // CB to neck.art + flow(neck, head, bf_art.get([0])); // neck.art to head.art + flow(head + 1, neck + 1, bf_vein.get([0])); // head.vein to neck.vein + flow(neck + 1, CB, bf_vein.get([1])); // neck.vein to CB + flow(CB, chest, bf_art.get([2])); // CB to chest.art + flow(chest + 1, CB, bf_vein.get([2])); // chest.vein to CB + flow(CB, back, bf_art.get([3])); // CB to back.art + flow(back + 1, CB, bf_vein.get([3])); // back.vein to CB + flow(CB, pelvis, bf_art.get([4])); // CB to pelvis.art + flow(pelvis + 1, CB, bf_vein.get([4])); // pelvis.vein to CB + flow(CB, left_shoulder, bf_art.get([5])); // CB to left_shoulder.art + flow(left_shoulder, left_arm, bf_art.get([6])); // left_shoulder.art to left_arm.art + flow(left_arm, left_hand, bf_art.get([7])); // left_arm.art to left_hand.art + flow(left_hand + 1, left_arm + 1, bf_vein.get([7])); // left_hand.vein to left_arm.vein + flow(left_arm + 1, left_shoulder + 1, bf_vein.get([6])); // left_arm.vein to left_shoulder.vein + flow(left_shoulder + 1, CB, bf_vein.get([5])); // left_shoulder.vein to CB + flow(left_hand + 2, left_arm + 2, bf_ava_hand); // left_hand.sfvein to left_arm.sfvein + flow(left_arm + 2, left_shoulder + 2, bf_ava_hand); // left_arm.sfvein to left_shoulder.sfvein + flow(left_shoulder + 2, CB, bf_ava_hand); // left_shoulder.sfvein to CB + flow(CB, right_shoulder, bf_art.get([8])); // CB to right_shoulder.art + flow(right_shoulder, right_arm, bf_art.get([9])); // right_shoulder.art to right_arm.art + flow(right_arm, right_hand, bf_art.get([10])); // right_arm.art to right_hand.art + flow(right_hand + 1, right_arm + 1, bf_vein.get([10])); // right_hand.vein to right_arm.vein + flow(right_arm + 1, right_shoulder + 1, bf_vein.get([9])); // right_arm.vein to right_shoulder.vein + flow(right_shoulder + 1, CB, bf_vein.get([8])); // right_shoulder.vein to CB + flow(right_hand + 2, right_arm + 2, bf_ava_hand); // right_hand.sfvein to right_arm.sfvein + flow(right_arm + 2, right_shoulder + 2, bf_ava_hand); // right_arm.sfvein to right_shoulder.sfvein + flow(right_shoulder + 2, CB, bf_ava_hand); // right_shoulder.sfvein to CB + flow(pelvis, left_thigh, bf_art.get([11])); // pelvis to left_thigh.art + flow(left_thigh, left_leg, bf_art.get([12])); // left_thigh.art to left_leg.art + flow(left_leg, left_foot, bf_art.get([13])); // left_leg.art to left_foot.art + flow(left_foot + 1, left_leg + 1, bf_vein.get([13])); // left_foot.vein to left_leg.vein + flow(left_leg + 1, left_thigh + 1, bf_vein.get([12])); // left_leg.vein to left_thigh.vein + flow(left_thigh + 1, pelvis + 1, bf_vein.get([11])); // left_thigh.vein to pelvis + flow(left_foot + 2, left_leg + 2, bf_ava_foot); // left_foot.sfvein to left_leg.sfvein + flow(left_leg + 2, left_thigh + 2, bf_ava_foot); // left_leg.sfvein to left_thigh.sfvein + flow(left_thigh + 2, pelvis + 1, bf_ava_foot); // left_thigh.vein to pelvis + flow(pelvis, right_thigh, bf_art.get([14])); // pelvis to right_thigh.art + flow(right_thigh, right_leg, bf_art.get([15])); // right_thigh.art to right_leg.art + flow(right_leg, right_foot, bf_art.get([16])); // right_leg.art to right_foot.art + flow(right_foot + 1, right_leg + 1, bf_vein.get([16])); // right_foot.vein to right_leg.vein + flow(right_leg + 1, right_thigh + 1, bf_vein.get([15])); // right_leg.vein to right_thigh.vein + flow(right_thigh + 1, pelvis + 1, bf_vein.get([14])); // right_thigh.vein to pelvis + flow(right_foot + 2, right_leg + 2, bf_ava_foot); // right_foot.sfvein to right_leg.sfvein + flow(right_leg + 2, right_thigh + 2, bf_ava_foot); // right_leg.sfvein to right_thigh.sfvein + flow(right_thigh + 2, pelvis + 1, bf_ava_foot); // right_thigh.vein to pelvis + return arr83; +} +export const [INDEX, VINDEX] = (function () { + const index_by_layer = (layer) => { + const out_index = []; + for (const bn of BODY_NAMES) { + for (const ln of LAYER_NAMES) { + if (layer.toLowerCase() === ln && IDICT[bn][ln] !== null) { + out_index.push(IDICT[bn][ln]); + } + } + } + return out_index; + }; + const valid_index_by_layer = (key) => { + const out_index = []; + for (let i = 0; i < BODY_NAMES.length; i++) { + const bn = BODY_NAMES[i]; + if (IDICT[bn][key] !== null) { + out_index.push(i); + } + } + return out_index; + }; + const index = {}; + const vindex = {}; + for (const key of LAYER_NAMES) { + index[key] = index_by_layer(key); + vindex[key] = valid_index_by_layer(key); + } + return [index, vindex]; +})(); diff --git a/lib/esm/jos3_functions/thermoregulation/ava_blood_flow.js b/lib/esm/jos3_functions/thermoregulation/ava_blood_flow.js new file mode 100644 index 0000000..e192e46 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/ava_blood_flow.js @@ -0,0 +1,45 @@ +import { $average } from "../../supa.js"; +import JOS3Defaults from "../JOS3Defaults.js"; +import { bfb_rate } from "../bfb_rate.js"; +import * as math from "mathjs"; +/** + * @typedef AvaBloodFlowResult + * @type {object} + * @property {number} bf_ava_hand - AVA blood flow rate at hand [L/h]. + * @property {number} bf_ava_foot - AVA blood flow rate at foot [L/h]. + */ +/** + * Calculate areteriovenous anastmoses (AVA) blood flow rate [L/h] based on + * Takemori's model, 1995. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m] + * @param {number} [weight=74.43] - Body weight [kg] + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi" + * @param {number} [age=20] - age [years] + * @param {number} [ci=2.59] - Cardiac index [L/min/m2] + * + * @returns {AvaBloodFlowResult} AVA blood flow rate at hand and foot [L/h] + */ +export function ava_blood_flow(err_cr, err_sk, height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age, ci = JOS3Defaults.cardiac_index) { + // Cal. mean error body core temp. + let cap_bcr = [10.2975, 9.3935, 4.488]; + let err_bcr = math.sum(math.dotMultiply(err_cr.subset(math.index(math.range(2, 5))), cap_bcr)) / math.sum(cap_bcr); + // Cal. mean error skin temp. + let err_msk = math.sum(math.dotMultiply(err_sk, JOS3Defaults.local_bsa)) / + math.sum(JOS3Defaults.local_bsa); + // Openness of AVA [-] + let sig_ava_hand = 0.265 * (err_msk + 0.43) + 0.953 * (err_bcr + 0.1905) + 0.9126; + let sig_ava_foot = 0.265 * (err_msk - 0.997) + 0.953 * (err_bcr + 0.0095) + 0.9126; + sig_ava_hand = Math.min(sig_ava_hand, 1); + sig_ava_hand = Math.max(sig_ava_hand, 0); + sig_ava_foot = Math.min(sig_ava_foot, 1); + sig_ava_foot = Math.max(sig_ava_foot, 0); + // Basal blood flow rate to the standard body [-] + let bfbrate = bfb_rate(height, weight, bsa_equation, age, ci); + // AVA blood flow rate [L/h] + let bf_ava_hand = 1.71 * bfbrate * sig_ava_hand; + let bf_ava_foot = 2.16 * bfbrate * sig_ava_foot; + return { bf_ava_hand, bf_ava_foot }; +} diff --git a/lib/esm/jos3_functions/thermoregulation/basal_met.js b/lib/esm/jos3_functions/thermoregulation/basal_met.js new file mode 100644 index 0000000..c027c28 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/basal_met.js @@ -0,0 +1,48 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +/** + * Calculate basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {string} [bmr_equation="harris-benedict"] - Choose harris-benedict or ganpule. + * + * @returns {number} Basal metabolic rate [W]. + */ +export function basal_met(height = JOS3Defaults.height, weight = JOS3Defaults.weight, age = JOS3Defaults.age, sex = JOS3Defaults.sex, bmr_equation = JOS3Defaults.bmr_equation) { + const valid_equations = [ + "harris-benedict", + "harris-benedict_origin", + "japanese", + "ganpule", + ]; + if (!valid_equations.includes(bmr_equation)) { + throw new Error(`Invalid BMR equation. Must be one of ${valid_equations.join(", ")}`); + } + let bmr; + switch (bmr_equation) { + case "harris-benedict": + bmr = + sex === "male" + ? 88.362 + 13.397 * weight + 500.3 * height - 5.677 * age + : 447.593 + 9.247 * weight + 479.9 * height - 4.33 * age; + break; + case "harris-benedict_origin": + bmr = + sex === "male" + ? 66.473 + 13.7516 * weight + 500.33 * height - 6.755 * age + : 655.0955 + 9.5634 * weight + 184.96 * height - 4.6756 * age; + break; + case "japanese": + case "ganpule": + // Ganpule et al., 2007, https://doi.org/10.1038/sj.ejcn.1602645 + bmr = + sex === "male" + ? 0.0481 * weight + 2.34 * height - 0.0138 * age - 0.4235 + : 0.0481 * weight + 2.34 * height - 0.0138 * age - 0.9708; + bmr *= 1000 / 4.186; + break; + } + return bmr * 0.048; // [kcal/day] to [W] +} diff --git a/lib/esm/jos3_functions/thermoregulation/clo_area_factor.js b/lib/esm/jos3_functions/thermoregulation/clo_area_factor.js new file mode 100644 index 0000000..8ffe65a --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/clo_area_factor.js @@ -0,0 +1,10 @@ +/** + * Calculate clothing area factor + * + * @param {math.Matrix} clo - Clothing insulation. + * + * @returns {math.Matrix} clothing area factor. + */ +export function clo_area_factor(clo) { + return clo.map((clo) => (clo < 0.5 ? clo * 0.2 + 1 : clo * 0.1 + 1.05)); +} diff --git a/lib/esm/jos3_functions/thermoregulation/conv_coef.js b/lib/esm/jos3_functions/thermoregulation/conv_coef.js new file mode 100644 index 0000000..47b795b --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/conv_coef.js @@ -0,0 +1,97 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import * as math from "mathjs"; +/** + * Calculate convective heat transfer coefficient (hc) [W/(m2*K)] + * + * @param {string} [posture=JOS3Defaults.posture] - Select posture from standing, sitting, lying, sedentary or supine. The default is "standing". + * @param {math.Matrix} [v=JOS3Defaults.air_speed] - Air velocity [m/s]. If Iterable is input, its length should be 17. The default is 0.1. + * @param {math.Matrix} [tdb=JOS3Defaults.dry_bulb_air_temperature] - Air temperature [°C]. If Iterable is input, its length should be 17. The default is 28.8. + * @param {math.Matrix} [t_skin=JOS3Defaults.skin_temperature] - Skin temperature [°C]. If Iterable is input, its length should be 17. The default is 34.0. + * + * @returns {math.Matrix} Convective heat transfer coefficient (hc) [W/(m2*K)]. + * + * @see {@link https://doi.org/10.3130/aija.62.45_5 | Ichihara et al., 1997} + * @see {@link https://doi.org/10.20718/jjpa.13.1_17 | Kurazumi et al., 2008} + */ +export function conv_coef(posture = JOS3Defaults.posture, v = math.multiply(math.ones(17), JOS3Defaults.air_speed), tdb = math.multiply(math.ones(17), JOS3Defaults.dry_bulb_air_temperature), t_skin = math.multiply(math.ones(17), JOS3Defaults.skin_temperature)) { + // Convert v to math.matrix + v = math.isMatrix(v) ? v : math.matrix(v); + /** + * Natural convection + * + * @param {string} posture + * @param {math.Matrix} tdb + * @param {math.Matrix} t_skin + * + * @return {math.Matrix} + */ + const natural_convection = (posture, tdb, t_skin) => { + posture = posture.toLowerCase(); + const valid_postures = [ + "standing", + "sitting", + "lying", + "sedentary", + "supine", + ]; + if (!valid_postures.includes(posture)) { + let postures = valid_postures.join(", "); + throw new Error(`Invalid posture ${posture}. Must be one of ${postures}.`); + } + let hc_natural; + switch (posture) { + case "standing": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + hc_natural = math.matrix([ + 4.48, 4.48, 2.97, 2.91, 2.85, 3.61, 3.55, 3.67, 3.61, 3.55, 3.67, 2.8, + 2.04, 2.04, 2.8, 2.04, 2.04, + ]); + break; + case "sitting": + case "sedentary": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + hc_natural = math.matrix([ + 4.75, 4.75, 3.12, 2.48, 1.84, 3.76, 3.62, 2.06, 3.76, 3.62, 2.06, + 2.98, 2.98, 2.62, 2.98, 2.98, 2.62, + ]); + break; + case "lying": + case "supine": + // Kurazumi et al., 2008, https://doi.org/10.20718/jjpa.13.1_17 + // The values are applied under cold environment. + let hc_a = math.matrix([ + 1.105, 1.105, 1.211, 1.211, 1.211, 0.913, 2.081, 2.178, 0.913, 2.081, + 2.178, 0.945, 0.385, 0.2, 0.945, 0.385, 0.2, + ]); + let hc_b = math.matrix([ + 0.345, 0.345, 0.046, 0.046, 0.046, 0.373, 0.85, 0.297, 0.373, 0.85, + 0.297, 0.447, 0.58, 0.966, 0.447, 0.58, 0.966, + ]); + hc_natural = math.dotMultiply(hc_a, math.dotPow(math.abs(math.subtract(tdb, t_skin)), hc_b)); + break; + } + return hc_natural; + }; + /** + * Forced convection + * + * @param v {math.Matrix} + * + * @return {math.Matrix} + */ + const forced_convection = (v) => { + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + let hc_a = math.matrix([ + 15.0, 15.0, 11.0, 17.0, 13.0, 17.0, 17.0, 20.0, 17.0, 17.0, 20.0, 14.0, + 15.8, 15.1, 14.0, 15.8, 15.1, + ]); + let hc_b = math.matrix([ + 0.62, 0.62, 0.67, 0.49, 0.6, 0.59, 0.61, 0.6, 0.59, 0.61, 0.6, 0.61, 0.74, + 0.62, 0.61, 0.74, 0.62, + ]); + return math.dotMultiply(hc_a, math.dotPow(v, hc_b)); + }; + let hc_natural = natural_convection(posture, tdb, t_skin); + let hc_forced = forced_convection(v); + return v.map((z, idx) => z < 0.2 ? hc_natural.get(idx) : hc_forced.get(idx)); +} diff --git a/lib/esm/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js b/lib/esm/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js new file mode 100644 index 0000000..5674fae --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js @@ -0,0 +1,56 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import { bfb_rate } from "../bfb_rate.js"; +import { BODY_NAMES, IDICT } from "../matrix.js"; +import * as math from "mathjs"; +/** + * @typedef CrMsFatBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_core - Core blood flow rate [L/h]. + * @property {math.MathCollection} bf_muscle - Muscle blood flow rate [L/h]. + * @property {math.MathCollection} bf_fat - Fat blood flow rate [L/h]. + */ +/** + * Calculate core, muscle and fat blood flow rate [L/h]. + * + * @param {math.MathCollection} q_work - Heat production by work [W]. + * @param {math.MathCollection} q_shiv - Heat production by shivering [W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose from "dubois","takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - Age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {CrMsFatBloodFlowResult} - Core, muscle and fat blood flow rate [L/h]. + */ +export function cr_ms_fat_blood_flow(q_work, q_shiv, height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age, ci = JOS3Defaults.cardiac_index) { + // Basal blood flow rate [L/h] + // core, CBFB + let bfb_core = math.matrix([ + 35.251, 15.24, 89.214, 87.663, 18.686, 1.808, 0.94, 0.217, 1.808, 0.94, + 0.217, 1.406, 0.164, 0.08, 1.406, 0.164, 0.08, + ]); + // muscle, MSBFB + let bfb_muscle = math.matrix([ + 0.682, 0.0, 0.0, 0.0, 12.614, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + // fat, FTBFB + let bfb_fat = math.matrix([ + 0.265, 0.0, 0.0, 0.0, 2.219, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + let bfbrate = bfb_rate(height, weight, bsa_equation, age, ci); + let bf_core = math.dotMultiply(bfb_core, bfbrate); + let bf_muscle = math.dotMultiply(bfb_muscle, bfbrate); + let bf_fat = math.dotMultiply(bfb_fat, bfbrate); + for (let i = 0; i < BODY_NAMES.length; i++) { + let bn = BODY_NAMES[i]; + if (IDICT[bn]["muscle"] !== null) { + bf_muscle.set([i], bf_muscle.get([i]) + (q_work.get([i]) + q_shiv.get([i])) / 1.163); + } + else { + bf_core.set([i], bf_core.get([i]) + (q_work.get([i]) + q_shiv.get([i])) / 1.163); + } + } + return { bf_core, bf_muscle, bf_fat }; +} diff --git a/lib/esm/jos3_functions/thermoregulation/dry_r.js b/lib/esm/jos3_functions/thermoregulation/dry_r.js new file mode 100644 index 0000000..10f2aa6 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/dry_r.js @@ -0,0 +1,20 @@ +import { clo_area_factor } from "./clo_area_factor.js"; +import * as math from "mathjs"; +/** + * Calculate total sensible thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * + * @returns {math.Matrix} Total sensible thermal resistance between skin and ambient. + */ +export function dry_r(hc, hr, clo) { + if (hc.toArray().some((x) => x < 0) || hr.toArray().some((x) => x < 0)) { + throw new Error("Input parameters hc and hr must be non-negative."); + } + let fcl = clo_area_factor(clo); + let r_a = math.dotDivide(1, math.add(hc, hr)); + let r_cl = math.dotMultiply(0.155, clo); + return math.add(math.dotDivide(r_a, fcl), r_cl); +} diff --git a/lib/esm/jos3_functions/thermoregulation/error_signals.js b/lib/esm/jos3_functions/thermoregulation/error_signals.js new file mode 100644 index 0000000..f1e6c8a --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/error_signals.js @@ -0,0 +1,28 @@ +import * as math from "mathjs"; +/** + * @typedef ErrorSignalsResult + * @type {object} + * @property {number} wrms - Warm signal [°C]. + * @property {number} clds - Cold signal [°C]. + */ +/** + * Calculate WRMS and CLDS signals of thermoregulation. + * + * @param {math.MathCollection} [err_sk=0] - Difference between set-point and skin temperatures [°C]. + * If the provided value is an array, its length should be 17. + * + * @returns {ErrorSignalsResult} an object containing the results of the calculation. + */ +export function error_signals(err_sk = math.zeros(17)) { + let receptor = math.matrix([ + 0.0549, 0.0146, 0.1492, 0.1321, 0.2122, 0.0227, 0.0117, 0.0923, 0.0227, + 0.0117, 0.0923, 0.0501, 0.0251, 0.0167, 0.0501, 0.0251, 0.0167, + ]); + let wrm = err_sk.map((n) => math.max(n, 0)); + wrm = math.dotMultiply(wrm, receptor); + let wrms = math.sum(wrm); + let cld = err_sk.map((n) => math.min(n, 0)); + cld = math.dotMultiply(cld, math.dotMultiply(receptor, -1)); + let clds = math.sum(cld); + return { wrms, clds }; +} diff --git a/lib/esm/jos3_functions/thermoregulation/evaporation.js b/lib/esm/jos3_functions/thermoregulation/evaporation.js new file mode 100644 index 0000000..d8bbbb4 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/evaporation.js @@ -0,0 +1,63 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import { error_signals } from "./error_signals.js"; +import { bsa_rate } from "../bsa_rate.js"; +import * as math from "mathjs"; +/** + * Calculates the Antoine equation for a given temperature value. + * + * @param {number} x - The temperature value in Kelvin. + * @returns {number} - The vapor pressure calculated using the Antoine equation. + */ +export const antoine = (x) => Math.E ** (16.6536 - 4030.183 / (x + 235)); +/** + * @typedef EvaporationResult + * @type {object} + * @property {math.MathCollection} wet - Local skin wettedness [-]. + * @property {math.MathCollection} e_sk - Evaporative heat loss at the skin by sweating and diffuse [W]. + * @property {math.MathCollection} e_max - Maximum evaporative heat loss at the skin [W]. + * @property {math.MathCollection} e_sweat - Evaporative heat loss at the skin by only sweating [W]. + */ +/** + * Calculate evaporative heat loss. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_skin - Skin temperatures [°C]. + * @param {math.MathCollection} tdb - Air temperatures at local body segments [°C]. + * @param {math.MathCollection} rh - Relative humidity at local body segments [%]. + * @param {math.MathCollection} ret - Total evaporative thermal resistances [m2.K/W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * + * @returns {EvaporationResult} an object containing the results of the calculation. + */ +export function evaporation(err_cr, err_sk, t_skin, tdb, rh, ret, height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age) { + let { wrms, clds } = error_signals(err_sk); + let bsar = bsa_rate(height, weight, bsa_equation); + let bsa = math.dotMultiply(JOS3Defaults.local_bsa, bsar); + let p_a = math.dotDivide(math.dotMultiply(tdb.map(antoine), rh), 100); + let p_sk_s = t_skin.map(antoine); + let e_max = math.dotMultiply(math.dotDivide(math.subtract(p_sk_s, p_a), ret), bsa); + e_max = e_max.map((e_max) => (e_max === 0 ? 0.001 : e_max)); + let skin_sweat = [ + 0.064, 0.017, 0.146, 0.129, 0.206, 0.051, 0.026, 0.0155, 0.051, 0.026, + 0.0155, 0.073, 0.036, 0.0175, 0.073, 0.036, 0.0175, + ]; + let sig_sweat = 371.2 * err_cr.get([0]) + 33.64 * (wrms - clds); + sig_sweat = sig_sweat > 0 ? sig_sweat : 0; + sig_sweat *= bsar; + let sd_sweat = age < 60 + ? math.ones(17) + : math.matrix([ + 0.69, 0.69, 0.59, 0.52, 0.4, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.4, + 0.4, 0.4, 0.4, 0.4, 0.4, + ]); + let e_sweat = math.multiply(skin_sweat, sig_sweat, sd_sweat, math.dotPow(2, math.divide(err_sk, 10))); + let wet = math.add(0.06, math.multiply(0.94, math.dotDivide(e_sweat, e_max))); + wet = wet.map((n) => (n > 1 ? 1 : n)); + let e_sk = math.dotMultiply(wet, e_max); + e_sweat = math.dotMultiply(math.divide(math.subtract(wet, 0.06), 0.94), e_max); + return { wet, e_sk, e_max, e_sweat }; +} diff --git a/lib/esm/jos3_functions/thermoregulation/fixed_hc.js b/lib/esm/jos3_functions/thermoregulation/fixed_hc.js new file mode 100644 index 0000000..f3c9c40 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/fixed_hc.js @@ -0,0 +1,12 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import * as math from "mathjs"; +/** + * Fixes hc values to fit two-node-model's values. + */ +export function fixed_hc(hc, v) { + const local_bsa_sum = math.sum(JOS3Defaults.local_bsa); + let mean_hc = math.sum(math.dotMultiply(hc, JOS3Defaults.local_bsa)) / local_bsa_sum; + let mean_va = math.sum(math.dotMultiply(v, JOS3Defaults.local_bsa)) / local_bsa_sum; + let mean_hc_whole = Math.max(3, 8.600001 * mean_va ** 0.53); + return math.dotDivide(math.dotMultiply(hc, mean_hc_whole), mean_hc); +} diff --git a/lib/esm/jos3_functions/thermoregulation/fixed_hr.js b/lib/esm/jos3_functions/thermoregulation/fixed_hr.js new file mode 100644 index 0000000..d17939d --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/fixed_hr.js @@ -0,0 +1,13 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import * as math from "mathjs"; +/** + * Fixes hr values to fit two-node-model's values. + * + * @param {math.MathCollection} hr + * @return {math.Matrix} + */ +export function fixed_hr(hr) { + let mean_hr = math.sum(math.dotMultiply(hr, JOS3Defaults.local_bsa)) / + math.sum(JOS3Defaults.local_bsa); + return math.dotDivide(math.dotMultiply(hr, 4.7), mean_hr); +} diff --git a/lib/esm/jos3_functions/thermoregulation/local_mbase.js b/lib/esm/jos3_functions/thermoregulation/local_mbase.js new file mode 100644 index 0000000..9a938aa --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/local_mbase.js @@ -0,0 +1,40 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import { basal_met } from "./basal_met.js"; +import * as math from "mathjs"; +/** + * Calculate local basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex='male'] - Sex (male or female). + * @param {string} [bmr_equation='harris-benedict'] - BMR equation to use (harris-benedict or ganpule). + * + * @returns {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + */ +export function local_mbase(height = JOS3Defaults.height, weight = JOS3Defaults.weight, age = JOS3Defaults.age, sex = JOS3Defaults.sex, bmr_equation = JOS3Defaults.bmr_equation) { + let mbase_all = basal_met(height, weight, age, sex, bmr_equation); + let mbf_cr = math.matrix([ + 0.19551, 0.00324, 0.28689, 0.25677, 0.09509, 0.01435, 0.00409, 0.00106, + 0.01435, 0.00409, 0.00106, 0.01557, 0.00422, 0.0025, 0.01557, 0.00422, + 0.0025, + ]); + let mbf_ms = math.matrix([ + 0.00252, 0.0, 0.0, 0.0, 0.04804, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + ]); + let mbf_fat = math.matrix([ + 0.00127, 0.0, 0.0, 0.0, 0.0095, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + let mbf_sk = math.matrix([ + 0.00152, 0.00033, 0.00211, 0.00187, 0.003, 0.00059, 0.00031, 0.00059, + 0.00059, 0.00031, 0.00059, 0.00144, 0.00027, 0.00118, 0.00144, 0.00027, + 0.00118, + ]); + let mbase_cr = math.dotMultiply(mbf_cr, mbase_all); + let mbase_ms = math.dotMultiply(mbf_ms, mbase_all); + let mbase_fat = math.dotMultiply(mbf_fat, mbase_all); + let mbase_sk = math.dotMultiply(mbf_sk, mbase_all); + return [mbase_cr, mbase_ms, mbase_fat, mbase_sk]; +} diff --git a/lib/esm/jos3_functions/thermoregulation/local_q_work.js b/lib/esm/jos3_functions/thermoregulation/local_q_work.js new file mode 100644 index 0000000..917f82d --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/local_q_work.js @@ -0,0 +1,21 @@ +import * as math from "mathjs"; +/** + * Calculate local thermogenesis by work [W]. + * + * @param {number} bmr - Basal metabolic rate [W] + * @param {number} par - Physical activity ratio [-] + * @throws {Error} If par is less than 1 + * + * @return {math.MathCollection} q_work - Local thermogenesis by work [W] + */ +export function local_q_work(bmr, par) { + if (par < 1) { + throw new Error("par must be greater than or equal to 1"); + } + let q_work_all = (par - 1) * bmr; + let workf = math.matrix([ + 0, 0, 0.091, 0.08, 0.129, 0.0262, 0.0139, 0.005, 0.0262, 0.0139, 0.005, + 0.201, 0.099, 0.005, 0.201, 0.099, 0.005, + ]); + return math.dotMultiply(workf, q_work_all); +} diff --git a/lib/esm/jos3_functions/thermoregulation/nonshivering.js b/lib/esm/jos3_functions/thermoregulation/nonshivering.js new file mode 100644 index 0000000..574abc1 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/nonshivering.js @@ -0,0 +1,65 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import { error_signals } from "./error_signals.js"; +import { bsa_rate } from "../bsa_rate.js"; +import * as math from "mathjs"; +/** + * Calculate local metabolic rate by non-shivering [W] + * + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {boolean} [cold_acclimation=false] - Whether the subject acclimates cold environment or not. + * @param {boolean} [batpositive=true] - Whether BAT activity is positive or not. + * + * @returns {math.MathCollection} q_nst - Local metabolic rate by non-shivering [W]. + */ +export function nonshivering(err_sk, height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age, cold_acclimation = false, batpositive = true) { + // NST (Non-Shivering Thermogenesis) model, Asaka, 2016 + let { clds } = error_signals(err_sk); + // BMI (Body Mass Index) + let bmi = weight / height ** 2; + // BAT: brown adipose tissue [SUV] + let bat = 10 ** (-0.10502 * bmi + 2.7708); + if (age < 30) { + bat *= 1.61; + } + else if (age < 40) { + bat *= 1.0; + } + else { + bat *= 0.8; + } + if (cold_acclimation) { + bat += 3.46; + } + if (!batpositive) { + // incidence age factor: T.Yoneshiro 2011 + if (age < 30) { + bat *= 44 / 83; + } + else if (age < 40) { + bat *= 15 / 38; + } + else if (age < 50) { + bat *= 7 / 26; + } + else if (age < 60) { + bat *= 1 / 8; + } + else { + bat *= 0; + } + } + // NST limit + let thres = 1.8 * bat + 2.43 + 5.62; // [W] + let sig_nst = 2.8 * clds; // [W] + sig_nst = Math.min(sig_nst, thres); + let nstf = math.matrix([ + 0.0, 0.19, 0.0, 0.19, 0.19, 0.215, 0.0, 0.0, 0.215, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + ]); + let bsar = bsa_rate(height, weight, bsa_equation); + return math.dotMultiply(math.dotMultiply(bsar, nstf), sig_nst); +} diff --git a/lib/esm/jos3_functions/thermoregulation/operative_temp.js b/lib/esm/jos3_functions/thermoregulation/operative_temp.js new file mode 100644 index 0000000..d9b9f80 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/operative_temp.js @@ -0,0 +1,15 @@ +import { $map } from "../../supa.js"; +import * as math from "mathjs"; +/** + * Calculate operative temperature [°C] + * + * @param {math.MathCollection} tdb - Air temperature [°C] + * @param {math.MathCollection} tr - Mean radiant temperature [°C] + * @param {math.MathCollection} hc - Convective heat transfer coefficient [W/(m2*K)] + * @param {math.MathCollection} hr - Radiative heat transfer coefficient [W/(m2*K)] + + * @returns {math.MathCollection} Operative temperature [°C] + */ +export function operative_temp(tdb, tr, hc, hr) { + return math.dotDivide(math.add(math.dotMultiply(hc, tdb), math.dotMultiply(hr, tr)), math.add(hc, hr)); +} diff --git a/lib/esm/jos3_functions/thermoregulation/rad_coef.js b/lib/esm/jos3_functions/thermoregulation/rad_coef.js new file mode 100644 index 0000000..e7bcc95 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/rad_coef.js @@ -0,0 +1,44 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import * as math from "mathjs"; +/** + * Calculate radiative heat transfer coefficient (hr) [W/(m2*K)] + * + * @param {string} posture - Select posture from standing, sitting, lying, sedentary or supine. Default is "standing". + * + * @returns {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + */ +export function rad_coef(posture = JOS3Defaults.posture) { + const valid_postures = [ + "standing", + "sitting", + "lying", + "sedentary", + "supine", + ]; + if (!valid_postures.includes(posture)) { + let postures = valid_postures.join(", "); + throw new Error(`Invalid posture ${posture}. Must be one of ${postures}.`); + } + switch (posture) { + case "standing": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + return math.matrix([ + 4.89, 4.89, 4.32, 4.09, 4.32, 4.55, 4.43, 4.21, 4.55, 4.43, 4.21, 4.77, + 5.34, 6.14, 4.77, 5.34, 6.14, + ]); + case "sitting": + case "sedentary": + // Ichihara et al., 1997, https://doi.org/10.3130/aija.62.45_5 + return math.matrix([ + 4.96, 4.96, 3.99, 4.64, 4.21, 4.96, 4.21, 4.74, 4.96, 4.21, 4.74, 4.1, + 4.74, 6.36, 4.1, 4.74, 6.36, + ]); + case "lying": + case "supine": + // Kurazumi et al., 2008, https://doi.org/10.20718/jjpa.13.1_17 + return math.matrix([ + 5.475, 5.475, 3.463, 3.463, 3.463, 4.249, 4.835, 4.119, 4.249, 4.835, + 4.119, 4.44, 5.547, 6.085, 4.44, 5.547, 6.085, + ]); + } +} diff --git a/lib/esm/jos3_functions/thermoregulation/resp_heat_loss.js b/lib/esm/jos3_functions/thermoregulation/resp_heat_loss.js new file mode 100644 index 0000000..81b5725 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/resp_heat_loss.js @@ -0,0 +1,20 @@ +/** + * @typedef RespHeatLossResult + * @type {object} + * @property {number} res_sh - Sensible heat loss by respiration [W]. + * @property {number} res_lh - Latent heat loss by respiration [W]. + */ +/** + * Calculate heat loss by respiration [W]. + * + * @param {number} tdb - Dry bulb air temperature [oC]. + * @param {number} p_a - Water vapor pressure in the ambient air [kPa]. + * @param {number} q_thermogenesis_total - Total thermogenesis [W]. + + * @return {RespHeatLossResult} res_sh, res_lh - Sensible and latent heat loss by respiration [W]. + */ +export function resp_heat_loss(tdb, p_a, q_thermogenesis_total) { + let res_sh = 0.0014 * q_thermogenesis_total * (34 - tdb); // sensible heat loss + let res_lh = 0.0173 * q_thermogenesis_total * (5.87 - p_a); // latent heat loss + return { res_sh, res_lh }; +} diff --git a/lib/esm/jos3_functions/thermoregulation/shivering.js b/lib/esm/jos3_functions/thermoregulation/shivering.js new file mode 100644 index 0000000..60cea0a --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/shivering.js @@ -0,0 +1,102 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import { error_signals } from "./error_signals.js"; +import { bsa_rate } from "../bsa_rate.js"; +import * as math from "mathjs"; +export let PRE_SHIV = 0; +/** + * Sets the value of PRE_SHIV. + * + * @param {number} value - the value to set PRE_SHIV to + */ +export function set_pre_shiv(value) { + PRE_SHIV = value; +} +/** + * Calculate local thermogenesis by shivering [W]. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_core - Core and skin temperatures [°C]. + * @param {math.MathCollection} t_skin - Core and skin temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {number} [dtime=60] - Interval of analysis time. + * @param {object} options - Additional options. + * + * @returns {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + */ +export function shivering(err_cr, err_sk, t_core, t_skin, height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age, sex = JOS3Defaults.sex, dtime = 60, options = {}) { + // Integrated error signal in the warm and cold receptors + let { clds } = error_signals(err_sk); + // Distribution coefficient of thermogenesis by shivering + let shivf = math.matrix([ + 0.0339, 0.0436, 0.27394, 0.24102, 0.38754, 0.00243, 0.00137, 0.0002, + 0.00243, 0.00137, 0.0002, 0.0039, 0.00175, 0.00035, 0.0039, 0.00175, + 0.00035, + ]); + // Integrated error signal of shivering + let sig_shiv = 24.36 * clds * -err_cr.get([0]); + sig_shiv = Math.max(sig_shiv, 0); + if (options["shivering_threshold"]) { + // Asaka, 2016 + // Threshold of starting shivering + let tskm = math.sum(math.dotMultiply(t_skin, JOS3Defaults.local_bsa)) / + math.sum(JOS3Defaults.local_bsa); + let thres; + if (tskm < 31) { + thres = 36.6; + } + else { + thres = sex === "male" ? -0.2436 * tskm + 44.1 : -0.225 * tskm + 43.05; + } + // Second threshold of starting shivering + if (thres < t_core.get([0])) { + sig_shiv = 0; + } + } + if (options["limit_dshiv/dt"]) { + let dshiv = sig_shiv - PRE_SHIV; + let limit_dshiv = options["limit_dshiv/dt"] === true + ? 0.0077 * dtime + : options["limit_dshiv/dt"] * dtime; + if (dshiv > limit_dshiv) { + sig_shiv = limit_dshiv + PRE_SHIV; + } + else if (dshiv < -limit_dshiv) { + sig_shiv = -limit_dshiv + PRE_SHIV; + } + } + PRE_SHIV = sig_shiv; + // Signal sd_shiv by aging + let sd_shiv; + if (age < 30) { + sd_shiv = math.ones(17); + } + else if (age < 40) { + sd_shiv = math.multiply(math.ones(17), 0.97514); + } + else if (age < 50) { + sd_shiv = math.multiply(math.ones(17), 0.95028); + } + else if (age < 60) { + sd_shiv = math.multiply(math.ones(17), 0.92818); + } + else if (age < 70) { + sd_shiv = math.multiply(math.ones(17), 0.90055); + } + else if (age < 80) { + sd_shiv = math.multiply(math.ones(17), 0.86188); + } + else { + sd_shiv = math.multiply(math.ones(17), 0.82597); + } + // Ratio of body surface area to the standard body [-] + let bsar = bsa_rate(height, weight, bsa_equation); + // Local thermogenesis by shivering [W] + let q_shiv = math.dotMultiply(math.dotMultiply(math.dotMultiply(shivf, bsar), sd_shiv), sig_shiv); + let x = q_shiv + 1; + return q_shiv; +} diff --git a/lib/esm/jos3_functions/thermoregulation/skin_blood_flow.js b/lib/esm/jos3_functions/thermoregulation/skin_blood_flow.js new file mode 100644 index 0000000..ac0fca5 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/skin_blood_flow.js @@ -0,0 +1,45 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import { error_signals } from "./error_signals.js"; +import { bfb_rate } from "../bfb_rate.js"; +import * as math from "mathjs"; +/** + * Calculate skin blood flow rate (bf_skin) [L/h]. + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {math.MathCollection} bf_skin - Skin blood flow rate [L/h]. + */ +export function skin_blood_flow(err_cr, err_sk, height = JOS3Defaults.height, weight = JOS3Defaults.weight, bsa_equation = JOS3Defaults.bsa_equation, age = JOS3Defaults.age, ci = JOS3Defaults.cardiac_index) { + let { wrms, clds } = error_signals(err_sk); + let bfb_sk = math.matrix([ + 1.754, 0.325, 1.967, 1.475, 2.272, 0.91, 0.508, 1.114, 0.91, 0.508, 1.114, + 1.456, 0.651, 0.934, 1.456, 0.651, 0.934, + ]); + let skin_dilat = math.matrix([ + 0.0692, 0.0992, 0.058, 0.0679, 0.0707, 0.04, 0.0373, 0.0632, 0.04, 0.0373, + 0.0632, 0.0736, 0.0411, 0.0623, 0.0736, 0.0411, 0.0623, + ]); + let skin_stric = math.matrix([ + 0.0213, 0.0213, 0.0638, 0.0638, 0.0638, 0.0213, 0.0213, 0.1489, 0.0213, + 0.0213, 0.1489, 0.0213, 0.0213, 0.1489, 0.0213, 0.0213, 0.1489, + ]); + let sig_dilat = 100.5 * err_cr.get([0]) + 6.4 * (wrms - clds); + sig_dilat = sig_dilat > 0 ? sig_dilat : 0; + let sig_stric = -10.8 * err_cr.get([0]) + -10.8 * (wrms - clds); + sig_stric = sig_stric > 0 ? sig_stric : 0; + let sd_stric = math.ones(17); + let sd_dilat = age < 60 + ? math.ones(17) + : math.matrix([ + 0.91, 0.91, 0.47, 0.47, 0.31, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, + 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, + ]); + let bf_skin = math.dotMultiply(math.dotMultiply(math.dotDivide(math.add(1, math.multiply(math.dotMultiply(skin_dilat, sd_dilat), sig_dilat)), math.add(1, math.multiply(math.dotMultiply(skin_stric, sd_stric), sig_stric))), bfb_sk), math.dotPow(2, math.divide(err_sk, 6))); + let bfb = bfb_rate(height, weight, bsa_equation, age, ci); + return math.dotMultiply(bf_skin, bfb); +} diff --git a/lib/esm/jos3_functions/thermoregulation/sum_bf.js b/lib/esm/jos3_functions/thermoregulation/sum_bf.js new file mode 100644 index 0000000..21acf40 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/sum_bf.js @@ -0,0 +1,23 @@ +import * as math from "mathjs"; +/** + * Sum the total blood flow in various body parts. + * + * @param {math.MathCollection} bf_core - Blood flow rate in the core region [L/h]. + * @param {math.MathCollection} bf_muscle - Blood flow rate in the muscle region [L/h]. + * @param {math.MathCollection} bf_fat - Blood flow rate in the fat region [L/h]. + * @param {math.MathCollection} bf_skin - Blood flow rate in the skin region [L/h]. + * @param {number} bf_ava_hand - AVA blood flow rate in one hand [L/h]. + * @param {number} bf_ava_foot - AVA blood flow rate in one foot [L/h]. + * + * @returns {number} co - Cardiac output (the sum of the whole blood flow rate) [L/h]. + */ +export function sum_bf(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot) { + let co = 0; + co += math.sum(bf_core); + co += math.sum(bf_muscle); + co += math.sum(bf_fat); + co += math.sum(bf_skin); + co += 2 * bf_ava_hand; + co += 2 * bf_ava_foot; + return co; +} diff --git a/lib/esm/jos3_functions/thermoregulation/sum_m.js b/lib/esm/jos3_functions/thermoregulation/sum_m.js new file mode 100644 index 0000000..bbfcda3 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/sum_m.js @@ -0,0 +1,39 @@ +import { BODY_NAMES, IDICT } from "../matrix.js"; +import * as math from "mathjs"; +/** + * @typedef SumMResult + * @type {object} + * @property {math.MathCollection} q_thermogenesis_core - Total thermogenesis in core layer [W]. + * @property {math.MathCollection} q_thermogenesis_muscle - Total thermogenesis in muscle layer [W]. + * @property {math.MathCollection} q_thermogenesis_fat - Total thermogenesis in fat layer [W]. + * @property {math.MathCollection} q_thermogenesis_skin - Total thermogenesis in skin layer [W]. + */ +/** + * Calculate total thermogenesis in each layer [W]. + * + * @param {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + * @param {math.MathCollection} q_work - Local thermogenesis by work [W]. + * @param {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + * @param {math.MathCollection} q_nst - Local thermogenesis by non-shivering [W]. + * + * @return {SumMResult} Total thermogenesis in core, muscle, fat, skin layers [W]. + */ +export function sum_m(mbase, q_work, q_shiv, q_nst) { + let [q_thermogenesis_core, q_thermogenesis_muscle, q_thermogenesis_fat, q_thermogenesis_skin,] = mbase; + for (let i = 0; i < BODY_NAMES.length; i++) { + let bn = BODY_NAMES[i]; + if (IDICT[bn]["muscle"] !== null) { + q_thermogenesis_muscle.set([i], q_thermogenesis_muscle.get([i]) + q_work.get([i]) + q_shiv.get([i])); + } + else { + q_thermogenesis_core.set([i], q_thermogenesis_core.get([i]) + q_work.get([i]) + q_shiv.get([i])); + } + } + q_thermogenesis_core = math.add(q_thermogenesis_core, q_nst); + return { + q_thermogenesis_core, + q_thermogenesis_muscle, + q_thermogenesis_fat, + q_thermogenesis_skin, + }; +} diff --git a/lib/esm/jos3_functions/thermoregulation/wet_r.js b/lib/esm/jos3_functions/thermoregulation/wet_r.js new file mode 100644 index 0000000..c084700 --- /dev/null +++ b/lib/esm/jos3_functions/thermoregulation/wet_r.js @@ -0,0 +1,23 @@ +import JOS3Defaults from "../JOS3Defaults.js"; +import { clo_area_factor } from "./clo_area_factor.js"; +import * as math from "mathjs"; +/** + * Calculate total evaporative thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * @param {number | math.Matrix} [i_clo=0.45] - Clothing vapor permeation efficiency [-]. + * @param {number} [lewis_rate=16.5] - Lewis rate [K/kPa]. + * + * @returns {math.Matrix} r_et - Total evaporative thermal resistance. + */ +export function wet_r(hc, clo, i_clo = JOS3Defaults.clothing_vapor_permeation_efficiency, lewis_rate = JOS3Defaults.lewis_rate) { + if (hc.toArray().some((hc) => hc < 0)) { + throw new Error("Input parameter hc must be non-negative."); + } + let fcl = clo_area_factor(clo); + let r_cl = math.dotMultiply(0.155, clo); + let r_ea = math.dotDivide(1, math.dotMultiply(lewis_rate, hc)); + let r_ecl = math.dotDivide(r_cl, math.multiply(i_clo, lewis_rate)); + return math.add(math.dotDivide(r_ea, fcl), r_ecl); +} diff --git a/lib/esm/jos3_functions/validate_body_parameters.js b/lib/esm/jos3_functions/validate_body_parameters.js new file mode 100644 index 0000000..fe4913e --- /dev/null +++ b/lib/esm/jos3_functions/validate_body_parameters.js @@ -0,0 +1,25 @@ +import JOS3Defaults from "./JOS3Defaults.js"; +/** + * Validate the parameters: height, weight, age, and body fat percentage. + * + * @param {number} height - The height of the person in meters. + * @param {number} weight - The weight of the person in kilograms. + * @param {number} age - The age of the person in years. + * @param {number} body_fat - The body fat percentage as a fraction of total body mass. + + * @throws {Error} If any of the parameters are out of the specified range. + */ +export function validate_body_parameters(height = JOS3Defaults.height, weight = JOS3Defaults.weight, age = JOS3Defaults.age, body_fat = JOS3Defaults.body_fat) { + if (height < 0.5 || height > 3.0) { + throw new Error("Height must be in the range [0.5, 3.0] meters."); + } + if (weight < 20 || weight > 200) { + throw new Error("Weight must be in the range [20, 200] kilograms."); + } + if (age < 5 || age > 100) { + throw new Error("Age must be in the range [5, 100] years."); + } + if (body_fat < 1 || body_fat > 90) { + throw new Error("Body Fat must be in the range [1, 90] (1% to 90%)."); + } +} diff --git a/lib/esm/jos3_functions/weight_rate.js b/lib/esm/jos3_functions/weight_rate.js new file mode 100644 index 0000000..b8ea8ad --- /dev/null +++ b/lib/esm/jos3_functions/weight_rate.js @@ -0,0 +1,24 @@ +import JOS3Defaults from "./JOS3Defaults.js"; +import { validate_body_parameters } from "./validate_body_parameters.js"; +/** + * Calculate the ratio of the body weight to the standard body (74.43 kg). + * + * The standard values of local body weights are as as follows: + * weight_local = [ + * 3.18, 0.84, 12.4, 11.03, 17.57, + * 2.16, 1.37, 0.34, 2.16, 1.37, 0.34, + * 7.01, 3.34, 0.48, 7.01, 3.34, 0.48 + * ] + * + * The data have been derived from 65MN. + * The weight of neck is extracted from the weight of 65MN's head based on + * the local body surface area of Smith's model. + * + * @param {number} [weight=JOS3Defaults.weight] - The body weight [kg]. + * + * @returns {number} the ratio of the body weight to the standard body (74.43 kg). + */ +export function weight_rate(weight = JOS3Defaults.weight) { + validate_body_parameters(undefined, weight); + return weight / JOS3Defaults.weight; +} diff --git a/lib/esm/models/JOS3.js b/lib/esm/models/JOS3.js new file mode 100644 index 0000000..c56120e --- /dev/null +++ b/lib/esm/models/JOS3.js @@ -0,0 +1,923 @@ +import JOS3Defaults from "../jos3_functions/JOS3Defaults.js"; +import { bsa_rate } from "../jos3_functions/bsa_rate.js"; +import { local_bsa } from "../jos3_functions/local_bsa.js"; +import { bfb_rate } from "../jos3_functions/bfb_rate.js"; +import { conductance } from "../jos3_functions/conductance.js"; +import { capacity } from "../jos3_functions/capacity.js"; +import * as math from "mathjs"; +import { BODY_NAMES, INDEX, local_arr, NUM_NODES, vessel_blood_flow, VINDEX, whole_body, } from "../jos3_functions/matrix.js"; +import { set_pre_shiv, shivering, } from "../jos3_functions/thermoregulation/shivering.js"; +import { basal_met } from "../jos3_functions/thermoregulation/basal_met.js"; +import { pmv } from "./pmv.js"; +import { fixed_hc } from "../jos3_functions/thermoregulation/fixed_hc.js"; +import { conv_coef } from "../jos3_functions/thermoregulation/conv_coef.js"; +import { fixed_hr } from "../jos3_functions/thermoregulation/fixed_hr.js"; +import { rad_coef } from "../jos3_functions/thermoregulation/rad_coef.js"; +import { operative_temp } from "../jos3_functions/thermoregulation/operative_temp.js"; +import { dry_r } from "../jos3_functions/thermoregulation/dry_r.js"; +import { wet_r } from "../jos3_functions/thermoregulation/wet_r.js"; +import { antoine, evaporation, } from "../jos3_functions/thermoregulation/evaporation.js"; +import { skin_blood_flow } from "../jos3_functions/thermoregulation/skin_blood_flow.js"; +import { ava_blood_flow } from "../jos3_functions/thermoregulation/ava_blood_flow.js"; +import { nonshivering } from "../jos3_functions/thermoregulation/nonshivering.js"; +import { local_mbase } from "../jos3_functions/thermoregulation/local_mbase.js"; +import { sum_m } from "../jos3_functions/thermoregulation/sum_m.js"; +import { local_q_work } from "../jos3_functions/thermoregulation/local_q_work.js"; +import { cr_ms_fat_blood_flow } from "../jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js"; +import { resp_heat_loss } from "../jos3_functions/thermoregulation/resp_heat_loss.js"; +import { sum_bf } from "../jos3_functions/thermoregulation/sum_bf.js"; +import Object from "lodash/object.js"; +/** + * Create an array of shape (17,) with the given input. + * + * @param inp {number | number[] | object} + * @returns {math.Matrix} + */ +function _to17array(inp) { + if (typeof inp === "number") { + return math.multiply(math.ones(17), inp); + } + if (math.isCollection(inp)) { + const size = math.size(inp).toArray(); + if (!math.equal(size, [17])) { + throw new Error("Input list is not of length 17"); + } + return math.matrix(inp); + } + if (typeof inp === "object") { + return math.matrix(BODY_NAMES.map((name) => inp[name])); + } + throw new Error("Unsupported input type. Supported types: number"); +} +/** + * JOS-3 model simulates human thermal physiology including skin + * temperature, core temperature, sweating rate, etc. for the whole body and + * 17 local body parts. + * + * This model was developed at Shin-ichi Tanabe Laboratory, Waseda University + * and was derived from 65 Multi-Node model (https://doi.org/10.1016/S0378-7788(02)00014-2) + * and JOS-2 model (https://doi.org/10.1016/j.buildenv.2013.04.013). + * + * To use this model, create an instance of the JOS3 class with optional body parameters + * such as body height, weight, age, sex, etc. + * + * Environmental conditions such as air temperature, mean radiant temperature, air velocity, etc. + * can be set using the setter methods. (ex. X.tdb, X.tr X.v) + * If you want to set the different conditions in each body part, set them + * as a 17 lengths of list, dictionary, or numpy array format. + * + * List or numpy array format input must be 17 lengths and means the order of "head", "neck", "chest", + * "back", "pelvis", "left_shoulder", "left_arm", "left_hand", "right_shoulder", "right_arm", + * "right_hand", "left_thigh", "left_leg", "left_foot", "right_thigh", "right_leg" and "right_foot". + * + * The model output includes local and mean skin temperature, local core temperature, + * local and mean skin wettedness, and heat loss from the skin etc. + * The model output can be accessed using "dict_results()" method and be converted to a csv file + * using "to_csv" method. + * Each output parameter also can be accessed using getter methods. + * (ex. X.t_skin, X.t_skin_mean, X.t_core) + * + * If you use this package, please cite us as follows and mention the version of pythermalcomfort used: + * Y. Takahashi, A. Nomoto, S. Yoda, R. Hisayama, M. Ogata, Y. Ozeki, S. Tanabe, + * Thermoregulation Model JOS-3 with New Open Source Code, Energy & Buildings (2020), + * doi: https://doi.org/10.1016/j.enbuild.2020.110575 + * + * Note: To maintain consistency in variable names for jsthermalcomfort and pythermalcomfort, + * some variable names differ from those used in the original paper. + * + * @public + * @memberof models + * @docname JOS3 + */ +export class JOS3 { + /** + * Initialize a new instance of JOS3 class, which is designed to model + * and simulate various physiological parameters related to human + * thermoregulation. + * + * This class uses mathematical models to calculate and predict + * body temperature, basal metabolic rate, body surface area, and + * other related parameters. + * + * @param {number} [height] - body height, in [m]. + * @param {number} [weight] - body weight, in [kg]. + * @param {number} [fat] - fat percentage, in [%]. + * @param {number} [age] - age, in [years]. + * @param {"male" | "female"} [sex] - sex. + * @param {number} [ci] - Cardiac index, in [L/min/m2]. + * @param {"harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule"} [bmr_equation] - The equation used + * to calculate basal metabolic rate (BMR). + * @param {"dubois" | "fujimoto" | "kruazumi" | "takahira"} [bsa_equation] - The equation used to calculate body + * surface area (bsa). + * @param {[] | "all"} [ex_output] - This is used when you want to display results other than the default output + * parameters (ex.skin temperature); by default, JOS outputs only the most necessary parameters in order to reduce + * the computational load. + */ + constructor(height = JOS3Defaults.height, weight = JOS3Defaults.weight, fat = JOS3Defaults.body_fat, age = JOS3Defaults.age, sex = JOS3Defaults.sex, ci = JOS3Defaults.cardiac_index, bmr_equation = JOS3Defaults.bmr_equation, bsa_equation = JOS3Defaults.bsa_equation, ex_output = []) { + // Initialize basic attributes + this._height = height; + this._weight = weight; + this._fat = fat; + this._age = age; + this._sex = sex; + this._ci = ci; + this._bmr_equation = bmr_equation; + this._bsa_equation = bsa_equation; + this._ex_output = ex_output; + // Calculate body surface area (bsa) rate + this._bsa_rate = bsa_rate(height, weight, bsa_equation); + // Calculate local body surface area + this._bsa = local_bsa(height, weight, bsa_equation); + // Calculate basal blood flow (BFB) rate [-] + this._bfb_rate = bfb_rate(height, weight, bsa_equation, age, ci); + // Calculate thermal conductance (CDT) [W/K] + this._cdt = conductance(height, weight, bsa_equation, fat); + // Calculate thermal capacity [J/K] + this._cap = capacity(height, weight, bsa_equation, age, ci); + // Set initial core and skin temperature set points [°C] + this.setpt_cr = math.multiply(math.ones(17), JOS3Defaults.core_temperature); + this.setpt_sk = math.multiply(math.ones(17), JOS3Defaults.skin_temperature); + // Initialize body temperature [°C] + this._bodytemp = math.multiply(math.ones(NUM_NODES), JOS3Defaults.other_body_temperature); + // Initialize environmental conditions and other factors + // (Default values of input conditions) + this._ta = math.multiply(math.ones(17), JOS3Defaults.dry_bulb_air_temperature); + this._tr = math.multiply(math.ones(17), JOS3Defaults.mean_radiant_temperature); + this._rh = math.multiply(math.ones(17), JOS3Defaults.relative_humidity); + this._va = math.multiply(math.ones(17), JOS3Defaults.air_speed); + this._clo = math.multiply(math.ones(17), JOS3Defaults.clothing_insulation); + this._iclo = math.multiply(math.ones(17), JOS3Defaults.clothing_vapor_permeation_efficiency); + this._par = JOS3Defaults.physical_activity_ratio; + this._posture = JOS3Defaults.posture; + this._hc = null; // Convective heat transfer coefficient + this._hr = null; // Radiative heat transfer coefficient + this.ex_q = math.zeros(NUM_NODES); // External heat gain + this._t = 0; // Elapsed time + this._cycle = 0; // Cycle time + this.model_name = "JOS3"; // Model name + this.options = { + nonshivering_thermogenesis: true, + cold_acclimated: false, + shivering_threshold: false, + "limit_dshiv/dt": false, + bat_positive: false, + ava_zero: false, + shivering: false, + }; + // Set shivering threshold = 0 + set_pre_shiv(0); + // Initialize history to store model parameters + this._history = []; + // Set elapsed time and cycle time to 0 + this._t = 0; // Elapsed time + this._cycle = 0; // Cycle time + // Reset set-point temperature and save the last model parameters + const dictout = this._reset_setpt(JOS3Defaults.physical_activity_ratio); + this._history.push(dictout); + } + /** + * Calculate operative temperature [°C] when PMV=0. + * + * @private + * + * @param va {number} - Air velocity [m/s]. + * @param rh {number} - Relative humidity [%]. + * @param met {number} - Metabolic rate [met]. + * @param clo {number} - Clothing insulation [clo]. + * + * @returns {number} + */ + _calculate_operative_temp_when_pmv_is_zero(va = JOS3Defaults.air_speed, rh = JOS3Defaults.relative_humidity, met = JOS3Defaults.metabolic_rate, clo = JOS3Defaults.clothing_insulation) { + let to = 28; // initial operative temperature + // Iterate until the PMV (Predicted Mean Vote) value is less than 0.001 + let vpmv; + for (let i = 0; i < 100; i++) { + vpmv = pmv(to, to, va, rh, met, clo); + // Break the loop if the absolute value of PMV is less than 0.001 + if (math.abs(vpmv) < 0.001) { + break; + } + // Update the temperature based on the PMV value + to = to - vpmv / 3; + } + return to; + } + /** + * Reset set-point temperatures under steady state calculation. + * Set-point temperatures are hypothetical core or skin temperatures in a thermally neutral state + * when at rest (similar to room set-point temperature for air conditioning). + * This function is used during initialization to calculate the set-point temperatures as a reference for thermoregulation. + * Be careful, input parameters (tdb, tr, rh, v, clo, par) and body temperatures are also reset. + * + * @private + * + * @param par {number} - Physical activity ratio. + */ + _reset_setpt(par = JOS3Defaults.physical_activity_ratio) { + // Set operative temperature under PMV=0 environment + // 1 met = 58.15 W/m2 + const w_per_m2_to_met = 1 / 58.15; // unit converter W/m2 to met + const met = this.bmr * par * w_per_m2_to_met; // [met] + this.to = this._calculate_operative_temp_when_pmv_is_zero(undefined, undefined, met, undefined); + this.rh = JOS3Defaults.relative_humidity; + this.v = JOS3Defaults.air_speed; + this.clo = JOS3Defaults.clothing_insulation; + this.par = par; + // Steady-calculatio + this.options["ava_zero"] = true; + let dict_out; + for (let i = 0; i < 10; i++) { + dict_out = this._run(60000, true); + } + // Set new set-point temperatures for core and skin + this.setpt_cr = this.t_core; + this.setpt_sk = this.t_skin; + this.options["ava_zero"] = false; + return dict_out; + } + /** + * Run JOS-3 model. + * + * @property {number} times - Number of loops of a simulation. + * @property {number} [dtime=60] - Time delta in seconds. + * @property {boolean} [output=true] - If you don't want to record parameters, set False. + */ + simulate(times, dtime = 60, output = true) { + // Loop through the simulation for the given number of times + for (let i = 0; i < times; i++) { + // Increment the elapsed time by the time delta + this._t += dtime; + // Increment the cycle counter + this._cycle += 1; + // Execute the simulation step + const dict_data = this._run(dtime, undefined, output); + // If output is True, append the results to the history + if (output) { + this._history.push(dict_data); + } + } + } + /** + * Runs the model once and gets the model parameters. + * + * The function then calculates several thermoregulation parameters using the input data, + * such as convective and radiative heat transfer coefficients, operative temperature, heat resistance, + * and blood flow rates. + * + * It also calculates the thermogenesis by shivering and non-shivering, basal thermogenesis, and thermogenesis by work. + * + * The function then calculates the total heat loss and gains, including respiratory, + * sweating, and extra heat gain, and builds the matrices required + * to solve for the new body temperature. + * + * It then calculates the new body temperature by solving the matrices using numpy's linalg library. + * + * Finally, the function returns a dictionary of the simulation results. + * The output parameters include cycle time, model time, t_skin_mean, t_skin, t_core, w_mean, w, weight_loss_by_evap_and_res, cardiac_output, q_thermogenesis_total, q_res, and q_skin_env. + * + * Additionally, if the _ex_output variable is set to "all" or is a list of keys, + * the function also returns a detailed dictionary of all the thermoregulation parameters + * and other variables used in the simulation. + * + * @private + * + * @param {number} dtime - Time delta [sec]. + * @param {boolean} passive - If you run a passive model. + * @param {boolean} output - If you don't need parameters. + * + * @returns {object} + */ + _run(dtime = 60, passive = false, output = true) { + // Compute convective and radiative heat transfer coefficient [W/(m2*K)] + // based on posture, air velocity, air temperature, and skin temperature. + // Manual setting is possible by setting self._hc and self._hr. + // Compute heat and evaporative heat resistance [m2.K/W], [m2.kPa/W] + // Get core and skin temperatures + let tcr = this.t_core; + let tsk = this.t_skin; + // Convective and radiative heat transfer coefficients [W/(m2*K)] + let hc = fixed_hc(conv_coef(this._posture, this._va, this._ta, tsk), this._va); + let hr = fixed_hr(rad_coef(this._posture)); + // Manually set convective and radiative heat transfer coefficients if necessary + if (this._hc !== null) { + hc = this._hc; + } + if (this._hr !== null) { + hr = this._hr; + } + // Compute operative temp. [°C], clothing heat and evaporative resistance [m2.K/W], [m2.kPa/W] + // Operative temp. [°C] + let to = operative_temp(this._ta, this._tr, hc, hr); + // Clothing heat resistance [m2.K/W] + let r_t = dry_r(hc, hr, this._clo); + // Clothing evaporative resistance [m2.kPa/W] + let r_et = wet_r(hc, this._clo, this._iclo); + // ------------------------------------------------------------------ + // Thermoregulation + // 1) Sweating + // 2) Vasoconstriction, Vasodilation + // 3) Shivering and non-shivering thermogenesis + // ------------------------------------------------------------------ + // Compute the difference between the set-point temperature and body temperatures + // and other thermoregulation parameters. + // If running a passive model, the set-point temperature of thermoregulation is + // set to the current body temperature. + // set-point temperature for thermoregulation + let setpt_cr = passive ? tcr.clone() : this.setpt_cr.clone(); + let setpt_sk = passive ? tsk.clone() : this.setpt_sk.clone(); + // Error signal = Difference between set-point and body temperatures + let err_cr = math.subtract(tcr, setpt_cr); + let err_sk = math.subtract(tsk, setpt_sk); + // SWEATING THERMOREGULATION + // Skin wettedness [-], e_skin, e_max, e_sweat [W] + // Calculate skin wettedness, sweating heat loss, maximum sweating rate, and total sweat rate + let { wet, e_sk, e_max, e_sweat } = evaporation(err_cr, err_sk, tsk, this._ta, this._rh, r_et, this._height, this._weight, this._bsa_equation, this._age); + // VASOCONSTRICTION, VASODILATION + // Calculate skin blood flow and basal skin blood flow [L/h] + let bf_skin = skin_blood_flow(err_cr, err_sk, this._height, this._weight, this._bsa_equation, this._age, this._ci); + // Calculate hands and feet's AVA blood flow [L/h] + let { bf_ava_hand, bf_ava_foot } = ava_blood_flow(err_cr, err_sk, this._height, this._weight, this._bsa_equation, this._age, this._ci); + if (this.options["ava_zero"] && passive) { + bf_ava_hand = 0; + bf_ava_foot = 0; + } + // SHIVERING AND NON-SHIVERING + // Calculate shivering thermogenesis [W] + let q_shiv = shivering(err_cr, err_sk, tcr, tsk, this._height, this._weight, this._bsa_equation, this._age, this._sex, dtime, this.options); + // Calculate non-shivering thermogenesis (NST) [W] + let q_nst = this.options["nonshivering_thermogenesis"] + ? nonshivering(err_sk, this._height, this._weight, this._bsa_equation, this._age, this.options["cold_acclimated"], this.options["bat_positive"]) + : math.zeros(17); + // ------------------------------------------------------------------ + // Thermogenesis + // ------------------------------------------------------------------ + // Calculate local basal metabolic rate (BMR) [W] + let q_bmr_local = local_mbase(this._height, this._weight, this._age, this._sex, this._bmr_equation); + // Calculate overall basal metabolic rate (BMR) [W] + let q_bmr_total = math.sum(q_bmr_local.map((q) => math.sum(q))); + // Calculate thermogenesis by work [W] + let q_work = local_q_work(q_bmr_total, this._par); + // Calculate the sum of thermogenesis in core, muscle, fat, skin [W] + let { q_thermogenesis_core, q_thermogenesis_muscle, q_thermogenesis_fat, q_thermogenesis_skin, } = sum_m(q_bmr_local.map((c) => c.clone()), q_work, q_shiv, q_nst); + let q_thermogenesis_total = math.sum(q_thermogenesis_core) + + math.sum(q_thermogenesis_muscle) + + math.sum(q_thermogenesis_fat) + + math.sum(q_thermogenesis_skin); + // ------------------------------------------------------------------ + // Others + // ------------------------------------------------------------------ + // Calculate blood flow in core, muscle, fat [L/h] + let { bf_core, bf_muscle, bf_fat } = cr_ms_fat_blood_flow(q_work, q_shiv, this._height, this._weight, this._bsa_equation, this._age, this._ci); + // Calculate heat loss by respiratory + let p_a = math.dotDivide(math.dotMultiply(this._ta.map(antoine), this._rh), 100); + let { res_sh, res_lh } = resp_heat_loss(this._ta.get([0]), p_a.get([0]), q_thermogenesis_total); + // Calculate sensible heat loss [W] + let shl_sk = math.dotMultiply(math.dotDivide(math.subtract(tsk, to), r_t), this._bsa); + // Calculate cardiac output [L/h] + let co = sum_bf(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot); + // Calculate weight loss rate by evaporation [g/sec] + let wlesk = math.dotDivide(math.add(e_sweat, math.dotMultiply(0.06, e_max)), 2418); + let wleres = res_lh / 2418; + // ------------------------------------------------------------------ + // Matrix + // This code section is focused on constructing and calculating + // various matrices required for modeling the thermoregulation + // of the human body. + // Since JOS-3 has 85 thermal nodes, the determinant of 85*85 is to be solved. + // ------------------------------------------------------------------ + // Matrix A = Matrix for heat exchange due to blood flow and conduction occurring between tissues + // (85, 85,) ndarray + // Calculates the blood flow in arteries and veins for core, muscle, fat, skin, + // and arteriovenous anastomoses (AVA) in hands and feet, + // and combines them into two arrays: + // 1) bf_local for the local blood flow and 2) bf_whole for the whole-body blood flow. + // These arrays are then combined to form arr_bf. + let { bf_art, bf_vein } = vessel_blood_flow(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot); + let bf_local = local_arr(bf_core, bf_muscle, bf_fat, bf_skin, bf_ava_hand, bf_ava_foot); + let bf_whole = whole_body(bf_art, bf_vein, bf_ava_hand, bf_ava_foot); + let arr_bf = math.zeros(NUM_NODES, NUM_NODES); + arr_bf = math.add(arr_bf, bf_local); + arr_bf = math.add(arr_bf, bf_whole); + // Adjusts the units of arr_bf from [W/K] to [/sec] and then to [-] + // by dividing by the heat capacity self._cap and multiplying by the time step dtime. + arr_bf = math.dotDivide(arr_bf, math.reshape(this._cap, [NUM_NODES, 1])); // Change unit [W/K] to [/sec] + arr_bf = math.dotMultiply(arr_bf, dtime); // Change unit [/sec] to [-] + // Performs similar unit conversions for the convective heat transfer coefficient array arr_cdt + // (also divided by self._cap and multiplied by dtime). + let arr_cdt = this._cdt.clone(); + arr_cdt = math.dotDivide(arr_cdt, math.reshape(this._cap, [NUM_NODES, 1])); // Change unit [W/K] to [/sec] + arr_cdt = math.dotMultiply(arr_cdt, dtime); // Change unit [/sec] to [-] + // Matrix B = Matrix for heat transfer between skin and environment + let arr_b = math.zeros(NUM_NODES); + arr_b = math.subset(arr_b, math.index(INDEX["skin"]), math.add(math.subset(arr_b, math.index(INDEX["skin"])), math.dotMultiply(math.dotDivide(1, r_t), this._bsa))); + arr_b = math.dotDivide(arr_b, this._cap); // Change unit [W/K] to [/sec] + arr_b = math.dotMultiply(arr_b, dtime); // Change unit [/sec] to [-] + // Calculates the off-diagonal and diagonal elements of the matrix A, + // which represents the heat transfer coefficients between different parts of the body, + // and combines them to form the full matrix A (arrA). + // Then, the inverse of matrix A is computed (arrA_inv). + let arr_a_tria = math.dotMultiply(math.add(arr_cdt, arr_bf), -1); + let arr_a_dia = math.add(arr_cdt, arr_bf); + arr_a_dia = math.add(math.sum(arr_a_dia, 1), arr_b); + arr_a_dia = math.diag(arr_a_dia); + arr_a_dia = math.add(arr_a_dia, math.identity(NUM_NODES)); + let arr_a = math.add(arr_a_tria, arr_a_dia); + let arr_a_inv = math.inv(arr_a); + // Matrix Q = Matrix for heat generation rate from thermogenesis, respiratory, sweating, + // and extra heat gain processes in different body parts. + // Matrix Q [W] / [J/K] * [sec] = [-] + // Thermogensis + let arr_q = math.zeros(NUM_NODES); + arr_q = math.subset(arr_q, math.index(INDEX["core"]), math.add(math.subset(arr_q, math.index(INDEX["core"])), q_thermogenesis_core)); + arr_q = math.subset(arr_q, math.index(INDEX["muscle"]), math.add(math.subset(arr_q, math.index(INDEX["muscle"])), math.subset(q_thermogenesis_muscle, math.index(VINDEX["muscle"])))); + arr_q = math.subset(arr_q, math.index(INDEX["fat"]), math.add(math.subset(arr_q, math.index(INDEX["fat"])), math.subset(q_thermogenesis_fat, math.index(VINDEX["fat"])))); + arr_q = math.subset(arr_q, math.index(INDEX["skin"]), math.add(math.subset(arr_q, math.index(INDEX["skin"])), q_thermogenesis_skin)); + // Respiratory [W] + arr_q.set([INDEX["core"][2]], arr_q.get([INDEX["core"][2]]) - (res_sh + res_lh)); // chest core + // Sweating [W] + arr_q = math.subset(arr_q, math.index(INDEX["skin"]), math.subtract(math.subset(arr_q, math.index(INDEX["skin"])), e_sk)); + // Extra heat gain [W] + arr_q = math.add(arr_q, this.ex_q.clone()); + arr_q = math.dotDivide(arr_q, this._cap); // Change unit [W]/[J/K] to [K/sec] + arr_q = math.dotMultiply(arr_q, dtime); // Change unit [K/sec] to [K] + // Boundary batrix [°C] + let arr_to = math.zeros(NUM_NODES); + arr_to = math.subset(arr_to, math.index(INDEX["skin"]), math.add(math.subset(arr_to, math.index(INDEX["skin"])), to)); + // Combines the current body temperature, the boundary matrix, and the heat generation matrix + // to calculate the new body temperature distribution (arr). + let arr = math.add(math.add(this._bodytemp, math.dotMultiply(arr_b, arr_to)), arr_q); + // ------------------------------------------------------------------ + // New body temp. [°C] + // ------------------------------------------------------------------ + this._bodytemp = math.multiply(arr_a_inv, arr); + // ------------------------------------------------------------------ + // Output parameters + // ------------------------------------------------------------------ + let dict_out = {}; + if (output) { + dict_out["cycle_time"] = this._cycle; + dict_out["simulation_time"] = this._t; + dict_out["dt"] = dtime; + dict_out["t_skin_mean"] = this.t_skin_mean; + dict_out["t_skin"] = this.t_skin.toArray(); + dict_out["t_core"] = this.t_core.toArray(); + dict_out["w_mean"] = + math.sum(math.dotMultiply(wet, JOS3Defaults.local_bsa)) / + math.sum(JOS3Defaults.local_bsa); + dict_out["w"] = wet.toArray(); + dict_out["weight_loss_by_evap_and_res"] = math.sum(wlesk) + wleres; + dict_out["cardiac_output"] = co; + dict_out["q_thermogenesis_total"] = q_thermogenesis_total; + dict_out["q_res"] = res_sh + res_lh; + dict_out["q_skin2env"] = math.add(shl_sk, e_sk).toArray(); + } + let detail_out = {}; + if (this._ex_output && output) { + detail_out["name"] = this.model_name; + detail_out["height"] = this._height; + detail_out["weight"] = this._weight; + detail_out["bsa"] = this._bsa.toArray(); + detail_out["fat"] = this._fat; + detail_out["sex"] = this._sex; + detail_out["age"] = this._age; + detail_out["t_core_set"] = setpt_cr.toArray(); + detail_out["t_skin_set"] = setpt_sk.toArray(); + detail_out["t_cb"] = this.t_cb; + detail_out["t_artery"] = this.t_artery.toArray(); + detail_out["t_vein"] = this.t_vein.toArray(); + detail_out["t_superficial_vein"] = this.t_superficial_vein.toArray(); + detail_out["t_muscle"] = this.t_muscle.toArray(); + detail_out["t_fat"] = this.t_fat.toArray(); + detail_out["to"] = to.toArray(); + detail_out["r_t"] = r_t.toArray(); + detail_out["r_et"] = r_et.toArray(); + detail_out["tdb"] = this._ta.clone().toArray(); + detail_out["tr"] = this._tr.clone().toArray(); + detail_out["rh"] = this._rh.clone().toArray(); + detail_out["v"] = this._va.clone().toArray(); + detail_out["par"] = this._par; + detail_out["clo"] = this._clo.clone().toArray(); + detail_out["e_skin"] = e_sk.toArray(); + detail_out["e_max"] = e_max.toArray(); + detail_out["e_sweat"] = e_sweat.toArray(); + detail_out["bf_core"] = bf_core.toArray(); + detail_out["bf_muscle"] = math + .subset(bf_muscle, math.index(VINDEX["muscle"])) + .toArray(); + detail_out["bf_fat"] = math + .subset(bf_fat, math.index(VINDEX["fat"])) + .toArray(); + detail_out["bf_skin"] = bf_skin.toArray(); + detail_out["bf_ava_hand"] = bf_ava_hand; + detail_out["bf_ava_foot"] = bf_ava_foot; + detail_out["q_bmr_core"] = q_bmr_local[0].toArray(); + detail_out["q_bmr_muscle"] = math + .subset(q_bmr_local[1], math.index(VINDEX["muscle"])) + .toArray(); + detail_out["q_bmr_fat"] = math + .subset(q_bmr_local[2], math.index(VINDEX["fat"])) + .toArray(); + detail_out["q_bmr_skin"] = q_bmr_local[3].toArray(); + detail_out["q_work"] = q_work.toArray(); + detail_out["q_shiv"] = q_shiv.toArray(); + detail_out["q_nst"] = q_nst.toArray(); + detail_out["q_thermogenesis_core"] = q_thermogenesis_core.toArray(); + detail_out["q_thermogenesis_muscle"] = math + .subset(q_thermogenesis_muscle, math.index(VINDEX["muscle"])) + .toArray(); + detail_out["q_thermogenesis_fat"] = math + .subset(q_thermogenesis_fat, math.index(VINDEX["fat"])) + .toArray(); + detail_out["q_thermogenesis_skin"] = q_thermogenesis_skin.toArray(); + dict_out["q_skin2env_sensible"] = shl_sk.toArray(); + dict_out["q_skin2env_latent"] = e_sk.toArray(); + dict_out["q_res_sensible"] = res_sh; + dict_out["q_res_latent"] = res_lh; + } + if (this._ex_output === "all") { + dict_out = { ...dict_out, ...detail_out }; + } + else if (Array.isArray(this._ex_output)) { + const out_keys = Object.keys(detail_out); + for (const key in this._ex_output) { + if (out_keys.includes(key)) { + dict_out[key] = detail_out[key]; + } + } + } + return dict_out; + } + /** + * Get results as a dictionary with the model values. + * + * @returns {object} + */ + dict_results() { + if (!this._history || this._history.length === 0) { + console.log("The model has no data."); + return null; + } + const checkWordContain = (word, ...args) => { + return args.some((arg) => word.includes(arg)); + }; + let key2keys = {}; // Column keys + for (let [key, value] of Object.entries(this._history[0])) { + let keys; + if (value.length !== undefined) { + if (typeof value === "string") { + keys = [key]; // string is iter. Convert to list without suffix + } + else if (checkWordContain(key, "sve", "sfv", "superficialvein")) { + keys = VINDEX["sfvein"].map((i) => `${key}_${BODY_NAMES[i]}`); + } + else if (checkWordContain(key, "ms", "muscle")) { + keys = VINDEX["muscle"].map((i) => `${key}_${BODY_NAMES[i]}`); + } + else if (checkWordContain(key, "fat")) { + keys = VINDEX["fat"].map((i) => `${key}_${BODY_NAMES[i]}`); + } + else if (value.length === 17) { + keys = BODY_NAMES.map((bn) => `${key}_${bn}`); + } + else { + keys = Array.from({ length: value.length }, (_, i) => `${key}_${BODY_NAMES[i]}`); + } + } + else { + keys = [key]; + } + key2keys[key] = keys; + } + let data = this._history.map((dictout) => { + let row = {}; + for (let [key, value] of Object.entries(dictout)) { + let keys = key2keys[key]; + let values = keys.length === 1 ? [value] : value; + keys.forEach((k, i) => { + row[k] = values[i]; + }); + } + return row; + }); + let outDict = {}; + Object.keys(data[0]).forEach((key) => { + outDict[key] = data.map((row) => row[key]); + }); + return outDict; + } + /** + * Set extra heat gain by tissue name. + * + * @private + * + * @param {string} tissue - Tissue name. "core", "skin", or "artery".... If you set value to head muscle and other segment's core, set "all_muscle". + * @param {number | math.MathCollection} value - Heat gain [W] + * + * @return {math.MathCollection} Extra heat gain of model. + */ + _set_ex_q(tissue, value) { + this.ex_q = math.subset(this.ex_q, math.index(INDEX[tissue]), value); + return this.ex_q; + } + /** + * Dry-bulb air temperature. + * + * @return {math.Matrix} + */ + get tdb() { + return this._ta; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tdb(inp) { + this._ta = _to17array(inp); + } + /** + * Mean radiant temperature [°C]. + * + * @return {math.Matrix} + */ + get tr() { + return this._tr; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tr(inp) { + this._tr = _to17array(inp); + } + /** + * Operative temperature [°C]. + * + * @return {math.Matrix} + */ + get to() { + const hc = fixed_hc(conv_coef(this._posture, this._va, this._ta, this.t_skin), this._va); + const hr = fixed_hr(rad_coef(this._posture)); + return operative_temp(this._ta, this._tr, hc, hr); + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set to(inp) { + this._ta = _to17array(inp); + this._tr = _to17array(inp); + } + /** + * Relative humidity [%]. + * + * @return {math.Matrix} + */ + get rh() { + return this._rh; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set rh(inp) { + this._rh = _to17array(inp); + } + /** + * Air velocity [m/s]. + * + * @return {math.Matrix} + */ + get v() { + return this._va; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set v(inp) { + this._va = _to17array(inp); + } + /** + * Current JOS3 posture. + * + * @return {string} + */ + get posture() { + return this._posture; + } + /** + * @param inp {number | string} + */ + set posture(inp) { + if (inp === 0) { + this._posture = "standing"; + } + else if (inp === 1) { + this._posture = "sitting"; + } + else if (inp === 2) { + this._posture = "lying"; + } + else if (inp.toLowerCase() === "standing") { + this._posture = "standing"; + } + else if (["sitting", "sedentary"].includes(inp.toLowerCase())) { + this._posture = "sitting"; + } + else if (["lying", "supine"].includes(inp.toLowerCase())) { + this._posture = "lying"; + } + else { + this._posture = "standing"; + console.log('posture must be 0="standing", 1="sitting" or 2="lying".'); + console.log('posture was set "standing".'); + } + } + /** + * Clothing insulation [clo]. + * + * @return {math.Matrix} + */ + get clo() { + return this._clo; + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set clo(inp) { + this._clo = _to17array(inp); + } + /** + * Physical activity ratio [-].This equals the ratio of metabolic rate to basal metabolic rate. par of sitting quietly is 1.2. + * + * @return {number} + */ + get par() { + return this._par; + } + /** + * @param inp {number} + */ + set par(inp) { + this._par = inp; + } + /** + * All segment temperatures of JOS-3. + * + * @return {math.Matrix} + */ + get body_temp() { + return this._bodytemp; + } + /** + * @param inp {math.Matrix} + */ + set body_temp(inp) { + this._bodytemp = inp.clone(); + } + /** + * Body surface areas by local body segments [m2]. + * + * @return {math.Matrix} + */ + get bsa() { + return this._bsa.clone(); + } + /** + * Dry heat resistances between the skin and ambience areas by local body segments [(m2*K)/W]. + * + * @return {math.Matrix} + */ + get r_t() { + const hc = fixed_hc(conv_coef(this._posture, this._va, this._ta, this.t_skin), this._va); + const hr = fixed_hr(rad_coef(this._posture)); + return dry_r(hc, hr, this._clo); + } + /** + * w (Evaporative) heat resistances between the skin and ambience areas by local body segments [(m2*kPa)/W]. + * + * @return {math.Matrix} + */ + get r_et() { + const hc = fixed_hc(conv_coef(this._posture, this._va, this._ta, this.t_skin), this._va); + return wet_r(hc, this._clo, this._iclo); + } + /** + * Skin wettedness on local body segments [-]. + * + * @return {math.Matrix} + */ + get w() { + const err_cr = math.subtract(this.t_core, this.setpt_cr); + const err_sk = math.subtract(this.t_skin, this.setpt_sk); + const { wet } = evaporation(err_cr, err_sk, this.t_skin, this._ta, this._rh, this.r_et, this._bsa_rate, this._age); + return wet; + } + /** + * Mean skin wettedness of the whole body [-]. + * + * @return {number} + */ + get w_mean() { + const wet = this.w; + const bsa_sum = math.sum(JOS3Defaults.local_bsa); + return math.sum(math.dotMultiply(wet, JOS3Defaults.local_bsa)) / bsa_sum; + } + /** + * Mean skin temperature of the whole body [°C]. + * + * @return {number} + */ + get t_skin_mean() { + return (math.sum(math.dotMultiply(math.subset(this._bodytemp, math.index(INDEX["skin"])), JOS3Defaults.local_bsa)) / math.sum(JOS3Defaults.local_bsa)); + } + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_skin() { + return math.subset(this._bodytemp, math.index(INDEX["skin"])); + } + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set t_skin(inp) { + this._bodytemp = math.subset(this._bodytemp, math.index(INDEX["skin"]), _to17array(inp)); + } + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_core() { + return math.subset(this._bodytemp, math.index(INDEX["core"])); + } + /** + * Temperature at central blood pool [°C]. + * + * @return {number} + */ + get t_cb() { + return this._bodytemp.get([0]); + } + /** + * Arterial temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_artery() { + return math.subset(this._bodytemp, math.index(INDEX["artery"])); + } + /** + * Vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_vein() { + return math.subset(this._bodytemp, math.index(INDEX["vein"])); + } + /** + * Superficial vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_superficial_vein() { + return math.subset(this._bodytemp, math.index(INDEX["sfvein"])); + } + /** + * Muscle temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_muscle() { + return math.subset(this._bodytemp, math.index(INDEX["muscle"])); + } + /** + * Fat temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_fat() { + return math.subset(this._bodytemp, math.index(INDEX["fat"])); + } + /** + * JOS3 body names + * + * @return {string[]} + */ + get body_names() { + return BODY_NAMES; + } + /** + * Results of the model. + * + * @return {object} + */ + get results() { + return this.dict_results(); + } + /** + * Basal metabolic rate. + * @returns {number} + */ + get bmr() { + const tcr = basal_met(this._height, this._weight, this._age, this._sex, this._bmr_equation); + return tcr / math.sum(this._bsa); + } +} diff --git a/lib/esm/models/index.js b/lib/esm/models/index.js index 86389a3..f0bbdfb 100644 --- a/lib/esm/models/index.js +++ b/lib/esm/models/index.js @@ -23,6 +23,7 @@ import { use_fans_heatwaves } from "./use_fans_heatwave.js"; import { clo_tout, clo_tout_array } from "./clo_tout.js"; import { utci, utci_array } from "./utci.js"; import { pet_steady } from "./pet_steady.js"; +import { JOS3 } from "./JOS3.js"; /** * @public * @name models @@ -66,4 +67,5 @@ export default { vertical_tmp_grad_ppd, wbgt, wc, + JOS3, }; diff --git a/lib/esm/supa.js b/lib/esm/supa.js new file mode 100644 index 0000000..ff165d9 --- /dev/null +++ b/lib/esm/supa.js @@ -0,0 +1,62 @@ +export function $map(arrays, op) { + const mapLength = arrays[0].length; + if (!arrays.every((a) => a.length === mapLength)) { + throw new Error(`cannot $map over arrays of different lengths (${arrays[1].length} vs ${mapLength})`); + } + const result = []; + for (let i = 0; i < mapLength; i++) { + const items = arrays.map((a) => a[i]); + result.push(op(items, i)); + } + return result; +} +/** + * @template T + * @param {number} length + * @param {T} value + * + * @return {T[]} + */ +export function $array(length, value) { + return Array(length).fill(value); +} +/** + * @template T + * @param arrays {T[][]} + * @param op {(reduced: T, items: T[]) => T} + * @param initial {T} + * + * @return {T} + */ +export function $reduce(arrays, op, initial) { + const reduceLength = arrays[0].length; + if (!arrays.every((a) => a.length === reduceLength)) { + throw new Error(`cannot $reduce over arrays of different lengths (${a.length} vs ${reduceLength})`); + } + let reduced = initial; + for (let i = 0; i < reduceLength; i++) { + const items = arrays.map((a) => a[i]); + reduced = op(reduced, items); + } + return reduced; +} +export function $average(array, weights) { + return ($reduce([array, weights], (reduced, [array, weights]) => reduced + array * weights, 0) / $sum(weights)); +} +export function $lerp(length, min, max) { + return Array(length) + .fill(min) + .map((x, i) => x + i * ((max - min) / (length - 1))); +} +export function $sum(array) { + return array.reduce((t, c) => t + c, 0); +} +export function $max(array, sentinel) { + return array.map((array) => (array < sentinel ? sentinel : array)); +} +export function $min(array, sentinel) { + return array.map((array) => (array > sentinel ? sentinel : array)); +} +export function $index(array, indicies) { + return array.filter((_, i) => indicies.includes(i)); +} diff --git a/lib/esm/types/jos3_functions/JOS3Defaults.d.ts b/lib/esm/types/jos3_functions/JOS3Defaults.d.ts new file mode 100644 index 0000000..9b2b2f6 --- /dev/null +++ b/lib/esm/types/jos3_functions/JOS3Defaults.d.ts @@ -0,0 +1,27 @@ +export default JOS3Defaults; +declare namespace JOS3Defaults { + let height: number; + let weight: number; + let age: number; + let body_fat: number; + let cardiac_index: number; + let blood_flow_rate: number; + let physical_activity_ratio: number; + let metabolic_rate: number; + let sex: string; + let posture: string; + let bmr_equation: string; + let bsa_equation: string; + let local_bsa: number[]; + let core_temperature: number; + let skin_temperature: number; + let other_body_temperature: number; + let dry_bulb_air_temperature: number; + let mean_radiant_temperature: number; + let relative_humidity: number; + let air_speed: number; + let clothing_insulation: number; + let clothing_vapor_permeation_efficiency: number; + let lewis_rate: number; +} +//# sourceMappingURL=JOS3Defaults.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/JOS3Defaults.d.ts.map b/lib/esm/types/jos3_functions/JOS3Defaults.d.ts.map new file mode 100644 index 0000000..403bc99 --- /dev/null +++ b/lib/esm/types/jos3_functions/JOS3Defaults.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"JOS3Defaults.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/JOS3Defaults.js"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/bfb_rate.d.ts b/lib/esm/types/jos3_functions/bfb_rate.d.ts new file mode 100644 index 0000000..c6cf2be --- /dev/null +++ b/lib/esm/types/jos3_functions/bfb_rate.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate the ratio of basal blood flow (BFB) of the standard body (290 L/h). + * + * @param {number} height - Body height [m]. The default is 1.72. + * @param {number} weight - Body weight [kg]. The default is 74.43. + * @param {string} bsa_equation - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". The default is "dubois". + * @param {number} age - age [years]. The default is 20. + * @param {number} ci - Cardiac index [L/min/㎡]. The default is 2.59. + * + * @returns {number} - Basal blood flow rate. + */ +export function bfb_rate(height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): number; +//# sourceMappingURL=bfb_rate.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/bfb_rate.d.ts.map b/lib/esm/types/jos3_functions/bfb_rate.d.ts.map new file mode 100644 index 0000000..055199c --- /dev/null +++ b/lib/esm/types/jos3_functions/bfb_rate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bfb_rate.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/bfb_rate.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,kCARW,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,MAAM,CA8BlB"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/bsa_rate.d.ts b/lib/esm/types/jos3_functions/bsa_rate.d.ts new file mode 100644 index 0000000..5245cde --- /dev/null +++ b/lib/esm/types/jos3_functions/bsa_rate.d.ts @@ -0,0 +1,15 @@ +/** + * Calculates the body surface area rate based on the given height, weight and + * BSA equation. + * + * @param {number} [height=JOS3Defaults.height] - The height of the person in + * meters. + * @param {number} [weight=JOS3Defaults.weight] - The weight of the person in + * kilograms. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The BSA equation + * to use for calculation. + * + * @returns {number} The body surface area rate. + */ +export function bsa_rate(height?: number, weight?: number, bsa_equation?: string): number; +//# sourceMappingURL=bsa_rate.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/bsa_rate.d.ts.map b/lib/esm/types/jos3_functions/bsa_rate.d.ts.map new file mode 100644 index 0000000..4e848e2 --- /dev/null +++ b/lib/esm/types/jos3_functions/bsa_rate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bsa_rate.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/bsa_rate.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,kCATW,MAAM,WAEN,MAAM,iBAEN,MAAM,GAGJ,MAAM,CAWlB"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/capacity.d.ts b/lib/esm/types/jos3_functions/capacity.d.ts new file mode 100644 index 0000000..318ae68 --- /dev/null +++ b/lib/esm/types/jos3_functions/capacity.d.ts @@ -0,0 +1,19 @@ +/** + * Calculate thermal capacity in Joules per Kelvin (J/K). + * Derived from Yokoyama's model, assuming blood's heat as 1.0 [kcal/L.K]. + * + * @param {number} [height=JOS3Defaults.height] - Body height in meters. Default + * is 1.72. + * @param {number} [weight=JOS3Defaults.weight] - Body weight in kg. Default is + * 74.43. + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - Equation name for + * bsa calc. Must be from "dubois","takahira", "fujimoto", "kurazumi". + * Default is "dubois". + * @param {number} [age=JOS3Defaults.age] - Age in years. Default is 20. + * @param {number} [ci=JOS3Defaults.cardiac_index] - Cardiac index in L/min/㎡. + * Default is 2.59. + + * @returns {number[]} - Thermal capacity in W/K. Shape is (NUM_NODES). + */ +export function capacity(height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): number[]; +//# sourceMappingURL=capacity.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/capacity.d.ts.map b/lib/esm/types/jos3_functions/capacity.d.ts.map new file mode 100644 index 0000000..032f726 --- /dev/null +++ b/lib/esm/types/jos3_functions/capacity.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"capacity.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/capacity.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,kCAbW,MAAM,WAEN,MAAM,iBAEN,MAAM,QAGN,MAAM,OACN,MAAM,GAGJ,MAAM,EAAE,CAiGpB"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/conductance.d.ts b/lib/esm/types/jos3_functions/conductance.d.ts new file mode 100644 index 0000000..19acd4f --- /dev/null +++ b/lib/esm/types/jos3_functions/conductance.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate thermal conductance between layers. + + * @param {number} height - Body height in [m]. Default is 1.72. + * @param {number} weight - Body weight in [kg]. Default is 74.43. + * @param {string} bsa_equation - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". Default is "dubois". + * @param {number} fat - Body fat rate in [%]. Default is 15. + + * @returns {math.Matrix} conductance - Thermal conductance between layers in [W/K]. The shape is (NUM_NODES, NUM_NODES). + */ +export function conductance(height?: number, weight?: number, bsa_equation?: string, fat?: number): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=conductance.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/conductance.d.ts.map b/lib/esm/types/jos3_functions/conductance.d.ts.map new file mode 100644 index 0000000..8ded809 --- /dev/null +++ b/lib/esm/types/jos3_functions/conductance.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"conductance.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/conductance.js"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,qCAPW,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,GAEJ,KAAK,MAAM,CAqJvB;sBA/JqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/local_bsa.d.ts b/lib/esm/types/jos3_functions/local_bsa.d.ts new file mode 100644 index 0000000..b03748a --- /dev/null +++ b/lib/esm/types/jos3_functions/local_bsa.d.ts @@ -0,0 +1,19 @@ +/** + * Calculate local body surface area (bsa) [m2]. + * + * The local body surface area has been derived from 65MN. + * The head have been divided to head and neck based on Smith's model. + * head = 0.1396*0.1117/0.1414 (65MN_Head * Smith_Head / Smith_Head+neck) + * neck = 0.1396*0.0297/0.1414 (65MN_Head * Smith_Neck / Smith_Head+neck) + * + * @param {number} [height=JOS3Defaults.height] - Body height [m] + * @param {number} [weight=JOS3Defaults.weight] - Body weight [kg] + * @param {string} [bsa_equation=JOS3Defaults.bsa_equation] - The equation name + * of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", + * or "kurazumi". + * + * @returns {math.Matrix} local_bsa of length 17 - Local body surface area (bsa) [m2] + */ +export function local_bsa(height?: number, weight?: number, bsa_equation?: string): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=local_bsa.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/local_bsa.d.ts.map b/lib/esm/types/jos3_functions/local_bsa.d.ts.map new file mode 100644 index 0000000..91afde9 --- /dev/null +++ b/lib/esm/types/jos3_functions/local_bsa.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"local_bsa.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/local_bsa.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,mCARW,MAAM,WACN,MAAM,iBACN,MAAM,GAIJ,KAAK,MAAM,CAWvB;sBA3BqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/matrix.d.ts b/lib/esm/types/jos3_functions/matrix.d.ts new file mode 100644 index 0000000..9ffcd07 --- /dev/null +++ b/lib/esm/types/jos3_functions/matrix.d.ts @@ -0,0 +1,63 @@ +/** + * @typedef VesselBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_art - Artery blood flow rate [l/h]. + * @property {math.MathCollection} bf_vein - Vein blood flow rate [l/h]. + */ +/** + * Get artery and vein blood flow rate [l/h]. + * + * @param {math.MathCollection} bf_core - Core blood flow rate [l/h]. + * @param {math.MathCollection} bf_muscle - Muscle blood flow rate [l/h]. + * @param {math.MathCollection} bf_fat - Fat blood flow rate [l/h]. + * @param {math.MathCollection} bf_skin - Skin blood flow rate [l/h]. + * @param {number} bf_ava_hand - AVA blood flow rate at hand [l/h]. + * @param {number} bf_ava_foot - AVA blood flow rate at foot [l/h]. + * + * @returns {VesselBloodFlowResult} bf_artery, bf_vein - Artery and vein blood flow rate [l/h]. + */ +export function vessel_blood_flow(bf_core: math.MathCollection, bf_muscle: math.MathCollection, bf_fat: math.MathCollection, bf_skin: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): VesselBloodFlowResult; +/** + * Create matrix to calculate heat exchange by blood flow in each segment. + * + * @param {math.MathCollection} bf_core + * @param {math.MathCollection} bf_muscle + * @param {math.MathCollection} bf_fat + * @param {math.MathCollection} bf_skin + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @returns {math.Matrix} The heat exchange by blood flow in each segment. + */ +export function local_arr(bf_core: math.MathCollection, bf_muscle: math.MathCollection, bf_fat: math.MathCollection, bf_skin: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): math.Matrix; +/** + * Create matrix to calculate heat exchange by blood flow between segments. [W/K] + * + * @param {math.MathCollection} bf_art + * @param {math.MathCollection} bf_vein + * @param {number} bf_ava_hand + * @param {number} bf_ava_foot + * + * @return {math.Matrix} + */ +export function whole_body(bf_art: math.MathCollection, bf_vein: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): math.Matrix; +export const BODY_NAMES: string[]; +export const LAYER_NAMES: string[]; +export namespace IDICT { + let CB: number; +} +export const NUM_NODES: number; +export const INDEX: {}; +export const VINDEX: {}; +export type VesselBloodFlowResult = { + /** + * - Artery blood flow rate [l/h]. + */ + bf_art: math.MathCollection; + /** + * - Vein blood flow rate [l/h]. + */ + bf_vein: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=matrix.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/matrix.d.ts.map b/lib/esm/types/jos3_functions/matrix.d.ts.map new file mode 100644 index 0000000..002068a --- /dev/null +++ b/lib/esm/types/jos3_functions/matrix.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/matrix.js"],"names":[],"mappings":"AAwFA;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AACH,2CATW,KAAK,cAAc,aACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEJ,qBAAqB,CAsHjC;AAED;;;;;;;;;;;GAWG;AACH,mCATW,KAAK,cAAc,aACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEJ,KAAK,MAAM,CAkFvB;AAED;;;;;;;;;GASG;AACH,mCAPW,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEL,KAAK,MAAM,CAkFtB;AAvZD,kCAkBE;AAEF,mCAQE;;;;;;;;;;;YA6DY,KAAK,cAAc;;;;aACnB,KAAK,cAAc;;sBA5FX,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts b/lib/esm/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts new file mode 100644 index 0000000..256d2bc --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts @@ -0,0 +1,33 @@ +/** + * @typedef AvaBloodFlowResult + * @type {object} + * @property {number} bf_ava_hand - AVA blood flow rate at hand [L/h]. + * @property {number} bf_ava_foot - AVA blood flow rate at foot [L/h]. + */ +/** + * Calculate areteriovenous anastmoses (AVA) blood flow rate [L/h] based on + * Takemori's model, 1995. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m] + * @param {number} [weight=74.43] - Body weight [kg] + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi" + * @param {number} [age=20] - age [years] + * @param {number} [ci=2.59] - Cardiac index [L/min/m2] + * + * @returns {AvaBloodFlowResult} AVA blood flow rate at hand and foot [L/h] + */ +export function ava_blood_flow(err_cr: math.MathCollection, err_sk: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): AvaBloodFlowResult; +export type AvaBloodFlowResult = { + /** + * - AVA blood flow rate at hand [L/h]. + */ + bf_ava_hand: number; + /** + * - AVA blood flow rate at foot [L/h]. + */ + bf_ava_foot: number; +}; +import * as math from "mathjs"; +//# sourceMappingURL=ava_blood_flow.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts.map new file mode 100644 index 0000000..647d9b1 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/ava_blood_flow.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ava_blood_flow.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/ava_blood_flow.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;;;;;;;;;;;;;GAaG;AACH,uCAVW,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,kBAAkB,CA0C9B;;;;;iBA1Da,MAAM;;;;iBACN,MAAM;;sBANE,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/basal_met.d.ts b/lib/esm/types/jos3_functions/thermoregulation/basal_met.d.ts new file mode 100644 index 0000000..0c96d17 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/basal_met.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {string} [bmr_equation="harris-benedict"] - Choose harris-benedict or ganpule. + * + * @returns {number} Basal metabolic rate [W]. + */ +export function basal_met(height?: number, weight?: number, age?: number, sex?: string, bmr_equation?: string): number; +//# sourceMappingURL=basal_met.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/basal_met.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/basal_met.d.ts.map new file mode 100644 index 0000000..bb4d754 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/basal_met.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"basal_met.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/basal_met.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,mCARW,MAAM,WACN,MAAM,QACN,MAAM,QACN,MAAM,iBACN,MAAM,GAEJ,MAAM,CAkDlB"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/clo_area_factor.d.ts b/lib/esm/types/jos3_functions/thermoregulation/clo_area_factor.d.ts new file mode 100644 index 0000000..88f31e4 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/clo_area_factor.d.ts @@ -0,0 +1,9 @@ +/** + * Calculate clothing area factor + * + * @param {math.Matrix} clo - Clothing insulation. + * + * @returns {math.Matrix} clothing area factor. + */ +export function clo_area_factor(clo: math.Matrix): math.Matrix; +//# sourceMappingURL=clo_area_factor.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/clo_area_factor.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/clo_area_factor.d.ts.map new file mode 100644 index 0000000..01729a5 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/clo_area_factor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"clo_area_factor.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/clo_area_factor.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qCAJW,KAAK,MAAM,GAET,KAAK,MAAM,CAIvB"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/conv_coef.d.ts b/lib/esm/types/jos3_functions/thermoregulation/conv_coef.d.ts new file mode 100644 index 0000000..34ec772 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/conv_coef.d.ts @@ -0,0 +1,16 @@ +/** + * Calculate convective heat transfer coefficient (hc) [W/(m2*K)] + * + * @param {string} [posture=JOS3Defaults.posture] - Select posture from standing, sitting, lying, sedentary or supine. The default is "standing". + * @param {math.Matrix} [v=JOS3Defaults.air_speed] - Air velocity [m/s]. If Iterable is input, its length should be 17. The default is 0.1. + * @param {math.Matrix} [tdb=JOS3Defaults.dry_bulb_air_temperature] - Air temperature [°C]. If Iterable is input, its length should be 17. The default is 28.8. + * @param {math.Matrix} [t_skin=JOS3Defaults.skin_temperature] - Skin temperature [°C]. If Iterable is input, its length should be 17. The default is 34.0. + * + * @returns {math.Matrix} Convective heat transfer coefficient (hc) [W/(m2*K)]. + * + * @see {@link https://doi.org/10.3130/aija.62.45_5 | Ichihara et al., 1997} + * @see {@link https://doi.org/10.20718/jjpa.13.1_17 | Kurazumi et al., 2008} + */ +export function conv_coef(posture?: string, v?: math.Matrix, tdb?: math.Matrix, t_skin?: math.Matrix): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=conv_coef.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/conv_coef.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/conv_coef.d.ts.map new file mode 100644 index 0000000..1be1dc6 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/conv_coef.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"conv_coef.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/conv_coef.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,oCAVW,MAAM,MACN,KAAK,MAAM,QACX,KAAK,MAAM,WACX,KAAK,MAAM,GAET,KAAK,MAAM,CAkHvB;sBA5HqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts b/lib/esm/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts new file mode 100644 index 0000000..971a9f4 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts @@ -0,0 +1,37 @@ +/** + * @typedef CrMsFatBloodFlowResult + * @type {object} + * @property {math.MathCollection} bf_core - Core blood flow rate [L/h]. + * @property {math.MathCollection} bf_muscle - Muscle blood flow rate [L/h]. + * @property {math.MathCollection} bf_fat - Fat blood flow rate [L/h]. + */ +/** + * Calculate core, muscle and fat blood flow rate [L/h]. + * + * @param {math.MathCollection} q_work - Heat production by work [W]. + * @param {math.MathCollection} q_shiv - Heat production by shivering [W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose from "dubois","takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - Age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {CrMsFatBloodFlowResult} - Core, muscle and fat blood flow rate [L/h]. + */ +export function cr_ms_fat_blood_flow(q_work: math.MathCollection, q_shiv: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): CrMsFatBloodFlowResult; +export type CrMsFatBloodFlowResult = { + /** + * - Core blood flow rate [L/h]. + */ + bf_core: math.MathCollection; + /** + * - Muscle blood flow rate [L/h]. + */ + bf_muscle: math.MathCollection; + /** + * - Fat blood flow rate [L/h]. + */ + bf_fat: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=cr_ms_fat_blood_flow.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts.map new file mode 100644 index 0000000..3259508 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cr_ms_fat_blood_flow.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,6CAVW,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,sBAAsB,CAoDlC;;;;;aApEa,KAAK,cAAc;;;;eACnB,KAAK,cAAc;;;;YACnB,KAAK,cAAc;;sBAPX,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/dry_r.d.ts b/lib/esm/types/jos3_functions/thermoregulation/dry_r.d.ts new file mode 100644 index 0000000..0829c1a --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/dry_r.d.ts @@ -0,0 +1,12 @@ +/** + * Calculate total sensible thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * + * @returns {math.Matrix} Total sensible thermal resistance between skin and ambient. + */ +export function dry_r(hc: math.Matrix, hr: math.Matrix, clo: math.Matrix): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=dry_r.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/dry_r.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/dry_r.d.ts.map new file mode 100644 index 0000000..6ca8ed9 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/dry_r.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"dry_r.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/dry_r.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,0BANW,KAAK,MAAM,MACX,KAAK,MAAM,OACX,KAAK,MAAM,GAET,KAAK,MAAM,CAWvB;sBApBqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/error_signals.d.ts b/lib/esm/types/jos3_functions/thermoregulation/error_signals.d.ts new file mode 100644 index 0000000..85b3efb --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/error_signals.d.ts @@ -0,0 +1,27 @@ +/** + * @typedef ErrorSignalsResult + * @type {object} + * @property {number} wrms - Warm signal [°C]. + * @property {number} clds - Cold signal [°C]. + */ +/** + * Calculate WRMS and CLDS signals of thermoregulation. + * + * @param {math.MathCollection} [err_sk=0] - Difference between set-point and skin temperatures [°C]. + * If the provided value is an array, its length should be 17. + * + * @returns {ErrorSignalsResult} an object containing the results of the calculation. + */ +export function error_signals(err_sk?: math.MathCollection): ErrorSignalsResult; +export type ErrorSignalsResult = { + /** + * - Warm signal [°C]. + */ + wrms: number; + /** + * - Cold signal [°C]. + */ + clds: number; +}; +import * as math from "mathjs"; +//# sourceMappingURL=error_signals.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/error_signals.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/error_signals.d.ts.map new file mode 100644 index 0000000..b6c6f9c --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/error_signals.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"error_signals.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/error_signals.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,uCALW,KAAK,cAAc,GAGjB,kBAAkB,CAiB9B;;;;;UA3Ba,MAAM;;;;UACN,MAAM;;sBANE,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/evaporation.d.ts b/lib/esm/types/jos3_functions/thermoregulation/evaporation.d.ts new file mode 100644 index 0000000..4e6f472 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/evaporation.d.ts @@ -0,0 +1,46 @@ +/** + * @typedef EvaporationResult + * @type {object} + * @property {math.MathCollection} wet - Local skin wettedness [-]. + * @property {math.MathCollection} e_sk - Evaporative heat loss at the skin by sweating and diffuse [W]. + * @property {math.MathCollection} e_max - Maximum evaporative heat loss at the skin [W]. + * @property {math.MathCollection} e_sweat - Evaporative heat loss at the skin by only sweating [W]. + */ +/** + * Calculate evaporative heat loss. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_skin - Skin temperatures [°C]. + * @param {math.MathCollection} tdb - Air temperatures at local body segments [°C]. + * @param {math.MathCollection} rh - Relative humidity at local body segments [%]. + * @param {math.MathCollection} ret - Total evaporative thermal resistances [m2.K/W]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * + * @returns {EvaporationResult} an object containing the results of the calculation. + */ +export function evaporation(err_cr: math.MathCollection, err_sk: math.MathCollection, t_skin: math.MathCollection, tdb: math.MathCollection, rh: math.MathCollection, ret: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number): EvaporationResult; +export function antoine(x: number): number; +export type EvaporationResult = { + /** + * - Local skin wettedness [-]. + */ + wet: math.MathCollection; + /** + * - Evaporative heat loss at the skin by sweating and diffuse [W]. + */ + e_sk: math.MathCollection; + /** + * - Maximum evaporative heat loss at the skin [W]. + */ + e_max: math.MathCollection; + /** + * - Evaporative heat loss at the skin by only sweating [W]. + */ + e_sweat: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=evaporation.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/evaporation.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/evaporation.d.ts.map new file mode 100644 index 0000000..47b7faf --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/evaporation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"evaporation.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/evaporation.js"],"names":[],"mappings":"AAaA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,oCAbW,KAAK,cAAc,UACnB,KAAK,cAAc,UACnB,KAAK,cAAc,OACnB,KAAK,cAAc,MACnB,KAAK,cAAc,OACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,GAEJ,iBAAiB,CA+D7B;AAxFM,2BAHI,MAAM,GACJ,MAAM,CAEqD;;;;;SAK1D,KAAK,cAAc;;;;UACnB,KAAK,cAAc;;;;WACnB,KAAK,cAAc;;;;aACnB,KAAK,cAAc;;sBAhBX,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/fixed_hc.d.ts b/lib/esm/types/jos3_functions/thermoregulation/fixed_hc.d.ts new file mode 100644 index 0000000..d8364fb --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/fixed_hc.d.ts @@ -0,0 +1,5 @@ +/** + * Fixes hc values to fit two-node-model's values. + */ +export function fixed_hc(hc: any, v: any): any; +//# sourceMappingURL=fixed_hc.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/fixed_hc.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/fixed_hc.d.ts.map new file mode 100644 index 0000000..c183e22 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/fixed_hc.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"fixed_hc.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/fixed_hc.js"],"names":[],"mappings":"AAGA;;GAEG;AACH,+CAWC"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/fixed_hr.d.ts b/lib/esm/types/jos3_functions/thermoregulation/fixed_hr.d.ts new file mode 100644 index 0000000..ecdd6a0 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/fixed_hr.d.ts @@ -0,0 +1,9 @@ +/** + * Fixes hr values to fit two-node-model's values. + * + * @param {math.MathCollection} hr + * @return {math.Matrix} + */ +export function fixed_hr(hr: math.MathCollection): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=fixed_hr.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/fixed_hr.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/fixed_hr.d.ts.map new file mode 100644 index 0000000..5ac832e --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/fixed_hr.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"fixed_hr.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/fixed_hr.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,6BAHW,KAAK,cAAc,GAClB,KAAK,MAAM,CAQtB;sBAdqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/local_mbase.d.ts b/lib/esm/types/jos3_functions/thermoregulation/local_mbase.d.ts new file mode 100644 index 0000000..d36f339 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/local_mbase.d.ts @@ -0,0 +1,14 @@ +/** + * Calculate local basal metabolic rate [W]. + * + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {number} [age=20] - Age [years]. + * @param {string} [sex='male'] - Sex (male or female). + * @param {string} [bmr_equation='harris-benedict'] - BMR equation to use (harris-benedict or ganpule). + * + * @returns {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + */ +export function local_mbase(height?: number, weight?: number, age?: number, sex?: string, bmr_equation?: string): [math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]; +import * as math from "mathjs"; +//# sourceMappingURL=local_mbase.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/local_mbase.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/local_mbase.d.ts.map new file mode 100644 index 0000000..ba89491 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/local_mbase.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"local_mbase.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/local_mbase.js"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,qCARW,MAAM,WACN,MAAM,QACN,MAAM,QACN,MAAM,iBACN,MAAM,GAEJ,CAAC,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,CAAC,CAuChG;sBAlDqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/local_q_work.d.ts b/lib/esm/types/jos3_functions/thermoregulation/local_q_work.d.ts new file mode 100644 index 0000000..07268c6 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/local_q_work.d.ts @@ -0,0 +1,12 @@ +/** + * Calculate local thermogenesis by work [W]. + * + * @param {number} bmr - Basal metabolic rate [W] + * @param {number} par - Physical activity ratio [-] + * @throws {Error} If par is less than 1 + * + * @return {math.MathCollection} q_work - Local thermogenesis by work [W] + */ +export function local_q_work(bmr: number, par: number): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=local_q_work.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/local_q_work.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/local_q_work.d.ts.map new file mode 100644 index 0000000..5ea31d9 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/local_q_work.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"local_q_work.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/local_q_work.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,kCANW,MAAM,OACN,MAAM,GAGL,KAAK,cAAc,CAe9B;sBAxBqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/nonshivering.d.ts b/lib/esm/types/jos3_functions/thermoregulation/nonshivering.d.ts new file mode 100644 index 0000000..d5f5a15 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/nonshivering.d.ts @@ -0,0 +1,16 @@ +/** + * Calculate local metabolic rate by non-shivering [W] + * + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {boolean} [cold_acclimation=false] - Whether the subject acclimates cold environment or not. + * @param {boolean} [batpositive=true] - Whether BAT activity is positive or not. + * + * @returns {math.MathCollection} q_nst - Local metabolic rate by non-shivering [W]. + */ +export function nonshivering(err_sk: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, cold_acclimation?: boolean, batpositive?: boolean): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=nonshivering.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/nonshivering.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/nonshivering.d.ts.map new file mode 100644 index 0000000..2706da7 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/nonshivering.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nonshivering.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/nonshivering.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,qCAVW,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,qBACN,OAAO,gBACP,OAAO,GAEL,KAAK,cAAc,CA4D/B;sBAzEqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/operative_temp.d.ts b/lib/esm/types/jos3_functions/thermoregulation/operative_temp.d.ts new file mode 100644 index 0000000..37a05ad --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/operative_temp.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate operative temperature [°C] + * + * @param {math.MathCollection} tdb - Air temperature [°C] + * @param {math.MathCollection} tr - Mean radiant temperature [°C] + * @param {math.MathCollection} hc - Convective heat transfer coefficient [W/(m2*K)] + * @param {math.MathCollection} hr - Radiative heat transfer coefficient [W/(m2*K)] + + * @returns {math.MathCollection} Operative temperature [°C] + */ +export function operative_temp(tdb: math.MathCollection, tr: math.MathCollection, hc: math.MathCollection, hr: math.MathCollection): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=operative_temp.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/operative_temp.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/operative_temp.d.ts.map new file mode 100644 index 0000000..5da01a2 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/operative_temp.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"operative_temp.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/operative_temp.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,oCAPW,KAAK,cAAc,MACnB,KAAK,cAAc,MACnB,KAAK,cAAc,MACnB,KAAK,cAAc,GAEjB,KAAK,cAAc,CAO/B;sBAjBqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/rad_coef.d.ts b/lib/esm/types/jos3_functions/thermoregulation/rad_coef.d.ts new file mode 100644 index 0000000..a474d21 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/rad_coef.d.ts @@ -0,0 +1,10 @@ +/** + * Calculate radiative heat transfer coefficient (hr) [W/(m2*K)] + * + * @param {string} posture - Select posture from standing, sitting, lying, sedentary or supine. Default is "standing". + * + * @returns {math.Matrix} hr - Radiative heat transfer coefficient (hr) [W/(m2*K)]. + */ +export function rad_coef(posture?: string): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=rad_coef.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/rad_coef.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/rad_coef.d.ts.map new file mode 100644 index 0000000..f70836d --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/rad_coef.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"rad_coef.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/rad_coef.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,mCAJW,MAAM,GAEJ,KAAK,MAAM,CAsCvB;sBA7CqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts b/lib/esm/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts new file mode 100644 index 0000000..1b0beea --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts @@ -0,0 +1,27 @@ +/** + * @typedef RespHeatLossResult + * @type {object} + * @property {number} res_sh - Sensible heat loss by respiration [W]. + * @property {number} res_lh - Latent heat loss by respiration [W]. + */ +/** + * Calculate heat loss by respiration [W]. + * + * @param {number} tdb - Dry bulb air temperature [oC]. + * @param {number} p_a - Water vapor pressure in the ambient air [kPa]. + * @param {number} q_thermogenesis_total - Total thermogenesis [W]. + + * @return {RespHeatLossResult} res_sh, res_lh - Sensible and latent heat loss by respiration [W]. + */ +export function resp_heat_loss(tdb: number, p_a: number, q_thermogenesis_total: number): RespHeatLossResult; +export type RespHeatLossResult = { + /** + * - Sensible heat loss by respiration [W]. + */ + res_sh: number; + /** + * - Latent heat loss by respiration [W]. + */ + res_lh: number; +}; +//# sourceMappingURL=resp_heat_loss.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts.map new file mode 100644 index 0000000..ddb08a8 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/resp_heat_loss.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"resp_heat_loss.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/resp_heat_loss.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,oCANW,MAAM,OACN,MAAM,yBACN,MAAM,GAEL,kBAAkB,CAM7B;;;;;YAjBa,MAAM;;;;YACN,MAAM"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/shivering.d.ts b/lib/esm/types/jos3_functions/thermoregulation/shivering.d.ts new file mode 100644 index 0000000..f2354c0 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/shivering.d.ts @@ -0,0 +1,27 @@ +/** + * Sets the value of PRE_SHIV. + * + * @param {number} value - the value to set PRE_SHIV to + */ +export function set_pre_shiv(value: number): void; +/** + * Calculate local thermogenesis by shivering [W]. + * + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} t_core - Core and skin temperatures [°C]. + * @param {math.MathCollection} t_skin - Core and skin temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name (str) of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {string} [sex="male"] - Choose male or female. + * @param {number} [dtime=60] - Interval of analysis time. + * @param {object} options - Additional options. + * + * @returns {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + */ +export function shivering(err_cr: math.MathCollection, err_sk: math.MathCollection, t_core: math.MathCollection, t_skin: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, sex?: string, dtime?: number, options?: object): math.MathCollection; +export let PRE_SHIV: number; +import * as math from "mathjs"; +//# sourceMappingURL=shivering.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/shivering.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/shivering.d.ts.map new file mode 100644 index 0000000..4f77877 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/shivering.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"shivering.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/shivering.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,oCAFW,MAAM,QAIhB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,kCAdW,KAAK,cAAc,UACnB,KAAK,cAAc,UACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,QACN,MAAM,UACN,MAAM,YACN,MAAM,GAEJ,KAAK,cAAc,CA8F/B;AAxHD,4BAAwB;sBAFF,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts b/lib/esm/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts new file mode 100644 index 0000000..d2f3509 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts @@ -0,0 +1,15 @@ +/** + * Calculate skin blood flow rate (bf_skin) [L/h]. + * @param {math.MathCollection} err_cr - Difference between set-point and body temperatures [°C]. + * @param {math.MathCollection} err_sk - Difference between set-point and body temperatures [°C]. + * @param {number} [height=1.72] - Body height [m]. + * @param {number} [weight=74.43] - Body weight [kg]. + * @param {string} [bsa_equation="dubois"] - The equation name of bsa calculation. Choose a name from "dubois", "takahira", "fujimoto", or "kurazumi". + * @param {number} [age=20] - age [years]. + * @param {number} [ci=2.59] - Cardiac index [L/min/㎡]. + * + * @returns {math.MathCollection} bf_skin - Skin blood flow rate [L/h]. + */ +export function skin_blood_flow(err_cr: math.MathCollection, err_sk: math.MathCollection, height?: number, weight?: number, bsa_equation?: string, age?: number, ci?: number): math.MathCollection; +import * as math from "mathjs"; +//# sourceMappingURL=skin_blood_flow.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts.map new file mode 100644 index 0000000..96a5e4f --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/skin_blood_flow.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"skin_blood_flow.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/skin_blood_flow.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wCAVW,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,MAAM,WACN,MAAM,iBACN,MAAM,QACN,MAAM,OACN,MAAM,GAEJ,KAAK,cAAc,CA8D/B;sBA1EqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/sum_bf.d.ts b/lib/esm/types/jos3_functions/thermoregulation/sum_bf.d.ts new file mode 100644 index 0000000..fb3245b --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/sum_bf.d.ts @@ -0,0 +1,15 @@ +/** + * Sum the total blood flow in various body parts. + * + * @param {math.MathCollection} bf_core - Blood flow rate in the core region [L/h]. + * @param {math.MathCollection} bf_muscle - Blood flow rate in the muscle region [L/h]. + * @param {math.MathCollection} bf_fat - Blood flow rate in the fat region [L/h]. + * @param {math.MathCollection} bf_skin - Blood flow rate in the skin region [L/h]. + * @param {number} bf_ava_hand - AVA blood flow rate in one hand [L/h]. + * @param {number} bf_ava_foot - AVA blood flow rate in one foot [L/h]. + * + * @returns {number} co - Cardiac output (the sum of the whole blood flow rate) [L/h]. + */ +export function sum_bf(bf_core: math.MathCollection, bf_muscle: math.MathCollection, bf_fat: math.MathCollection, bf_skin: math.MathCollection, bf_ava_hand: number, bf_ava_foot: number): number; +import * as math from "mathjs"; +//# sourceMappingURL=sum_bf.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/sum_bf.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/sum_bf.d.ts.map new file mode 100644 index 0000000..cc3800e --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/sum_bf.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sum_bf.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/sum_bf.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,gCATW,KAAK,cAAc,aACnB,KAAK,cAAc,UACnB,KAAK,cAAc,WACnB,KAAK,cAAc,eACnB,MAAM,eACN,MAAM,GAEJ,MAAM,CAkBlB;sBA9BqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/sum_m.d.ts b/lib/esm/types/jos3_functions/thermoregulation/sum_m.d.ts new file mode 100644 index 0000000..7ef7ce5 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/sum_m.d.ts @@ -0,0 +1,39 @@ +/** + * @typedef SumMResult + * @type {object} + * @property {math.MathCollection} q_thermogenesis_core - Total thermogenesis in core layer [W]. + * @property {math.MathCollection} q_thermogenesis_muscle - Total thermogenesis in muscle layer [W]. + * @property {math.MathCollection} q_thermogenesis_fat - Total thermogenesis in fat layer [W]. + * @property {math.MathCollection} q_thermogenesis_skin - Total thermogenesis in skin layer [W]. + */ +/** + * Calculate total thermogenesis in each layer [W]. + * + * @param {[math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection]} mbase - Local basal metabolic rate (Mbase) [W]. + * @param {math.MathCollection} q_work - Local thermogenesis by work [W]. + * @param {math.MathCollection} q_shiv - Local thermogenesis by shivering [W]. + * @param {math.MathCollection} q_nst - Local thermogenesis by non-shivering [W]. + * + * @return {SumMResult} Total thermogenesis in core, muscle, fat, skin layers [W]. + */ +export function sum_m(mbase: [math.MathCollection, math.MathCollection, math.MathCollection, math.MathCollection], q_work: math.MathCollection, q_shiv: math.MathCollection, q_nst: math.MathCollection): SumMResult; +export type SumMResult = { + /** + * - Total thermogenesis in core layer [W]. + */ + q_thermogenesis_core: math.MathCollection; + /** + * - Total thermogenesis in muscle layer [W]. + */ + q_thermogenesis_muscle: math.MathCollection; + /** + * - Total thermogenesis in fat layer [W]. + */ + q_thermogenesis_fat: math.MathCollection; + /** + * - Total thermogenesis in skin layer [W]. + */ + q_thermogenesis_skin: math.MathCollection; +}; +import * as math from "mathjs"; +//# sourceMappingURL=sum_m.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/sum_m.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/sum_m.d.ts.map new file mode 100644 index 0000000..02abade --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/sum_m.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sum_m.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/sum_m.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AACH,6BAPW,CAAC,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,CAAC,UACpF,KAAK,cAAc,UACnB,KAAK,cAAc,SACnB,KAAK,cAAc,GAElB,UAAU,CAkCrB;;;;;0BAhDa,KAAK,cAAc;;;;4BACnB,KAAK,cAAc;;;;yBACnB,KAAK,cAAc;;;;0BACnB,KAAK,cAAc;;sBARX,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/wet_r.d.ts b/lib/esm/types/jos3_functions/thermoregulation/wet_r.d.ts new file mode 100644 index 0000000..6ac233d --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/wet_r.d.ts @@ -0,0 +1,13 @@ +/** + * Calculate total evaporative thermal resistance (between the skin and ambient air). + * + * @param {math.Matrix} hc - Convective heat transfer coefficient (hc) [W/(m2*K)]. + * @param {math.Matrix} clo - Clothing insulation [clo]. + * @param {number | math.Matrix} [i_clo=0.45] - Clothing vapor permeation efficiency [-]. + * @param {number} [lewis_rate=16.5] - Lewis rate [K/kPa]. + * + * @returns {math.Matrix} r_et - Total evaporative thermal resistance. + */ +export function wet_r(hc: math.Matrix, clo: math.Matrix, i_clo?: number | math.Matrix, lewis_rate?: number): math.Matrix; +import * as math from "mathjs"; +//# sourceMappingURL=wet_r.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/thermoregulation/wet_r.d.ts.map b/lib/esm/types/jos3_functions/thermoregulation/wet_r.d.ts.map new file mode 100644 index 0000000..2123463 --- /dev/null +++ b/lib/esm/types/jos3_functions/thermoregulation/wet_r.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wet_r.d.ts","sourceRoot":"","sources":["../../../../../src/jos3_functions/thermoregulation/wet_r.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,0BAPW,KAAK,MAAM,OACX,KAAK,MAAM,UACX,MAAM,GAAG,KAAK,MAAM,eACpB,MAAM,GAEJ,KAAK,MAAM,CAiBvB;sBA3BqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/validate_body_parameters.d.ts b/lib/esm/types/jos3_functions/validate_body_parameters.d.ts new file mode 100644 index 0000000..abd2fc0 --- /dev/null +++ b/lib/esm/types/jos3_functions/validate_body_parameters.d.ts @@ -0,0 +1,12 @@ +/** + * Validate the parameters: height, weight, age, and body fat percentage. + * + * @param {number} height - The height of the person in meters. + * @param {number} weight - The weight of the person in kilograms. + * @param {number} age - The age of the person in years. + * @param {number} body_fat - The body fat percentage as a fraction of total body mass. + + * @throws {Error} If any of the parameters are out of the specified range. + */ +export function validate_body_parameters(height?: number, weight?: number, age?: number, body_fat?: number): void; +//# sourceMappingURL=validate_body_parameters.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/validate_body_parameters.d.ts.map b/lib/esm/types/jos3_functions/validate_body_parameters.d.ts.map new file mode 100644 index 0000000..872c5c2 --- /dev/null +++ b/lib/esm/types/jos3_functions/validate_body_parameters.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"validate_body_parameters.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/validate_body_parameters.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,kDAPW,MAAM,WACN,MAAM,QACN,MAAM,aACN,MAAM,QAyBhB"} \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/weight_rate.d.ts b/lib/esm/types/jos3_functions/weight_rate.d.ts new file mode 100644 index 0000000..5f5f05c --- /dev/null +++ b/lib/esm/types/jos3_functions/weight_rate.d.ts @@ -0,0 +1,20 @@ +/** + * Calculate the ratio of the body weight to the standard body (74.43 kg). + * + * The standard values of local body weights are as as follows: + * weight_local = [ + * 3.18, 0.84, 12.4, 11.03, 17.57, + * 2.16, 1.37, 0.34, 2.16, 1.37, 0.34, + * 7.01, 3.34, 0.48, 7.01, 3.34, 0.48 + * ] + * + * The data have been derived from 65MN. + * The weight of neck is extracted from the weight of 65MN's head based on + * the local body surface area of Smith's model. + * + * @param {number} [weight=JOS3Defaults.weight] - The body weight [kg]. + * + * @returns {number} the ratio of the body weight to the standard body (74.43 kg). + */ +export function weight_rate(weight?: number): number; +//# sourceMappingURL=weight_rate.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/jos3_functions/weight_rate.d.ts.map b/lib/esm/types/jos3_functions/weight_rate.d.ts.map new file mode 100644 index 0000000..ec1714b --- /dev/null +++ b/lib/esm/types/jos3_functions/weight_rate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"weight_rate.d.ts","sourceRoot":"","sources":["../../../../src/jos3_functions/weight_rate.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,qCAJW,MAAM,GAEJ,MAAM,CAKlB"} \ No newline at end of file diff --git a/lib/esm/types/models/JOS3.d.ts b/lib/esm/types/models/JOS3.d.ts new file mode 100644 index 0000000..c4046c4 --- /dev/null +++ b/lib/esm/types/models/JOS3.d.ts @@ -0,0 +1,385 @@ +/** + * JOS-3 model simulates human thermal physiology including skin + * temperature, core temperature, sweating rate, etc. for the whole body and + * 17 local body parts. + * + * This model was developed at Shin-ichi Tanabe Laboratory, Waseda University + * and was derived from 65 Multi-Node model (https://doi.org/10.1016/S0378-7788(02)00014-2) + * and JOS-2 model (https://doi.org/10.1016/j.buildenv.2013.04.013). + * + * To use this model, create an instance of the JOS3 class with optional body parameters + * such as body height, weight, age, sex, etc. + * + * Environmental conditions such as air temperature, mean radiant temperature, air velocity, etc. + * can be set using the setter methods. (ex. X.tdb, X.tr X.v) + * If you want to set the different conditions in each body part, set them + * as a 17 lengths of list, dictionary, or numpy array format. + * + * List or numpy array format input must be 17 lengths and means the order of "head", "neck", "chest", + * "back", "pelvis", "left_shoulder", "left_arm", "left_hand", "right_shoulder", "right_arm", + * "right_hand", "left_thigh", "left_leg", "left_foot", "right_thigh", "right_leg" and "right_foot". + * + * The model output includes local and mean skin temperature, local core temperature, + * local and mean skin wettedness, and heat loss from the skin etc. + * The model output can be accessed using "dict_results()" method and be converted to a csv file + * using "to_csv" method. + * Each output parameter also can be accessed using getter methods. + * (ex. X.t_skin, X.t_skin_mean, X.t_core) + * + * If you use this package, please cite us as follows and mention the version of pythermalcomfort used: + * Y. Takahashi, A. Nomoto, S. Yoda, R. Hisayama, M. Ogata, Y. Ozeki, S. Tanabe, + * Thermoregulation Model JOS-3 with New Open Source Code, Energy & Buildings (2020), + * doi: https://doi.org/10.1016/j.enbuild.2020.110575 + * + * Note: To maintain consistency in variable names for jsthermalcomfort and pythermalcomfort, + * some variable names differ from those used in the original paper. + * + * @public + * @memberof models + * @docname JOS3 + */ +export class JOS3 { + /** + * Initialize a new instance of JOS3 class, which is designed to model + * and simulate various physiological parameters related to human + * thermoregulation. + * + * This class uses mathematical models to calculate and predict + * body temperature, basal metabolic rate, body surface area, and + * other related parameters. + * + * @param {number} [height] - body height, in [m]. + * @param {number} [weight] - body weight, in [kg]. + * @param {number} [fat] - fat percentage, in [%]. + * @param {number} [age] - age, in [years]. + * @param {"male" | "female"} [sex] - sex. + * @param {number} [ci] - Cardiac index, in [L/min/m2]. + * @param {"harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule"} [bmr_equation] - The equation used + * to calculate basal metabolic rate (BMR). + * @param {"dubois" | "fujimoto" | "kruazumi" | "takahira"} [bsa_equation] - The equation used to calculate body + * surface area (bsa). + * @param {[] | "all"} [ex_output] - This is used when you want to display results other than the default output + * parameters (ex.skin temperature); by default, JOS outputs only the most necessary parameters in order to reduce + * the computational load. + */ + constructor(height?: number, weight?: number, fat?: number, age?: number, sex?: "male" | "female", ci?: number, bmr_equation?: "harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule", bsa_equation?: "dubois" | "fujimoto" | "kruazumi" | "takahira", ex_output?: [] | "all"); + _height: number; + _weight: number; + _fat: number; + _age: number; + _sex: "male" | "female"; + _ci: number; + _bmr_equation: "harris-benedict" | "harris-benedict_origin" | "japanese" | "ganpule"; + _bsa_equation: "dubois" | "takahira" | "fujimoto" | "kruazumi"; + _ex_output: [] | "all"; + _bsa_rate: number; + _bsa: math.Matrix; + _bfb_rate: number; + _cdt: math.Matrix; + _cap: number[]; + setpt_cr: math.MathType; + setpt_sk: math.MathType; + _bodytemp: math.MathType; + _ta: math.MathType; + _tr: math.MathType; + _rh: math.MathType; + _va: math.MathType; + _clo: math.MathType; + _iclo: math.MathType; + _par: number; + _posture: string; + _hc: any; + _hr: any; + ex_q: math.MathCollection; + _t: number; + _cycle: number; + model_name: string; + options: { + nonshivering_thermogenesis: boolean; + cold_acclimated: boolean; + shivering_threshold: boolean; + "limit_dshiv/dt": boolean; + bat_positive: boolean; + ava_zero: boolean; + shivering: boolean; + }; + _history: any[]; + /** + * Calculate operative temperature [°C] when PMV=0. + * + * @private + * + * @param va {number} - Air velocity [m/s]. + * @param rh {number} - Relative humidity [%]. + * @param met {number} - Metabolic rate [met]. + * @param clo {number} - Clothing insulation [clo]. + * + * @returns {number} + */ + private _calculate_operative_temp_when_pmv_is_zero; + /** + * Reset set-point temperatures under steady state calculation. + * Set-point temperatures are hypothetical core or skin temperatures in a thermally neutral state + * when at rest (similar to room set-point temperature for air conditioning). + * This function is used during initialization to calculate the set-point temperatures as a reference for thermoregulation. + * Be careful, input parameters (tdb, tr, rh, v, clo, par) and body temperatures are also reset. + * + * @private + * + * @param par {number} - Physical activity ratio. + */ + private _reset_setpt; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set to(arg: math.Matrix); + /** + * Operative temperature [°C]. + * + * @return {math.Matrix} + */ + get to(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set rh(arg: math.Matrix); + /** + * Relative humidity [%]. + * + * @return {math.Matrix} + */ + get rh(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set v(arg: math.Matrix); + /** + * Air velocity [m/s]. + * + * @return {math.Matrix} + */ + get v(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set clo(arg: math.Matrix); + /** + * Clothing insulation [clo]. + * + * @return {math.Matrix} + */ + get clo(): math.Matrix; + /** + * @param inp {number} + */ + set par(arg: number); + /** + * Physical activity ratio [-].This equals the ratio of metabolic rate to basal metabolic rate. par of sitting quietly is 1.2. + * + * @return {number} + */ + get par(): number; + /** + * Run JOS-3 model. + * + * @property {number} times - Number of loops of a simulation. + * @property {number} [dtime=60] - Time delta in seconds. + * @property {boolean} [output=true] - If you don't want to record parameters, set False. + */ + simulate(times: any, dtime?: number, output?: boolean): void; + /** + * Runs the model once and gets the model parameters. + * + * The function then calculates several thermoregulation parameters using the input data, + * such as convective and radiative heat transfer coefficients, operative temperature, heat resistance, + * and blood flow rates. + * + * It also calculates the thermogenesis by shivering and non-shivering, basal thermogenesis, and thermogenesis by work. + * + * The function then calculates the total heat loss and gains, including respiratory, + * sweating, and extra heat gain, and builds the matrices required + * to solve for the new body temperature. + * + * It then calculates the new body temperature by solving the matrices using numpy's linalg library. + * + * Finally, the function returns a dictionary of the simulation results. + * The output parameters include cycle time, model time, t_skin_mean, t_skin, t_core, w_mean, w, weight_loss_by_evap_and_res, cardiac_output, q_thermogenesis_total, q_res, and q_skin_env. + * + * Additionally, if the _ex_output variable is set to "all" or is a list of keys, + * the function also returns a detailed dictionary of all the thermoregulation parameters + * and other variables used in the simulation. + * + * @private + * + * @param {number} dtime - Time delta [sec]. + * @param {boolean} passive - If you run a passive model. + * @param {boolean} output - If you don't need parameters. + * + * @returns {object} + */ + private _run; + /** + * Get results as a dictionary with the model values. + * + * @returns {object} + */ + dict_results(): object; + /** + * Set extra heat gain by tissue name. + * + * @private + * + * @param {string} tissue - Tissue name. "core", "skin", or "artery".... If you set value to head muscle and other segment's core, set "all_muscle". + * @param {number | math.MathCollection} value - Heat gain [W] + * + * @return {math.MathCollection} Extra heat gain of model. + */ + private _set_ex_q; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tdb(arg: math.Matrix); + /** + * Dry-bulb air temperature. + * + * @return {math.Matrix} + */ + get tdb(): math.Matrix; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set tr(arg: math.Matrix); + /** + * Mean radiant temperature [°C]. + * + * @return {math.Matrix} + */ + get tr(): math.Matrix; + /** + * @param inp {number | string} + */ + set posture(arg: string); + /** + * Current JOS3 posture. + * + * @return {string} + */ + get posture(): string; + /** + * @param inp {math.Matrix} + */ + set body_temp(arg: math.Matrix); + /** + * All segment temperatures of JOS-3. + * + * @return {math.Matrix} + */ + get body_temp(): math.Matrix; + /** + * Body surface areas by local body segments [m2]. + * + * @return {math.Matrix} + */ + get bsa(): math.Matrix; + /** + * Dry heat resistances between the skin and ambience areas by local body segments [(m2*K)/W]. + * + * @return {math.Matrix} + */ + get r_t(): math.Matrix; + /** + * w (Evaporative) heat resistances between the skin and ambience areas by local body segments [(m2*kPa)/W]. + * + * @return {math.Matrix} + */ + get r_et(): math.Matrix; + /** + * Skin wettedness on local body segments [-]. + * + * @return {math.Matrix} + */ + get w(): math.Matrix; + /** + * Mean skin wettedness of the whole body [-]. + * + * @return {number} + */ + get w_mean(): number; + /** + * Mean skin temperature of the whole body [°C]. + * + * @return {number} + */ + get t_skin_mean(): number; + /** + * @param inp {number | number[] | object | math.Matrix} + */ + set t_skin(arg: math.Matrix); + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_skin(): math.Matrix; + /** + * Skin temperatures by the local body segments [°C]. + * + * @returns {math.Matrix} + */ + get t_core(): math.Matrix; + /** + * Temperature at central blood pool [°C]. + * + * @return {number} + */ + get t_cb(): number; + /** + * Arterial temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_artery(): math.Matrix; + /** + * Vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_vein(): math.Matrix; + /** + * Superficial vein temperatures by the local body segments [°C]. + * + * @return {math.Matrix} + */ + get t_superficial_vein(): math.Matrix; + /** + * Muscle temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_muscle(): math.Matrix; + /** + * Fat temperatures of head and pelvis [°C]. + * + * @return {math.Matrix} + */ + get t_fat(): math.Matrix; + /** + * JOS3 body names + * + * @return {string[]} + */ + get body_names(): string[]; + /** + * Results of the model. + * + * @return {object} + */ + get results(): any; + /** + * Basal metabolic rate. + * @returns {number} + */ + get bmr(): number; +} +import * as math from "mathjs"; +//# sourceMappingURL=JOS3.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/models/JOS3.d.ts.map b/lib/esm/types/models/JOS3.d.ts.map new file mode 100644 index 0000000..666bf90 --- /dev/null +++ b/lib/esm/types/models/JOS3.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"JOS3.d.ts","sourceRoot":"","sources":["../../../../src/models/JOS3.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;IACE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,qBAdW,MAAM,WACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,GAAG,QAAQ,OACjB,MAAM,iBACN,iBAAiB,GAAG,wBAAwB,GAAG,UAAU,GAAG,SAAS,iBAErE,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,cAE/C,EAAE,GAAG,KAAK,EAmGpB;IAnFC,gBAAqB;IACrB,gBAAqB;IACrB,aAAe;IACf,aAAe;IACf,wBAAe;IACf,YAAa;IACb,qFAAiC;IACjC,+DAAiC;IACjC,uBAA2B;IAG3B,kBAAuD;IAGvD,kBAAmD;IAGnD,kBAAgE;IAGhE,kBAA0D;IAG1D,eAA2D;IAG3D,wBAA2E;IAC3E,wBAA2E;IAG3E,yBAGC;IAID,mBAGC;IACD,mBAGC;IACD,mBAAuE;IACvE,mBAA+D;IAC/D,oBAA0E;IAC1E,qBAGC;IACD,aAAgD;IAChD,iBAAoC;IACpC,SAAe;IACf,SAAe;IACf,0BAAiC;IACjC,WAAW;IACX,eAAe;IACf,mBAAwB;IACxB;;;;;;;;MAQC;IAMD,gBAAkB;IAWpB;;;;;;;;;;;OAWG;IACH,mDAuBC;IAED;;;;;;;;;;OAUG;IACH,qBA+BC;IAopBD;;OAEG;IACH,yBAGC;IAtBD;;;;OAIG;IACH,sBASC;IAmBD;;OAEG;IACH,yBAEC;IAdD;;;;OAIG;IACH,sBAEC;IAkBD;;OAEG;IACH,wBAEC;IAdD;;;;OAIG;IACH,qBAEC;IAkDD;;OAEG;IACH,0BAEC;IAdD;;;;OAIG;IACH,uBAEC;IAkBD;;OAEG;IACH,qBAEC;IAdD;;;;OAIG;IACH,kBAEC;IAjvBD;;;;;;OAMG;IACH,6DAiBC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,aA2dC;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAyDlB;IAED;;;;;;;;;OASG;IACH,kBAGC;IAWD;;OAEG;IACH,0BAEC;IAdD;;;;OAIG;IACH,uBAEC;IAkBD;;OAEG;IACH,yBAEC;IAdD;;;;OAIG;IACH,sBAEC;IA0ED;;OAEG;IACH,yBAkBC;IA9BD;;;;OAIG;IACH,sBAEC;IAkED;;OAEG;IACH,gCAEC;IAdD;;;;OAIG;IACH,6BAEC;IASD;;;;OAIG;IACH,uBAEC;IAED;;;;OAIG;IACH,uBASC;IAED;;;;OAIG;IACH,wBAOC;IAED;;;;OAIG;IACH,qBAgBC;IAED;;;;OAIG;IACH,qBAIC;IAED;;;;OAIG;IACH,0BASC;IAWD;;OAEG;IACH,6BAMC;IAlBD;;;;OAIG;IACH,0BAEC;IAaD;;;;OAIG;IACH,0BAEC;IAED;;;;OAIG;IACH,mBAEC;IAED;;;;OAIG;IACH,4BAEC;IAED;;;;OAIG;IACH,0BAEC;IAED;;;;OAIG;IACH,sCAEC;IAED;;;;OAIG;IACH,4BAEC;IAED;;;;OAIG;IACH,yBAEC;IAED;;;;OAIG;IACH,2BAEC;IAED;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,kBAUC;CACF;sBA3wCqB,QAAQ"} \ No newline at end of file diff --git a/lib/esm/types/models/index.d.ts b/lib/esm/types/models/index.d.ts index 2e89339..c846f76 100644 --- a/lib/esm/types/models/index.d.ts +++ b/lib/esm/types/models/index.d.ts @@ -1,78 +1,80 @@ declare namespace _default { - export { heat_index }; - export { phs }; - export { humidex }; - export { net }; - export { wbgt }; - export { clo_tout }; - export { clo_tout_array }; - export { discomfort_index }; - export { discomfort_index_array }; - export { two_nodes }; - export { two_nodes_array }; - export { wc }; + export { adaptive_ashrae }; + export { adaptive_ashrae_array }; export { adaptive_en }; export { adaptive_en_array }; + export { a_pmv }; + export { a_pmv_array }; + export { athb }; + export { athb_array }; + export { e_pmv }; + export { e_pmv_array }; export { at }; - export { vertical_tmp_grad_ppd }; - export { set_tmp }; - export { set_tmp_array }; - export { adaptive_ashrae }; - export { adaptive_ashrae_array }; - export { solar_gain }; + export { ankle_draft }; + export { clo_tout }; + export { clo_tout_array }; export { cooling_effect }; + export { discomfort_index }; + export { discomfort_index_array }; + export { heat_index }; + export { humidex }; + export { net }; + export { phs }; + export { pet_steady }; export { pmv_ppd }; export { pmv_ppd_array }; export { pmv }; export { pmv_array }; - export { athb }; - export { athb_array }; - export { a_pmv }; - export { a_pmv_array }; - export { ankle_draft }; - export { e_pmv }; - export { e_pmv_array }; - export { use_fans_heatwaves }; + export { solar_gain }; + export { set_tmp }; + export { set_tmp_array }; + export { two_nodes }; + export { two_nodes_array }; export { utci }; export { utci_array }; - export { pet_steady }; + export { use_fans_heatwaves }; + export { vertical_tmp_grad_ppd }; + export { wbgt }; + export { wc }; + export { JOS3 }; } export default _default; -import { heat_index } from "./heat_index.js"; -import { phs } from "./phs.js"; -import { humidex } from "./humidex.js"; -import { net } from "./net.js"; -import { wbgt } from "./wbgt.js"; -import { clo_tout } from "./clo_tout.js"; -import { clo_tout_array } from "./clo_tout.js"; -import { discomfort_index } from "./discomfort_index.js"; -import { discomfort_index_array } from "./discomfort_index.js"; -import { two_nodes } from "./two_nodes.js"; -import { two_nodes_array } from "./two_nodes.js"; -import { wc } from "./wc.js"; +import { adaptive_ashrae } from "./adaptive_ashrae.js"; +import { adaptive_ashrae_array } from "./adaptive_ashrae.js"; import { adaptive_en } from "./adaptive_en.js"; import { adaptive_en_array } from "./adaptive_en.js"; +import { a_pmv } from "./a_pmv.js"; +import { a_pmv_array } from "./a_pmv.js"; +import { athb } from "./athb.js"; +import { athb_array } from "./athb.js"; +import { e_pmv } from "./e_pmv.js"; +import { e_pmv_array } from "./e_pmv.js"; import { at } from "./at.js"; -import { vertical_tmp_grad_ppd } from "./vertical_tmp_grad_ppd.js"; -import { set_tmp } from "./set_tmp.js"; -import { set_tmp_array } from "./set_tmp.js"; -import { adaptive_ashrae } from "./adaptive_ashrae.js"; -import { adaptive_ashrae_array } from "./adaptive_ashrae.js"; -import { solar_gain } from "./solar_gain.js"; +import { ankle_draft } from "./ankle_draft.js"; +import { clo_tout } from "./clo_tout.js"; +import { clo_tout_array } from "./clo_tout.js"; import { cooling_effect } from "./cooling_effect.js"; +import { discomfort_index } from "./discomfort_index.js"; +import { discomfort_index_array } from "./discomfort_index.js"; +import { heat_index } from "./heat_index.js"; +import { humidex } from "./humidex.js"; +import { net } from "./net.js"; +import { phs } from "./phs.js"; +import { pet_steady } from "./pet_steady.js"; import { pmv_ppd } from "./pmv_ppd.js"; import { pmv_ppd_array } from "./pmv_ppd.js"; import { pmv } from "./pmv.js"; import { pmv_array } from "./pmv.js"; -import { athb } from "./athb.js"; -import { athb_array } from "./athb.js"; -import { a_pmv } from "./a_pmv.js"; -import { a_pmv_array } from "./a_pmv.js"; -import { ankle_draft } from "./ankle_draft.js"; -import { e_pmv } from "./e_pmv.js"; -import { e_pmv_array } from "./e_pmv.js"; -import { use_fans_heatwaves } from "./use_fans_heatwave.js"; +import { solar_gain } from "./solar_gain.js"; +import { set_tmp } from "./set_tmp.js"; +import { set_tmp_array } from "./set_tmp.js"; +import { two_nodes } from "./two_nodes.js"; +import { two_nodes_array } from "./two_nodes.js"; import { utci } from "./utci.js"; import { utci_array } from "./utci.js"; -import { pet_steady } from "./pet_steady.js"; +import { use_fans_heatwaves } from "./use_fans_heatwave.js"; +import { vertical_tmp_grad_ppd } from "./vertical_tmp_grad_ppd.js"; +import { wbgt } from "./wbgt.js"; +import { wc } from "./wc.js"; +import { JOS3 } from "./JOS3.js"; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/models/index.d.ts.map b/lib/esm/types/models/index.d.ts.map index 6deff00..4a5383d 100644 --- a/lib/esm/types/models/index.d.ts.map +++ b/lib/esm/types/models/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAA2B,iBAAiB;oBACxB,UAAU;wBACN,cAAc;oBAClB,UAAU;qBACT,WAAW;yBAqBS,eAAe;+BAAf,eAAe;iCAjBjD,uBAAuB;uCAAvB,uBAAuB;0BACa,gBAAgB;gCAAhB,gBAAgB;mBAExC,SAAS;4BACmB,kBAAkB;kCAAlB,kBAAkB;mBAC9C,SAAS;sCAUU,4BAA4B;wBAb3B,cAAc;8BAAd,cAAc;gCAKE,sBAAsB;sCAAtB,sBAAsB;2BAClD,iBAAiB;+BACb,qBAAqB;wBAHb,cAAc;8BAAd,cAAc;oBAKtB,UAAU;0BAAV,UAAU;qBADR,WAAW;2BAAX,WAAW;sBAET,YAAY;4BAAZ,YAAY;4BACnB,kBAAkB;sBACX,YAAY;4BAAZ,YAAY;mCAEZ,wBAAwB;qBAE1B,WAAW;2BAAX,WAAW;2BACjB,iBAAiB"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAeuD,sBAAsB;sCAAtB,sBAAsB;4BAH9B,kBAAkB;kCAAlB,kBAAkB;sBAQ9B,YAAY;4BAAZ,YAAY;qBAFd,WAAW;2BAAX,WAAW;sBAIT,YAAY;4BAAZ,YAAY;mBAT5B,SAAS;4BAQA,kBAAkB;yBAIL,eAAe;+BAAf,eAAe;+BARzB,qBAAqB;iCAT7C,uBAAuB;uCAAvB,uBAAuB;2BARH,iBAAiB;wBAEpB,cAAc;oBAClB,UAAU;oBAFV,UAAU;2BA0BH,iBAAiB;wBAbL,cAAc;8BAAd,cAAc;oBAKtB,UAAU;0BAAV,UAAU;2BAHd,iBAAiB;wBANL,cAAc;8BAAd,cAAc;0BADV,gBAAgB;gCAAhB,gBAAgB;qBAiB1B,WAAW;2BAAX,WAAW;mCAFT,wBAAwB;sCADrB,4BAA4B;qBAnB7C,WAAW;mBAOb,SAAS;qBAiBP,WAAW"} \ No newline at end of file diff --git a/lib/esm/types/supa.d.ts b/lib/esm/types/supa.d.ts new file mode 100644 index 0000000..913f5b6 --- /dev/null +++ b/lib/esm/types/supa.d.ts @@ -0,0 +1,25 @@ +export function $map(arrays: any, op: any): any[]; +/** + * @template T + * @param {number} length + * @param {T} value + * + * @return {T[]} + */ +export function $array(length: number, value: T): T[]; +/** + * @template T + * @param arrays {T[][]} + * @param op {(reduced: T, items: T[]) => T} + * @param initial {T} + * + * @return {T} + */ +export function $reduce(arrays: T[][], op: (reduced: T, items: T[]) => T, initial: T): T; +export function $average(array: any, weights: any): number; +export function $lerp(length: any, min: any, max: any): any[]; +export function $sum(array: any): any; +export function $max(array: any, sentinel: any): any; +export function $min(array: any, sentinel: any): any; +export function $index(array: any, indicies: any): any; +//# sourceMappingURL=supa.d.ts.map \ No newline at end of file diff --git a/lib/esm/types/supa.d.ts.map b/lib/esm/types/supa.d.ts.map new file mode 100644 index 0000000..a8f38ce --- /dev/null +++ b/lib/esm/types/supa.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"supa.d.ts","sourceRoot":"","sources":["../../../src/supa.js"],"names":[],"mappings":"AAAA,kDAeC;AAED;;;;;;GAMG;AACH,kCALW,MAAM,iBAOhB;AAED;;;;;;;GAOG;AACH,4FAeC;AAED,2DAQC;AAED,8DAIC;AAED,sCAEC;AAED,qDAEC;AAED,qDAEC;AAED,uDAEC"} \ No newline at end of file