@dnv-plant/typescriptpws 1.0.97 → 1.0.98
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/LICENSE +1 -1
- package/azure-test-job.yml +25 -0
- package/index.ts +18 -13
- package/package.json +2 -1
- package/src/calculations/applicationTools.ts +16 -12
- package/src/calculations/calculationBase.ts +40 -13
- package/src/calculations/discharge.ts +752 -109
- package/src/calculations/dispersion.ts +17 -15
- package/src/calculations/dispersionView.ts +31 -27
- package/src/calculations/fireball.ts +17 -13
- package/src/calculations/flammableWorkflow.ts +291 -0
- package/src/calculations/jetFire.ts +19 -22
- package/src/calculations/lateExplosion.ts +16 -12
- package/src/calculations/linkedRunners.ts +2715 -780
- package/src/calculations/poolFire.ts +16 -12
- package/src/calculations/properties.ts +17 -14
- package/src/calculations/radiation.ts +65 -61
- package/src/calculations/standalones.ts +16 -12
- package/src/calculations/toxics.ts +17 -13
- package/src/calculations/utilities.ts +673 -23
- package/src/constants.ts +25 -15
- package/src/entities.ts +455 -320
- package/src/entity-schemas.ts +284 -148
- package/src/enums.ts +123 -64
- package/src/materials.ts +152 -152
- package/src/utilities.ts +40 -27
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
1
|
+
// ************************************************************************************
|
|
2
|
+
// *
|
|
3
|
+
// * This file has been auto-generated by a code generation tool.
|
|
4
|
+
// *
|
|
5
|
+
// * DO NOT MODIFY THIS FILE
|
|
6
|
+
// * This file is maintained by DNV.
|
|
7
|
+
// * Editing it may lead to inconsistent results and limit DNV's ability to provide support.
|
|
8
|
+
// * Please contact DNV if you believe changes are required.
|
|
9
|
+
// *
|
|
10
|
+
// * API version: 1.0.
|
|
11
|
+
// * MDE version: 9.3.8211.
|
|
12
|
+
// * Package version: 1.0.98
|
|
13
|
+
// * Date/time: 23 Jun 2026 12:11:11.
|
|
14
|
+
// * Template: TYPE_SCRIPT_PWS/calculations.sbn.
|
|
15
|
+
// *
|
|
16
|
+
// ************************************************************************************
|
|
13
17
|
|
|
14
18
|
import * as Enums from '../enums';
|
|
15
19
|
import * as Entities from '../entities';
|
|
@@ -78,7 +82,7 @@ export class BESSConfidenceIntervalEnergyScalingCalculation extends CalculationB
|
|
|
78
82
|
kLower?: number;
|
|
79
83
|
|
|
80
84
|
/**
|
|
81
|
-
*
|
|
85
|
+
* Calculates scaling values for the energy which correspond to the specified confidence interval for the toxic mass. The battery chemistry gives us a specific data set for which the best-fit of toxic mass / unit energy is calculated. There will be some degree of scatter around this fit and a user-specified confidence interval can be calculated giving the range of toxic masses for a known energy. This interval can also be represented by scaling values for the energy. This will give upper and lower energy values which for this chemistry will give toxic masses corresponding to the confidence interval.
|
|
82
86
|
*
|
|
83
87
|
*/
|
|
84
88
|
constructor(data: { chemistry: number; confidenceInterval: number; controller?: AbortController }) {
|
|
@@ -233,46 +237,237 @@ export class BESSConfidenceIntervalEnergyScalingCalculationResponseSchema {
|
|
|
233
237
|
}
|
|
234
238
|
}
|
|
235
239
|
|
|
236
|
-
export interface
|
|
240
|
+
export interface BESSDefaultOffgasMaterialCalculationRequestSchemaData {
|
|
241
|
+
bessChemistry: Enums.BESSChemistry;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
class BESSDefaultOffgasMaterialCalculationRequest extends CalculationRequestBase {
|
|
245
|
+
bessChemistry: Enums.BESSChemistry;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* BESSDefaultOffgasMaterial calculation request class.
|
|
249
|
+
*
|
|
250
|
+
*/
|
|
251
|
+
constructor(data: { bessChemistry: Enums.BESSChemistry }) {
|
|
252
|
+
super();
|
|
253
|
+
this.bessChemistry = data.bessChemistry;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export class BESSDefaultOffgasMaterialCalculationRequestSchema {
|
|
258
|
+
schema: Joi.ObjectSchema;
|
|
259
|
+
propertyTypes: Record<string, string>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Schema for the BESSDefaultOffgasMaterial calculation request.
|
|
263
|
+
*/
|
|
264
|
+
constructor() {
|
|
265
|
+
this.schema = Joi.object({
|
|
266
|
+
bessChemistry: Joi.string().valid(...Object.values(Enums.BESSChemistry)),
|
|
267
|
+
}).unknown(true);
|
|
268
|
+
|
|
269
|
+
this.propertyTypes = {
|
|
270
|
+
bessChemistry: 'Enums.BESSChemistry',
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
validate(data: BESSDefaultOffgasMaterialCalculationRequestSchemaData): BESSDefaultOffgasMaterialCalculationRequest {
|
|
275
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
276
|
+
if (error) {
|
|
277
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
278
|
+
}
|
|
279
|
+
return this.makeCalculationRequest(value);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
makeCalculationRequest(data: BESSDefaultOffgasMaterialCalculationRequestSchemaData): BESSDefaultOffgasMaterialCalculationRequest {
|
|
283
|
+
return new BESSDefaultOffgasMaterialCalculationRequest(data);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export class BESSDefaultOffgasMaterialCalculation extends CalculationBase {
|
|
288
|
+
bessChemistry: Enums.BESSChemistry;
|
|
289
|
+
defaultMaterial?: Entities.Material;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Returns the default material for the BESS unit based on battery chemistry. Where the user does not have a specific composition, we can provide a suitable material as default based on battery chemistry.
|
|
293
|
+
*
|
|
294
|
+
*/
|
|
295
|
+
constructor(data: { bessChemistry: Enums.BESSChemistry; controller?: AbortController }) {
|
|
296
|
+
super(data.controller);
|
|
297
|
+
this.bessChemistry = data.bessChemistry;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async run() {
|
|
301
|
+
try {
|
|
302
|
+
const request = new BESSDefaultOffgasMaterialCalculationRequest({
|
|
303
|
+
bessChemistry: this.bessChemistry,
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
const schema = new BESSDefaultOffgasMaterialCalculationRequestSchema();
|
|
307
|
+
const validatedRequest = schema.validate(request);
|
|
308
|
+
|
|
309
|
+
const requestJson = JSON.stringify(validatedRequest);
|
|
310
|
+
const url = `${getAnalyticsApiTarget()}calculatebessdefaultoffgasmaterial?clientId=${getClientAliasId()}`;
|
|
311
|
+
|
|
312
|
+
this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
|
|
313
|
+
|
|
314
|
+
const { data } = await this.postRequest(url, requestJson);
|
|
315
|
+
|
|
316
|
+
const responseSchema = new BESSDefaultOffgasMaterialCalculationResponseSchema();
|
|
317
|
+
const validatedResponse = responseSchema.validate(data);
|
|
318
|
+
|
|
319
|
+
this.resultCode = validatedResponse.resultCode;
|
|
320
|
+
if (this.resultCode === Enums.ResultCode.SUCCESS) {
|
|
321
|
+
Object.assign(this, {
|
|
322
|
+
defaultMaterial: validatedResponse.defaultMaterial,
|
|
323
|
+
resultCode: validatedResponse.resultCode,
|
|
324
|
+
messages: validatedResponse.messages ?? [],
|
|
325
|
+
calculationElapsedTime: validatedResponse.calculationElapsedTime,
|
|
326
|
+
operationId: validatedResponse.operationId,
|
|
327
|
+
});
|
|
328
|
+
} else {
|
|
329
|
+
this.messages.push(...(validatedResponse.messages ?? []));
|
|
330
|
+
}
|
|
331
|
+
} catch (err: any) {
|
|
332
|
+
if ((err as any)?.response) {
|
|
333
|
+
this.handleFailedResponse((err as any).response);
|
|
334
|
+
} else {
|
|
335
|
+
throw err;
|
|
336
|
+
}
|
|
337
|
+
console.error(err);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return this.resultCode;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
toString() {
|
|
344
|
+
const parts = ['* BESSDefaultOffgasMaterial'];
|
|
345
|
+
|
|
346
|
+
parts.push(`defaultMaterial: ${String(this.defaultMaterial)}`);
|
|
347
|
+
parts.push(`resultCode: ${String(this.resultCode)}`);
|
|
348
|
+
parts.push('*** messages:');
|
|
349
|
+
parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
|
|
350
|
+
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
|
|
351
|
+
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
|
|
352
|
+
|
|
353
|
+
return parts.join('\n');
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export class BESSDefaultOffgasMaterialCalculationResponse extends CalculationResponseBase {
|
|
358
|
+
defaultMaterial: Entities.Material;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* BESSDefaultOffgasMaterial calculation response class.
|
|
362
|
+
*
|
|
363
|
+
*/
|
|
364
|
+
constructor(data: { defaultMaterial: Entities.Material; resultCode: Enums.ResultCode; messages: string[]; calculationElapsedTime: number; operationId: string }) {
|
|
365
|
+
super();
|
|
366
|
+
this.defaultMaterial = data.defaultMaterial;
|
|
367
|
+
this.resultCode = data.resultCode;
|
|
368
|
+
this.messages = data.messages;
|
|
369
|
+
this.calculationElapsedTime = data.calculationElapsedTime;
|
|
370
|
+
this.operationId = data.operationId;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
initialiseFromDictionary(data: { [key: string]: unknown }) {
|
|
374
|
+
if (data.defaultMaterial) {
|
|
375
|
+
this.defaultMaterial = new Entities.Material();
|
|
376
|
+
this.defaultMaterial.initialiseFromDictionary(data.defaultMaterial as { [key: string]: unknown });
|
|
377
|
+
}
|
|
378
|
+
if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
|
|
379
|
+
this.resultCode = data.resultCode as Enums.ResultCode;
|
|
380
|
+
}
|
|
381
|
+
this.messages = this.messages ?? [];
|
|
382
|
+
if (data.messages && Array.isArray(data.messages)) {
|
|
383
|
+
this.messages.push(...data.messages);
|
|
384
|
+
}
|
|
385
|
+
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
|
|
386
|
+
this.calculationElapsedTime = data.calculationElapsedTime as number;
|
|
387
|
+
}
|
|
388
|
+
if (data.operationId !== undefined && typeof data.operationId === 'string') {
|
|
389
|
+
this.operationId = data.operationId as string;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export interface BESSDefaultOffgasMaterialCalculationResponseSchemaData {
|
|
395
|
+
defaultMaterial: Entities.Material;
|
|
396
|
+
resultCode: Enums.ResultCode;
|
|
397
|
+
messages: string[];
|
|
398
|
+
calculationElapsedTime: number;
|
|
399
|
+
operationId: string;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export class BESSDefaultOffgasMaterialCalculationResponseSchema {
|
|
403
|
+
schema: Joi.ObjectSchema;
|
|
404
|
+
propertyTypes: Record<string, string>;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Schema for the BESSDefaultOffgasMaterial calculation response.
|
|
408
|
+
*/
|
|
409
|
+
constructor() {
|
|
410
|
+
this.schema = Joi.object({
|
|
411
|
+
defaultMaterial: new EntitySchemas.MaterialSchema().schema,
|
|
412
|
+
resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
|
|
413
|
+
messages: Joi.array().items(Joi.string()),
|
|
414
|
+
calculationElapsedTime: Joi.number().unsafe(),
|
|
415
|
+
operationId: Joi.string().uuid().allow(null),
|
|
416
|
+
}).unknown(true);
|
|
417
|
+
|
|
418
|
+
this.propertyTypes = {
|
|
419
|
+
defaultMaterial: 'Entities.Material',
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
validate(data: BESSDefaultOffgasMaterialCalculationResponseSchemaData): BESSDefaultOffgasMaterialCalculationResponse {
|
|
424
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
425
|
+
if (error) {
|
|
426
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
427
|
+
}
|
|
428
|
+
return this.makeCalculationResponse(value);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
makeCalculationResponse(data: BESSDefaultOffgasMaterialCalculationResponseSchemaData): BESSDefaultOffgasMaterialCalculationResponse {
|
|
432
|
+
return new BESSDefaultOffgasMaterialCalculationResponse(data);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface BESSDefaultSmokeMaterialCalculationRequestSchemaData {
|
|
237
437
|
bessUnit: Entities.BESSUnit;
|
|
238
|
-
bessRelease: Entities.BESSRelease;
|
|
239
438
|
}
|
|
240
439
|
|
|
241
|
-
class
|
|
440
|
+
class BESSDefaultSmokeMaterialCalculationRequest extends CalculationRequestBase {
|
|
242
441
|
bessUnit: Entities.BESSUnit;
|
|
243
|
-
bessRelease: Entities.BESSRelease;
|
|
244
442
|
|
|
245
443
|
/**
|
|
246
|
-
*
|
|
444
|
+
* BESSDefaultSmokeMaterial calculation request class.
|
|
247
445
|
*
|
|
248
446
|
*/
|
|
249
|
-
constructor(data: { bessUnit: Entities.BESSUnit
|
|
447
|
+
constructor(data: { bessUnit: Entities.BESSUnit }) {
|
|
250
448
|
super();
|
|
251
449
|
this.bessUnit = data.bessUnit;
|
|
252
|
-
this.bessRelease = data.bessRelease;
|
|
253
450
|
}
|
|
254
451
|
}
|
|
255
452
|
|
|
256
|
-
export class
|
|
453
|
+
export class BESSDefaultSmokeMaterialCalculationRequestSchema {
|
|
257
454
|
schema: Joi.ObjectSchema;
|
|
258
455
|
propertyTypes: Record<string, string>;
|
|
259
456
|
|
|
260
457
|
/**
|
|
261
|
-
* Schema for the
|
|
458
|
+
* Schema for the BESSDefaultSmokeMaterial calculation request.
|
|
262
459
|
*/
|
|
263
460
|
constructor() {
|
|
264
461
|
this.schema = Joi.object({
|
|
265
462
|
bessUnit: new EntitySchemas.BESSUnitSchema().schema,
|
|
266
|
-
bessRelease: new EntitySchemas.BESSReleaseSchema().schema,
|
|
267
463
|
}).unknown(true);
|
|
268
464
|
|
|
269
465
|
this.propertyTypes = {
|
|
270
466
|
bessUnit: 'Entities.BESSUnit',
|
|
271
|
-
bessRelease: 'Entities.BESSRelease',
|
|
272
467
|
};
|
|
273
468
|
}
|
|
274
469
|
|
|
275
|
-
validate(data:
|
|
470
|
+
validate(data: BESSDefaultSmokeMaterialCalculationRequestSchemaData): BESSDefaultSmokeMaterialCalculationRequest {
|
|
276
471
|
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
277
472
|
if (error) {
|
|
278
473
|
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
@@ -280,54 +475,47 @@ export class BESSToxicSourceCalculationRequestSchema {
|
|
|
280
475
|
return this.makeCalculationRequest(value);
|
|
281
476
|
}
|
|
282
477
|
|
|
283
|
-
makeCalculationRequest(data:
|
|
284
|
-
return new
|
|
478
|
+
makeCalculationRequest(data: BESSDefaultSmokeMaterialCalculationRequestSchemaData): BESSDefaultSmokeMaterialCalculationRequest {
|
|
479
|
+
return new BESSDefaultSmokeMaterialCalculationRequest(data);
|
|
285
480
|
}
|
|
286
481
|
}
|
|
287
482
|
|
|
288
|
-
export class
|
|
483
|
+
export class BESSDefaultSmokeMaterialCalculation extends CalculationBase {
|
|
289
484
|
bessUnit: Entities.BESSUnit;
|
|
290
|
-
|
|
291
|
-
bessMaterial?: Entities.Material;
|
|
292
|
-
dischargeResult?: Entities.DischargeResult;
|
|
293
|
-
dischargeRecords?: Entities.DischargeRecord[];
|
|
485
|
+
material?: Entities.Material;
|
|
294
486
|
|
|
295
487
|
/**
|
|
296
|
-
*
|
|
488
|
+
* Returns the default smoke material for the BESS unit based on battery chemistry and energy capacity. HF content is defined from an internal calculation and combined with estimated combustion products to define the material.
|
|
297
489
|
*
|
|
298
490
|
*/
|
|
299
|
-
constructor(data: { bessUnit: Entities.BESSUnit;
|
|
491
|
+
constructor(data: { bessUnit: Entities.BESSUnit; controller?: AbortController }) {
|
|
300
492
|
super(data.controller);
|
|
301
493
|
this.bessUnit = data.bessUnit;
|
|
302
|
-
this.bessRelease = data.bessRelease;
|
|
303
494
|
}
|
|
304
495
|
|
|
305
496
|
async run() {
|
|
306
497
|
try {
|
|
307
|
-
const request = new
|
|
498
|
+
const request = new BESSDefaultSmokeMaterialCalculationRequest({
|
|
308
499
|
bessUnit: this.bessUnit,
|
|
309
|
-
bessRelease: this.bessRelease,
|
|
310
500
|
});
|
|
311
501
|
|
|
312
|
-
const schema = new
|
|
502
|
+
const schema = new BESSDefaultSmokeMaterialCalculationRequestSchema();
|
|
313
503
|
const validatedRequest = schema.validate(request);
|
|
314
504
|
|
|
315
505
|
const requestJson = JSON.stringify(validatedRequest);
|
|
316
|
-
const url = `${getAnalyticsApiTarget()}
|
|
506
|
+
const url = `${getAnalyticsApiTarget()}calculatebessdefaultsmokematerial?clientId=${getClientAliasId()}`;
|
|
317
507
|
|
|
318
508
|
this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
|
|
319
509
|
|
|
320
510
|
const { data } = await this.postRequest(url, requestJson);
|
|
321
511
|
|
|
322
|
-
const responseSchema = new
|
|
512
|
+
const responseSchema = new BESSDefaultSmokeMaterialCalculationResponseSchema();
|
|
323
513
|
const validatedResponse = responseSchema.validate(data);
|
|
324
514
|
|
|
325
515
|
this.resultCode = validatedResponse.resultCode;
|
|
326
516
|
if (this.resultCode === Enums.ResultCode.SUCCESS) {
|
|
327
517
|
Object.assign(this, {
|
|
328
|
-
|
|
329
|
-
dischargeResult: validatedResponse.dischargeResult,
|
|
330
|
-
dischargeRecords: validatedResponse.dischargeRecords,
|
|
518
|
+
material: validatedResponse.material,
|
|
331
519
|
resultCode: validatedResponse.resultCode,
|
|
332
520
|
messages: validatedResponse.messages ?? [],
|
|
333
521
|
calculationElapsedTime: validatedResponse.calculationElapsedTime,
|
|
@@ -349,16 +537,9 @@ export class BESSToxicSourceCalculation extends CalculationBase {
|
|
|
349
537
|
}
|
|
350
538
|
|
|
351
539
|
toString() {
|
|
352
|
-
const parts = ['*
|
|
540
|
+
const parts = ['* BESSDefaultSmokeMaterial'];
|
|
353
541
|
|
|
354
|
-
parts.push(`
|
|
355
|
-
parts.push(`dischargeResult: ${String(this.dischargeResult)}`);
|
|
356
|
-
parts.push('*** dischargeRecords:');
|
|
357
|
-
parts.push(
|
|
358
|
-
this.dischargeRecords && this.dischargeRecords.length > 0
|
|
359
|
-
? this.dischargeRecords.map((point) => `dischargeRecordsElement: ${point}`).join('\n')
|
|
360
|
-
: 'dischargeRecords does not contain any elements',
|
|
361
|
-
);
|
|
542
|
+
parts.push(`material: ${String(this.material)}`);
|
|
362
543
|
parts.push(`resultCode: ${String(this.resultCode)}`);
|
|
363
544
|
parts.push('*** messages:');
|
|
364
545
|
parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
|
|
@@ -369,28 +550,16 @@ export class BESSToxicSourceCalculation extends CalculationBase {
|
|
|
369
550
|
}
|
|
370
551
|
}
|
|
371
552
|
|
|
372
|
-
export class
|
|
373
|
-
|
|
374
|
-
dischargeResult: Entities.DischargeResult;
|
|
375
|
-
dischargeRecords: Entities.DischargeRecord[];
|
|
553
|
+
export class BESSDefaultSmokeMaterialCalculationResponse extends CalculationResponseBase {
|
|
554
|
+
material: Entities.Material;
|
|
376
555
|
|
|
377
556
|
/**
|
|
378
|
-
*
|
|
557
|
+
* BESSDefaultSmokeMaterial calculation response class.
|
|
379
558
|
*
|
|
380
559
|
*/
|
|
381
|
-
constructor(data: {
|
|
382
|
-
bessMaterial: Entities.Material;
|
|
383
|
-
dischargeResult: Entities.DischargeResult;
|
|
384
|
-
dischargeRecords: Entities.DischargeRecord[];
|
|
385
|
-
resultCode: Enums.ResultCode;
|
|
386
|
-
messages: string[];
|
|
387
|
-
calculationElapsedTime: number;
|
|
388
|
-
operationId: string;
|
|
389
|
-
}) {
|
|
560
|
+
constructor(data: { material: Entities.Material; resultCode: Enums.ResultCode; messages: string[]; calculationElapsedTime: number; operationId: string }) {
|
|
390
561
|
super();
|
|
391
|
-
this.
|
|
392
|
-
this.dischargeResult = data.dischargeResult;
|
|
393
|
-
this.dischargeRecords = data.dischargeRecords;
|
|
562
|
+
this.material = data.material;
|
|
394
563
|
this.resultCode = data.resultCode;
|
|
395
564
|
this.messages = data.messages;
|
|
396
565
|
this.calculationElapsedTime = data.calculationElapsedTime;
|
|
@@ -398,20 +567,9 @@ export class BESSToxicSourceCalculationResponse extends CalculationResponseBase
|
|
|
398
567
|
}
|
|
399
568
|
|
|
400
569
|
initialiseFromDictionary(data: { [key: string]: unknown }) {
|
|
401
|
-
if (data.
|
|
402
|
-
this.
|
|
403
|
-
this.
|
|
404
|
-
}
|
|
405
|
-
if (data.dischargeResult) {
|
|
406
|
-
this.dischargeResult = new Entities.DischargeResult();
|
|
407
|
-
this.dischargeResult.initialiseFromDictionary(data.dischargeResult as { [key: string]: unknown });
|
|
408
|
-
}
|
|
409
|
-
if (data.dischargeRecords && Array.isArray(data.dischargeRecords)) {
|
|
410
|
-
this.dischargeRecords = data.dischargeRecords.map((item) => {
|
|
411
|
-
const record = new Entities.DischargeRecord();
|
|
412
|
-
record.initialiseFromDictionary(item);
|
|
413
|
-
return record;
|
|
414
|
-
});
|
|
570
|
+
if (data.material) {
|
|
571
|
+
this.material = new Entities.Material();
|
|
572
|
+
this.material.initialiseFromDictionary(data.material as { [key: string]: unknown });
|
|
415
573
|
}
|
|
416
574
|
if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
|
|
417
575
|
this.resultCode = data.resultCode as Enums.ResultCode;
|
|
@@ -429,28 +587,24 @@ export class BESSToxicSourceCalculationResponse extends CalculationResponseBase
|
|
|
429
587
|
}
|
|
430
588
|
}
|
|
431
589
|
|
|
432
|
-
export interface
|
|
433
|
-
|
|
434
|
-
dischargeResult: Entities.DischargeResult;
|
|
435
|
-
dischargeRecords: Entities.DischargeRecord[];
|
|
590
|
+
export interface BESSDefaultSmokeMaterialCalculationResponseSchemaData {
|
|
591
|
+
material: Entities.Material;
|
|
436
592
|
resultCode: Enums.ResultCode;
|
|
437
593
|
messages: string[];
|
|
438
594
|
calculationElapsedTime: number;
|
|
439
595
|
operationId: string;
|
|
440
596
|
}
|
|
441
597
|
|
|
442
|
-
export class
|
|
598
|
+
export class BESSDefaultSmokeMaterialCalculationResponseSchema {
|
|
443
599
|
schema: Joi.ObjectSchema;
|
|
444
600
|
propertyTypes: Record<string, string>;
|
|
445
601
|
|
|
446
602
|
/**
|
|
447
|
-
* Schema for the
|
|
603
|
+
* Schema for the BESSDefaultSmokeMaterial calculation response.
|
|
448
604
|
*/
|
|
449
605
|
constructor() {
|
|
450
606
|
this.schema = Joi.object({
|
|
451
|
-
|
|
452
|
-
dischargeResult: new EntitySchemas.DischargeResultSchema().schema,
|
|
453
|
-
dischargeRecords: Joi.array().items(new EntitySchemas.DischargeRecordSchema().schema).allow(null),
|
|
607
|
+
material: new EntitySchemas.MaterialSchema().schema,
|
|
454
608
|
resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
|
|
455
609
|
messages: Joi.array().items(Joi.string()),
|
|
456
610
|
calculationElapsedTime: Joi.number().unsafe(),
|
|
@@ -458,13 +612,11 @@ export class BESSToxicSourceCalculationResponseSchema {
|
|
|
458
612
|
}).unknown(true);
|
|
459
613
|
|
|
460
614
|
this.propertyTypes = {
|
|
461
|
-
|
|
462
|
-
dischargeResult: 'Entities.DischargeResult',
|
|
463
|
-
dischargeRecords: 'Entities.DischargeRecord[]',
|
|
615
|
+
material: 'Entities.Material',
|
|
464
616
|
};
|
|
465
617
|
}
|
|
466
618
|
|
|
467
|
-
validate(data:
|
|
619
|
+
validate(data: BESSDefaultSmokeMaterialCalculationResponseSchemaData): BESSDefaultSmokeMaterialCalculationResponse {
|
|
468
620
|
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
469
621
|
if (error) {
|
|
470
622
|
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
@@ -472,8 +624,8 @@ export class BESSToxicSourceCalculationResponseSchema {
|
|
|
472
624
|
return this.makeCalculationResponse(value);
|
|
473
625
|
}
|
|
474
626
|
|
|
475
|
-
makeCalculationResponse(data:
|
|
476
|
-
return new
|
|
627
|
+
makeCalculationResponse(data: BESSDefaultSmokeMaterialCalculationResponseSchemaData): BESSDefaultSmokeMaterialCalculationResponse {
|
|
628
|
+
return new BESSDefaultSmokeMaterialCalculationResponse(data);
|
|
477
629
|
}
|
|
478
630
|
}
|
|
479
631
|
|
|
@@ -543,10 +695,7 @@ export class LongPipeBreachCalculation extends CalculationBase {
|
|
|
543
695
|
dischargeRecords?: Entities.DischargeRecord[];
|
|
544
696
|
|
|
545
697
|
/**
|
|
546
|
-
* Calculates the time-varying release from a breach (full bore or partial) in a long pipeline. Currently restricted to gas pipelines only. The release combines the outflow from the branches upstream and downstream of the breach. Valves can be specified along the pipe length. The release stops once the pipe has depressurised. The discharge mass, temperature, and other outputs are reported back as discharge records.
|
|
547
|
-
\remark Pressure as part of the state defined in pipe entity is in absolute units, this is to align with other uses of the
|
|
548
|
-
state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for
|
|
549
|
-
flash calculation, etc.
|
|
698
|
+
* Calculates the time-varying release from a breach (full bore or partial) in a long pipeline. Currently restricted to gas pipelines only. The release combines the outflow from the branches upstream and downstream of the breach. Valves can be specified along the pipe length. The release stops once the pipe has depressurised. The discharge mass, temperature, and other outputs are reported back as discharge records. * Note: Pressure as part of the state defined in pipe entity is in absolute units, which is to align with other uses of the state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for flash calculation, etc.
|
|
550
699
|
*
|
|
551
700
|
*/
|
|
552
701
|
constructor(data: { pipe: Entities.Pipe; pipeBreach: Entities.PipeBreach; dischargeParameters: Entities.DischargeParameters; controller?: AbortController }) {
|
|
@@ -792,7 +941,7 @@ export class VesselCatastrophicRuptureCalculation extends CalculationBase {
|
|
|
792
941
|
dischargeRecords?: Entities.DischargeRecord[];
|
|
793
942
|
|
|
794
943
|
/**
|
|
795
|
-
* Calculates the instantaneous release from a pressure vessel or storage tank. It includes expansion modelling to atmospheric conditions. The discharge mass, temperature, and other outputs are reported back as discharge records. The height of the release is located at the midpoint of the vessel.
|
|
944
|
+
* Calculates the instantaneous release from a pressure vessel or storage tank. It includes expansion modelling to atmospheric conditions. The discharge mass, temperature, and other outputs are reported back as discharge records. The height of the release is located at the midpoint of the vessel * Note: Pressure as part of the state defined in vessel entity is in absolute units, this is to align with other uses of the state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for flash calculation, etc.
|
|
796
945
|
*
|
|
797
946
|
*/
|
|
798
947
|
constructor(data: { vessel: Entities.Vessel; dischargeParameters: Entities.DischargeParameters; controller?: AbortController }) {
|
|
@@ -1042,7 +1191,7 @@ export class VesselLeakCalculation extends CalculationBase {
|
|
|
1042
1191
|
dischargeRecords?: Entities.DischargeRecord[];
|
|
1043
1192
|
|
|
1044
1193
|
/**
|
|
1045
|
-
* Calculates the steady state or time-varying leak from a pressure vessel or storage tank. It includes expansion modelling (from the vessel orifice to atmospheric conditions). The discharge rate, temperature, and other time-dependent outputs at a particular time are reported back as discharge records. For steady-state there are always two DischargeRecords generated; for time-varying the number can vary.
|
|
1194
|
+
* Calculates the steady state or time-varying leak from a pressure vessel or storage tank. It includes expansion modelling (from the vessel orifice to atmospheric conditions). The discharge rate, temperature, and other time-dependent outputs at a particular time are reported back as discharge records. For steady-state there are always two DischargeRecords generated; for time-varying the number can vary. * Note: Pressure as part of the state defined in vessel entity is in absolute units, this is to align with other uses of the state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for flash calculation, etc.
|
|
1046
1195
|
*
|
|
1047
1196
|
*/
|
|
1048
1197
|
constructor(data: { vessel: Entities.Vessel; leak: Entities.Leak; dischargeParameters: Entities.DischargeParameters; controller?: AbortController }) {
|
|
@@ -1294,7 +1443,7 @@ export class VesselLineRuptureCalculation extends CalculationBase {
|
|
|
1294
1443
|
dischargeRecords?: Entities.DischargeRecord[];
|
|
1295
1444
|
|
|
1296
1445
|
/**
|
|
1297
|
-
*
|
|
1446
|
+
* Calculates the steady state or time-varying rupture of a short pipe attached to a pressure vessel or storage tank. It includes expansion modelling (pressure drop along the pipe and to atmospheric conditions). The discharge rate, temperature, and other time-dependent outputs at a particular time are reported back as discharge records. For steady-state there are always two DischargeRecords generated; for time-varying the number can vary. * Note: Pressure as part of the state defined in vessel entity is in absolute units, this is to align with other uses of the state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for flash calculation, etc.
|
|
1298
1447
|
*
|
|
1299
1448
|
*/
|
|
1300
1449
|
constructor(data: { vessel: Entities.Vessel; lineRupture: Entities.LineRupture; dischargeParameters: Entities.DischargeParameters; controller?: AbortController }) {
|
|
@@ -1546,7 +1695,7 @@ export class VesselReliefValveCalculation extends CalculationBase {
|
|
|
1546
1695
|
dischargeRecords?: Entities.DischargeRecord[];
|
|
1547
1696
|
|
|
1548
1697
|
/**
|
|
1549
|
-
*
|
|
1698
|
+
* Calculates the steady state or time-varying rupture of a relief valve attached to a pressure vessel or storage tank. It includes expansion modelling (pressure drop along the pipe and to atmospheric conditions). The discharge rate, temperature, and other time-dependent outputs at a particular time are reported back as discharge records. For steady-state there are always two DischargeRecords generated; for time-varying the number can vary. * Note: Pressure as part of the state defined in vessel entity is in absolute units, this is to align with other uses of the state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for flash calculation, etc.
|
|
1550
1699
|
*
|
|
1551
1700
|
*/
|
|
1552
1701
|
constructor(data: { vessel: Entities.Vessel; reliefValve: Entities.ReliefValve; dischargeParameters: Entities.DischargeParameters; controller?: AbortController }) {
|
|
@@ -1732,6 +1881,502 @@ export class VesselReliefValveCalculationResponseSchema {
|
|
|
1732
1881
|
}
|
|
1733
1882
|
}
|
|
1734
1883
|
|
|
1884
|
+
export interface VesselSphereCatastrophicRuptureCalculationRequestSchemaData {
|
|
1885
|
+
vesselSphere: Entities.VesselSphere;
|
|
1886
|
+
dischargeParameters: Entities.DischargeParameters;
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
class VesselSphereCatastrophicRuptureCalculationRequest extends CalculationRequestBase {
|
|
1890
|
+
vesselSphere: Entities.VesselSphere;
|
|
1891
|
+
dischargeParameters: Entities.DischargeParameters;
|
|
1892
|
+
|
|
1893
|
+
/**
|
|
1894
|
+
* VesselSphereCatastrophicRupture calculation request class.
|
|
1895
|
+
*
|
|
1896
|
+
*/
|
|
1897
|
+
constructor(data: { vesselSphere: Entities.VesselSphere; dischargeParameters: Entities.DischargeParameters }) {
|
|
1898
|
+
super();
|
|
1899
|
+
this.vesselSphere = data.vesselSphere;
|
|
1900
|
+
this.dischargeParameters = data.dischargeParameters;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
export class VesselSphereCatastrophicRuptureCalculationRequestSchema {
|
|
1905
|
+
schema: Joi.ObjectSchema;
|
|
1906
|
+
propertyTypes: Record<string, string>;
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* Schema for the VesselSphereCatastrophicRupture calculation request.
|
|
1910
|
+
*/
|
|
1911
|
+
constructor() {
|
|
1912
|
+
this.schema = Joi.object({
|
|
1913
|
+
vesselSphere: new EntitySchemas.VesselSphereSchema().schema,
|
|
1914
|
+
dischargeParameters: new EntitySchemas.DischargeParametersSchema().schema,
|
|
1915
|
+
}).unknown(true);
|
|
1916
|
+
|
|
1917
|
+
this.propertyTypes = {
|
|
1918
|
+
vesselSphere: 'Entities.VesselSphere',
|
|
1919
|
+
dischargeParameters: 'Entities.DischargeParameters',
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
validate(data: VesselSphereCatastrophicRuptureCalculationRequestSchemaData): VesselSphereCatastrophicRuptureCalculationRequest {
|
|
1924
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
1925
|
+
if (error) {
|
|
1926
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
1927
|
+
}
|
|
1928
|
+
return this.makeCalculationRequest(value);
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
makeCalculationRequest(data: VesselSphereCatastrophicRuptureCalculationRequestSchemaData): VesselSphereCatastrophicRuptureCalculationRequest {
|
|
1932
|
+
return new VesselSphereCatastrophicRuptureCalculationRequest(data);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
export class VesselSphereCatastrophicRuptureCalculation extends CalculationBase {
|
|
1937
|
+
vesselSphere: Entities.VesselSphere;
|
|
1938
|
+
dischargeParameters: Entities.DischargeParameters;
|
|
1939
|
+
exitMaterial?: Entities.Material;
|
|
1940
|
+
dischargeResult?: Entities.DischargeResult;
|
|
1941
|
+
dischargeRecords?: Entities.DischargeRecord[];
|
|
1942
|
+
|
|
1943
|
+
/**
|
|
1944
|
+
* Calculates the instantaneous release from a spherical vessel. It includes expansion modelling to atmospheric conditions. The discharge mass, temperature, and other outputs are reported back as discharge records. The height of the release is located at the midpoint of the vessel * Note: Pressure as part of the state defined in vessel entity is in absolute units, this is to align with other uses of the state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for flash calculation, etc.
|
|
1945
|
+
*
|
|
1946
|
+
*/
|
|
1947
|
+
constructor(data: { vesselSphere: Entities.VesselSphere; dischargeParameters: Entities.DischargeParameters; controller?: AbortController }) {
|
|
1948
|
+
super(data.controller);
|
|
1949
|
+
this.vesselSphere = data.vesselSphere;
|
|
1950
|
+
this.dischargeParameters = data.dischargeParameters;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
async run() {
|
|
1954
|
+
try {
|
|
1955
|
+
const request = new VesselSphereCatastrophicRuptureCalculationRequest({
|
|
1956
|
+
vesselSphere: this.vesselSphere,
|
|
1957
|
+
dischargeParameters: this.dischargeParameters,
|
|
1958
|
+
});
|
|
1959
|
+
|
|
1960
|
+
const schema = new VesselSphereCatastrophicRuptureCalculationRequestSchema();
|
|
1961
|
+
const validatedRequest = schema.validate(request);
|
|
1962
|
+
|
|
1963
|
+
const requestJson = JSON.stringify(validatedRequest);
|
|
1964
|
+
const url = `${getAnalyticsApiTarget()}calculatevesselspherecatastrophicrupture?clientId=${getClientAliasId()}`;
|
|
1965
|
+
|
|
1966
|
+
this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
|
|
1967
|
+
|
|
1968
|
+
const { data } = await this.postRequest(url, requestJson);
|
|
1969
|
+
|
|
1970
|
+
const responseSchema = new VesselSphereCatastrophicRuptureCalculationResponseSchema();
|
|
1971
|
+
const validatedResponse = responseSchema.validate(data);
|
|
1972
|
+
|
|
1973
|
+
this.resultCode = validatedResponse.resultCode;
|
|
1974
|
+
if (this.resultCode === Enums.ResultCode.SUCCESS) {
|
|
1975
|
+
Object.assign(this, {
|
|
1976
|
+
exitMaterial: validatedResponse.exitMaterial,
|
|
1977
|
+
dischargeResult: validatedResponse.dischargeResult,
|
|
1978
|
+
dischargeRecords: validatedResponse.dischargeRecords,
|
|
1979
|
+
resultCode: validatedResponse.resultCode,
|
|
1980
|
+
messages: validatedResponse.messages ?? [],
|
|
1981
|
+
calculationElapsedTime: validatedResponse.calculationElapsedTime,
|
|
1982
|
+
operationId: validatedResponse.operationId,
|
|
1983
|
+
});
|
|
1984
|
+
} else {
|
|
1985
|
+
this.messages.push(...(validatedResponse.messages ?? []));
|
|
1986
|
+
}
|
|
1987
|
+
} catch (err: any) {
|
|
1988
|
+
if ((err as any)?.response) {
|
|
1989
|
+
this.handleFailedResponse((err as any).response);
|
|
1990
|
+
} else {
|
|
1991
|
+
throw err;
|
|
1992
|
+
}
|
|
1993
|
+
console.error(err);
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
return this.resultCode;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
toString() {
|
|
2000
|
+
const parts = ['* VesselSphereCatastrophicRupture'];
|
|
2001
|
+
|
|
2002
|
+
parts.push(`exitMaterial: ${String(this.exitMaterial)}`);
|
|
2003
|
+
parts.push(`dischargeResult: ${String(this.dischargeResult)}`);
|
|
2004
|
+
parts.push('*** dischargeRecords:');
|
|
2005
|
+
parts.push(
|
|
2006
|
+
this.dischargeRecords && this.dischargeRecords.length > 0
|
|
2007
|
+
? this.dischargeRecords.map((point) => `dischargeRecordsElement: ${point}`).join('\n')
|
|
2008
|
+
: 'dischargeRecords does not contain any elements',
|
|
2009
|
+
);
|
|
2010
|
+
parts.push(`resultCode: ${String(this.resultCode)}`);
|
|
2011
|
+
parts.push('*** messages:');
|
|
2012
|
+
parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
|
|
2013
|
+
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
|
|
2014
|
+
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
|
|
2015
|
+
|
|
2016
|
+
return parts.join('\n');
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
export class VesselSphereCatastrophicRuptureCalculationResponse extends CalculationResponseBase {
|
|
2021
|
+
exitMaterial: Entities.Material;
|
|
2022
|
+
dischargeResult: Entities.DischargeResult;
|
|
2023
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
2024
|
+
|
|
2025
|
+
/**
|
|
2026
|
+
* VesselSphereCatastrophicRupture calculation response class.
|
|
2027
|
+
*
|
|
2028
|
+
*/
|
|
2029
|
+
constructor(data: {
|
|
2030
|
+
exitMaterial: Entities.Material;
|
|
2031
|
+
dischargeResult: Entities.DischargeResult;
|
|
2032
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
2033
|
+
resultCode: Enums.ResultCode;
|
|
2034
|
+
messages: string[];
|
|
2035
|
+
calculationElapsedTime: number;
|
|
2036
|
+
operationId: string;
|
|
2037
|
+
}) {
|
|
2038
|
+
super();
|
|
2039
|
+
this.exitMaterial = data.exitMaterial;
|
|
2040
|
+
this.dischargeResult = data.dischargeResult;
|
|
2041
|
+
this.dischargeRecords = data.dischargeRecords;
|
|
2042
|
+
this.resultCode = data.resultCode;
|
|
2043
|
+
this.messages = data.messages;
|
|
2044
|
+
this.calculationElapsedTime = data.calculationElapsedTime;
|
|
2045
|
+
this.operationId = data.operationId;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
initialiseFromDictionary(data: { [key: string]: unknown }) {
|
|
2049
|
+
if (data.exitMaterial) {
|
|
2050
|
+
this.exitMaterial = new Entities.Material();
|
|
2051
|
+
this.exitMaterial.initialiseFromDictionary(data.exitMaterial as { [key: string]: unknown });
|
|
2052
|
+
}
|
|
2053
|
+
if (data.dischargeResult) {
|
|
2054
|
+
this.dischargeResult = new Entities.DischargeResult();
|
|
2055
|
+
this.dischargeResult.initialiseFromDictionary(data.dischargeResult as { [key: string]: unknown });
|
|
2056
|
+
}
|
|
2057
|
+
if (data.dischargeRecords && Array.isArray(data.dischargeRecords)) {
|
|
2058
|
+
this.dischargeRecords = data.dischargeRecords.map((item) => {
|
|
2059
|
+
const record = new Entities.DischargeRecord();
|
|
2060
|
+
record.initialiseFromDictionary(item);
|
|
2061
|
+
return record;
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
|
|
2065
|
+
this.resultCode = data.resultCode as Enums.ResultCode;
|
|
2066
|
+
}
|
|
2067
|
+
this.messages = this.messages ?? [];
|
|
2068
|
+
if (data.messages && Array.isArray(data.messages)) {
|
|
2069
|
+
this.messages.push(...data.messages);
|
|
2070
|
+
}
|
|
2071
|
+
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
|
|
2072
|
+
this.calculationElapsedTime = data.calculationElapsedTime as number;
|
|
2073
|
+
}
|
|
2074
|
+
if (data.operationId !== undefined && typeof data.operationId === 'string') {
|
|
2075
|
+
this.operationId = data.operationId as string;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
export interface VesselSphereCatastrophicRuptureCalculationResponseSchemaData {
|
|
2081
|
+
exitMaterial: Entities.Material;
|
|
2082
|
+
dischargeResult: Entities.DischargeResult;
|
|
2083
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
2084
|
+
resultCode: Enums.ResultCode;
|
|
2085
|
+
messages: string[];
|
|
2086
|
+
calculationElapsedTime: number;
|
|
2087
|
+
operationId: string;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
export class VesselSphereCatastrophicRuptureCalculationResponseSchema {
|
|
2091
|
+
schema: Joi.ObjectSchema;
|
|
2092
|
+
propertyTypes: Record<string, string>;
|
|
2093
|
+
|
|
2094
|
+
/**
|
|
2095
|
+
* Schema for the VesselSphereCatastrophicRupture calculation response.
|
|
2096
|
+
*/
|
|
2097
|
+
constructor() {
|
|
2098
|
+
this.schema = Joi.object({
|
|
2099
|
+
exitMaterial: new EntitySchemas.MaterialSchema().schema,
|
|
2100
|
+
dischargeResult: new EntitySchemas.DischargeResultSchema().schema,
|
|
2101
|
+
dischargeRecords: Joi.array().items(new EntitySchemas.DischargeRecordSchema().schema).allow(null),
|
|
2102
|
+
resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
|
|
2103
|
+
messages: Joi.array().items(Joi.string()),
|
|
2104
|
+
calculationElapsedTime: Joi.number().unsafe(),
|
|
2105
|
+
operationId: Joi.string().uuid().allow(null),
|
|
2106
|
+
}).unknown(true);
|
|
2107
|
+
|
|
2108
|
+
this.propertyTypes = {
|
|
2109
|
+
exitMaterial: 'Entities.Material',
|
|
2110
|
+
dischargeResult: 'Entities.DischargeResult',
|
|
2111
|
+
dischargeRecords: 'Entities.DischargeRecord[]',
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
validate(data: VesselSphereCatastrophicRuptureCalculationResponseSchemaData): VesselSphereCatastrophicRuptureCalculationResponse {
|
|
2116
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
2117
|
+
if (error) {
|
|
2118
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
2119
|
+
}
|
|
2120
|
+
return this.makeCalculationResponse(value);
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
makeCalculationResponse(data: VesselSphereCatastrophicRuptureCalculationResponseSchemaData): VesselSphereCatastrophicRuptureCalculationResponse {
|
|
2124
|
+
return new VesselSphereCatastrophicRuptureCalculationResponse(data);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
export interface VesselSphereLeakCalculationRequestSchemaData {
|
|
2129
|
+
vesselSphere: Entities.VesselSphere;
|
|
2130
|
+
leak: Entities.Leak;
|
|
2131
|
+
dischargeParameters: Entities.DischargeParameters;
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
class VesselSphereLeakCalculationRequest extends CalculationRequestBase {
|
|
2135
|
+
vesselSphere: Entities.VesselSphere;
|
|
2136
|
+
leak: Entities.Leak;
|
|
2137
|
+
dischargeParameters: Entities.DischargeParameters;
|
|
2138
|
+
|
|
2139
|
+
/**
|
|
2140
|
+
* VesselSphereLeak calculation request class.
|
|
2141
|
+
*
|
|
2142
|
+
*/
|
|
2143
|
+
constructor(data: { vesselSphere: Entities.VesselSphere; leak: Entities.Leak; dischargeParameters: Entities.DischargeParameters }) {
|
|
2144
|
+
super();
|
|
2145
|
+
this.vesselSphere = data.vesselSphere;
|
|
2146
|
+
this.leak = data.leak;
|
|
2147
|
+
this.dischargeParameters = data.dischargeParameters;
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
export class VesselSphereLeakCalculationRequestSchema {
|
|
2152
|
+
schema: Joi.ObjectSchema;
|
|
2153
|
+
propertyTypes: Record<string, string>;
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* Schema for the VesselSphereLeak calculation request.
|
|
2157
|
+
*/
|
|
2158
|
+
constructor() {
|
|
2159
|
+
this.schema = Joi.object({
|
|
2160
|
+
vesselSphere: new EntitySchemas.VesselSphereSchema().schema,
|
|
2161
|
+
leak: new EntitySchemas.LeakSchema().schema,
|
|
2162
|
+
dischargeParameters: new EntitySchemas.DischargeParametersSchema().schema,
|
|
2163
|
+
}).unknown(true);
|
|
2164
|
+
|
|
2165
|
+
this.propertyTypes = {
|
|
2166
|
+
vesselSphere: 'Entities.VesselSphere',
|
|
2167
|
+
leak: 'Entities.Leak',
|
|
2168
|
+
dischargeParameters: 'Entities.DischargeParameters',
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
validate(data: VesselSphereLeakCalculationRequestSchemaData): VesselSphereLeakCalculationRequest {
|
|
2173
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
2174
|
+
if (error) {
|
|
2175
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
2176
|
+
}
|
|
2177
|
+
return this.makeCalculationRequest(value);
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
makeCalculationRequest(data: VesselSphereLeakCalculationRequestSchemaData): VesselSphereLeakCalculationRequest {
|
|
2181
|
+
return new VesselSphereLeakCalculationRequest(data);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
export class VesselSphereLeakCalculation extends CalculationBase {
|
|
2186
|
+
vesselSphere: Entities.VesselSphere;
|
|
2187
|
+
leak: Entities.Leak;
|
|
2188
|
+
dischargeParameters: Entities.DischargeParameters;
|
|
2189
|
+
exitMaterial?: Entities.Material;
|
|
2190
|
+
dischargeResult?: Entities.DischargeResult;
|
|
2191
|
+
dischargeRecords?: Entities.DischargeRecord[];
|
|
2192
|
+
|
|
2193
|
+
/**
|
|
2194
|
+
* Calculates the steady state or time varying leak from a spherical vessel. It includes expansion modelling (from the vessel orifice to atmospheric conditions). The discharge rate, temperature, and other time-dependent outputs at a particular time are reported back as discharge records. For steady-state there are always two DischargeRecords generated; for time-varying the number can vary. * Note: Pressure as part of the state defined in vessel entity is in absolute units, this is to align with other uses of the state entity for which pressure gauge is not the right definition, i.e. the final state discharge, state specification for flash calculation, etc.
|
|
2195
|
+
*
|
|
2196
|
+
*/
|
|
2197
|
+
constructor(data: { vesselSphere: Entities.VesselSphere; leak: Entities.Leak; dischargeParameters: Entities.DischargeParameters; controller?: AbortController }) {
|
|
2198
|
+
super(data.controller);
|
|
2199
|
+
this.vesselSphere = data.vesselSphere;
|
|
2200
|
+
this.leak = data.leak;
|
|
2201
|
+
this.dischargeParameters = data.dischargeParameters;
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
async run() {
|
|
2205
|
+
try {
|
|
2206
|
+
const request = new VesselSphereLeakCalculationRequest({
|
|
2207
|
+
vesselSphere: this.vesselSphere,
|
|
2208
|
+
leak: this.leak,
|
|
2209
|
+
dischargeParameters: this.dischargeParameters,
|
|
2210
|
+
});
|
|
2211
|
+
|
|
2212
|
+
const schema = new VesselSphereLeakCalculationRequestSchema();
|
|
2213
|
+
const validatedRequest = schema.validate(request);
|
|
2214
|
+
|
|
2215
|
+
const requestJson = JSON.stringify(validatedRequest);
|
|
2216
|
+
const url = `${getAnalyticsApiTarget()}calculatevesselsphereleak?clientId=${getClientAliasId()}`;
|
|
2217
|
+
|
|
2218
|
+
this.resultCode = Enums.ResultCode.UNEXPECTED_APPLICATION_ERROR;
|
|
2219
|
+
|
|
2220
|
+
const { data } = await this.postRequest(url, requestJson);
|
|
2221
|
+
|
|
2222
|
+
const responseSchema = new VesselSphereLeakCalculationResponseSchema();
|
|
2223
|
+
const validatedResponse = responseSchema.validate(data);
|
|
2224
|
+
|
|
2225
|
+
this.resultCode = validatedResponse.resultCode;
|
|
2226
|
+
if (this.resultCode === Enums.ResultCode.SUCCESS) {
|
|
2227
|
+
Object.assign(this, {
|
|
2228
|
+
exitMaterial: validatedResponse.exitMaterial,
|
|
2229
|
+
dischargeResult: validatedResponse.dischargeResult,
|
|
2230
|
+
dischargeRecords: validatedResponse.dischargeRecords,
|
|
2231
|
+
resultCode: validatedResponse.resultCode,
|
|
2232
|
+
messages: validatedResponse.messages ?? [],
|
|
2233
|
+
calculationElapsedTime: validatedResponse.calculationElapsedTime,
|
|
2234
|
+
operationId: validatedResponse.operationId,
|
|
2235
|
+
});
|
|
2236
|
+
} else {
|
|
2237
|
+
this.messages.push(...(validatedResponse.messages ?? []));
|
|
2238
|
+
}
|
|
2239
|
+
} catch (err: any) {
|
|
2240
|
+
if ((err as any)?.response) {
|
|
2241
|
+
this.handleFailedResponse((err as any).response);
|
|
2242
|
+
} else {
|
|
2243
|
+
throw err;
|
|
2244
|
+
}
|
|
2245
|
+
console.error(err);
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
return this.resultCode;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
toString() {
|
|
2252
|
+
const parts = ['* VesselSphereLeak'];
|
|
2253
|
+
|
|
2254
|
+
parts.push(`exitMaterial: ${String(this.exitMaterial)}`);
|
|
2255
|
+
parts.push(`dischargeResult: ${String(this.dischargeResult)}`);
|
|
2256
|
+
parts.push('*** dischargeRecords:');
|
|
2257
|
+
parts.push(
|
|
2258
|
+
this.dischargeRecords && this.dischargeRecords.length > 0
|
|
2259
|
+
? this.dischargeRecords.map((point) => `dischargeRecordsElement: ${point}`).join('\n')
|
|
2260
|
+
: 'dischargeRecords does not contain any elements',
|
|
2261
|
+
);
|
|
2262
|
+
parts.push(`resultCode: ${String(this.resultCode)}`);
|
|
2263
|
+
parts.push('*** messages:');
|
|
2264
|
+
parts.push(`messages: ${this.messages !== undefined ? this.messages : '(None)'}`);
|
|
2265
|
+
parts.push(`calculationElapsedTime: ${this.calculationElapsedTime !== undefined ? this.calculationElapsedTime : '(None)'}`);
|
|
2266
|
+
parts.push(`operationId: ${this.operationId !== undefined ? this.operationId : '(None)'}`);
|
|
2267
|
+
|
|
2268
|
+
return parts.join('\n');
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
export class VesselSphereLeakCalculationResponse extends CalculationResponseBase {
|
|
2273
|
+
exitMaterial: Entities.Material;
|
|
2274
|
+
dischargeResult: Entities.DischargeResult;
|
|
2275
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
2276
|
+
|
|
2277
|
+
/**
|
|
2278
|
+
* VesselSphereLeak calculation response class.
|
|
2279
|
+
*
|
|
2280
|
+
*/
|
|
2281
|
+
constructor(data: {
|
|
2282
|
+
exitMaterial: Entities.Material;
|
|
2283
|
+
dischargeResult: Entities.DischargeResult;
|
|
2284
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
2285
|
+
resultCode: Enums.ResultCode;
|
|
2286
|
+
messages: string[];
|
|
2287
|
+
calculationElapsedTime: number;
|
|
2288
|
+
operationId: string;
|
|
2289
|
+
}) {
|
|
2290
|
+
super();
|
|
2291
|
+
this.exitMaterial = data.exitMaterial;
|
|
2292
|
+
this.dischargeResult = data.dischargeResult;
|
|
2293
|
+
this.dischargeRecords = data.dischargeRecords;
|
|
2294
|
+
this.resultCode = data.resultCode;
|
|
2295
|
+
this.messages = data.messages;
|
|
2296
|
+
this.calculationElapsedTime = data.calculationElapsedTime;
|
|
2297
|
+
this.operationId = data.operationId;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
initialiseFromDictionary(data: { [key: string]: unknown }) {
|
|
2301
|
+
if (data.exitMaterial) {
|
|
2302
|
+
this.exitMaterial = new Entities.Material();
|
|
2303
|
+
this.exitMaterial.initialiseFromDictionary(data.exitMaterial as { [key: string]: unknown });
|
|
2304
|
+
}
|
|
2305
|
+
if (data.dischargeResult) {
|
|
2306
|
+
this.dischargeResult = new Entities.DischargeResult();
|
|
2307
|
+
this.dischargeResult.initialiseFromDictionary(data.dischargeResult as { [key: string]: unknown });
|
|
2308
|
+
}
|
|
2309
|
+
if (data.dischargeRecords && Array.isArray(data.dischargeRecords)) {
|
|
2310
|
+
this.dischargeRecords = data.dischargeRecords.map((item) => {
|
|
2311
|
+
const record = new Entities.DischargeRecord();
|
|
2312
|
+
record.initialiseFromDictionary(item);
|
|
2313
|
+
return record;
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
if (data.resultCode !== undefined && (typeof data.resultCode === 'string' || typeof data.resultCode === 'number')) {
|
|
2317
|
+
this.resultCode = data.resultCode as Enums.ResultCode;
|
|
2318
|
+
}
|
|
2319
|
+
this.messages = this.messages ?? [];
|
|
2320
|
+
if (data.messages && Array.isArray(data.messages)) {
|
|
2321
|
+
this.messages.push(...data.messages);
|
|
2322
|
+
}
|
|
2323
|
+
if (data.calculationElapsedTime !== undefined && typeof data.calculationElapsedTime === 'number') {
|
|
2324
|
+
this.calculationElapsedTime = data.calculationElapsedTime as number;
|
|
2325
|
+
}
|
|
2326
|
+
if (data.operationId !== undefined && typeof data.operationId === 'string') {
|
|
2327
|
+
this.operationId = data.operationId as string;
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
export interface VesselSphereLeakCalculationResponseSchemaData {
|
|
2333
|
+
exitMaterial: Entities.Material;
|
|
2334
|
+
dischargeResult: Entities.DischargeResult;
|
|
2335
|
+
dischargeRecords: Entities.DischargeRecord[];
|
|
2336
|
+
resultCode: Enums.ResultCode;
|
|
2337
|
+
messages: string[];
|
|
2338
|
+
calculationElapsedTime: number;
|
|
2339
|
+
operationId: string;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
export class VesselSphereLeakCalculationResponseSchema {
|
|
2343
|
+
schema: Joi.ObjectSchema;
|
|
2344
|
+
propertyTypes: Record<string, string>;
|
|
2345
|
+
|
|
2346
|
+
/**
|
|
2347
|
+
* Schema for the VesselSphereLeak calculation response.
|
|
2348
|
+
*/
|
|
2349
|
+
constructor() {
|
|
2350
|
+
this.schema = Joi.object({
|
|
2351
|
+
exitMaterial: new EntitySchemas.MaterialSchema().schema,
|
|
2352
|
+
dischargeResult: new EntitySchemas.DischargeResultSchema().schema,
|
|
2353
|
+
dischargeRecords: Joi.array().items(new EntitySchemas.DischargeRecordSchema().schema).allow(null),
|
|
2354
|
+
resultCode: Joi.string().valid(...Object.values(Enums.ResultCode)),
|
|
2355
|
+
messages: Joi.array().items(Joi.string()),
|
|
2356
|
+
calculationElapsedTime: Joi.number().unsafe(),
|
|
2357
|
+
operationId: Joi.string().uuid().allow(null),
|
|
2358
|
+
}).unknown(true);
|
|
2359
|
+
|
|
2360
|
+
this.propertyTypes = {
|
|
2361
|
+
exitMaterial: 'Entities.Material',
|
|
2362
|
+
dischargeResult: 'Entities.DischargeResult',
|
|
2363
|
+
dischargeRecords: 'Entities.DischargeRecord[]',
|
|
2364
|
+
};
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
validate(data: VesselSphereLeakCalculationResponseSchemaData): VesselSphereLeakCalculationResponse {
|
|
2368
|
+
const { error, value } = this.schema.validate(data, { abortEarly: false });
|
|
2369
|
+
if (error) {
|
|
2370
|
+
throw new Error(`Validation error: ${error.details.map((x) => x.message).join(', ')}`);
|
|
2371
|
+
}
|
|
2372
|
+
return this.makeCalculationResponse(value);
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
makeCalculationResponse(data: VesselSphereLeakCalculationResponseSchemaData): VesselSphereLeakCalculationResponse {
|
|
2376
|
+
return new VesselSphereLeakCalculationResponse(data);
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
|
|
1735
2380
|
export interface VesselStateCalculationRequestSchemaData {
|
|
1736
2381
|
material: Entities.Material;
|
|
1737
2382
|
materialState: Entities.State;
|
|
@@ -1791,9 +2436,7 @@ export class VesselStateCalculation extends CalculationBase {
|
|
|
1791
2436
|
outputState?: Entities.State;
|
|
1792
2437
|
|
|
1793
2438
|
/**
|
|
1794
|
-
* Calculates the fluid phase for a user-defined material where the user has defined the pressure and/or temperature. The model carries out a flash calculation to obtain the fluid properties
|
|
1795
|
-
the vessel conditions (e.g. Pure gas, Stratified Two-Phase vessel, Pressurised Liquid) that can be input to the
|
|
1796
|
-
source term models: vessel leak and vessel catastrophic rupture.
|
|
2439
|
+
* Calculates the fluid phase for a user-defined material where the user has defined the pressure and/or temperature. The model carries out a flash calculation to obtain the fluid properties and returns the vessel conditions (i.e. Pure gas, Stratified Two-Phase vessel, Pressurised Liquid) that can be input to the source term models: vessel leak and vessel catastrophic rupture.
|
|
1797
2440
|
*
|
|
1798
2441
|
*/
|
|
1799
2442
|
constructor(data: { material: Entities.Material; materialState: Entities.State; controller?: AbortController }) {
|