Massively trace backwards thermal-hydraulic regime for district heating network
Source:R/tracebw.R
tracebw.Rd
Trace values of thermal-hydraulic regime (temperature, pressure, flow rate, and other) in the bunched pipeline against the flow direction using user-provided values of specific heat loss power.
Algorithm also suits for partially measurable district heating network with massive data lack conditions, when there are no temperature and pressure sensor readings on the majority of terminal nodes.
Usage
tracebw(
sender = 6,
acceptor = 7,
temperature = 70,
pressure = pipenostics::mpa_kgf(6),
flow_rate = 20,
d = 100,
wth = 8,
len = 72.446,
loss = 78.4,
roughness = 0.001,
inlet = 0.5,
outlet = 1,
method = "romeo",
opinion = "median",
verbose = TRUE,
csv = FALSE,
file = "tracebw.csv"
)
Arguments
- sender
identifier of the node which heat carrier flows out. Type: any type that can be painlessly coerced to character by
as.character
.- acceptor
identifier of the node which heat carrier flows in. According to topology of test bench considered this identifier should be unique for every row. Type: any type that can be painlessly coerced to character by
as.character
.- temperature
sensor-measured temperature of heat carrier (water) sensor-measured on the terminal acceptor node, [°C]. Use
NA_float_
s for (terminal) nodes without temperature sensor. Type:assert_double
.- pressure
sensor-measured absolute pressure of heat carrier (water) inside the pipe (i.e. acceptor's incoming edge), [MPa]. Type:
assert_double
.- flow_rate
sensor-measured amount of heat carrier (water) on terminal node that is transferred by pipe (i.e. acceptor's incoming edge) during a period, [ton/h]. Type:
assert_double
. UseNA_float_
s for nodes without flow rate sensor.- d
outside diameter of pipe (i.e.diameter of acceptor's incoming edge), [mm]. Type:
assert_double
.- wth
wall thickness of pipe, [mm]. Type:
assert_double
.- len
pipe length (i.e. length of acceptor's incoming edge), [m]. Type:
assert_double
.- loss
user-provided value of specific heat loss power for each pipe, [kcal/m/h]. Values of the argument can be obtained experimentally, or taken from regulatory documents. Type:
assert_double
.- roughness
roughness of internal wall of pipe (i.e. acceptor's incoming edge), [m]. Type:
assert_double
.- inlet
elevation of pipe inlet, [m]. Type:
assert_double
.- outlet
elevation of pipe outlet, [m]. Type:
assert_double
.- method
method of determining Darcy friction factor:
romeo
vatankhah
buzzelli
Type:
assert_choice
. For more details seedropp
.- opinion
method for aggregating values of regime parameters on each node for the next tracing step:
mean
values of parameter are averaged before the next tracing step
median
median of parameter values are used for the next tracing step
Type:
assert_choice
.- verbose
logical indicator: should they watch tracing process on console? Type:
assert_flag
.- csv
logical indicator: should they incrementally dump results to csv- file while tracing? Type:
assert_flag
.- file
name of csv-file which they dump results to. Type:
assert_character
of length 1 that can be used safely to create a file and write to it.
Value
data.frame
containing results (detailed log) of tracing in
narrow format:
node
Tracing job. Identifier of the node which regime parameters is calculated for. Values in this vector are identical to those in argument
acceptor
. Type:assert_character
.tracing
Tracing job. Identifiers of nodes from which regime parameters are traced for the given node. Identifier
sensor
is used when values of regime parameters for the node are sensor readings. Type:assert_character
.backward
Tracing job. Identifier of tracing direction. It constantly equals to
TRUE
. Type:assert_logical
.aggregation
Tracing job. Identifier of aggregation method: span, median, mean, or identity. Type:
assert_character
.loss
Traced thermal hydraulic regime. Normative specific heat loss power of adjacent pipe, [kcal/m/h]. Type:
assert_double
.flux
Traced thermal hydraulic regime. Normative heat flux of adjacent pipe, [W/m²]. Type:
assert_double
.Q
Traced thermal hydraulic regime. Normative heat loss of adjacent pipe per day, [kcal]. Type:
assert_character
.temperature
Traced thermal hydraulic regime. Traced temperature of heat carrier (water) that is associated with the node, [°C]. Type:
assert_double
.pressure
Traced thermal hydraulic regime. Traced pressure of heat carrier (water) that is associated with the node, [MPa]. Type:
assert_double
.flow_rate
Traced thermal hydraulic regime. Traced flow rate of heat carrier (water) that is associated with the node, [ton/h]. Type:
assert_double
.job
Tracing job. Value of tracing job counter. Type:
assert_count
.
Type: assert_data_frame
.
Details
They consider the topology of district heating network represented by
m325nxdata
:
The network may be partially sensor-equipped too:
In latter case no more than two nodes must be equipped with pressure and temperature sensors whereas for other nodes only flow rate sensors must be installed.
Tracing starts from sensor-equipped nodes and goes backwards, i.e against the flow direction.
Though some input arguments are natively vectorized their individual values
all relate to common part of district heating network, i.e. associated with
common object. It is due to isomorphism between vector representation and
directed graph of this network. For more details of isomorphic topology
description see m325nxdata
.
Before tracing starts for the next node, previously calculated values of thermal-hydraulic parameters are aggregated by either averaging or by median. The latter seems more robust for avoiding strong influence of possible outliers which may come from actual heating transfer anomalies, erroneous sensor readings or wrong pipeline specifications.
Aggregation for values of flow rate at the node is always sum
.
See also
Other Regime tracing:
dropg()
,
dropp()
,
dropt()
,
m325tracebw()
,
m325tracefw()
,
m325traceline()
,
tracefw()
,
traceline()
Examples
library(pipenostics)
# It is possible to run without specification of argument values:
tracebw()
#>
#> 2025-09-17 17:54:00.663418 tracebw | start backward tracing; segments 1;
#> 2025-09-17 17:54:00.663418 tracebw | start job; job 0;
#> 2025-09-17 17:54:00.663418 tracebw | now process; 1 node(s); [7]
#> 2025-09-17 17:54:00.663418 tracebw | seen tracing; [1/1] are TP-sensor-equipped;
#> 2025-09-17 17:54:00.663418 tracebw | tracing loss;;
#> 2025-09-17 17:54:00.663418 tracebw | OK! Specific heat loss power traced from 1 nodes;[7];
#> 2025-09-17 17:54:00.663418 tracebw | tracing heat flux;;
#> 2025-09-17 17:54:00.663418 tracebw | OK! Heat flux traced from 1 nodes;[7];
#> 2025-09-17 17:54:00.663418 tracebw | tracing heat loss per day;;
#> 2025-09-17 17:54:00.663418 tracebw | OK! Heat loss per day traced from 1 nodes;[7];
#> 2025-09-17 17:54:00.663418 tracebw | tracing temperature;;
#> 2025-09-17 17:54:00.663418 tracebw | OK! Temperature traced from 1 nodes;[7];
#> 2025-09-17 17:54:00.663418 tracebw | tracing pressure;;
#> 2025-09-17 17:54:00.663418 tracebw | OK! Pressure traced from 1 nodes;[7];
#> 2025-09-17 17:54:00.663418 tracebw | tracing flow_rate;;
#> 2025-09-17 17:54:00.663418 tracebw | finish job; job 0; processed node(s) 1
#> 2025-09-17 17:54:00.663418 tracebw | finish backward tracing;;
#> node tracing backward aggregation loss flux Q temperature
#> 1 7 sensor TRUE identity 78.4 290.2324 136314.4 70
#> span 7 sensor TRUE span 0.0 0.0000 0.0 0
#> median 7 sensor TRUE median 78.4 290.2324 136314.4 70
#> mean 7 sensor TRUE mean 78.4 290.2324 136314.4 70
#> pressure flow_rate job
#> 1 0.588399 20 0
#> span 0.000000 20 0
#> median 0.588399 20 0
#> mean 0.588399 20 0
# Consider isomorphic representation of District Heating Network graph:
DHN <- m325nxdata
# * Adapt node identifiers for ordering representation simplification:
DHN[["sender"]] <- sprintf("N%02i", DHN[["sender"]])
DHN[["acceptor"]] <- sprintf("N%02i", DHN[["acceptor"]])
# * Provided actual values of specific heat loss power
# (say, field measurements) for each pipe in DHN, [kcal/m/h]:
actual_loss <- c(
96.2360000000000, 96.2880000000000, 70.5840000000000,
116.0449431257620, 70.7340165868372, 96.2114863150603,
78.4000000000000, 116.0158816197730, 28.1152000000000,
24.9182000000000, 116.6790503515620, 152.8311474487970,
152.7893321276950, 96.7331745004449, 96.6000000000000,
116.6668284940720, 24.9596000000000, 115.9228232554340,
28.1658000000000, 96.1226072815915, 77.8240000000000,
115.9455144867840, 70.6899252508703, 96.1840000000000,
96.2360000000000, 70.5400000000000
)
# * Remove inappropriate attributes of the graph:
DHN.1 <- DHN[,
setdiff(
colnames(DHN),
c("a", "year", "insulation", "laying", "beta", "exp5k")
)
]
# * Trace thermal-hydraulic regime for DHN:
tracebw_report <- do.call(
"tracebw", c(as.list(DHN.1), list(loss = actual_loss), verbose = FALSE)
)
# * If the actual values of specific heat loss power presented above are
# close to those in Minenergo-325, then the results of regime tracing match
# the normative procedure:
m325_report <- do.call("m325tracebw", c(as.list(DHN), verbose = FALSE))
stopifnot(
all.equal(tracebw_report$temperature, m325_report$temperature, tol = 1e-4),
all.equal(tracebw_report$pressure, m325_report$pressure, tol = 1e-4),
all.equal(tracebw_report$flow_rate, m325_report$flow_rate, tol = 1e-4)
)