@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.
Files changed (215) hide show
  1. package/index.ts +2 -2
  2. package/jest.config.js +5 -0
  3. package/package.json +6 -6
  4. package/src/calculations/applicationTools.ts +2 -2
  5. package/src/calculations/discharge.ts +2 -2
  6. package/src/calculations/dispersion.ts +2 -2
  7. package/src/calculations/dispersionView.ts +2 -2
  8. package/src/calculations/fireball.ts +2 -2
  9. package/src/calculations/jetFire.ts +2 -2
  10. package/src/calculations/lateExplosion.ts +2 -2
  11. package/src/calculations/linkedRunners.ts +2 -2
  12. package/src/calculations/poolFire.ts +2 -2
  13. package/src/calculations/properties.ts +2 -2
  14. package/src/calculations/radiation.ts +2 -2
  15. package/src/calculations/standalones.ts +2 -2
  16. package/src/calculations/toxics.ts +2 -2
  17. package/src/calculations/utilities.ts +2 -2
  18. package/src/constants.ts +2 -2
  19. package/src/entities.ts +2 -2
  20. package/src/entity-schemas.ts +2 -2
  21. package/src/enums.ts +2 -2
  22. package/src/materials.ts +14 -14
  23. package/src/utilities.ts +2 -2
  24. package/tests/concentration-at-point-calculation/testCase116.test.ts +146 -0
  25. package/tests/concentration-at-point-calculation/testCase117.test.ts +142 -0
  26. package/tests/concentration-at-point-calculation/testCase118.test.ts +143 -0
  27. package/tests/concentration-at-point-calculation/testCase119.test.ts +149 -0
  28. package/tests/concentration-at-point-calculation/testCase120.test.ts +155 -0
  29. package/tests/constants/testConstants.test.ts +23 -0
  30. package/tests/convert-comp-mass-to-mole-calculation/testCase129.test.ts +74 -0
  31. package/tests/convert-comp-mass-to-mole-calculation/testCase130.test.ts +73 -0
  32. package/tests/convert-comp-mass-to-mole-calculation/testCase131.test.ts +73 -0
  33. package/tests/convert-comp-mass-to-mole-calculation/testCase132.test.ts +73 -0
  34. package/tests/convert-comp-mass-to-mole-calculation/testCase133.test.ts +73 -0
  35. package/tests/convert-comp-mole-to-mass-calculation/testCase134.test.ts +72 -0
  36. package/tests/convert-comp-mole-to-mass-calculation/testCase135.test.ts +72 -0
  37. package/tests/convert-comp-mole-to-mass-calculation/testCase136.test.ts +72 -0
  38. package/tests/convert-comp-mole-to-mass-calculation/testCase137.test.ts +72 -0
  39. package/tests/convert-comp-mole-to-mass-calculation/testCase138.test.ts +72 -0
  40. package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase64.test.ts +194 -0
  41. package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase65.test.ts +197 -0
  42. package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase66.test.ts +194 -0
  43. package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase67.test.ts +198 -0
  44. package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase68.test.ts +178 -0
  45. package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase31a.test.ts +158 -0
  46. package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase32a.test.ts +156 -0
  47. package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase33a.test.ts +158 -0
  48. package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase34a.test.ts +165 -0
  49. package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase35a.test.ts +188 -0
  50. package/tests/distances-to-conc-levels-calculation/testCase121.test.ts +149 -0
  51. package/tests/distances-to-conc-levels-calculation/testCase122.test.ts +145 -0
  52. package/tests/distances-to-conc-levels-calculation/testCase123.test.ts +150 -0
  53. package/tests/distances-to-conc-levels-calculation/testCase124.test.ts +154 -0
  54. package/tests/distances-to-conc-levels-calculation/testCase125.test.ts +157 -0
  55. package/tests/entities/testVessel.test.ts +49 -0
  56. package/tests/fireball-calculation/testCase89.test.ts +151 -0
  57. package/tests/fireball-calculation/testCase90.test.ts +153 -0
  58. package/tests/fireball-calculation/testCase91.test.ts +152 -0
  59. package/tests/fireball-calculation/testCse92.test.ts +150 -0
  60. package/tests/flash-calculation/testCase26.test.ts +71 -0
  61. package/tests/flash-calculation/testCase27.test.ts +69 -0
  62. package/tests/flash-calculation/testCase28.test.ts +69 -0
  63. package/tests/flash-calculation/testCase29.test.ts +67 -0
  64. package/tests/flash-calculation/testCase30.test.ts +70 -0
  65. package/tests/general/operation-id-demo.test.ts +64 -0
  66. package/tests/get-component-by-id/get-component-by-id-METHANE.test.ts +35 -0
  67. package/tests/get-mass-from-vessel-calculation/testCase139.test.ts +65 -0
  68. package/tests/jet-fire-calculation/testCase36.test.ts +141 -0
  69. package/tests/jet-fire-calculation/testCase37.test.ts +148 -0
  70. package/tests/jet-fire-calculation/testCase38.test.ts +147 -0
  71. package/tests/jet-fire-calculation/testCase39.test.ts +146 -0
  72. package/tests/jet-fire-calculation/testCase40.test.ts +152 -0
  73. package/tests/late-explosion-calculation/testCase46.test.ts +157 -0
  74. package/tests/late-explosion-calculation/testCase47.test.ts +149 -0
  75. package/tests/late-explosion-calculation/testCase48.test.ts +176 -0
  76. package/tests/late-explosion-calculation/testCase49.test.ts +178 -0
  77. package/tests/late-explosion-calculation/testCase50.test.ts +176 -0
  78. package/tests/late-explosion-calculation/testCase74.test.ts +166 -0
  79. package/tests/late-explosion-calculation/testCase75.test.ts +163 -0
  80. package/tests/late-explosion-calculation/testCase76.test.ts +174 -0
  81. package/tests/late-explosion-calculation/testCase77.test.ts +175 -0
  82. package/tests/late-explosion-calculation/testCase78.test.ts +175 -0
  83. package/tests/lethality-distance-calculation/testCase60.test.ts +142 -0
  84. package/tests/linked-runners/user-defined-source-linked-run/test-uds-153.test.ts +121 -0
  85. package/tests/linked-runners/user-defined-source-linked-run/test-uds-154.test.ts +167 -0
  86. package/tests/linked-runners/user-defined-source-linked-run/test-uds-155.test.ts +202 -0
  87. package/tests/linked-runners/user-defined-source-linked-run/test-uds-156.test.ts +201 -0
  88. package/tests/linked-runners/vessel-leak-linked-run/test-vl-157.test.ts +182 -0
  89. package/tests/linked-runners/vessel-leak-linked-run/test-vl-158.test.ts +200 -0
  90. package/tests/linked-runners/vessel-leak-linked-run/test-vl-159.test.ts +158 -0
  91. package/tests/linked-runners/vessel-leak-linked-run/test-vl-160.test.ts +165 -0
  92. package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-161.test.ts +161 -0
  93. package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-162.test.ts +167 -0
  94. package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-163.test.ts +177 -0
  95. package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-164.test.ts +165 -0
  96. package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-165.test.ts +166 -0
  97. package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-166.test.ts +154 -0
  98. package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-167.test.ts +157 -0
  99. package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-168.test.ts +168 -0
  100. package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase126.test.ts +72 -0
  101. package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase127.test.ts +73 -0
  102. package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase128.test.ts +72 -0
  103. package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase103.test.ts +74 -0
  104. package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase104.test.ts +75 -0
  105. package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase105.test.ts +74 -0
  106. package/tests/long-pipe-calculation/testCase55.test.ts +88 -0
  107. package/tests/long-pipe-calculation/testCase56.test.ts +90 -0
  108. package/tests/long-pipe-calculation/testCase57.test.ts +88 -0
  109. package/tests/long-pipe-calculation/testCase58.test.ts +88 -0
  110. package/tests/long-pipe-calculation/testCase59.test.ts +88 -0
  111. package/tests/materials/test-get-component-by-cas-id-1-2-PROPYLENE-OXIDE.test.ts +23 -0
  112. package/tests/materials/test-get-component-by-cas-id-CARBON-MONOXIDE.test.ts +25 -0
  113. package/tests/materials/test-get-component-by-cas-id-METHANE.test.ts +22 -0
  114. package/tests/materials/test-get-component-by-id-1-2-PROPYLENE-OXIDE.test.ts +23 -0
  115. package/tests/materials/test-get-component-by-id-CARBON-MONOXIDE.test.ts +22 -0
  116. package/tests/materials/test-get-component-by-id-METHANE.test.ts +22 -0
  117. package/tests/materials/test-get-component-by-name-1-2-PROPYLENE-OXIDE.test.ts +24 -0
  118. package/tests/materials/test-get-component-by-name-CARBON-MONOXIDE.test.ts +23 -0
  119. package/tests/materials/test-get-component-by-name-METHANE.test.ts +25 -0
  120. package/tests/materials/test-get-components.test.ts +47 -0
  121. package/tests/materials/test-get-dippr-components.test.ts +28 -0
  122. package/tests/materials/test-get-dnv-components.test.ts +28 -0
  123. package/tests/materials/test-get-material-by-cas-id-1-2-PROPYLENE-OXIDE.test.ts +29 -0
  124. package/tests/materials/test-get-material-by-cas-id-CARBON-MONOXIDE.test.ts +31 -0
  125. package/tests/materials/test-get-material-by-cas-id-METHANE.test.ts +30 -0
  126. package/tests/materials/test-get-material-by-cas-id-ZERO.test.ts +31 -0
  127. package/tests/materials/test-get-material-by-id-1-2-PROPYLENE-OXIDE.test.ts +30 -0
  128. package/tests/materials/test-get-material-by-id-CARBON-MONOXIDE.test.ts +29 -0
  129. package/tests/materials/test-get-material-by-id-METHANE.test.ts +29 -0
  130. package/tests/materials/test-get-material-by-name-1-2-PROPYLENE-OXIDE.test.ts +29 -0
  131. package/tests/materials/test-get-material-by-name-CARBON-MONOXIDE.test.ts +29 -0
  132. package/tests/materials/test-get-material-by-name-METHANE.test.ts +29 -0
  133. package/tests/materials/test-get-materials.test.ts +32 -0
  134. package/tests/max-conc-distance-calculation/testCase106.test.ts +146 -0
  135. package/tests/max-conc-distance-calculation/testCase107.test.ts +148 -0
  136. package/tests/max-conc-distance-calculation/testCase108.test.ts +172 -0
  137. package/tests/max-conc-distance-calculation/testCase109.test.ts +146 -0
  138. package/tests/max-conc-distance-calculation/testCase110.test.ts +146 -0
  139. package/tests/max-conc-footprint-calculation/testCase31.test.ts +169 -0
  140. package/tests/max-conc-footprint-calculation/testCase32.test.ts +183 -0
  141. package/tests/max-conc-footprint-calculation/testCase33.test.ts +161 -0
  142. package/tests/max-conc-footprint-calculation/testCase34.test.ts +172 -0
  143. package/tests/max-conc-footprint-calculation/testCase35.test.ts +188 -0
  144. package/tests/max-distance-to-conc-calculation/testCase111.test.ts +138 -0
  145. package/tests/max-distance-to-conc-calculation/testCase112.test.ts +174 -0
  146. package/tests/max-distance-to-conc-calculation/testCase113.test.ts +153 -0
  147. package/tests/max-distance-to-conc-calculation/testCase114.test.ts +162 -0
  148. package/tests/max-distance-to-conc-calculation/testCase115.test.ts +167 -0
  149. package/tests/mixture-constant-properties-calculation/testCase97.test.ts +83 -0
  150. package/tests/mixture-constant-properties-calculation/testCase98.test.ts +90 -0
  151. package/tests/mixture-constant-properties-calculation/testCase99.test.ts +87 -0
  152. package/tests/pool-fire-calculation/testCase41.test.ts +153 -0
  153. package/tests/pool-fire-calculation/testCase41a.test.ts +141 -0
  154. package/tests/pool-fire-calculation/testCase42.test.ts +169 -0
  155. package/tests/pool-fire-calculation/testCase42a.test.ts +175 -0
  156. package/tests/pool-fire-calculation/testCase43.test.ts +161 -0
  157. package/tests/pool-fire-calculation/testCase43a.test.ts +157 -0
  158. package/tests/pool-fire-calculation/testCase44.test.ts +147 -0
  159. package/tests/pool-fire-calculation/testCase44a.test.ts +152 -0
  160. package/tests/pool-fire-calculation/testCase45.test.ts +176 -0
  161. package/tests/pool-fire-calculation/testCase45a.test.ts +182 -0
  162. package/tests/radiation-at-ponts/testCase69.test.ts +167 -0
  163. package/tests/radiation-at-ponts/testCase70.test.ts +179 -0
  164. package/tests/radiation-at-ponts/testCase71.test.ts +150 -0
  165. package/tests/radiation-at-ponts/testCase72.test.ts +166 -0
  166. package/tests/radiation-at-ponts/testCase73.test.ts +169 -0
  167. package/tests/radiation-contour-calculation/testCase51.test.ts +127 -0
  168. package/tests/radiation-contour-calculation/testCase52.test.ts +126 -0
  169. package/tests/radiation-contour-calculation/testCase53.test.ts +126 -0
  170. package/tests/radiation-contour-calculation/testCase54.test.ts +131 -0
  171. package/tests/relief-valve-min-temperature-calculation/testCase140.test.ts +49 -0
  172. package/tests/set-mixing-layer-height/testCase100.test.ts +36 -0
  173. package/tests/set-mixing-layer-height/testCase101.test.ts +36 -0
  174. package/tests/set-mixing-layer-height/testCase102.test.ts +36 -0
  175. package/tests/set-phase-to-be-released-for-leak-calculation/testCase150.test.ts +67 -0
  176. package/tests/set-phase-to-be-released-for-line-rupture-calculation/testCase151.test.ts +67 -0
  177. package/tests/set-phase-to-be-released-for-relief-valve-calculation/TestCase152.test.ts +61 -0
  178. package/tests/sideview/testCase31b.test.ts +150 -0
  179. package/tests/sideview/testCase32b.test.ts +145 -0
  180. package/tests/sideview/testCase33b.test.ts +130 -0
  181. package/tests/sideview/testCase34b.test.ts +153 -0
  182. package/tests/sideview/testCase35b.test.ts +140 -0
  183. package/tests/tank-fire-calculation/testCase79.test.ts +61 -0
  184. package/tests/tank-fire-calculation/testCase80.test.ts +67 -0
  185. package/tests/tank-fire-calculation/testCase81.test.ts +68 -0
  186. package/tests/tank-fire-calculation/testCase82.test.ts +68 -0
  187. package/tests/tank-fire-calculation/testCase83.test.ts +73 -0
  188. package/tests/utilities/convert-camel-case-to-snake-case.test.ts +7 -0
  189. package/tests/utilities/convert-snake-case-to-camel-case.test.ts +7 -0
  190. package/tests/vessel-catastrophic-rupture-calculation/testCase1.test.ts +83 -0
  191. package/tests/vessel-catastrophic-rupture-calculation/testCase2.test.ts +82 -0
  192. package/tests/vessel-catastrophic-rupture-calculation/testCase3.test.ts +91 -0
  193. package/tests/vessel-catastrophic-rupture-calculation/testCase4.test.ts +85 -0
  194. package/tests/vessel-catastrophic-rupture-calculation/testCase5.test.ts +84 -0
  195. package/tests/vessel-leak-calculation/testCase10.test.ts +108 -0
  196. package/tests/vessel-leak-calculation/testCase6.test.ts +113 -0
  197. package/tests/vessel-leak-calculation/testCase7.test.ts +123 -0
  198. package/tests/vessel-leak-calculation/testCase8.test.ts +102 -0
  199. package/tests/vessel-leak-calculation/testCase9.test.ts +106 -0
  200. package/tests/vessel-line-rupture-calculation/vlr-ammonia.test.ts +84 -0
  201. package/tests/vessel-line-rupture-calculation/vlr-ethaneMethane.test.ts +82 -0
  202. package/tests/vessel-line-rupture-calculation/vlr-nDecane.test.ts +79 -0
  203. package/tests/vessel-line-rupture-calculation/vlr-oxygen.test.ts +77 -0
  204. package/tests/vessel-line-rupture-calculation/vlr-propane.test.ts +77 -0
  205. package/tests/vessel-relief-valve-calculation/vrv-chlorine.test.ts +99 -0
  206. package/tests/vessel-relief-valve-calculation/vrv-hydrogen.test.ts +96 -0
  207. package/tests/vessel-relief-valve-calculation/vrv-methane.test.ts +80 -0
  208. package/tests/vessel-relief-valve-calculation/vrv-methaneH2s.test.ts +86 -0
  209. package/tests/vessel-relief-valve-calculation/vrv-nitrogen.test.ts +80 -0
  210. package/tests/vessel-state-calculation/vs-ammonia.test.ts +56 -0
  211. package/tests/vessel-state-calculation/vs-butane.test.ts +57 -0
  212. package/tests/vessel-state-calculation/vs-chlorine.test.ts +56 -0
  213. package/tests/vessel-state-calculation/vs-methane.test.ts +57 -0
  214. package/tests/vessel-state-calculation/vs-naturalGas.test.ts +59 -0
  215. package/tests/vessel-state-calculation/vs-nitrogenPentane.test.ts +58 -0
