Skip to content

Commit 38b426d

Browse files
committedMar 15, 2025·
Merge remote-tracking branch 'origin/main' into issue308-speed-up-optimise-energy-method
2 parents 95d000a + b58cdd2 commit 38b426d

File tree

8 files changed

+177
-16
lines changed

8 files changed

+177
-16
lines changed
 

‎CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111

1212
- Added support for DHW profiles in optimisation (issue #272).
1313
- Added Prandtl number to FluidData class (issue #326).
14+
- Pressure drop calculation for horizontal pipe and total system (issue #332).
15+
16+
## Changed
17+
18+
- Added U-bend to the pressure drop calculation of the pipe (issue #332).
1419

1520
## [2.3.1] - 2025-01-23
1621

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import copy
2+
3+
import numpy as np
4+
import pygfunction as gt
5+
6+
from GHEtool import *
7+
from GHEtool.VariableClasses.PipeData import _PipeData
8+
from math import pi
9+
10+
11+
def calculate_pressure_drop_horizontal(fluid_data: FluidData, r_in: float, length: float, minor_losses: float) -> float:
12+
"""
13+
This function calculates the pressure drop in the horizontal pipe.
14+
15+
Parameters
16+
----------
17+
fluid_data : FluidData
18+
Fluid data
19+
r_in : float
20+
Inner pipe diameter [m]
21+
length : float
22+
Length of the pipe [m]
23+
minor_losses : float
24+
Coefficient for minor losses [-]
25+
26+
Returns
27+
-------
28+
Pressure drop : float
29+
Pressure drop [kPa]
30+
"""
31+
# Darcy fluid factor
32+
fd = gt.pipes.fluid_friction_factor_circular_pipe(
33+
fluid_data.mfr,
34+
r_in,
35+
fluid_data.mu,
36+
fluid_data.rho,
37+
1e-6)
38+
A = pi * r_in ** 2
39+
V = (fluid_data.vfr / 1000) / A
40+
41+
return ((fd * length / (2 * r_in) + minor_losses) * fluid_data.rho * V ** 2 / 2) / 1000
42+
43+
44+
def calculate_total_pressure_drop(pipe_data: _PipeData, fluid_data: FluidData, borehole_length: float,
45+
r_in: float, distance: float, minor_losses: float) -> float:
46+
"""
47+
This function calculates the total pressure drop of your system, assuming every borehole is brought individually
48+
to the main collector.
49+
50+
Parameters
51+
----------
52+
pipe_data : PipeData
53+
Pipe data
54+
fluid_data : FluidData
55+
Fluid data
56+
borehole_length : float
57+
Borehole length [m]
58+
r_in : float
59+
Inner pipe diameter [m]
60+
distance : float
61+
distance from the borehole to the collector [m]
62+
minor_losses : float
63+
Coefficient for minor losses [-]
64+
65+
Returns
66+
-------
67+
Pressure drop : float
68+
Pressure drop [kPa]
69+
"""
70+
71+
return pipe_data.pressure_drop(fluid_data, borehole_length) + \
72+
calculate_pressure_drop_horizontal(fluid_data, r_in, distance * 2, minor_losses)
73+
74+
75+
def create_pressure_drop_curve(pipe_data: _PipeData, fluid_data: FluidData, borehole_length: float,
76+
r_in: float, distance: float, minor_losses: float, range: float = 2,
77+
datapoints: int = 30) -> tuple:
78+
"""
79+
This function calculates the pressure drop for different flow rates.
80+
81+
Parameters
82+
----------
83+
pipe_data : PipeData
84+
Pipe data
85+
fluid_data : FluidData
86+
Fluid data
87+
borehole_length : float
88+
Borehole length [m]
89+
r_in : float
90+
Inner pipe diameter [m]
91+
distance : float
92+
distance from the borehole to the collector [m]
93+
minor_losses : float
94+
Coefficient for minor losses [-]
95+
range : float
96+
Multiplier of the flow rate for the range of the data.
97+
datapoints : int
98+
Number of datapoints.
99+
100+
Returns
101+
-------
102+
pressure drop, flow rates : np.ndarray, np.ndarray
103+
Array with the pressure drops [kPa], Array with the flow rates per borehole [l/s]
104+
"""
105+
106+
flow_rates = np.linspace(0, range * fluid_data.vfr, datapoints)
107+
pressure_drops = np.zeros(flow_rates.shape)
108+
109+
new_fluid = copy.copy(fluid_data)
110+
111+
for i, val in enumerate(flow_rates):
112+
new_fluid.vfr = val
113+
pressure_drops[i] = calculate_total_pressure_drop(pipe_data, new_fluid, borehole_length, r_in, distance,
114+
minor_losses)
115+
116+
return np.nan_to_num(pressure_drops), flow_rates

‎GHEtool/VariableClasses/PipeData/CoaxialPipe.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def Re(self, fluid_data: FluidData) -> float:
140140
# Reynolds number
141141
return fluid_data.rho * V * D_h / fluid_data.mu
142142

143-
def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
143+
def pressure_drop(self, fluid_data: FluidData, borehole_length: float) -> float:
144144
"""
145145
Calculates the pressure drop across the entire borehole.
146146
It assumed that the U-tubes are all connected in parallel.
@@ -149,8 +149,8 @@ def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
149149
----------
150150
fluid_data: FluidData
151151
Fluid data
152-
borehole_depth : float
153-
Borehole depth [m]
152+
borehole_length : float
153+
Borehole length [m]
154154
155155
Returns
156156
-------
@@ -167,7 +167,10 @@ def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
167167
# Darcy-Wiesbach friction factor
168168
fd = gt.pipes.fluid_friction_factor_circular_pipe(
169169
fluid_data.mfr, r_h, fluid_data.mu, fluid_data.rho, self.epsilon)
170-
return (fd * (borehole_depth * 2) / (2 * r_h) * fluid_data.rho * V ** 2 / 2) / 1000
170+
171+
# add 0.2 for the local losses
172+
# (source: https://www.engineeringtoolbox.com/minor-loss-coefficients-pipes-d_626.html)
173+
return ((fd * (borehole_length * 2) / (2 * r_h) + 0.2) * fluid_data.rho * V ** 2 / 2) / 1000
171174

172175
def draw_borehole_internal(self, r_b: float) -> None:
173176
"""

‎GHEtool/VariableClasses/PipeData/MultipleUTube.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import numpy as np
44
import pygfunction as gt
55
import matplotlib.pyplot as plt
6-
from math import pi
76

7+
from math import pi
88
from GHEtool.VariableClasses.PipeData._PipeData import _PipeData
99
from GHEtool.VariableClasses.FluidData import FluidData
1010

@@ -133,7 +133,7 @@ def Re(self, fluid_data: FluidData) -> float:
133133
(pi * self.r_in ** 2)
134134
return fluid_data.rho * u * self.r_in * 2 / fluid_data.mu
135135

136-
def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
136+
def pressure_drop(self, fluid_data: FluidData, borehole_length: float) -> float:
137137
"""
138138
Calculates the pressure drop across the entire borehole.
139139
It assumed that the U-tubes are all connected in parallel.
@@ -142,8 +142,8 @@ def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
142142
----------
143143
fluid_data: FluidData
144144
Fluid data
145-
borehole_depth : float
146-
Borehole depth [m]
145+
borehole_length : float
146+
Borehole length [m]
147147
148148
Returns
149149
-------
@@ -161,7 +161,9 @@ def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
161161
A = pi * self.r_in ** 2
162162
V = (fluid_data.vfr / 1000) / A / self.number_of_pipes
163163

164-
return (fd * (borehole_depth * 2) / (2 * self.r_in) * fluid_data.rho * V ** 2 / 2) / 1000
164+
# add 0.2 for the local losses
165+
# (source: https://www.engineeringtoolbox.com/minor-loss-coefficients-pipes-d_626.html)
166+
return ((fd * (borehole_length * 2) / (2 * self.r_in) + 0.2) * fluid_data.rho * V ** 2 / 2) / 1000
165167

166168
def draw_borehole_internal(self, r_b: float) -> None:
167169
"""

‎GHEtool/VariableClasses/PipeData/_PipeData.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def Re(self, fluid_data: FluidData) -> float:
8181
"""
8282

8383
@abc.abstractmethod
84-
def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
84+
def pressure_drop(self, fluid_data: FluidData, borehole_length: float) -> float:
8585
"""
8686
Calculates the pressure drop across the entire borehole.
8787
It assumed that the U-tubes are all connected in parallel.
@@ -90,8 +90,8 @@ def pressure_drop(self, fluid_data: FluidData, borehole_depth: float) -> float:
9090
----------
9191
fluid_data: FluidData
9292
Fluid data
93-
borehole_depth : float
94-
Borehole depth [m]
93+
borehole_length : float
94+
Borehole length [m]
9595
9696
Returns
9797
-------

‎GHEtool/test/unit-tests/test_pipedata.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ def test_pressure_drop():
214214
fluid_data = FluidData(0.3, 0.568, 998, 4180, 1e-3)
215215
single = MultipleUTube(1, 0.02, 0.02, 0.4, 0.05, 1)
216216
double = MultipleUTube(1, 0.013, 0.016, 0.4, 0.05, 2)
217-
assert np.isclose(single.pressure_drop(fluid_data, 100), 4.4688388696204555)
218-
assert np.isclose(double.pressure_drop(fluid_data, 100), 10.339838859988387)
217+
assert np.isclose(single.pressure_drop(fluid_data, 100), 4.474549607676448)
218+
assert np.isclose(double.pressure_drop(fluid_data, 100), 10.347836812519452)
219219
coaxial = CoaxialPipe(r_in_in, r_in_out, r_out_in, r_out_out, k_p, k_g, is_inner_inlet=True)
220-
assert np.isclose(coaxial.pressure_drop(fluid_data, 100), 0.16366613552554135)
220+
assert np.isclose(coaxial.pressure_drop(fluid_data, 100), 0.1639237572210245)
221221

222222

223223
def test_repr_():
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import numpy as np
2+
3+
from GHEtool import *
4+
from GHEtool.Methods.pressure_drop_calculation import calculate_pressure_drop_horizontal, calculate_total_pressure_drop, \
5+
create_pressure_drop_curve
6+
7+
8+
def test_horizontal():
9+
fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3)
10+
11+
assert np.isclose(calculate_pressure_drop_horizontal(fluid_data, 0.02 - 0.0037 / 2, 15, 0), 0.26307939880441045)
12+
assert np.isclose(calculate_pressure_drop_horizontal(fluid_data, 0.02 - 0.0037 / 2, 15, 2), 0.3005010707434382)
13+
14+
15+
def test_total_pressure_drop():
16+
single_u = SingleUTube(1.5, 0.013, 0.016, 0.4, 0.035)
17+
double_u = DoubleUTube(1.5, 0.013, 0.016, 0.4, 0.035)
18+
fluid_data = FluidData(0.3, 0.568, 998, 4180, 1e-3)
19+
20+
assert np.isclose(calculate_total_pressure_drop(single_u, fluid_data, 100, 0.02 - 0.0037 / 2, 10, 2),
21+
35.307092460895696)
22+
assert np.isclose(calculate_total_pressure_drop(double_u, fluid_data, 100, 0.02 - 0.0037 / 2, 10, 2),
23+
11.139813565855187)
24+
25+
26+
def test_range_pressure_drop():
27+
single_u = SingleUTube(1.5, 0.013, 0.016, 0.4, 0.035)
28+
fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3)
29+
30+
pressure, _ = create_pressure_drop_curve(single_u, fluid_data, 100, 0.02 - 0.0037 / 2, 10, 2)
31+
assert np.allclose(pressure, np.array(
32+
[0., 0.2531815, 0.50685423, 0.76101819, 1.90189987, 2.7952022, 3.8125133, 4.961455, 6.23750754, 7.63693955,
33+
9.15659304, 10.79374378, 12.54600583, 14.41126361, 16.38762198, 18.4733661, 20.6669424, 22.96692063,
34+
25.37198565, 27.88092014, 30.49259237, 33.20594602, 36.01999211, 38.93380122, 41.94649778, 45.05725469,
35+
48.26528879, 51.56985689, 54.97025229, 58.46580177]))

‎setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = GHEtool
3-
version = 2.3.1
3+
version = 2.3.2dev0
44
author = Wouter Peere
55
author_email = wouter@ghetool.eu
66
description = Python package for borefield sizing

0 commit comments

Comments
 (0)
Please sign in to comment.