@dnv-plant/typescriptpws 1.0.70 → 1.0.73-alpha.1902013
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +2 -2
- package/jest.config.js +5 -0
- package/package.json +6 -6
- package/src/calculations/applicationTools.ts +2 -2
- package/src/calculations/discharge.ts +2 -2
- package/src/calculations/dispersion.ts +2 -2
- package/src/calculations/dispersionView.ts +2 -2
- package/src/calculations/fireball.ts +2 -2
- package/src/calculations/jetFire.ts +2 -2
- package/src/calculations/lateExplosion.ts +2 -2
- package/src/calculations/linkedRunners.ts +2 -2
- package/src/calculations/poolFire.ts +2 -2
- package/src/calculations/properties.ts +2 -2
- package/src/calculations/radiation.ts +2 -2
- package/src/calculations/standalones.ts +2 -2
- package/src/calculations/toxics.ts +2 -2
- package/src/calculations/utilities.ts +2 -2
- package/src/constants.ts +2 -2
- package/src/entities.ts +2 -2
- package/src/entity-schemas.ts +2 -2
- package/src/enums.ts +2 -2
- package/src/materials.ts +14 -14
- package/src/utilities.ts +2 -2
- package/tests/concentration-at-point-calculation/testCase116.test.ts +146 -0
- package/tests/concentration-at-point-calculation/testCase117.test.ts +142 -0
- package/tests/concentration-at-point-calculation/testCase118.test.ts +143 -0
- package/tests/concentration-at-point-calculation/testCase119.test.ts +149 -0
- package/tests/concentration-at-point-calculation/testCase120.test.ts +155 -0
- package/tests/constants/testConstants.test.ts +23 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase129.test.ts +74 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase130.test.ts +73 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase131.test.ts +73 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase132.test.ts +73 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase133.test.ts +73 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase134.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase135.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase136.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase137.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase138.test.ts +72 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase64.test.ts +194 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase65.test.ts +197 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase66.test.ts +194 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase67.test.ts +198 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase68.test.ts +178 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase31a.test.ts +158 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase32a.test.ts +156 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase33a.test.ts +158 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase34a.test.ts +165 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase35a.test.ts +188 -0
- package/tests/distances-to-conc-levels-calculation/testCase121.test.ts +149 -0
- package/tests/distances-to-conc-levels-calculation/testCase122.test.ts +145 -0
- package/tests/distances-to-conc-levels-calculation/testCase123.test.ts +150 -0
- package/tests/distances-to-conc-levels-calculation/testCase124.test.ts +154 -0
- package/tests/distances-to-conc-levels-calculation/testCase125.test.ts +157 -0
- package/tests/entities/testVessel.test.ts +49 -0
- package/tests/fireball-calculation/testCase89.test.ts +151 -0
- package/tests/fireball-calculation/testCase90.test.ts +153 -0
- package/tests/fireball-calculation/testCase91.test.ts +152 -0
- package/tests/fireball-calculation/testCse92.test.ts +150 -0
- package/tests/flash-calculation/testCase26.test.ts +71 -0
- package/tests/flash-calculation/testCase27.test.ts +69 -0
- package/tests/flash-calculation/testCase28.test.ts +69 -0
- package/tests/flash-calculation/testCase29.test.ts +67 -0
- package/tests/flash-calculation/testCase30.test.ts +70 -0
- package/tests/general/operation-id-demo.test.ts +64 -0
- package/tests/get-component-by-id/get-component-by-id-METHANE.test.ts +35 -0
- package/tests/get-mass-from-vessel-calculation/testCase139.test.ts +65 -0
- package/tests/jet-fire-calculation/testCase36.test.ts +141 -0
- package/tests/jet-fire-calculation/testCase37.test.ts +148 -0
- package/tests/jet-fire-calculation/testCase38.test.ts +147 -0
- package/tests/jet-fire-calculation/testCase39.test.ts +146 -0
- package/tests/jet-fire-calculation/testCase40.test.ts +152 -0
- package/tests/late-explosion-calculation/testCase46.test.ts +157 -0
- package/tests/late-explosion-calculation/testCase47.test.ts +149 -0
- package/tests/late-explosion-calculation/testCase48.test.ts +176 -0
- package/tests/late-explosion-calculation/testCase49.test.ts +178 -0
- package/tests/late-explosion-calculation/testCase50.test.ts +176 -0
- package/tests/late-explosion-calculation/testCase74.test.ts +166 -0
- package/tests/late-explosion-calculation/testCase75.test.ts +163 -0
- package/tests/late-explosion-calculation/testCase76.test.ts +174 -0
- package/tests/late-explosion-calculation/testCase77.test.ts +175 -0
- package/tests/late-explosion-calculation/testCase78.test.ts +175 -0
- package/tests/lethality-distance-calculation/testCase60.test.ts +142 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-153.test.ts +121 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-154.test.ts +167 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-155.test.ts +202 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-156.test.ts +201 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-157.test.ts +182 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-158.test.ts +200 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-159.test.ts +158 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-160.test.ts +165 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-161.test.ts +161 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-162.test.ts +167 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-163.test.ts +177 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-164.test.ts +165 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-165.test.ts +166 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-166.test.ts +154 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-167.test.ts +157 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-168.test.ts +168 -0
- package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase126.test.ts +72 -0
- package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase127.test.ts +73 -0
- package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase128.test.ts +72 -0
- package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase103.test.ts +74 -0
- package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase104.test.ts +75 -0
- package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase105.test.ts +74 -0
- package/tests/long-pipe-calculation/testCase55.test.ts +88 -0
- package/tests/long-pipe-calculation/testCase56.test.ts +90 -0
- package/tests/long-pipe-calculation/testCase57.test.ts +88 -0
- package/tests/long-pipe-calculation/testCase58.test.ts +88 -0
- package/tests/long-pipe-calculation/testCase59.test.ts +88 -0
- package/tests/materials/test-get-component-by-cas-id-1-2-PROPYLENE-OXIDE.test.ts +23 -0
- package/tests/materials/test-get-component-by-cas-id-CARBON-MONOXIDE.test.ts +25 -0
- package/tests/materials/test-get-component-by-cas-id-METHANE.test.ts +22 -0
- package/tests/materials/test-get-component-by-id-1-2-PROPYLENE-OXIDE.test.ts +23 -0
- package/tests/materials/test-get-component-by-id-CARBON-MONOXIDE.test.ts +22 -0
- package/tests/materials/test-get-component-by-id-METHANE.test.ts +22 -0
- package/tests/materials/test-get-component-by-name-1-2-PROPYLENE-OXIDE.test.ts +24 -0
- package/tests/materials/test-get-component-by-name-CARBON-MONOXIDE.test.ts +23 -0
- package/tests/materials/test-get-component-by-name-METHANE.test.ts +25 -0
- package/tests/materials/test-get-components.test.ts +47 -0
- package/tests/materials/test-get-dippr-components.test.ts +28 -0
- package/tests/materials/test-get-dnv-components.test.ts +28 -0
- package/tests/materials/test-get-material-by-cas-id-1-2-PROPYLENE-OXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-cas-id-CARBON-MONOXIDE.test.ts +31 -0
- package/tests/materials/test-get-material-by-cas-id-METHANE.test.ts +30 -0
- package/tests/materials/test-get-material-by-cas-id-ZERO.test.ts +31 -0
- package/tests/materials/test-get-material-by-id-1-2-PROPYLENE-OXIDE.test.ts +30 -0
- package/tests/materials/test-get-material-by-id-CARBON-MONOXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-id-METHANE.test.ts +29 -0
- package/tests/materials/test-get-material-by-name-1-2-PROPYLENE-OXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-name-CARBON-MONOXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-name-METHANE.test.ts +29 -0
- package/tests/materials/test-get-materials.test.ts +32 -0
- package/tests/max-conc-distance-calculation/testCase106.test.ts +146 -0
- package/tests/max-conc-distance-calculation/testCase107.test.ts +148 -0
- package/tests/max-conc-distance-calculation/testCase108.test.ts +172 -0
- package/tests/max-conc-distance-calculation/testCase109.test.ts +146 -0
- package/tests/max-conc-distance-calculation/testCase110.test.ts +146 -0
- package/tests/max-conc-footprint-calculation/testCase31.test.ts +169 -0
- package/tests/max-conc-footprint-calculation/testCase32.test.ts +183 -0
- package/tests/max-conc-footprint-calculation/testCase33.test.ts +161 -0
- package/tests/max-conc-footprint-calculation/testCase34.test.ts +172 -0
- package/tests/max-conc-footprint-calculation/testCase35.test.ts +188 -0
- package/tests/max-distance-to-conc-calculation/testCase111.test.ts +138 -0
- package/tests/max-distance-to-conc-calculation/testCase112.test.ts +174 -0
- package/tests/max-distance-to-conc-calculation/testCase113.test.ts +153 -0
- package/tests/max-distance-to-conc-calculation/testCase114.test.ts +162 -0
- package/tests/max-distance-to-conc-calculation/testCase115.test.ts +167 -0
- package/tests/mixture-constant-properties-calculation/testCase97.test.ts +83 -0
- package/tests/mixture-constant-properties-calculation/testCase98.test.ts +90 -0
- package/tests/mixture-constant-properties-calculation/testCase99.test.ts +87 -0
- package/tests/pool-fire-calculation/testCase41.test.ts +153 -0
- package/tests/pool-fire-calculation/testCase41a.test.ts +141 -0
- package/tests/pool-fire-calculation/testCase42.test.ts +169 -0
- package/tests/pool-fire-calculation/testCase42a.test.ts +175 -0
- package/tests/pool-fire-calculation/testCase43.test.ts +161 -0
- package/tests/pool-fire-calculation/testCase43a.test.ts +157 -0
- package/tests/pool-fire-calculation/testCase44.test.ts +147 -0
- package/tests/pool-fire-calculation/testCase44a.test.ts +152 -0
- package/tests/pool-fire-calculation/testCase45.test.ts +176 -0
- package/tests/pool-fire-calculation/testCase45a.test.ts +182 -0
- package/tests/radiation-at-ponts/testCase69.test.ts +167 -0
- package/tests/radiation-at-ponts/testCase70.test.ts +179 -0
- package/tests/radiation-at-ponts/testCase71.test.ts +150 -0
- package/tests/radiation-at-ponts/testCase72.test.ts +166 -0
- package/tests/radiation-at-ponts/testCase73.test.ts +169 -0
- package/tests/radiation-contour-calculation/testCase51.test.ts +127 -0
- package/tests/radiation-contour-calculation/testCase52.test.ts +126 -0
- package/tests/radiation-contour-calculation/testCase53.test.ts +126 -0
- package/tests/radiation-contour-calculation/testCase54.test.ts +131 -0
- package/tests/relief-valve-min-temperature-calculation/testCase140.test.ts +49 -0
- package/tests/set-mixing-layer-height/testCase100.test.ts +36 -0
- package/tests/set-mixing-layer-height/testCase101.test.ts +36 -0
- package/tests/set-mixing-layer-height/testCase102.test.ts +36 -0
- package/tests/set-phase-to-be-released-for-leak-calculation/testCase150.test.ts +67 -0
- package/tests/set-phase-to-be-released-for-line-rupture-calculation/testCase151.test.ts +67 -0
- package/tests/set-phase-to-be-released-for-relief-valve-calculation/TestCase152.test.ts +61 -0
- package/tests/sideview/testCase31b.test.ts +150 -0
- package/tests/sideview/testCase32b.test.ts +145 -0
- package/tests/sideview/testCase33b.test.ts +130 -0
- package/tests/sideview/testCase34b.test.ts +153 -0
- package/tests/sideview/testCase35b.test.ts +140 -0
- package/tests/tank-fire-calculation/testCase79.test.ts +61 -0
- package/tests/tank-fire-calculation/testCase80.test.ts +67 -0
- package/tests/tank-fire-calculation/testCase81.test.ts +68 -0
- package/tests/tank-fire-calculation/testCase82.test.ts +68 -0
- package/tests/tank-fire-calculation/testCase83.test.ts +73 -0
- package/tests/utilities/convert-camel-case-to-snake-case.test.ts +7 -0
- package/tests/utilities/convert-snake-case-to-camel-case.test.ts +7 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase1.test.ts +83 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase2.test.ts +82 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase3.test.ts +91 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase4.test.ts +85 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase5.test.ts +84 -0
- package/tests/vessel-leak-calculation/testCase10.test.ts +108 -0
- package/tests/vessel-leak-calculation/testCase6.test.ts +113 -0
- package/tests/vessel-leak-calculation/testCase7.test.ts +123 -0
- package/tests/vessel-leak-calculation/testCase8.test.ts +102 -0
- package/tests/vessel-leak-calculation/testCase9.test.ts +106 -0
- package/tests/vessel-line-rupture-calculation/vlr-ammonia.test.ts +84 -0
- package/tests/vessel-line-rupture-calculation/vlr-ethaneMethane.test.ts +82 -0
- package/tests/vessel-line-rupture-calculation/vlr-nDecane.test.ts +79 -0
- package/tests/vessel-line-rupture-calculation/vlr-oxygen.test.ts +77 -0
- package/tests/vessel-line-rupture-calculation/vlr-propane.test.ts +77 -0
- package/tests/vessel-relief-valve-calculation/vrv-chlorine.test.ts +99 -0
- package/tests/vessel-relief-valve-calculation/vrv-hydrogen.test.ts +96 -0
- package/tests/vessel-relief-valve-calculation/vrv-methane.test.ts +80 -0
- package/tests/vessel-relief-valve-calculation/vrv-methaneH2s.test.ts +86 -0
- package/tests/vessel-relief-valve-calculation/vrv-nitrogen.test.ts +80 -0
- package/tests/vessel-state-calculation/vs-ammonia.test.ts +56 -0
- package/tests/vessel-state-calculation/vs-butane.test.ts +57 -0
- package/tests/vessel-state-calculation/vs-chlorine.test.ts +56 -0
- package/tests/vessel-state-calculation/vs-methane.test.ts +57 -0
- package/tests/vessel-state-calculation/vs-naturalGas.test.ts +59 -0
- package/tests/vessel-state-calculation/vs-nitrogenPentane.test.ts +58 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Vessel, Substrate, Weather, DischargeParameters, DispersionParameters, DispersionOutputConfig } from "../../src/entities";
|
|
2
|
+
import { VesselStateCalculation, VesselCatastrophicRuptureCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { DispersionCalculation } from "../../src/calculations/dispersion";
|
|
4
|
+
import { MaxConcDistanceCalculation } from "../../src/calculations/dispersionView";
|
|
5
|
+
import { ResultCode, SurfaceType, AtmosphericStabilityClass, Resolution, SpecialConcentration, VesselShape, WindProfileFlag } from "../../src/enums";
|
|
6
|
+
import { setAccessToken } from "../../src/utilities";
|
|
7
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
8
|
+
|
|
9
|
+
if (!accessToken) {
|
|
10
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
setAccessToken(accessToken);
|
|
14
|
+
|
|
15
|
+
describe("Max Concentration Distance Calculation - Test Case 107", () => {
|
|
16
|
+
test("should match regression values", async () => {
|
|
17
|
+
const materialName = "ETHANE_BUTANE_PROPANE";
|
|
18
|
+
const endPointConcentration = 0.0;
|
|
19
|
+
const elevation = 2.0;
|
|
20
|
+
const resolution = Resolution.HIGH;
|
|
21
|
+
const specialConcentration = SpecialConcentration.UFL;
|
|
22
|
+
const lflFraction = 0.5;
|
|
23
|
+
const componentToTrackName = "N-BUTANE";
|
|
24
|
+
const windProfileFlag = WindProfileFlag.LOGARITHMIC_PROFILE;
|
|
25
|
+
|
|
26
|
+
const material = new Material({
|
|
27
|
+
name: materialName,
|
|
28
|
+
components: [
|
|
29
|
+
new MaterialComponent({ name: "ETHANE", moleFraction: 0.5 }),
|
|
30
|
+
new MaterialComponent({ name: "N-BUTANE", moleFraction: 0.3 }),
|
|
31
|
+
new MaterialComponent({ name: "PROPANE", moleFraction: 0.2 }),
|
|
32
|
+
],
|
|
33
|
+
componentCount: 3
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const state = new State({
|
|
37
|
+
temperature: 265.0,
|
|
38
|
+
pressure: 5.0e5,
|
|
39
|
+
liquidFraction: 0.0,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
43
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
44
|
+
|
|
45
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
46
|
+
console.log("Messages:");
|
|
47
|
+
vesselStateCalculation.messages.forEach((msg) => console.log(msg));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
51
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
52
|
+
|
|
53
|
+
const vessel = new Vessel({
|
|
54
|
+
state,
|
|
55
|
+
material,
|
|
56
|
+
liquidFillFractionByVolume: 0.8,
|
|
57
|
+
shape: VesselShape.VERTICAL_CYLINDER,
|
|
58
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const dischargeParameters = new DischargeParameters();
|
|
62
|
+
const ruptureCalc = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
63
|
+
const ruptureResult = await ruptureCalc.run();
|
|
64
|
+
|
|
65
|
+
if (ruptureCalc.messages.length > 0) {
|
|
66
|
+
console.log("Messages:");
|
|
67
|
+
ruptureCalc.messages.forEach((msg) => console.log(msg));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
expect(ruptureResult).toBe(ResultCode.SUCCESS);
|
|
71
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${ruptureCalc.calculationElapsedTime}ms)`);
|
|
72
|
+
|
|
73
|
+
const substrate = new Substrate();
|
|
74
|
+
const weather = new Weather({windProfileFlag: windProfileFlag});
|
|
75
|
+
const dispersionParameters = new DispersionParameters();
|
|
76
|
+
|
|
77
|
+
const dispersionCalc = new DispersionCalculation(
|
|
78
|
+
ruptureCalc.exitMaterial!,
|
|
79
|
+
substrate,
|
|
80
|
+
ruptureCalc.dischargeResult!,
|
|
81
|
+
ruptureCalc.dischargeRecords!,
|
|
82
|
+
ruptureCalc.dischargeRecords!.length,
|
|
83
|
+
weather,
|
|
84
|
+
dispersionParameters,
|
|
85
|
+
endPointConcentration
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const dispersionResult = await dispersionCalc.run();
|
|
89
|
+
|
|
90
|
+
if (dispersionCalc.messages.length > 0) {
|
|
91
|
+
console.log("Messages:");
|
|
92
|
+
dispersionCalc.messages.forEach((msg) => console.log(msg));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
expect(dispersionResult).toBe(ResultCode.SUCCESS);
|
|
96
|
+
console.log(`SUCCESS: dispersion_calculation (${dispersionCalc.calculationElapsedTime}ms)`);
|
|
97
|
+
console.log(`length dispersion records = ${dispersionCalc.dispersionRecords!.length}`);
|
|
98
|
+
console.log(`minimum concentration = ${dispersionCalc.scalarUdmOutputs!.minimumConcentration}`);
|
|
99
|
+
console.log(`observer count = ${dispersionCalc.scalarUdmOutputs!.observerCount}`);
|
|
100
|
+
console.log(`final centreline concentration = ${dispersionCalc.dispersionRecords!.at(-1)!.centrelineConcentration}`);
|
|
101
|
+
console.log(`final downwind distance = ${dispersionCalc.dispersionRecords!.at(-1)!.downwindDistance}`);
|
|
102
|
+
|
|
103
|
+
const dispersionOutputConfig = new DispersionOutputConfig({
|
|
104
|
+
concentration: endPointConcentration,
|
|
105
|
+
elevation,
|
|
106
|
+
resolution,
|
|
107
|
+
specialConcentration,
|
|
108
|
+
lflFractionValue: lflFraction,
|
|
109
|
+
componentToTrackName,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const maxConcDistanceCalc = new MaxConcDistanceCalculation(
|
|
113
|
+
dispersionCalc.scalarUdmOutputs!,
|
|
114
|
+
weather,
|
|
115
|
+
dispersionCalc.dispersionRecords!,
|
|
116
|
+
dispersionCalc.dispersionRecords!.length,
|
|
117
|
+
substrate,
|
|
118
|
+
dispersionOutputConfig,
|
|
119
|
+
ruptureCalc.exitMaterial!,
|
|
120
|
+
dispersionParameters
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const maxDistanceResult = await maxConcDistanceCalc.run();
|
|
124
|
+
|
|
125
|
+
if (maxConcDistanceCalc.messages.length > 0) {
|
|
126
|
+
console.log("Messages:");
|
|
127
|
+
maxConcDistanceCalc.messages.forEach((msg) => console.log(msg));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
expect(maxDistanceResult).toBe(ResultCode.SUCCESS);
|
|
131
|
+
|
|
132
|
+
const records = maxConcDistanceCalc.concentrationRecords!;
|
|
133
|
+
expect(records.length).toBe(168);
|
|
134
|
+
|
|
135
|
+
const lastRecord = records.at(-1)!;
|
|
136
|
+
const expectedConcentration = 0.02941206246379815;
|
|
137
|
+
const expectedX = 4.048969882876413;
|
|
138
|
+
|
|
139
|
+
const concError = Math.abs((lastRecord.concentration! - expectedConcentration) / expectedConcentration);
|
|
140
|
+
const xError = Math.abs((lastRecord.position.x - expectedX) / expectedX);
|
|
141
|
+
|
|
142
|
+
expect(concError).toBeLessThan(1e-3);
|
|
143
|
+
expect(xError).toBeLessThan(1e-3);
|
|
144
|
+
|
|
145
|
+
console.log(`SUCCESS: max_conc_distance_calculation (${maxConcDistanceCalc.calculationElapsedTime}ms)`);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Vessel, Substrate, Weather, DischargeParameters, DispersionParameters, DispersionOutputConfig } from "../../src/entities";
|
|
2
|
+
import { VesselStateCalculation, VesselCatastrophicRuptureCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { DispersionCalculation } from "../../src/calculations/dispersion";
|
|
4
|
+
import { MaxConcDistanceCalculation } from "../../src/calculations/dispersionView";
|
|
5
|
+
import { ResultCode, SurfaceType, AtmosphericStabilityClass, Resolution, SpecialConcentration, VesselShape, WindProfileFlag } from "../../src/enums";
|
|
6
|
+
import { setAccessToken } from "../../src/utilities";
|
|
7
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
8
|
+
|
|
9
|
+
if (!accessToken) {
|
|
10
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
setAccessToken(accessToken);
|
|
14
|
+
|
|
15
|
+
describe("Max Concentration Distance Calculation - Test Case 108", () => {
|
|
16
|
+
test("should match regression expectations", async () => {
|
|
17
|
+
const materialName = "N-HEXANE";
|
|
18
|
+
const endPointConcentration = 0.0;
|
|
19
|
+
const elevation = 4.0;
|
|
20
|
+
const resolution = Resolution.EXTREME;
|
|
21
|
+
const specialConcentration = SpecialConcentration.LFL;
|
|
22
|
+
const lflFraction = 0.3;
|
|
23
|
+
const componentToTrackName = "";
|
|
24
|
+
const windProfileFlag = WindProfileFlag.LOGARITHMIC_PROFILE;
|
|
25
|
+
|
|
26
|
+
const material = new Material({
|
|
27
|
+
name: materialName,
|
|
28
|
+
components: [new MaterialComponent({ name: materialName })],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const state = new State({
|
|
32
|
+
temperature: 265.0,
|
|
33
|
+
pressure: 5.0e5,
|
|
34
|
+
liquidFraction: 0.0,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
38
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
39
|
+
|
|
40
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
41
|
+
console.log("Messages:");
|
|
42
|
+
vesselStateCalculation.messages.forEach((msg) => console.log(msg));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
46
|
+
console.log(
|
|
47
|
+
`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const vessel = new Vessel({
|
|
51
|
+
state,
|
|
52
|
+
material,
|
|
53
|
+
liquidFillFractionByVolume: 0.8,
|
|
54
|
+
shape: VesselShape.VERTICAL_CYLINDER,
|
|
55
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const dischargeParameters = new DischargeParameters();
|
|
59
|
+
const ruptureCalculation = new VesselCatastrophicRuptureCalculation(
|
|
60
|
+
vessel,
|
|
61
|
+
dischargeParameters
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const ruptureResult = await ruptureCalculation.run();
|
|
65
|
+
|
|
66
|
+
if (ruptureCalculation.messages.length > 0) {
|
|
67
|
+
console.log("Messages:");
|
|
68
|
+
ruptureCalculation.messages.forEach((msg) => console.log(msg));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
expect(ruptureResult).toBe(ResultCode.SUCCESS);
|
|
72
|
+
console.log(
|
|
73
|
+
`SUCCESS: vessel_catastrophic_rupture_calculation (${ruptureCalculation.calculationElapsedTime}ms)`
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const substrate = new Substrate();
|
|
77
|
+
const weather = new Weather({windProfileFlag: windProfileFlag});
|
|
78
|
+
const dispersionParameters = new DispersionParameters();
|
|
79
|
+
|
|
80
|
+
const dispersionCalculation = new DispersionCalculation(
|
|
81
|
+
ruptureCalculation.exitMaterial!,
|
|
82
|
+
substrate,
|
|
83
|
+
ruptureCalculation.dischargeResult!,
|
|
84
|
+
ruptureCalculation.dischargeRecords!,
|
|
85
|
+
ruptureCalculation.dischargeRecords!.length,
|
|
86
|
+
weather,
|
|
87
|
+
dispersionParameters,
|
|
88
|
+
endPointConcentration
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const dispersionResult = await dispersionCalculation.run();
|
|
92
|
+
|
|
93
|
+
if (dispersionCalculation.messages.length > 0) {
|
|
94
|
+
console.log("Messages:");
|
|
95
|
+
dispersionCalculation.messages.forEach((msg) => console.log(msg));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
expect(dispersionResult).toBe(ResultCode.SUCCESS);
|
|
99
|
+
console.log(
|
|
100
|
+
`SUCCESS: dispersion_calculation (${dispersionCalculation.calculationElapsedTime}ms)`
|
|
101
|
+
);
|
|
102
|
+
console.log(
|
|
103
|
+
`Length dispersion records = ${dispersionCalculation.dispersionRecords!.length}`
|
|
104
|
+
);
|
|
105
|
+
console.log(
|
|
106
|
+
`Minimum concentration = ${dispersionCalculation.scalarUdmOutputs!.minimumConcentration}`
|
|
107
|
+
);
|
|
108
|
+
console.log(
|
|
109
|
+
`Observer count = ${dispersionCalculation.scalarUdmOutputs!.observerCount}`
|
|
110
|
+
);
|
|
111
|
+
const lastDispersionRecord =
|
|
112
|
+
dispersionCalculation.dispersionRecords!.at(-1)!;
|
|
113
|
+
console.log(
|
|
114
|
+
`Final centreline concentration = ${lastDispersionRecord.centrelineConcentration}`
|
|
115
|
+
);
|
|
116
|
+
console.log(
|
|
117
|
+
`Final downwind distance = ${lastDispersionRecord.downwindDistance}`
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const dispersionOutputConfig = new DispersionOutputConfig({
|
|
121
|
+
concentration: endPointConcentration,
|
|
122
|
+
elevation,
|
|
123
|
+
resolution,
|
|
124
|
+
specialConcentration,
|
|
125
|
+
lflFractionValue: lflFraction,
|
|
126
|
+
componentToTrackName,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const maxConcDistanceCalculation = new MaxConcDistanceCalculation(
|
|
130
|
+
dispersionCalculation.scalarUdmOutputs!,
|
|
131
|
+
weather,
|
|
132
|
+
dispersionCalculation.dispersionRecords!,
|
|
133
|
+
dispersionCalculation.dispersionRecords!.length,
|
|
134
|
+
substrate,
|
|
135
|
+
dispersionOutputConfig,
|
|
136
|
+
ruptureCalculation.exitMaterial!,
|
|
137
|
+
dispersionParameters
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const maxDistanceResult = await maxConcDistanceCalculation.run();
|
|
141
|
+
|
|
142
|
+
if (maxConcDistanceCalculation.messages.length > 0) {
|
|
143
|
+
console.log("Messages:");
|
|
144
|
+
maxConcDistanceCalculation.messages.forEach((msg) => console.log(msg));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
expect(maxDistanceResult).toBe(ResultCode.SUCCESS);
|
|
148
|
+
|
|
149
|
+
const records = maxConcDistanceCalculation.concentrationRecords!;
|
|
150
|
+
expect(records.length).toBe(108);
|
|
151
|
+
|
|
152
|
+
const lastRecord = records.at(-1)!;
|
|
153
|
+
|
|
154
|
+
const expectedConcentration = 0.3615707454077038;
|
|
155
|
+
const expectedX = 6.446181601923854;
|
|
156
|
+
|
|
157
|
+
const concError = Math.abs(
|
|
158
|
+
(lastRecord.concentration! - expectedConcentration) / expectedConcentration
|
|
159
|
+
);
|
|
160
|
+
const xError = Math.abs(
|
|
161
|
+
(lastRecord.position.x - expectedX) / expectedX
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
expect(concError).toBeLessThan(1e-3);
|
|
165
|
+
expect(xError).toBeLessThan(1e-3);
|
|
166
|
+
|
|
167
|
+
console.log(
|
|
168
|
+
`SUCCESS: max_conc_distance_calculation (${maxConcDistanceCalculation.calculationElapsedTime}ms)`
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Vessel, Substrate, Weather, DischargeParameters, DispersionParameters, DispersionOutputConfig } from "../../src/entities";
|
|
2
|
+
import { VesselStateCalculation, VesselCatastrophicRuptureCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { DispersionCalculation } from "../../src/calculations/dispersion";
|
|
4
|
+
import { MaxConcDistanceCalculation } from "../../src/calculations/dispersionView";
|
|
5
|
+
import { ResultCode, SurfaceType, AtmosphericStabilityClass, Resolution, SpecialConcentration, VesselShape, WindProfileFlag } from "../../src/enums";
|
|
6
|
+
import { setAccessToken } from "../../src/utilities";
|
|
7
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
8
|
+
|
|
9
|
+
if (!accessToken) {
|
|
10
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
setAccessToken(accessToken);
|
|
14
|
+
|
|
15
|
+
describe("Max Concentration Distance Calculation - Test Case 109", () => {
|
|
16
|
+
test("should run calculation and perform regression check", async () => {
|
|
17
|
+
const materialName = "HYDROGEN";
|
|
18
|
+
const endPointConcentration = 0.0;
|
|
19
|
+
const elevation = 10.0;
|
|
20
|
+
const resolution = Resolution.MEDIUM;
|
|
21
|
+
const specialConcentration = SpecialConcentration.LFL_FRACTION;
|
|
22
|
+
const lflFraction = 0.7;
|
|
23
|
+
const componentToTrackName = "";
|
|
24
|
+
const windProfileFlag = WindProfileFlag.LOGARITHMIC_PROFILE;
|
|
25
|
+
|
|
26
|
+
const material = new Material({
|
|
27
|
+
name: materialName,
|
|
28
|
+
components: [new MaterialComponent({ name: materialName })],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const state = new State({
|
|
32
|
+
temperature: 265.0,
|
|
33
|
+
pressure: 5.0e5,
|
|
34
|
+
liquidFraction: 0.0,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
38
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
39
|
+
|
|
40
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
41
|
+
console.log("Messages:");
|
|
42
|
+
vesselStateCalculation.messages.forEach((msg) => console.log(msg));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
46
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
47
|
+
|
|
48
|
+
const vessel = new Vessel({
|
|
49
|
+
state,
|
|
50
|
+
material,
|
|
51
|
+
liquidFillFractionByVolume: 0.8,
|
|
52
|
+
shape: VesselShape.VERTICAL_CYLINDER,
|
|
53
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const dischargeParameters = new DischargeParameters();
|
|
57
|
+
const ruptureCalculation = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
58
|
+
|
|
59
|
+
const ruptureResult = await ruptureCalculation.run();
|
|
60
|
+
|
|
61
|
+
if (ruptureCalculation.messages.length > 0) {
|
|
62
|
+
console.log("Messages:");
|
|
63
|
+
ruptureCalculation.messages.forEach((msg) => console.log(msg));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
expect(ruptureResult).toBe(ResultCode.SUCCESS);
|
|
67
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${ruptureCalculation.calculationElapsedTime}ms)`);
|
|
68
|
+
|
|
69
|
+
const substrate = new Substrate();
|
|
70
|
+
const weather = new Weather({windProfileFlag: windProfileFlag});
|
|
71
|
+
const dispersionParameters = new DispersionParameters();
|
|
72
|
+
|
|
73
|
+
const dispersionCalculation = new DispersionCalculation(
|
|
74
|
+
ruptureCalculation.exitMaterial!,
|
|
75
|
+
substrate,
|
|
76
|
+
ruptureCalculation.dischargeResult!,
|
|
77
|
+
ruptureCalculation.dischargeRecords!,
|
|
78
|
+
ruptureCalculation.dischargeRecords!.length,
|
|
79
|
+
weather,
|
|
80
|
+
dispersionParameters,
|
|
81
|
+
endPointConcentration
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const dispersionResult = await dispersionCalculation.run();
|
|
85
|
+
|
|
86
|
+
if (dispersionCalculation.messages.length > 0) {
|
|
87
|
+
console.log("Messages:");
|
|
88
|
+
dispersionCalculation.messages.forEach((msg) => console.log(msg));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
expect(dispersionResult).toBe(ResultCode.SUCCESS);
|
|
92
|
+
console.log(`SUCCESS: dispersion_calculation (${dispersionCalculation.calculationElapsedTime}ms)`);
|
|
93
|
+
console.log(`Length dispersion records = ${dispersionCalculation.dispersionRecords!.length}`);
|
|
94
|
+
console.log(`Minimum concentration = ${dispersionCalculation.scalarUdmOutputs!.minimumConcentration}`);
|
|
95
|
+
console.log(`Observer count = ${dispersionCalculation.scalarUdmOutputs!.observerCount}`);
|
|
96
|
+
const lastDispersionRecord = dispersionCalculation.dispersionRecords!.at(-1)!;
|
|
97
|
+
console.log(`Final centreline concentration = ${lastDispersionRecord.centrelineConcentration}`);
|
|
98
|
+
console.log(`Final downwind distance = ${lastDispersionRecord.downwindDistance}`);
|
|
99
|
+
|
|
100
|
+
const dispersionOutputConfig = new DispersionOutputConfig({
|
|
101
|
+
concentration: endPointConcentration,
|
|
102
|
+
elevation,
|
|
103
|
+
resolution,
|
|
104
|
+
specialConcentration,
|
|
105
|
+
lflFractionValue: lflFraction,
|
|
106
|
+
componentToTrackName,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const maxConcDistanceCalculation = new MaxConcDistanceCalculation(
|
|
110
|
+
dispersionCalculation.scalarUdmOutputs!,
|
|
111
|
+
weather,
|
|
112
|
+
dispersionCalculation.dispersionRecords!,
|
|
113
|
+
dispersionCalculation.dispersionRecords!.length,
|
|
114
|
+
substrate,
|
|
115
|
+
dispersionOutputConfig,
|
|
116
|
+
ruptureCalculation.exitMaterial!,
|
|
117
|
+
dispersionParameters
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const maxDistanceResult = await maxConcDistanceCalculation.run();
|
|
121
|
+
|
|
122
|
+
if (maxConcDistanceCalculation.messages.length > 0) {
|
|
123
|
+
console.log("Messages:");
|
|
124
|
+
maxConcDistanceCalculation.messages.forEach((msg) => console.log(msg));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
expect(maxDistanceResult).toBe(ResultCode.SUCCESS);
|
|
128
|
+
|
|
129
|
+
const records = maxConcDistanceCalculation.concentrationRecords!;
|
|
130
|
+
expect(records.length).toBe(6);
|
|
131
|
+
|
|
132
|
+
const lastRecord = records.at(-1)!;
|
|
133
|
+
|
|
134
|
+
const expectedConcentration = 0.02586928069095842;
|
|
135
|
+
const expectedX = 26.782730275398364;
|
|
136
|
+
|
|
137
|
+
const concError = Math.abs((lastRecord.concentration! - expectedConcentration) / expectedConcentration);
|
|
138
|
+
const xError = Math.abs((lastRecord.position.x - expectedX) / expectedX);
|
|
139
|
+
|
|
140
|
+
expect(concError).toBeLessThan(1e-3);
|
|
141
|
+
expect(xError).toBeLessThan(1e-3);
|
|
142
|
+
|
|
143
|
+
console.log(`SUCCESS: max_conc_distance_calculation (${maxConcDistanceCalculation.calculationElapsedTime}ms)`);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Vessel, Substrate, Weather, DischargeParameters, DispersionParameters, DispersionOutputConfig } from "../../src/entities";
|
|
2
|
+
import { VesselStateCalculation, VesselCatastrophicRuptureCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { DispersionCalculation } from "../../src/calculations/dispersion";
|
|
4
|
+
import { MaxConcDistanceCalculation } from "../../src/calculations/dispersionView";
|
|
5
|
+
import { ResultCode, SurfaceType, AtmosphericStabilityClass, Resolution, SpecialConcentration, VesselShape, WindProfileFlag } from "../../src/enums";
|
|
6
|
+
import { setAccessToken } from "../../src/utilities";
|
|
7
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
8
|
+
|
|
9
|
+
if (!accessToken) {
|
|
10
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
setAccessToken(accessToken);
|
|
14
|
+
|
|
15
|
+
describe("Max Concentration Distance Calculation - Test Case 110", () => {
|
|
16
|
+
test("should match expected concentration regression for ETHANE", async () => {
|
|
17
|
+
const materialName = "ETHANE";
|
|
18
|
+
const endPointConcentration = 0.0;
|
|
19
|
+
const elevation = 3.0;
|
|
20
|
+
const resolution = Resolution.VERY_HIGH;
|
|
21
|
+
const specialConcentration = SpecialConcentration.UFL;
|
|
22
|
+
const lflFraction = 0.1;
|
|
23
|
+
const componentToTrackName = "";
|
|
24
|
+
const windProfileFlag = WindProfileFlag.LOGARITHMIC_PROFILE;
|
|
25
|
+
|
|
26
|
+
const material = new Material({
|
|
27
|
+
name: materialName,
|
|
28
|
+
components: [new MaterialComponent({ name: materialName })],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const state = new State({
|
|
32
|
+
temperature: 265.0,
|
|
33
|
+
pressure: 5.0e5,
|
|
34
|
+
liquidFraction: 0.0,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
38
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
39
|
+
|
|
40
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
41
|
+
console.log("Messages:");
|
|
42
|
+
vesselStateCalculation.messages.forEach((msg) => console.log(msg));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
46
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
47
|
+
|
|
48
|
+
const vessel = new Vessel({
|
|
49
|
+
state,
|
|
50
|
+
material,
|
|
51
|
+
liquidFillFractionByVolume: 0.8,
|
|
52
|
+
shape: VesselShape.VERTICAL_CYLINDER,
|
|
53
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const dischargeParameters = new DischargeParameters();
|
|
57
|
+
const vesselCatastrophicRuptureCalculation = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
58
|
+
const ruptureResult = await vesselCatastrophicRuptureCalculation.run();
|
|
59
|
+
|
|
60
|
+
if (vesselCatastrophicRuptureCalculation.messages.length > 0) {
|
|
61
|
+
console.log("Messages:");
|
|
62
|
+
vesselCatastrophicRuptureCalculation.messages.forEach((msg) => console.log(msg));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
expect(ruptureResult).toBe(ResultCode.SUCCESS);
|
|
66
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${vesselCatastrophicRuptureCalculation.calculationElapsedTime}ms)`);
|
|
67
|
+
|
|
68
|
+
const substrate = new Substrate();
|
|
69
|
+
const weather = new Weather({windProfileFlag: windProfileFlag});
|
|
70
|
+
const dispersionParameters = new DispersionParameters();
|
|
71
|
+
|
|
72
|
+
const dispersionCalculation = new DispersionCalculation(
|
|
73
|
+
vesselCatastrophicRuptureCalculation.exitMaterial!,
|
|
74
|
+
substrate,
|
|
75
|
+
vesselCatastrophicRuptureCalculation.dischargeResult!,
|
|
76
|
+
vesselCatastrophicRuptureCalculation.dischargeRecords!,
|
|
77
|
+
vesselCatastrophicRuptureCalculation.dischargeRecords!.length,
|
|
78
|
+
weather,
|
|
79
|
+
dispersionParameters,
|
|
80
|
+
endPointConcentration
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const dispersionResult = await dispersionCalculation.run();
|
|
84
|
+
|
|
85
|
+
if (dispersionCalculation.messages.length > 0) {
|
|
86
|
+
console.log("Messages:");
|
|
87
|
+
dispersionCalculation.messages.forEach((msg) => console.log(msg));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
expect(dispersionResult).toBe(ResultCode.SUCCESS);
|
|
91
|
+
console.log(`SUCCESS: dispersion_calculation (${dispersionCalculation.calculationElapsedTime}ms)`);
|
|
92
|
+
console.log(`Length dispersion records = ${dispersionCalculation.dispersionRecords!.length}`);
|
|
93
|
+
console.log(`Minimum concentration = ${dispersionCalculation.scalarUdmOutputs!.minimumConcentration}`);
|
|
94
|
+
console.log(`Observer count = ${dispersionCalculation.scalarUdmOutputs!.observerCount}`);
|
|
95
|
+
|
|
96
|
+
const lastDispersionRecord = dispersionCalculation.dispersionRecords!.at(-1)!;
|
|
97
|
+
console.log(`Final centreline concentration = ${lastDispersionRecord.centrelineConcentration}`);
|
|
98
|
+
console.log(`Final downwind distance = ${lastDispersionRecord.downwindDistance}`);
|
|
99
|
+
|
|
100
|
+
const dispersionOutputConfig = new DispersionOutputConfig({
|
|
101
|
+
concentration: endPointConcentration,
|
|
102
|
+
elevation,
|
|
103
|
+
resolution,
|
|
104
|
+
specialConcentration,
|
|
105
|
+
lflFractionValue: lflFraction,
|
|
106
|
+
componentToTrackName,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const maxConcDistanceCalculation = new MaxConcDistanceCalculation(
|
|
110
|
+
dispersionCalculation.scalarUdmOutputs!,
|
|
111
|
+
weather,
|
|
112
|
+
dispersionCalculation.dispersionRecords!,
|
|
113
|
+
dispersionCalculation.dispersionRecords!.length,
|
|
114
|
+
substrate,
|
|
115
|
+
dispersionOutputConfig,
|
|
116
|
+
vesselCatastrophicRuptureCalculation.exitMaterial!,
|
|
117
|
+
dispersionParameters
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const maxDistanceResult = await maxConcDistanceCalculation.run();
|
|
121
|
+
|
|
122
|
+
if (maxConcDistanceCalculation.messages.length > 0) {
|
|
123
|
+
console.log("Messages:");
|
|
124
|
+
maxConcDistanceCalculation.messages.forEach((msg) => console.log(msg));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
expect(maxDistanceResult).toBe(ResultCode.SUCCESS);
|
|
128
|
+
|
|
129
|
+
const records = maxConcDistanceCalculation.concentrationRecords!;
|
|
130
|
+
expect(records.length).toBe(418);
|
|
131
|
+
|
|
132
|
+
const lastRecord = records.at(-1)!;
|
|
133
|
+
|
|
134
|
+
const expectedConcentration = 0.11220565556406681;
|
|
135
|
+
const expectedX = 3.5835448524927003;
|
|
136
|
+
|
|
137
|
+
const concError = Math.abs((lastRecord.concentration! - expectedConcentration) / expectedConcentration);
|
|
138
|
+
const xError = Math.abs((lastRecord.position.x - expectedX) / expectedX);
|
|
139
|
+
|
|
140
|
+
expect(concError).toBeLessThan(1e-3);
|
|
141
|
+
expect(xError).toBeLessThan(1e-3);
|
|
142
|
+
|
|
143
|
+
console.log(`SUCCESS: max_conc_distance_calculation (${maxConcDistanceCalculation.calculationElapsedTime}ms)`);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|