Skip to content

Optional matplotlib dependency #311

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ target/

# VirtualEnvironment
venv/

# Generated files
*.png
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* [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. They will be removed in `v3.0.0`.

### Other changes

* [Issue 312](https://github.com/MassimoCimmino/pygfunction/issues/312) - The installation of `matplotlib` is now optional. Using `pip install pygfunction` will not install `matplotlib` and `pip install pygfunction[plot]` should be used instead.

## Version 2.2.3 (2024-07-01)

### New features
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This allows for the very fast calculation of *g*-functions, even for very large
bore fields with hundreds of boreholes.

Using *pygfunction*, *g*-functions can be calculated for any bore field
configuration (i.e. arbitrarily positionned in space), including fields of
configuration (i.e. arbitrarily positioned in space), including fields of
boreholes with individually different lengths and radiuses. For regular fields
of boreholes of equal size, setting-up the calculation of the *g*-function is
as simple as a few lines of code. For example, the code for the calculation of
Expand All @@ -40,12 +40,13 @@ fluid temperatures in the boreholes for several U-tube pipe configurations.

## Requirements

*pygfunction* was developed and tested using Python 3.7. In addition, the
*pygfunction* was developed and tested using Python 3.8. In addition, the
following packages are needed to run *pygfunction* and its examples:
- matplotlib (>= 3.5.1),
- matplotlib (>= 3.8.4),
- numpy (>= 1.21.5)
- scipy (>= 1.7.3)
- SecondaryCoolantProps (>= 1.1)
- typing_extensions >= 4.0.1

The documentation is generated using [Sphinx](http://www.sphinx-doc.org). The
following packages are needed to build the documentation:
Expand All @@ -58,7 +59,7 @@ following packages are needed to build the documentation:
**Users** - [Download pip](https://pip.pypa.io/en/latest/) and install the latest release:

```
pip install pygfunction
pip install pygfunction[plot]
```

Alternatively, [download the latest release](https://github.com/MassimoCimmino/pygfunction/releases) and run the installation script:
Expand Down
6 changes: 3 additions & 3 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
matplotlib >= 3.8.4
numpy >= 1.21.5
scipy >= 1.7.3
matplotlib >= 3.5.1
numpydoc >= 1.2.0
recommonmark >= 0.6.0
sphinx >= 4.4.0
scipy >= 1.7.3
secondarycoolantprops >= 1.1.0
sphinx >= 4.4.0
typing_extensions >= 4.0.1
2 changes: 1 addition & 1 deletion doc/source/examples/comparison_load_aggregation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Compare the accuracy and speed of different load aggregation algorithms

This example compares the simulation times and the accuracy of borehole wall
temperature predictions of different load aggregation algorithms implemented
into the :doc:`load agggregation <load_aggregation>` module.
into the :doc:`load aggregation <load_aggregation>` module.

The g-function of a single borehole is first calculated. Then, the borehole wall
temperature variations are calculated using the load aggregation schemes of
Expand Down
2 changes: 1 addition & 1 deletion doc/source/examples/load_aggregation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Simulation of a borehole using load aggregation
***********************************************

This example demonstrates the use of the
:doc:`load agggregation <load_aggregation>` module to predict the borehole
:doc:`load aggregation <load_aggregation>` module to predict the borehole
wall temperature of a single temperature with known heat extraction rates.

The g-function of a single borehole is first calculated. Then, the borehole wall
Expand Down
2 changes: 1 addition & 1 deletion doc/source/examples/mixed_inlet_conditions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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
different lengths. The *g*-function considering piping connections is compared to
the *g*-function obtained using a boundary condition of uniform borehole wall
temperature.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/examples/multiple_independent_Utubes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ in this example.
The following script evaluates the fluid temperatures in a borehole with 4
independent U-tubes with different inlet fluid temperatures and different inlet
fluid mass flow rates. The resulting fluid temperature profiles are verified
against the fluid temeprature profiles presented by Cimmino [1]_.
against the fluid temperature profiles presented by Cimmino [1]_.

The script is located in:
`pygfunction/examples/multiple_independent_Utubes.py`
Expand Down
29 changes: 16 additions & 13 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Setting up pygfunction
**********************

*pygfunction* uses Python 3.8, along with the following packages:
- matplotlib (>= 3.5.1),
- numpy (>= 1.21.5)
- scipy (>= 1.7.3)
- SecondaryCoolantProps (>= 1.1)
- typing_extensions (>= 4.0.1)
- (optionally) matplotlib (>= 3.8.4)

*pygfunction*'s- documentation is built using:
- sphinx (>= 4.4.0)
Expand All @@ -18,30 +18,33 @@ Setting up pygfunction
**Users** - `Download pip <https://pip.pypa.io/en/latest/>`_ and install the
latest release:

```
pip install pygfunction
```
.. code:: shell

pip install pygfunction

pip install pygfunction[plot]

Alternatively, `download the latest release
<https://github.com/MassimoCimmino/pygfunction/releases>`_ and run the
installation script:

```
pip install .
```
.. code:: shell

pip install .

**Developers** - To get the latest version of the code, you can `download the
repository from github <https://github.com/MassimoCimmino/pygfunction>`_ or
clone the project in a local directory using git:

```
git clone https://github.com/MassimoCimmino/pygfunction.git
```
.. code:: shell

git clone https://github.com/MassimoCimmino/pygfunction.git

Install *pygfunction* in development mode (this requires `pip >= 21.1`):
```
pip install --editable .
```

.. code:: shell

pip install --editable .

Test that *pygfunction* is running correctly by running any of the
provided examples in ``../pygfunction/examples/``
2 changes: 1 addition & 1 deletion doc/source/nomenclature_tables/heat_transfer.csv
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Q_t,Watts,Total net heat extraction rate of a borehole or network
R_b,m.K/W,Effective borehole thermal resistance
R_fp,m.K/W,Fluid to outer pipe wall thermal resistance
R_p,m.K/W,Conduction thermal resistance of a pipe wall
T_b,degC,Effective borehole wall temprature
T_b,degC,Effective borehole wall temperature
T_f,degC,Fluid temperature
1 change: 0 additions & 1 deletion examples/bore_field_thermal_resistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import AutoMinorLocator

import pygfunction as gt

Expand Down
2 changes: 1 addition & 1 deletion examples/comparison_load_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def main():
# Apply current load
LoadAgg.set_current_load(Q_b[i]/H)

# Evaluate borehole wall temeprature
# Evaluate borehole wall temperature
deltaT_b = LoadAgg.temporal_superposition()
T_b[n,i] = T_g - deltaT_b
toc = perf_counter()
Expand Down
9 changes: 6 additions & 3 deletions examples/custom_bore_field_from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
""" Example of definition of a bore field using custom borehole positions.

"""
import os

import pygfunction as gt


Expand All @@ -10,15 +12,16 @@ def main():
# Parameters
# -------------------------------------------------------------------------

# Filepath to bore field text file
filename = './data/custom_field_32_boreholes.txt'
# File path to bore field text file
base_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(base_dir, 'data', 'custom_field_32_boreholes.txt')

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

# Build list of boreholes
borefield = gt.borefield.Borefield.from_file(filename)
borefield = gt.borefield.Borefield.from_file(file_path)

# -------------------------------------------------------------------------
# Draw bore field
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_borehole.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def main():

# Check the geometry to make sure it is physically possible

# This class method is automatically called at the instanciation of the
# This class method is automatically called at the instantiation of the
# pipe object and raises an error if the pipe geometry is invalid. It is
# manually called here for demonstration.
check_single = SingleUTube._check_geometry()
Expand Down
5 changes: 3 additions & 2 deletions examples/discretize_boreholes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
can be calculated accurately using a small number of segments.
"""

import pygfunction as gt
from numpy import pi
import matplotlib.pyplot as plt
import numpy as np
from numpy import pi

import pygfunction as gt


def main():
Expand Down
1 change: 0 additions & 1 deletion examples/equal_inlet_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import AutoMinorLocator

import pygfunction as gt

Expand Down
4 changes: 2 additions & 2 deletions examples/fluid_temperature_reversible_flow_direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main():
# Ground properties
alpha = 2.5/2.2e6 # Ground thermal diffusivity (m2/s)
k_s = 2.5 # Ground thermal conductivity (W/m.K)
T_g = 10. # Undisturbed ground temperatue (degC)
T_g = 10. # Undisturbed ground temperature (degC)

# Grout properties
k_g = 1.5 # Grout thermal conductivity (W/m.K)
Expand Down Expand Up @@ -91,7 +91,7 @@ def main():
# Initialize bore field and pipe models
# -------------------------------------------------------------------------

# The field is a retangular array
# The field is a rectangular array
borefield = gt.borefield.Borefield.rectangle_field(
N_1, N_2, B, B, H, D, r_b)
nBoreholes = len(borefield)
Expand Down
4 changes: 2 additions & 2 deletions examples/inclined_boreholes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
extraction boreholes". Ph.D. Thesis, University of Lund, Lund, Sweden.
"""

import pygfunction as gt
import numpy as np
import matplotlib.pyplot as plt

import pygfunction as gt


def main():
Expand Down
2 changes: 1 addition & 1 deletion examples/load_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main():
# Apply current load
LoadAgg.set_current_load(Q_b_i/H)

# Evaluate borehole wall temeprature
# Evaluate borehole wall temperature
deltaT_b = LoadAgg.temporal_superposition()
T_b[i] = T_g - deltaT_b

Expand Down
1 change: 0 additions & 1 deletion examples/mixed_inlet_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import AutoMinorLocator

import pygfunction as gt

Expand Down
8 changes: 5 additions & 3 deletions examples/multiple_independent_Utubes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
Cimmino (2016).

"""
import os

import matplotlib.lines as mlines
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import AutoMinorLocator

import pygfunction as gt

Expand Down Expand Up @@ -55,7 +56,8 @@ def main():
T_f_in = np.array([6.0, -6.0, 5.0, -5.0])

# Path to validation data
filePath = './data/Cimmi16_multiple_independent_Utubes.txt'
base_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(base_dir, 'data', 'Cimmi16_multiple_independent_Utubes.txt')

# -------------------------------------------------------------------------
# Initialize pipe model
Expand Down Expand Up @@ -112,7 +114,7 @@ def main():
# -------------------------------------------------------------------------
# Load data from Cimmino (2016)
# -------------------------------------------------------------------------
data = np.loadtxt(filePath, skiprows=1)
data = np.loadtxt(file_path, skiprows=1)
ax1.plot(data[:,2:], data[:,0], 'b-',)
reference = mlines.Line2D([], [],
color='blue',
Expand Down
8 changes: 5 additions & 3 deletions examples/multipole_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
against the results of Claesson and Hellstrom (2011).

"""
import os

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

import pygfunction as gt

Expand Down Expand Up @@ -51,7 +52,8 @@ def main():
T_f = np.array([1., 1.])

# Path to validation data
filePath = './data/ClaHel11_multipole_temperature.txt'
base_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(base_dir, 'data', 'ClaHel11_multipole_temperature.txt')

# Thermal resistances for J=3
R_Claesson = 0.01*np.array([25.592, 1.561, 25.311])
Expand Down Expand Up @@ -91,7 +93,7 @@ def main():
x_T=x, y_T=y)

# Load validation data
data = np.loadtxt(filePath, skiprows=1)
data = np.loadtxt(file_path, skiprows=1)

# Configure figure and axes
fig = gt.utilities._initialize_figure()
Expand Down
1 change: 0 additions & 1 deletion examples/unequal_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
number of segments.
"""
import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator
import numpy as np

import pygfunction as gt
Expand Down
9 changes: 5 additions & 4 deletions examples/uniform_heat_extraction_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
equal for all boreholes.

"""
import matplotlib.lines as mlines
import os

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

import pygfunction as gt

Expand All @@ -29,7 +29,8 @@ def main():
alpha = 1.0e-6 # Ground thermal diffusivity (m2/s)

# Path to validation data
filePath = './data/CiBe14_uniform_heat_extraction_rate.txt'
base_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(base_dir, 'data', 'CiBe14_uniform_heat_extraction_rate.txt')

# g-Function calculation options
# The second field is evaluated with more segments to draw the
Expand Down Expand Up @@ -85,7 +86,7 @@ def main():
# -------------------------------------------------------------------------
# Load data from Cimmino and Bernier (2014)
# -------------------------------------------------------------------------
data = np.loadtxt(filePath, skiprows=55)
data = np.loadtxt(file_path, skiprows=55)

# -------------------------------------------------------------------------
# Evaluate g-functions for all fields
Expand Down
Loading