Skip to content

Commit

Permalink
Merge pull request #120 from FedericoTartarini/sz/fix
Browse files Browse the repository at this point in the history
Use .js for all imports
  • Loading branch information
szaldivar authored Nov 4, 2023
2 parents f60ea23 + 58d1674 commit 241917b
Show file tree
Hide file tree
Showing 39 changed files with 327 additions and 176 deletions.
176 changes: 88 additions & 88 deletions docs/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/cjs/models/clo_tout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.clo_tout_array = exports.clo_tout = void 0;
const utilities_1 = require("../utilities/utilities");
const utilities_js_1 = require("../utilities/utilities.js");
/**
* Representative clothing insulation Icl as a function of outdoor air
* temperature at 06:00 a.m {@link #ref_4|[4]}.
Expand All @@ -24,11 +24,11 @@ const utilities_1 = require("../utilities/utilities");
* @returns {number} Representative clothing insulation Icl, [clo]
*/
function clo_tout(tout, units = "SI") {
const t = units === "IP" ? (0, utilities_1.units_converter)({ tmp: tout }).tmp : tout;
const t = units === "IP" ? (0, utilities_js_1.units_converter)({ tmp: tout }).tmp : tout;
let clo = t < 26 ? Math.pow(10, (-0.1635 - 0.0066 * t)) : 0.46;
clo = t < 5 ? 0.818 - 0.0364 * t : clo;
clo = t < -5 ? 1 : clo;
return (0, utilities_1.round)(clo, 2);
return (0, utilities_js_1.round)(clo, 2);
}
exports.clo_tout = clo_tout;
/**
Expand Down
4 changes: 2 additions & 2 deletions lib/cjs/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const pmv_js_1 = require("./pmv.js");
const a_pmv_js_1 = require("./a_pmv.js");
const ankle_draft_js_1 = require("./ankle_draft.js");
const e_pmv_js_1 = require("./e_pmv.js");
const vertical_tmp_grad_ppd_1 = require("./vertical_tmp_grad_ppd");
const vertical_tmp_grad_ppd_js_1 = require("./vertical_tmp_grad_ppd.js");
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");
Expand All @@ -46,7 +46,7 @@ exports.default = {
adaptive_en: adaptive_en_js_1.adaptive_en,
adaptive_en_array: adaptive_en_js_1.adaptive_en_array,
at: at_js_1.at,
vertical_tmp_grad_ppd: vertical_tmp_grad_ppd_1.vertical_tmp_grad_ppd,
vertical_tmp_grad_ppd: vertical_tmp_grad_ppd_js_1.vertical_tmp_grad_ppd,
set_tmp: set_tmp_js_1.set_tmp,
set_tmp_array: set_tmp_js_1.set_tmp_array,
adaptive_ashrae: adaptive_ashrae_js_1.adaptive_ashrae,
Expand Down
2 changes: 1 addition & 1 deletion lib/cjs/types/models/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { wc } from "./wc.js";
import { adaptive_en } from "./adaptive_en.js";
import { adaptive_en_array } from "./adaptive_en.js";
import { at } from "./at.js";
import { vertical_tmp_grad_ppd } from "./vertical_tmp_grad_ppd";
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";
Expand Down
2 changes: 1 addition & 1 deletion lib/cjs/types/models/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/esm/models/clo_tout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { units_converter, round } from "../utilities/utilities";
import { units_converter, round } from "../utilities/utilities.js";
/**
* Representative clothing insulation Icl as a function of outdoor air
* temperature at 06:00 a.m {@link #ref_4|[4]}.
Expand Down
2 changes: 1 addition & 1 deletion lib/esm/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { pmv, pmv_array } from "./pmv.js";
import { a_pmv, a_pmv_array } from "./a_pmv.js";
import { ankle_draft } from "./ankle_draft.js";
import { e_pmv, e_pmv_array } from "./e_pmv.js";
import { vertical_tmp_grad_ppd } from "./vertical_tmp_grad_ppd";
import { vertical_tmp_grad_ppd } from "./vertical_tmp_grad_ppd.js";
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";
Expand Down
91 changes: 91 additions & 0 deletions lib/esm/models/vertical_tmp_grad_ppd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { round, check_standard_compliance, units_converter, } from "../utilities/utilities.js";
import { pmv } from "../models/pmv.js";
/**
* @typedef {Object} VerTmpGradReturnType - a result set containing the predicted precentage of dissatisfied and the acceptability
* @property {number} PPD_vg Predicted Percentage of Dissatisfied occupants with vertical temperature gradient, [%]
* @property {boolean} Acceptability The ASHRAE 55 2020 standard defines that the value of air speed at the ankle level
* is acceptable if PPD_ad is lower or equal than 5 %
* @public
*/
/**
* Calculates the percentage of thermally dissatisfied people with a vertical temperature gradient between feet and head {@link #ref_1|[1]} .
* This equation is only applicable for vr < 0.2 m/s (40 fps).
*
* @public
* @memberof models
* @docname Vertical air temperature gradient
*
* @param {number} tdb dry bulb air temperature, default in [°C] in [°F] if "units" = 'IP'.
*
* Note: The air temperature is the average value over two heights: 0.6 m (24 in.) and 1.1 m (43 in.) for seated occupants and 1.1 m
* (43 in.) and 1.7 m (67 in.) for standing occupants.
* @param {number} tr mean radiant temperature, default in [°C] in [°F] if "units" = 'IP'.
* @param {number} vr relative air speed, default in [m/s] in [fps] if "units" = "IP"
*
* Note: vr is the relative air speed caused by body movement and not the air speed measured by the air speed sensor.
* The relative air speed is the sum of the average air speed measured by the sensor plus the activity-generated air speed (Vag).
* Where Vag is the activity-generated air speed caused by motion of individual body parts. vr can be calculated using the function
* pythermalcomfort.utilities.v_relative().
* @param {number} rh relative humidity, [%].
* @param {number} met metabolic rate, [met]
* @param {number} clo clothing insulation, [clo]
*
* Note: The activity as well as the air speed modify the insulation characteristics of the clothing and the adjacent air layer.
* Consequently the ISO 7730 states that the clothing insulation shall be corrected {@link #ref_2|[2]}. The ASHRAE 55 Standard corrects for the effect of
* the body movement for met equal or higher than 1.2 met using the equation clo = Icl × (0.6 + 0.4/met) The dynamic clothing insulation,
* clo, can be calculated using the function pythermalcomfort.utilities.clo_dynamic().
* @param {number} vertical_tmp_grad vertical temperature gradient between the feet and the head, default in [°C/m] in [°F/ft] if units = ‘IP’
* @param {"SI" | "IP"} [units="SI"] - select the SI (International System of Units) or the IP (Imperial Units) system.
*
* @returns {VerTmpGradReturnType} Object with results of the PPD with vertical temprature gradient.
*
* @example
* const result = vertical_tmp_grad_ppd(25, 25, 0.1, 50, 1.2, 0.5, 7); // returns {'PPD_vg': 12.6, 'Acceptability': false}
*/
export function vertical_tmp_grad_ppd(tdb, tr, vr, rh, met, clo, vertical_tmp_grad, units = "SI") {
if (units === "IP") {
({
tdb: tdb,
tr: tr,
vr: vr,
} = units_converter({ tdb: tdb, tr: tr, vr: vr }, "IP"));
vertical_tmp_grad = (vertical_tmp_grad / 1.8) * 3.28;
}
const warnings = check_standard_compliance("ASHRAE", {
tdb: tdb,
tr: tr,
v_limited: vr,
rh: rh,
met: met,
clo: clo,
});
warnings.forEach((warning) => console.warn(warning));
const tsv = pmv(tdb, tr, vr, rh, met, clo, 0, "ASHRAE");
const ppd_vg = calculate_ppd_vg(tsv, vertical_tmp_grad);
const acceptability = check_acceptability(ppd_vg);
return {
PPD_vg: ppd_vg,
Acceptability: acceptability,
};
}
/**
* Calculate Predicted Percentage of Dissatisfied (PPD) based on tsv and vertical temperature gradient.
*
* @param {number} tsv - PMV in ashrae standard
* @param {number} vertical_tmp_grad - Vertical temperature gradient between the feet and the head
* @returns {number} Predicted Percentage of Dissatisfied occupants with vertical temperature gradient
*/
function calculate_ppd_vg(tsv, vertical_tmp_grad) {
const numerator = Math.exp(0.13 * (tsv - 1.91) ** 2 + 0.15 * vertical_tmp_grad - 1.6);
const ppd_vg = round((numerator / (1 + numerator) - 0.345) * 100, 1);
return ppd_vg;
}
/**
* Check the acceptability based on ppd_vg
*
* @param {number} ppd_vg - PPD based on Vertical temperature gradient
* @returns {boolean} Acceptability
*/
function check_acceptability(ppd_vg) {
return ppd_vg <= 5;
}
1 change: 1 addition & 0 deletions lib/esm/types/models/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { wc } from "./wc.js";
import { adaptive_en } from "./adaptive_en.js";
import { adaptive_en_array } from "./adaptive_en.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";
Expand Down
2 changes: 1 addition & 1 deletion lib/esm/types/models/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions lib/esm/types/models/vertical_tmp_grad_ppd.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @typedef {Object} VerTmpGradReturnType - a result set containing the predicted precentage of dissatisfied and the acceptability
* @property {number} PPD_vg Predicted Percentage of Dissatisfied occupants with vertical temperature gradient, [%]
* @property {boolean} Acceptability The ASHRAE 55 2020 standard defines that the value of air speed at the ankle level
* is acceptable if PPD_ad is lower or equal than 5 %
* @public
*/
/**
* Calculates the percentage of thermally dissatisfied people with a vertical temperature gradient between feet and head {@link #ref_1|[1]} .
* This equation is only applicable for vr < 0.2 m/s (40 fps).
*
* @public
* @memberof models
* @docname Vertical air temperature gradient
*
* @param {number} tdb dry bulb air temperature, default in [°C] in [°F] if "units" = 'IP'.
*
* Note: The air temperature is the average value over two heights: 0.6 m (24 in.) and 1.1 m (43 in.) for seated occupants and 1.1 m
* (43 in.) and 1.7 m (67 in.) for standing occupants.
* @param {number} tr mean radiant temperature, default in [°C] in [°F] if "units" = 'IP'.
* @param {number} vr relative air speed, default in [m/s] in [fps] if "units" = "IP"
*
* Note: vr is the relative air speed caused by body movement and not the air speed measured by the air speed sensor.
* The relative air speed is the sum of the average air speed measured by the sensor plus the activity-generated air speed (Vag).
* Where Vag is the activity-generated air speed caused by motion of individual body parts. vr can be calculated using the function
* pythermalcomfort.utilities.v_relative().
* @param {number} rh relative humidity, [%].
* @param {number} met metabolic rate, [met]
* @param {number} clo clothing insulation, [clo]
*
* Note: The activity as well as the air speed modify the insulation characteristics of the clothing and the adjacent air layer.
* Consequently the ISO 7730 states that the clothing insulation shall be corrected {@link #ref_2|[2]}. The ASHRAE 55 Standard corrects for the effect of
* the body movement for met equal or higher than 1.2 met using the equation clo = Icl × (0.6 + 0.4/met) The dynamic clothing insulation,
* clo, can be calculated using the function pythermalcomfort.utilities.clo_dynamic().
* @param {number} vertical_tmp_grad vertical temperature gradient between the feet and the head, default in [°C/m] in [°F/ft] if units = ‘IP’
* @param {"SI" | "IP"} [units="SI"] - select the SI (International System of Units) or the IP (Imperial Units) system.
*
* @returns {VerTmpGradReturnType} Object with results of the PPD with vertical temprature gradient.
*
* @example
* const result = vertical_tmp_grad_ppd(25, 25, 0.1, 50, 1.2, 0.5, 7); // returns {'PPD_vg': 12.6, 'Acceptability': false}
*/
export function vertical_tmp_grad_ppd(tdb: number, tr: number, vr: number, rh: number, met: number, clo: number, vertical_tmp_grad: number, units?: "SI" | "IP"): VerTmpGradReturnType;
/**
* - a result set containing the predicted precentage of dissatisfied and the acceptability
*/
export type VerTmpGradReturnType = {
/**
* Predicted Percentage of Dissatisfied occupants with vertical temperature gradient, [%]
*/
PPD_vg: number;
/**
* The ASHRAE 55 2020 standard defines that the value of air speed at the ankle level
* is acceptable if PPD_ad is lower or equal than 5 %
*/
Acceptability: boolean;
};
//# sourceMappingURL=vertical_tmp_grad_ppd.d.ts.map
1 change: 1 addition & 0 deletions lib/esm/types/models/vertical_tmp_grad_ppd.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/jos3_functions/bfb_rate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JOS3Defaults from "./JOS3Defaults";
import { bsa_rate } from "./bsa_rate";
import { validate_body_parameters } from "./validate_body_parameters";
import JOS3Defaults from "./JOS3Defaults.js";
import { bsa_rate } from "./bsa_rate.js";
import { validate_body_parameters } from "./validate_body_parameters.js";

