R-package for diagnostics, reliability and predictive maintenance of pipeline systems.

Aiming for digital transformation of technical engineering departments
of heat generating and heat transferring companies the package
aggregates to some extent the separate knowledge concerning engineering,
reliability, diagnostics and predictive maintenance of pipeline systems.
For the present time the package contains utilities for processing
corrosion data commonly gathered by *inline inspection*, as well as
emperical models for calculations of local thermal-hydraulic regimes of
district heating network.

For the stable release just install the latest version from CRAN:

```
install.packages("pipenostics")
```

For the development version, use devtools:

```
devtools::install_github("omega1x/pipenostics")
```

By using of `b31crvl()`

simply imitate the output of *CRVL.BAS* which is the honored software for determining the allowable length and maximum
allowable working pressure presented in ASME B31G-1991:

```
library(pipenostics)
b31crvl(maop = 910, d = 30, wth = .438, smys = 52000, def = .72, depth = .1, l = 7.5)
-- Calculated data --
Intermediate factor (A) = 1.847
Design pressure = 1093 PSI; Safe pressure = 1093 PSI
Pipe may be operated safely at MAOP, 910 PSI
With corrosion length 7.500 inch, maximum allowed corrosion depth is 0.2490 inch; A = 1.847
With corrosion depth 0.100 inch, maximum allowed corrosion length is Inf inch; A = 5.000
```

Let's consider a pipe in district heating network with

```
diameter <- 762 # [mm]
wall_thickness <- 10 # [mm]
UTS <- 434.3697 # [MPa]
```

which transfers heat-carrier (water) at

```
operating_pressure <- 0.588399 # [MPa]
temperature <- 95 # [°C]
```

During *inline inspection* four corroded areas (defects) are detected with:

```
depth <- c(2.45, 7.86, 7.93, 8.15) # [mm]
```

whereas the length of all defects is not greater 200 mm:

```
length <- rep(200, 4) # [mm]
print(length)
# [1] 200 200 200 200
```

Corrosion rates in radial and in longitudinal directions are not well-known and
may vary in range `.01`

- `.30`

mm/year:

```
rar = function(n) stats::runif(n, .01, .30) / 365
ral = function(n) stats::runif(n, .01, .30) / 365
```

Then probabilities of failure (POFs) related to each corroded area are near:

```
pof <- mepof(depth, length, rep(diameter, 4), rep(wall_thickness, 4),
rep(UTS, 4), rep(operating_pressure, 4), rep(temperature, 4),
rar, ral, method = "dnv")
# pipenostics::mepof: process case [4/4] - 100 % . All done, thanks!
print(pof)
# [1] 0.000000 0.252935 0.368741 0.771299
```

So, the POF of the pipe is near

```
print(max(pof))
# [1] 0.771299
```

The value of POF changes in time. So, in a year after *inline inspection* of
the pipe we can get something near

```
pof <- mepof(depth, length, rep(diameter, 4), rep(wall_thickness, 4),
rep(UTS, 4), rep(operating_pressure, 4), rep(temperature, 4),
rar, ral, method = "dnv", days = 365)
# pipenostics::mepof: process case [4/4] - 100 % . All done, thanks!
print(pof)
# [1] 0.000000 0.526646 0.647422 0.928825
```

For entire pipe we get something near:

```
print(max(pof))
# [1] 0.928825
```

Two years ago before *inline inspection* the pipe state was rather good:

```
pof <- mepof(depth, length, rep(diameter, 4), rep(wall_thickness, 4),
rep(UTS, 4), rep(operating_pressure, 4), rep(temperature, 4),
rar, ral, method = "dnv", days = -2 * 365)
# pipenostics::mepof: process case [4/4] - 100 % . All done, thanks!
print(pof)
# [1] 0.000000 0.040849 0.072734 0.272358
```

For entire pipe we get something near:

```
print(max(pof))
# [1] 0.272358
```

Let's consider the next 4-segment tracing path:

Suppose we have the next sensor readings for *forward tracing*:

```
t_fw <- 130 # [°C]
p_fw <- 0.588399 # [MPa]
g_fw <- 250 # [ton/hour]
```

Let's discharges to network for each pipeline segment are somehow determined as

```
discharges <- seq(0, 30, 10) # [ton/hour]
print(discharges)
# [1] 0 10 20 30
```

Then the calculated regime (red squares) for forward tracing is

```
regime_fw <- m325traceline(t_fw, p_fw, g_fw, discharges, forward = TRUE)
print(regime_fw)
# $temperature
# [1] 129.1799 128.4269 127.9628 127.3367
#
# $pressure
# [1] 0.5878607 0.5874226 0.5872143 0.5870330
#
# $consumption
# [1] 250 240 220 190
```

For further examples go to package function descriptions.

Aiming to avoid portability and accessibility problems made us search ways to restrict source code development by functionality of few external packages. It reasonably helps to use the package inside ML-services traditionally leveraged in large companies maintaining district heating systems.

Since most functions have native argument vectorization usage of those functions with fast data.table framework is strongly encouraged when processing large data sets. For that purpose arguments for all package functions are thoroughly checked for type consistency and physical sense using asserts and tests from checkmate package. Moreover, in package documentation we borrow type designations according to checkmate notation.

It is recognized by pipeline companies that some sections of high pressure pipelines particularly those installed a number of years ago, have experienced some corrosion. Where corrosion is found, pipeline operators have been deeply concerned about the need for a method of determining the remaining strength of these corroded areas. If the corrosion does not penetrate the pipe wall, what is the pressure containing capability of the remaining pipe metal in terms of its ability to continue to operate safely at the maximum allowable operating pressure (MAOP) of the pipeline system?

