-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathphs.html
76 lines (73 loc) · 1.98 KB
/
phs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PHS example</title>
<meta
name="description"
content="Example of PHS usage in jsthermalcomfort"
/>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script
src="https://cdn.plot.ly/plotly-2.26.1.min.js"
charset="utf-8"
></script>
</head>
<body style="text-align: center">
<h1>PHS example</h1>
<h2>V = 0.2</h2>
<div
id="heat_map_0"
style="width: 600px; height: 600px; margin: auto"
></div>
<h2>V = 2.5</h2>
<div
id="heat_map_1"
style="width: 600px; height: 600px; margin: auto"
></div>
<script type="module">
import { phs } from "https://cdn.jsdelivr.net/gh/FedericoTartarini/jsthermalcomfort/lib/esm/models/phs.js";
function range(start, stop, step = 1) {
if (stop === undefined) {
stop = start;
start = 0;
}
return Array.from(
{ length: Math.ceil((stop - start) / step) },
(_, index) => start + index * step,
);
}
for (const [index, v] of [0.2, 2.5].entries()) {
const z = [];
const tdb_range = range(30, 49);
const rh_range = range(0, 100).reverse();
for (const rh of rh_range) {
z.push(Array.from({ length: 49 - 30 }, () => null));
for (const tdb of tdb_range) {
const result = phs(tdb, tdb, v, rh, 55, 0.5, 2).t_re;
z[z.length - 1][tdb - 30] = result;
}
}
const heatmap_data = [
{
z,
x: tdb_range,
y: rh_range,
type: "heatmap",
hoverongaps: false,
zmin: 36.9,
zmax: 59.3,
},
];
Plotly.newPlot(`heat_map_${index}`, heatmap_data, {
xaxis: {
title: "TDB",
},
yaxis: {
title: "RH",
},
});
}
</script>
</body>
</html>