/**
* Calculate the ratio of basal blood flow (BFB) of the standard body (290 L/h).
Expand Down
6 changes: 3 additions & 3 deletions src/jos3_functions/bsa_rate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JOS3Defaults from "../jos3_functions/JOS3Defaults";
import { validate_body_parameters } from "./validate_body_parameters";
import { body_surface_area } from "../utilities/utilities";
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
Expand Down
10 changes: 5 additions & 5 deletions src/jos3_functions/capacity.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import JOS3Defaults from "./JOS3Defaults";
import { validate_body_parameters } from "./validate_body_parameters";
import { bfb_rate } from "./bfb_rate";
import { weight_rate } from "./weight_rate";
import { NUM_NODES, BODY_NAMES, IDICT } from "./matrix";
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).
Expand Down
10 changes: 5 additions & 5 deletions src/jos3_functions/conductance.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import JOS3Defaults from "./JOS3Defaults";
import { validate_body_parameters } from "./validate_body_parameters";
import { weight_rate } from "./weight_rate";
import { bsa_rate } from "./bsa_rate";
import { NUM_NODES, BODY_NAMES, IDICT } from "./matrix";
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";

function maprange(array, from, to, op) {
return array.map((x, i) => (i >= from && i < to ? op(x) : x));
Expand Down
6 changes: 3 additions & 3 deletions src/jos3_functions/local_bsa.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JOS3Defaults from "./JOS3Defaults";
import { validate_body_parameters } from "./validate_body_parameters";
import { bsa_rate } from "./bsa_rate";
import JOS3Defaults from "./JOS3Defaults.js";
import { validate_body_parameters } from "./validate_body_parameters.js";
import { bsa_rate } from "./bsa_rate.js";

/**
* Calculate local body surface area (bsa) [m2].
Expand Down
6 changes: 3 additions & 3 deletions src/jos3_functions/thermoregulation/ava_blood_flow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { $average } from "../../supa";
import JOS3Defaults from "../JOS3Defaults";
import { bfb_rate } from "../bfb_rate";
import { $average } from "../../supa.js";
import JOS3Defaults from "../JOS3Defaults.js";
import { bfb_rate } from "../bfb_rate.js";

/**
* Calculate areteriovenous anastmoses (AVA) blood flow rate [L/h] based on
Expand Down
2 changes: 1 addition & 1 deletion src/jos3_functions/thermoregulation/basal_met.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JOS3Defaults from "../JOS3Defaults";
import JOS3Defaults from "../JOS3Defaults.js";

/**
* Calculate basal metabolic rate [W].
Expand Down
4 changes: 2 additions & 2 deletions src/jos3_functions/thermoregulation/conv_coef.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JOS3Defaults from "../JOS3Defaults";
import { $map, $array } from "../../supa";
import JOS3Defaults from "../JOS3Defaults.js";
import { $map, $array } from "../../supa.js";

/**
* Calculate convective heat transfer coefficient (hc) [W/(m2*K)]
Expand Down
6 changes: 3 additions & 3 deletions src/jos3_functions/thermoregulation/cr_ms_fat_blood_flow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JOS3Defaults from "../JOS3Defaults";
import { bfb_rate } from "../bfb_rate";
import { BODY_NAMES, IDICT } from "../matrix";
import JOS3Defaults from "../JOS3Defaults.js";
import { bfb_rate } from "../bfb_rate.js";
import { BODY_NAMES, IDICT } from "../matrix.js";

/**
* Calculate core, muscle and fat blood flow rate [L/h].
Expand Down
4 changes: 2 additions & 2 deletions src/jos3_functions/thermoregulation/dry_r.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $map } from "../../supa";
import { clo_area_factor } from "./clo_area_factor";
import { $map } from "../../supa.js";
import { clo_area_factor } from "./clo_area_factor.js";

/**
* Calculate total sensible thermal resistance (between the skin and ambient air).
Expand Down
2 changes: 1 addition & 1 deletion src/jos3_functions/thermoregulation/error_signals.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $array, $map, $max, $min, $sum } from "../../supa";
import { $array, $map, $max, $min, $sum } from "../../supa.js";

/**
* Calculate WRMS and CLDS signals of thermoregulation.
Expand Down
8 changes: 4 additions & 4 deletions src/jos3_functions/thermoregulation/evaporation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import JOS3Defaults from "../JOS3Defaults";
import { error_signals } from "./error_signals";
import { bsa_rate } from "../bsa_rate";
import { $map, $max, $min, $array } from "../../supa";
import JOS3Defaults from "../JOS3Defaults.js";
import { error_signals } from "./error_signals.js";
import { bsa_rate } from "../bsa_rate.js";
import { $map, $max, $min, $array } from "../../supa.js";

export const antoine = (x) => Math.E ** (16.6536 - 4030.183 / (x + 235));

Expand Down
4 changes: 2 additions & 2 deletions src/jos3_functions/thermoregulation/fixed_hc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $average, $reduce } from "../../supa";
import JOS3Defaults from "../JOS3Defaults";
import { $average, $reduce } from "../../supa.js";
import JOS3Defaults from "../JOS3Defaults.js";

/**
* Fixes hc values to fit two-node-model's values.
Expand Down
4 changes: 2 additions & 2 deletions src/jos3_functions/thermoregulation/fixed_hr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $average } from "../../supa";
import JOS3Defaults from "../JOS3Defaults";
import { $average } from "../../supa.js";
import JOS3Defaults from "../JOS3Defaults.js";

/**
* Fixes hr values to fit two-node-model's values.
Expand Down
4 changes: 2 additions & 2 deletions src/jos3_functions/thermoregulation/local_mbase.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JOS3Defaults from "../JOS3Defaults";
import { basal_met } from "./basal_met";
import JOS3Defaults from "../JOS3Defaults.js";
import { basal_met } from "./basal_met.js";

/**
* Calculate local basal metabolic rate [W].
Expand Down
Loading

0 comments on commit 241917b

Please sign in to comment.