Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion static/js/ASHRAE/ashrae.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const vRelativeValue = $("#relative-air-speed-value");
const vRelativeDiv = $("#relative-air-speed-div");
const dynamicCloValue = $("#dynamic-clo-value");
const dynamicCloDiv = $("#dynamic-clo-div");
const useRelativeAirSpeedCheckbox = $("#use-relative-air-speed");

$(document).ready(function () {
comf.useSelfGeneratedAirSpeed = useRelativeAirSpeedCheckbox.is(":checked");
highlightNabBarItem("#nav_a_ashrae");

dropdownsCloMet();
Expand Down Expand Up @@ -69,10 +71,31 @@ $(document).ready(function () {
handleClickToCheckBox();
});

useRelativeAirSpeedCheckbox.change(function () {
comf.useSelfGeneratedAirSpeed = $(this).prop("checked");
update();
});

$("#chartSelect").val("psychtop").change();
});

$(function () {
$("#airSpeedDialog").dialog({
autoOpen: false,
width: 380,
modal: true,
resizable: false,
buttons: {
Close: function () {
$(this).dialog("close");
},
},
});

$("#airSpeedSettings").click(function () {
$("#airSpeedDialog").dialog("open");
});

$("#globedialog").dialog({
autoOpen: false,
height: 350,
Expand Down Expand Up @@ -524,7 +547,7 @@ function update() {
d.rh = psy.convert(d.rh, d.ta, window.humUnit, "rh");

// calculate and display relative air speed
if (d.met > 1) {
if (d.met > 1 && comf.useSelfGeneratedAirSpeed) {
vRelativeDiv.show();
if (isCelsius) {
vRelativeValue.html(comf.relativeAirSpeed(d.vel, d.met).toFixed(2));
Expand Down
25 changes: 24 additions & 1 deletion static/js/EN/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ keys = ["ta", "tr", "vel", "rh", "met", "clo", "trm", "vel_a"];

const vRelativeValue = $("#relative-air-speed-value");
const vRelativeDiv = $("#relative-air-speed-div");
const useRelativeAirSpeedCheckbox = $("#use-relative-air-speed");

$(document).ready(function () {
comf.useSelfGeneratedAirSpeed = useRelativeAirSpeedCheckbox.is(":checked");
highlightNabBarItem("#nav_a_en");

dropdownsCloMet();
Expand Down Expand Up @@ -50,6 +52,22 @@ $(document).ready(function () {
});

$(function () {
$("#airSpeedDialog").dialog({
autoOpen: false,
width: 380,
modal: true,
resizable: false,
buttons: {
Close: function () {
$(this).dialog("close");
},
},
});

$("#airSpeedSettings").click(function () {
$("#airSpeedDialog").dialog("open");
});

$("#globedialog").dialog({
autoOpen: false,
height: 350,
Expand Down Expand Up @@ -140,6 +158,11 @@ $("#vel-a-box").click(function () {
update();
});

$("#use-relative-air-speed").change(function () {
comf.useSelfGeneratedAirSpeed = $(this).prop("checked");
update();
});

$("#unitsToggle").click(function () {
toggleUnits();
update();
Expand Down Expand Up @@ -320,7 +343,7 @@ function update() {
}

// calculate and display relative air speed
if (d.met > 1) {
if (d.met > 1 && comf.useSelfGeneratedAirSpeed) {
vRelativeDiv.show();
if (isCelsius) {
vRelativeValue.html(comf.relativeAirSpeed(d.vel, d.met).toFixed(2));
Expand Down
4 changes: 3 additions & 1 deletion static/js/comfort-models.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ if (typeof module !== "undefined" && module.exports) {
module.exports.comf = comf;
}

comf.useSelfGeneratedAirSpeed = true;

comf.relativeAirSpeed = function (v, met) {
if (met > 1) {
if (comf.useSelfGeneratedAirSpeed && met > 1) {
return v + 0.3 * (met - 1);
} else {
return v;
Expand Down
75 changes: 75 additions & 0 deletions static/js/compare/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $(document).ready(function () {
});
$("#temphumchart-div").hide();

comf.useSelfGeneratedAirSpeed = $("#use-relative-air-speed").is(":checked");
window.isCelsius = true;
window.humUnit = "rh";

Expand Down Expand Up @@ -68,6 +69,7 @@ $(function () {
d3.selectAll("path.comfortzone1").remove();
d3.selectAll("circle.point1").remove();
}
updateVrRowVisibility();
});
$("#inputs2")
.button({})
Expand All @@ -89,11 +91,20 @@ $(function () {
r = comf.pmvElevatedAirspeed(d.ta, d.tr, d.vel, d.rh, d.met, d.clo, 0);
renderPmvElevResults(r, "2");
calcPmvElevCompliance(d, r, "2");
if (comf.useSelfGeneratedAirSpeed && d.met > 1) {
const vr2 = comf.relativeAirSpeed(d.vel, d.met);
$("#vr-res2").html(isCelsius ? vr2.toFixed(2) : (vr2 * 196.9).toFixed(1));
$("#vr-unit2").html(isCelsius ? " m/s" : " fpm");
} else {
$("#vr-res2").html("");
$("#vr-unit2").html("");
}
} else {
$(".inputbox2, .unit2, .tempunit2, .result2").hide();
d3.selectAll("path.comfortzone2").remove();
d3.selectAll("circle.point2").remove();
}
updateVrRowVisibility();
});
$("#inputs3")
.button({})
Expand All @@ -115,11 +126,20 @@ $(function () {
r = comf.pmvElevatedAirspeed(d.ta, d.tr, d.vel, d.rh, d.met, d.clo, 0);
renderPmvElevResults(r, "3");
calcPmvElevCompliance(d, r, "3");
if (comf.useSelfGeneratedAirSpeed && d.met > 1) {
const vr3 = comf.relativeAirSpeed(d.vel, d.met);
$("#vr-res3").html(isCelsius ? vr3.toFixed(2) : (vr3 * 196.9).toFixed(1));
$("#vr-unit3").html(isCelsius ? " m/s" : " fpm");
} else {
$("#vr-res3").html("");
$("#vr-unit3").html("");
}
} else {
$(".inputbox3, .unit3, .tempunit3, .result3").hide();
d3.selectAll("path.comfortzone3").remove();
d3.selectAll("circle.point3").remove();
}
updateVrRowVisibility();
});

$("#link").click(function () {
Expand Down Expand Up @@ -414,6 +434,29 @@ $("#unitsToggle").click(function () {
update("3");
});

$("#airSpeedDialog").dialog({
autoOpen: false,
width: 380,
modal: true,
resizable: false,
buttons: {
Close: function () {
$(this).dialog("close");
},
},
});

$("#airSpeedSettings").click(function () {
$("#airSpeedDialog").dialog("open");
});

$("#use-relative-air-speed").change(function () {
comf.useSelfGeneratedAirSpeed = $(this).prop("checked");
update("1");
update("2");
update("3");
});

$("#restart").click(function () {
setDefaults1();
setDefaults2();
Expand Down Expand Up @@ -450,6 +493,23 @@ $("#specPressure").click(function () {
}
});

function updateVrRowVisibility() {
if (!comf.useSelfGeneratedAirSpeed) {
$("#vr-row").hide();
return;
}
for (let j = 1; j <= 3; j++) {
if ($("#inputs" + j).is(":checked")) {
const met = parseFloat(document.getElementById("met" + j).value) || 0;
if (met > 1) {
$("#vr-row").show();
return;
}
}
}
$("#vr-row").hide();
}

function update(i) {
if ($("#tr-input").is(":hidden")) {
$("#tr" + i).val($("#ta" + i).val());
Expand All @@ -476,6 +536,21 @@ function update(i) {
renderPmvElevResults(r, i);
calcPmvElevCompliance(d, r, i);

if (comf.useSelfGeneratedAirSpeed && d.met > 1) {
const vr = comf.relativeAirSpeed(d.vel, d.met);
if (isCelsius) {
$("#vr-res" + i).html(vr.toFixed(2));
$("#vr-unit" + i).html(" m/s");
} else {
$("#vr-res" + i).html((vr * 196.9).toFixed(1));
$("#vr-unit" + i).html(" fpm");
}
} else {
$("#vr-res" + i).html("");
$("#vr-unit" + i).html("");
}
updateVrRowVisibility();

let b;
if ($("#chart-div").is(":visible")) {
b = pc.findComfortBoundary(d, 0.5);
Expand Down
41 changes: 41 additions & 0 deletions static/js/ranges/ranges.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ $(document).ready(function () {
window.humUnit = "rh";
rangeYes = false;

comf.useSelfGeneratedAirSpeed = $("#use-relative-air-speed").is(":checked");
resetDefaultValues();
update();
pc.drawChart(d);
Expand Down Expand Up @@ -379,6 +380,33 @@ $("#unitsToggle").click(function () {
update();
});

$("#airSpeedDialog").dialog({
autoOpen: false,
width: 380,
modal: true,
resizable: false,
buttons: {
Close: function () {
$(this).dialog("close");
},
},
});

$("#airSpeedSettings").click(function () {
$("#airSpeedDialog").dialog("open");
});

$("#use-relative-air-speed").change(function () {
comf.useSelfGeneratedAirSpeed = $(this).prop("checked");
if (rangeYes) {
if (rangefactor === "tr") drawTRrange();
else if (rangefactor === "vel") drawVELrange();
else if (rangefactor === "met") drawMETrange();
else if (rangefactor === "clo") drawCLOrange();
}
update();
});

$("#restart").click(function () {
rangeYes = false;
d3.selectAll("path.comfortzone-range").remove();
Expand Down Expand Up @@ -626,6 +654,7 @@ function drawRange(factor, incr) {
$(".factor-name").html(factor_names[rangefactor]);
$("#factor-name").html(factor_names[rangefactor]);
// $("#inputfield-" + factor).css('background-color', '#CECEE3');
update();
} else {
alert("insert the min and max values of the range");
}
Expand Down Expand Up @@ -757,6 +786,18 @@ function update() {
bc.redrawComfortRegion(b);
bc.redrawPoint();
}

if (d.met > 1 && comf.useSelfGeneratedAirSpeed) {
const vr = comf.relativeAirSpeed(d.vel, d.met);
if (isCelsius) {
$("#relative-air-speed-value").html(vr.toFixed(2));
} else {
$("#relative-air-speed-value").html((vr * 196.9).toFixed(1));
}
$("#relative-air-speed-div").show();
} else {
$("#relative-air-speed-div").hide();
}
}

function parameter_selection_change() {
Expand Down
31 changes: 31 additions & 0 deletions templates/ashrae.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,15 @@
/>
SI/IP
</label>
<label class="btn btn-light border" data-tooltip="Relative air speed settings">
<input
type="radio"
name="options"
id="airSpeedSettings"
autocomplete="off"
/>
Relative air speed
</label>
</div>
</div>
<div class="row justify-content-center mt-2">
Expand Down Expand Up @@ -599,6 +608,28 @@

<div id="globedialog" title="Globe to MRT converter"></div>
<div id="localdialog" title="Local discomfort assessment"></div>
<div id="airSpeedDialog" title="Relative air speed">
<p>
When metabolic rate is above 1 met, the tool automatically adds the
air speed generated by physical activity (e.g. walking) to the
measured air speed, following ASHRAE 55.
</p>
<p>
Disable this if occupants are at elevated metabolic rates without
generating air movement (e.g. exercising on stationary equipment).
</p>
<div class="form-check mt-2">
<input
class="form-check-input"
type="checkbox"
id="use-relative-air-speed"
checked
/>
<label class="form-check-label" for="use-relative-air-speed">
Include activity-generated air speed
</label>
</div>
</div>
<div
id="ERFdialog"
title="SolarCal: shortwave radiation calculator"
Expand Down
Loading