Skip to content

Commit

Permalink
Merge pull request #90 from MassimoCimmino/issue78_optimizeIntegrals
Browse files Browse the repository at this point in the history
Issue78 optimize integrals
  • Loading branch information
MassimoCimmino authored May 20, 2021
2 parents 77abb30 + fc6a817 commit 127e52b
Show file tree
Hide file tree
Showing 4 changed files with 768 additions and 361 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* [Issue 75](https://github.com/MassimoCimmino/pygfunction/issues/75) - New module `media` with properties of brine mixtures.
* [Issue 81](https://github.com/MassimoCimmino/pygfunction/issues/81) - Added functions to find a remove duplicate boreholes.

### Enhancements

* [Issue 78](https://github.com/MassimoCimmino/pygfunction/issues/78) - Optimization of solvers for the calculation of g-functions. The finite line source (FLS) solution is now calculated using `scipy.integrate.quad_vec` which significantly improves calculation time over `scipy.integrate.quad`. The identification of similarities in the 'similarities' solver has also been refactored to identify similarities between boreholes as an intermediate step before identifying similarities between segments. The calculation time for the identification of similarities is significantly decreased.

### Bug fixes

* [Issue 86](https://github.com/MassimoCimmino/pygfunction/issues/86) - Documentation is now built using Python 3 to support Python 3 features in the code.
Expand Down
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
Loading

0 comments on commit 127e52b

Please sign in to comment.