@dnv-plant/typescriptpws
v1.0.95
Published
Integrate Phast models with our versatile APIs for enhanced customization and efficiency.
Downloads
220
Readme
PHAST WEB SERVICES
Introduction
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.
Consequence analysis
Phast Web services and TypeScript PWS have been developed to enable you to call Phast consequence calculations from within your own TypeScript files.
We have services available for a wide range of consequence calculations:
- Discharge
- Toxic/flammable gas dispersion
- Fire and explosion modelling
- Various supporting, utility calculations
Reference documentation
A detailed reference document for Phast Web Services can be found here.
Getting started
In order to call the Phast Web Services calculations you will need to obtain an access token from DNV.
Sample code to perform a vessel leak calculation
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.
import { VesselLeakCalculation, VesselStateCalculation } from "@dnv-plant/typescriptpws";
import { DischargeParameters, Leak, Material, MaterialComponent, State, Vessel } from "@dnv-plant/typescriptpws";
import { ResultCode, TimeVaryingOption, VesselShape } from "@dnv-plant/typescriptpws";
// Define the material contained by the vessel.
const material = new Material("METHANE", [new MaterialComponent("METHANE", 1.0)]);
// Define the initial state of the vessel.
const pressure = 2000000; // Pa
const temperature = 300; // K
const liquidFraction = 0.0;
const myState = new State(pressure, temperature, liquidFraction);
// Create a vessel state calculation using the material and state.
const vesselStateCalculation = new VesselStateCalculation();
vesselStateCalculation.material = material;
vesselStateCalculation.materialState = myState;
// Run the vessel state calculation.
vesselStateCalculation.run();
// Create a vessel entity and pass in the results from the VesselStateCalculation.
const vessel = new Vessel();
vessel.material = material;
vessel.state = myState;
vessel.vesselConditions = vesselStateCalculation.vesselConditions;
// Create a leak to use in the vessel leak calculation.
// The leak has a hole diameter of 50mm (0.05m). The hole height fraction is set to 0.0, which corresponds to the
// bottom of the vessel. The time-varying option is set to initial rate.
const leak = new Leak();
leak.holeDiameter = 0.05;
leak.holeHeightFraction = 0.0;
leak.timeVaryingOption = TimeVaryingOption.INITIAL_RATE;
// Create discharge parameters to use in the vessel leak calculation taking all the default values.
const dischargeParameters = new DischargeParameters();
// Create a vessel leak calculation using the vessel, leak, and discharge parameters.
const vesselLeakCalculation = new VesselLeakCalculation();
vesselLeakCalculation.vessel = vessel;
vesselLeakCalculation.leak = leak;
vesselLeakCalculation.dischargeParameters = dischargeParameters;
// Run the vessel leak calculation.
const resultCode = vesselLeakCalculation.run();
if (resultCode === ResultCode.SUCCESS) {
console.log('SUCCESS: vesselLeakCalculation');
} else {
console.log(`FAILED vesselLeakCalculation with result code ${resultCode}`);
throw new Error(`Vessel leak calculation failed with result code ${resultCode}`);
}
// Print any messages.
if (vesselLeakCalculation.messages.length > 0) {
console.log('Messages:');
vesselLeakCalculation.messages.forEach((message: string) => console.log(message));
}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.
