-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from wouterpeere/issue332-add-u-bend-in-press…
…ure-drop Issue332 add u bend in pressure drop
- Loading branch information
Showing
8 changed files
with
177 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import copy | ||
|
||
import numpy as np | ||
import pygfunction as gt | ||
|
||
from GHEtool import * | ||
from GHEtool.VariableClasses.PipeData import _PipeData | ||
from math import pi | ||
|
||
|
||
def calculate_pressure_drop_horizontal(fluid_data: FluidData, r_in: float, length: float, minor_losses: float) -> float: | ||
""" | ||
This function calculates the pressure drop in the horizontal pipe. | ||
Parameters | ||
---------- | ||
fluid_data : FluidData | ||
Fluid data | ||
r_in : float | ||
Inner pipe diameter [m] | ||
length : float | ||
Length of the pipe [m] | ||
minor_losses : float | ||
Coefficient for minor losses [-] | ||
Returns | ||
------- | ||
Pressure drop : float | ||
Pressure drop [kPa] | ||
""" | ||
# Darcy fluid factor | ||
fd = gt.pipes.fluid_friction_factor_circular_pipe( | ||
fluid_data.mfr, | ||
r_in, | ||
fluid_data.mu, | ||
fluid_data.rho, | ||
1e-6) | ||
A = pi * r_in ** 2 | ||
V = (fluid_data.vfr / 1000) / A | ||
|
||
return ((fd * length / (2 * r_in) + minor_losses) * fluid_data.rho * V ** 2 / 2) / 1000 | ||
|
||
|
||
def calculate_total_pressure_drop(pipe_data: _PipeData, fluid_data: FluidData, borehole_length: float, | ||
r_in: float, distance: float, minor_losses: float) -> float: | ||
""" | ||
This function calculates the total pressure drop of your system, assuming every borehole is brought individually | ||
to the main collector. | ||
Parameters | ||
---------- | ||
pipe_data : PipeData | ||
Pipe data | ||
fluid_data : FluidData | ||
Fluid data | ||
borehole_length : float | ||
Borehole length [m] | ||
r_in : float | ||
Inner pipe diameter [m] | ||
distance : float | ||
distance from the borehole to the collector [m] | ||
minor_losses : float | ||
Coefficient for minor losses [-] | ||
Returns | ||
------- | ||
Pressure drop : float | ||
Pressure drop [kPa] | ||
""" | ||
|
||
return pipe_data.pressure_drop(fluid_data, borehole_length) + \ | ||
calculate_pressure_drop_horizontal(fluid_data, r_in, distance * 2, minor_losses) | ||
|
||
|
||
def create_pressure_drop_curve(pipe_data: _PipeData, fluid_data: FluidData, borehole_length: float, | ||
r_in: float, distance: float, minor_losses: float, range: float = 2, | ||
datapoints: int = 30) -> tuple: | ||
""" | ||
This function calculates the pressure drop for different flow rates. | ||
Parameters | ||
---------- | ||
pipe_data : PipeData | ||
Pipe data | ||
fluid_data : FluidData | ||
Fluid data | ||
borehole_length : float | ||
Borehole length [m] | ||
r_in : float | ||
Inner pipe diameter [m] | ||
distance : float | ||
distance from the borehole to the collector [m] | ||
minor_losses : float | ||
Coefficient for minor losses [-] | ||
range : float | ||
Multiplier of the flow rate for the range of the data. | ||
datapoints : int | ||
Number of datapoints. | ||
Returns | ||
------- | ||
pressure drop, flow rates : np.ndarray, np.ndarray | ||
Array with the pressure drops [kPa], Array with the flow rates per borehole [l/s] | ||
""" | ||
|
||
flow_rates = np.linspace(0, range * fluid_data.vfr, datapoints) | ||
pressure_drops = np.zeros(flow_rates.shape) | ||
|
||
new_fluid = copy.copy(fluid_data) | ||
|
||
for i, val in enumerate(flow_rates): | ||
new_fluid.vfr = val | ||
pressure_drops[i] = calculate_total_pressure_drop(pipe_data, new_fluid, borehole_length, r_in, distance, | ||
minor_losses) | ||
|
||
return np.nan_to_num(pressure_drops), flow_rates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import numpy as np | ||
|
||
from GHEtool import * | ||
from GHEtool.Methods.pressure_drop_calculation import calculate_pressure_drop_horizontal, calculate_total_pressure_drop, \ | ||
create_pressure_drop_curve | ||
|
||
|
||
def test_horizontal(): | ||
fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3) | ||
|
||
assert np.isclose(calculate_pressure_drop_horizontal(fluid_data, 0.02 - 0.0037 / 2, 15, 0), 0.26307939880441045) | ||
assert np.isclose(calculate_pressure_drop_horizontal(fluid_data, 0.02 - 0.0037 / 2, 15, 2), 0.3005010707434382) | ||
|
||
|
||
def test_total_pressure_drop(): | ||
single_u = SingleUTube(1.5, 0.013, 0.016, 0.4, 0.035) | ||
double_u = DoubleUTube(1.5, 0.013, 0.016, 0.4, 0.035) | ||
fluid_data = FluidData(0.3, 0.568, 998, 4180, 1e-3) | ||
|
||
assert np.isclose(calculate_total_pressure_drop(single_u, fluid_data, 100, 0.02 - 0.0037 / 2, 10, 2), | ||
35.307092460895696) | ||
assert np.isclose(calculate_total_pressure_drop(double_u, fluid_data, 100, 0.02 - 0.0037 / 2, 10, 2), | ||
11.139813565855187) | ||
|
||
|
||
def test_range_pressure_drop(): | ||
single_u = SingleUTube(1.5, 0.013, 0.016, 0.4, 0.035) | ||
fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3) | ||
|
||
pressure, _ = create_pressure_drop_curve(single_u, fluid_data, 100, 0.02 - 0.0037 / 2, 10, 2) | ||
assert np.allclose(pressure, np.array( | ||
[0., 0.2531815, 0.50685423, 0.76101819, 1.90189987, 2.7952022, 3.8125133, 4.961455, 6.23750754, 7.63693955, | ||
9.15659304, 10.79374378, 12.54600583, 14.41126361, 16.38762198, 18.4733661, 20.6669424, 22.96692063, | ||
25.37198565, 27.88092014, 30.49259237, 33.20594602, 36.01999211, 38.93380122, 41.94649778, 45.05725469, | ||
48.26528879, 51.56985689, 54.97025229, 58.46580177])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = GHEtool | ||
version = 2.3.1 | ||
version = 2.3.2dev0 | ||
author = Wouter Peere | ||
author_email = [email protected] | ||
description = Python package for borefield sizing | ||
|