Skip to main content

PipelineIntegrity library

GitHub Workflow Status GitHub Workflow Status GitHub Workflow Status Codacy Badge Codacy Badge

In Russian

The free, open source PipelineIntegrity library designed to calculate the degree of danger of pipeline metal loss defects according to the ASME B31G method.

ASME B31G method

Installation

pip install pipeline-integrity

Usage

A pipe under pressure, with a length, diameter and wall thickness from specified material.

from pipeline_integrity.material import Material
from pipeline_integrity.pipe import Pipe

pipe = Pipe(
  440,  # length, inches
  56,  # diameter, inches
  0.63,  # wall thickness, inches
  Material(  # pipe material
    "Steel",
    52000  # SMYS, psi
  ),
  900  # pressure, psi
)
)

Metal loss defect with a specified position on the pipe and a specified depth.

defect = pipe.add_metal_loss(
  40,  # the defect starts at a distance of 40 inches from the beginning of the pipe
  4,  # defect length 4 inches
  10,  # along the circumference of the pipe, the defect begins
       # at 10 arc minutes from the top of the pipe
  20,  # the size of the defect along the circumference is 20 arc minutes
  0.039  # defect depth 0.039 inches
)

SMTS for pipe material must be set to create context for calculating the degree of severity of the defect according to the ASME B31G method

from pipeline_integrity.method.asme.b31g_2012 import Context

pipe.material.smts = 70000
asme = Context(defect)

Defect depth less than 10% wall thickness, no danger.

assert defect.depth == 0.039
assert pipe.wallthickness == 0.63

assert asme.years() > 0
assert 0.7 < asme.erf() < 0.71

For very low pressure cases, repair is never required (special value REPAIR_NOT_REQUIRED=777).

pipe.maop = 1
assert asme.years() == asme.REPAIR_NOT_REQUIRED

The depth of the defect is 50% of the pipe wall thickness.

pipe.maop = 900
defect.depth = 0.31
assert defect.length == 4
assert 0.74 < asme.erf() < 0.75

A defect with a length of 30 inches and a depth of 50% of the pipe wall thickness requires repair at the specified working pressure in the pipe.

defect.length = 30
assert asme.years() == 0
assert asme.erf() > 1.3

When the operating pressure is reduced to a safe value, the defect does not require repair.

assert pipe.maop == 900
assert round(asme.safe_pressure, 2) == 653.71
pipe.maop = 500
asme.is_explain = True
assert asme.years() > 0

If you set context property is_explain = True, then you can get explanation in text form.

asme.explain()
Calculate ERF by ASME B31G 2012 classic.
Calculate failure stress level by the classic way.
Parameter Sflow = 1.1 * material_smys.
Sflow = 1.1 * 52000 = 57200.0.
Parameter Z = length^2 / (diameter * wallthickness).
Z = 30^2 / (56 * 0.63) = 25.51.
Parameter Z = 25.51 > 20.
Failure stress level = Sflow * (1 - depth / wallthickness).
stress_fail = 57200.0 * (1 - 0.31 / 0.63) = 29053.968.
Failure pressure = 2 * stress_fail * wallthickness / diameter.
press_fail = 2 * 29053.968 * 0.63 / 56 = 653.714.
ERF = pipe_maop / press_fail.
ERF = 500 / 653.714 = 0.765

Repair is not required at the moment, calculate the time before repair.
With corrosion rate 0.016 mm/year, pipe wall 0.63 and depth 0.31 a through hole is formed after years: 21.
Calculating the year in which the corrosion growth of the defect will require repair.
Years: 4 ERF: 0.952.
Years: 5 ERF: 1.014.
Defect will require repair after years: 4.

Development

git clone git@github.com:vb64/pipeline.integrity.git
cd pipeline.integrity

With Python 3:

make setup PYTHON_BIN=/path/to/python3
make tests

With Python 2:

make setup2 PYTHON_BIN=/path/to/python2
make tests2

Example

Living version of online calculator example, that use this library, can be found here. The source code of this example placed in this repo in example dir.

Metadata

Release files for pipeline-integrity 1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipeline-integrity 1.6
File Size Uploaded
pipeline_integrity-1.6.tar.gz 14.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pipeline-integrity 1.6
File Interpreter ABI Platform
pipeline_integrity-1.6-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / pipeline_integrity-1.6.tar.gz

Download URL pipeline_integrity-1.6.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5e8a9179d24921d1aa9fecfc8d73b0a19552295fe3c18e71df7eda255a6089a2
BLAKE2b-256 checksum
How to use checksums
66b29536246cd4a27400ea498ad26cb1f7ae595f5e0a3afe7c364063058e383b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release files / pipeline_integrity-1.6-py3-none-any.whl

Download URL pipeline_integrity-1.6-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
536717c8c952608b9a9bc9fceae0abcea6b40b9fc500a9ebd125cd8dfed4713e
BLAKE2b-256 checksum
How to use checksums
862e95c09a3cd3704e8ed3d974151109f4cb38280fb0c9ef1b6e21e48b430d19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.6 This release

2 release files

1.5.1

2 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page