@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,182 @@
1
+ import { VesselLeakLinkedRunCalculation } from "../../../src/calculations/linkedRunners";
2
+ import { LoadMassInventoryVesselForLeakScenarioCalculation } from "../../../src/calculations/utilities";
3
+ import { Material, MaterialComponent, Weather, Substrate, DischargeParameters, FlammableParameters, DispersionParameters, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume, FlammableOutputConfig, DispersionOutputConfig } from "../../../src/entities";
4
+ import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, WindProfileFlag } from "../../../src/enums";
5
+ import { setAccessToken } from "../../../src/utilities";
6
+
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("VesselLeakLinkedRunCalculation - VLR_157", () => {
16
+ it("should run the calculation and validate regression outputs", async () => {
17
+ // Create material with Ammonia
18
+ const material = new Material({
19
+ name: "AMMONIA",
20
+ components: [new MaterialComponent({ name: "AMMONIA", moleFraction: 1.0 })],
21
+ componentCount: 1
22
+ });
23
+
24
+ // Create a load mass inventory vessel for leak scenario calculation using the material
25
+ const loadMassInventoryVesselForLeakScenarioCalculation = new LoadMassInventoryVesselForLeakScenarioCalculation(
26
+ material,
27
+ 1e3,
28
+ 11e5,
29
+ 250,
30
+ 0.008,
31
+ 1.0,
32
+ 0.35
33
+ );
34
+
35
+ // Run the calculation
36
+ console.log('Running load_mass_inventory_vessel_for_leak_scenario_calculation...');
37
+ const loadResultCode = await loadMassInventoryVesselForLeakScenarioCalculation.run();
38
+
39
+ // Print any messages
40
+ if (loadMassInventoryVesselForLeakScenarioCalculation.messages.length > 0) {
41
+ console.log('Messages:');
42
+ loadMassInventoryVesselForLeakScenarioCalculation.messages.forEach((msg) => console.log(msg));
43
+ }
44
+
45
+ expect(loadResultCode).toBe(ResultCode.SUCCESS);
46
+
47
+ if (loadResultCode === ResultCode.SUCCESS) {
48
+ console.log(`SUCCESS: load_mass_inventory_vessel_for_leak_scenario_calculation (${loadMassInventoryVesselForLeakScenarioCalculation.calculationElapsedTime}ms)`);
49
+ }
50
+
51
+ // Define the weather conditions
52
+ const weather = new Weather({
53
+ windSpeed: 5.0,
54
+ stabilityClass: AtmosphericStabilityClass.STABILITY_B,
55
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
56
+ });
57
+
58
+ // Define the substrate
59
+ const substrate = new Substrate();
60
+
61
+ // Define the dispersion parameters
62
+ const dispersionParameters = [
63
+ new DispersionParameters({ averagingTime: 18.75 }),
64
+ new DispersionParameters({ averagingTime: 18.75 })
65
+ ];
66
+
67
+ // Define the dispersion output configuration
68
+ const dispersionOutputConfigsFlammable = [
69
+ new DispersionOutputConfig({
70
+ specialConcentration: SpecialConcentration.LFL_FRACTION,
71
+ elevation: 0.0
72
+ })
73
+ ];
74
+
75
+ const dispersionOutputConfigsToxic = [
76
+ new DispersionOutputConfig({
77
+ specialConcentration: SpecialConcentration.NOT_DEFINED,
78
+ concentration: 5e-5,
79
+ elevation: 0.0
80
+ })
81
+ ];
82
+
83
+ // Define the flammable parameters
84
+ const flammableParameters = new FlammableParameters();
85
+
86
+ // Define the flammable output configuration
87
+ const flammableOutputConfigs = [new FlammableOutputConfig()];
88
+
89
+ // Define the explosion parameters
90
+ const explosionParameters = new ExplosionParameters();
91
+
92
+ // Define the explosion output configuration
93
+ const explosionOutputConfigs = [new ExplosionOutputConfig()];
94
+
95
+ // Define the explosion confined volumes
96
+ const explosionConfinedVolumes = [new ExplosionConfinedVolume()];
97
+
98
+ // Create the vessel leak linked run calculation
99
+ const vesselLeakLinkedRunCalculation = new VesselLeakLinkedRunCalculation(
100
+ loadMassInventoryVesselForLeakScenarioCalculation.vessel!,
101
+ loadMassInventoryVesselForLeakScenarioCalculation.leak!,
102
+ new DischargeParameters(),
103
+ substrate,
104
+ weather,
105
+ dispersionParameters,
106
+ dispersionParameters.length,
107
+ 0.0,
108
+ flammableParameters,
109
+ explosionParameters,
110
+ dispersionOutputConfigsFlammable,
111
+ dispersionOutputConfigsFlammable.length,
112
+ dispersionOutputConfigsToxic,
113
+ dispersionOutputConfigsToxic.length,
114
+ flammableOutputConfigs,
115
+ flammableOutputConfigs.length,
116
+ explosionOutputConfigs,
117
+ explosionOutputConfigs.length,
118
+ explosionConfinedVolumes,
119
+ explosionConfinedVolumes.length
120
+ );
121
+
122
+ // Run the calculation
123
+ console.log('Running vessel_leak_linked_run_calculation...');
124
+ const resultCode = await vesselLeakLinkedRunCalculation.run();
125
+
126
+ // Print any messages
127
+ if (vesselLeakLinkedRunCalculation.messages.length > 0) {
128
+ console.log('Messages:');
129
+ vesselLeakLinkedRunCalculation.messages.forEach((msg) => console.log(msg));
130
+ }
131
+
132
+ expect(resultCode).toBe(ResultCode.SUCCESS);
133
+
134
+ if (resultCode === ResultCode.SUCCESS) {
135
+ // Check if the results match expected values within tolerance
136
+ expect(
137
+ Math.abs(vesselLeakLinkedRunCalculation.dischargeRecord!.massFlow! - 1.2425987768572015) / 1.2425987768572015
138
+ ).toBeLessThan(1e-3);
139
+
140
+ expect(
141
+ Math.abs(vesselLeakLinkedRunCalculation.jetFireFlameResult!.flameLength! - 20.59055621597361) / 20.59055621597361
142
+ ).toBeLessThan(1e-3);
143
+
144
+ expect(vesselLeakLinkedRunCalculation.poolFireFlameResult!.flameDiameter).toBe(0.0);
145
+
146
+ expect(vesselLeakLinkedRunCalculation.flamConcContourPoints!.length).toBe(0);
147
+
148
+ expect(vesselLeakLinkedRunCalculation.toxicConcContourPoints!.length).toBe(603);
149
+
150
+ expect(vesselLeakLinkedRunCalculation.areaFootprintFlamConc![0]).toBe(0.0);
151
+
152
+ expect(
153
+ Math.abs(vesselLeakLinkedRunCalculation.areaFootprintToxicConc![0] - 28937.347548819664) / 28937.347548819664
154
+ ).toBeLessThan(1e-3);
155
+
156
+ expect(
157
+ Math.abs(vesselLeakLinkedRunCalculation.areaContourJet![0] - 239.35604734762828) / 239.35604734762828
158
+ ).toBeLessThan(1e-3);
159
+
160
+ expect(vesselLeakLinkedRunCalculation.areaContourPool![0]).toBe(0.0);
161
+
162
+ expect(vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].explodedMass).toBe(0.0);
163
+
164
+ expect(vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].maximumDistance).toBe(0.0);
165
+
166
+ // Log key results
167
+ console.log(`Mass flow = ${vesselLeakLinkedRunCalculation.dischargeRecord!.massFlow}`);
168
+ console.log(`Flame length = ${vesselLeakLinkedRunCalculation.jetFireFlameResult!.flameLength}`);
169
+ console.log(`Flame diameter = ${vesselLeakLinkedRunCalculation.poolFireFlameResult!.flameDiameter}`);
170
+ console.log(`Length of the dispersion flammable contour array = ${vesselLeakLinkedRunCalculation.flamConcContourPoints!.length}`);
171
+ console.log(`Length of the dispersion toxic contour array = ${vesselLeakLinkedRunCalculation.toxicConcContourPoints!.length}`);
172
+ console.log(`Area of the flammable cloud = ${vesselLeakLinkedRunCalculation.areaFootprintFlamConc![0]}`);
173
+ console.log(`Area of the toxic cloud = ${vesselLeakLinkedRunCalculation.areaFootprintToxicConc![0]}`);
174
+ console.log(`Area of the jet fire = ${vesselLeakLinkedRunCalculation.areaContourJet![0]}`);
175
+ console.log(`Area of the pool = ${vesselLeakLinkedRunCalculation.areaContourPool![0]}`);
176
+ console.log(`Flammable mass = ${vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].explodedMass}`);
177
+ console.log(`Explosion maximum distance = ${vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].maximumDistance}`);
178
+
179
+ console.log(`SUCCESS: vessel_leak_linked_run_calculation (${vesselLeakLinkedRunCalculation.calculationElapsedTime}ms)`);
180
+ }
181
+ });
182
+ });
@@ -0,0 +1,200 @@
1
+ import { VesselLeakLinkedRunCalculation } from "../../../src/calculations/linkedRunners";
2
+ import { LoadMassInventoryVesselForLeakScenarioCalculation } from "../../../src/calculations/utilities";
3
+ import { Material, MaterialComponent, Weather, Substrate, DischargeParameters, FlammableParameters, DispersionParameters, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume, FlammableOutputConfig, DispersionOutputConfig } from "../../../src/entities";
4
+ import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, WindProfileFlag, MixtureModelling } from "../../../src/enums";
5
+ import { setAccessToken } from "../../../src/utilities";
6
+
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("VesselLeakLinkedRunCalculation - VLR_158", () => {
16
+ it("should run the calculation and validate regression outputs", async () => {
17
+ // Create material with a mixture of propane, butane, and pentane
18
+ const material = new Material({
19
+ name: "PROPANE+N-BUTANE+N-PENTANE",
20
+ components: [
21
+ new MaterialComponent({ name: "PROPANE", moleFraction: 0.1 }),
22
+ new MaterialComponent({ name: "N-BUTANE", moleFraction: 0.3 }),
23
+ new MaterialComponent({ name: "N-PENTANE", moleFraction: 0.6 })
24
+ ],
25
+ componentCount: 3
26
+ });
27
+
28
+ // Create a load mass inventory vessel for leak scenario calculation using the material
29
+ const loadMassInventoryVesselForLeakScenarioCalculation = new LoadMassInventoryVesselForLeakScenarioCalculation(
30
+ material,
31
+ 1e4,
32
+ 6e5,
33
+ 250,
34
+ 0.08,
35
+ 1.0,
36
+ 0.0
37
+ );
38
+
39
+ // Run the calculation
40
+ console.log('Running load_mass_inventory_vessel_for_leak_scenario_calculation...');
41
+ const loadResultCode = await loadMassInventoryVesselForLeakScenarioCalculation.run();
42
+
43
+ // Print any messages
44
+ if (loadMassInventoryVesselForLeakScenarioCalculation.messages.length > 0) {
45
+ console.log('Messages:');
46
+ loadMassInventoryVesselForLeakScenarioCalculation.messages.forEach((msg) => console.log(msg));
47
+ }
48
+
49
+ expect(loadResultCode).toBe(ResultCode.SUCCESS);
50
+
51
+ if (loadResultCode === ResultCode.SUCCESS) {
52
+ console.log(`SUCCESS: load_mass_inventory_vessel_for_leak_scenario_calculation (${loadMassInventoryVesselForLeakScenarioCalculation.calculationElapsedTime}ms)`);
53
+ }
54
+
55
+ // Define the weather conditions
56
+ const weather = new Weather({
57
+ windSpeed: 5.0,
58
+ stabilityClass: AtmosphericStabilityClass.STABILITY_B,
59
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
60
+ });
61
+
62
+ // Define the substrate
63
+ const substrate = new Substrate();
64
+
65
+ // Define the dispersion parameters
66
+ const dispersionParameters = [
67
+ new DispersionParameters({ averagingTime: 18.75 }),
68
+ new DispersionParameters({ averagingTime: 18.75 })
69
+ ];
70
+
71
+ // Define the dispersion output configuration
72
+ const dispersionOutputConfigsFlammable = [
73
+ new DispersionOutputConfig({
74
+ specialConcentration: SpecialConcentration.LFL_FRACTION,
75
+ elevation: 0.0
76
+ })
77
+ ];
78
+
79
+ const dispersionOutputConfigsToxic = [
80
+ new DispersionOutputConfig({
81
+ specialConcentration: SpecialConcentration.NOT_DEFINED,
82
+ concentration: 5e-5,
83
+ elevation: 0.0
84
+ })
85
+ ];
86
+
87
+ // Define the flammable parameters
88
+ const flammableParameters = new FlammableParameters();
89
+
90
+ // Define the flammable output configuration
91
+ const flammableOutputConfigs = [new FlammableOutputConfig()];
92
+
93
+ // Define the explosion parameters
94
+ const explosionParameters = new ExplosionParameters();
95
+
96
+ // Define the explosion output configuration
97
+ const explosionOutputConfigs = [new ExplosionOutputConfig()];
98
+
99
+ // Define the explosion confined volumes
100
+ const explosionConfinedVolumes = [new ExplosionConfinedVolume()];
101
+
102
+ // Set mixture modeling to MC_MULTIPLE_AEROSOL
103
+ const vessel = loadMassInventoryVesselForLeakScenarioCalculation.vessel!;
104
+ vessel.state!.mixtureModelling = MixtureModelling.MC_MULTIPLE_AEROSOL;
105
+
106
+ // Create the vessel leak linked run calculation
107
+ const vesselLeakLinkedRunCalculation = new VesselLeakLinkedRunCalculation(
108
+ vessel,
109
+ loadMassInventoryVesselForLeakScenarioCalculation.leak!,
110
+ new DischargeParameters(),
111
+ substrate,
112
+ weather,
113
+ dispersionParameters,
114
+ dispersionParameters.length,
115
+ 0.0,
116
+ flammableParameters,
117
+ explosionParameters,
118
+ dispersionOutputConfigsFlammable,
119
+ dispersionOutputConfigsFlammable.length,
120
+ dispersionOutputConfigsToxic,
121
+ dispersionOutputConfigsToxic.length,
122
+ flammableOutputConfigs,
123
+ flammableOutputConfigs.length,
124
+ explosionOutputConfigs,
125
+ explosionOutputConfigs.length,
126
+ explosionConfinedVolumes,
127
+ explosionConfinedVolumes.length
128
+ );
129
+
130
+ // Run the calculation
131
+ console.log('Running vessel_leak_linked_run_calculation...');
132
+ const resultCode = await vesselLeakLinkedRunCalculation.run();
133
+
134
+ // Print any messages
135
+ if (vesselLeakLinkedRunCalculation.messages.length > 0) {
136
+ console.log('Messages:');
137
+ vesselLeakLinkedRunCalculation.messages.forEach((msg) => console.log(msg));
138
+ }
139
+
140
+ expect(resultCode).toBe(ResultCode.SUCCESS);
141
+
142
+ if (resultCode === ResultCode.SUCCESS) {
143
+ // Check if the results match expected values within tolerance
144
+ expect(
145
+ Math.abs(vesselLeakLinkedRunCalculation.dischargeRecord!.massFlow! - 79.92636564283663) / 79.92636564283663
146
+ ).toBeLessThan(1e-3);
147
+
148
+ expect(
149
+ Math.abs(vesselLeakLinkedRunCalculation.jetFireFlameResult!.flameLength! - 77.05440102800145) / 77.05440102800145
150
+ ).toBeLessThan(1e-3);
151
+
152
+ expect(
153
+ Math.abs(vesselLeakLinkedRunCalculation.poolFireFlameResult!.flameDiameter! - 41.782142639160156) / 41.782142639160156
154
+ ).toBeLessThan(1e-3);
155
+
156
+ expect(vesselLeakLinkedRunCalculation.flamConcContourPoints!.length).toBe(601);
157
+
158
+ expect(vesselLeakLinkedRunCalculation.toxicConcContourPoints!.length).toBe(693);
159
+
160
+ expect(
161
+ Math.abs(vesselLeakLinkedRunCalculation.areaFootprintFlamConc![0] - 11080.56953438209) / 11080.56953438209
162
+ ).toBeLessThan(1e-3);
163
+
164
+ expect(
165
+ Math.abs(vesselLeakLinkedRunCalculation.areaFootprintToxicConc![0] - 445160.15045601147) / 445160.15045601147
166
+ ).toBeLessThan(1e-3);
167
+
168
+ expect(
169
+ Math.abs(vesselLeakLinkedRunCalculation.areaContourJet![0] - 61978.79874189871) / 61978.79874189871
170
+ ).toBeLessThan(1e-3);
171
+
172
+ expect(
173
+ Math.abs(vesselLeakLinkedRunCalculation.areaContourPool![0] - 14778.202000753792) / 14778.202000753792
174
+ ).toBeLessThan(1e-3);
175
+
176
+ expect(
177
+ Math.abs(vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].explodedMass! - 680.3354816239089) / 680.3354816239089
178
+ ).toBeLessThan(1e-3);
179
+
180
+ expect(
181
+ Math.abs(vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].maximumDistance! - 552.0412952025639) / 552.0412952025639
182
+ ).toBeLessThan(1e-3);
183
+
184
+ // Log key results
185
+ console.log(`Mass flow = ${vesselLeakLinkedRunCalculation.dischargeRecord!.massFlow}`);
186
+ console.log(`Flame length = ${vesselLeakLinkedRunCalculation.jetFireFlameResult!.flameLength}`);
187
+ console.log(`Flame diameter = ${vesselLeakLinkedRunCalculation.poolFireFlameResult!.flameDiameter}`);
188
+ console.log(`Length of the dispersion flammable contour array = ${vesselLeakLinkedRunCalculation.flamConcContourPoints!.length}`);
189
+ console.log(`Length of the dispersion toxic contour array = ${vesselLeakLinkedRunCalculation.toxicConcContourPoints!.length}`);
190
+ console.log(`Area of the flammable cloud = ${vesselLeakLinkedRunCalculation.areaFootprintFlamConc![0]}`);
191
+ console.log(`Area of the toxic cloud = ${vesselLeakLinkedRunCalculation.areaFootprintToxicConc![0]}`);
192
+ console.log(`Area of the jet fire = ${vesselLeakLinkedRunCalculation.areaContourJet![0]}`);
193
+ console.log(`Area of the pool = ${vesselLeakLinkedRunCalculation.areaContourPool![0]}`);
194
+ console.log(`Flammable mass = ${vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].explodedMass}`);
195
+ console.log(`Explosion maximum distance = ${vesselLeakLinkedRunCalculation.explosionOverpressureResults![0].maximumDistance}`);
196
+
197
+ console.log(`SUCCESS: vessel_leak_linked_run_calculation (${vesselLeakLinkedRunCalculation.calculationElapsedTime}ms)`);
198
+ }
199
+ });
200
+ });
@@ -0,0 +1,158 @@
1
+ import { VesselLeakLinkedRunCalculation } from "../../../src/calculations/linkedRunners";
2
+ import { LoadMassInventoryVesselForLeakScenarioCalculation } from "../../../src/calculations/utilities";
3
+ import {
4
+ Material, MaterialComponent, Weather, Substrate, DischargeParameters,
5
+ FlammableParameters, DispersionParameters, ExplosionParameters,
6
+ ExplosionOutputConfig, ExplosionConfinedVolume, FlammableOutputConfig,
7
+ DispersionOutputConfig
8
+ } from "../../../src/entities";
9
+ import {
10
+ ResultCode, AtmosphericStabilityClass, SpecialConcentration,
11
+ WindProfileFlag, MixtureModelling
12
+ } from "../../../src/enums";
13
+ import { setAccessToken } from "../../../src/utilities";
14
+
15
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
16
+
17
+ if (!accessToken) {
18
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
19
+ }
20
+
21
+ setAccessToken(accessToken);
22
+
23
+ describe("VesselLeakLinkedRunCalculation - VLR_159", () => {
24
+ it("should run the calculation and validate regression outputs", async () => {
25
+ const material = new Material({
26
+ name: "H2S+N-BUTANE",
27
+ components: [
28
+ new MaterialComponent({ name: "HYDROGEN SULFIDE", moleFraction: 0.02 }),
29
+ new MaterialComponent({ name: "N-BUTANE", moleFraction: 0.98 })
30
+ ],
31
+ componentCount: 2
32
+ });
33
+
34
+ const loadCalc = new LoadMassInventoryVesselForLeakScenarioCalculation(
35
+ material,
36
+ 1e4, // mass
37
+ 6e5, // pressure
38
+ 250, // temperature
39
+ 0.08, // hole size
40
+ 1.0, // release elevation
41
+ 0.0 // release angle
42
+ );
43
+
44
+ console.log("Running load_mass_inventory_vessel_for_leak_scenario_calculation...");
45
+ const loadResult = await loadCalc.run();
46
+
47
+ if (loadCalc.messages.length > 0) {
48
+ console.log("Messages:");
49
+ loadCalc.messages.forEach(msg => console.log(msg));
50
+ }
51
+
52
+ expect(loadResult).toBe(ResultCode.SUCCESS);
53
+
54
+ if (loadResult === ResultCode.SUCCESS) {
55
+ console.log(`SUCCESS: load_mass_inventory_vessel_for_leak_scenario_calculation (${loadCalc.calculationElapsedTime}ms)`);
56
+ }
57
+
58
+ const weather = new Weather({
59
+ windSpeed: 5.0,
60
+ stabilityClass: AtmosphericStabilityClass.STABILITY_B,
61
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
62
+ });
63
+
64
+ const substrate = new Substrate();
65
+
66
+ const dispersionParams = [
67
+ new DispersionParameters({ averagingTime: 18.75 }),
68
+ new DispersionParameters({ averagingTime: 18.75 })
69
+ ];
70
+
71
+ const flamOutputConfigs = [
72
+ new DispersionOutputConfig({
73
+ specialConcentration: SpecialConcentration.LFL_FRACTION,
74
+ elevation: 0.0
75
+ })
76
+ ];
77
+
78
+ const toxicOutputConfigs = [
79
+ new DispersionOutputConfig({
80
+ specialConcentration: SpecialConcentration.NOT_DEFINED,
81
+ concentration: 5e-5,
82
+ elevation: 0.0
83
+ })
84
+ ];
85
+
86
+ const flammableParams = new FlammableParameters();
87
+ const flammableOutputConfigs = [new FlammableOutputConfig()];
88
+ const explosionParams = new ExplosionParameters();
89
+ const explosionOutputConfigs = [new ExplosionOutputConfig()];
90
+ const confinedVolumes = [new ExplosionConfinedVolume()];
91
+
92
+ const vessel = loadCalc.vessel!;
93
+ vessel.state!.mixtureModelling = MixtureModelling.MC_MULTIPLE_AEROSOL;
94
+
95
+ const vlrCalc = new VesselLeakLinkedRunCalculation(
96
+ vessel,
97
+ loadCalc.leak!,
98
+ new DischargeParameters(),
99
+ substrate,
100
+ weather,
101
+ dispersionParams,
102
+ dispersionParams.length,
103
+ 0.0,
104
+ flammableParams,
105
+ explosionParams,
106
+ flamOutputConfigs,
107
+ flamOutputConfigs.length,
108
+ toxicOutputConfigs,
109
+ toxicOutputConfigs.length,
110
+ flammableOutputConfigs,
111
+ flammableOutputConfigs.length,
112
+ explosionOutputConfigs,
113
+ explosionOutputConfigs.length,
114
+ confinedVolumes,
115
+ confinedVolumes.length
116
+ );
117
+
118
+ console.log("Running vessel_leak_linked_run_calculation...");
119
+ const result = await vlrCalc.run();
120
+
121
+ if (vlrCalc.messages.length > 0) {
122
+ console.log("Messages:");
123
+ vlrCalc.messages.forEach(msg => console.log(msg));
124
+ }
125
+
126
+ expect(result).toBe(ResultCode.SUCCESS);
127
+
128
+ if (result === ResultCode.SUCCESS) {
129
+ const relErr = (actual: number, expected: number) => Math.abs(actual - expected) / expected;
130
+
131
+ expect(relErr(vlrCalc.dischargeRecord!.massFlow!, 78.2703129718767)).toBeLessThan(1e-3);
132
+ expect(relErr(vlrCalc.jetFireFlameResult!.flameLength!, 79.83450740611565)).toBeLessThan(1e-3);
133
+ expect(relErr(vlrCalc.poolFireFlameResult!.flameDiameter!, 40.45197677612305)).toBeLessThan(1e-3);
134
+ expect(vlrCalc.flamConcContourPoints!.length).toBe(593);
135
+ expect(vlrCalc.toxicConcContourPoints!.length).toBe(695);
136
+ expect(relErr(vlrCalc.areaFootprintFlamConc![0], 11956.182247202978)).toBeLessThan(1e-3);
137
+ expect(relErr(vlrCalc.areaFootprintToxicConc![0], 508942.11044945125)).toBeLessThan(1e-3);
138
+ expect(relErr(vlrCalc.areaContourJet![0], 59421.0918161459)).toBeLessThan(1e-3);
139
+ expect(relErr(vlrCalc.areaContourPool![0], 89742.0801748534)).toBeLessThan(1e-3);
140
+ expect(relErr(vlrCalc.explosionOverpressureResults![0].explodedMass!, 599.1546378493579)).toBeLessThan(1e-3);
141
+ expect(relErr(vlrCalc.explosionOverpressureResults![0].maximumDistance!, 536.4452979306577)).toBeLessThan(1e-3);
142
+
143
+ // Logs
144
+ console.log(`Mass flow = ${vlrCalc.dischargeRecord!.massFlow}`);
145
+ console.log(`Flame length = ${vlrCalc.jetFireFlameResult!.flameLength}`);
146
+ console.log(`Flame diameter = ${vlrCalc.poolFireFlameResult!.flameDiameter}`);
147
+ console.log(`Flammable contour points = ${vlrCalc.flamConcContourPoints!.length}`);
148
+ console.log(`Toxic contour points = ${vlrCalc.toxicConcContourPoints!.length}`);
149
+ console.log(`Area flammable cloud = ${vlrCalc.areaFootprintFlamConc![0]}`);
150
+ console.log(`Area toxic cloud = ${vlrCalc.areaFootprintToxicConc![0]}`);
151
+ console.log(`Area jet fire = ${vlrCalc.areaContourJet![0]}`);
152
+ console.log(`Area pool fire = ${vlrCalc.areaContourPool![0]}`);
153
+ console.log(`Exploded mass = ${vlrCalc.explosionOverpressureResults![0].explodedMass}`);
154
+ console.log(`Explosion max distance = ${vlrCalc.explosionOverpressureResults![0].maximumDistance}`);
155
+ console.log(`SUCCESS: vessel_leak_linked_run_calculation (${vlrCalc.calculationElapsedTime}ms)`);
156
+ }
157
+ });
158
+ });