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

New Borefield class #210

Open
MassimoCimmino opened this issue Jun 21, 2022 · 2 comments
Open

New Borefield class #210

MassimoCimmino opened this issue Jun 21, 2022 · 2 comments

Comments

@MassimoCimmino
Copy link
Owner

Many functions in the heat_transfer and gfunction modules necessitate to generate arrays of borehole parameters (i.e. H, D, r_b, x, y, tilt, orientation) from lists of boreholes. This generates multiple instances of duplicate and not very readable code.

The new Borefield class will replace lists of boreholes within the modules. Anytime a user provides a list of boreholes, this list will be used to generate a Borefield object. Alternatively, Borefield objects can be provided as input.

To preserve current behavior, the following should be considered (for an instance borefield of the Borefield class):

  • borefield[i] should return the i-th borehole
  • borefield[i0:i1] should return an instance of the Borefield class formed by boreholes i0 through i1-1.

To simplify the code, the Borefield class will:

  • Implement class methods similar to the Borehole class to evaluate, e.g., distance vectors and arrays. An additional parameter outer can be included to evaluate distance vectors (outer=False) and arrays (outer=True).
  • Return arrays of parameters, e.g. borefield.H returns an array of borehole lengths.
@j-c-cook
Copy link
Contributor

j-c-cook commented Jan 9, 2023

  • Return arrays of parameters, e.g. borefield.H returns an array of borehole lengths.

I'm currently not sure how to make an instance a callable method like above. If self.H = self.H(), then when calling borefield.H, the method is bound and still needs the () on the end. Given that Borefield inherits from list, I think all of the methods would need overridden to update the instances any time an item was added or removed.

import pygfunction as gt
borefield = gt.boreholes.rectangle_field(2, 2, 5, 5, 100, 5, 0.075)
H = borefield.H()

@MassimoCimmino
Copy link
Owner Author

I had started the development a while ago on my branch. I also have uncommitted changes.

I had the Borefield class implemented similar to the Borehole class but with parameters stored as arrays:

class Borefield(object):
def __init__(self, boreholes):
self.boreholes = boreholes
self.nBoreholes = len(boreholes)
self.H = np.array([b.H for b in boreholes])
self.D = np.array([b.D for b in boreholes])
self.r_b = np.array([b.r_b for b in boreholes])
self.x = np.array([b.x for b in boreholes])
self.y = np.array([b.y for b in boreholes])
self.tilt = np.array([b.tilt for b in boreholes])
self.orientation = np.array([b.orientation for b in boreholes])
self._is_tilted = np.array(
[b._is_tilted for b in boreholes], dtype=bool)

The main objective of implementing a Borefield class is to simplify the code for g-function calculation, since we have multiple instances of converting lists of boreholes into arrays of parameters (there are other operations that are encountered a couple times). I put this on hold since my initial implementation had non-negligible impact on the computational efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants