From 86019e5c6dd85e36b872e468fe4cab71a6fb6a7d Mon Sep 17 00:00:00 2001 From: Massimo Cimmino Date: Fri, 28 Jun 2024 11:00:16 -0400 Subject: [PATCH 1/2] Simplify expressions for steady-state FLS --- pygfunction/heat_transfer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pygfunction/heat_transfer.py b/pygfunction/heat_transfer.py index 7174904d..9e5b457f 100644 --- a/pygfunction/heat_transfer.py +++ b/pygfunction/heat_transfer.py @@ -1375,7 +1375,8 @@ def _finite_line_source_steady_state(dis, H1, D1, H2, D2, reaSource, imgSource): D2 + D1 + H2 + H1], axis=-1) dis = np.expand_dims(dis, axis=-1) - h = 0.5 / H2 * np.inner(p, q * np.log((q + np.sqrt(q**2 + dis**2)) / dis) - np.sqrt(q**2 + dis**2)) + qpd = np.sqrt(q**2 + dis**2) + h = 0.5 / H2 * np.inner(p, q * np.log(q + qpd) - qpd) elif reaSource: # Real FLS solution p = np.array([1, -1, 1, -1]) @@ -1385,7 +1386,8 @@ def _finite_line_source_steady_state(dis, H1, D1, H2, D2, reaSource, imgSource): D2 - D1 + H2 - H1,], axis=-1) dis = np.expand_dims(dis, axis=-1) - h = 0.5 / H2 * np.inner(p, q * np.log((q + np.sqrt(q**2 + dis**2)) / dis) - np.sqrt(q**2 + dis**2)) + qpd = np.sqrt(q**2 + dis**2) + h = 0.5 / H2 * np.inner(p, q * np.log(q + qpd) - qpd) elif imgSource: # Image FLS solution p = np.array([1, -1, 1, -1]) @@ -1395,7 +1397,8 @@ def _finite_line_source_steady_state(dis, H1, D1, H2, D2, reaSource, imgSource): D2 + D1 + H2 + H1], axis=-1) dis = np.expand_dims(dis, axis=-1) - h = 0.5 / H2 * np.inner(p, q * np.log((q + np.sqrt(q**2 + dis**2)) / dis) - np.sqrt(q**2 + dis**2)) + qpd = np.sqrt(q**2 + dis**2) + h = 0.5 / H2 * np.inner(p, q * np.log(q + qpd) - qpd) else: # No heat source h = np.zeros(np.broadcast_shapes( From bf991e7161d7e465d05a4dafbe80329800e5a5d8 Mon Sep 17 00:00:00 2001 From: Massimo Cimmino Date: Fri, 28 Jun 2024 11:00:27 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9da6ce2..8ef08814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * [Issue 276](https://github.com/MassimoCimmino/pygfunction/issues/276) - Added functions to the `boreholes` module for the generation of rectangular fields in a staggered configuration. +### Enhancements + +* [Issue 291](https://github.com/MassimoCimmino/pygfunction/issues/291) - Simplified the expressions in heat_transfer._finite_line_source_steady_state`. The function is now approximately 25% faster. + ### Bug fixes * [Issue 255](https://github.com/MassimoCimmino/pygfunction/issues/255) - Default to an `orientation` of `0.` when `tilt` is `0.` in `boreholes.Borehole` class.