@@ -0,0 +1,176 @@
1
+ import { Material, MaterialComponent, State, Vessel, Weather, LineRupture, 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 } 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 50", () => {
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: 3e5,
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 lineRuptureCalc = new VesselLineRuptureCalculation(vessel, lineRupture, new DischargeParameters());
64
+
65
+ console.log("Running vesselLineRuptureCalculation...");
66
+ resultCode = await lineRuptureCalc.run();
67
+
68
+ if (lineRuptureCalc.messages.length > 0) {
69
+ console.log("Messages:");
70
+ lineRuptureCalc.messages.forEach((msg) => console.log(msg));
71
+ }
72
+
73
+ expect(resultCode).toBe(ResultCode.SUCCESS);
74
+ console.log(`SUCCESS: vesselLineRuptureCalculation (${lineRuptureCalc.calculationElapsedTime}ms)`);
75
+ console.log(`vesselLineRuptureCalculation.dischargeResult.releaseMass: ${lineRuptureCalc.dischargeResult!.releaseMass} [kg]`);
76
+
77
+ const exitMaterial = lineRuptureCalc.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
+ lineRuptureCalc.dischargeResult!,
94
+ lineRuptureCalc.dischargeRecords!,
95
+ lineRuptureCalc.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 explosionOutputConfigs = [
123
+ new ExplosionOutputConfig({ overpressureLevel: 1034 }),
124
+ new ExplosionOutputConfig({ overpressureLevel: 2068 }),
125
+ new ExplosionOutputConfig({ overpressureLevel: 8272 })
126
+ ];
127
+
128
+ const explosionConfinedVolumes = [
129
+ new ExplosionConfinedVolume(),
130
+ new ExplosionConfinedVolume()
131
+ ];
132
+
133
+ // Create and run explosion calculation
134
+ const explosionCalc = new LateExplosionToOPLevelsCalculation(
135
+ exitMaterial,
136
+ dispersionCalc.scalarUdmOutputs!,
137
+ weather,
138
+ dispersionCalc.dispersionRecords!,
139
+ dispersionCalc.dispersionRecords!.length,
140
+ substrate,
141
+ dispersionOutputConfig,
142
+ explosionOutputConfigs,
143
+ explosionOutputConfigs.length,
144
+ explosionParams,
145
+ explosionConfinedVolumes,
146
+ explosionConfinedVolumes.length,
147
+ new DispersionParameters()
148
+ );
149
+
150
+ console.log("Running lateExplosionToOPLevelsCalculation...");
151
+ resultCode = await explosionCalc.run();
152
+
153
+ if (explosionCalc.messages.length > 0) {
154
+ console.log("Messages:");
155
+ explosionCalc.messages.forEach((msg) => console.log(msg));
156
+ }
157
+
158
+ expect(resultCode).toBe(ResultCode.SUCCESS);
159
+
160
+ // Regression checks
161
+ const result = explosionCalc.explosionUnifConfOverpressureResults![0];
162
+ const expectedMass = 1081.1427088939722;
163
+ const expectedTime = 96.0561524166236;
164
+ const expectedDistance = 1042.2068518145015;
165
+
166
+ const massError = Math.abs((result.explodedMass! - expectedMass) / expectedMass);
167
+ const timeError = Math.abs((result.ignitionTime! - expectedTime) / expectedTime);
168
+ const distanceError = Math.abs((result.maximumDistance! - expectedDistance) / expectedDistance);
169
+
170
+ expect(massError).toBeLessThan(1e-3);
171
+ expect(timeError).toBeLessThan(1e-3);
172
+ expect(distanceError).toBeLessThan(1e-3);
173
+
174
+ console.log(`SUCCESS: lateExplosionToOPLevelsCalculation (${explosionCalc.calculationElapsedTime}ms)`);
175
+ });
176
+ });
@@ -0,0 +1,166 @@
1
+ import { Material, MaterialComponent, State, Vessel, Weather, Substrate, DischargeParameters, DispersionParameters, DispersionOutputConfig, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume } from "../../src/entities";
2
+ import { VesselStateCalculation, VesselLineRuptureCalculation, VesselCatastrophicRuptureCalculation } from "../../src/calculations/discharge";
3
+ import { DispersionCalculation } from "../../src/calculations/dispersion";
4
+ import { LateExplosionCalculation } from "../../src/calculations/lateExplosion";
5
+ import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, VesselShape, WindProfileFlag } from "../../src/enums";
6
+
7
+ import { setAccessToken } from "../../src/utilities";
8
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
9
+
10
+ if (!accessToken) {
11
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
12
+ }
13
+
14
+ setAccessToken(accessToken);
15
+
16
+ describe("Integrated Explosion Scenario - Test Case 74", () => {
17
+ test("should run the full explosion scenario and perform regression check", async () => {
18
+ // Define the material contained by the vessel
19
+ const material = new Material({
20
+ name: "N-HEXANE",
21
+ components: [new MaterialComponent({ name: "N-HEXANE", moleFraction: 1.0 })]
22
+ });
23
+
24
+ // Define the initial state of the vessel
25
+ const state = new State({
26
+ temperature: 280.0,
27
+ pressure: 2.0e5,
28
+ liquidFraction: 0.8
29
+ });
30
+
31
+ // Create and run vessel state calculation
32
+ const vesselStateCalc = new VesselStateCalculation(material, state);
33
+
34
+ console.log("Running vesselStateCalculation...");
35
+ const vesselStateResult = await vesselStateCalc.run();
36
+
37
+ if (vesselStateCalc.messages.length > 0) {
38
+ console.log("Messages:");
39
+ vesselStateCalc.messages.forEach((msg) => console.log(msg));
40
+ }
41
+
42
+ expect(vesselStateResult).toBe(ResultCode.SUCCESS);
43
+ console.log(`SUCCESS: vesselStateCalculation (${vesselStateCalc.calculationElapsedTime}ms)`);
44
+
45
+ // Create vessel
46
+ const vessel = new Vessel({
47
+ state,
48
+ material,
49
+ vesselConditions: vesselStateCalc.vesselConditions,
50
+ liquidFillFractionByVolume: 0.8
51
+ });
52
+
53
+ // Create and run vessel catastrophic rupture calculation
54
+ const vesselCatastrophicCalc = new VesselCatastrophicRuptureCalculation(
55
+ vessel,
56
+ new DischargeParameters()
57
+ );
58
+
59
+ console.log("Running vesselCatastrophicRuptureCalculation...");
60
+ const catastrophicResult = await vesselCatastrophicCalc.run();
61
+
62
+ if (vesselCatastrophicCalc.messages.length > 0) {
63
+ console.log("Messages:");
64
+ vesselCatastrophicCalc.messages.forEach((msg) => console.log(msg));
65
+ }
66
+
67
+ expect(catastrophicResult).toBe(ResultCode.SUCCESS);
68
+ console.log(`SUCCESS: vesselCatastrophicRuptureCalculation (${vesselCatastrophicCalc.calculationElapsedTime}ms)`);
69
+
70
+ const exitMaterial = vesselCatastrophicCalc.exitMaterial!;
71
+
72
+ // Define weather
73
+ const weather = new Weather({
74
+ windSpeed: 1.5,
75
+ stabilityClass: AtmosphericStabilityClass.STABILITY_F,
76
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
77
+ });
78
+
79
+ // Define substrate
80
+ const substrate = new Substrate();
81
+
82
+ // Create and run dispersion calculation
83
+ const dispersionCalc = new DispersionCalculation(
84
+ exitMaterial,
85
+ substrate,
86
+ vesselCatastrophicCalc.dischargeResult!,
87
+ vesselCatastrophicCalc.dischargeRecords!,
88
+ 1,
89
+ weather,
90
+ new DispersionParameters(),
91
+ 0.0
92
+ );
93
+
94
+ console.log("Running dispersionCalculation...");
95
+ const dispersionResult = await dispersionCalc.run();
96
+
97
+ if (dispersionCalc.messages.length > 0) {
98
+ console.log("Messages:");
99
+ dispersionCalc.messages.forEach((msg) => console.log(msg));
100
+ }
101
+
102
+ expect(dispersionResult).toBe(ResultCode.SUCCESS);
103
+ console.log(`SUCCESS: dispersionCalculation (${dispersionCalc.calculationElapsedTime}ms)`);
104
+
105
+ // Define explosion configurations
106
+ const dispersionOutputConfig = new DispersionOutputConfig({
107
+ concentration: 0.0,
108
+ specialConcentration: SpecialConcentration.MIN
109
+ });
110
+
111
+ const explosionParams = new ExplosionParameters({
112
+ explosionUniformStrength: 7.0
113
+ });
114
+
115
+ const explosionOutputConfig = new ExplosionOutputConfig({
116
+ overpressureLevel: 2068
117
+ });
118
+
119
+ const explosionConfinedVolumes = [
120
+ new ExplosionConfinedVolume(),
121
+ new ExplosionConfinedVolume()
122
+ ];
123
+
124
+ // Create and run explosion calculation
125
+ const explosionCalc = new LateExplosionCalculation(
126
+ exitMaterial,
127
+ dispersionCalc.scalarUdmOutputs!,
128
+ weather,
129
+ dispersionCalc.dispersionRecords!,
130
+ dispersionCalc.dispersionRecords!.length,
131
+ substrate,
132
+ dispersionOutputConfig,
133
+ explosionOutputConfig,
134
+ explosionParams,
135
+ explosionConfinedVolumes,
136
+ explosionConfinedVolumes.length,
137
+ new DispersionParameters()
138
+ );
139
+
140
+ console.log("Running lateExplosionCalculation...");
141
+ const explosionResult = await explosionCalc.run();
142
+
143
+ if (explosionCalc.messages.length > 0) {
144
+ console.log("Messages:");
145
+ explosionCalc.messages.forEach((msg) => console.log(msg));
146
+ }
147
+
148
+ expect(explosionResult).toBe(ResultCode.SUCCESS);
149
+
150
+ // Regression checks
151
+ const result = explosionCalc.explosionUnifConfOverpressureResult!;
152
+ const expectedMass = 9.863701824923115;
153
+ const expectedTime = 5.794506457215323;
154
+ const expectedDistance = 112.78500368023822;
155
+
156
+ const massError = Math.abs((result.explodedMass! - expectedMass) / expectedMass);
157
+ const timeError = Math.abs((result.ignitionTime! - expectedTime) / expectedTime);
158
+ const distanceError = Math.abs((result.maximumDistance! - expectedDistance) / expectedDistance);
159
+
160
+ expect(massError).toBeLessThan(1e-3);
161
+ expect(timeError).toBeLessThan(1e-3);
162
+ expect(distanceError).toBeLessThan(1e-3);
163
+
164
+ console.log(`SUCCESS: lateExplosionCalculation (${explosionCalc.calculationElapsedTime}ms)`);
165
+ });
166
+ });
@@ -0,0 +1,163 @@
1
+ import { Material, MaterialComponent, State, Vessel, Weather, Substrate, DischargeParameters, DispersionParameters, DispersionOutputConfig, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume } from "../../src/entities";
2
+ import { VesselStateCalculation, VesselLineRuptureCalculation, VesselCatastrophicRuptureCalculation } from "../../src/calculations/discharge";
3
+ import { DispersionCalculation } from "../../src/calculations/dispersion";
4
+ import { 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 75", () => {
16
+ test("should run the full explosion scenario and perform regression check", async () => {
17
+ // Define the material
18
+ const material = new Material({
19
+ name: "AMMONIA",
20
+ components: [new MaterialComponent({ name: "AMMONIA", moleFraction: 1.0 })]
21
+ });
22
+
23
+ // Define the initial state
24
+ const state = new State({
25
+ temperature: 265.0,
26
+ pressure: 5.0e5,
27
+ liquidFraction: 0.8
28
+ });
29
+
30
+ // Create and run vessel state calculation
31
+ const vesselStateCalc = new VesselStateCalculation(material, state);
32
+
33
+ console.log("Running vesselStateCalculation...");
34
+ const vesselStateResult = 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(vesselStateResult).toBe(ResultCode.SUCCESS);
42
+ console.log(`SUCCESS: vesselStateCalculation (${vesselStateCalc.calculationElapsedTime}ms)`);
43
+
44
+ // Create vessel
45
+ const vessel = new Vessel({
46
+ state,
47
+ material,
48
+ vesselConditions: vesselStateCalc.vesselConditions,
49
+ liquidFillFractionByVolume: 0.8
50
+ });
51
+
52
+ // Create and run vessel catastrophic rupture calculation
53
+ const dischargeParams = new DischargeParameters();
54
+ const vesselRuptureCalc = new VesselCatastrophicRuptureCalculation(vessel, dischargeParams);
55
+
56
+ console.log("Running vesselCatastrophicRuptureCalculation...");
57
+ const ruptureResult = await vesselRuptureCalc.run();
58
+
59
+ if (vesselRuptureCalc.messages.length > 0) {
60
+ console.log("Messages:");
61
+ vesselRuptureCalc.messages.forEach(msg => console.log(msg));
62
+ }
63
+
64
+ expect(ruptureResult).toBe(ResultCode.SUCCESS);
65
+ console.log(`SUCCESS: vesselCatastrophicRuptureCalculation (${vesselRuptureCalc.calculationElapsedTime}ms)`);
66
+
67
+ const exitMaterial = vesselRuptureCalc.exitMaterial!;
68
+
69
+ // Define weather
70
+ const weather = new Weather({
71
+ windSpeed: 10.0,
72
+ stabilityClass: AtmosphericStabilityClass.STABILITY_A_,
73
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
74
+ });
75
+
76
+ // Define substrate
77
+ const substrate = new Substrate();
78
+
79
+ // Create and run dispersion calculation
80
+ const dispersionCalc = new DispersionCalculation(
81
+ exitMaterial,
82
+ substrate,
83
+ vesselRuptureCalc.dischargeResult!,
84
+ vesselRuptureCalc.dischargeRecords!,
85
+ vesselRuptureCalc.dischargeRecords!.length,
86
+ weather,
87
+ new DispersionParameters(),
88
+ 0.0
89
+ );
90
+
91
+ console.log("Running dispersionCalculation...");
92
+ const dispersionResult = await dispersionCalc.run();
93
+
94
+ if (dispersionCalc.messages.length > 0) {
95
+ console.log("Messages:");
96
+ dispersionCalc.messages.forEach(msg => console.log(msg));
97
+ }
98
+
99
+ expect(dispersionResult).toBe(ResultCode.SUCCESS);
100
+ console.log(`SUCCESS: dispersionCalculation (${dispersionCalc.calculationElapsedTime}ms)`);
101
+
102
+ // Define explosion configurations
103
+ const dispersionOutputConfig = new DispersionOutputConfig({
104
+ concentration: 0.0,
105
+ specialConcentration: SpecialConcentration.MIN
106
+ });
107
+
108
+ const explosionParams = new ExplosionParameters({
109
+ explosionUniformStrength: 7.0
110
+ });
111
+
112
+ const explosionOutputConfig = new ExplosionOutputConfig({
113
+ overpressureLevel: 1034
114
+ });
115
+
116
+ const explosionConfinedVolumes = [
117
+ new ExplosionConfinedVolume(),
118
+ new ExplosionConfinedVolume()
119
+ ];
120
+
121
+ // Create and run explosion calculation
122
+ const explosionCalc = new LateExplosionCalculation(
123
+ exitMaterial,
124
+ dispersionCalc.scalarUdmOutputs!,
125
+ weather,
126
+ dispersionCalc.dispersionRecords!,
127
+ dispersionCalc.dispersionRecords!.length,
128
+ substrate,
129
+ dispersionOutputConfig,
130
+ explosionOutputConfig,
131
+ explosionParams,
132
+ explosionConfinedVolumes,
133
+ explosionConfinedVolumes.length,
134
+ new DispersionParameters()
135
+ );
136
+
137
+ console.log("Running lateExplosionCalculation...");
138
+ const explosionResult = await explosionCalc.run();
139
+
140
+ if (explosionCalc.messages.length > 0) {
141
+ console.log("Messages:");
142
+ explosionCalc.messages.forEach(msg => console.log(msg));
143
+ }
144
+
145
+ expect(explosionResult).toBe(ResultCode.SUCCESS);
146
+
147
+ // Regression checks
148
+ const result = explosionCalc.explosionUnifConfOverpressureResult!;
149
+ const expectedMass = 1005.5754053562894;
150
+ const expectedTime = 0.5886114409418679;
151
+ const expectedDistance = 626.5034456922325;
152
+
153
+ const massError = Math.abs((result.explodedMass! - expectedMass) / expectedMass);
154
+ const timeError = Math.abs((result.ignitionTime! - expectedTime) / expectedTime);
155
+ const distanceError = Math.abs((result.maximumDistance! - expectedDistance) / expectedDistance);
156
+
157
+ expect(massError).toBeLessThan(1e-3);
158
+ expect(timeError).toBeLessThan(1e-3);
159
+ expect(distanceError).toBeLessThan(1e-3);
160
+
161
+ console.log(`SUCCESS: lateExplosionCalculation (${explosionCalc.calculationElapsedTime}ms)`);
162
+ });
163
+ });
@@ -0,0 +1,174 @@
1
+ import { Material, MaterialComponent, State, ReliefValve, Vessel, Weather, Substrate, DischargeParameters, DispersionParameters, DispersionOutputConfig, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume } from "../../src/entities";
2
+ import { VesselStateCalculation, VesselReliefValveCalculation } from "../../src/calculations/discharge";
3
+ import { DispersionCalculation } from "../../src/calculations/dispersion";
4
+ import { LateExplosionToOPLevelsCalculation } 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 76", () => {
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: 270.0,
20
+ pressure: 8e6,
21
+ liquidFraction: 1.0
22
+ });
23
+
24
+ // Define the material contained by the vessel
25
+ const material = new Material({
26
+ name: "HYDROGEN",
27
+ components: [new MaterialComponent({ name: "HYDROGEN", 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 (sphere with 5m diameter)
45
+ const vessel = new Vessel({
46
+ state,
47
+ material,
48
+ vesselConditions: vesselStateCalc.vesselConditions,
49
+ liquidFillFractionByVolume: 0.7,
50
+ shape: VesselShape.VESSEL_SPHERE,
51
+ diameter: 5
52
+ });
53
+
54
+ // Create relief valve
55
+ const reliefValve = new ReliefValve({
56
+ pipeDiameter: 0.5,
57
+ pipeLength: 1.0,
58
+ pipeHeightFraction: 1,
59
+ reliefValveConstrictionDiameter: 0.25
60
+ });
61
+
62
+ // Create and run vessel relief valve calculation
63
+ const reliefValveCalc = new VesselReliefValveCalculation(vessel, reliefValve, new DischargeParameters());
64
+
65
+ console.log("Running vesselReliefValveCalculation...");
66
+ resultCode = await reliefValveCalc.run();
67
+
68
+ if (reliefValveCalc.messages.length > 0) {
69
+ console.log("Messages:");
70
+ reliefValveCalc.messages.forEach((msg) => console.log(msg));
71
+ }
72
+
73
+ expect(resultCode).toBe(ResultCode.SUCCESS);
74
+ console.log(`SUCCESS: vesselReliefValveCalculation (${reliefValveCalc.calculationElapsedTime}ms)`);
75
+ console.log(`vesselReliefValveCalculation.dischargeResult.releaseMass: ${reliefValveCalc.dischargeResult!.releaseMass} [kg]`);
76
+
77
+ const exitMaterial = reliefValveCalc.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
+ reliefValveCalc.dischargeResult!,
94
+ reliefValveCalc.dischargeRecords!,
95
+ reliefValveCalc.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 explosionOutputConfigs = [
123
+ new ExplosionOutputConfig({ overpressureLevel: 4136 })
124
+ ];
125
+
126
+ const explosionConfinedVolumes = [
127
+ new ExplosionConfinedVolume(),
128
+ new ExplosionConfinedVolume()
129
+ ];
130
+
131
+ // Create and run explosion calculation
132
+ const explosionCalc = new LateExplosionToOPLevelsCalculation(
133
+ exitMaterial,
134
+ dispersionCalc.scalarUdmOutputs!,
135
+ weather,
136
+ dispersionCalc.dispersionRecords!,
137
+ dispersionCalc.dispersionRecords!.length,
138
+ substrate,
139
+ dispersionOutputConfig,
140
+ explosionOutputConfigs,
141
+ explosionOutputConfigs.length,
142
+ explosionParams,
143
+ explosionConfinedVolumes,
144
+ explosionConfinedVolumes.length,
145
+ new DispersionParameters()
146
+ );
147
+
148
+ console.log("Running lateExplosionToOPLevelsCalculation...");
149
+ resultCode = await explosionCalc.run();
150
+
151
+ if (explosionCalc.messages.length > 0) {
152
+ console.log("Messages:");
153
+ explosionCalc.messages.forEach((msg) => console.log(msg));
154
+ }
155
+
156
+ expect(resultCode).toBe(ResultCode.SUCCESS);
157
+
158
+ // Regression checks
159
+ const result = explosionCalc.explosionUnifConfOverpressureResults![0];
160
+ const expectedMass = 364.4122308301167;
161
+ const expectedTime = 4.444690161422924;
162
+ const expectedDistance = 449.089635837361;
163
+
164
+ const massError = Math.abs((result.explodedMass! - expectedMass) / expectedMass);
165
+ const timeError = Math.abs((result.ignitionTime! - expectedTime) / expectedTime);
166
+ const distanceError = Math.abs((result.maximumDistance! - expectedDistance) / expectedDistance);
167
+
168
+ expect(massError).toBeLessThan(1e-3);
169
+ expect(timeError).toBeLessThan(1e-3);
170
+ expect(distanceError).toBeLessThan(1e-3);
171
+
172
+ console.log(`SUCCESS: lateExplosionToOPLevelsCalculation (${explosionCalc.calculationElapsedTime}ms)`);
173
+ });
174
+ });