Thus, one of the needs of the pipeline industry has been a procedure that will help operators, particularly field personnel, make decisions on existing pipelines, when exposed for any purpose, as to whether any corroded region may be left in service or whether it needs to be repaired or replaced. Such determinations must be based upon sound research and extensive testing in order to provide safe and conservative guidelines on which to base field decisions.

ASME
B31G-1991
and ASME
B31G-2012
codes have proven sound and have seen successful use in the pipeline
industry providing users with such required formalized framework for a very long period of time. That is why failure pressure calculators
`b31gpf()`

and `b31gmodpf()`

are widely used in assessment of POFs.

To preserve simplicity of traditional inline measurements
during inspections we hereinafter consider only **Analysis Level 1** in this *R*-package, since as noted in
ASME
B31G-2012
**Level 1** evaluation is quite suitable for use in prioritizing
corrosion defects identified by *inline inspection*.

Other approaches for operating with corrosion data presented in the package are aimed on
failure pressure calculations. Models like `dnvpf()`

, `shell92pf()`

, and
`pcorrcpf()`

assume different shapes of corrosion defects and usage
conditions for some cases. So, it is encouraged first to find out which
model is most suitable for solving some real world problem.

For the sake of simplicity and transparency the next values describing technological conditions, material properties of pipe and defect parameters are used as arguments throughout the most functions concerning corrosion diagnostics:

*maop*- maximum allowable operating pressure - MAOP in PSI*d*- nominal outside diameter of the pipe, inch, or mm*wth*- nominal wall thickness of the pipe, inch, or mm*smys*- specified minimum yield of stress - SMYS as a characteristics of steel strength, PSI*uts*- ultimate tensile strength - UTS or specified minimum tensile strength (SMTS) as another characteristic of steel strength, MPa*depth*- measured maximum depth of the corroded area, inch, or mm*l*- measured maximum longitudial length of the corroded area, inch, or mm

In the course of further development of the functionality of this package, some revisions or supplements to the existing concept are not excepted.

Consistent estimate of failure for pipeline systems plays a critical role in optimizing their operation. To prevent pipeline failures due to growing corrosion defects it is necessary to assess the pipeline failure probability (POF) during a certain period, taking into account its actual level of defectiveness.

The pipeline failure is preceded by limit state which comes when the burst pressure, considered as a random variable, reaches an unacceptable level, or when the defect depth, also a random variable, exceeds the predetermined limit value.

Up to now no methods existed which would give absolutely correct POF assessments. Nevertheless the stochastic
nature of corrosion processes clearly suggests exploiting of
Monte-Carlo simulations (MC).
Meanwhile the lack of comprehensive knowledge of stochastic properties of characteristics of pipe and
of its defects aids in embracing of Principle of maximum entropy
which allows to avoid doubtful and excessive preferences and detalization when choosing probability
distribution models for failure factors and for *inline inspection* measurements.

Package function `mepof()`

is designed to calculate probability of failure (POF) of the corroded pipe by
MC, assigning maximun entropy
for stochastic nature of corroded area length and depth, as well as engineering characteristics of pipe with
thermal-hydraulic regime perameters.

Heat loss is the energy characteristic of district heating networks. It is the amount of heat energy spent on the transportation and distribution of heat energy from the source to the consumers.

Heat losses depend on the operating temperature, technical condition, volume and configuration of the district heating network, as well as on climatic factors. Heat losses are additive being the sum of the heat losses of individual pipeline segments.

Determination of heat losses for pipeline segments hereinafter is called
*heat loss localization*.

It is assumed that actual heat loss (*Q**A HL*) of
pipeline segment has two contributions: normative heat loss
(

*Q**A HL* =

Localization of *Q**E xNHL* is an important part of
health maintenance activities of district heating network operation. One
can determine

Minenergo-325 lists legally
affirmed maximum values of heat flux that is allowed to be emitted by
steel pipes (see `m325nhl()`

). Higher emission is treated as
*Q**E xNHL*.
Minenergo-278 gives method
for engineering calculation of

`m278hlcha()`

,
`m278hlund()`

, and `m278hlair()`

).Localization of extra-normative heat losses
*Q**E xNHL* could be performed if they know
thermal-hydraulic regime of district heating network for each pipeline
segment. In most cases thermal-hydraulic field (values of temperature,
pressure and heat carrier consumption) is measured only on heat-supply
origins and near consumers, i.e. mostly on terminal nodes of the
pipeline network. Middle segments of the network are rarely equipped and
thus are not sensor-measured. For restoring of thermal-hydraulic field
at each pipeline segment they can trace temperature, pressure and
heat-carrier consumption using hydraulic and thermal laws and
engineering characteristics of each pipe. Since only normative values of
heat flux are accessible for calculations the restored thermal-hydraulic
field is a normative (not actual) one. Nevertheless, even tracing small
networks may produce local inconsistencies in restored normative field
and those facts signal for possible extra-normative heat-losses in-situ.
In accordance to sensor positions forward (see

`m325tracefw()`

,
`m325traceline()`

) and backward (see `m325tracebw()`

,
`m325traceline(forward = FALSE)`

) tracing can be performed for the
linear and the bunched pipelines on the basis of
Minenergo-325 norms.**Any scripts or data that you put into this service are public.**

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.