Open MassimoCimmino opened 2 years ago
- 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()
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:
https://github.com/MassimoCimmino/pygfunction/blob/0beb558de5f921be22a45fc42a12cb45aa9b6533/pygfunction/boreholes.py#L240-L252
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.
Many functions in the
heat_transfer
andgfunction
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 aBorefield
object. Alternatively,Borefield
objects can be provided as input.To preserve current behavior, the following should be considered (for an instance
borefield
of theBorefield
class):borefield[i]
should return thei
-th boreholeborefield[i0:i1]
should return an instance of theBorefield
class formed by boreholesi0
throughi1-1
.To simplify the code, the
Borefield
class will:Borehole
class to evaluate, e.g., distance vectors and arrays. An additional parameterouter
can be included to evaluate distance vectors (outer=False
) and arrays (outer=True
).borefield.H
returns an array of borehole lengths.