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

Issue31 mixed inlet temperature #34

Merged
merged 26 commits into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1ccd053
Implement mixed inlet conditions for g-function calculation
MassimoCimmino Oct 20, 2017
7b46144
Merge branch 'master' into series_mixed_gFunctions
MassimoCimmino Nov 29, 2017
53a0797
Merge branch 'master' into series_mixed_gFunctions
MassimoCimmino Dec 7, 2017
31093c7
Merge branch 'master' into series_mixed_gFunctions
MassimoCimmino Jan 5, 2018
451fb47
Fix merge errors
MassimoCimmino Jan 5, 2018
78ff8a4
Example mixed inlet
MassimoCimmino Jan 5, 2018
1f474c6
Replace _path_from_inlet with _path_to_inlet
MassimoCimmino Jan 5, 2018
0ec94e2
Update example
MassimoCimmino Jan 5, 2018
598fe0f
Merge remote-tracking branch 'pygfunction-dev/series_mixed_gFunctions…
MassimoCimmino Jan 8, 2018
8319683
Relocate _path_to_inlet() and _verify_bore_connectivity()
MassimoCimmino Jan 17, 2018
0821592
Implement functions for field and borehole thermal resistances
MassimoCimmino Jan 17, 2018
c3dc102
Evaluate g-function based on effective borehole temperature
MassimoCimmino Jan 17, 2018
f6839a5
Example: Effective field thermal resistance
MassimoCimmino Jan 19, 2018
d7276a4
Adjustements to g-function examples
MassimoCimmino Jan 19, 2018
1aa8dfc
Merge branch 'master' into series_mixed_gFunctions
MassimoCimmino Jan 19, 2018
6e25df6
Figure for thermal resistance example
MassimoCimmino Jan 19, 2018
412acf8
Complete effective bore field resistance example
MassimoCimmino Feb 1, 2018
a416e4f
DocExample: Bore field thermal resistance
MassimoCimmino Feb 1, 2018
6ec8e47
Fix docstring of mixed_inlet_temperature
MassimoCimmino Feb 1, 2018
518a62d
Adjust example
MassimoCimmino Feb 1, 2018
e4afee2
DocExample: mixed_inlet_conditions
MassimoCimmino Feb 1, 2018
62fec6c
Delete misplaced examples
MassimoCimmino Feb 1, 2018
90da0f5
Fix outputs of gfunction.mixed_inlet_temperature()
MassimoCimmino Feb 1, 2018
1c6bfe6
Fix reference to Cimmino, 2018
MassimoCimmino Feb 1, 2018
203ae0d
Docstrings for borehole_thermal_resistance and field_thermal_resistance
MassimoCimmino Feb 1, 2018
6257af7
Update CHANGELOG.md
MassimoCimmino Feb 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [Commit 2bd12bd](https://github.com/MassimoCimmino/pygfunction/commit/2bd12bd254928889431366c2ddd38539e246ef05) - Implemented `UTube.visualize_pipes()` class method.
* [Issue 30](https://github.com/MassimoCimmino/pygfunction/issues/30) - Laminar regime is now considered for calculation of convection heat transfer coefficient.
* [Issue 32](https://github.com/MassimoCimmino/pygfunction/issues/32) - g-Functions for bore fields with mixed series and parallel connections between boreholes.

### Bug fixes

Expand Down
26 changes: 26 additions & 0 deletions doc/source/example_bore_field_thermal_resistance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. examples:

******************************************************
Calculation of effective bore field thermal resistance
******************************************************

This example demonstrates the use of the
:py:func:`.pipes.field_thermal_resistance` function to evaluate the bore field
thermal resistance. The concept effective bore field thermal is detailed by
Cimmino [1]_

The following script evaluates the effective bore field thermal resistance
for fields of 1 to 5 series-connected boreholes with fluid flow rates ranging
from 0.01 kg/s ti 1.00 kg/s.

The script is located in:
`pygfunction/examples/bore_field_thermal_resistance.py`

.. literalinclude:: ../../pygfunction/examples/bore_field_thermal_resistance.py
:language: python
:linenos:

.. rubric:: References
.. [1] Cimmino, M. (2018). g-Functions for bore fields with mixed parallel and
series connections considering the axial fluid temperature variations.
IGSHPA Research Track, Stockholm. In review.
2 changes: 2 additions & 0 deletions doc/source/example_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ Examples
example_equal_inlet_temperature
example_multiple_independent_Utubes
example_multipole_temperature
example_bore_field_thermal_resistance
example_mixed_inlet_conditions
31 changes: 31 additions & 0 deletions doc/source/example_mixed_inlet_conditions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. examples:

*********************************************************************
Calculation of g-functions with mixed parallel and series connections
*********************************************************************

This example demonstrates the use of the :doc:`g-function <gfunction>` module
and the :doc:`pipes <pipes>` module to calculate *g*-functions considering the
piping connections between the boreholes, based on the method of Cimmino [1]_.
For boreholes connected in series, it is considered the outlet fluid temperature
of the upstream borehole is equal to the inlet fluid temperature of the
downstream borehole. The total rate of heat extraction in the bore field is
constant.

The following script generates the *g*-functions of a field of 5 equally spaced
borehole on a straight line and connected in series. The boreholes have
different lengths. The *g*-function considering piping conections is compared to
the *g*-function obtained using a boundary condition of uniform borehole wall
temperature.

The script is located in:
`pygfunction/examples/mixed_inlet_conditions.py`

.. literalinclude:: ../../pygfunction/examples/mixed_inlet_conditions.py
:language: python
:linenos:

.. rubric:: References
.. [1] Cimmino, M. (2018). g-Functions for bore fields with mixed parallel and
series connections considering the axial fluid temperature variations.
IGSHPA Research Track, Stockholm. In review.
73 changes: 73 additions & 0 deletions pygfunction/boreholes.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,76 @@ def visualize_field(borefield):
plt.tight_layout(rect=[0, 0.0, 0.95, 1.0])

return fig


def _path_to_inlet(bore_connectivity, bore_index):
"""
Returns the path from a borehole to the bore field inlet.

This function raises an error if the supplied borehole connectivity is
invalid.

Parameters
----------
bore_connectivity : list
Index of fluid inlet into each borehole. -1 corresponds to a borehole
connected to the bore field inlet.
bore_index : int
Index of borehole to evaluate path.

Returns
-------
path : list
List of boreholes leading to the bore field inlet, starting from
borehole bore_index

"""
# Initialize path
path = [bore_index]
# Index of borehole feeding into borehole (bore_index)
index_in = bore_connectivity[bore_index]
# Stop when bore field inlet is reached (index_in == -1)
while not index_in == -1:
# Add index of upstream borehole to path
path.append(index_in)
# Get index of next upstream borehole
index_in = bore_connectivity[index_in]

return path


def _verify_bore_connectivity(bore_connectivity, nBoreholes):
"""
Verifies that borehole connectivity is valid.

This function raises an error if the supplied borehole connectivity is
invalid.

Parameters
----------
bore_connectivity : list
Index of fluid inlet into each borehole. -1 corresponds to a borehole
connected to the bore field inlet.
nBoreholes : int
Number of boreholes in the bore field.

"""
if not len(bore_connectivity) == nBoreholes:
raise ValueError(
'The length of the borehole connectivity list does not correspond '
'to the number of boreholes in the bore field.')
# Cycle through each borehole and verify that connections lead to -1
# (-1 is the bore field inlet)
for i in range(nBoreholes):
n = 0 # Initialize step counter
# Index of borehole feeding into borehole i
index_in = bore_connectivity[i]
# Stop when bore field inlet is reached (index_in == -1)
while not index_in == -1:
index_in = bore_connectivity[index_in]
n += 1 # Increment step counter
# Raise error if n exceeds the number of boreholes
if n > nBoreholes:
raise ValueError(
'The borehole connectivity list is invalid.')
return
136 changes: 136 additions & 0 deletions pygfunction/examples/bore_field_thermal_resistance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# -*- coding: utf-8 -*-
""" Example of calculation of effective bore field thermal resistance.

The effective bore field thermal resistance of fields of up to 5 boreholes
of equal lengths connected in series is calculated for various fluid flow
rates.

"""
from __future__ import division, print_function, absolute_import

import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator
import numpy as np
from scipy import pi

import pygfunction as gt


def main():
# -------------------------------------------------------------------------
# Simulation parameters
# -------------------------------------------------------------------------

# Number of boreholes
nBoreholes = 5
# Borehole dimensions
D = 4.0 # Borehole buried depth (m)
# Borehole length (m)
H = 150.
r_b = 0.075 # Borehole radius (m)
B = 7.5 # Borehole spacing (m)

# Pipe dimensions
rp_out = 0.02 # Pipe outer radius (m)
rp_in = 0.015 # Pipe inner radius (m)
D_s = 0.05 # Shank spacing (m)
epsilon = 1.0e-6 # Pipe roughness (m)

# Pipe positions
# Single U-tube [(x_in, y_in), (x_out, y_out)]
pos_pipes = [(-D_s, 0.), (D_s, 0.)]

# Ground properties
k_s = 2.0 # Ground thermal conductivity (W/m.K)

# Grout properties
k_g = 1.0 # Grout thermal conductivity (W/m.K)

# Pipe properties
k_p = 0.4 # Pipe thermal conductivity (W/m.K)

# Fluid properties
# Total fluid mass flow rate per borehole (kg/s), from 0.01 kg/s to 1 kg/s
m_flow_boreholes = 10**np.arange(-2, 0.001, 0.05)
cp_f = 4000. # Fluid specific isobaric heat capacity (J/kg.K)
den_f = 1015. # Fluid density (kg/m3)
visc_f = 0.002 # Fluid dynamic viscosity (kg/m.s)
k_f = 0.5 # Fluid thermal conductivity (W/m.K)

# -------------------------------------------------------------------------
# Borehole field
# -------------------------------------------------------------------------

boreField = []
bore_connectivity = []
for i in range(nBoreholes):
x = i*B
borehole = gt.boreholes.Borehole(H, D, r_b, x, 0.)
boreField.append(borehole)
# Boreholes are connected in series: The index of the upstream
# borehole is that of the previous borehole
bore_connectivity.append(i - 1)

# -------------------------------------------------------------------------
# Evaluate the effective bore field thermal resistance
# -------------------------------------------------------------------------

# Initialize result array
R = np.zeros((nBoreholes, len(m_flow_boreholes)))
for i in range(nBoreholes):
for j in range(len(m_flow_boreholes)):
nBoreholes = i + 1
m_flow = m_flow_boreholes[j]

# Pipe thermal resistance
R_p = gt.pipes.conduction_thermal_resistance_circular_pipe(
rp_in, rp_out, k_p)
# Fluid to inner pipe wall thermal resistance (Single U-tube)
h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe(
m_flow, rp_in, visc_f, den_f, k_f, cp_f, epsilon)
R_f = 1.0/(h_f*2*pi*rp_in)

# Single U-tube, same for all boreholes in the bore field
UTubes = []
for borehole in boreField:
SingleUTube = gt.pipes.SingleUTube(pos_pipes, rp_in, rp_out,
borehole, k_s, k_g, R_f + R_p)
UTubes.append(SingleUTube)

# Effective bore field thermal resistance
R_field = gt.pipes.field_thermal_resistance(
UTubes[:nBoreholes], bore_connectivity[:nBoreholes],
m_flow, cp_f)
# Add to result array
R[i,j] = R_field

# -------------------------------------------------------------------------
# Plot bore field thermal resistances
# -------------------------------------------------------------------------

plt.rc('figure')
fig = plt.figure()
ax1 = fig.add_subplot(111)
# Bore field thermal resistances
ax1.plot(m_flow_boreholes, R[0,:], 'k-', lw=1.5, label='1 borehole')
ax1.plot(m_flow_boreholes, R[2,:], 'r--', lw=1.5, label='3 boreholes')
ax1.plot(m_flow_boreholes, R[4,:], 'b-.', lw=1.5, label='5 boreholes')
ax1.legend()
# Axis labels
ax1.set_xlabel(r'$\dot{m}$ [kg/s]')
ax1.set_ylabel(r'$R^*_{field}$ [m.K/W]')
# Axis limits
ax1.set_xlim([0., 1.])
ax1.set_ylim([0., 1.])
# Show minor ticks
ax1.xaxis.set_minor_locator(AutoMinorLocator())
ax1.yaxis.set_minor_locator(AutoMinorLocator())
# Adjust to plot window
plt.tight_layout()

return


# Main function
if __name__ == '__main__':
main()
Loading