Package: pipeline-integrity
PipelineIntegrity libraryIn RussianThe free, open source PipelineIntegrity library designed to calculate the degree of danger
of pipeline metal loss defects according to the ASME B31G method.Installationpipinstallpipeline-integrityUsageA pipe under pressure, with a length, diameter and wall thickness from specified material.frompipeline_integrity.materialimportMaterialfrompipeline_integrity.pipeimportPipepipe=Pipe(440,# length, inches56,# diameter, inches0.63,# wall thickness, inchesMaterial(# 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 pipe4,# defect length 4 inches10,# along the circumference of the pipe, the defect begins# at 10 arc minutes from the top of the pipe20,# the size of the defect along the circumference is 20 arc minutes0.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 methodfrompipeline_integrity.method.asme.b31g_2012importContextpipe.material.smts=70000asme=Context(defect)Defect depth less than 10% wall thickness, no danger.assertdefect.depth==0.039assertpipe.wallthickness==0.63assertasme.years()>0assert0.7<asme.erf()<0.71For very low pressure cases, repair is never required (special value REPAIR_NOT_REQUIRED=777).pipe.maop=1assertasme.years()==asme.REPAIR_NOT_REQUIREDThe depth of the defect is 50% of the pipe wall thickness.pipe.maop=900defect.depth=0.31assertdefect.length==4assert0.74<asme.erf()<0.75A 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=30assertasme.years()==0assertasme.erf()>1.3When the operating pressure is reduced to a safe value, the defect does not require repair.assertpipe.maop==900assertround(asme.safe_pressure,2)==653.71pipe.maop=500asme.is_explain=Trueassertasme.years()>0If you set context propertyis_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.integrityWith Python 3:$ make setup PYTHON_BIN=/path/to/python3
$ make testsWith Python 2:$ make setup2 PYTHON_BIN=/path/to/python2
$ make tests2ExampleLiving version of online calculator example, that use this library, can befound here.
The source code of this example placed in this repo inexample dir.