Skip to main content

Python library supporting Phast Web Services

Project description

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 Python PWS have been developed to enable you to call Phast consequence calculations from within your own Python scripts.

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 create a Python script that is able to call the Phast Web Services calculations you will need to obtain an access token from DNV.

Please note that the PyPWS library is tested on Python versions 3.11 onwards. It is recommended to use one of these versions.

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.

from pypws.calculations import VesselLeakCalculation, VesselStateCalculation
from pypws.entities import DischargeParameters, Leak, Material, MaterialComponent, State, Vessel
from pypws.enums import ResultCode, TimeVaryingOption, VesselShape

# Define the material contained by the vessel.
material = Material(material_name, [MaterialComponent(material_name, 1.0)])

# Define the initial state of the vessel.
state = State(temperature=state_temperature, pressure=state_pressure, liquid_fraction=0.0)

# Create a vessel state calculation using the material and state.
vessel_state_calculation = VesselStateCalculation(material, state)

# Run the vessel state calculation.
vessel_state_calculation.run()

# Create a vessel entity and pass in the results from the VesselStateCalculation.
vessel = Vessel(state=vessel_state_calculation.output_state, material=vessel_state_calculation.material, vessel_conditions=vessel_state_calculation.vessel_conditions, diameter=6.0, length=10.0, shape=VesselShape.HORIZONTAL_CYLINDER, liquid_fill_fraction_by_volume=0.0)

# Create a leak to use in the vessel leak calculation.
# The leak has a hole of diameter of 50mm but we specify it as 0.05 as all calculations are performed using
# SI units which in this case is metres.  The hole height fraction is set to 0.0 which corresponds to the
# bottom of the vessel.  The time varying option is set topytest initial rate.
leak = Leak(hole_diameter=0.05, hole_height_fraction=0.0, time_varying_option=TimeVaryingOption.INITIAL_RATE)

# Create discharge parameters to use in the vessel leak calculation taking all the default values.
discharge_parameters = DischargeParameters()

# Create a vessel leak calculation using the vessel, leak, and discharge parameters.
vessel_leak_calculation = VesselLeakCalculation(vessel, leak, discharge_parameters)

# Run the vessel leak calculation.
result_code = vessel_leak_calculation.run()

if resultCode == ResultCode.SUCCESS:
    print('SUCCESS: vessel_leak_calculation')
else:
    print(f'FAILED vessel_leak_calculation with result code {resultCode}')
    assert False

# Print any messages.
if len(vessel_leak_calculation.messages) > 0:
    print('Messages:')
    for message in vessel_leak_calculation.messages:
        print(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 vessel_leak_calculation for reasons of brevity.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypws-4.2.25.tar.gz (127.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypws-4.2.25-py3-none-any.whl (102.9 kB view details)

Uploaded Python 3

File details

Details for the file pypws-4.2.25.tar.gz.

File metadata

  • Download URL: pypws-4.2.25.tar.gz
  • Upload date:
  • Size: 127.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for pypws-4.2.25.tar.gz
Algorithm Hash digest
SHA256 d66591574457ed0485dedf062aad79fc414ae05c3ed7f192691792a638ffcda3
MD5 e052ed305a0182c7319d9170d85415a7
BLAKE2b-256 f062210f886a408b3038fb72061aa244656baeaa3f084b799955f776f6e9ffd8

See more details on using hashes here.

File details

Details for the file pypws-4.2.25-py3-none-any.whl.

File metadata

  • Download URL: pypws-4.2.25-py3-none-any.whl
  • Upload date:
  • Size: 102.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for pypws-4.2.25-py3-none-any.whl
Algorithm Hash digest
SHA256 6e5b1670dc0545b8e084b920e209dfe2003921ed4c0de5ec9054c501798de95b
MD5 8f1c62c6936212187c9715f169e2be48
BLAKE2b-256 9b15fd8df54ba363ff85b58555e07a1c213d5d037267014dadb903c6daa0ea4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page