@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,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VesselCatastrophicRuptureCalculation,
|
|
3
|
+
VesselStateCalculation,
|
|
4
|
+
} from "../../src/calculations/discharge";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Material,
|
|
8
|
+
MaterialComponent,
|
|
9
|
+
State,
|
|
10
|
+
Vessel,
|
|
11
|
+
DischargeParameters
|
|
12
|
+
} from "../../src/entities";
|
|
13
|
+
|
|
14
|
+
import { ResultCode, VesselShape } from "../../src/enums";
|
|
15
|
+
import { setAccessToken } from "../../src/utilities";
|
|
16
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
17
|
+
|
|
18
|
+
if (!accessToken) {
|
|
19
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setAccessToken(accessToken);
|
|
23
|
+
describe("Test Case - Vessel Catastrophic Rupture Calculation for AMMONIA", () => {
|
|
24
|
+
test("should correctly compute release mass and expansion energy", async () => {
|
|
25
|
+
const material = new Material({
|
|
26
|
+
name: "AMMONIA",
|
|
27
|
+
components: [
|
|
28
|
+
new MaterialComponent({
|
|
29
|
+
name: "AMMONIA",
|
|
30
|
+
moleFraction: 1.0
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const state = new State({
|
|
36
|
+
temperature: 250.0,
|
|
37
|
+
pressure: 5.0e6,
|
|
38
|
+
liquidFraction: 0.8
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
42
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
43
|
+
|
|
44
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
45
|
+
console.log("Messages:");
|
|
46
|
+
vesselStateCalculation.messages.forEach(msg => console.log(msg));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
50
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
51
|
+
|
|
52
|
+
const vessel = new Vessel({
|
|
53
|
+
state: state,
|
|
54
|
+
material: material,
|
|
55
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
56
|
+
liquidFillFractionByVolume: 0.8,
|
|
57
|
+
diameter: 2.0,
|
|
58
|
+
length: 5,
|
|
59
|
+
shape: VesselShape.HORIZONTAL_CYLINDER
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const dischargeParameters = new DischargeParameters();
|
|
63
|
+
const catastrophicRupture = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
64
|
+
|
|
65
|
+
console.log("Running vessel_catastrophic_rupture_calculation...");
|
|
66
|
+
const resultCode = await catastrophicRupture.run();
|
|
67
|
+
|
|
68
|
+
if (catastrophicRupture.messages.length > 0) {
|
|
69
|
+
console.log("Messages:");
|
|
70
|
+
catastrophicRupture.messages.forEach(msg => console.log(msg));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
74
|
+
|
|
75
|
+
const releaseMass = catastrophicRupture.dischargeResult!.releaseMass!;
|
|
76
|
+
const expansionEnergy = catastrophicRupture.dischargeResult!.expansionEnergy!;
|
|
77
|
+
|
|
78
|
+
expect(Math.abs((releaseMass - 8403.10476066265) / 8403.10476066265)).toBeLessThan(1e-3);
|
|
79
|
+
expect(Math.abs((expansionEnergy - 399.5722780225985) / 399.5722780225985)).toBeLessThan(1e-3);
|
|
80
|
+
|
|
81
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${catastrophicRupture.calculationElapsedTime}ms)`);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VesselCatastrophicRuptureCalculation,
|
|
3
|
+
VesselStateCalculation,
|
|
4
|
+
} from "../../src/calculations/discharge";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Material,
|
|
8
|
+
MaterialComponent,
|
|
9
|
+
State,
|
|
10
|
+
Vessel,
|
|
11
|
+
DischargeParameters
|
|
12
|
+
} from "../../src/entities";
|
|
13
|
+
|
|
14
|
+
import { ResultCode, VesselShape } from "../../src/enums";
|
|
15
|
+
import { setAccessToken } from "../../src/utilities";
|
|
16
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
17
|
+
|
|
18
|
+
if (!accessToken) {
|
|
19
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setAccessToken(accessToken);
|
|
23
|
+
describe("Test Case - Vessel Catastrophic Rupture Calculation for CHLORINE", () => {
|
|
24
|
+
test("should correctly compute release mass and expansion energy", async () => {
|
|
25
|
+
const material = new Material({
|
|
26
|
+
name: "CHLORINE",
|
|
27
|
+
components: [
|
|
28
|
+
new MaterialComponent({
|
|
29
|
+
name: "CHLORINE",
|
|
30
|
+
moleFraction: 1.0
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const state = new State({
|
|
36
|
+
temperature: 300.0,
|
|
37
|
+
pressure: 5.0e6,
|
|
38
|
+
liquidFraction: 0.8
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
42
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
43
|
+
|
|
44
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
45
|
+
console.log("Messages:");
|
|
46
|
+
vesselStateCalculation.messages.forEach(msg => console.log(msg));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
50
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
51
|
+
|
|
52
|
+
const vessel = new Vessel({
|
|
53
|
+
state: state,
|
|
54
|
+
material: material,
|
|
55
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
56
|
+
liquidFillFractionByVolume: 0.8,
|
|
57
|
+
diameter: 2.0,
|
|
58
|
+
shape: VesselShape.VESSEL_SPHERE
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const dischargeParameters = new DischargeParameters();
|
|
62
|
+
const catastrophicRupture = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
63
|
+
|
|
64
|
+
console.log("Running vessel_catastrophic_rupture_calculation...");
|
|
65
|
+
const resultCode = await catastrophicRupture.run();
|
|
66
|
+
|
|
67
|
+
if (catastrophicRupture.messages.length > 0) {
|
|
68
|
+
console.log("Messages:");
|
|
69
|
+
catastrophicRupture.messages.forEach(msg => console.log(msg));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
73
|
+
|
|
74
|
+
const releaseMass = catastrophicRupture.dischargeResult!.releaseMass!;
|
|
75
|
+
const expansionEnergy = catastrophicRupture.dischargeResult!.expansionEnergy!;
|
|
76
|
+
|
|
77
|
+
expect(Math.abs((releaseMass - 4651.875667954904) / 4651.875667954904)).toBeLessThan(1e-3);
|
|
78
|
+
expect(Math.abs((expansionEnergy - 385.60331992903724) / 385.60331992903724)).toBeLessThan(1e-3);
|
|
79
|
+
|
|
80
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${catastrophicRupture.calculationElapsedTime}ms)`);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VesselCatastrophicRuptureCalculation,
|
|
3
|
+
VesselStateCalculation,
|
|
4
|
+
} from "../../src/calculations/discharge";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Material,
|
|
8
|
+
MaterialComponent,
|
|
9
|
+
State,
|
|
10
|
+
Vessel,
|
|
11
|
+
DischargeParameters
|
|
12
|
+
} from "../../src/entities";
|
|
13
|
+
|
|
14
|
+
import { ResultCode, VesselShape } from "../../src/enums";
|
|
15
|
+
import { setAccessToken } from "../../src/utilities";
|
|
16
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
17
|
+
|
|
18
|
+
if (!accessToken) {
|
|
19
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setAccessToken(accessToken);
|
|
23
|
+
describe("Test Case - Vessel Catastrophic Rupture Calculation for ETHANE_BUTANE_PROPANE", () => {
|
|
24
|
+
test("should correctly compute release mass and expansion energy", async () => {
|
|
25
|
+
const material = new Material({
|
|
26
|
+
name: "ETHANE_BUTANE_PROPANE",
|
|
27
|
+
components: [
|
|
28
|
+
new MaterialComponent({
|
|
29
|
+
name: "ETHANE",
|
|
30
|
+
moleFraction: 0.5
|
|
31
|
+
}),
|
|
32
|
+
new MaterialComponent({
|
|
33
|
+
name: "N-BUTANE",
|
|
34
|
+
moleFraction: 0.3
|
|
35
|
+
}),
|
|
36
|
+
new MaterialComponent({
|
|
37
|
+
name: "PROPANE",
|
|
38
|
+
moleFraction: 0.2
|
|
39
|
+
})
|
|
40
|
+
],
|
|
41
|
+
componentCount: 3
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const state = new State({
|
|
45
|
+
temperature: 265.0,
|
|
46
|
+
pressure: 5.0e5,
|
|
47
|
+
liquidFraction: 0.8
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
51
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
52
|
+
|
|
53
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
54
|
+
console.log("Messages:");
|
|
55
|
+
vesselStateCalculation.messages.forEach(msg => console.log(msg));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
59
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
60
|
+
|
|
61
|
+
const vessel = new Vessel({
|
|
62
|
+
state: state,
|
|
63
|
+
material: material,
|
|
64
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
65
|
+
liquidFillFractionByVolume: 0.8,
|
|
66
|
+
shape: VesselShape.VERTICAL_CYLINDER,
|
|
67
|
+
diameter: 2.0
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const dischargeParameters = new DischargeParameters();
|
|
71
|
+
const catastrophicRupture = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
72
|
+
|
|
73
|
+
console.log("Running vessel_catastrophic_rupture_calculation...");
|
|
74
|
+
const resultCode = await catastrophicRupture.run();
|
|
75
|
+
|
|
76
|
+
if (catastrophicRupture.messages.length > 0) {
|
|
77
|
+
console.log("Messages:");
|
|
78
|
+
catastrophicRupture.messages.forEach(msg => console.log(msg));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
82
|
+
|
|
83
|
+
const releaseMass = catastrophicRupture.dischargeResult!.releaseMass!;
|
|
84
|
+
const expansionEnergy = catastrophicRupture.dischargeResult!.expansionEnergy!;
|
|
85
|
+
|
|
86
|
+
expect(Math.abs((releaseMass - 131.31770718737567) / 131.31770718737567)).toBeLessThan(1e-3);
|
|
87
|
+
expect(Math.abs((expansionEnergy - 2833.902840039733) / 2833.902840039733)).toBeLessThan(1e-3);
|
|
88
|
+
|
|
89
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${catastrophicRupture.calculationElapsedTime}ms)`);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VesselCatastrophicRuptureCalculation,
|
|
3
|
+
VesselStateCalculation,
|
|
4
|
+
} from "../../src/calculations/discharge";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Material,
|
|
8
|
+
MaterialComponent,
|
|
9
|
+
State,
|
|
10
|
+
Vessel,
|
|
11
|
+
DischargeParameters
|
|
12
|
+
} from "../../src/entities";
|
|
13
|
+
|
|
14
|
+
import { ResultCode, VesselShape } from "../../src/enums";
|
|
15
|
+
import { setAccessToken } from "../../src/utilities";
|
|
16
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
17
|
+
|
|
18
|
+
if (!accessToken) {
|
|
19
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setAccessToken(accessToken);
|
|
23
|
+
describe("Test Case - Vessel Catastrophic Rupture Calculation for HEXANE", () => {
|
|
24
|
+
test("should correctly compute release mass and expansion energy", async () => {
|
|
25
|
+
const material = new Material({
|
|
26
|
+
name: "HEXANE",
|
|
27
|
+
components: [
|
|
28
|
+
new MaterialComponent({
|
|
29
|
+
name: "N-HEXANE",
|
|
30
|
+
moleFraction: 1.0
|
|
31
|
+
})
|
|
32
|
+
],
|
|
33
|
+
componentCount: 1
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const state = new State({
|
|
37
|
+
temperature: 280.0,
|
|
38
|
+
pressure: 2.0e5,
|
|
39
|
+
liquidFraction: 0.8
|
|
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: state,
|
|
55
|
+
material: material,
|
|
56
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
57
|
+
liquidFillFractionByVolume: 0.8,
|
|
58
|
+
shape: VesselShape.VESSEL_CUBOID,
|
|
59
|
+
height: 2.0,
|
|
60
|
+
width: 1.0,
|
|
61
|
+
length: 3.0
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const dischargeParameters = new DischargeParameters();
|
|
65
|
+
const catastrophicRupture = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
66
|
+
|
|
67
|
+
console.log("Running vessel_catastrophic_rupture_calculation...");
|
|
68
|
+
const resultCode = await catastrophicRupture.run();
|
|
69
|
+
|
|
70
|
+
if (catastrophicRupture.messages.length > 0) {
|
|
71
|
+
console.log("Messages:");
|
|
72
|
+
catastrophicRupture.messages.forEach(msg => console.log(msg));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
76
|
+
|
|
77
|
+
const releaseMass = catastrophicRupture.dischargeResult!.releaseMass;
|
|
78
|
+
const expansionEnergy = catastrophicRupture.dischargeResult!.expansionEnergy;
|
|
79
|
+
|
|
80
|
+
expect(Math.abs((releaseMass! - 3225.8372574404343) / 3225.8372574404343)).toBeLessThan(1e-3);
|
|
81
|
+
expect(Math.abs((expansionEnergy! - 6.579403395934496) / 6.579403395934496)).toBeLessThan(1e-3);
|
|
82
|
+
|
|
83
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${catastrophicRupture.calculationElapsedTime}ms)`);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VesselCatastrophicRuptureCalculation,
|
|
3
|
+
VesselStateCalculation,
|
|
4
|
+
} from "../../src/calculations/discharge";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Material,
|
|
8
|
+
MaterialComponent,
|
|
9
|
+
State,
|
|
10
|
+
Vessel,
|
|
11
|
+
DischargeParameters
|
|
12
|
+
} from "../../src/entities";
|
|
13
|
+
|
|
14
|
+
import { ResultCode, VesselShape } from "../../src/enums";
|
|
15
|
+
import { setAccessToken } from "../../src/utilities";
|
|
16
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
17
|
+
|
|
18
|
+
if (!accessToken) {
|
|
19
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setAccessToken(accessToken);
|
|
23
|
+
|
|
24
|
+
describe("Test Case - Vessel Catastrophic Rupture Calculation for HYDROGEN", () => {
|
|
25
|
+
test("should correctly compute release mass and expansion energy", async () => {
|
|
26
|
+
const material = new Material({
|
|
27
|
+
name: "HYDROGEN",
|
|
28
|
+
components: [
|
|
29
|
+
new MaterialComponent({
|
|
30
|
+
name: "HYDROGEN",
|
|
31
|
+
moleFraction: 1.0
|
|
32
|
+
})
|
|
33
|
+
],
|
|
34
|
+
componentCount: 1
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const state = new State({
|
|
38
|
+
temperature: 270.0,
|
|
39
|
+
pressure: 8.0e6,
|
|
40
|
+
liquidFraction: 0.8
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
44
|
+
const vesselStateResult = await vesselStateCalculation.run();
|
|
45
|
+
|
|
46
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
47
|
+
console.log("Messages:");
|
|
48
|
+
vesselStateCalculation.messages.forEach(msg => console.log(msg));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
expect(vesselStateResult).toBe(ResultCode.SUCCESS);
|
|
52
|
+
console.log(`SUCCESS: vessel_state_calculation (${vesselStateCalculation.calculationElapsedTime}ms)`);
|
|
53
|
+
|
|
54
|
+
const vessel = new Vessel({
|
|
55
|
+
state: state,
|
|
56
|
+
material: material,
|
|
57
|
+
vesselConditions: vesselStateCalculation.vesselConditions,
|
|
58
|
+
liquidFillFractionByVolume: 0.8,
|
|
59
|
+
shape: VesselShape.VESSEL_SPHERE,
|
|
60
|
+
diameter: 5.0
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const dischargeParameters = new DischargeParameters();
|
|
64
|
+
const catastrophicRupture = new VesselCatastrophicRuptureCalculation(vessel, dischargeParameters);
|
|
65
|
+
|
|
66
|
+
console.log("Running vessel_catastrophic_rupture_calculation...");
|
|
67
|
+
const resultCode = await catastrophicRupture.run();
|
|
68
|
+
|
|
69
|
+
if (catastrophicRupture.messages.length > 0) {
|
|
70
|
+
console.log("Messages:");
|
|
71
|
+
catastrophicRupture.messages.forEach(msg => console.log(msg));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
75
|
+
|
|
76
|
+
const releaseMass = catastrophicRupture.dischargeResult!.releaseMass!;
|
|
77
|
+
const expansionEnergy = catastrophicRupture.dischargeResult!.expansionEnergy!;
|
|
78
|
+
|
|
79
|
+
expect(Math.abs((releaseMass - 442.9319348311668) / 442.9319348311668)).toBeLessThan(1e-3);
|
|
80
|
+
expect(Math.abs((expansionEnergy - 111410.44845369669) / 111410.44845369669)).toBeLessThan(1e-3);
|
|
81
|
+
|
|
82
|
+
console.log(`SUCCESS: vessel_catastrophic_rupture_calculation (${catastrophicRupture.calculationElapsedTime}ms)`);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { VesselLeakCalculation, VesselStateCalculation } from "../../src/calculations/discharge";
|
|
2
|
+
import { DischargeParameters, Leak, Material, MaterialComponent, State, Vessel } from "../../src/entities";
|
|
3
|
+
import { ResultCode, TimeVaryingOption, VesselShape } from "../../src/enums";
|
|
4
|
+
|
|
5
|
+
|
|
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
|
+
describe('Vessel Leak Calculation - Test Case 10', () => {
|
|
15
|
+
test('Vessel leak calculation for N-Butane', async () => {
|
|
16
|
+
// Set the case properties
|
|
17
|
+
const materialName = 'N-BUTANE';
|
|
18
|
+
const stateTemperature = 300.0;
|
|
19
|
+
const statePressure = 3.0E+05;
|
|
20
|
+
const vesselShape = VesselShape.VESSEL_CUBOID;
|
|
21
|
+
const vesselHeight = 2.0;
|
|
22
|
+
const vesselWidth = 1.0;
|
|
23
|
+
const vesselLength = 3.0;
|
|
24
|
+
const leakHoleDiameter = 0.05;
|
|
25
|
+
const timeVaryingOption = TimeVaryingOption.INITIAL_RATE;
|
|
26
|
+
const leakHoleHeightFraction = 0.2;
|
|
27
|
+
|
|
28
|
+
// Define the initial state of the vessel
|
|
29
|
+
const state = new State({
|
|
30
|
+
temperature: stateTemperature,
|
|
31
|
+
pressure: statePressure,
|
|
32
|
+
liquidFraction: 0.0
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Define the material contained by the vessel
|
|
36
|
+
const material = new Material({
|
|
37
|
+
name: materialName,
|
|
38
|
+
components: [
|
|
39
|
+
new MaterialComponent({ name: materialName, moleFraction: 1.0 })
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Create a vessel state calculation using the material and state
|
|
44
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
45
|
+
const vesselStateResultCode = await vesselStateCalculation.run();
|
|
46
|
+
|
|
47
|
+
// Check vessel state calculation result
|
|
48
|
+
expect(vesselStateResultCode).toBe(ResultCode.SUCCESS);
|
|
49
|
+
|
|
50
|
+
// Create a vessel to use in the leak calculation
|
|
51
|
+
const vessel = new Vessel({
|
|
52
|
+
state: vesselStateCalculation.outputState!,
|
|
53
|
+
material: vesselStateCalculation.material,
|
|
54
|
+
height: vesselHeight,
|
|
55
|
+
width: vesselWidth,
|
|
56
|
+
length: vesselLength,
|
|
57
|
+
shape: vesselShape,
|
|
58
|
+
liquidFillFractionByVolume: 0.5,
|
|
59
|
+
vesselConditions: vesselStateCalculation.vesselConditions
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Create a leak to use in the vessel leak calculation
|
|
63
|
+
const leak = new Leak({
|
|
64
|
+
holeDiameter: leakHoleDiameter,
|
|
65
|
+
timeVaryingOption: timeVaryingOption,
|
|
66
|
+
holeHeightFraction: leakHoleHeightFraction,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Create discharge parameters to use in the vessel leak calculation
|
|
70
|
+
const dischargeParameters = new DischargeParameters();
|
|
71
|
+
|
|
72
|
+
// Create a vessel leak calculation using the vessel, leak, and discharge parameters
|
|
73
|
+
const vesselLeakCalculation = new VesselLeakCalculation(
|
|
74
|
+
vessel,
|
|
75
|
+
leak,
|
|
76
|
+
dischargeParameters
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Run the vessel leak calculation
|
|
80
|
+
const vesselLeakResultCode = await vesselLeakCalculation.run();
|
|
81
|
+
|
|
82
|
+
// Check vessel leak calculation result
|
|
83
|
+
expect(vesselLeakResultCode).toBe(ResultCode.SUCCESS);
|
|
84
|
+
|
|
85
|
+
// Regression tests for discharge records
|
|
86
|
+
const dischargeRecords = vesselLeakCalculation.dischargeRecords;
|
|
87
|
+
expect(dischargeRecords).toBeDefined();
|
|
88
|
+
expect(dischargeRecords!.length).toBe(2);
|
|
89
|
+
|
|
90
|
+
// Check mass flow regression
|
|
91
|
+
const expectedMassFlow = 18.596151455819438;
|
|
92
|
+
const actualMassFlow = dischargeRecords ? dischargeRecords[0].massFlow : undefined;
|
|
93
|
+
expect(actualMassFlow).toBeDefined();
|
|
94
|
+
expect(Math.abs(((actualMassFlow as number) - expectedMassFlow) / expectedMassFlow)).toBeLessThan(1e-3);
|
|
95
|
+
|
|
96
|
+
// Check final velocity regression
|
|
97
|
+
const expectedFinalVelocity = 82.9875939245342;
|
|
98
|
+
const actualFinalVelocity = dischargeRecords ? dischargeRecords[0].finalVelocity : undefined;
|
|
99
|
+
expect(actualFinalVelocity).toBeDefined();
|
|
100
|
+
expect(Math.abs(((actualFinalVelocity as number) - expectedFinalVelocity) / expectedFinalVelocity)).toBeLessThan(1e-3);
|
|
101
|
+
|
|
102
|
+
// Check droplet diameter regression
|
|
103
|
+
const expectedDropletDiameter = 0.00024867091738833337;
|
|
104
|
+
const actualDropletDiameter = dischargeRecords ? dischargeRecords[0].dropletDiameter : undefined;
|
|
105
|
+
expect(actualDropletDiameter).toBeDefined();
|
|
106
|
+
expect(Math.abs(((actualDropletDiameter as number) - expectedDropletDiameter) / expectedDropletDiameter)).toBeLessThan(1e-3);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { VesselLeakCalculation, VesselStateCalculation } from "../../src/calculations/discharge";
|
|
2
|
+
import { DischargeParameters, Leak, LocalPosition, Material, MaterialComponent, SafetySystem, State, Vessel } from "../../src/entities";
|
|
3
|
+
import { ResultCode, TimeVaryingOption, VesselShape } from "../../src/enums";
|
|
4
|
+
|
|
5
|
+
import { setAccessToken } from "../../src/utilities";
|
|
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('Vessel Leak Calculation', () => {
|
|
15
|
+
test('test case 6 - vessel leak calculation', async () => {
|
|
16
|
+
// Set the case properties
|
|
17
|
+
const materialName = 'METHANE';
|
|
18
|
+
const stateTemperature = 280.0;
|
|
19
|
+
const statePressure = 1.0E+06;
|
|
20
|
+
const vesselShape = VesselShape.VESSEL_SPHERE;
|
|
21
|
+
const vesselDiameter = 3.0;
|
|
22
|
+
const leakHoleDiameter = 0.1;
|
|
23
|
+
const timeVaryingOption = TimeVaryingOption.INITIAL_RATE;
|
|
24
|
+
const leakHoleHeightFraction = 0.5;
|
|
25
|
+
|
|
26
|
+
// Define the initial state of the vessel
|
|
27
|
+
const state = new State({
|
|
28
|
+
temperature: stateTemperature,
|
|
29
|
+
pressure: statePressure,
|
|
30
|
+
liquidFraction: 0.0
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Define the material contained by the vessel
|
|
34
|
+
const material = new Material({
|
|
35
|
+
name: materialName,
|
|
36
|
+
components: [new MaterialComponent({name: materialName, moleFraction:1.0})]
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Create a vessel state calculation using the material and state
|
|
40
|
+
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
41
|
+
|
|
42
|
+
// Run the vessel state calculation
|
|
43
|
+
const vesselStateResultCode = await vesselStateCalculation.run();
|
|
44
|
+
|
|
45
|
+
// Check vessel state calculation result
|
|
46
|
+
expect(vesselStateResultCode).toBe(ResultCode.SUCCESS);
|
|
47
|
+
|
|
48
|
+
// Optional: Log messages if any
|
|
49
|
+
if (vesselStateCalculation.messages.length > 0) {
|
|
50
|
+
vesselStateCalculation.messages.forEach(message => {
|
|
51
|
+
console.log(message);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Create a vessel to use in the leak calculation
|
|
56
|
+
const vessel = new Vessel({
|
|
57
|
+
state: vesselStateCalculation.outputState!,
|
|
58
|
+
material: vesselStateCalculation.material,
|
|
59
|
+
diameter: vesselDiameter,
|
|
60
|
+
shape: vesselShape,
|
|
61
|
+
vesselConditions: vesselStateCalculation.vesselConditions
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Create a leak to use in the vessel leak calculation
|
|
65
|
+
const leak = new Leak({
|
|
66
|
+
holeDiameter:leakHoleDiameter,
|
|
67
|
+
timeVaryingOption: timeVaryingOption,
|
|
68
|
+
holeHeightFraction:leakHoleHeightFraction,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Create discharge parameters to use in the vessel leak calculation
|
|
72
|
+
const dischargeParameters = new DischargeParameters();
|
|
73
|
+
|
|
74
|
+
// Create a vessel leak calculation using the vessel, leak, and discharge parameters
|
|
75
|
+
const vesselLeakCalculation = new VesselLeakCalculation(
|
|
76
|
+
vessel,
|
|
77
|
+
leak,
|
|
78
|
+
dischargeParameters
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// Run the vessel leak calculation
|
|
82
|
+
const vesselLeakResultCode = await vesselLeakCalculation.run();
|
|
83
|
+
|
|
84
|
+
// Check vessel leak calculation result
|
|
85
|
+
expect(vesselLeakResultCode).toBe(ResultCode.SUCCESS);
|
|
86
|
+
|
|
87
|
+
// Optional: Log messages if any
|
|
88
|
+
if (vesselLeakCalculation.messages.length > 0) {
|
|
89
|
+
vesselLeakCalculation.messages.forEach(message => {
|
|
90
|
+
console.log(message);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Regression tests for discharge records
|
|
95
|
+
const dischargeRecords = vesselLeakCalculation.dischargeRecords;
|
|
96
|
+
|
|
97
|
+
// Check number of discharge records
|
|
98
|
+
expect(dischargeRecords).toBeDefined();
|
|
99
|
+
expect(dischargeRecords!.length).toBe(2);
|
|
100
|
+
|
|
101
|
+
// Check mass flow regression
|
|
102
|
+
const expectedMassFlow = 12.033250169270818;
|
|
103
|
+
const actualMassFlow = dischargeRecords ? dischargeRecords[0].massFlow : undefined;
|
|
104
|
+
expect(actualMassFlow).toBeDefined();
|
|
105
|
+
expect(Math.abs(((actualMassFlow as number) - expectedMassFlow) / expectedMassFlow)).toBeLessThan(1e-3);
|
|
106
|
+
|
|
107
|
+
// Check final velocity regression
|
|
108
|
+
const expectedFinalVelocity = 649.4227509851291;
|
|
109
|
+
const actualFinalVelocity = dischargeRecords ? dischargeRecords[0].finalVelocity : undefined;
|
|
110
|
+
expect(actualFinalVelocity).toBeDefined();
|
|
111
|
+
expect(Math.abs(((actualFinalVelocity as number) - expectedFinalVelocity) / expectedFinalVelocity)).toBeLessThan(1e-3);
|
|
112
|
+
});
|
|
113
|
+
});
|