Skip to content

Commit

Permalink
Final review
Browse files Browse the repository at this point in the history
  • Loading branch information
MassimoCimmino committed Dec 20, 2024
1 parent 1084a09 commit a37a8ca
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

* [Issue 215](https://github.com/MassimoCimmino/pygfunction/issues/215) - Implemented variable fluid mass flow rate g-functions. Bore fields with series-connected boreholes and reversible flow direction can now be simulated.
* [Issue 282](https://github.com/MassimoCimmino/pygfunction/issues/282) - Enabled the use of negative mass flow rates in `Pipe` and `Network` classes to model reversed flow direction.
* [Pull Request 308](https://github.com/MassimoCimmino/pygfunction/pull/308) - Introduced a new `borefield` module. The new `Borefield` class replaces lists of `Borehole` objects as the preferred way to configure bore fields. The `Borefield.evaluate_g_function` method evaluates g-functions using the 'UHTR' and 'UBWT' boundary conditions. Deprecated bore field creation functions in the `boreholes` module (e.g. `boreholes.rectangle_field()`). These functions are replaced by methods of the new `Borefield` class. The will be removed in `v3.0.0`.
* [Pull Request 308](https://github.com/MassimoCimmino/pygfunction/pull/308) - Introduced a new `borefield` module. The new `Borefield` class replaces lists of `Borehole` objects as the preferred way to configure bore fields. The `Borefield.evaluate_g_function` method evaluates g-functions using the 'UHTR' and 'UBWT' boundary conditions. Deprecated bore field creation functions in the `boreholes` module (e.g. `boreholes.rectangle_field()`). These functions are replaced by methods of the new `Borefield` class. They will be removed in `v3.0.0`.

## Version 2.2.3 (2024-07-01)

Expand Down
4 changes: 2 additions & 2 deletions examples/custom_bore_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def main():
# Position 2 has a borehole with radius inside of another bore
# The duplicates will be removed with the remove_duplicates function
x = np.array([0., 0., 0.03, 5., 3.5, 1., 5.5])
y = np.array([0., 0., 0., 0., 4., 7., 5.5])
y = np.array([0., 0., 0.00, 0., 4.0, 7., 5.5])

# -------------------------------------------------------------------------
# Borehole field
Expand All @@ -42,7 +42,7 @@ def main():
# Draw bore field
# -------------------------------------------------------------------------

borefield.visualize_field(borefield)
borefield.visualize_field()

return

Expand Down
46 changes: 24 additions & 22 deletions pygfunction/borefield.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from typing import Union, List, Dict, Tuple
from typing_extensions import Self # for compatibility with Python <= 3.10
from typing_extensions import Self # for compatibility with Python <= 3.10

import matplotlib.pyplot as plt
from matplotlib.figure import Figure
Expand All @@ -10,6 +10,7 @@
from .boreholes import Borehole
from .utilities import _initialize_figure, _format_axes, _format_axes_3d


class Borefield:
"""
Contains information regarding the dimensions and positions of boreholes within a borefield.
Expand Down Expand Up @@ -82,7 +83,7 @@ def __getitem__(self, key):

def __eq__(
self, other_field: Union[Borehole, List[Borehole], Self]) -> bool:
"""Return True if other_field is the same as self"""
"""Return True if other_field is the same as self."""
# Convert other_field into Borefield object
if isinstance(other_field, (Borehole, list)):
other_field = Borefield.from_boreholes(other_field)
Expand All @@ -99,12 +100,12 @@ def __eq__(
return check

def __len__(self) -> int:
"""Returns the number of boreholes."""
"""Return the number of boreholes."""
return self.nBoreholes

def __ne__(
self, other_field: Union[Borehole, List[Borehole], Self]) -> bool:
"""Return True if other_field is not the same as self"""
"""Return True if other_field is not the same as self."""
check = not self == other_field
return check

Expand Down Expand Up @@ -182,7 +183,7 @@ def evaluate_g_function(
Default is :func:`utilities.segment_ratios`.
approximate_FLS : bool, optional
Set to true to use the approximation of the FLS solution of
Cimmino (2021) [#gFunction-Cimmin2021]_. This approximation
Cimmino (2021) [#borefield-Cimmin2021]_. This approximation
does not require the numerical evaluation of any integral.
When using the 'equivalent' solver, the approximation is
only applied to the thermal response at the borehole
Expand Down Expand Up @@ -437,7 +438,7 @@ def to_file(self, filename: str):
def from_boreholes(
cls, boreholes: Union[Borehole, List[Borehole]]) -> Self:
"""
Build a borefield given coordinates and dimensions provided in a text file.
Build a borefield given a list of Borehole objects.
Parameters
----------
Expand All @@ -446,7 +447,7 @@ def from_boreholes(
Returns
-------
boreField : Borefield object
borefield : Borefield object
Borefield object.
"""
Expand Down Expand Up @@ -476,7 +477,7 @@ def from_file(cls, filename: str) -> Self:
Returns
-------
boreField : Borefield object
borefield : Borefield object
Borefield object.
Notes
Expand Down Expand Up @@ -511,8 +512,8 @@ def from_file(cls, filename: str) -> Self:

@classmethod
def rectangle_field(
cls, N_1: int, N_2:int, B_1: float, B_2: float, H: float, D: float,
r_b: float, tilt: float = 0.,
cls, N_1: int, N_2: int, B_1: float, B_2: float, H: float,
D: float, r_b: float, tilt: float = 0.,
origin: Union[Tuple[float, float], None] = None) -> Self:
"""
Build a bore field in a rectangular configuration.
Expand Down Expand Up @@ -588,8 +589,9 @@ def rectangle_field(

@classmethod
def staggered_rectangle_field(
cls, N_1: int, N_2:int, B_1: float, B_2: float, H: float, D: float,
r_b: float, include_last_borehole: bool, tilt: float = 0.,
cls, N_1: int, N_2: int, B_1: float, B_2: float, H: float,
D: float, r_b: float, include_last_borehole: bool,
tilt: float = 0.,
origin: Union[Tuple[float, float], None] = None) -> Self:
"""
Build a bore field in a staggered rectangular bore field configuration.
Expand All @@ -612,8 +614,8 @@ def staggered_rectangle_field(
Borehole radius (in meters).
include_last_borehole : bool
If True, then each row of boreholes has equal numbers of boreholes.
If False, then the staggered rows have one borehole less so they are
contained within the imaginary 'box' around the borefield.
If False, then the staggered rows have one borehole less so they
are contained within the imaginary 'box' around the borefield.
tilt : float, optional
Angle (in radians) from vertical of the axis of the borehole. The
orientation of the tilt is orthogonal to the origin coordinate.
Expand Down Expand Up @@ -694,7 +696,7 @@ def staggered_rectangle_field(

@classmethod
def dense_rectangle_field(
cls, N_1: int, N_2:int, B: float, H: float, D: float,
cls, N_1: int, N_2: int, B: float, H: float, D: float,
r_b: float, include_last_borehole: bool, tilt: float = 0.,
origin: Union[Tuple[float, float], None] = None) -> Self:
"""
Expand Down Expand Up @@ -767,8 +769,8 @@ def dense_rectangle_field(

@classmethod
def L_shaped_field(
cls, N_1: int, N_2:int, B_1: float, B_2: float, H: float, D: float,
r_b: float, tilt: float = 0.,
cls, N_1: int, N_2: int, B_1: float, B_2: float, H: float,
D: float, r_b: float, tilt: float = 0.,
origin: Union[Tuple[float, float], None] = None) -> Self:
"""
Build a bore field in a L-shaped configuration.
Expand Down Expand Up @@ -845,8 +847,8 @@ def L_shaped_field(

@classmethod
def U_shaped_field(
cls, N_1: int, N_2:int, B_1: float, B_2: float, H: float, D: float,
r_b: float, tilt: float = 0.,
cls, N_1: int, N_2: int, B_1: float, B_2: float, H: float,
D: float, r_b: float, tilt: float = 0.,
origin: Union[Tuple[float, float], None] = None) -> Self:
"""
Build a bore field in a U-shaped configuration.
Expand Down Expand Up @@ -930,8 +932,8 @@ def U_shaped_field(

@classmethod
def box_shaped_field(
cls, N_1: int, N_2:int, B_1: float, B_2: float, H: float, D: float,
r_b: float, tilt: float = 0.,
cls, N_1: int, N_2: int, B_1: float, B_2: float, H: float,
D: float, r_b: float, tilt: float = 0.,
origin: Union[Tuple[float, float], None] = None) -> Self:
"""
Build a bore field in a box-shaped configuration.
Expand Down Expand Up @@ -1021,7 +1023,7 @@ def box_shaped_field(

@classmethod
def circle_field(
cls, N: int, R: float, H: float, D: float, r_b:float,
cls, N: int, R: float, H: float, D: float, r_b: float,
tilt: float = 0.,
origin: Union[Tuple[float, float], None] = None) -> Self:
"""
Expand Down

0 comments on commit a37a8ca

Please sign in to comment.