@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,175 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Vessel, LineRupture, Weather, Substrate, DischargeParameters, DispersionParameters, DispersionOutputConfig, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume } from "../../src/entities";
|
|
2
|
+
import { VesselStateCalculation, VesselLineRuptureCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { DispersionCalculation } from "../../src/calculations/dispersion";
|
|
4
|
+
import { LateExplosionToOPLevelsCalculation, LateExplosionCalculation } from "../../src/calculations/lateExplosion";
|
|
5
|
+
import { ResultCode, AtmosphericStabilityClass, 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("Integrated Explosion Scenario - Test Case 77", () => {
|
|
16
|
+
test("should run the full explosion scenario and perform regression check", async () => {
|
|
17
|
+
// Define the initial state of the vessel
|
|
18
|
+
const state = new State({
|
|
19
|
+
temperature: 260.0,
|
|
20
|
+
pressure: 5e5,
|
|
21
|
+
liquidFraction: 1.0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Define the material contained by the vessel
|
|
25
|
+
const material = new Material({
|
|
26
|
+
name: "ETHANE_METHANE_HY",
|
|
27
|
+
components: [
|
|
28
|
+
new MaterialComponent({ name: "ETHANE", moleFraction: 0.15 }),
|
|
29
|
+
new MaterialComponent({ name: "METHANE", moleFraction: 0.8 }),
|
|
30
|
+
new MaterialComponent({ name: "HYDROGEN", moleFraction: 0.05 })
|
|
31
|
+
],
|
|
32
|
+
componentCount: 3
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Create and run vessel state calculation
|
|
36
|
+
const vesselStateCalc = new VesselStateCalculation(material, state);
|
|
37
|
+
|
|
38
|
+
console.log("Running vesselStateCalculation...");
|
|
39
|
+
let resultCode = await vesselStateCalc.run();
|
|
40
|
+
|
|
41
|
+
if (vesselStateCalc.messages.length > 0) {
|
|
42
|
+
console.log("Messages:");
|
|
43
|
+
vesselStateCalc.messages.forEach((msg) => console.log(msg));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
47
|
+
console.log(`SUCCESS: vesselStateCalculation (${vesselStateCalc.calculationElapsedTime}ms)`);
|
|
48
|
+
|
|
49
|
+
// Create vessel (sphere with 3m diameter)
|
|
50
|
+
const vessel = new Vessel({
|
|
51
|
+
state,
|
|
52
|
+
material,
|
|
53
|
+
vesselConditions: vesselStateCalc.vesselConditions,
|
|
54
|
+
liquidFillFractionByVolume: 0.7,
|
|
55
|
+
shape: VesselShape.VESSEL_SPHERE,
|
|
56
|
+
diameter: 3
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Create line rupture
|
|
60
|
+
const lineRupture = new LineRupture({
|
|
61
|
+
pipeDiameter: 0.5,
|
|
62
|
+
pipeLength: 1.0,
|
|
63
|
+
pipeHeightFraction: 0.5
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Create and run vessel line rupture calculation
|
|
67
|
+
const lineRuptureCalc = new VesselLineRuptureCalculation(vessel, lineRupture, new DischargeParameters());
|
|
68
|
+
|
|
69
|
+
console.log("Running vesselLineRuptureCalculation...");
|
|
70
|
+
resultCode = await lineRuptureCalc.run();
|
|
71
|
+
|
|
72
|
+
if (lineRuptureCalc.messages.length > 0) {
|
|
73
|
+
console.log("Messages:");
|
|
74
|
+
lineRuptureCalc.messages.forEach((msg) => console.log(msg));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
78
|
+
console.log(`SUCCESS: vesselLineRuptureCalculation (${lineRuptureCalc.calculationElapsedTime}ms)`);
|
|
79
|
+
console.log(`vesselLineRuptureCalculation.dischargeResult.releaseMass: ${lineRuptureCalc.dischargeResult!.releaseMass} [kg]`);
|
|
80
|
+
|
|
81
|
+
const exitMaterial = lineRuptureCalc.exitMaterial!;
|
|
82
|
+
|
|
83
|
+
// Define weather
|
|
84
|
+
const weather = new Weather({
|
|
85
|
+
windSpeed: 1.5,
|
|
86
|
+
stabilityClass: AtmosphericStabilityClass.STABILITY_F,
|
|
87
|
+
windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Define substrate
|
|
91
|
+
const substrate = new Substrate();
|
|
92
|
+
|
|
93
|
+
// Create and run dispersion calculation
|
|
94
|
+
const dispersionCalc = new DispersionCalculation(
|
|
95
|
+
exitMaterial,
|
|
96
|
+
substrate,
|
|
97
|
+
lineRuptureCalc.dischargeResult!,
|
|
98
|
+
lineRuptureCalc.dischargeRecords!,
|
|
99
|
+
lineRuptureCalc.dischargeRecords!.length,
|
|
100
|
+
weather,
|
|
101
|
+
new DispersionParameters(),
|
|
102
|
+
0.0
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
console.log("Running dispersionCalculation...");
|
|
106
|
+
resultCode = await dispersionCalc.run();
|
|
107
|
+
|
|
108
|
+
if (dispersionCalc.messages.length > 0) {
|
|
109
|
+
console.log("Messages:");
|
|
110
|
+
dispersionCalc.messages.forEach((msg) => console.log(msg));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
114
|
+
console.log(`SUCCESS: dispersionCalculation (${dispersionCalc.calculationElapsedTime}ms)`);
|
|
115
|
+
|
|
116
|
+
// Define explosion configurations
|
|
117
|
+
const dispersionOutputConfig = new DispersionOutputConfig({
|
|
118
|
+
concentration: 0.0,
|
|
119
|
+
specialConcentration: SpecialConcentration.MIN
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const explosionParams = new ExplosionParameters({
|
|
123
|
+
explosionUniformStrength: 8.0
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const explosionOutputConfigs = new ExplosionOutputConfig({ overpressureLevel: 20680, meConfinedMethod: 1 });
|
|
127
|
+
|
|
128
|
+
const explosionConfinedVolumes = [
|
|
129
|
+
new ExplosionConfinedVolume({ confinedVolume: 100, confinedStrength: 10 }),
|
|
130
|
+
new ExplosionConfinedVolume({ confinedVolume: 25, confinedStrength: 7 })
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
// Create and run explosion calculation
|
|
134
|
+
const explosionCalc = new LateExplosionCalculation(
|
|
135
|
+
exitMaterial,
|
|
136
|
+
dispersionCalc.scalarUdmOutputs!,
|
|
137
|
+
weather,
|
|
138
|
+
dispersionCalc.dispersionRecords!,
|
|
139
|
+
dispersionCalc.dispersionRecords!.length,
|
|
140
|
+
substrate,
|
|
141
|
+
dispersionOutputConfig,
|
|
142
|
+
explosionOutputConfigs,
|
|
143
|
+
explosionParams,
|
|
144
|
+
explosionConfinedVolumes,
|
|
145
|
+
explosionConfinedVolumes.length,
|
|
146
|
+
new DispersionParameters()
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
console.log("Running lateExplosionCalculation...");
|
|
150
|
+
resultCode = await explosionCalc.run();
|
|
151
|
+
|
|
152
|
+
if (explosionCalc.messages.length > 0) {
|
|
153
|
+
console.log("Messages:");
|
|
154
|
+
explosionCalc.messages.forEach((msg) => console.log(msg));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
158
|
+
|
|
159
|
+
// Regression checks
|
|
160
|
+
const result = explosionCalc.explosionUnifConfOverpressureResult!;
|
|
161
|
+
const expectedMass = 31.04536142489174;
|
|
162
|
+
const expectedTime = 1.1859455812737545;
|
|
163
|
+
const expectedDistance = 74.63993525895671;
|
|
164
|
+
|
|
165
|
+
const massError = Math.abs((result.explodedMass! - expectedMass) / expectedMass);
|
|
166
|
+
const timeError = Math.abs((result.ignitionTime! - expectedTime) / expectedTime);
|
|
167
|
+
const distanceError = Math.abs((result.maximumDistance! - expectedDistance) / expectedDistance);
|
|
168
|
+
|
|
169
|
+
expect(massError).toBeLessThan(1e-3);
|
|
170
|
+
expect(timeError).toBeLessThan(1e-3);
|
|
171
|
+
expect(distanceError).toBeLessThan(1e-3);
|
|
172
|
+
|
|
173
|
+
console.log(`SUCCESS: lateExplosionCalculation (${explosionCalc.calculationElapsedTime}ms)`);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Vessel, LineRupture, Weather, Substrate, DischargeParameters, DispersionParameters, DispersionOutputConfig, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume } from "../../src/entities";
|
|
2
|
+
import { VesselStateCalculation, VesselLineRuptureCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { DispersionCalculation } from "../../src/calculations/dispersion";
|
|
4
|
+
import { LateExplosionCalculation } from "../../src/calculations/lateExplosion";
|
|
5
|
+
import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, VesselShape, MEConfinedMethod, 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("Integrated Explosion Scenario - Test Case 78", () => {
|
|
16
|
+
test("should run the full explosion scenario and perform regression check", async () => {
|
|
17
|
+
// Define the initial state of the vessel
|
|
18
|
+
const state = new State({
|
|
19
|
+
temperature: 250.0,
|
|
20
|
+
pressure: 3.0e5,
|
|
21
|
+
liquidFraction: 1.0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Define the material contained by the vessel
|
|
25
|
+
const material = new Material({
|
|
26
|
+
name: "PROPANE",
|
|
27
|
+
components: [new MaterialComponent({ name: "PROPANE", moleFraction: 1.0 })]
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create and run vessel state calculation
|
|
31
|
+
const vesselStateCalc = new VesselStateCalculation(material, state);
|
|
32
|
+
|
|
33
|
+
console.log("Running vesselStateCalculation...");
|
|
34
|
+
let resultCode = await vesselStateCalc.run();
|
|
35
|
+
|
|
36
|
+
if (vesselStateCalc.messages.length > 0) {
|
|
37
|
+
console.log("Messages:");
|
|
38
|
+
vesselStateCalc.messages.forEach((msg) => console.log(msg));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
42
|
+
console.log(`SUCCESS: vesselStateCalculation (${vesselStateCalc.calculationElapsedTime}ms)`);
|
|
43
|
+
|
|
44
|
+
// Create vessel (horizontal cylinder with 2m diameter and 5m length)
|
|
45
|
+
const vessel = new Vessel({
|
|
46
|
+
state,
|
|
47
|
+
material,
|
|
48
|
+
vesselConditions: vesselStateCalc.vesselConditions,
|
|
49
|
+
liquidFillFractionByVolume: 0.7,
|
|
50
|
+
shape: VesselShape.HORIZONTAL_CYLINDER,
|
|
51
|
+
diameter: 2,
|
|
52
|
+
length: 5
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Create line rupture
|
|
56
|
+
const lineRupture = new LineRupture({
|
|
57
|
+
pipeDiameter: 0.1,
|
|
58
|
+
pipeLength: 5.0,
|
|
59
|
+
pipeHeightFraction: 0.3
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Create and run vessel line rupture calculation
|
|
63
|
+
const vesselLineRuptureCalc = new VesselLineRuptureCalculation(vessel, lineRupture, new DischargeParameters());
|
|
64
|
+
|
|
65
|
+
console.log("Running vesselLineRuptureCalculation...");
|
|
66
|
+
resultCode = await vesselLineRuptureCalc.run();
|
|
67
|
+
|
|
68
|
+
if (vesselLineRuptureCalc.messages.length > 0) {
|
|
69
|
+
console.log("Messages:");
|
|
70
|
+
vesselLineRuptureCalc.messages.forEach((msg) => console.log(msg));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
74
|
+
console.log(`SUCCESS: vesselLineRuptureCalculation (${vesselLineRuptureCalc.calculationElapsedTime}ms)`);
|
|
75
|
+
console.log(`vesselLineRuptureCalculation.dischargeResult.releaseMass: ${vesselLineRuptureCalc.dischargeResult!.releaseMass} [kg]`);
|
|
76
|
+
|
|
77
|
+
const exitMaterial = vesselLineRuptureCalc.exitMaterial!;
|
|
78
|
+
|
|
79
|
+
// Define weather
|
|
80
|
+
const weather = new Weather({
|
|
81
|
+
windSpeed: 1.5,
|
|
82
|
+
stabilityClass: AtmosphericStabilityClass.STABILITY_F,
|
|
83
|
+
windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Define substrate
|
|
87
|
+
const substrate = new Substrate();
|
|
88
|
+
|
|
89
|
+
// Create and run dispersion calculation
|
|
90
|
+
const dispersionCalc = new DispersionCalculation(
|
|
91
|
+
exitMaterial,
|
|
92
|
+
substrate,
|
|
93
|
+
vesselLineRuptureCalc.dischargeResult!,
|
|
94
|
+
vesselLineRuptureCalc.dischargeRecords!,
|
|
95
|
+
vesselLineRuptureCalc.dischargeRecords!.length,
|
|
96
|
+
weather,
|
|
97
|
+
new DispersionParameters(),
|
|
98
|
+
0.0
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
console.log("Running dispersionCalculation...");
|
|
102
|
+
resultCode = await dispersionCalc.run();
|
|
103
|
+
|
|
104
|
+
if (dispersionCalc.messages.length > 0) {
|
|
105
|
+
console.log("Messages:");
|
|
106
|
+
dispersionCalc.messages.forEach((msg) => console.log(msg));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
110
|
+
console.log(`SUCCESS: dispersionCalculation (${dispersionCalc.calculationElapsedTime}ms)`);
|
|
111
|
+
|
|
112
|
+
// Define explosion configurations
|
|
113
|
+
const dispersionOutputConfig = new DispersionOutputConfig({
|
|
114
|
+
concentration: 0.0,
|
|
115
|
+
specialConcentration: SpecialConcentration.MIN
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const explosionParams = new ExplosionParameters({
|
|
119
|
+
explosionUniformStrength: 10.0
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const explosionOutputConfig = new ExplosionOutputConfig({
|
|
123
|
+
overpressureLevel: 8272,
|
|
124
|
+
meConfinedMethod: MEConfinedMethod.USER_DEFINED
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const explosionConfinedVolumes = [
|
|
128
|
+
new ExplosionConfinedVolume({ confinedVolume: 167, confinedStrength: 9 }),
|
|
129
|
+
new ExplosionConfinedVolume({ confinedVolume: 33, confinedStrength: 10 }),
|
|
130
|
+
new ExplosionConfinedVolume({ confinedVolume: 300, confinedStrength: 6 })
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
// Create and run explosion calculation
|
|
134
|
+
const explosionCalc = new LateExplosionCalculation(
|
|
135
|
+
exitMaterial,
|
|
136
|
+
dispersionCalc.scalarUdmOutputs!,
|
|
137
|
+
weather,
|
|
138
|
+
dispersionCalc.dispersionRecords!,
|
|
139
|
+
dispersionCalc.dispersionRecords!.length,
|
|
140
|
+
substrate,
|
|
141
|
+
dispersionOutputConfig,
|
|
142
|
+
explosionOutputConfig,
|
|
143
|
+
explosionParams,
|
|
144
|
+
explosionConfinedVolumes,
|
|
145
|
+
explosionConfinedVolumes.length,
|
|
146
|
+
new DispersionParameters()
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
console.log("Running lateExplosionCalculation...");
|
|
150
|
+
resultCode = await explosionCalc.run();
|
|
151
|
+
|
|
152
|
+
if (explosionCalc.messages.length > 0) {
|
|
153
|
+
console.log("Messages:");
|
|
154
|
+
explosionCalc.messages.forEach((msg) => console.log(msg));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
158
|
+
|
|
159
|
+
// Regression checks
|
|
160
|
+
const result = explosionCalc.explosionUnifConfOverpressureResult!;
|
|
161
|
+
const expectedMass = 1081.1427088939722;
|
|
162
|
+
const expectedTime = 96.0561524166236;
|
|
163
|
+
const expectedDistance = 272.08706213990797;
|
|
164
|
+
|
|
165
|
+
const massError = Math.abs((result.explodedMass! - expectedMass) / expectedMass);
|
|
166
|
+
const timeError = Math.abs((result.ignitionTime! - expectedTime) / expectedTime);
|
|
167
|
+
const distanceError = Math.abs((result.maximumDistance! - expectedDistance) / expectedDistance);
|
|
168
|
+
|
|
169
|
+
expect(massError).toBeLessThan(1e-3);
|
|
170
|
+
expect(timeError).toBeLessThan(1e-3);
|
|
171
|
+
expect(distanceError).toBeLessThan(1e-3);
|
|
172
|
+
|
|
173
|
+
console.log(`SUCCESS: lateExplosionCalculation (${explosionCalc.calculationElapsedTime}ms)`);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Bund, DischargeParameters, DispersionOutputConfig, DispersionParameters, Material, MaterialComponent, State, Substrate, Vessel, Weather } from "../../src/entities";
|
|
2
|
+
import { VesselCatastrophicRuptureCalculation, VesselStateCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { DispersionCalculation } from "../../src/calculations/dispersion";
|
|
4
|
+
import { LethalityDistanceCalculation } from "../../src/calculations/toxics";
|
|
5
|
+
import { AtmosphericStabilityClass, ResultCode, SurfaceType, 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("Lethality Distance Calculation - Test Case 60", () => {
|
|
16
|
+
test("should perform the full chain of calculations and validate results", async () => {
|
|
17
|
+
const materialName = "CARBON DIOXIDE (TOXIC)";
|
|
18
|
+
const stateTemperature = 280.0;
|
|
19
|
+
const statePressure = 8.0e6;
|
|
20
|
+
const liquidFraction = 0.8;
|
|
21
|
+
const vesselShape = VesselShape.VESSEL_SPHERE;
|
|
22
|
+
const vesselDiameter = 5.0;
|
|
23
|
+
const liquidFillFractionByVolume = 0.8;
|
|
24
|
+
const surfaceType = SurfaceType.LAND;
|
|
25
|
+
const surfaceRoughness = 0.2;
|
|
26
|
+
const windSpeed = 5.0;
|
|
27
|
+
const stabilityClass = AtmosphericStabilityClass.STABILITY_A_;
|
|
28
|
+
const endPointConcentration = 0.0;
|
|
29
|
+
const specifyBund = true;
|
|
30
|
+
const bundHeight = 1.0;
|
|
31
|
+
const bundDiameter = 8.0;
|
|
32
|
+
const windProfileFlag = WindProfileFlag.LOGARITHMIC_PROFILE;
|
|
33
|
+
|
|
34
|
+
const material = new Material({
|
|
35
|
+
name: materialName,
|
|
36
|
+
components: [new MaterialComponent({ name: materialName, moleFraction: 1.0 })],
|
|
37
|
+
componentCount: 1,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const state = new State({
|
|
41
|
+
temperature: stateTemperature,
|
|
42
|
+
pressure: statePressure,
|
|
43
|
+
liquidFraction,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
47
|
+
console.log("Running vessel_state_calculation...");
|
|
48
|
+
let resultCode = await vesselStateCalculation.run();
|
|
49
|
+
|
|
50
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
51
|
+
console.log("Messages:");
|
|
52
|
+
vesselStateCalculation.messages.forEach((msg) => console.log(msg));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
56
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
57
|
+
|
|
58
|
+
const vessel = new Vessel({
|
|
59
|
+
state,
|
|
60
|
+
material,
|
|
61
|
+
liquidFillFractionByVolume,
|
|
62
|
+
shape: vesselShape,
|
|
63
|
+
diameter: vesselDiameter,
|
|
64
|
+
vesselConditions: vesselStateCalculation.vesselConditions!,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const dischargeParameters = new DischargeParameters();
|
|
68
|
+
const vesselCatastrophicRuptureCalculation = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
69
|
+
|
|
70
|
+
console.log("Running vessel_catastrophic_rupture_calculation...");
|
|
71
|
+
resultCode = await vesselCatastrophicRuptureCalculation.run();
|
|
72
|
+
|
|
73
|
+
if (vesselCatastrophicRuptureCalculation.messages.length > 0) {
|
|
74
|
+
console.log("Messages:");
|
|
75
|
+
vesselCatastrophicRuptureCalculation.messages.forEach((msg) => console.log(msg));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
79
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${vesselCatastrophicRuptureCalculation.calculationElapsedTime}ms)`);
|
|
80
|
+
|
|
81
|
+
const bund = new Bund({ specifyBund, bundHeight, bundDiameter });
|
|
82
|
+
const substrate = new Substrate({ bund, surfaceType, surfaceRoughness });
|
|
83
|
+
const weather = new Weather({ windSpeed: windSpeed, stabilityClass: stabilityClass, windProfileFlag: windProfileFlag });
|
|
84
|
+
const dispersionParameters = new DispersionParameters();
|
|
85
|
+
|
|
86
|
+
const dispersionCalculation = new DispersionCalculation(
|
|
87
|
+
vesselCatastrophicRuptureCalculation.exitMaterial!,
|
|
88
|
+
substrate,
|
|
89
|
+
vesselCatastrophicRuptureCalculation.dischargeResult!,
|
|
90
|
+
vesselCatastrophicRuptureCalculation.dischargeRecords!,
|
|
91
|
+
vesselCatastrophicRuptureCalculation.dischargeRecords!.length,
|
|
92
|
+
weather,
|
|
93
|
+
dispersionParameters,
|
|
94
|
+
endPointConcentration,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
console.log("Running dispersion_calculation...");
|
|
98
|
+
resultCode = await dispersionCalculation.run();
|
|
99
|
+
|
|
100
|
+
if (dispersionCalculation.messages.length > 0) {
|
|
101
|
+
console.log("Messages:");
|
|
102
|
+
dispersionCalculation.messages.forEach((msg) => console.log(msg));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
106
|
+
console.log(`SUCCESS: dispersion_calculation (${dispersionCalculation.calculationElapsedTime}ms)`);
|
|
107
|
+
|
|
108
|
+
const dispersionOutputConfig = new DispersionOutputConfig({ concentration: endPointConcentration });
|
|
109
|
+
|
|
110
|
+
const lethalityDistanceCalculation = new LethalityDistanceCalculation(
|
|
111
|
+
vesselCatastrophicRuptureCalculation.exitMaterial!,
|
|
112
|
+
dispersionCalculation.scalarUdmOutputs!,
|
|
113
|
+
weather,
|
|
114
|
+
dispersionCalculation.dispersionRecords!,
|
|
115
|
+
dispersionCalculation.dispersionRecords!.length,
|
|
116
|
+
substrate,
|
|
117
|
+
dispersionOutputConfig,
|
|
118
|
+
dispersionParameters,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
console.log("Running lethality_distance_calculation...");
|
|
122
|
+
resultCode = await lethalityDistanceCalculation.run();
|
|
123
|
+
|
|
124
|
+
if (lethalityDistanceCalculation.messages.length > 0) {
|
|
125
|
+
console.log("Messages:");
|
|
126
|
+
lethalityDistanceCalculation.messages.forEach((msg) => console.log(msg));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
130
|
+
expect(lethalityDistanceCalculation.toxicRecords!.length).toBe(1830);
|
|
131
|
+
|
|
132
|
+
if (lethalityDistanceCalculation.toxicRecords!.length > 0) {
|
|
133
|
+
const last = lethalityDistanceCalculation.toxicRecords![lethalityDistanceCalculation.toxicRecords!.length - 1];
|
|
134
|
+
const expectedLastToxicResult = 0.0004837476263379603;
|
|
135
|
+
const relativeError = Math.abs((last.toxicResult! - expectedLastToxicResult) / expectedLastToxicResult);
|
|
136
|
+
expect(relativeError).toBeLessThan(1e-3);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
console.log(`SUCCESS: lethality_distance_calculation (${lethalityDistanceCalculation.calculationElapsedTime}ms)`);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { UserDefinedSourceLinkedRunCalculation } from "../../../src/calculations/linkedRunners";
|
|
2
|
+
import { Material, MaterialComponent, Weather, Substrate, DischargeParameters, FlammableParameters, DispersionParameters, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume, FlammableOutputConfig, DispersionOutputConfig, State, DischargeRecord, DischargeResult } from "../../../src/entities";
|
|
3
|
+
import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, WindProfileFlag, Phase, FluidSpec, DynamicType} from "../../../src/enums";
|
|
4
|
+
import { setAccessToken } from "../../../src/utilities";
|
|
5
|
+
|
|
6
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
7
|
+
|
|
8
|
+
if (!accessToken) {
|
|
9
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
setAccessToken(accessToken);
|
|
13
|
+
|
|
14
|
+
describe("UserDefinedSourceLinkedRunCalculation - VLR_153", () => {
|
|
15
|
+
it("should run the calculation and validate regression outputs", async () => {
|
|
16
|
+
const material = new Material({name: "AMMONIA", components: [new MaterialComponent({ name: "AMMONIA", moleFraction: 1.0 })], componentCount: 1});
|
|
17
|
+
|
|
18
|
+
const weather = new Weather({ windSpeed: 5.0, stabilityClass: AtmosphericStabilityClass.STABILITY_B, windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE});
|
|
19
|
+
|
|
20
|
+
const substrate = new Substrate({surfaceRoughness: 0.01});
|
|
21
|
+
|
|
22
|
+
const dispersionParameters = [
|
|
23
|
+
new DispersionParameters({averagingTime: 18.75}),
|
|
24
|
+
new DispersionParameters({averagingTime: 600.0})
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const dispersionOutputConfigsFlammable = [
|
|
28
|
+
new DispersionOutputConfig({ specialConcentration: SpecialConcentration.LFL_FRACTION, elevation: 0.0})
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const dispersionOutputConfigsToxic = [
|
|
32
|
+
new DispersionOutputConfig({ specialConcentration: SpecialConcentration.NOT_DEFINED, elevation: 0.0, concentration: 5e-5})
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const flammableParameters = new FlammableParameters();
|
|
36
|
+
const flammableOutputConfigs = [new FlammableOutputConfig()];
|
|
37
|
+
|
|
38
|
+
const explosionParameters = new ExplosionParameters();
|
|
39
|
+
const explosionOutputConfigs = [new ExplosionOutputConfig()];
|
|
40
|
+
const explosionConfinedVolumes = [new ExplosionConfinedVolume()];
|
|
41
|
+
|
|
42
|
+
const dischargeRecord = new DischargeRecord({
|
|
43
|
+
massFlow: 50.0,
|
|
44
|
+
time: 600.0,
|
|
45
|
+
finalState: new State({temperature: 200.0, pressure: 101325.0, flashFlag: FluidSpec.TP, liquidFraction: 1.0}),
|
|
46
|
+
orificeState: new State({temperature: 300.0, pressure: 101325.0, liquidFraction: 1.0}),
|
|
47
|
+
orificeVelocity: 0.0,
|
|
48
|
+
storageState: new State({temperature: 300.0, pressure: 101325.0, liquidFraction: 1.0}),
|
|
49
|
+
finalVelocity: 60.0,
|
|
50
|
+
dropletDiameter: 0.0009
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const dischargeResult = new DischargeResult({
|
|
54
|
+
releaseMass: 3000.0,
|
|
55
|
+
height: 0.0,
|
|
56
|
+
angle: 0.0,
|
|
57
|
+
holeDiameter: 0.3,
|
|
58
|
+
releaseType: DynamicType.CONTINUOUS,
|
|
59
|
+
preDilutionAirRate: 0.0,
|
|
60
|
+
expansionEnergy: 6000.0
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const calculation = new UserDefinedSourceLinkedRunCalculation(
|
|
64
|
+
material,
|
|
65
|
+
dischargeResult,
|
|
66
|
+
[dischargeRecord],
|
|
67
|
+
1,
|
|
68
|
+
Phase.LIQUID,
|
|
69
|
+
new DischargeParameters(),
|
|
70
|
+
substrate,
|
|
71
|
+
weather,
|
|
72
|
+
dispersionParameters,
|
|
73
|
+
2,
|
|
74
|
+
0.0,
|
|
75
|
+
flammableParameters,
|
|
76
|
+
explosionParameters,
|
|
77
|
+
dispersionOutputConfigsFlammable,
|
|
78
|
+
1,
|
|
79
|
+
dispersionOutputConfigsToxic,
|
|
80
|
+
1,
|
|
81
|
+
flammableOutputConfigs,
|
|
82
|
+
1,
|
|
83
|
+
explosionOutputConfigs,
|
|
84
|
+
1,
|
|
85
|
+
explosionConfinedVolumes,
|
|
86
|
+
1
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
console.log("Running user_defined_source_linked_run_calculation...");
|
|
90
|
+
const resultCode = await calculation.run();
|
|
91
|
+
|
|
92
|
+
if (calculation.messages.length > 0) {
|
|
93
|
+
console.log("Messages:");
|
|
94
|
+
calculation.messages.forEach((msg) => console.log(msg));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
98
|
+
|
|
99
|
+
if (resultCode === ResultCode.SUCCESS) {
|
|
100
|
+
expect(calculation.jetFireFlameResult!.flameLength).toBe(0.0);
|
|
101
|
+
expect(
|
|
102
|
+
Math.abs(calculation.poolFireFlameResult!.flameDiameter! - 87.63609313964844) / 87.63609313964844
|
|
103
|
+
).toBeLessThan(1e-3);
|
|
104
|
+
expect(calculation.flamConcContourPoints!.length).toBe(0);
|
|
105
|
+
expect(calculation.toxicConcContourPoints!.length).toBe(637);
|
|
106
|
+
expect(calculation.areaFootprintFlamConc![0]).toBe(0.0);
|
|
107
|
+
expect(
|
|
108
|
+
Math.abs(calculation.areaFootprintToxicConc![0] - 940696.3465428002) / 940696.3465428002
|
|
109
|
+
).toBeLessThan(1e-3);
|
|
110
|
+
expect(calculation.areaContourJet![0]).toBe(0.0);
|
|
111
|
+
expect(
|
|
112
|
+
Math.abs(calculation.areaContourPool![0] - 25251.117265661516) / 25251.117265661516
|
|
113
|
+
).toBeLessThan(1e-3);
|
|
114
|
+
expect(calculation.explosionOverpressureResults![0].explodedMass).toBe(0.0);
|
|
115
|
+
expect(calculation.explosionOverpressureResults![0].maximumDistance).toBe(0.0);
|
|
116
|
+
|
|
117
|
+
console.log(`SUCCESS: user_defined_source_linked_run_calculation (${calculation.calculationElapsedTime}ms)`);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|