Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue199 change integral bounds #201

Merged
merged 3 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [Issue 152](https://github.com/MassimoCimmino/pygfunction/issues/152) - Vectorized `coefficients_temperature` and `_general_solution` in `pipe` objects to accept depths `z` as an array. This speeds up calculations for `get_temperature` and `get_borehole_heat_extraction_rate` class methods.
* [Issue 183](https://github.com/MassimoCimmino/pygfunction/issues/183) - Vectorized `pipes.multipole()` and `pipes._Fmk()` to decrease the calculation time of `pipes.thermal_resistances()`. A `memoization` technique is implemented to reduce computation time for repeated function calls to further speed-up the initialization of `Pipe` and `Network` objects.
* [Issue 198](https://github.com/MassimoCimmino/pygfunction/issues/198) - Refactored the `'detailed'` solver to evaluate same-borehole thermal response factors in a single call to `finite_line_source_vectorized()`. This speeds up calculations of *g*-functions using the `'detailed'` solver.
* [Issue 199](https://github.com/MassimoCimmino/pygfunction/issues/199) - Changed the integral bounds to avoid repeated evaluation of integrals over semi-infinite intervals. This speeds up calculations of *g*-functions using all solvers and the evaluation of the finite line source solution with `time` as an array.

### Other changes

Expand Down
35 changes: 24 additions & 11 deletions pygfunction/heat_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,14 @@ def finite_line_source(
reaSource=reaSource, imgSource=imgSource, N=N)
else:
if not approximation:
h = np.stack(
[0.5 / H2 * quad(f, 1.0 / np.sqrt(4.0*alpha*t), np.inf)[0] for t in time],
axis=-1)
# Lower bound of integration
a = 1.0 / np.sqrt(4.0*alpha*time)
# Upper bound of integration
b = np.concatenate(([np.inf], a[:-1]))
h = np.cumsum(np.stack(
[0.5 / H2 * quad(f, a_i, b_i)[0]
for t, a_i, b_i in zip(time, a, b)],
axis=-1), axis=-1)
else:
h = finite_line_source_approximation(
time, alpha, dis, H1, D1, H2, D2,
Expand Down Expand Up @@ -396,10 +401,14 @@ def finite_line_source_vectorized(
a = 1.0 / np.sqrt(4.0*alpha*time)
h = 0.5 / H2 * quad_vec(f, a, np.inf)[0]
else:
h = np.stack(
[0.5 / H2 * quad_vec(f, 1.0 / np.sqrt(4.0*alpha*t), np.inf)[0]
for t in time],
axis=-1)
# Lower bound of integration
a = 1.0 / np.sqrt(4.0*alpha*time)
# Upper bound of integration
b = np.concatenate(([np.inf], a[:-1]))
h = np.cumsum(np.stack(
[0.5 / H2 * quad_vec(f, a_i, b_i)[0]
for t, a_i, b_i in zip(time, a, b)],
axis=-1), axis=-1)
else:
h = finite_line_source_approximation(
time, alpha, dis, H1, D1, H2, D2, reaSource=reaSource,
Expand Down Expand Up @@ -506,10 +515,14 @@ def finite_line_source_equivalent_boreholes_vectorized(
a = 1.0 / np.sqrt(4.0*alpha*time)
h = 0.5 / (N2*H2) * quad_vec(f, a, np.inf)[0]
else:
h = np.stack(
[0.5 / (N2*H2) * quad_vec(f, 1.0 / np.sqrt(4.0*alpha*t), np.inf)[0]
for t in time],
axis=-1)
# Lower bound of integration
a = 1.0 / np.sqrt(4.0*alpha*time)
# Upper bound of integration
b = np.concatenate(([np.inf], a[:-1]))
h = np.cumsum(np.stack(
[0.5 / (N2*H2) * quad_vec(f, a_i, b_i)[0]
for t, a_i, b_i in zip(time, a, b)],
axis=-1), axis=-1)
return h


Expand Down