@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,167 @@
1
+ import { UserDefinedSourceLinkedRunCalculation } from "../../../src/calculations/linkedRunners";
2
+ import { Material, MaterialComponent, Weather, Substrate, DischargeParameters, FlammableParameters, DispersionParameters, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume, FlammableOutputConfig, DispersionOutputConfig, State, DischargeRecord, DischargeResult } from "../../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, WindProfileFlag, Phase, FluidSpec, DynamicType } from "../../../src/enums";
4
+ import { setAccessToken } from "../../../src/utilities";
5
+
6
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
7
+
8
+ if (!accessToken) {
9
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
10
+ }
11
+
12
+ setAccessToken(accessToken);
13
+
14
+ describe("UserDefinedSourceLinkedRunCalculation - VLR_154", () => {
15
+ it("should run the calculation and validate regression outputs", async () => {
16
+ const material = new Material({
17
+ name: "N-HEXANE",
18
+ components: [new MaterialComponent({ name: "N-HEXANE", moleFraction: 1.0 })],
19
+ componentCount: 1
20
+ });
21
+
22
+ const weather = new Weather({
23
+ windSpeed: 10.0,
24
+ stabilityClass: AtmosphericStabilityClass.STABILITY_A_,
25
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
26
+ });
27
+
28
+ const substrate = new Substrate();
29
+
30
+ const dispersionParameters = [
31
+ new DispersionParameters({ averagingTime: 18.75 }),
32
+ new DispersionParameters({ averagingTime: 600.0 })
33
+ ];
34
+
35
+ const dispersionOutputConfigsFlammable = [
36
+ new DispersionOutputConfig({
37
+ specialConcentration: SpecialConcentration.LFL_FRACTION,
38
+ elevation: 1.0
39
+ })
40
+ ];
41
+
42
+ const dispersionOutputConfigsToxic = [
43
+ new DispersionOutputConfig({
44
+ specialConcentration: SpecialConcentration.MIN,
45
+ elevation: 0.0
46
+ })
47
+ ];
48
+
49
+ const flammableParameters = new FlammableParameters();
50
+ const flammableOutputConfigs = [new FlammableOutputConfig()];
51
+
52
+ const explosionParameters = new ExplosionParameters();
53
+ const explosionOutputConfigs = [new ExplosionOutputConfig()];
54
+ const explosionConfinedVolumes = [new ExplosionConfinedVolume()];
55
+
56
+ const dischargeRecord = new DischargeRecord({
57
+ massFlow: 100.0,
58
+ time: 360.0,
59
+ finalState: new State({
60
+ temperature: 200.0,
61
+ pressure: 101325.0,
62
+ flashFlag: FluidSpec.TP,
63
+ liquidFraction: 1.0
64
+ }),
65
+ orificeState: new State({
66
+ temperature: 300.0,
67
+ pressure: 101325.0,
68
+ liquidFraction: 1.0
69
+ }),
70
+ orificeVelocity: 0.0,
71
+ storageState: new State({
72
+ temperature: 300.0,
73
+ pressure: 101325.0,
74
+ liquidFraction: 1.0
75
+ }),
76
+ finalVelocity: 60.0,
77
+ dropletDiameter: 0.0015
78
+ });
79
+
80
+ const dischargeResult = new DischargeResult({
81
+ releaseMass: 3000.0,
82
+ height: 1.0,
83
+ angle: -0.30,
84
+ holeDiameter: 0.3,
85
+ releaseType: DynamicType.CONTINUOUS,
86
+ preDilutionAirRate: 0.0,
87
+ expansionEnergy: 6000.0
88
+ });
89
+
90
+ const calculation = new UserDefinedSourceLinkedRunCalculation(
91
+ material,
92
+ dischargeResult,
93
+ [dischargeRecord],
94
+ 1,
95
+ Phase.LIQUID,
96
+ new DischargeParameters(),
97
+ substrate,
98
+ weather,
99
+ dispersionParameters,
100
+ 2,
101
+ 0.0,
102
+ flammableParameters,
103
+ explosionParameters,
104
+ dispersionOutputConfigsFlammable,
105
+ 1,
106
+ dispersionOutputConfigsToxic,
107
+ 1,
108
+ flammableOutputConfigs,
109
+ 1,
110
+ explosionOutputConfigs,
111
+ 1,
112
+ explosionConfinedVolumes,
113
+ 1
114
+ );
115
+
116
+ console.log("Running user_defined_source_linked_run_calculation...");
117
+ const resultCode = await calculation.run();
118
+
119
+ if (calculation.messages.length > 0) {
120
+ console.log("Messages:");
121
+ calculation.messages.forEach((msg) => console.log(msg));
122
+ }
123
+
124
+ expect(resultCode).toBe(ResultCode.SUCCESS);
125
+
126
+ if (resultCode === ResultCode.SUCCESS) {
127
+ expect(
128
+ Math.abs(calculation.jetFireFlameResult!.flameLength! - 1.20062703145107) / 1.20062703145107
129
+ ).toBeLessThan(1e-3);
130
+
131
+ expect(
132
+ Math.abs(calculation.poolFireFlameResult!.flameDiameter! - 110.98406982421875) / 110.98406982421875
133
+ ).toBeLessThan(1e-3);
134
+
135
+ expect(calculation.flamConcContourPoints!.length).toBe(845);
136
+ expect(calculation.toxicConcContourPoints!.length).toBe(623);
137
+
138
+ expect(
139
+ Math.abs(calculation.areaFootprintFlamConc![0] - 58.403489642509236) / 58.403489642509236
140
+ ).toBeLessThan(1e-3);
141
+
142
+ expect(
143
+ Math.abs(calculation.areaFootprintToxicConc![0] - 246.68210076602227) / 246.68210076602227
144
+ ).toBeLessThan(1e-3);
145
+
146
+ expect(
147
+ Math.abs(calculation.areaContourJet![0] - 7.049885685309768) / 7.049885685309768
148
+ ).toBeLessThan(1e-3);
149
+
150
+ expect(
151
+ Math.abs(calculation.areaContourPool![0] - 58892.18880393686) / 58892.18880393686
152
+ ).toBeLessThan(1e-3);
153
+
154
+ expect(
155
+ Math.abs(calculation.explosionOverpressureResults![0].explodedMass! - 0.4674426254901133) /
156
+ 0.4674426254901133
157
+ ).toBeLessThan(1e-3);
158
+
159
+ expect(
160
+ Math.abs(calculation.explosionOverpressureResults![0].maximumDistance! - 53.57915999004202) /
161
+ 53.57915999004202
162
+ ).toBeLessThan(1e-3);
163
+
164
+ console.log(`SUCCESS: user_defined_source_linked_run_calculation (${calculation.calculationElapsedTime}ms)`);
165
+ }
166
+ });
167
+ });
@@ -0,0 +1,202 @@
1
+ import { UserDefinedSourceLinkedRunCalculation } from "../../../src/calculations/linkedRunners";
2
+ import { Material, MaterialComponent, Weather, Substrate, DischargeParameters, FlammableParameters, DispersionParameters, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume, FlammableOutputConfig, DispersionOutputConfig, State, DischargeRecord, DischargeResult, Bund } from "../../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, WindProfileFlag, Phase, FluidSpec, DynamicType } from "../../../src/enums";
4
+ import { setAccessToken } from "../../../src/utilities";
5
+
6
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
7
+
8
+ if (!accessToken) {
9
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
10
+ }
11
+
12
+ setAccessToken(accessToken);
13
+
14
+ describe("UserDefinedSourceLinkedRunCalculation - VLR_155", () => {
15
+ it("should run the calculation and validate regression outputs", async () => {
16
+ // Define the material - N-HEXANE + H2S + N-OCTANE
17
+ const material = new Material({
18
+ name: "N-HEXANE + H2S + N-OCTANE",
19
+ components: [
20
+ new MaterialComponent({ name: "N-HEXANE", moleFraction: 0.4 }),
21
+ new MaterialComponent({ name: "HYDROGEN SULFIDE", moleFraction: 0.05 }),
22
+ new MaterialComponent({ name: "N-OCTANE", moleFraction: 0.55 })
23
+ ],
24
+ componentCount: 3
25
+ });
26
+
27
+ // Define the weather conditions
28
+ const weather = new Weather({
29
+ windSpeed: 2.0,
30
+ stabilityClass: AtmosphericStabilityClass.STABILITY_D,
31
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
32
+ });
33
+
34
+ // Define the substrate with bund
35
+ const substrate = new Substrate({
36
+ bund: new Bund({
37
+ specifyBund: true,
38
+ bundHeight: 0.5,
39
+ bundDiameter: 10
40
+ })
41
+ });
42
+
43
+ // Define the dispersion parameters
44
+ const dispersionParameters = [
45
+ new DispersionParameters({ averagingTime: 18.75 }),
46
+ new DispersionParameters({ averagingTime: 600.0 })
47
+ ];
48
+
49
+ // Define the dispersion output configuration
50
+ const dispersionOutputConfigsFlammable = [
51
+ new DispersionOutputConfig({
52
+ specialConcentration: SpecialConcentration.LFL_FRACTION,
53
+ elevation: 1.0
54
+ })
55
+ ];
56
+
57
+ const dispersionOutputConfigsToxic = [
58
+ new DispersionOutputConfig({
59
+ specialConcentration: SpecialConcentration.MIN,
60
+ elevation: 1.0
61
+ })
62
+ ];
63
+
64
+ // Define the flammable parameters
65
+ const flammableParameters = new FlammableParameters();
66
+
67
+ // Define the flammable output configuration
68
+ const flammableOutputConfigs = [new FlammableOutputConfig()];
69
+
70
+ // Define the explosion parameters
71
+ const explosionParameters = new ExplosionParameters();
72
+
73
+ // Define the explosion output configuration
74
+ const explosionOutputConfigs = [new ExplosionOutputConfig()];
75
+
76
+ // Define the explosion confined volumes
77
+ const explosionConfinedVolumes = [new ExplosionConfinedVolume()];
78
+
79
+ // Define the discharge record
80
+ const dischargeRecord = new DischargeRecord({
81
+ massFlow: 60.0,
82
+ time: 3600.0,
83
+ finalState: new State({
84
+ temperature: 300.0,
85
+ pressure: 101325.0,
86
+ flashFlag: FluidSpec.PLF,
87
+ liquidFraction: 0.6
88
+ }),
89
+ orificeState: new State({
90
+ temperature: 300.0,
91
+ pressure: 101325.0,
92
+ liquidFraction: 1.0
93
+ }),
94
+ orificeVelocity: 0.0,
95
+ storageState: new State({
96
+ temperature: 300.0,
97
+ pressure: 101325.0,
98
+ liquidFraction: 1.0
99
+ }),
100
+ finalVelocity: 3.0,
101
+ dropletDiameter: 0.0015
102
+ });
103
+
104
+ // Define the discharge result
105
+ const dischargeResult = new DischargeResult({
106
+ releaseMass: 3000.0,
107
+ height: 1.0,
108
+ angle: -0.30,
109
+ holeDiameter: 0.3,
110
+ releaseType: DynamicType.CONTINUOUS,
111
+ preDilutionAirRate: 0.0,
112
+ expansionEnergy: 6000.0
113
+ });
114
+
115
+ // Create the calculation
116
+ const calculation = new UserDefinedSourceLinkedRunCalculation(
117
+ material,
118
+ dischargeResult,
119
+ [dischargeRecord],
120
+ 1,
121
+ Phase.TWO_PHASE,
122
+ new DischargeParameters(),
123
+ substrate,
124
+ weather,
125
+ dispersionParameters,
126
+ 2,
127
+ 0.0,
128
+ flammableParameters,
129
+ explosionParameters,
130
+ dispersionOutputConfigsFlammable,
131
+ 1,
132
+ dispersionOutputConfigsToxic,
133
+ 1,
134
+ flammableOutputConfigs,
135
+ 1,
136
+ explosionOutputConfigs,
137
+ 1,
138
+ explosionConfinedVolumes,
139
+ 1
140
+ );
141
+
142
+ console.log("Running user_defined_source_linked_run_calculation...");
143
+ const resultCode = await calculation.run();
144
+
145
+ if (calculation.messages.length > 0) {
146
+ console.log("Messages:");
147
+ calculation.messages.forEach((msg) => console.log(msg));
148
+ }
149
+
150
+ expect(resultCode).toBe(ResultCode.SUCCESS);
151
+
152
+ if (resultCode === ResultCode.SUCCESS) {
153
+ // Check jet fire flame length
154
+ expect(
155
+ Math.abs(calculation.jetFireFlameResult!.flameLength! - 80.16969583685379) / 80.16969583685379
156
+ ).toBeLessThan(1e-3);
157
+
158
+ // Check pool fire flame diameter
159
+ expect(
160
+ Math.abs(calculation.poolFireFlameResult!.flameDiameter! - 10.003320693969727) / 10.003320693969727
161
+ ).toBeLessThan(1e-3);
162
+
163
+ // Check flammable concentration contour points
164
+ expect(calculation.flamConcContourPoints!.length).toBe(631);
165
+
166
+ // Check toxic concentration contour points
167
+ expect(calculation.toxicConcContourPoints!.length).toBe(655);
168
+
169
+ // Check area footprint flammable concentration
170
+ expect(
171
+ Math.abs(calculation.areaFootprintFlamConc![0] - 41211.35703106363) / 41211.35703106363
172
+ ).toBeLessThan(1e-3);
173
+
174
+ // Check area footprint toxic concentration
175
+ expect(
176
+ Math.abs(calculation.areaFootprintToxicConc![0] - 118848.08490953424) / 118848.08490953424
177
+ ).toBeLessThan(1e-3);
178
+
179
+ // Check area contour jet
180
+ expect(
181
+ Math.abs(calculation.areaContourJet![0] - 43404.20877637401) / 43404.20877637401
182
+ ).toBeLessThan(1e-3);
183
+
184
+ // Check area contour pool
185
+ expect(
186
+ Math.abs(calculation.areaContourPool![0] - 7403.796952127473) / 7403.796952127473
187
+ ).toBeLessThan(1e-3);
188
+
189
+ // Check explosion overpressure results exploded mass
190
+ expect(
191
+ Math.abs(calculation.explosionOverpressureResults![0].explodedMass! - 2672.757423118294) / 2672.757423118294
192
+ ).toBeLessThan(1e-3);
193
+
194
+ // Check explosion overpressure results maximum distance
195
+ expect(
196
+ Math.abs(calculation.explosionOverpressureResults![0].maximumDistance! - 1017.2702969747482) / 1017.2702969747482
197
+ ).toBeLessThan(1e-3);
198
+
199
+ console.log(`SUCCESS: user_defined_source_linked_run_calculation (${calculation.calculationElapsedTime}ms)`);
200
+ }
201
+ });
202
+ });
@@ -0,0 +1,201 @@
1
+ import { UserDefinedSourceLinkedRunCalculation } from "../../../src/calculations/linkedRunners";
2
+ import { Material, MaterialComponent, Weather, Substrate, DischargeParameters, FlammableParameters, DispersionParameters, ExplosionParameters, ExplosionOutputConfig, ExplosionConfinedVolume, FlammableOutputConfig, DispersionOutputConfig, State, DischargeRecord, DischargeResult, Bund } from "../../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, SpecialConcentration, WindProfileFlag, Phase, FluidSpec, DynamicType } from "../../../src/enums";
4
+ import { setAccessToken } from "../../../src/utilities";
5
+
6
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
7
+
8
+ if (!accessToken) {
9
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
10
+ }
11
+
12
+ setAccessToken(accessToken);
13
+
14
+ describe("UserDefinedSourceLinkedRunCalculation - VLR_156", () => {
15
+ it("should run the calculation and validate regression outputs", async () => {
16
+ // Define the material - AMMONIA + DIMETHYLAMINE
17
+ const material = new Material({
18
+ name: "AMMONIA + DIMETHYLAMINE",
19
+ components: [
20
+ new MaterialComponent({ name: "AMMONIA", moleFraction: 0.2 }),
21
+ new MaterialComponent({ name: "DIMETHYLAMINE", moleFraction: 0.8 })
22
+ ],
23
+ componentCount: 2
24
+ });
25
+
26
+ // Define the weather conditions
27
+ const weather = new Weather({
28
+ windSpeed: 5.0,
29
+ stabilityClass: AtmosphericStabilityClass.STABILITY_F,
30
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
31
+ });
32
+
33
+ // Define the substrate with bund
34
+ const substrate = new Substrate({
35
+ bund: new Bund({
36
+ specifyBund: true,
37
+ bundHeight: 0.5,
38
+ bundDiameter: 20
39
+ })
40
+ });
41
+
42
+ // Define the dispersion parameters
43
+ const dispersionParameters = [
44
+ new DispersionParameters({ averagingTime: 18.75 }),
45
+ new DispersionParameters({ averagingTime: 600.0 })
46
+ ];
47
+
48
+ // Define the dispersion output configuration
49
+ const dispersionOutputConfigsFlammable = [
50
+ new DispersionOutputConfig({
51
+ specialConcentration: SpecialConcentration.LFL,
52
+ elevation: 0.0
53
+ })
54
+ ];
55
+
56
+ const dispersionOutputConfigsToxic = [
57
+ new DispersionOutputConfig({
58
+ specialConcentration: SpecialConcentration.MIN,
59
+ elevation: 0.0
60
+ })
61
+ ];
62
+
63
+ // Define the flammable parameters
64
+ const flammableParameters = new FlammableParameters();
65
+
66
+ // Define the flammable output configuration
67
+ const flammableOutputConfigs = [new FlammableOutputConfig()];
68
+
69
+ // Define the explosion parameters
70
+ const explosionParameters = new ExplosionParameters();
71
+
72
+ // Define the explosion output configuration
73
+ const explosionOutputConfigs = [new ExplosionOutputConfig()];
74
+
75
+ // Define the explosion confined volumes
76
+ const explosionConfinedVolumes = [new ExplosionConfinedVolume()];
77
+
78
+ // Define the discharge record
79
+ const dischargeRecord = new DischargeRecord({
80
+ massFlow: 60.0,
81
+ time: 3600.0,
82
+ finalState: new State({
83
+ temperature: 300.0,
84
+ pressure: 101325.0,
85
+ flashFlag: FluidSpec.PLF,
86
+ liquidFraction: 0.9
87
+ }),
88
+ orificeState: new State({
89
+ temperature: 300.0,
90
+ pressure: 101325.0,
91
+ liquidFraction: 1.0
92
+ }),
93
+ orificeVelocity: 0.0,
94
+ storageState: new State({
95
+ temperature: 300.0,
96
+ pressure: 101325.0,
97
+ liquidFraction: 1.0
98
+ }),
99
+ finalVelocity: 3.0,
100
+ dropletDiameter: 0.0015
101
+ });
102
+
103
+ // Define the discharge result
104
+ const dischargeResult = new DischargeResult({
105
+ releaseMass: 3000.0,
106
+ height: 0.0,
107
+ angle: 0.0,
108
+ holeDiameter: 0.3,
109
+ releaseType: DynamicType.CONTINUOUS,
110
+ preDilutionAirRate: 0.0,
111
+ expansionEnergy: 6000.0
112
+ });
113
+
114
+ // Create the calculation
115
+ const calculation = new UserDefinedSourceLinkedRunCalculation(
116
+ material,
117
+ dischargeResult,
118
+ [dischargeRecord],
119
+ 1,
120
+ Phase.TWO_PHASE,
121
+ new DischargeParameters(),
122
+ substrate,
123
+ weather,
124
+ dispersionParameters,
125
+ 2,
126
+ 0.0,
127
+ flammableParameters,
128
+ explosionParameters,
129
+ dispersionOutputConfigsFlammable,
130
+ 1,
131
+ dispersionOutputConfigsToxic,
132
+ 1,
133
+ flammableOutputConfigs,
134
+ 1,
135
+ explosionOutputConfigs,
136
+ 1,
137
+ explosionConfinedVolumes,
138
+ 1
139
+ );
140
+
141
+ console.log("Running user_defined_source_linked_run_calculation...");
142
+ const resultCode = await calculation.run();
143
+
144
+ if (calculation.messages.length > 0) {
145
+ console.log("Messages:");
146
+ calculation.messages.forEach((msg) => console.log(msg));
147
+ }
148
+
149
+ expect(resultCode).toBe(ResultCode.SUCCESS);
150
+
151
+ if (resultCode === ResultCode.SUCCESS) {
152
+ // Check jet fire flame length
153
+ expect(
154
+ Math.abs(calculation.jetFireFlameResult!.flameLength! - 53.00690906122035) / 53.00690906122035
155
+ ).toBeLessThan(1e-3);
156
+
157
+ // Check pool fire flame diameter
158
+ expect(
159
+ Math.abs(calculation.poolFireFlameResult!.flameDiameter! - 20.001361846923828) / 20.001361846923828
160
+ ).toBeLessThan(1e-3);
161
+
162
+ // Check flammable concentration contour points
163
+ expect(calculation.flamConcContourPoints!.length).toBe(595);
164
+
165
+ // Check toxic concentration contour points
166
+ expect(calculation.toxicConcContourPoints!.length).toBe(715);
167
+
168
+ // Check area footprint flammable concentration
169
+ expect(
170
+ Math.abs(calculation.areaFootprintFlamConc![0] - 847.3190961205354) / 847.3190961205354
171
+ ).toBeLessThan(1e-3);
172
+
173
+ // Check area footprint toxic concentration
174
+ expect(
175
+ Math.abs(calculation.areaFootprintToxicConc![0] - 1768.0057401841577) / 1768.0057401841577
176
+ ).toBeLessThan(1e-3);
177
+
178
+ // Check area contour jet
179
+ expect(
180
+ Math.abs(calculation.areaContourJet![0] - 8291.147477879847) / 8291.147477879847
181
+ ).toBeLessThan(1e-3);
182
+
183
+ // Check area contour pool
184
+ expect(
185
+ Math.abs(calculation.areaContourPool![0] - 9056.660506598088) / 9056.660506598088
186
+ ).toBeLessThan(1e-3);
187
+
188
+ // Check explosion overpressure results exploded mass
189
+ expect(
190
+ Math.abs(calculation.explosionOverpressureResults![0].explodedMass! - 35.04344559768403) / 35.04344559768403
191
+ ).toBeLessThan(1e-3);
192
+
193
+ // Check explosion overpressure results maximum distance
194
+ expect(
195
+ Math.abs(calculation.explosionOverpressureResults![0].maximumDistance! - 179.62723831597395) / 179.62723831597395
196
+ ).toBeLessThan(1e-3);
197
+
198
+ console.log(`SUCCESS: user_defined_source_linked_run_calculation (${calculation.calculationElapsedTime}ms)`);
199
+ }
200
+ });
201
+ });