Skip to content

Commit

Permalink
First implementation of the tilt property
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterpeere committed Jan 20, 2025
1 parent e5811f1 commit c5465d0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
10 changes: 7 additions & 3 deletions GHEtool/Borefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import copy
import math
import warnings
from math import pi
from typing import Tuple, Union
Expand Down Expand Up @@ -133,6 +134,7 @@ def __init__(
self.Tf_min: float = 0.0 # minimum temperature of the fluid

# initiale borehole
self.avg_tilt: float = 0.
self.borehole = Borehole()

# initiate different sizing
Expand Down Expand Up @@ -204,7 +206,7 @@ def depth(self) -> float:

def calculate_depth(self, borehole_length: float, buried_depth: float) -> float:
"""
This function calculates the depth of the borehole.
This function calculates the depth of the borehole given the average tilt of the borefield.
Parameters
----------
Expand All @@ -218,8 +220,9 @@ def calculate_depth(self, borehole_length: float, buried_depth: float) -> float:
float
Depth of the borehole [m]
"""
# TODO take into account tilt
return borehole_length + buried_depth
if np.isclose(self.avg_tilt, 0):
return borehole_length + buried_depth
return np.average([bor.H * math.cos(bor.tilt) for bor in self.borefield]) + buried_depth

@property
def H(self) -> float:
Expand Down Expand Up @@ -458,6 +461,7 @@ def borefield(self, borefield: list[gt.boreholes.Borehole] = None) -> None:
self.D = np.average([bor.D for bor in borefield])
self.r_b = np.average([bor.r_b for bor in borefield])
self._H = np.average([bor.H for bor in borefield])
self.avg_tilt = np.average([bor.tilt for bor in borefield])
self.gfunction_calculation_object.remove_previous_data()
unequal_length = np.any([bor.H != borefield[0].H for bor in borefield])
if unequal_length:
Expand Down
7 changes: 4 additions & 3 deletions GHEtool/VariableClasses/CustomGFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file contains both the CustomGFunction class and all the relevant information w.r.t. custom gfunctions.
"""
import copy
import math
import pickle
import warnings
from typing import List, Union
Expand Down Expand Up @@ -225,10 +226,10 @@ def create_custom_dataset(self, borefield: List[gt.boreholes.Borehole], alpha: U

# calculate borehole buried depth
D = np.average([bor.D for bor in borefield])
# TODO correct for tilt
tilt = np.average([bor.tilt for bor in borefield])
depth = borehole_length * math.cos(tilt) + D
gfunc_uniform_T = gt.gfunction.gFunction(borefield,
alpha if isinstance(alpha, float) else alpha(borehole_length + D,
D),
alpha if isinstance(alpha, float) else alpha(depth, D),
self.time_array, options=self.options,
method=self.options["method"])

Expand Down
16 changes: 16 additions & 0 deletions GHEtool/test/unit-tests/test_main_class.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# noinspection PyPackageRequirements
import copy
import math

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -70,6 +71,7 @@ def test_nb_of_boreholes():
borefield.set_ground_parameters(data_ground_flux)
assert borefield.number_of_boreholes == 120
borefield.set_borefield(gt.boreholes.rectangle_field(5, 5, 6, 6, 110, 0.1, 0.07))
assert np.isclose(borefield.avg_tilt, 0)
assert np.isclose(borefield.H, 110)
assert np.isclose(borefield.r_b, 0.07)
assert np.isclose(borefield.D, 0.1)
Expand All @@ -78,11 +80,13 @@ def test_nb_of_boreholes():
assert np.any(borefield.gfunction_calculation_object.borehole_length_array)
borefield.borefield = gt.boreholes.rectangle_field(6, 5, 6, 6, 100, 1, 0.075)
assert not np.any(borefield.gfunction_calculation_object.borehole_length_array)
assert np.isclose(borefield.avg_tilt, 0)
assert np.isclose(borefield.H, 100)
assert np.isclose(borefield.r_b, 0.075)
assert np.isclose(borefield.D, 1)
borefield.gfunction(5000, 110)
assert np.any(borefield.gfunction_calculation_object.borehole_length_array)
assert np.isclose(borefield.avg_tilt, 0)
assert borefield.number_of_boreholes == 30
borefield.borefield = None
assert not np.any(borefield.gfunction_calculation_object.borehole_length_array)
Expand All @@ -91,6 +95,7 @@ def test_nb_of_boreholes():
borefield.borefield = gt.boreholes.rectangle_field(6, 5, 6, 6, 100, 1, 0.075)
borefield.gfunction(5000, 110)
assert np.any(borefield.gfunction_calculation_object.borehole_length_array)
assert np.isclose(borefield.avg_tilt, 0)
borefield.set_borefield(None)
assert not np.any(borefield.gfunction_calculation_object.borehole_length_array)
assert borefield.number_of_boreholes == 0
Expand All @@ -105,6 +110,17 @@ def test_set_borefield():
assert borefield.H == 125


def test_tilt():
borefield = Borefield()
borefield.set_borefield([
gt.boreholes.Borehole(100, 4, 0.075, 0, 0),
gt.boreholes.Borehole(150, 4, 0.075, 10, 0, tilt=math.pi / 9)
])
assert borefield.H == 125
assert np.isclose(borefield.avg_tilt, math.pi / 18)
assert np.isclose(borefield.depth, 4 + (100 + 150 * math.cos(math.pi / 9)) / 2)


def test_gfunction_with_irregular_borehole_depth():
borefield = Borefield()
borefield.ground_data = ground_data_constant
Expand Down

0 comments on commit c5465d0

Please sign in to comment.