@dnv-plant/typescriptpws 1.0.70 → 1.0.73-alpha.1902013
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +2 -2
- package/jest.config.js +5 -0
- package/package.json +6 -6
- package/src/calculations/applicationTools.ts +2 -2
- package/src/calculations/discharge.ts +2 -2
- package/src/calculations/dispersion.ts +2 -2
- package/src/calculations/dispersionView.ts +2 -2
- package/src/calculations/fireball.ts +2 -2
- package/src/calculations/jetFire.ts +2 -2
- package/src/calculations/lateExplosion.ts +2 -2
- package/src/calculations/linkedRunners.ts +2 -2
- package/src/calculations/poolFire.ts +2 -2
- package/src/calculations/properties.ts +2 -2
- package/src/calculations/radiation.ts +2 -2
- package/src/calculations/standalones.ts +2 -2
- package/src/calculations/toxics.ts +2 -2
- package/src/calculations/utilities.ts +2 -2
- package/src/constants.ts +2 -2
- package/src/entities.ts +2 -2
- package/src/entity-schemas.ts +2 -2
- package/src/enums.ts +2 -2
- package/src/materials.ts +14 -14
- package/src/utilities.ts +2 -2
- package/tests/concentration-at-point-calculation/testCase116.test.ts +146 -0
- package/tests/concentration-at-point-calculation/testCase117.test.ts +142 -0
- package/tests/concentration-at-point-calculation/testCase118.test.ts +143 -0
- package/tests/concentration-at-point-calculation/testCase119.test.ts +149 -0
- package/tests/concentration-at-point-calculation/testCase120.test.ts +155 -0
- package/tests/constants/testConstants.test.ts +23 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase129.test.ts +74 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase130.test.ts +73 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase131.test.ts +73 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase132.test.ts +73 -0
- package/tests/convert-comp-mass-to-mole-calculation/testCase133.test.ts +73 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase134.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase135.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase136.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase137.test.ts +72 -0
- package/tests/convert-comp-mole-to-mass-calculation/testCase138.test.ts +72 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase64.test.ts +194 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase65.test.ts +197 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase66.test.ts +194 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase67.test.ts +198 -0
- package/tests/distances-and-ellipses-to-radiation-levels-calculation/testCase68.test.ts +178 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase31a.test.ts +158 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase32a.test.ts +156 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase33a.test.ts +158 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase34a.test.ts +165 -0
- package/tests/distances-and-footprints-to-concentration-levels-calculation/testCase35a.test.ts +188 -0
- package/tests/distances-to-conc-levels-calculation/testCase121.test.ts +149 -0
- package/tests/distances-to-conc-levels-calculation/testCase122.test.ts +145 -0
- package/tests/distances-to-conc-levels-calculation/testCase123.test.ts +150 -0
- package/tests/distances-to-conc-levels-calculation/testCase124.test.ts +154 -0
- package/tests/distances-to-conc-levels-calculation/testCase125.test.ts +157 -0
- package/tests/entities/testVessel.test.ts +49 -0
- package/tests/fireball-calculation/testCase89.test.ts +151 -0
- package/tests/fireball-calculation/testCase90.test.ts +153 -0
- package/tests/fireball-calculation/testCase91.test.ts +152 -0
- package/tests/fireball-calculation/testCse92.test.ts +150 -0
- package/tests/flash-calculation/testCase26.test.ts +71 -0
- package/tests/flash-calculation/testCase27.test.ts +69 -0
- package/tests/flash-calculation/testCase28.test.ts +69 -0
- package/tests/flash-calculation/testCase29.test.ts +67 -0
- package/tests/flash-calculation/testCase30.test.ts +70 -0
- package/tests/general/operation-id-demo.test.ts +64 -0
- package/tests/get-component-by-id/get-component-by-id-METHANE.test.ts +35 -0
- package/tests/get-mass-from-vessel-calculation/testCase139.test.ts +65 -0
- package/tests/jet-fire-calculation/testCase36.test.ts +141 -0
- package/tests/jet-fire-calculation/testCase37.test.ts +148 -0
- package/tests/jet-fire-calculation/testCase38.test.ts +147 -0
- package/tests/jet-fire-calculation/testCase39.test.ts +146 -0
- package/tests/jet-fire-calculation/testCase40.test.ts +152 -0
- package/tests/late-explosion-calculation/testCase46.test.ts +157 -0
- package/tests/late-explosion-calculation/testCase47.test.ts +149 -0
- package/tests/late-explosion-calculation/testCase48.test.ts +176 -0
- package/tests/late-explosion-calculation/testCase49.test.ts +178 -0
- package/tests/late-explosion-calculation/testCase50.test.ts +176 -0
- package/tests/late-explosion-calculation/testCase74.test.ts +166 -0
- package/tests/late-explosion-calculation/testCase75.test.ts +163 -0
- package/tests/late-explosion-calculation/testCase76.test.ts +174 -0
- package/tests/late-explosion-calculation/testCase77.test.ts +175 -0
- package/tests/late-explosion-calculation/testCase78.test.ts +175 -0
- package/tests/lethality-distance-calculation/testCase60.test.ts +142 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-153.test.ts +121 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-154.test.ts +167 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-155.test.ts +202 -0
- package/tests/linked-runners/user-defined-source-linked-run/test-uds-156.test.ts +201 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-157.test.ts +182 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-158.test.ts +200 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-159.test.ts +158 -0
- package/tests/linked-runners/vessel-leak-linked-run/test-vl-160.test.ts +165 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-161.test.ts +161 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-162.test.ts +167 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-163.test.ts +177 -0
- package/tests/linked-runners/vessel-line-rupture-linked-run/test-vlr-164.test.ts +165 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-165.test.ts +166 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-166.test.ts +154 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-167.test.ts +157 -0
- package/tests/linked-runners/vessel-relief-valve-linked-run/test-vrv-168.test.ts +168 -0
- package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase126.test.ts +72 -0
- package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase127.test.ts +73 -0
- package/tests/load-mass-inventory-vessel-for-line-rupture-scenario-calculation/testCase128.test.ts +72 -0
- package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase103.test.ts +74 -0
- package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase104.test.ts +75 -0
- package/tests/load-mass-inventory-vessel-for-relief-valve-scenario-calculation/testCase105.test.ts +74 -0
- package/tests/long-pipe-calculation/testCase55.test.ts +88 -0
- package/tests/long-pipe-calculation/testCase56.test.ts +90 -0
- package/tests/long-pipe-calculation/testCase57.test.ts +88 -0
- package/tests/long-pipe-calculation/testCase58.test.ts +88 -0
- package/tests/long-pipe-calculation/testCase59.test.ts +88 -0
- package/tests/materials/test-get-component-by-cas-id-1-2-PROPYLENE-OXIDE.test.ts +23 -0
- package/tests/materials/test-get-component-by-cas-id-CARBON-MONOXIDE.test.ts +25 -0
- package/tests/materials/test-get-component-by-cas-id-METHANE.test.ts +22 -0
- package/tests/materials/test-get-component-by-id-1-2-PROPYLENE-OXIDE.test.ts +23 -0
- package/tests/materials/test-get-component-by-id-CARBON-MONOXIDE.test.ts +22 -0
- package/tests/materials/test-get-component-by-id-METHANE.test.ts +22 -0
- package/tests/materials/test-get-component-by-name-1-2-PROPYLENE-OXIDE.test.ts +24 -0
- package/tests/materials/test-get-component-by-name-CARBON-MONOXIDE.test.ts +23 -0
- package/tests/materials/test-get-component-by-name-METHANE.test.ts +25 -0
- package/tests/materials/test-get-components.test.ts +47 -0
- package/tests/materials/test-get-dippr-components.test.ts +28 -0
- package/tests/materials/test-get-dnv-components.test.ts +28 -0
- package/tests/materials/test-get-material-by-cas-id-1-2-PROPYLENE-OXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-cas-id-CARBON-MONOXIDE.test.ts +31 -0
- package/tests/materials/test-get-material-by-cas-id-METHANE.test.ts +30 -0
- package/tests/materials/test-get-material-by-cas-id-ZERO.test.ts +31 -0
- package/tests/materials/test-get-material-by-id-1-2-PROPYLENE-OXIDE.test.ts +30 -0
- package/tests/materials/test-get-material-by-id-CARBON-MONOXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-id-METHANE.test.ts +29 -0
- package/tests/materials/test-get-material-by-name-1-2-PROPYLENE-OXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-name-CARBON-MONOXIDE.test.ts +29 -0
- package/tests/materials/test-get-material-by-name-METHANE.test.ts +29 -0
- package/tests/materials/test-get-materials.test.ts +32 -0
- package/tests/max-conc-distance-calculation/testCase106.test.ts +146 -0
- package/tests/max-conc-distance-calculation/testCase107.test.ts +148 -0
- package/tests/max-conc-distance-calculation/testCase108.test.ts +172 -0
- package/tests/max-conc-distance-calculation/testCase109.test.ts +146 -0
- package/tests/max-conc-distance-calculation/testCase110.test.ts +146 -0
- package/tests/max-conc-footprint-calculation/testCase31.test.ts +169 -0
- package/tests/max-conc-footprint-calculation/testCase32.test.ts +183 -0
- package/tests/max-conc-footprint-calculation/testCase33.test.ts +161 -0
- package/tests/max-conc-footprint-calculation/testCase34.test.ts +172 -0
- package/tests/max-conc-footprint-calculation/testCase35.test.ts +188 -0
- package/tests/max-distance-to-conc-calculation/testCase111.test.ts +138 -0
- package/tests/max-distance-to-conc-calculation/testCase112.test.ts +174 -0
- package/tests/max-distance-to-conc-calculation/testCase113.test.ts +153 -0
- package/tests/max-distance-to-conc-calculation/testCase114.test.ts +162 -0
- package/tests/max-distance-to-conc-calculation/testCase115.test.ts +167 -0
- package/tests/mixture-constant-properties-calculation/testCase97.test.ts +83 -0
- package/tests/mixture-constant-properties-calculation/testCase98.test.ts +90 -0
- package/tests/mixture-constant-properties-calculation/testCase99.test.ts +87 -0
- package/tests/pool-fire-calculation/testCase41.test.ts +153 -0
- package/tests/pool-fire-calculation/testCase41a.test.ts +141 -0
- package/tests/pool-fire-calculation/testCase42.test.ts +169 -0
- package/tests/pool-fire-calculation/testCase42a.test.ts +175 -0
- package/tests/pool-fire-calculation/testCase43.test.ts +161 -0
- package/tests/pool-fire-calculation/testCase43a.test.ts +157 -0
- package/tests/pool-fire-calculation/testCase44.test.ts +147 -0
- package/tests/pool-fire-calculation/testCase44a.test.ts +152 -0
- package/tests/pool-fire-calculation/testCase45.test.ts +176 -0
- package/tests/pool-fire-calculation/testCase45a.test.ts +182 -0
- package/tests/radiation-at-ponts/testCase69.test.ts +167 -0
- package/tests/radiation-at-ponts/testCase70.test.ts +179 -0
- package/tests/radiation-at-ponts/testCase71.test.ts +150 -0
- package/tests/radiation-at-ponts/testCase72.test.ts +166 -0
- package/tests/radiation-at-ponts/testCase73.test.ts +169 -0
- package/tests/radiation-contour-calculation/testCase51.test.ts +127 -0
- package/tests/radiation-contour-calculation/testCase52.test.ts +126 -0
- package/tests/radiation-contour-calculation/testCase53.test.ts +126 -0
- package/tests/radiation-contour-calculation/testCase54.test.ts +131 -0
- package/tests/relief-valve-min-temperature-calculation/testCase140.test.ts +49 -0
- package/tests/set-mixing-layer-height/testCase100.test.ts +36 -0
- package/tests/set-mixing-layer-height/testCase101.test.ts +36 -0
- package/tests/set-mixing-layer-height/testCase102.test.ts +36 -0
- package/tests/set-phase-to-be-released-for-leak-calculation/testCase150.test.ts +67 -0
- package/tests/set-phase-to-be-released-for-line-rupture-calculation/testCase151.test.ts +67 -0
- package/tests/set-phase-to-be-released-for-relief-valve-calculation/TestCase152.test.ts +61 -0
- package/tests/sideview/testCase31b.test.ts +150 -0
- package/tests/sideview/testCase32b.test.ts +145 -0
- package/tests/sideview/testCase33b.test.ts +130 -0
- package/tests/sideview/testCase34b.test.ts +153 -0
- package/tests/sideview/testCase35b.test.ts +140 -0
- package/tests/tank-fire-calculation/testCase79.test.ts +61 -0
- package/tests/tank-fire-calculation/testCase80.test.ts +67 -0
- package/tests/tank-fire-calculation/testCase81.test.ts +68 -0
- package/tests/tank-fire-calculation/testCase82.test.ts +68 -0
- package/tests/tank-fire-calculation/testCase83.test.ts +73 -0
- package/tests/utilities/convert-camel-case-to-snake-case.test.ts +7 -0
- package/tests/utilities/convert-snake-case-to-camel-case.test.ts +7 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase1.test.ts +83 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase2.test.ts +82 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase3.test.ts +91 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase4.test.ts +85 -0
- package/tests/vessel-catastrophic-rupture-calculation/testCase5.test.ts +84 -0
- package/tests/vessel-leak-calculation/testCase10.test.ts +108 -0
- package/tests/vessel-leak-calculation/testCase6.test.ts +113 -0
- package/tests/vessel-leak-calculation/testCase7.test.ts +123 -0
- package/tests/vessel-leak-calculation/testCase8.test.ts +102 -0
- package/tests/vessel-leak-calculation/testCase9.test.ts +106 -0
- package/tests/vessel-line-rupture-calculation/vlr-ammonia.test.ts +84 -0
- package/tests/vessel-line-rupture-calculation/vlr-ethaneMethane.test.ts +82 -0
- package/tests/vessel-line-rupture-calculation/vlr-nDecane.test.ts +79 -0
- package/tests/vessel-line-rupture-calculation/vlr-oxygen.test.ts +77 -0
- package/tests/vessel-line-rupture-calculation/vlr-propane.test.ts +77 -0
- package/tests/vessel-relief-valve-calculation/vrv-chlorine.test.ts +99 -0
- package/tests/vessel-relief-valve-calculation/vrv-hydrogen.test.ts +96 -0
- package/tests/vessel-relief-valve-calculation/vrv-methane.test.ts +80 -0
- package/tests/vessel-relief-valve-calculation/vrv-methaneH2s.test.ts +86 -0
- package/tests/vessel-relief-valve-calculation/vrv-nitrogen.test.ts +80 -0
- package/tests/vessel-state-calculation/vs-ammonia.test.ts +56 -0
- package/tests/vessel-state-calculation/vs-butane.test.ts +57 -0
- package/tests/vessel-state-calculation/vs-chlorine.test.ts +56 -0
- package/tests/vessel-state-calculation/vs-methane.test.ts +57 -0
- package/tests/vessel-state-calculation/vs-naturalGas.test.ts +59 -0
- package/tests/vessel-state-calculation/vs-nitrogenPentane.test.ts +58 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Pipe, PipeBreach, LocalPosition, DischargeParameters } from "../../src/entities";
|
|
2
|
+
import { LongPipeBreachCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { ResultCode } 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("Long Pipe Breach Calculation - Test Case 55", () => {
|
|
14
|
+
test("should run long pipe breach calculation with regression checks", async () => {
|
|
15
|
+
const material = new Material({
|
|
16
|
+
name: "METHANE",
|
|
17
|
+
components: [new MaterialComponent({ name: "METHANE", moleFraction: 1.0 })],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const state = new State({
|
|
21
|
+
temperature: 270.0,
|
|
22
|
+
pressure: 5.0e6,
|
|
23
|
+
liquidFraction: 0.0,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const nodes = [new LocalPosition(), new LocalPosition({x: 500, y: 10, z: 0})];
|
|
27
|
+
|
|
28
|
+
const pipe = new Pipe({
|
|
29
|
+
state,
|
|
30
|
+
material,
|
|
31
|
+
diameter: 2.0,
|
|
32
|
+
nodes,
|
|
33
|
+
nodeCount: nodes.length,
|
|
34
|
+
roughness: 0.0001,
|
|
35
|
+
pumpedInflow: 0.0,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const pipeBreach = new PipeBreach({
|
|
39
|
+
relativeAperture: 1.0,
|
|
40
|
+
distanceDownstream: 200,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const dischargeParameters = new DischargeParameters();
|
|
44
|
+
|
|
45
|
+
const longPipeBreachCalculation = new LongPipeBreachCalculation(
|
|
46
|
+
pipe,
|
|
47
|
+
pipeBreach,
|
|
48
|
+
dischargeParameters
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
console.log("Running long_pipe_breach_calculation...");
|
|
52
|
+
const resultCode = await longPipeBreachCalculation.run();
|
|
53
|
+
|
|
54
|
+
if (longPipeBreachCalculation.messages.length > 0) {
|
|
55
|
+
console.log("Messages:");
|
|
56
|
+
longPipeBreachCalculation.messages.forEach((msg) => console.log(msg));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
60
|
+
|
|
61
|
+
const records = longPipeBreachCalculation.dischargeRecords!;
|
|
62
|
+
const result = longPipeBreachCalculation.dischargeResult!;
|
|
63
|
+
|
|
64
|
+
// Regression check 1: mass_flow at index 1
|
|
65
|
+
const expectedMassFlow = 84340.97304790844;
|
|
66
|
+
const massFlow = records[1].massFlow!;
|
|
67
|
+
const massFlowError = Math.abs((massFlow - expectedMassFlow) / expectedMassFlow);
|
|
68
|
+
expect(massFlowError).toBeLessThan(1e-3);
|
|
69
|
+
|
|
70
|
+
// Regression check 2: number of records
|
|
71
|
+
expect(records.length).toBe(100);
|
|
72
|
+
|
|
73
|
+
// Regression check 3: last record time
|
|
74
|
+
const expectedLastTime = 4.258897723827401;
|
|
75
|
+
const lastTime = records.at(-1)!.time!;
|
|
76
|
+
const timeError = Math.abs((lastTime - expectedLastTime) / expectedLastTime);
|
|
77
|
+
expect(timeError).toBeLessThan(1e-3);
|
|
78
|
+
|
|
79
|
+
// Regression check 4: release mass
|
|
80
|
+
const expectedReleaseMass = 62852.79140375229;
|
|
81
|
+
const releaseMass = result.releaseMass!;
|
|
82
|
+
const releaseMassError = Math.abs((releaseMass - expectedReleaseMass) / expectedReleaseMass);
|
|
83
|
+
expect(releaseMassError).toBeLessThan(1e-3);
|
|
84
|
+
|
|
85
|
+
console.log(`SUCCESS: long_pipe_breach_calculation (${longPipeBreachCalculation.calculationElapsedTime}ms)`);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Pipe, PipeBreach, LocalPosition, DischargeParameters } from "../../src/entities";
|
|
2
|
+
import { LongPipeBreachCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { ResultCode } 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("Long Pipe Breach Calculation - Test Case 56", () => {
|
|
14
|
+
test("should run long pipe breach calculation with regression checks", async () => {
|
|
15
|
+
const material = new Material({
|
|
16
|
+
name: "HYDROGEN",
|
|
17
|
+
components: [new MaterialComponent({ name: "HYDROGEN", moleFraction: 1.0 })],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const state = new State({
|
|
21
|
+
temperature: 250.0,
|
|
22
|
+
pressure: 1.0e7,
|
|
23
|
+
liquidFraction: 0.0,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const nodes = [new LocalPosition(), new LocalPosition({ x: 500, y: 10, z: 0 })];
|
|
27
|
+
|
|
28
|
+
const pipe = new Pipe({
|
|
29
|
+
state,
|
|
30
|
+
material,
|
|
31
|
+
diameter: 1.5,
|
|
32
|
+
nodes,
|
|
33
|
+
nodeCount: nodes.length,
|
|
34
|
+
roughness: 0.0001,
|
|
35
|
+
pumpedInflow: 1.0,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const pipeBreach = new PipeBreach({
|
|
39
|
+
relativeAperture: 0.75,
|
|
40
|
+
distanceDownstream: 200,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const dischargeParameters = new DischargeParameters();
|
|
44
|
+
|
|
45
|
+
const longPipeBreachCalculation = new LongPipeBreachCalculation(
|
|
46
|
+
pipe,
|
|
47
|
+
pipeBreach,
|
|
48
|
+
dischargeParameters
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
console.log("Running long_pipe_breach_calculation...");
|
|
52
|
+
const resultCode = await longPipeBreachCalculation.run();
|
|
53
|
+
|
|
54
|
+
if (longPipeBreachCalculation.messages.length > 0) {
|
|
55
|
+
console.log("Messages:");
|
|
56
|
+
longPipeBreachCalculation.messages.forEach((msg) => console.log(msg));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
60
|
+
|
|
61
|
+
const records = longPipeBreachCalculation.dischargeRecords!;
|
|
62
|
+
const result = longPipeBreachCalculation.dischargeResult!;
|
|
63
|
+
|
|
64
|
+
// Regression check 1: mass_flow at index 1
|
|
65
|
+
const expectedMassFlow = 26120.676566180955;
|
|
66
|
+
const massFlow = records[1].massFlow!;
|
|
67
|
+
const massFlowError = Math.abs((massFlow - expectedMassFlow) / expectedMassFlow);
|
|
68
|
+
expect(massFlowError).toBeLessThan(1e-3);
|
|
69
|
+
|
|
70
|
+
// Regression check 2: number of records
|
|
71
|
+
expect(records.length).toBe(100);
|
|
72
|
+
|
|
73
|
+
// Regression check 3: last record time
|
|
74
|
+
const expectedLastTime = 3600.0;
|
|
75
|
+
const lastTime = records.at(-1)!.time!;
|
|
76
|
+
const timeError = Math.abs((lastTime - expectedLastTime) / expectedLastTime);
|
|
77
|
+
expect(timeError).toBeLessThan(1e-3);
|
|
78
|
+
|
|
79
|
+
// Regression check 4: release mass
|
|
80
|
+
const expectedReleaseMass = 11421.86243095664;
|
|
81
|
+
const releaseMass = result.releaseMass!;
|
|
82
|
+
const releaseMassError = Math.abs((releaseMass - expectedReleaseMass) / expectedReleaseMass);
|
|
83
|
+
expect(releaseMassError).toBeLessThan(1e-3);
|
|
84
|
+
|
|
85
|
+
console.log(
|
|
86
|
+
`SUCCESS: long_pipe_breach_calculation (${longPipeBreachCalculation.calculationElapsedTime}ms)`
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Pipe, PipeBreach, LocalPosition, DischargeParameters } from "../../src/entities";
|
|
2
|
+
import { LongPipeBreachCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { ResultCode } 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("Long Pipe Breach Calculation - Test Case 57", () => {
|
|
14
|
+
test("should run long pipe breach calculation with regression checks", async () => {
|
|
15
|
+
const material = new Material({
|
|
16
|
+
name: "CARBON DIOXIDE (TOXIC)",
|
|
17
|
+
components: [new MaterialComponent({ name: "CARBON DIOXIDE (TOXIC)", moleFraction: 1.0 })],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const state = new State({
|
|
21
|
+
temperature: 300.0,
|
|
22
|
+
pressure: 1.0e6,
|
|
23
|
+
liquidFraction: 0.0,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const nodes = [new LocalPosition(), new LocalPosition({ x: 500, y: 10, z: 0 })];
|
|
27
|
+
|
|
28
|
+
const pipe = new Pipe({
|
|
29
|
+
state,
|
|
30
|
+
material,
|
|
31
|
+
diameter: 1.0,
|
|
32
|
+
nodes,
|
|
33
|
+
nodeCount: nodes.length,
|
|
34
|
+
roughness: 0.0001,
|
|
35
|
+
pumpedInflow: 1.0,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const pipeBreach = new PipeBreach({
|
|
39
|
+
relativeAperture: 0.5,
|
|
40
|
+
distanceDownstream: 200,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const dischargeParameters = new DischargeParameters();
|
|
44
|
+
|
|
45
|
+
const longPipeBreachCalculation = new LongPipeBreachCalculation(
|
|
46
|
+
pipe,
|
|
47
|
+
pipeBreach,
|
|
48
|
+
dischargeParameters
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
console.log("Running long_pipe_breach_calculation...");
|
|
52
|
+
const resultCode = await longPipeBreachCalculation.run();
|
|
53
|
+
|
|
54
|
+
if (longPipeBreachCalculation.messages.length > 0) {
|
|
55
|
+
console.log("Messages:");
|
|
56
|
+
longPipeBreachCalculation.messages.forEach((msg) => console.log(msg));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
60
|
+
|
|
61
|
+
const records = longPipeBreachCalculation.dischargeRecords!;
|
|
62
|
+
const result = longPipeBreachCalculation.dischargeResult!;
|
|
63
|
+
|
|
64
|
+
// Regression check 1: mass_flow at index 1
|
|
65
|
+
const expectedMassFlow = 3296.332186434568;
|
|
66
|
+
const massFlow = records[1].massFlow!;
|
|
67
|
+
const massFlowError = Math.abs((massFlow - expectedMassFlow) / expectedMassFlow);
|
|
68
|
+
expect(massFlowError).toBeLessThan(1e-3);
|
|
69
|
+
|
|
70
|
+
// Regression check 2: number of records
|
|
71
|
+
expect(records.length).toBe(100);
|
|
72
|
+
|
|
73
|
+
// Regression check 3: last record time
|
|
74
|
+
const expectedLastTime = 3600.0;
|
|
75
|
+
const lastTime = records.at(-1)!.time!;
|
|
76
|
+
const timeError = Math.abs((lastTime - expectedLastTime) / expectedLastTime);
|
|
77
|
+
expect(timeError).toBeLessThan(1e-3);
|
|
78
|
+
|
|
79
|
+
// Regression check 4: release mass
|
|
80
|
+
const expectedReleaseMass = 10146.339556422015;
|
|
81
|
+
const releaseMass = result.releaseMass!;
|
|
82
|
+
const releaseMassError = Math.abs((releaseMass - expectedReleaseMass) / expectedReleaseMass);
|
|
83
|
+
expect(releaseMassError).toBeLessThan(1e-3);
|
|
84
|
+
|
|
85
|
+
console.log(`SUCCESS: long_pipe_breach_calculation (${longPipeBreachCalculation.calculationElapsedTime}ms)`);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Pipe, PipeBreach, LocalPosition, DischargeParameters } from "../../src/entities";
|
|
2
|
+
import { LongPipeBreachCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { ResultCode } 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("Long Pipe Breach Calculation - Test Case 58", () => {
|
|
14
|
+
test("should run long pipe breach calculation with regression checks", async () => {
|
|
15
|
+
const material = new Material({
|
|
16
|
+
name: "ETHANE",
|
|
17
|
+
components: [new MaterialComponent({ name: "ETHANE", moleFraction: 1.0 })],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const state = new State({
|
|
21
|
+
temperature: 280.0,
|
|
22
|
+
pressure: 2.0e6,
|
|
23
|
+
liquidFraction: 0.0,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const nodes = [new LocalPosition(), new LocalPosition({ x: 500, y: 10, z: 0 })];
|
|
27
|
+
|
|
28
|
+
const pipe = new Pipe({
|
|
29
|
+
state,
|
|
30
|
+
material,
|
|
31
|
+
diameter: 0.3,
|
|
32
|
+
nodes,
|
|
33
|
+
nodeCount: nodes.length,
|
|
34
|
+
roughness: 0.0001,
|
|
35
|
+
pumpedInflow: 5.0,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const pipeBreach = new PipeBreach({
|
|
39
|
+
relativeAperture: 1.0,
|
|
40
|
+
distanceDownstream: 200,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const dischargeParameters = new DischargeParameters();
|
|
44
|
+
|
|
45
|
+
const longPipeBreachCalculation = new LongPipeBreachCalculation(
|
|
46
|
+
pipe,
|
|
47
|
+
pipeBreach,
|
|
48
|
+
dischargeParameters
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
console.log("Running long_pipe_breach_calculation...");
|
|
52
|
+
const resultCode = await longPipeBreachCalculation.run();
|
|
53
|
+
|
|
54
|
+
if (longPipeBreachCalculation.messages.length > 0) {
|
|
55
|
+
console.log("Messages:");
|
|
56
|
+
longPipeBreachCalculation.messages.forEach((msg) => console.log(msg));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
60
|
+
|
|
61
|
+
const records = longPipeBreachCalculation.dischargeRecords!;
|
|
62
|
+
const result = longPipeBreachCalculation.dischargeResult!;
|
|
63
|
+
|
|
64
|
+
// Regression check 1: mass_flow at index 1
|
|
65
|
+
const expectedMassFlow = 989.859163055802;
|
|
66
|
+
const massFlow = records[1].massFlow!;
|
|
67
|
+
const massFlowError = Math.abs((massFlow - expectedMassFlow) / expectedMassFlow);
|
|
68
|
+
expect(massFlowError).toBeLessThan(1e-3);
|
|
69
|
+
|
|
70
|
+
// Regression check 2: number of records
|
|
71
|
+
expect(records.length).toBe(100);
|
|
72
|
+
|
|
73
|
+
// Regression check 3: last record time
|
|
74
|
+
const expectedLastTime = 3600.0;
|
|
75
|
+
const lastTime = records.at(-1)!.time!;
|
|
76
|
+
const timeError = Math.abs((lastTime - expectedLastTime) / expectedLastTime);
|
|
77
|
+
expect(timeError).toBeLessThan(1e-3);
|
|
78
|
+
|
|
79
|
+
// Regression check 4: release mass
|
|
80
|
+
const expectedReleaseMass = 19120.476210344274;
|
|
81
|
+
const releaseMass = result.releaseMass!;
|
|
82
|
+
const releaseMassError = Math.abs((releaseMass - expectedReleaseMass) / expectedReleaseMass);
|
|
83
|
+
expect(releaseMassError).toBeLessThan(1e-3);
|
|
84
|
+
|
|
85
|
+
console.log(`SUCCESS: long_pipe_breach_calculation (${longPipeBreachCalculation.calculationElapsedTime}ms)`);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Material, MaterialComponent, State, Pipe, PipeBreach, LocalPosition, DischargeParameters } from "../../src/entities";
|
|
2
|
+
import { LongPipeBreachCalculation } from "../../src/calculations/discharge";
|
|
3
|
+
import { ResultCode } 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("Long Pipe Breach Calculation - Test Case 59", () => {
|
|
14
|
+
test("should run long pipe breach calculation with regression checks", async () => {
|
|
15
|
+
const material = new Material({
|
|
16
|
+
name: "PROPANE",
|
|
17
|
+
components: [new MaterialComponent({ name: "PROPANE", moleFraction: 1.0 })],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const state = new State({
|
|
21
|
+
temperature: 320.0,
|
|
22
|
+
pressure: 1.0e6,
|
|
23
|
+
liquidFraction: 0.0,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const nodes = [new LocalPosition(), new LocalPosition({ x: 500, y: 10, z: 0 })];
|
|
27
|
+
|
|
28
|
+
const pipe = new Pipe({
|
|
29
|
+
state,
|
|
30
|
+
material,
|
|
31
|
+
diameter: 0.5,
|
|
32
|
+
nodes,
|
|
33
|
+
nodeCount: nodes.length,
|
|
34
|
+
roughness: 0.0001,
|
|
35
|
+
pumpedInflow: 2.0,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const pipeBreach = new PipeBreach({
|
|
39
|
+
relativeAperture: 0.25,
|
|
40
|
+
distanceDownstream: 200,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const dischargeParameters = new DischargeParameters();
|
|
44
|
+
|
|
45
|
+
const longPipeBreachCalculation = new LongPipeBreachCalculation(
|
|
46
|
+
pipe,
|
|
47
|
+
pipeBreach,
|
|
48
|
+
dischargeParameters
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
console.log("Running long_pipe_breach_calculation...");
|
|
52
|
+
const resultCode = await longPipeBreachCalculation.run();
|
|
53
|
+
|
|
54
|
+
if (longPipeBreachCalculation.messages.length > 0) {
|
|
55
|
+
console.log("Messages:");
|
|
56
|
+
longPipeBreachCalculation.messages.forEach((msg) => console.log(msg));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
60
|
+
|
|
61
|
+
const records = longPipeBreachCalculation.dischargeRecords!;
|
|
62
|
+
const result = longPipeBreachCalculation.dischargeResult!;
|
|
63
|
+
|
|
64
|
+
// Regression check 1: mass_flow at index 1
|
|
65
|
+
const expectedMassFlow = 395.8218347470558;
|
|
66
|
+
const massFlow = records[1].massFlow!;
|
|
67
|
+
const massFlowError = Math.abs((massFlow - expectedMassFlow) / expectedMassFlow);
|
|
68
|
+
expect(massFlowError).toBeLessThan(1e-3);
|
|
69
|
+
|
|
70
|
+
// Regression check 2: number of records
|
|
71
|
+
expect(records.length).toBe(100);
|
|
72
|
+
|
|
73
|
+
// Regression check 3: last record time
|
|
74
|
+
const expectedLastTime = 3600.0;
|
|
75
|
+
const lastTime = records.at(-1)!.time!;
|
|
76
|
+
const timeError = Math.abs((lastTime - expectedLastTime) / expectedLastTime);
|
|
77
|
+
expect(timeError).toBeLessThan(1e-3);
|
|
78
|
+
|
|
79
|
+
// Regression check 4: release mass
|
|
80
|
+
const expectedReleaseMass = 8909.033415824528;
|
|
81
|
+
const releaseMass = result.releaseMass!;
|
|
82
|
+
const releaseMassError = Math.abs((releaseMass - expectedReleaseMass) / expectedReleaseMass);
|
|
83
|
+
expect(releaseMassError).toBeLessThan(1e-3);
|
|
84
|
+
|
|
85
|
+
console.log(`SUCCESS: long_pipe_breach_calculation (${longPipeBreachCalculation.calculationElapsedTime}ms)`);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getComponentByCasId } from "../../src/materials"; // Adjust the path as needed
|
|
2
|
+
import { setAccessToken } from "../../src/utilities";
|
|
3
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
4
|
+
|
|
5
|
+
if (!accessToken) {
|
|
6
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setAccessToken(accessToken);
|
|
10
|
+
describe("Material Component Retrieval by CAS ID - 1,2-PROPYLENE OXIDE", () => {
|
|
11
|
+
test("should retrieve material component data for CAS ID 75569", async () => {
|
|
12
|
+
const casId = 75569;
|
|
13
|
+
console.log("Running getComponentByCasId");
|
|
14
|
+
|
|
15
|
+
const materialComponentData = await getComponentByCasId(casId);
|
|
16
|
+
|
|
17
|
+
// Validate that the result is not null or undefined
|
|
18
|
+
expect(materialComponentData).toBeDefined();
|
|
19
|
+
expect(materialComponentData!.name).toBe("1,2-PROPYLENE OXIDE");
|
|
20
|
+
|
|
21
|
+
console.log("Material Component Data:", materialComponentData);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getComponentByCasId } from "../../src/materials";
|
|
2
|
+
import { setAccessToken } from "../../src/utilities";
|
|
3
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
4
|
+
|
|
5
|
+
if (!accessToken) {
|
|
6
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setAccessToken(accessToken);
|
|
10
|
+
describe("getComponentByCasId - CARBON MONOXIDE", () => {
|
|
11
|
+
test("should retrieve material component data for CARBON MONOXIDE", async () => {
|
|
12
|
+
// CAS ID for Carbon Monoxide
|
|
13
|
+
const casId = 630080;
|
|
14
|
+
|
|
15
|
+
// Call the method
|
|
16
|
+
console.log("Running getComponentByCasId");
|
|
17
|
+
const materialComponentData = await getComponentByCasId(casId);
|
|
18
|
+
|
|
19
|
+
// Validate response
|
|
20
|
+
expect(materialComponentData).toBeDefined();
|
|
21
|
+
expect(materialComponentData.name).toBe("CARBON MONOXIDE");
|
|
22
|
+
|
|
23
|
+
console.log("Material Component Data:", materialComponentData);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getComponentByCasId } from "../../src/materials";
|
|
2
|
+
import { setAccessToken } from "../../src/utilities";
|
|
3
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
4
|
+
|
|
5
|
+
if (!accessToken) {
|
|
6
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setAccessToken(accessToken);
|
|
10
|
+
describe("Get Component By CASID - METHANE", () => {
|
|
11
|
+
test("should return material component data for METHANE by CAS ID", async () => {
|
|
12
|
+
const casId = 74828;
|
|
13
|
+
|
|
14
|
+
console.log("Running getComponentByCasId");
|
|
15
|
+
const materialComponentData = await getComponentByCasId(casId);
|
|
16
|
+
|
|
17
|
+
expect(materialComponentData).not.toBeNull();
|
|
18
|
+
expect(materialComponentData.name).toBe("METHANE");
|
|
19
|
+
|
|
20
|
+
console.log("Material Component Data:", materialComponentData);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getComponentById } from "../../src/materials"; // Adjust path as needed
|
|
2
|
+
import { setAccessToken } from "../../src/utilities";
|
|
3
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
4
|
+
|
|
5
|
+
if (!accessToken) {
|
|
6
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setAccessToken(accessToken);
|
|
10
|
+
describe("getComponentById - Test Case for 1,2-PROPYLENE OXIDE", () => {
|
|
11
|
+
test("should fetch the material component data for 1,2-PROPYLENE OXIDE by id", async () => {
|
|
12
|
+
const componentId = "8e8525ec-40cb-4afe-98a6-951f602b2c45";
|
|
13
|
+
|
|
14
|
+
console.log("Running getComponentById");
|
|
15
|
+
|
|
16
|
+
const materialComponentData = await getComponentById(componentId);
|
|
17
|
+
|
|
18
|
+
expect(materialComponentData).not.toBeNull();
|
|
19
|
+
expect(materialComponentData!.name).toBe("1,2-PROPYLENE OXIDE");
|
|
20
|
+
|
|
21
|
+
console.log("Material Component Data:", materialComponentData);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getComponentById } from "../../src/materials"; // Adjust path as needed
|
|
2
|
+
import { setAccessToken } from "../../src/utilities";
|
|
3
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
4
|
+
|
|
5
|
+
if (!accessToken) {
|
|
6
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setAccessToken(accessToken);
|
|
10
|
+
describe("Material Component Fetch - Test Case CARBON MONOXIDE", () => {
|
|
11
|
+
test("should fetch CARBON MONOXIDE by ID", async () => {
|
|
12
|
+
const carbonMonoxideId = "bd1ee7c4-58c6-4b74-82d3-c8da95b4159b";
|
|
13
|
+
|
|
14
|
+
console.log("Running getComponentById");
|
|
15
|
+
const materialComponentData = await getComponentById(carbonMonoxideId);
|
|
16
|
+
|
|
17
|
+
expect(materialComponentData).not.toBeNull();
|
|
18
|
+
expect(materialComponentData!.name).toBe("CARBON MONOXIDE");
|
|
19
|
+
|
|
20
|
+
console.log("Material Component Data:", materialComponentData);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getComponentById } from "../../src/materials"; // Adjust import path if necessary
|
|
2
|
+
import { setAccessToken } from "../../src/utilities";
|
|
3
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
4
|
+
|
|
5
|
+
if (!accessToken) {
|
|
6
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setAccessToken(accessToken);
|
|
10
|
+
describe("getComponentById - METHANE", () => {
|
|
11
|
+
test("should fetch material component data by ID for METHANE", async () => {
|
|
12
|
+
const methaneId = "9ad96d64-098e-4079-b604-a432145eba99";
|
|
13
|
+
console.log("Running getComponentById");
|
|
14
|
+
|
|
15
|
+
const materialComponentData = await getComponentById(methaneId);
|
|
16
|
+
|
|
17
|
+
expect(materialComponentData).not.toBeNull();
|
|
18
|
+
expect(materialComponentData.name).toBe("METHANE");
|
|
19
|
+
|
|
20
|
+
console.log("Material Component Data:", materialComponentData);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getComponentByName } from "../../src/materials";
|
|
2
|
+
import { MaterialComponent } from "../../src/entities";
|
|
3
|
+
import { setAccessToken } from "../../src/utilities";
|
|
4
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
5
|
+
|
|
6
|
+
if (!accessToken) {
|
|
7
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
setAccessToken(accessToken);
|
|
11
|
+
|
|
12
|
+
describe("Material Component Lookup - Test Case get_component_by_name", () => {
|
|
13
|
+
test("should retrieve data for 1,2-PROPYLENE OXIDE", async () => {
|
|
14
|
+
const componentName = "1,2-PROPYLENE OXIDE";
|
|
15
|
+
console.log("Running getComponentByName");
|
|
16
|
+
|
|
17
|
+
const materialComponentData = await getComponentByName(componentName);
|
|
18
|
+
|
|
19
|
+
expect(materialComponentData).not.toBeNull();
|
|
20
|
+
expect(materialComponentData?.name).toBe(componentName);
|
|
21
|
+
|
|
22
|
+
console.log("Material Component Data:", materialComponentData);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { getComponentByName } from "../../src/materials"; // Adjust import path as needed
|
|
3
|
+
import { setAccessToken } from "../../src/utilities";
|
|
4
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
5
|
+
|
|
6
|
+
if (!accessToken) {
|
|
7
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
setAccessToken(accessToken);
|
|
11
|
+
|
|
12
|
+
describe("Material Component Lookup - CARBON MONOXIDE", () => {
|
|
13
|
+
test("should retrieve material component data for CARBON MONOXIDE", async () => {
|
|
14
|
+
console.log("Running getComponentByName");
|
|
15
|
+
|
|
16
|
+
const materialComponentData = await getComponentByName("CARBON MONOXIDE");
|
|
17
|
+
|
|
18
|
+
expect(materialComponentData).toBeDefined();
|
|
19
|
+
expect(materialComponentData!.name).toBe("CARBON MONOXIDE");
|
|
20
|
+
|
|
21
|
+
console.log("Material Component Data:", materialComponentData);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getComponentByName } from "../../src/materials";
|
|
2
|
+
import { setAccessToken } from "../../src/utilities";
|
|
3
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
4
|
+
|
|
5
|
+
if (!accessToken) {
|
|
6
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setAccessToken(accessToken);
|
|
10
|
+
describe('getComponentByName - Test for METHANE', () => {
|
|
11
|
+
test('should return METHANE material component data', async () => {
|
|
12
|
+
console.log('Running getComponentByName for METHANE');
|
|
13
|
+
|
|
14
|
+
// Invoke the function to get component by name
|
|
15
|
+
const materialComponentData = await getComponentByName('METHANE');
|
|
16
|
+
|
|
17
|
+
// Assert that the material component data is not null
|
|
18
|
+
expect(materialComponentData).not.toBeNull();
|
|
19
|
+
|
|
20
|
+
// Assert that the name is 'METHANE'
|
|
21
|
+
expect(materialComponentData?.name).toBe('METHANE');
|
|
22
|
+
|
|
23
|
+
console.log('Material Component Data:', materialComponentData);
|
|
24
|
+
});
|
|
25
|
+
});
|