Skip to content

Commit

Permalink
Merge branch 'main' into fix-peak-day-ahead-ground-loads
Browse files Browse the repository at this point in the history
  • Loading branch information
j-c-cook authored Jan 23, 2022
2 parents f93c82e + 7a866db commit 8d1bbc9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ non-exhaustive list of the possible categories issues could fall in:
### Enhances

* [Issue 81](https://github.com/j-c-cook/ghedt/issues/81) - The `near-square` design option in the `Design` object now requires the user to specify a land length which computes a maximum number of boreholes rather. This functionality replaces a hard-coded 32x32 maximum.
* [Issue 85](https://github.com/j-c-cook/ghedt/issues/85) - Enhances the `Design` API to accept the simulation method (hybrid or hourly) used for searching fields.

### Fixes

Expand Down
27 changes: 22 additions & 5 deletions ghedt/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ghedt.peak_load_analysis_tool as plat
import pygfunction as gt
import numpy as np
import textwrap


# Common design interface
Expand All @@ -15,7 +16,7 @@ def __init__(self, V_flow: float, borehole: gt.boreholes.Borehole,
grout: plat.media.Grout, soil: plat.media.Soil,
sim_params: plat.media.SimulationParameters,
geometric_constraints: dt.media.GeometricConstraints,
hourly_extraction_ground_loads: list,
hourly_extraction_ground_loads: list, method: str = 'hybrid',
routine: str = 'near-square', flow: str = 'borehole'):
self.V_flow = V_flow # volumetric flow rate, m3/s
self.borehole = borehole
Expand All @@ -27,6 +28,21 @@ def __init__(self, V_flow: float, borehole: gt.boreholes.Borehole,
self.sim_params = sim_params
self.geometric_constraints = geometric_constraints
self.hourly_extraction_ground_loads = hourly_extraction_ground_loads
self.method = method
if self.method == 'hourly':
msg = 'Note: It is not recommended to perform a field selection ' \
'with the hourly simulation due to computation time. If ' \
'the goal is to validate the selected field with the ' \
'hourly simulation, the better solution is to utilize the ' \
'hybrid simulation to automatically select the field. Then ' \
'perform a sizing routine on the selected GHE with the ' \
'hourly simulation.'
# Wrap the text to a 50 char line width and print it
wrapper = textwrap.TextWrapper(width=72)
word_list = wrapper.wrap(text=msg)
for element in word_list:
print(element)
print('\n')

# Check the routine parameter
self.routine = routine
Expand Down Expand Up @@ -76,28 +92,29 @@ def find_design(self, disp=False):
self.coordinates_domain, self.V_flow, self.borehole,
self.bhe_object, self.fluid, self.pipe, self.grout,
self.soil, self.sim_params, self.hourly_extraction_ground_loads,
flow=self.flow, disp=disp)
method=self.method, flow=self.flow, disp=disp)
# Find a rectangle
elif self.routine == 'rectangle':
bisection_search = dt.search_routines.Bisection1D(
self.coordinates_domain, self.V_flow, self.borehole,
self.bhe_object, self.fluid, self.pipe, self.grout, self.soil,
self.sim_params, self.hourly_extraction_ground_loads,
flow=self.flow, disp=disp)
method=self.method, flow=self.flow, disp=disp)
# Find a bi-rectangle
elif self.routine == 'bi-rectangle':
bisection_search = dt.search_routines.Bisection2D(
self.coordinates_domain_nested, self.V_flow,
self.borehole, self.bhe_object, self.fluid, self.pipe,
self.grout, self.soil, self.sim_params,
self.hourly_extraction_ground_loads, flow=self.flow, disp=disp)
self.hourly_extraction_ground_loads, method=self.method,
flow=self.flow, disp=disp)
# Find bi-zoned rectangle
elif self.routine == 'bi-zoned':
bisection_search = dt.search_routines.BisectionZD(
self.coordinates_domain_nested, self.V_flow, self.borehole,
self.bhe_object, self.fluid, self.pipe, self.grout, self.soil,
self.sim_params, self.hourly_extraction_ground_loads,
flow=self.flow, disp=disp)
method=self.method, flow=self.flow, disp=disp)
else:
raise ValueError('The requested routine is not available. '
'The currently available routines are: '
Expand Down
2 changes: 1 addition & 1 deletion ghedt/examples/Design/find_near_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def main():
design_single_u_tube = dt.design.Design(
V_flow, borehole, single_u_tube, fluid, pipe_single, grout,
soil, sim_params, geometric_constraints, hourly_extraction_ground_loads,
flow=flow, routine='near-square')
method='hybrid', flow=flow, routine='near-square')

