@dnv-plant/typescriptpws 1.0.0-alpha.1785278 → 1.0.13-alpha.1789228

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 ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2025 DNV AS
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md CHANGED
@@ -1,20 +1,90 @@
1
- # Introduction
2
- TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
3
-
4
- # Getting Started
5
- TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
6
- 1. Installation process
7
- 2. Software dependencies
8
- 3. Latest releases
9
- 4. API references
10
-
11
- # Build and Test
12
- TODO: Describe and show how to build your code and run the tests.
13
-
14
- # Contribute
15
- TODO: Explain how other users and developers can contribute to make your code better.
16
-
17
- If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
18
- - [ASP.NET Core](https://github.com/aspnet/Home)
19
- - [Visual Studio Code](https://github.com/Microsoft/vscode)
20
- - [Chakra Core](https://github.com/Microsoft/ChakraCore)
1
+ # PHAST WEB SERVICES
2
+
3
+ ## Introduction
4
+
5
+ Phast is the world's most comprehensive process hazard analysis software which models the progress of a potential incident from the initial release to far-field dispersion including modelling of pool spreading and evaporation and resulting flammable and toxic effects. In Phast Web Services we have taken the same state of the art consequence modelling calculations and made them available as web services so you can use them in your own applications.
6
+
7
+ ## Consequence analysis
8
+
9
+ Phast Web services and TypeScript PWS have been developed to enable you to call Phast consequence calculations from within your own TypeScript files.
10
+
11
+ We have services available for a wide range of consequence calculations:
12
+
13
+ - Discharge
14
+ - Toxic/flammable gas dispersion
15
+ - Fire and explosion modelling
16
+ - Various supporting, utility calculations
17
+
18
+ ## Reference documentation
19
+ A detailed reference document for Phast Web Services can be found [here](https://phastwebservices.dnv.com/).
20
+
21
+ ## Getting started
22
+ In order to call the Phast Web Services calculations you will need to obtain an access token from DNV.
23
+
24
+ ## Sample code to perform a vessel leak calculation
25
+ In the following example the **VesselLeakCalculation** is used to predict the release of Methane from a 50mm hole in a horizontal vessel. In order to get the correct conditions within the vessel the **VesselStateCalculation** is called first and the results from this are passed to the **VesselLeakCalculation** to correctly set it up.
26
+
27
+ ```typescript
28
+ import { VesselLeakCalculation, VesselStateCalculation } from "@dnv-plant/typescriptpws";
29
+ import { DischargeParameters, Leak, Material, MaterialComponent, State, Vessel } from "@dnv-plant/typescriptpws";
30
+ import { ResultCode, TimeVaryingOption, VesselShape } from "@dnv-plant/typescriptpws";
31
+
32
+ // Define the material contained by the vessel.
33
+ const material = new Material("METHANE", [new MaterialComponent("METHANE", 1.0)]);
34
+
35
+ // Define the initial state of the vessel.
36
+ const pressure = 2000000; // Pa
37
+ const temperature = 300; // K
38
+ const liquidFraction = 0.0;
39
+
40
+ const myState = new State(pressure, temperature, liquidFraction);
41
+
42
+ // Create a vessel state calculation using the material and state.
43
+ const vesselStateCalculation = new VesselStateCalculation();
44
+ vesselStateCalculation.material = material;
45
+ vesselStateCalculation.materialState = myState;
46
+
47
+ // Run the vessel state calculation.
48
+ vesselStateCalculation.run();
49
+
50
+ // Create a vessel entity and pass in the results from the VesselStateCalculation.
51
+ const vessel = new Vessel();
52
+ vessel.material = material;
53
+ vessel.state = myState;
54
+ vessel.vesselConditions = vesselStateCalculation.vesselConditions;
55
+
56
+ // Create a leak to use in the vessel leak calculation.
57
+ // The leak has a hole diameter of 50mm (0.05m). The hole height fraction is set to 0.0, which corresponds to the
58
+ // bottom of the vessel. The time-varying option is set to initial rate.
59
+ const leak = new Leak();
60
+ leak.holeDiameter = 0.05;
61
+ leak.holeHeightFraction = 0.0;
62
+ leak.timeVaryingOption = TimeVaryingOption.INITIAL_RATE;
63
+
64
+ // Create discharge parameters to use in the vessel leak calculation taking all the default values.
65
+ const dischargeParameters = new DischargeParameters();
66
+
67
+ // Create a vessel leak calculation using the vessel, leak, and discharge parameters.
68
+ const vesselLeakCalculation = new VesselLeakCalculation();
69
+ vesselLeakCalculation.vessel = vessel;
70
+ vesselLeakCalculation.leak = leak;
71
+ vesselLeakCalculation.dischargeParameters = dischargeParameters;
72
+
73
+ // Run the vessel leak calculation.
74
+ const resultCode = vesselLeakCalculation.run();
75
+
76
+ if (resultCode === ResultCode.SUCCESS) {
77
+ console.log('SUCCESS: vesselLeakCalculation');
78
+ } else {
79
+ console.log(`FAILED vesselLeakCalculation with result code ${resultCode}`);
80
+ throw new Error(`Vessel leak calculation failed with result code ${resultCode}`);
81
+ }
82
+
83
+ // Print any messages.
84
+ if (vesselLeakCalculation.messages.length > 0) {
85
+ console.log('Messages:');
86
+ vesselLeakCalculation.messages.forEach((message: string) => console.log(message));
87
+ }
88
+ ```
89
+
90
+ Note that each calculation returns a "Result Code" which can be used to check whether the calculation was successful. In the event of a failed calculation another property (messages) of the calculation instance can be inspected to display possible reasons for the failed calculation. These two features are only shown for the vesselLeakCalculation for reasons of brevity.
package/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ /***********************************************************************
2
+ * This file has been auto-generated by a code generation tool.
3
+ * Version: 1.0.13
4
+ * Date/time: 03 Feb 2025 21:02:35
5
+ * Template: templates/typescriptpws/index.razor.
6
+ ***********************************************************************/
7
+
8
+ export * from './src/calculations';
9
+ export * from './src/constants';
10
+ export * from './src/entities';
11
+ export * from './src/entity-schemas';
12
+ export * from './src/enums';
13
+ export * from './src/materials';
14
+ export * from './src/utilities';
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@dnv-plant/typescriptpws",
3
- "version": "1.0.0-alpha.1785278",
3
+ "version": "1.0.13-alpha.1789228",
4
4
  "description": "Integrate Phast models with our versatile APIs for enhanced customization and efficiency.",
5
- "main": "index.js",
5
+ "main": "index.ts",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
9
  "keywords": [],
10
- "author": "",
11
- "license": "ISC",
10
+ "author": "DNV <software.support@dnv.com> (www.dnv.com)",
11
+ "license": "MIT",
12
12
  "dependencies": {
13
13
  "axios": "^1.7.9",
14
14
  "joi": "^17.13.3",