# NOT RUN {
# Consider 4-segment tracing path depicted in ?m325regtrace help page.
# First, let sensor readings for forward tracing:
t_fw <- 130 # [<U+00B0>C]
p_fw <- .588399*all.equal(.588399, mpa_kgf(6)) # [MPa]
g_fw <- 250 # [ton/hour]
# Let discharges to network for each pipeline segment are somehow determined as
discharges <- seq(0, 30, 10) # [ton/hour]
# }
# NOT RUN {
# 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
# }
# NOT RUN {
# Next consider values of traced regime as sensor readings for backward tracing:
t_bw <- 127.3367 # [<U+00B0>C]
p_bw <- .5870330 # [MPa]
g_bw <- 190 # [ton/hour]
# Then the calculated regime (red squares) for backward tracing is
# }
# NOT RUN {
regime_bw <- m325traceline(t_bw, p_bw, g_bw, discharges, forward = FALSE)
print(regime_bw)
# $temperature
# [1] 129.9953 129.1769 128.4254 127.9619
#
# $pressure
# [1] 0.5883998 0.5878611 0.5874228 0.5872144
#
# $consumption
# [1] 250 250 240 220
# Let compare sensor readings with backward tracing results:
tracing <- with(regime_bw, {
lambda <- function(val, constraint)
c(val, constraint, constraint - val,
abs(constraint - val)*100/constraint)
first <- 1
structure(
rbind(
lambda(temperature[first], t_fw),
lambda(pressure[first], p_fw),
lambda(consumption[first], g_fw)
),
dimnames = list(
c("temperature", "pressure", "consumption"),
c("sensor.value", "traced.value", "abs.discr", "rel.discr")
)
)
})
print(tracing)
# sensor.value traced.value abs.discr rel.discr
# temperature 130.000000 129.9952943 4.705723e-03 0.0036197868
# pressure 0.588399 0.5883998 -8.290938e-07 0.0001409067
# consumption 250.000000 250.0000000 0.000000e+00 0.0000000000
# }
Run the code above in your browser using DataLab