@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,153 @@
1
+ import {VesselCatastrophicRuptureCalculation, VesselStateCalculation, VesselLeakCalculation, VesselLineRuptureCalculation } from "../../src/calculations/discharge";
2
+ import { DispersionCalculation } from "../../src/calculations/dispersion";
3
+ import { SideviewAtTimeCalculation} from "../../src/calculations/dispersionView";
4
+ import {Bund, DischargeParameters, DispersionOutputConfig, DispersionParameters, LineRupture, Material, MaterialComponent, State, Substrate, Vessel, Weather } from "../../src/entities";
5
+ import { AtmosphericStabilityClass, ResultCode, SurfaceType, VesselShape, WindProfileFlag} from "../../src/enums";
6
+ import { setAccessToken } from "../../src/utilities";
7
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
8
+
9
+ if (!accessToken) {
10
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
11
+ }
12
+
13
+ setAccessToken(accessToken);
14
+
15
+ describe("SideviewAtTimeCalculation - AMMONIA line rupture", () => {
16
+ test("should calculate correct sideview dispersion for AMMONIA with line rupture", async () => {
17
+ const material = new Material({
18
+ name: "AMMONIA",
19
+ components: [new MaterialComponent({ name: "AMMONIA", moleFraction: 1.0 })],
20
+ });
21
+
22
+ const state = new State({
23
+ temperature: 290.0,
24
+ pressure: 7.0e6,
25
+ liquidFraction: 1.0,
26
+ });
27
+
28
+ const surfaceType = SurfaceType.LAND;
29
+ const surfaceRoughness = 0.183;
30
+ const windSpeed = 1.5;
31
+ const stabilityClass = AtmosphericStabilityClass.STABILITY_D;
32
+ const endPointConcentration = 0.0;
33
+ const specifyBund = true;
34
+ const bundHeight = 0.5;
35
+ const bundDiameter = 5.0;
36
+ const windProfileFlag = WindProfileFlag.LOGARITHMIC_PROFILE;
37
+
38
+ const vesselStateCalc = new VesselStateCalculation(material, state);
39
+ console.log("Running vessel_state_calculation...");
40
+ let resultCode = await vesselStateCalc.run();
41
+ vesselStateCalc.messages.forEach((msg) => console.log(msg));
42
+ expect(resultCode).toBe(ResultCode.SUCCESS);
43
+
44
+ const vessel = new Vessel({
45
+ state,
46
+ material,
47
+ vesselConditions: vesselStateCalc.vesselConditions!,
48
+ liquidFillFractionByVolume: 0.7,
49
+ shape: VesselShape.VESSEL_CUBOID,
50
+ height: 2,
51
+ width: 1,
52
+ length: 3,
53
+ });
54
+
55
+ const lineRupture = new LineRupture({
56
+ pipeDiameter: 0.1,
57
+ pipeLength: 1.0,
58
+ pipeHeightFraction: 0.1,
59
+ });
60
+
61
+ const ruptureCalc = new VesselLineRuptureCalculation(
62
+ vessel,
63
+ lineRupture,
64
+ new DischargeParameters()
65
+ );
66
+
67
+ console.log("Running vessel_line_rupture_calculation...");
68
+ resultCode = await ruptureCalc.run();
69
+ ruptureCalc.messages.forEach((msg) => console.log(msg));
70
+ expect(resultCode).toBe(ResultCode.SUCCESS);
71
+
72
+ const bund = new Bund({
73
+ specifyBund,
74
+ bundHeight,
75
+ bundDiameter,
76
+ });
77
+
78
+ const substrate = new Substrate({
79
+ bund,
80
+ surfaceType,
81
+ surfaceRoughness,
82
+ });
83
+
84
+ const weather = new Weather({
85
+ windSpeed: windSpeed,
86
+ stabilityClass: stabilityClass,
87
+ windProfileFlag: windProfileFlag
88
+ });
89
+
90
+ const dispersionParams = new DispersionParameters();
91
+
92
+ const dispersionCalc = new DispersionCalculation(
93
+ ruptureCalc.exitMaterial!,
94
+ substrate,
95
+ ruptureCalc.dischargeResult!,
96
+ ruptureCalc.dischargeRecords!,
97
+ ruptureCalc.dischargeRecords!.length,
98
+ weather,
99
+ dispersionParams,
100
+ endPointConcentration
101
+ );
102
+
103
+ console.log("Running dispersion_calculation...");
104
+ resultCode = await dispersionCalc.run();
105
+ dispersionCalc.messages.forEach((msg) => console.log(msg));
106
+ expect(resultCode).toBe(ResultCode.SUCCESS);
107
+
108
+ const outputConfig = new DispersionOutputConfig({
109
+ concentration: endPointConcentration,
110
+ });
111
+
112
+ const sideviewCalc = new SideviewAtTimeCalculation(
113
+ dispersionCalc.scalarUdmOutputs!,
114
+ weather,
115
+ dispersionCalc.dispersionRecords!,
116
+ dispersionCalc.dispersionRecords!.length,
117
+ substrate,
118
+ outputConfig,
119
+ ruptureCalc.exitMaterial!,
120
+ dispersionParams
121
+ );
122
+
123
+ console.log("Running sideview_at_time_calculation...");
124
+ resultCode = await sideviewCalc.run();
125
+ sideviewCalc.messages.forEach((msg) => console.log(msg));
126
+ expect(resultCode).toBe(ResultCode.SUCCESS);
127
+
128
+ const contourPoints = sideviewCalc.contourPoints!;
129
+ const dispersionRecords = sideviewCalc.dispersionRecords!;
130
+
131
+ // Check number of contour points
132
+ expect(contourPoints.length).toBe(56);
133
+
134
+ // Check x-value of the third-from-last contour point
135
+ const targetContourPoint = contourPoints[contourPoints.length - 3];
136
+ const expectedX = 288.38690766280035;
137
+ const xError = Math.abs((targetContourPoint.x - expectedX) / expectedX);
138
+ expect(xError).toBeLessThan(1e-3);
139
+
140
+ // Check centreline concentration of the last dispersion record
141
+ const lastDispersion = dispersionRecords[dispersionRecords.length - 1];
142
+ const expectedConc = 0.0005178235809216942;
143
+ const concError = Math.abs(
144
+ (lastDispersion.centrelineConcentration! - expectedConc) / expectedConc
145
+ );
146
+ expect(concError).toBeLessThan(1e-3);
147
+
148
+ console.log(
149
+ `SUCCESS: sideview_at_time_calculation (${sideviewCalc.calculationElapsedTime}ms)`
150
+ );
151
+ });
152
+ });
153
+
@@ -0,0 +1,140 @@
1
+ import {VesselStateCalculation, VesselLeakCalculation, VesselReliefValveCalculation } from "../../src/calculations/discharge";
2
+ import { DispersionCalculation } from "../../src/calculations/dispersion";
3
+ import { SideviewAtTimeCalculation} from "../../src/calculations/dispersionView";
4
+ import {Bund, DischargeParameters, DispersionOutputConfig, DispersionParameters, LocalPosition, Leak, ReliefValve, Material, MaterialComponent, State, Substrate, Vessel, Weather } from "../../src/entities";
5
+ import { AtmosphericStabilityClass, ResultCode, SurfaceType, VesselShape, TimeVaryingOption, 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("SideviewAtTimeCalculation", () => {
16
+ test("should calculate correct sideview dispersion for CHLORINE via relief valve", async () => {
17
+ const state = new State({
18
+ temperature: 320.0,
19
+ pressure: 1.0e6,
20
+ liquidFraction: 1.0,
21
+ });
22
+
23
+ const material = new Material({
24
+ name: "CHLORINE",
25
+ components: [new MaterialComponent({ name: "CHLORINE", moleFraction: 1.0 })],
26
+ });
27
+
28
+ const vesselStateCalc = new VesselStateCalculation(material, state);
29
+
30
+ console.log("Running vessel_state_calculation...");
31
+ let resultCode = await vesselStateCalc.run();
32
+ vesselStateCalc.messages.forEach((msg) => console.log(msg));
33
+ expect(resultCode).toBe(ResultCode.SUCCESS);
34
+
35
+ const vessel = new Vessel({
36
+ state,
37
+ material,
38
+ vesselConditions: vesselStateCalc.vesselConditions!,
39
+ liquidFillFractionByVolume: 0.7,
40
+ shape: VesselShape.HORIZONTAL_CYLINDER,
41
+ diameter: 2.0,
42
+ length: 5.0,
43
+ });
44
+
45
+ const reliefValve = new ReliefValve({
46
+ pipeDiameter: 0.02,
47
+ pipeLength: 10.0,
48
+ pipeHeightFraction: 1.0,
49
+ reliefValveConstrictionDiameter: 0.02,
50
+ });
51
+
52
+ const reliefValveCalc = new VesselReliefValveCalculation(
53
+ vessel,
54
+ reliefValve,
55
+ new DischargeParameters()
56
+ );
57
+
58
+ console.log("Running vessel_relief_valve_calculation...");
59
+ resultCode = await reliefValveCalc.run();
60
+ reliefValveCalc.messages.forEach((msg) => console.log(msg));
61
+ expect(resultCode).toBe(ResultCode.SUCCESS);
62
+ console.log(`Relief valve release mass: ${reliefValveCalc.dischargeResult!.releaseMass} [kg]`);
63
+
64
+ const bund = new Bund({
65
+ specifyBund: true,
66
+ bundHeight: 0.5,
67
+ bundDiameter: 5.0,
68
+ });
69
+
70
+ const substrate = new Substrate({
71
+ bund,
72
+ surfaceType: SurfaceType.LAND,
73
+ surfaceRoughness: 0.183,
74
+ });
75
+
76
+ const weather = new Weather({
77
+ windSpeed: 1.5,
78
+ stabilityClass: AtmosphericStabilityClass.STABILITY_D,
79
+ windProfileFlag: WindProfileFlag.LOGARITHMIC_PROFILE
80
+ });
81
+
82
+ const dispersionParams = new DispersionParameters();
83
+
84
+ const dispersionCalc = new DispersionCalculation(
85
+ reliefValveCalc.exitMaterial!,
86
+ substrate,
87
+ reliefValveCalc.dischargeResult!,
88
+ reliefValveCalc.dischargeRecords!,
89
+ reliefValveCalc.dischargeRecords!.length,
90
+ weather,
91
+ dispersionParams,
92
+ 0.0
93
+ );
94
+
95
+ console.log("Running dispersion_calculation...");
96
+ resultCode = await dispersionCalc.run();
97
+ dispersionCalc.messages.forEach((msg) => console.log(msg));
98
+ expect(resultCode).toBe(ResultCode.SUCCESS);
99
+
100
+ const outputConfig = new DispersionOutputConfig({
101
+ concentration: 0.0,
102
+ });
103
+
104
+ const sideviewCalc = new SideviewAtTimeCalculation(
105
+ dispersionCalc.scalarUdmOutputs!,
106
+ weather,
107
+ dispersionCalc.dispersionRecords!,
108
+ dispersionCalc.dispersionRecords!.length,
109
+ substrate,
110
+ outputConfig,
111
+ reliefValveCalc.exitMaterial!,
112
+ dispersionParams
113
+ );
114
+
115
+ console.log("Running sideview_at_time_calculation...");
116
+ resultCode = await sideviewCalc.run();
117
+ sideviewCalc.messages.forEach((msg) => console.log(msg));
118
+ expect(resultCode).toBe(ResultCode.SUCCESS);
119
+
120
+ const contourPoints = sideviewCalc.contourPoints!;
121
+ const dispersionRecords = sideviewCalc.dispersionRecords!;
122
+
123
+ expect(contourPoints.length).toBe(197);
124
+
125
+ const targetX = 130.8644880935483;
126
+ const actualX = contourPoints[contourPoints.length - 3].x;
127
+ const xError = Math.abs((actualX - targetX) / targetX);
128
+ expect(xError).toBeLessThan(1e-3);
129
+
130
+ const expectedConc = 1.4451621633042375e-05;
131
+ const actualConc = dispersionRecords[dispersionRecords.length - 1].centrelineConcentration!;
132
+ const concError = Math.abs((actualConc - expectedConc) / expectedConc);
133
+ expect(concError).toBeLessThan(1e-3);
134
+
135
+ console.log(
136
+ `SUCCESS: sideview_at_time_calculation (${sideviewCalc.calculationElapsedTime}ms)`
137
+ );
138
+ });
139
+ });
140
+
@@ -0,0 +1,61 @@
1
+ import { TankFireCalculation } from "../../src/calculations/standalones";
2
+ import { Material, MaterialComponent, FlammableParameters, AtmosphericStorageTank , State, Weather, Substrate, } from "../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, PoolFireType } from "../../src/enums";
4
+ import { setAccessToken } from "../../src/utilities";
5
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
6
+
7
+ if (!accessToken) {
8
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
9
+ }
10
+
11
+ setAccessToken(accessToken);
12
+
13
+ describe('TankFireCalculation', () => {
14
+ test('should calculate fire properties correctly', async () => {
15
+ // Set the case properties.
16
+ const materialName = "N-HEXANE";
17
+ const diameter = 1.0;
18
+ const height = 3.0;
19
+ const windSpeed = 1.5;
20
+ const fireType = PoolFireType.LATE;
21
+ const weatherStability = AtmosphericStabilityClass.STABILITY_F;
22
+
23
+ // Define the initial state of the tank.
24
+ const state = new State({temperature: 250.0, pressure: 1.0E+06, liquidFraction: 0.0});
25
+
26
+ // Define the material contained by the tank.
27
+ const material = new Material({name: materialName, components: [new MaterialComponent({name:materialName, moleFraction: 1.0})]});
28
+
29
+ // Define the weather conditions
30
+ const weather = new Weather({windSpeed: windSpeed, stabilityClass: weatherStability});
31
+
32
+ // Define the substrate
33
+ const substrate = new Substrate();
34
+
35
+ // Define the flammable parameters
36
+ const flammableParameters = new FlammableParameters({poolFireType: fireType});
37
+
38
+ // Define the conditions of the tank
39
+ const tank = new AtmosphericStorageTank({state: state, material: material, diameter: diameter, height: height});
40
+
41
+ // Create the TankFireCalculation object
42
+ const tankFireCalculation = new TankFireCalculation(tank, weather, substrate, flammableParameters);
43
+
44
+ // Run the calculation
45
+ console.log("Running the calculation...");
46
+ const resultCode = await tankFireCalculation.run();
47
+ expect(resultCode).toBe(ResultCode.SUCCESS);
48
+ // Print any messages
49
+ if (tankFireCalculation.messages.length > 0) {
50
+ console.log('Messages:');
51
+ tankFireCalculation.messages.forEach(message => console.log(message));
52
+ }
53
+
54
+ // Validate results
55
+
56
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.surfaceEmissivePower! - 126425.34375) / 126425.34375)).toBeLessThan(1e-3);
57
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.flameLength! - 3.9397664070129395) / 3.9397664070129395)).toBeLessThan(1e-3);
58
+ console.log(`SUCCESS: tank_fire_calculation (${tankFireCalculation.calculationElapsedTime}ms)`);
59
+
60
+ });
61
+ });
@@ -0,0 +1,67 @@
1
+ import { TankFireCalculation } from "../../src/calculations/standalones";
2
+ import { Material, MaterialComponent, FlammableParameters, AtmosphericStorageTank, State, Weather, Substrate } from "../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, PoolFireType } from "../../src/enums";
4
+ import { setAccessToken } from "../../src/utilities";
5
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
6
+
7
+ if (!accessToken) {
8
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
9
+ }
10
+
11
+ setAccessToken(accessToken);
12
+
13
+ describe('TankFireCalculation', () => {
14
+ test('should calculate fire properties correctly', async () => {
15
+ // Set the case properties.
16
+ const materialName = "N-PENTANE";
17
+ const diameter = 0.5;
18
+ const height = 2.0;
19
+ const windSpeed = 2.0;
20
+ const fireType = PoolFireType.LATE;
21
+ const weatherStability = AtmosphericStabilityClass.STABILITY_E;
22
+
23
+ // Define the initial state of the tank.
24
+ const state = new State({temperature: 260.0, pressure: 101325, liquidFraction: 0.0});
25
+
26
+ // Define the material contained by the tank.
27
+ const material = new Material({
28
+ name: materialName,
29
+ components: [new MaterialComponent({name: materialName, moleFraction: 1.0})]
30
+ });
31
+
32
+ // Define the weather conditions
33
+ const weather = new Weather({windSpeed: windSpeed, stabilityClass: weatherStability});
34
+
35
+ // Define the substrate
36
+ const substrate = new Substrate();
37
+
38
+ // Define the flammable parameters
39
+ const flammableParameters = new FlammableParameters({poolFireType: fireType});
40
+
41
+ // Define the conditions of the tank
42
+ const tank = new AtmosphericStorageTank({state: state, material: material, diameter: diameter, height: height});
43
+
44
+ // Create the TankFireCalculation object
45
+ const tankFireCalculation = new TankFireCalculation(tank, weather, substrate, flammableParameters);
46
+
47
+ // Run the calculation
48
+ console.log("Running the calculation...");
49
+ const resultCode = await tankFireCalculation.run();
50
+ expect(resultCode).toBe(ResultCode.SUCCESS);
51
+
52
+ // Print any messages
53
+ if (tankFireCalculation.messages.length > 0) {
54
+ console.log('Messages:');
55
+ tankFireCalculation.messages.forEach(message => console.log(message));
56
+ }
57
+
58
+ // Check surface emissive power
59
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.surfaceEmissivePower! - 133009.03125) / 133009.03125)).toBeLessThan(1e-3);
60
+
61
+ // Check flame length
62
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.flameLength! - 2.8789072036743164) / 2.8789072036743164)).toBeLessThan(1e-3);
63
+
64
+ console.log(`SUCCESS: tank_fire_calculation (${tankFireCalculation.calculationElapsedTime}ms)`);
65
+
66
+ });
67
+ });
@@ -0,0 +1,68 @@
1
+ import { TankFireCalculation } from "../../src/calculations/standalones";
2
+ import { Material, MaterialComponent, FlammableParameters, AtmosphericStorageTank, State, Weather, Substrate } from "../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, PoolFireType } from "../../src/enums";
4
+ import { setAccessToken } from "../../src/utilities";
5
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
6
+
7
+ if (!accessToken) {
8
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
9
+ }
10
+
11
+ setAccessToken(accessToken);
12
+
13
+ describe('TankFireCalculation', () => {
14
+ test('should calculate fire properties correctly for N-OCTANE', async () => {
15
+ // Set the case properties.
16
+ const materialName = "N-OCTANE";
17
+ const diameter = 2.0;
18
+ const height = 5.0;
19
+ const windSpeed = 5.0;
20
+ const fireType = PoolFireType.LATE;
21
+ const weatherStability = AtmosphericStabilityClass.STABILITY_D;
22
+
23
+ // Define the initial state of the tank.
24
+ const state = new State({temperature: 280.0, pressure: 1.0E+06, liquidFraction: 0.0});
25
+
26
+ // Define the material contained by the tank.
27
+ const material = new Material({
28
+ name: materialName,
29
+ components: [new MaterialComponent({name: materialName, moleFraction: 1.0})]
30
+ });
31
+
32
+ // Define the weather conditions
33
+ const weather = new Weather({windSpeed: windSpeed, stabilityClass: weatherStability});
34
+
35
+ // Define the substrate
36
+ const substrate = new Substrate();
37
+
38
+ // Define the flammable parameters
39
+ const flammableParameters = new FlammableParameters({poolFireType: fireType});
40
+
41
+ // Define the conditions of the tank
42
+ const tank = new AtmosphericStorageTank({state: state, material: material, diameter: diameter, height: height});
43
+
44
+ // Create the TankFireCalculation object
45
+ const tankFireCalculation = new TankFireCalculation(tank, weather, substrate, flammableParameters);
46
+
47
+ // Run the calculation
48
+ console.log("Running the calculation...");
49
+ const resultCode = await tankFireCalculation.run();
50
+ expect(resultCode).toBe(ResultCode.SUCCESS);
51
+
52
+ // Print any messages
53
+ if (tankFireCalculation.messages.length > 0) {
54
+ console.log('Messages:');
55
+ tankFireCalculation.messages.forEach(message => console.log(message));
56
+ }
57
+
58
+ // Validate results
59
+
60
+ // Check surface emissive power
61
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.surfaceEmissivePower! - 114386.2734375) / 114386.2734375)).toBeLessThan(1e-3);
62
+
63
+ // Check flame length
64
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.flameLength! - 5.776425838470459) / 5.776425838470459)).toBeLessThan(1e-3);
65
+
66
+ console.log(`SUCCESS: tank_fire_calculation (${tankFireCalculation.calculationElapsedTime}ms)`);
67
+ });
68
+ });
@@ -0,0 +1,68 @@
1
+ import { TankFireCalculation } from "../../src/calculations/standalones";
2
+ import { Material, MaterialComponent, FlammableParameters, AtmosphericStorageTank, State, Weather, Substrate } from "../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, PoolFireType } from "../../src/enums";
4
+ import { setAccessToken } from "../../src/utilities";
5
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
6
+
7
+ if (!accessToken) {
8
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
9
+ }
10
+
11
+ setAccessToken(accessToken);
12
+
13
+ describe('TankFireCalculation', () => {
14
+ test('should calculate fire properties correctly for N-DECANE', async () => {
15
+ // Set the case properties.
16
+ const materialName = "N-DECANE";
17
+ const diameter = 2.0;
18
+ const height = 4.0;
19
+ const windSpeed = 10.0;
20
+ const fireType = PoolFireType.LATE;
21
+ const weatherStability = AtmosphericStabilityClass.STABILITY_A_;
22
+
23
+ // Define the initial state of the tank.
24
+ const state = new State({temperature: 300.0, pressure: 1.0E+06, liquidFraction: 0.0});
25
+
26
+ // Define the material contained by the tank.
27
+ const material = new Material({
28
+ name: materialName,
29
+ components: [new MaterialComponent({name: materialName, moleFraction: 1.0})]
30
+ });
31
+
32
+ // Define the weather conditions
33
+ const weather = new Weather({windSpeed: windSpeed, stabilityClass: weatherStability});
34
+
35
+ // Define the substrate
36
+ const substrate = new Substrate();
37
+
38
+ // Define the flammable parameters
39
+ const flammableParameters = new FlammableParameters({poolFireType: fireType});
40
+
41
+ // Define the conditions of the tank
42
+ const tank = new AtmosphericStorageTank({state: state, material: material, diameter: diameter, height: height});
43
+
44
+ // Create the TankFireCalculation object
45
+ const tankFireCalculation = new TankFireCalculation(tank, weather, substrate, flammableParameters);
46
+
47
+ // Run the calculation
48
+ console.log("Running the calculation...");
49
+ const resultCode = await tankFireCalculation.run();
50
+ expect(resultCode).toBe(ResultCode.SUCCESS);
51
+
52
+ // Print any messages
53
+ if (tankFireCalculation.messages.length > 0) {
54
+ console.log('Messages:');
55
+ tankFireCalculation.messages.forEach(message => console.log(message));
56
+ }
57
+
58
+ // Validate results
59
+
60
+ // Check surface emissive power
61
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.surfaceEmissivePower! - 114386.2734375) / 114386.2734375)).toBeLessThan(1e-3);
62
+
63
+ // Check flame length
64
+ expect(Math.abs((tankFireCalculation.poolFireFlameResult!.flameLength! - 5.283842086791992) / 5.283842086791992)).toBeLessThan(1e-3);
65
+
66
+ console.log(`SUCCESS: tank_fire_calculation (${tankFireCalculation.calculationElapsedTime}ms)`);
67
+ });
68
+ });
@@ -0,0 +1,73 @@
1
+ import { TankFireCalculation } from "../../src/calculations/standalones";
2
+ import { Material, MaterialComponent, FlammableParameters, AtmosphericStorageTank, State, Weather, Substrate } from "../../src/entities";
3
+ import { ResultCode, AtmosphericStabilityClass, PoolFireType } from "../../src/enums";
4
+ import { setAccessToken } from "../../src/utilities";
5
+ const accessToken = process.env.PWS_ACCESS_TOKEN;
6
+
7
+ if (!accessToken) {
8
+ throw new Error("ACCESS_TOKEN environment variable is not set.");
9
+ }
10
+
11
+ setAccessToken(accessToken);
12
+
13
+ describe('TankFireCalculation', () => {
14
+ test('should calculate fire properties correctly for N-HEPTANE_N-OCTANE mixture', async () => {
15
+ // Set the case properties.
16
+ const materialName = "N-HEPTANE_N-OCTANE";
17
+ const diameter = 3.0;
18
+ const height = 10.0;
19
+ const windSpeed = 1.0;
20
+ const fireType = PoolFireType.LATE;
21
+ const weatherStability = AtmosphericStabilityClass.STABILITY_C;
22
+
23
+ // Define the initial state of the tank.
24
+ const state = new State({ temperature: 290.0, pressure: 1.0E+06, liquidFraction: 0.0 });
25
+
26
+ // Define the material contained by the tank (binary mixture)
27
+ const material = new Material({
28
+ name: materialName,
29
+ components: [
30
+ new MaterialComponent({ name: "N-HEPTANE", moleFraction: 0.4 }),
31
+ new MaterialComponent({ name: "N-OCTANE", moleFraction: 0.6 }),
32
+ ],
33
+ componentCount: 2,
34
+ });
35
+
36
+ // Define the weather conditions
37
+ const weather = new Weather({ windSpeed: windSpeed, stabilityClass: weatherStability });
38
+
39
+ // Define the substrate
40
+ const substrate = new Substrate();
41
+
42
+ // Define the flammable parameters
43
+ const flammableParameters = new FlammableParameters({ poolFireType: fireType });
44
+
45
+ // Define the conditions of the tank
46
+ const tank = new AtmosphericStorageTank({ state, material, diameter, height });
47
+
48
+ // Create the TankFireCalculation object
49
+ const tankFireCalculation = new TankFireCalculation(tank, weather, substrate, flammableParameters);
50
+
51
+ // Run the calculation
52
+ console.log("Running the calculation...");
53
+ const resultCode = await tankFireCalculation.run();
54
+
55
+ // Print any messages
56
+ if (tankFireCalculation.messages.length > 0) {
57
+ console.log("Messages:");
58
+ tankFireCalculation.messages.forEach(msg => console.log(msg));
59
+ }
60
+
61
+ expect(resultCode).toBe(ResultCode.SUCCESS);
62
+
63
+
64
+ const surfaceEmissivePower = tankFireCalculation.poolFireFlameResult!.surfaceEmissivePower!;
65
+ const flameLength = tankFireCalculation.poolFireFlameResult!.flameLength!;
66
+
67
+ expect(Math.abs((surfaceEmissivePower - 103709.09375) / 103709.09375)).toBeLessThan(1e-3);
68
+ expect(Math.abs((flameLength - 8.156496047973633) / 8.156496047973633)).toBeLessThan(1e-3);
69
+
70
+ console.log(`SUCCESS: tank_fire_calculation (${tankFireCalculation.calculationElapsedTime}ms)`);
71
+
72
+ });
73
+ });
@@ -0,0 +1,7 @@
1
+ import { convertCamelCaseToSnakeCase } from '../../src/utilities';
2
+
3
+ describe('convertCamelCaseToSnakeCase', () => {
4
+ test('should convert camelCase to snake_case', () => {
5
+ expect(convertCamelCaseToSnakeCase('convertToSnakeCase')).toBe('convert_to_snake_case');
6
+ });
7
+ });
@@ -0,0 +1,7 @@
1
+ import { convertSnakeCaseToCamelCase } from '../../src/utilities';
2
+
3
+ describe('convertSnakeCaseToCamelCase', () => {
4
+ test('should convert snake_case to camelCase', () => {
5
+ expect(convertSnakeCaseToCamelCase('convert_to_camel_case')).toBe('convertToCamelCase');
6
+ });
7
+ });