-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1401d9f
commit 8eea8a8
Showing
2 changed files
with
47 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
import { | ||
alpha, | ||
calcHrrAlpha, | ||
cappedCurve, | ||
generateHrr, | ||
StdGrowthRate, | ||
} from "../fds-inspect-core/fds.ts"; | ||
import { DataVector } from "../fds-inspect-core/smv.ts"; | ||
import * as fdsInspectCore from "jsr:@smoke-cloud/[email protected]"; | ||
import * as fdsInspect from "jsr:@smoke-cloud/[email protected]"; | ||
import Chart, { | ||
ChartConfiguration, | ||
ChartData, | ||
|
@@ -17,59 +11,68 @@ import annotationPlugin from "npm:chartjs-plugin-annotation"; | |
// import { createCanvas } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { createCanvas } from "jsr:@gfx/[email protected]"; | ||
import * as path from "jsr:@std/[email protected]"; | ||
import { HrrSpec } from "../fds-inspect-core/fds.ts"; | ||
import { HrrSpecSimple } from "../fds-inspect-core/fds.ts"; | ||
import pattern from "npm:patternomaly"; | ||
|
||
Chart.register(annotationPlugin); | ||
|
||
export function createStdHRRCurves(dv: DataVector, offset: number) { | ||
export function createStdHRRCurves( | ||
dv: fdsInspectCore.smv.DataVector, | ||
offset: number, | ||
) { | ||
if (offset == undefined) offset = 0; | ||
let maxHRR = 0; | ||
for (const p of dv.values) { | ||
maxHRR = Math.max(maxHRR, p.y); | ||
} | ||
if (maxHRR === 0) maxHRR = 1; | ||
const slowDV: DataVector = { | ||
const slowDV: fdsInspectCore.smv.DataVector = { | ||
name: "Slow HRR", | ||
x: { name: "Time", units: "s" }, | ||
y: { name: "Slow HRR", units: "kW" }, | ||
values: [], | ||
}; | ||
const mediumDV: DataVector = { | ||
const mediumDV: fdsInspectCore.smv.DataVector = { | ||
name: "Medium HRR", | ||
x: { name: "Time", units: "s" }, | ||
y: { name: "Medium HRR", units: "kW" }, | ||
values: [], | ||
}; | ||
const fastDV: DataVector = { | ||
const fastDV: fdsInspectCore.smv.DataVector = { | ||
name: "Fast HRR", | ||
x: { name: "Time", units: "s" }, | ||
y: { name: "Fast HRR", units: "kW" }, | ||
values: [], | ||
}; | ||
const ultrafastDV: DataVector = { | ||
const ultrafastDV: fdsInspectCore.smv.DataVector = { | ||
name: "Ultrafast HRR", | ||
x: { name: "Time", units: "s" }, | ||
y: { name: "Ultrafast HRR", units: "kW" }, | ||
values: [], | ||
}; | ||
const bound = 1.5; | ||
for (const p of dv.values) { | ||
const slowVal = calcHrrAlpha( | ||
alpha(StdGrowthRate.EurocodeSlow), | ||
const slowVal = fdsInspectCore.fds.calcHrrAlpha( | ||
fdsInspectCore.fds.alpha( | ||
fdsInspectCore.fds.StdGrowthRate.EurocodeSlow, | ||
), | ||
p.x - offset, | ||
); | ||
const mediumVal = calcHrrAlpha( | ||
alpha(StdGrowthRate.EurocodeMedium), | ||
const mediumVal = fdsInspectCore.fds.calcHrrAlpha( | ||
fdsInspectCore.fds.alpha( | ||
fdsInspectCore.fds.StdGrowthRate.EurocodeMedium, | ||
), | ||
p.x - offset, | ||
); | ||
const fastVal = calcHrrAlpha( | ||
alpha(StdGrowthRate.EurocodeFast), | ||
const fastVal = fdsInspectCore.fds.calcHrrAlpha( | ||
fdsInspectCore.fds.alpha( | ||
fdsInspectCore.fds.StdGrowthRate.EurocodeFast, | ||
), | ||
p.x - offset, | ||
); | ||
const ultrafastVal = calcHrrAlpha( | ||
alpha(StdGrowthRate.EurocodeUltrafast), | ||
const ultrafastVal = fdsInspectCore.fds.calcHrrAlpha( | ||
fdsInspectCore.fds.alpha( | ||
fdsInspectCore.fds.StdGrowthRate.EurocodeUltrafast, | ||
), | ||
p.x - offset, | ||
); | ||
if (slowVal < (bound * maxHRR)) { | ||
|
@@ -105,14 +108,17 @@ export interface ChartRange { | |
} | ||
export interface ChartBand { | ||
type: "chart-band"; | ||
dvA: DataVector; | ||
dvB: DataVector; | ||
dvA: fdsInspectCore.smv.DataVector; | ||
dvB: fdsInspectCore.smv.DataVector; | ||
label: string; | ||
} | ||
|
||
export async function plotDv( | ||
plotPath: string, | ||
dvs: (DataVector & { color?: string; dash?: number[] })[], | ||
dvs: (fdsInspectCore.smv.DataVector & { | ||
color?: string; | ||
dash?: number[]; | ||
})[], | ||
title: string, | ||
plotConfig?: {}, | ||
extras?: { | ||
|
@@ -283,11 +289,11 @@ unitMap.set("m3/s", "m³/s"); | |
|
||
export function plotHRRDV( | ||
plotPath: string, | ||
hrrDV: DataVector, | ||
hrrDV: fdsInspectCore.smv.DataVector, | ||
name: string, | ||
config?: { offset?: number }, | ||
spec?: { | ||
hrrSpec?: HrrSpecSimple; | ||
hrrSpec?: fdsInspectCore.fds.HrrSpecSimple; | ||
bound?: number; | ||
door?: { open: number; close: number }; | ||
sprinklerTime?: number; | ||
|
@@ -301,7 +307,10 @@ export function plotHRRDV( | |
offset, | ||
); | ||
|
||
const vecs: (DataVector & { color?: string; dash?: number[] })[] = [ | ||
const vecs: (fdsInspectCore.smv.DataVector & { | ||
color?: string; | ||
dash?: number[]; | ||
})[] = [ | ||
{ color: "#008000", dash: [10, 5], ...slowDV }, | ||
{ color: "#FF0000", dash: [10, 5], ...mediumDV }, | ||
{ color: "#00BFBF", dash: [10, 5], ...fastDV }, | ||
|
@@ -420,8 +429,8 @@ export function plotHRRDV( | |
if (spec?.hrrSpec) { | ||
extras.chartExtras.push({ | ||
type: "chart-band", | ||
dvA: generateHrr(spec?.hrrSpec, hrrDV, 0.9), | ||
dvB: generateHrr(spec?.hrrSpec, hrrDV, 1.1), | ||
dvA: fdsInspectCore.fds.generateHrr(spec?.hrrSpec, hrrDV, 0.9), | ||
dvB: fdsInspectCore.fds.generateHrr(spec?.hrrSpec, hrrDV, 1.1), | ||
label: "10% Bounds", | ||
}); | ||
} | ||
|
@@ -432,7 +441,7 @@ export function plotHRRDV( | |
} | ||
|
||
// Weighted moving average | ||
function wma(dv: DataVector, window: number) { | ||
function wma(dv: fdsInspectCore.smv.DataVector, window: number) { | ||
if (dv.values.length <= 1) { | ||
// The weighted average of an empty vector or a vector that has a | ||
// single element is just the same vector | ||
|