@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,73 @@
|
|
|
1
|
+
import { ConvertCompositionMassToMoleCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
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('Test Case 131', () => {
|
|
14
|
+
test('Convert composition mass to mole calculation for ETHANE, METHANE, and HYDROGEN', async () => {
|
|
15
|
+
|
|
16
|
+
// Define the test case properties
|
|
17
|
+
const materialName = 'ETHANE_METHANE_HYDROGEN';
|
|
18
|
+
const compositionMass = [0.3, 0.5, 0.2];
|
|
19
|
+
|
|
20
|
+
// Define the material
|
|
21
|
+
const material = new Material({
|
|
22
|
+
name: materialName,
|
|
23
|
+
components: [
|
|
24
|
+
new MaterialComponent({ name: 'ETHANE', moleFraction: 0.3 }),
|
|
25
|
+
new MaterialComponent({ name: 'METHANE', moleFraction: 0.5 }),
|
|
26
|
+
new MaterialComponent({ name: 'HYDROGEN', moleFraction: 0.2 })
|
|
27
|
+
],
|
|
28
|
+
componentCount: 3
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Create a ConvertCompositionMassToMoleCalculation using the material and composition mass
|
|
32
|
+
const convertCompMassToMoleCalculation = new ConvertCompositionMassToMoleCalculation(
|
|
33
|
+
material,
|
|
34
|
+
compositionMass,
|
|
35
|
+
compositionMass.length
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Run the ConvertCompositionMassToMoleCalculation
|
|
39
|
+
console.log('Running convertCompMassToMoleCalculation...');
|
|
40
|
+
const resultCode = await convertCompMassToMoleCalculation.run();
|
|
41
|
+
|
|
42
|
+
// Print any messages
|
|
43
|
+
if (convertCompMassToMoleCalculation.messages.length > 0) {
|
|
44
|
+
console.log('Messages:');
|
|
45
|
+
convertCompMassToMoleCalculation.messages.forEach((message) => {
|
|
46
|
+
console.log(message);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
50
|
+
|
|
51
|
+
// Log mole and mass fractions
|
|
52
|
+
console.log(`Mole fraction: ${convertCompMassToMoleCalculation.compositionMole}`);
|
|
53
|
+
console.log(`Mass fraction: ${convertCompMassToMoleCalculation.compositionMass}`);
|
|
54
|
+
|
|
55
|
+
// Ensure the properties are defined before using them
|
|
56
|
+
expect(convertCompMassToMoleCalculation.compositionMole).toBeDefined();
|
|
57
|
+
expect(convertCompMassToMoleCalculation.compositionMass).toBeDefined();
|
|
58
|
+
|
|
59
|
+
if (convertCompMassToMoleCalculation.compositionMole) {
|
|
60
|
+
// Regression check for the first mole fraction value
|
|
61
|
+
const expectedMoleFraction = 0.07108364334790362;
|
|
62
|
+
const actualMoleFraction = convertCompMassToMoleCalculation.compositionMole[0];
|
|
63
|
+
const moleFractionDifference = Math.abs((actualMoleFraction - expectedMoleFraction) / expectedMoleFraction);
|
|
64
|
+
|
|
65
|
+
// Perform the regression check and fail if the difference is too large
|
|
66
|
+
expect(moleFractionDifference).toBeLessThan(1e-3);
|
|
67
|
+
|
|
68
|
+
console.log(`SUCCESS: convertCompMassToMoleCalculation (${convertCompMassToMoleCalculation.calculationElapsedTime}ms)`);
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error('Composition mole data is undefined.');
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ConvertCompositionMassToMoleCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
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('Test Case 132', () => {
|
|
14
|
+
test('Convert composition mass to mole calculation for BUTANE, DECANE, and ETHANE', async () => {
|
|
15
|
+
|
|
16
|
+
// Define the test case properties
|
|
17
|
+
const materialName = 'BUTANE_DECANE_ETHANE';
|
|
18
|
+
const compositionMass = [0.2, 0.2, 0.6];
|
|
19
|
+
|
|
20
|
+
// Define the material
|
|
21
|
+
const material = new Material({
|
|
22
|
+
name: materialName,
|
|
23
|
+
components: [
|
|
24
|
+
new MaterialComponent({ name: 'N-BUTANE', moleFraction: 0.2 }),
|
|
25
|
+
new MaterialComponent({ name: 'N-DECANE', moleFraction: 0.2 }),
|
|
26
|
+
new MaterialComponent({ name: 'ETHANE', moleFraction: 0.6 })
|
|
27
|
+
],
|
|
28
|
+
componentCount: 3
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Create a ConvertCompositionMassToMoleCalculation using the material and composition mass
|
|
32
|
+
const convertCompMassToMoleCalculation = new ConvertCompositionMassToMoleCalculation(
|
|
33
|
+
material,
|
|
34
|
+
compositionMass,
|
|
35
|
+
compositionMass.length
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Run the ConvertCompositionMassToMoleCalculation
|
|
39
|
+
console.log('Running convertCompMassToMoleCalculation...');
|
|
40
|
+
const resultCode = await convertCompMassToMoleCalculation.run();
|
|
41
|
+
|
|
42
|
+
// Print any messages
|
|
43
|
+
if (convertCompMassToMoleCalculation.messages.length > 0) {
|
|
44
|
+
console.log('Messages:');
|
|
45
|
+
convertCompMassToMoleCalculation.messages.forEach((message) => {
|
|
46
|
+
console.log(message);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
50
|
+
|
|
51
|
+
// Log mole and mass fractions
|
|
52
|
+
console.log(`Mole fraction: ${convertCompMassToMoleCalculation.compositionMole}`);
|
|
53
|
+
console.log(`Mass fraction: ${convertCompMassToMoleCalculation.compositionMass}`);
|
|
54
|
+
|
|
55
|
+
// Ensure the properties are defined before using them
|
|
56
|
+
expect(convertCompMassToMoleCalculation.compositionMole).toBeDefined();
|
|
57
|
+
expect(convertCompMassToMoleCalculation.compositionMass).toBeDefined();
|
|
58
|
+
|
|
59
|
+
if (convertCompMassToMoleCalculation.compositionMole) {
|
|
60
|
+
// Regression check for the first mole fraction value
|
|
61
|
+
const expectedMoleFraction = 0.13874660598043345;
|
|
62
|
+
const actualMoleFraction = convertCompMassToMoleCalculation.compositionMole[0];
|
|
63
|
+
const moleFractionDifference = Math.abs((actualMoleFraction - expectedMoleFraction) / expectedMoleFraction);
|
|
64
|
+
|
|
65
|
+
// Perform the regression check and fail if the difference is too large
|
|
66
|
+
expect(moleFractionDifference).toBeLessThan(1e-3);
|
|
67
|
+
|
|
68
|
+
console.log(`SUCCESS: convertCompMassToMoleCalculation (${convertCompMassToMoleCalculation.calculationElapsedTime}ms)`);
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error('Composition mole data is undefined.');
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ConvertCompositionMassToMoleCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
3
|
+
import { ResultCode } from "../../src/enums";
|
|
4
|
+
import { setAccessToken } from "../../src/utilities";
|
|
5
|
+
|
|
6
|
+
const accessToken = process.env.PWS_ACCESS_TOKEN;
|
|
7
|
+
if (!accessToken) {
|
|
8
|
+
throw new Error("ACCESS_TOKEN environment variable is not set.");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
setAccessToken(accessToken);
|
|
12
|
+
|
|
13
|
+
describe('Test Case 133', () => {
|
|
14
|
+
test('Convert composition mass to mole calculation for TOLUENE, PROPANE, and BUTANE', async () => {
|
|
15
|
+
|
|
16
|
+
// Define the test case properties
|
|
17
|
+
const materialName = 'TOLUENE_PROPANE_BUTANE';
|
|
18
|
+
const compositionMass = [0.3, 0.2, 0.5];
|
|
19
|
+
|
|
20
|
+
// Define the material
|
|
21
|
+
const material = new Material({
|
|
22
|
+
name: materialName,
|
|
23
|
+
components: [
|
|
24
|
+
new MaterialComponent({ name: 'TOLUENE', moleFraction: 0.3 }),
|
|
25
|
+
new MaterialComponent({ name: 'PROPANE', moleFraction: 0.2 }),
|
|
26
|
+
new MaterialComponent({ name: 'N-BUTANE', moleFraction: 0.5 })
|
|
27
|
+
],
|
|
28
|
+
componentCount: 3
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Create a ConvertCompositionMassToMoleCalculation using the material and composition mass
|
|
32
|
+
const convertCompMassToMoleCalculation = new ConvertCompositionMassToMoleCalculation(
|
|
33
|
+
material,
|
|
34
|
+
compositionMass,
|
|
35
|
+
compositionMass.length
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Run the ConvertCompositionMassToMoleCalculation
|
|
39
|
+
console.log('Running convertCompMassToMoleCalculation...');
|
|
40
|
+
const resultCode = await convertCompMassToMoleCalculation.run();
|
|
41
|
+
|
|
42
|
+
// Print any messages
|
|
43
|
+
if (convertCompMassToMoleCalculation.messages.length > 0) {
|
|
44
|
+
console.log('Messages:');
|
|
45
|
+
convertCompMassToMoleCalculation.messages.forEach((message) => {
|
|
46
|
+
console.log(message);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
50
|
+
|
|
51
|
+
// Log mole and mass fractions
|
|
52
|
+
console.log(`Mole fraction: ${convertCompMassToMoleCalculation.compositionMole}`);
|
|
53
|
+
console.log(`Mass fraction: ${convertCompMassToMoleCalculation.compositionMass}`);
|
|
54
|
+
|
|
55
|
+
// Ensure the properties are defined before using them
|
|
56
|
+
expect(convertCompMassToMoleCalculation.compositionMole).toBeDefined();
|
|
57
|
+
expect(convertCompMassToMoleCalculation.compositionMass).toBeDefined();
|
|
58
|
+
|
|
59
|
+
if (convertCompMassToMoleCalculation.compositionMole) {
|
|
60
|
+
// Regression check for the first mole fraction value
|
|
61
|
+
const expectedMoleFraction = 0.1986058448591834;
|
|
62
|
+
const actualMoleFraction = convertCompMassToMoleCalculation.compositionMole[0];
|
|
63
|
+
const moleFractionDifference = Math.abs((actualMoleFraction - expectedMoleFraction) / expectedMoleFraction);
|
|
64
|
+
|
|
65
|
+
// Perform the regression check and fail if the difference is too large
|
|
66
|
+
expect(moleFractionDifference).toBeLessThan(1e-3);
|
|
67
|
+
|
|
68
|
+
console.log(`SUCCESS: convertCompMassToMoleCalculation (${convertCompMassToMoleCalculation.calculationElapsedTime}ms)`);
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error('Composition mole data is undefined.');
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ConvertCompositionMoleToMassCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
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("Test Case 134 - Convert Composition Mole to Mass Scenario", () => {
|
|
14
|
+
test("should convert mole fractions to mass fractions with regression checks", async () => {
|
|
15
|
+
// Define the test case properties
|
|
16
|
+
const materialName = "ETHANE_BUTANE_PROPANE";
|
|
17
|
+
const compositionMoles = [0.3, 0.2, 0.5];
|
|
18
|
+
|
|
19
|
+
// Define the material
|
|
20
|
+
const material = new Material({
|
|
21
|
+
name: materialName,
|
|
22
|
+
components: [
|
|
23
|
+
new MaterialComponent({ name: "ETHANE", moleFraction: 0.3 }),
|
|
24
|
+
new MaterialComponent({ name: "N-BUTANE", moleFraction: 0.2 }),
|
|
25
|
+
new MaterialComponent({ name: "PROPANE", moleFraction: 0.5 }),
|
|
26
|
+
],
|
|
27
|
+
componentCount: 3,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create a convert composition mole to mass calculation
|
|
31
|
+
const convertCompMoleToMassCalculation = new ConvertCompositionMoleToMassCalculation(
|
|
32
|
+
material,
|
|
33
|
+
compositionMoles,
|
|
34
|
+
compositionMoles.length,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Run the convert composition mole to mass calculation
|
|
38
|
+
console.log("Running convert_comp_mole_to_mass_calculation...");
|
|
39
|
+
const resultCode = await convertCompMoleToMassCalculation.run();
|
|
40
|
+
|
|
41
|
+
// Print any messages
|
|
42
|
+
if (convertCompMoleToMassCalculation.messages.length > 0) {
|
|
43
|
+
console.log("Messages:");
|
|
44
|
+
convertCompMoleToMassCalculation.messages.forEach((message) => console.log(message));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Assert the result code is SUCCESS
|
|
48
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
49
|
+
|
|
50
|
+
if (resultCode === ResultCode.SUCCESS) {
|
|
51
|
+
console.log(`Mole fraction: ${convertCompMoleToMassCalculation.compositionMoles}`);
|
|
52
|
+
console.log(`Mass fraction: ${convertCompMoleToMassCalculation.compositionMass}`);
|
|
53
|
+
|
|
54
|
+
// Regression check for the first mass fraction
|
|
55
|
+
const massFractionError = Math.abs(
|
|
56
|
+
(convertCompMoleToMassCalculation.compositionMass![0] - 0.2112924967705441) /
|
|
57
|
+
0.2112924967705441
|
|
58
|
+
);
|
|
59
|
+
expect(massFractionError).toBeLessThan(1e-3);
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
`SUCCESS: convert_comp_mole_to_mass_calculation (${
|
|
63
|
+
convertCompMoleToMassCalculation.calculationElapsedTime
|
|
64
|
+
}ms)`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`FAILED convert_comp_mole_to_mass_calculation with result code ${resultCode}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ConvertCompositionMoleToMassCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
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("Test Case 135 - Convert Composition Mole to Mass Scenario", () => {
|
|
14
|
+
test("should convert mole fractions to mass fractions with regression checks", async () => {
|
|
15
|
+
// Define the test case properties
|
|
16
|
+
const materialName = "ETHANE_METHANE_PROPANE";
|
|
17
|
+
const compositionMoles = [0.3, 0.5, 0.2];
|
|
18
|
+
|
|
19
|
+
// Define the material
|
|
20
|
+
const material = new Material({
|
|
21
|
+
name: materialName,
|
|
22
|
+
components: [
|
|
23
|
+
new MaterialComponent({ name: "ETHANE", moleFraction: 0.3 }),
|
|
24
|
+
new MaterialComponent({ name: "METHANE", moleFraction: 0.5 }),
|
|
25
|
+
new MaterialComponent({ name: "PROPANE", moleFraction: 0.2 }),
|
|
26
|
+
],
|
|
27
|
+
componentCount: 3,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create a convert composition mole to mass calculation
|
|
31
|
+
const convertCompMoleToMassCalculation = new ConvertCompositionMoleToMassCalculation(
|
|
32
|
+
material,
|
|
33
|
+
compositionMoles,
|
|
34
|
+
compositionMoles.length,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Run the convert composition mole to mass calculation
|
|
38
|
+
console.log("Running convert_comp_mole_to_mass_calculation...");
|
|
39
|
+
const resultCode = await convertCompMoleToMassCalculation.run();
|
|
40
|
+
|
|
41
|
+
// Print any messages
|
|
42
|
+
if (convertCompMoleToMassCalculation.messages.length > 0) {
|
|
43
|
+
console.log("Messages:");
|
|
44
|
+
convertCompMoleToMassCalculation.messages.forEach((message) => console.log(message));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Assert the result code is SUCCESS
|
|
48
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
49
|
+
|
|
50
|
+
if (resultCode === ResultCode.SUCCESS) {
|
|
51
|
+
console.log(`Mole fraction: ${convertCompMoleToMassCalculation.compositionMoles}`);
|
|
52
|
+
console.log(`Mass fraction: ${convertCompMoleToMassCalculation.compositionMass}`);
|
|
53
|
+
|
|
54
|
+
// Regression check for the first mass fraction
|
|
55
|
+
const massFractionError = Math.abs(
|
|
56
|
+
(convertCompMoleToMassCalculation.compositionMass![0] - 0.3488138195652663) /
|
|
57
|
+
0.3488138195652663
|
|
58
|
+
);
|
|
59
|
+
expect(massFractionError).toBeLessThan(1e-3);
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
`SUCCESS: convert_comp_mole_to_mass_calculation (${
|
|
63
|
+
convertCompMoleToMassCalculation.calculationElapsedTime
|
|
64
|
+
}ms)`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`FAILED convert_comp_mole_to_mass_calculation with result code ${resultCode}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ConvertCompositionMoleToMassCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
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("Test Case 136 - Convert Composition Mole to Mass Scenario", () => {
|
|
14
|
+
test("should convert mole fractions to mass fractions with regression checks", async () => {
|
|
15
|
+
// Define the test case properties
|
|
16
|
+
const materialName = "ETHANE_METHANE_HYDROGEN";
|
|
17
|
+
const compositionMoles = [0.1, 0.3, 0.6];
|
|
18
|
+
|
|
19
|
+
// Define the material
|
|
20
|
+
const material = new Material({
|
|
21
|
+
name: materialName,
|
|
22
|
+
components: [
|
|
23
|
+
new MaterialComponent({ name: "ETHANE", moleFraction: 0.1 }),
|
|
24
|
+
new MaterialComponent({ name: "METHANE", moleFraction: 0.3 }),
|
|
25
|
+
new MaterialComponent({ name: "HYDROGEN", moleFraction: 0.6 }),
|
|
26
|
+
],
|
|
27
|
+
componentCount: 3,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create a convert composition mole to mass calculation
|
|
31
|
+
const convertCompMoleToMassCalculation = new ConvertCompositionMoleToMassCalculation(
|
|
32
|
+
material,
|
|
33
|
+
compositionMoles,
|
|
34
|
+
compositionMoles.length,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Run the convert composition mole to mass calculation
|
|
38
|
+
console.log("Running convert_comp_mole_to_mass_calculation...");
|
|
39
|
+
const resultCode = await convertCompMoleToMassCalculation.run();
|
|
40
|
+
|
|
41
|
+
// Print any messages
|
|
42
|
+
if (convertCompMoleToMassCalculation.messages.length > 0) {
|
|
43
|
+
console.log("Messages:");
|
|
44
|
+
convertCompMoleToMassCalculation.messages.forEach((message) => console.log(message));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Assert the result code is SUCCESS
|
|
48
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
49
|
+
|
|
50
|
+
if (resultCode === ResultCode.SUCCESS) {
|
|
51
|
+
console.log(`Mole fraction: ${convertCompMoleToMassCalculation.compositionMoles}`);
|
|
52
|
+
console.log(`Mass fraction: ${convertCompMoleToMassCalculation.compositionMass}`);
|
|
53
|
+
|
|
54
|
+
// Regression check for the first mass fraction
|
|
55
|
+
const massFractionError = Math.abs(
|
|
56
|
+
(convertCompMoleToMassCalculation.compositionMass![0] - 0.3330203480316813) /
|
|
57
|
+
0.3330203480316813
|
|
58
|
+
);
|
|
59
|
+
expect(massFractionError).toBeLessThan(1e-3);
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
`SUCCESS: convert_comp_mole_to_mass_calculation (${
|
|
63
|
+
convertCompMoleToMassCalculation.calculationElapsedTime
|
|
64
|
+
}ms)`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`FAILED convert_comp_mole_to_mass_calculation with result code ${resultCode}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ConvertCompositionMoleToMassCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
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("Test Case 137 - Convert Composition Mole to Mass Scenario", () => {
|
|
14
|
+
test("should convert mole fractions to mass fractions with regression checks", async () => {
|
|
15
|
+
// Define the test case properties
|
|
16
|
+
const materialName = "BUTANE_DECANE_ETHANE";
|
|
17
|
+
const compositionMoles = [0.4, 0.2, 0.4];
|
|
18
|
+
|
|
19
|
+
// Define the material
|
|
20
|
+
const material = new Material({
|
|
21
|
+
name: materialName,
|
|
22
|
+
components: [
|
|
23
|
+
new MaterialComponent({ name: "N-BUTANE", moleFraction: 0.4 }),
|
|
24
|
+
new MaterialComponent({ name: "N-DECANE", moleFraction: 0.2 }),
|
|
25
|
+
new MaterialComponent({ name: "ETHANE", moleFraction: 0.4 }),
|
|
26
|
+
],
|
|
27
|
+
componentCount: 3,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create a convert composition mole to mass calculation
|
|
31
|
+
const convertCompMoleToMassCalculation = new ConvertCompositionMoleToMassCalculation(
|
|
32
|
+
material,
|
|
33
|
+
compositionMoles,
|
|
34
|
+
compositionMoles.length,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Run the convert composition mole to mass calculation
|
|
38
|
+
console.log("Running convert_comp_mole_to_mass_calculation...");
|
|
39
|
+
const resultCode = await convertCompMoleToMassCalculation.run();
|
|
40
|
+
|
|
41
|
+
// Print any messages
|
|
42
|
+
if (convertCompMoleToMassCalculation.messages.length > 0) {
|
|
43
|
+
console.log("Messages:");
|
|
44
|
+
convertCompMoleToMassCalculation.messages.forEach((message) => console.log(message));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Assert the result code is SUCCESS
|
|
48
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
49
|
+
|
|
50
|
+
if (resultCode === ResultCode.SUCCESS) {
|
|
51
|
+
console.log(`Mole fraction: ${convertCompMoleToMassCalculation.compositionMoles}`);
|
|
52
|
+
console.log(`Mass fraction: ${convertCompMoleToMassCalculation.compositionMass}`);
|
|
53
|
+
|
|
54
|
+
// Regression check for the first mass fraction
|
|
55
|
+
const massFractionError = Math.abs(
|
|
56
|
+
(convertCompMoleToMassCalculation.compositionMass![0] - 0.364786643038023) /
|
|
57
|
+
0.364786643038023
|
|
58
|
+
);
|
|
59
|
+
expect(massFractionError).toBeLessThan(1e-3);
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
`SUCCESS: convert_comp_mole_to_mass_calculation (${
|
|
63
|
+
convertCompMoleToMassCalculation.calculationElapsedTime
|
|
64
|
+
}ms)`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`FAILED convert_comp_mole_to_mass_calculation with result code ${resultCode}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ConvertCompositionMoleToMassCalculation } from "../../src/calculations/utilities";
|
|
2
|
+
import { Material, MaterialComponent } from "../../src/entities";
|
|
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("Test Case 138 - Convert Composition Mole to Mass Scenario", () => {
|
|
14
|
+
test("should convert mole fractions to mass fractions with regression checks", async () => {
|
|
15
|
+
// Define the test case properties
|
|
16
|
+
const materialName = "TOLUENE_PROPANE_BUTANE";
|
|
17
|
+
const compositionMoles = [0.2, 0.2, 0.6];
|
|
18
|
+
|
|
19
|
+
// Define the material
|
|
20
|
+
const material = new Material({
|
|
21
|
+
name: materialName,
|
|
22
|
+
components: [
|
|
23
|
+
new MaterialComponent({ name: "TOLUENE", moleFraction: 0.2 }),
|
|
24
|
+
new MaterialComponent({ name: "PROPANE", moleFraction: 0.2 }),
|
|
25
|
+
new MaterialComponent({ name: "N-BUTANE", moleFraction: 0.6 }),
|
|
26
|
+
],
|
|
27
|
+
componentCount: 3,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create a convert composition mole to mass calculation
|
|
31
|
+
const convertCompMoleToMassCalculation = new ConvertCompositionMoleToMassCalculation(
|
|
32
|
+
material,
|
|
33
|
+
compositionMoles,
|
|
34
|
+
compositionMoles.length,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Run the convert composition mole to mass calculation
|
|
38
|
+
console.log("Running convert_comp_mole_to_mass_calculation...");
|
|
39
|
+
const resultCode = await convertCompMoleToMassCalculation.run();
|
|
40
|
+
|
|
41
|
+
// Print any messages
|
|
42
|
+
if (convertCompMoleToMassCalculation.messages.length > 0) {
|
|
43
|
+
console.log("Messages:");
|
|
44
|
+
convertCompMoleToMassCalculation.messages.forEach((message) => console.log(message));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Assert the result code is SUCCESS
|
|
48
|
+
expect(resultCode).toBe(ResultCode.SUCCESS);
|
|
49
|
+
|
|
50
|
+
if (resultCode === ResultCode.SUCCESS) {
|
|
51
|
+
console.log(`Mole fraction: ${convertCompMoleToMassCalculation.compositionMoles}`);
|
|
52
|
+
console.log(`Mass fraction: ${convertCompMoleToMassCalculation.compositionMass}`);
|
|
53
|
+
|
|
54
|
+
// Regression check for the first mass fraction
|
|
55
|
+
const massFractionError = Math.abs(
|
|
56
|
+
(convertCompMoleToMassCalculation.compositionMass![0] - 0.2966459438074564) /
|
|
57
|
+
0.2966459438074564
|
|
58
|
+
);
|
|
59
|
+
expect(massFractionError).toBeLessThan(1e-3);
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
`SUCCESS: convert_comp_mole_to_mass_calculation (${
|
|
63
|
+
convertCompMoleToMassCalculation.calculationElapsedTime
|
|
64
|
+
}ms)`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`FAILED convert_comp_mole_to_mass_calculation with result code ${resultCode}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|