# Find the near-square design for a single U-tube and size it.
tic = clock()
Expand Down
4 changes: 2 additions & 2 deletions ghedt/ground_heat_exchangers.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def __init__(self, V_flow_system: float, B_spacing: float,
self, V_flow_system, B_spacing, bhe_object, fluid, borehole, pipe,
grout, soil, GFunction, sim_params, hourly_extraction_ground_loads)

# Split the extraction loads into heating and cooling for input to the
# HybridLoad object
# Split the extraction loads into heating and cooling for input to
# the HybridLoad object
hourly_rejection_loads, hourly_extraction_loads = \
plat.ground_loads.HybridLoad.split_heat_and_cool(
self.hourly_extraction_ground_loads)
Expand Down
23 changes: 12 additions & 11 deletions ghedt/search_routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def __init__(self, coordinates_domain: list, V_flow: float,
fluid: gt.media.Fluid, pipe: plat.media.Pipe,
grout: plat.media.Grout, soil: plat.media.Soil,
sim_params: plat.media.SimulationParameters,
hourly_extraction_ground_loads: list, flow: str = 'borehole',
max_iter=15, disp=False, search=True):
hourly_extraction_ground_loads: list, method: str = 'hybrid',
flow: str = 'borehole', max_iter=15, disp=False, search=True):

# Take the lowest part of the coordinates domain to be used for the
# initial setup
Expand All @@ -28,6 +28,7 @@ def __init__(self, coordinates_domain: list, V_flow: float,
self.flow = flow
V_flow_system, m_flow_borehole = \
self.retrieve_flow(coordinates, fluid.rho)
self.method = method

self.log_time = dt.utilities.Eskilson_log_times()
self.bhe_object = bhe_object
Expand Down Expand Up @@ -99,7 +100,7 @@ def initialize_ghe(self, coordinates, H):
def calculate_excess(self, coordinates, H):
self.initialize_ghe(coordinates, H)
# Simulate after computing just one g-function
max_HP_EFT, min_HP_EFT = self.ghe.simulate()
max_HP_EFT, min_HP_EFT = self.ghe.simulate(method=self.method)
T_excess = self.ghe.cost(max_HP_EFT, min_HP_EFT)

# This is more of a debugging statement. May remove it in the future.
Expand Down Expand Up @@ -216,8 +217,8 @@ def __init__(self, coordinates_domain_nested: list, V_flow: float,
fluid: gt.media.Fluid, pipe: plat.media.Pipe,
grout: plat.media.Grout, soil: plat.media.Soil,
sim_params: plat.media.SimulationParameters,
hourly_extraction_ground_loads: list, flow: str = 'borehole',
max_iter=15, disp=False):
hourly_extraction_ground_loads: list, method: str = 'hybrid',
flow: str = 'borehole', max_iter=15, disp=False):
if disp:
print('Note: This routine requires a nested bisection search.')

Expand All @@ -226,8 +227,8 @@ def __init__(self, coordinates_domain_nested: list, V_flow: float,
Bisection1D.__init__(
self, coordinates_domain, V_flow, borehole, bhe_object,
fluid, pipe, grout, soil, sim_params,
hourly_extraction_ground_loads, flow=flow, max_iter=max_iter,
disp=disp, search=False)
hourly_extraction_ground_loads, method=method, flow=flow,
max_iter=max_iter, disp=disp, search=False)

self.coordinates_domain_nested = []
self.calculated_temperatures_nested = []
Expand Down Expand Up @@ -262,8 +263,8 @@ def __init__(self, coordinates_domain_nested: list, V_flow: float,
fluid: gt.media.Fluid, pipe: plat.media.Pipe,
grout: plat.media.Grout, soil: plat.media.Soil,
sim_params: plat.media.SimulationParameters,
hourly_extraction_ground_loads: list, flow: str = 'borehole',
max_iter=15, disp=False):
hourly_extraction_ground_loads: list, method: str = 'hybrid',
flow: str = 'borehole', max_iter=15, disp=False):
if disp:
print('Note: This design routine currently requires several '
'bisection searches.')
Expand All @@ -273,8 +274,8 @@ def __init__(self, coordinates_domain_nested: list, V_flow: float,
Bisection1D.__init__(
self, coordinates_domain, V_flow, borehole, bhe_object,
fluid, pipe, grout, soil, sim_params,
hourly_extraction_ground_loads, flow=flow, max_iter=max_iter,
disp=disp, search=False)
hourly_extraction_ground_loads, method=method, flow=flow,
max_iter=max_iter, disp=disp, search=False)

self.coordinates_domain_nested = coordinates_domain_nested
self.calculated_temperatures_nested = {}
Expand Down

0 comments on commit 8d1bbc9

Please sign in to comment.