-
Notifications
You must be signed in to change notification settings - Fork 25
Issue210 borefield class #310
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
base: master
Are you sure you want to change the base?
Conversation
| self.nBoreholes = np.max( | ||
| [len(np.atleast_1d(var)) | ||
| for var in (H, D, r_b, x, y, tilt, orientation)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider an assertion for when len(x) != len(y)?
What about enforcing H, D, r_b, tilt and orientation to match len(<var>) == len(y) or len(<var>) == 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An assertion would certainly be important here. The goal was to mimic numpy array broadcasting rules and allow for example x = [0., 5., 10.], y = 0. if 3 boreholes are on the same row.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Borehole class can represent both a segment of a borehole or the borehole itself. Likewise, the collection of parameters in Borefield can represent segments or boreholes. With that in mind, segments along a vertical borehole share the same coordinates (x, y) and only require H and D arrays at instantiation.
One way to approach this would be to use b = np.broadcast(H, D, r_b, x, y, tilt, orientation) to make sure that the inputs are broadcastable to a common shape with b.nd <= 1. The number of boreholes is then nBoreholes = b.size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to make use of any ideas contained in commit j-c-cook@bd6e467. I've enjoyed the back and forth and little bit of collaboration here. I'll likely drop out of discussion now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adapted your changes in #322. I removed the try / except clauses since numpy.broadcast raises an error if the arguments cannot be broadcast.
|
The following example shows that a borehole field of size 1 can be both a x = np.array([0.])
y = np.array([0.])
borefield = gt.borefield.Borefield(H, D, r_b, x, y)
print(type(borefield))
print(type(borefield[0]))Outputs: |
This follows the work in #308 and works towards fully integrating the Borefield class into the g-function module and solvers to close #210 and #211.
This requires a major refactoring of the
heat_transfermodule and the different g-function solvers. Here is an overview of the ongoing work (and the reasoning) on this issue:solversmodule. Thegfunctionmodule was too large and this allows to isolate each class into their own script to facilitate the work on different parts of pygfunction. This will facilitate the addition of new solvers in the future.heat_transfermodule into multiple scripts. This script was also too large. Different functions can naturally be classified into files for the vertical FLS and the inclined FLS. This change will also facilitate the addition of other heat transfer solutions in the future (e.g. for Short-term correction using the cylindrical heat source #44 and Groundwater advection #219).heat_transferfunctions to useBorefieldobjects as inputs instead of long lists of geometrical parameters. This will simplify unnecessary code in the solvers that formats geometrical parameters before calls toheat_transferfunctions.Detailed,SimilaritiesandEquivalentsolvers to make use of theBorefieldclass. This should greatly improve the readability of the code.Networkto use theBorefield classborefieldmodule for Create API for computing g-function values from static inputs #308. Since the solvers will be almost entirely re-implemented, might as well make progress on Type annotations and mypy #178.This addresses some of the issues pointed out by @ikijano in #257. It has become increasingly difficult to implement new features as they multiply (it was not possible to predict the vast array of methods we have today when we developed v2.0) and it is time to re-visit the implementation to make future development easier.
The work on issue #210 had been delayed since it first looked like it would negatively affect the computational time. Thankfully, it now looks like there might even be some (not that significant but still not always negligible) improvements.