@dnv-plant/typescriptpws 1.0.63-alpha.1857334 → 1.0.63-alpha.1857371
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/package.json
CHANGED
package/jest.config.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { VesselLeakCalculation, VesselStateCalculation } from "../../src/calculations/discharge";
|
|
2
|
-
import { DischargeParameters, Leak, LocalPosition, Material, MaterialComponent, SafetySystem, State, Vessel } from "../../src/entities";
|
|
3
|
-
import { ResultCode, TimeVaryingOption, VesselShape } from "../../src/enums";
|
|
4
|
-
|
|
5
|
-
import { setAccessToken } from "../../src/utilities";
|
|
6
|
-
setAccessToken("eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleTEiLCJ0eXAiOiJKV1QifQ.eyJzdWIiOiJhZjQ2NGIwNC1jYjM2LTQwOGUtYWI4Zi03MzQ5OTRkYjU5YzUiLCJpc3MiOiJodHRwczovL3BsYW50d2Vic2VydmljZXMuZG52LmNvbSIsImF1ZCI6Imh0dHBzOi8vcGxhbnR3ZWJzZXJ2aWNlcy5kbnYuY29tIiwiaWF0IjoxNzQyOTExNzIzLCJleHAiOjE3NzQ0NDc2MTYsImp0aSI6IjA5NDJiM2Y5MWMzNjRhYWRiMTFhYmVjYzE4MjY0YzFhIiwic2NvcGVzIjpudWxsfQ.dnORse8zs7vVstqbFtJii0LyG7K9NdeOJ3N_Jm77wYvTY0UJpVQPPeZDYnvLIe0-eeuJqqHG2v3J1pgdCgl44GFaGCE0yXJm-6RyZQllv-96X4RI0gLVaVvdTvKmCI8oCEtRWvP-q9cT3Nt_pZF1En3N2szONTmKU-vEhMf87s1q0Huh26LE_KZUxe7pMwh77_YX-3uDzwzkNomiBZdGI5yYLEVYoz3TY1tUkjhfa71V-UqSWqcASiHs6L0HyyXjl3G66LrClGKM4URIfEtCH8F8GeIJ_CWHMP3SKbDkg_exQ_JuRN8dJR-WucdLQwvlGIb5iu1_KtO931Jt-ldoyGS5-GmTrcbHpX06HwpbxdkDjxrsI-x_wMVCLQCa13sm9IFHwfpsr8O9DbQ9-LERRSq3gI0tTc6j96529mx2Gk4_iWvHUAxApTyXZ6lHANyWVa0HPW4Pg9Ls2S_oXLO4lUf0e0H1ATXFCFO3YCSjc4fuASYl7XFo_LkvjitlF9MhZYTfPSrYRzztwHtEw4YAcNz82ydaMEFBNLRdWZF8iwSXbQzxc78-XmIvNsiWhgBvFEGiIpw46dW60nNj-t0oMnNHsLof2tpy8rqvySOsWo65-zYWn7UJldVio0pN-wrpwoRfJ_l4GVKqGtXcoq_eO44IPyqpqAVRwbdnJUa13YM")
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
describe('Vessel Leak Calculation', () => {
|
|
10
|
-
test('test case 6 - vessel leak calculation', async () => {
|
|
11
|
-
// Set the case properties
|
|
12
|
-
const materialName = 'METHANE';
|
|
13
|
-
const stateTemperature = 280.0;
|
|
14
|
-
const statePressure = 1.0E+06;
|
|
15
|
-
const vesselShape = VesselShape.VESSEL_SPHERE;
|
|
16
|
-
const vesselDiameter = 3.0;
|
|
17
|
-
const leakHoleDiameter = 0.1;
|
|
18
|
-
const timeVaryingOption = TimeVaryingOption.INITIAL_RATE;
|
|
19
|
-
const leakHoleHeightFraction = 0.5;
|
|
20
|
-
|
|
21
|
-
// Define the initial state of the vessel
|
|
22
|
-
const state = new State({
|
|
23
|
-
temperature: stateTemperature,
|
|
24
|
-
pressure: statePressure,
|
|
25
|
-
liquidFraction: 0.0
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Define the material contained by the vessel
|
|
29
|
-
const material = new Material({
|
|
30
|
-
name: materialName,
|
|
31
|
-
components: [new MaterialComponent({name: materialName, moleFraction:1.0})]
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// Create a vessel state calculation using the material and state
|
|
35
|
-
const vesselStateCalculation = new VesselStateCalculation(material, state);
|
|
36
|
-
|
|
37
|
-
// Run the vessel state calculation
|
|
38
|
-
const vesselStateResultCode = await vesselStateCalculation.run();
|
|
39
|
-
|
|
40
|
-
// Check vessel state calculation result
|
|
41
|
-
expect(vesselStateResultCode).toBe(ResultCode.SUCCESS);
|
|
42
|
-
|
|
43
|
-
// Optional: Log messages if any
|
|
44
|
-
if (vesselStateCalculation.messages.length > 0) {
|
|
45
|
-
vesselStateCalculation.messages.forEach(message => {
|
|
46
|
-
console.log(message);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Create a vessel to use in the leak calculation
|
|
51
|
-
const vessel = new Vessel({
|
|
52
|
-
state: vesselStateCalculation.outputState!,
|
|
53
|
-
material: vesselStateCalculation.material,
|
|
54
|
-
diameter: vesselDiameter,
|
|
55
|
-
shape: vesselShape,
|
|
56
|
-
vesselConditions: vesselStateCalculation.vesselConditions
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Create a leak to use in the vessel leak calculation
|
|
60
|
-
const leak = new Leak({
|
|
61
|
-
holeDiameter:leakHoleDiameter,
|
|
62
|
-
timeVaryingOption: timeVaryingOption,
|
|
63
|
-
holeHeightFraction:leakHoleHeightFraction,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// Create discharge parameters to use in the vessel leak calculation
|
|
67
|
-
const dischargeParameters = new DischargeParameters();
|
|
68
|
-
|
|
69
|
-
// Create a vessel leak calculation using the vessel, leak, and discharge parameters
|
|
70
|
-
const vesselLeakCalculation = new VesselLeakCalculation(
|
|
71
|
-
vessel,
|
|
72
|
-
leak,
|
|
73
|
-
dischargeParameters
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// Run the vessel leak calculation
|
|
77
|
-
const vesselLeakResultCode = await vesselLeakCalculation.run();
|
|
78
|
-
|
|
79
|
-
// Check vessel leak calculation result
|
|
80
|
-
expect(vesselLeakResultCode).toBe(ResultCode.SUCCESS);
|
|
81
|
-
|
|
82
|
-
// Optional: Log messages if any
|
|
83
|
-
if (vesselLeakCalculation.messages.length > 0) {
|
|
84
|
-
vesselLeakCalculation.messages.forEach(message => {
|
|
85
|
-
console.log(message);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Regression tests for discharge records
|
|
90
|
-
const dischargeRecords = vesselLeakCalculation.dischargeRecords;
|
|
91
|
-
|
|
92
|
-
// Check number of discharge records
|
|
93
|
-
expect(dischargeRecords).toBeDefined();
|
|
94
|
-
expect(dischargeRecords!.length).toBe(2);
|
|
95
|
-
|
|
96
|
-
// Check mass flow regression
|
|
97
|
-
const expectedMassFlow = 12.033250169270818;
|
|
98
|
-
const actualMassFlow = dischargeRecords ? dischargeRecords[0].massFlow : undefined;
|
|
99
|
-
expect(actualMassFlow).toBeDefined();
|
|
100
|
-
expect(Math.abs(((actualMassFlow as number) - expectedMassFlow) / expectedMassFlow)).toBeLessThan(1e-3);
|
|
101
|
-
|
|
102
|
-
// Check final velocity regression
|
|
103
|
-
const expectedFinalVelocity = 649.4227509851291;
|
|
104
|
-
const actualFinalVelocity = dischargeRecords ? dischargeRecords[0].finalVelocity : undefined;
|
|
105
|
-
expect(actualFinalVelocity).toBeDefined();
|
|
106
|
-
expect(Math.abs(((actualFinalVelocity as number) - expectedFinalVelocity) / expectedFinalVelocity)).toBeLessThan(1e-3);
|
|
107
|
-
});
|
|
108
|
-
});
|