@dnv-plant/typescriptpws 1.0.86 → 1.0.88

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.
@@ -6,12 +6,10 @@
6
6
  * Editing it may lead to inconsistent results and limit DNV's ability to provide support.
7
7
  * Please contact DNV if you believe changes are required.
8
8
  *
9
- * Version: 1.0.86
10
- * Date/time: 10 Jul 2025 09:49:06
9
+ * Version: 1.0.89
10
+ * Date/time: 29 Jul 2025 17:59:11
11
11
  * Template: templates/typescriptpws/calculations.razor.
12
- ***********************************************************************/
13
-
14
-
12
+ ***********************************************************************/
15
13
 
16
14
  import * as Enums from "../enums";
17
15
  import * as Entities from "../entities";
@@ -36,12 +34,17 @@ class CalculationBase {
36
34
  messages: string[] = [];
37
35
  calculationElapsedTime?: number = 0.0;
38
36
  operationId?: string = "";
37
+ controller?: AbortController;
38
+
39
+ constructor(controller?: AbortController) {
40
+ this.controller = controller;
41
+ }
39
42
 
40
43
  /**
41
44
  * Post JSON to URL and time the call
42
45
  */
43
46
  async postRequest(url: string, data: string): Promise<AxiosResponse> {
44
- return postRequest(url, data);
47
+ return postRequest(url, data, this.controller);
45
48
  }
46
49
 
47
50
  /**
@@ -177,16 +180,8 @@ class DispersionCalculationRequest extends CalculationRequestBase {
177
180
  /**
178
181
  * Dispersion calculation request class.
179
182
  *
180
- * @param {Entities.Material} material - a material entity with post-discharge composition.
181
- * @param {Entities.Substrate} substrate - a substrate entity.
182
- * @param {Entities.DischargeResult} dischargeResult - Discharge / source term definition.
183
- * @param {Entities.DischargeRecord[]} dischargeRecords - an array of discharge records.
184
- * @param {number} dischargeRecordCount - Number of discharge records.
185
- * @param {Entities.Weather} weather - a weather entity.
186
- * @param {Entities.DispersionParameters} dispersionParameters - a dispersion parameters entity.
187
- * @param {number} endPointConcentration - Concentration at which the dispersion calculations will terminate (v/v fraction).
188
183
  */
189
- constructor(
184
+ constructor(data: {
190
185
  material: Entities.Material,
191
186
  substrate: Entities.Substrate,
192
187
  dischargeResult: Entities.DischargeResult,
@@ -195,16 +190,16 @@ class DispersionCalculationRequest extends CalculationRequestBase {
195
190
  weather: Entities.Weather,
196
191
  dispersionParameters: Entities.DispersionParameters,
197
192
  endPointConcentration: number
198
- ) {
193
+ }) {
199
194
  super();
200
- this.material = material;
201
- this.substrate = substrate;
202
- this.dischargeResult = dischargeResult;
203
- this.dischargeRecords = dischargeRecords;
204
- this.dischargeRecordCount = dischargeRecordCount;
205
- this.weather = weather;
206
- this.dispersionParameters = dispersionParameters;
207
- this.endPointConcentration = endPointConcentration;
195
+ this.material = data.material;
196
+ this.substrate = data.substrate;
197
+ this.dischargeResult = data.dischargeResult;
198
+ this.dischargeRecords = data.dischargeRecords;
199
+ this.dischargeRecordCount = data.dischargeRecordCount;
200
+ this.weather = data.weather;
201
+ this.dispersionParameters = data.dispersionParameters;
202
+ this.endPointConcentration = data.endPointConcentration;
208
203
  }
209
204
  }
210
205
 
@@ -248,16 +243,7 @@ export class DispersionCalculationRequestSchema {
248
243
  }
249
244
 
250
245
  makeCalculationRequest(data: DispersionCalculationRequestSchemaData): DispersionCalculationRequest {
251
- return new DispersionCalculationRequest(
252
- data.material,
253
- data.substrate,
254
- data.dischargeResult,
255
- data.dischargeRecords,
256
- data.dischargeRecordCount,
257
- data.weather,
258
- data.dispersionParameters,
259
- data.endPointConcentration
260
- );
246
+ return new DispersionCalculationRequest(data);
261
247
  }
262
248
  }
263
249
 
@@ -279,16 +265,8 @@ export class DispersionCalculation extends CalculationBase {
279
265
  of DispersionRecords. The modelling includes rainout and re-evaporation for 2-phase releases.
280
266
  Time-varying scenarios with mixtures are not currently handled and will give an error. It is recommended therefore to use a continuous or instantaneous source for mixtures.
281
267
  *
282
- * @param {Entities.Material} material - a material entity with post-discharge composition.
283
- * @param {Entities.Substrate} substrate - a substrate entity.
284
- * @param {Entities.DischargeResult} dischargeResult - Discharge / source term definition.
285
- * @param {Entities.DischargeRecord[]} dischargeRecords - an array of discharge records.
286
- * @param {number} dischargeRecordCount - Number of discharge records.
287
- * @param {Entities.Weather} weather - a weather entity.
288
- * @param {Entities.DispersionParameters} dispersionParameters - a dispersion parameters entity.
289
- * @param {number} endPointConcentration - Concentration at which the dispersion calculations will terminate (v/v fraction).
290
268
  */
291
- constructor(
269
+ constructor(data: {
292
270
  material: Entities.Material,
293
271
  substrate: Entities.Substrate,
294
272
  dischargeResult: Entities.DischargeResult,
@@ -297,30 +275,31 @@ Time-varying scenarios with mixtures are not currently handled and will give an
297
275
  weather: Entities.Weather,
298
276
  dispersionParameters: Entities.DispersionParameters,
299
277
  endPointConcentration: number
300
- ) {
301
- super();
302
- this.material = material;
303
- this.substrate = substrate;
304
- this.dischargeResult = dischargeResult;
305
- this.dischargeRecords = dischargeRecords;
306
- this.dischargeRecordCount = dischargeRecordCount;
307
- this.weather = weather;
308
- this.dispersionParameters = dispersionParameters;
309
- this.endPointConcentration = endPointConcentration;
278
+ controller?: AbortController;
279
+ }) {
280
+ super(data.controller);
281
+ this.material = data.material;
282
+ this.substrate = data.substrate;
283
+ this.dischargeResult = data.dischargeResult;
284
+ this.dischargeRecords = data.dischargeRecords;
285
+ this.dischargeRecordCount = data.dischargeRecordCount;
286
+ this.weather = data.weather;
287
+ this.dispersionParameters = data.dispersionParameters;
288
+ this.endPointConcentration = data.endPointConcentration;
310
289
  }
311
290
 
312
291
  async run() {
313
292
  try {
314
- const request = new DispersionCalculationRequest(
315
- this.material,
316
- this.substrate,
317
- this.dischargeResult,
318
- this.dischargeRecords,
319
- this.dischargeRecordCount,
320
- this.weather,
321
- this.dispersionParameters,
322
- this.endPointConcentration
323
- );
293
+ const request = new DispersionCalculationRequest({
294
+ material: this.material,
295
+ substrate: this.substrate,
296
+ dischargeResult: this.dischargeResult,
297
+ dischargeRecords: this.dischargeRecords,
298
+ dischargeRecordCount: this.dischargeRecordCount,
299
+ weather: this.weather,
300
+ dispersionParameters: this.dispersionParameters,
301
+ endPointConcentration: this.endPointConcentration
302
+ });
324
303
 
325
304
  const schema = new DispersionCalculationRequestSchema();
326
305
  const validatedRequest = schema.validate(request);
@@ -395,11 +374,8 @@ export class DispersionCalculationResponse extends CalculationResponseBase {
395
374
  /**
396
375
  * Dispersion calculation response class.
397
376
  *
398
- * @param {Entities.ScalarUdmOutputs} scalarUdmOutputs - Scalar dispersion results.
399
- * @param {Entities.DispersionRecord[]} dispersionRecords - an array of dispersion records.
400
- * @param {Entities.PoolRecord[]} poolRecords - an array of pool records.
401
377
  */
402
- constructor(
378
+ constructor(data: {
403
379
  scalarUdmOutputs: Entities.ScalarUdmOutputs,
404
380
  dispersionRecords: Entities.DispersionRecord[],
405
381
  poolRecords: Entities.PoolRecord[],
@@ -407,15 +383,15 @@ export class DispersionCalculationResponse extends CalculationResponseBase {
407
383
  messages: string[],
408
384
  calculationElapsedTime: number,
409
385
  operationId: string
410
- ) {
386
+ }) {
411
387
  super();
412
- this.scalarUdmOutputs = scalarUdmOutputs;
413
- this.dispersionRecords = dispersionRecords;
414
- this.poolRecords = poolRecords;
415
- this.resultCode = resultCode;
416
- this.messages = messages;
417
- this.calculationElapsedTime = calculationElapsedTime;
418
- this.operationId = operationId;
388
+ this.scalarUdmOutputs = data.scalarUdmOutputs;
389
+ this.dispersionRecords = data.dispersionRecords;
390
+ this.poolRecords = data.poolRecords;
391
+ this.resultCode = data.resultCode;
392
+ this.messages = data.messages;
393
+ this.calculationElapsedTime = data.calculationElapsedTime;
394
+ this.operationId = data.operationId;
419
395
  }
420
396
 
421
397
  initialiseFromDictionary(data: { [key: string]: unknown }) {
@@ -501,14 +477,6 @@ export class DispersionCalculationResponseSchema {
501
477
  }
502
478
 
503
479
  makeCalculationResponse(data: DispersionCalculationResponseSchemaData): DispersionCalculationResponse {
504
- return new DispersionCalculationResponse(
505
- data.scalarUdmOutputs,
506
- data.dispersionRecords,
507
- data.poolRecords,
508
- data.resultCode,
509
- data.messages,
510
- data.calculationElapsedTime,
511
- data.operationId
512
- );
480
+ return new DispersionCalculationResponse(data);
513
481
  }
514
482
  }