Skip to content

Commit

Permalink
Implement class method to split boreholes
Browse files Browse the repository at this point in the history
  • Loading branch information
MassimoCimmino committed May 20, 2021
1 parent c37c58e commit 979209d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 45 deletions.
39 changes: 38 additions & 1 deletion pygfunction/boreholes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,43 @@ def position(self):
pos = (self.x, self.y)
return pos

def segments(self, nSegments):
"""
Split a borehole into segments.
Parameters
----------
nSegments : int
Number of segments.
Returns
-------
boreSegments : list
List of borehole segments.
Examples
--------
>>> b1 = gt.boreholes.Borehole(H=150., D=4., r_b=0.075, x=5., y=0.)
>>> b1.segments(5)
"""
boreSegments = []
for i in range(nSegments):
# Divide borehole into segments of equal length
H = self.H / nSegments
# Buried depth of the i-th segment
D = self.D + i * self.H / nSegments * np.cos(self.tilt)
# x-position
x = self.x + i * self.H / nSegments * np.sin(self.tilt) * np.cos(self.orientation)
# y-position
y = self.y + i * self.H / nSegments * np.sin(self.tilt) * np.sin(self.orientation)
# Add to list of segments
boreSegments.append(
Borehole(H, D, self.r_b, x, y,
tilt=self.tilt,
orientation=self.orientation))
return boreSegments


def find_duplicates(boreField, disp=False):
"""
Expand Down Expand Up @@ -547,7 +584,7 @@ def visualize_field(borefield):
y_H = y + borehole.H*np.sin(borehole.tilt)*np.sin(borehole.orientation)
z_H = borehole.D + borehole.H*np.cos(borehole.tilt)
# Add current borehole to the figure
ax1.plot(np.atleast_1d(x), np.atleast_1d(y), np.atleast_1d(borehole.D),
ax1.plot(np.atleast_1d(x), np.atleast_1d(y), -np.atleast_1d(borehole.D),
'ko')
ax1.plot(np.array([x, x_H]),
np.array([y, y_H]),
Expand Down
48 changes: 4 additions & 44 deletions pygfunction/gfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,8 +1681,7 @@ def thermal_response_factors(self, time, alpha, kind='linear'):

for i in range(nBoreholes):
# Segments of the receiving borehole
b2 = self._borehole_segments_one_borehole(
self.boreholes[i], self.nSegments)
b2 = self.boreholes[i].segments(self.nSegments)
# -----------------------------------------------------------------
# Segment-to-segment thermal response factors for same-borehole
# thermal interactions
Expand All @@ -1702,8 +1701,7 @@ def thermal_response_factors(self, time, alpha, kind='linear'):
# Segments of the emitting borehole
b1 = [seg
for b in self.boreholes[i+1:]
for seg in self._borehole_segments_one_borehole(
b, self.nSegments)]
for seg in b.segments(self.nSegments)]
h = finite_line_source(time, alpha, b1, b2)
# Broadcast values to h_ij matrix
for j in range(i+1, nBoreholes):
Expand All @@ -1727,18 +1725,6 @@ def thermal_response_factors(self, time, alpha, kind='linear'):

return h_ij

def _borehole_segments_one_borehole(self, borehole, nSegments):
boreSegments = []
for i in range(nSegments):
# Divide borehole into segments of equal length
H = borehole.H / nSegments
# Buried depth of the i-th segment
D = borehole.D + i * borehole.H / nSegments
# Add to list of segments
boreSegments.append(
Borehole(H, D, borehole.r_b, borehole.x, borehole.y))
return boreSegments


class _Similarities(_BaseSolver):
"""
Expand Down Expand Up @@ -1983,32 +1969,6 @@ def find_similarities(self):

return

def _borehole_segments_one_borehole(self, borehole):
"""
Split a borehole into segments.
Parameters
----------
borehole : Borehole object
Borehole to be split into segments.
Returns
-------
boreSegments : list
List of borehole segments.
"""
boreSegments = []
for i in range(self.nSegments):
# Divide borehole into segments of equal length
H = borehole.H / self.nSegments
# Buried depth of the i-th segment
D = borehole.D + i * borehole.H / self.nSegments
# Add to list of segments
boreSegments.append(
Borehole(H, D, borehole.r_b, borehole.x, borehole.y))
return boreSegments

def _compare_boreholes(self, borehole1, borehole2):
"""
Compare two boreholes and checks if they have the same dimensions :
Expand Down Expand Up @@ -2309,8 +2269,8 @@ def _map_axial_segment_pairs(self, borehole1, borehole2,
# Find segment pairs for the image FLS solution
compare_pairs = self._compare_image_pairs
# Dive both boreholes into segments
segments1 = self._borehole_segments_one_borehole(borehole1)
segments2 = self._borehole_segments_one_borehole(borehole2)
segments1 = borehole1.segments(self.nSegments)
segments2 = borehole2.segments(self.nSegments)
# Segments have equal lengths
H1 = segments1[0].H
H2 = segments2[0].H
Expand Down

0 comments on commit 979209d

Please sign in to comment.