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

Remove matplotlib dependency overhead #311

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 2 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 @@ -42,10 +42,10 @@ fluid temperatures in the boreholes for several U-tube pipe configurations.

*pygfunction* was developed and tested using Python 3.7. In addition, the
following packages are needed to run *pygfunction* and its examples:
- matplotlib (>= 3.5.1),
- 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 Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy >= 1.21.5
scipy >= 1.7.3
matplotlib >= 3.5.1
matplotlib >= 3.8.4
numpydoc >= 1.2.0
recommonmark >= 0.6.0
sphinx >= 4.4.0
Expand Down
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
1 change: 0 additions & 1 deletion doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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)
Expand Down
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
6 changes: 3 additions & 3 deletions examples/bore_field_thermal_resistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"""
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import AutoMinorLocator

import pygfunction as gt
from utilities import utilities


def main():
Expand Down Expand Up @@ -110,7 +110,7 @@ def main():
# -------------------------------------------------------------------------

# Configure figure and axes
fig = gt.utilities._initialize_figure()
fig = utilities.initialize_figure()

ax1 = fig.add_subplot(111)
# Axis labels
Expand All @@ -120,7 +120,7 @@ def main():
ax1.set_xlim([0., 1.])
ax1.set_ylim([0., 1.])

gt.utilities._format_axes(ax1)
utilities.format_axes(ax1)

# Bore field thermal resistances
ax1.plot(m_flow_network, R[0,:], '-', label='1 borehole')
Expand Down
21 changes: 11 additions & 10 deletions examples/comparison_gfunction_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from time import perf_counter

import pygfunction as gt
from utilities import utilities


def main():
Expand Down Expand Up @@ -82,7 +83,7 @@ def main():
# Plot results
# -------------------------------------------------------------------------
# Draw g-functions
ax = gfunc_detailed.visualize_g_function().axes[0]
ax = utilities.visualize_g_function(gfunc_detailed).axes[0]
ax.plot(lntts, gfunc_similarities.gFunc, 'bx')
ax.plot(lntts, gfunc_equivalent.gFunc, 'ro')
ax.legend([f'detailed (t = {t_detailed:.3f} sec)',
Expand All @@ -93,12 +94,12 @@ def main():

# Draw absolute error
# Configure figure and axes
fig = gt.utilities._initialize_figure()
fig = utilities.initialize_figure()
ax = fig.add_subplot(111)
# Axis labels
ax.set_xlabel(r'ln$(t/t_s)$')
ax.set_ylabel(r'Absolute error')
gt.utilities._format_axes(ax)
utilities.format_axes(ax)
# Absolute error
ax.plot(lntts, np.abs(gfunc_similarities.gFunc - gfunc_detailed.gFunc),
'-', label='similarities')
Expand All @@ -112,12 +113,12 @@ def main():

# Draw relative error
# Configure figure and axes
fig = gt.utilities._initialize_figure()
fig = utilities.initialize_figure()
ax = fig.add_subplot(111)
# Axis labels
ax.set_xlabel(r'ln$(t/t_s)$')
ax.set_ylabel(r'Relative error')
gt.utilities._format_axes(ax)
utilities.format_axes(ax)
# Relative error
gFunc_ref = gfunc_detailed.gFunc # reference g-function
ax.plot(lntts, (gfunc_similarities.gFunc - gFunc_ref) / gFunc_ref,
Expand Down Expand Up @@ -155,7 +156,7 @@ def main():
# Plot results
# -------------------------------------------------------------------------
# Draw g-functions
ax = gfunc_similarities.visualize_g_function().axes[0]
ax = utilities.visualize_g_function(gfunc_similarities).axes[0]
ax.plot(lntts, gfunc_equivalent.gFunc, 'ro')
ax.legend([f'similarities (t = {t_similarities:.3f} sec)',
f'equivalent (t = {t_equivalent:.3f} sec)'])
Expand All @@ -164,12 +165,12 @@ def main():

# Draw absolute error
# Configure figure and axes
fig = gt.utilities._initialize_figure()
fig = utilities.initialize_figure()
ax = fig.add_subplot(111)
# Axis labels
ax.set_xlabel(r'ln$(t/t_s)$')
ax.set_ylabel(r'Absolute error')
gt.utilities._format_axes(ax)
utilities.format_axes(ax)
# Absolute error
ax.plot(lntts, np.abs(gfunc_equivalent.gFunc - gfunc_similarities.gFunc),
label='equivalent')
Expand All @@ -181,12 +182,12 @@ def main():

# Draw relative error
# Configure figure and axes
fig = gt.utilities._initialize_figure()
fig = utilities.initialize_figure()
ax = fig.add_subplot(111)
# Axis labels
ax.set_xlabel(r'ln$(t/t_s)$')
ax.set_ylabel(r'Relative error')
gt.utilities._format_axes(ax)
utilities.format_axes(ax)
# Relative error
ax.plot(lntts, (gfunc_equivalent.gFunc - gfunc_similarities.gFunc) / gfunc_similarities.gFunc,
label='equivalent')
Expand Down
11 changes: 6 additions & 5 deletions examples/comparison_load_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from scipy.signal import fftconvolve

import pygfunction as gt
from utilities import utilities


def main():
Expand Down Expand Up @@ -97,7 +98,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 All @@ -123,21 +124,21 @@ def main():
# -------------------------------------------------------------------------

# Configure figure and axes
fig = gt.utilities._initialize_figure()
fig = utilities.initialize_figure()

ax1 = fig.add_subplot(311)
# Axis labels
ax1.set_xlabel(r'$t$ [hours]')
ax1.set_ylabel(r'$Q_b$ [W]')
gt.utilities._format_axes(ax1)
utilities.format_axes(ax1)
hours = np.array([(j+1)*dt/3600. for j in range(Nt)])
ax1.plot(hours, Q_b)

ax2 = fig.add_subplot(312)
# Axis labels
ax2.set_xlabel(r'$t$ [hours]')
ax2.set_ylabel(r'$T_b$ [degC]')
gt.utilities._format_axes(ax2)
utilities.format_axes(ax2)
for T_b_n, line, label in zip(T_b, loadAgg_lines, loadAgg_labels):
ax2.plot(hours, T_b_n, line, label=label)
ax2.plot(hours, T_b_exact, 'k.', label='exact')
Expand All @@ -147,7 +148,7 @@ def main():
# Axis labels
ax3.set_xlabel(r'$t$ [hours]')
ax3.set_ylabel(r'Error [degC]')
gt.utilities._format_axes(ax3)
utilities.format_axes(ax3)
for T_b_n, line, label in zip(T_b, loadAgg_lines, loadAgg_labels):
ax3.plot(hours, T_b_n - T_b_exact, line, label=label)
# Adjust to plot window
Expand Down
3 changes: 2 additions & 1 deletion examples/custom_bore_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np

import pygfunction as gt
from utilities import utilities


def main():
Expand Down Expand Up @@ -42,7 +43,7 @@ def main():
# Draw bore field
# -------------------------------------------------------------------------

borefield.visualize_field()
utilities.visualize_field(borefield)

return

Expand Down
12 changes: 8 additions & 4 deletions examples/custom_bore_field_from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,33 @@
""" Example of definition of a bore field using custom borehole positions.

"""
import os

import pygfunction as gt
from utilities import utilities


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
# -------------------------------------------------------------------------

borefield.visualize_field()
utilities.visualize_field(borefield)

return

Expand Down
9 changes: 5 additions & 4 deletions examples/custom_borehole.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from scipy.constants import pi

import pygfunction as gt
from utilities import utilities


def main():
Expand Down Expand Up @@ -87,7 +88,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 All @@ -101,7 +102,7 @@ def main():
f'{R_b:.4f} m.K/W')

# Visualize the borehole geometry and save the figure
fig_single = SingleUTube.visualize_pipes()
fig_single = utilities.visualize_pipes(SingleUTube)
fig_single.savefig('single-u-tube-borehole.png')

# -------------------------------------------------------------------------
Expand Down Expand Up @@ -153,7 +154,7 @@ def main():
f'{R_b_parallel:.4f} m.K/W')

# Visualize the borehole geometry and save the figure
fig_double = DoubleUTube_series.visualize_pipes()
fig_double = utilities.visualize_pipes(DoubleUTube_series)
fig_double.savefig('double-u-tube-borehole.png')

# -------------------------------------------------------------------------
Expand Down Expand Up @@ -198,7 +199,7 @@ def main():
print(f'Coaxial tube Borehole thermal resistance: {R_b:.4f} m.K/W')

# Visualize the borehole geometry and save the figure
fig_coaxial = Coaxial.visualize_pipes()
fig_coaxial = utilities.visualize_coaxial_pipes(Coaxial)
fig_coaxial.savefig('coaxial-borehole.png')


Expand Down
10 changes: 6 additions & 4 deletions examples/discretize_boreholes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
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
from utilities import utilities


def main():
Expand Down Expand Up @@ -90,7 +92,7 @@ def main():
N_2 = 4
borefield = gt.borefield.Borefield.rectangle_field(
N_1, N_2, B, B, H, D, r_b)
gt.boreholes.visualize_field(borefield)
utilities.visualize_field(borefield)
nBoreholes = len(borefield)

# -------------------------------------------------------------------------
Expand Down Expand Up @@ -154,7 +156,7 @@ def main():
# Plot g-functions
# -------------------------------------------------------------------------

ax = gfunc_MIFT_uniform.visualize_g_function().axes[0]
ax = utilities.visualize_g_function(gfunc_MIFT_uniform).axes[0]
ax.plot(np.log(time / ts), gfunc_UBWT_uniform.gFunc)
ax.plot(np.log(time / ts), gfunc_MIFT_unequal.gFunc, 'o')
ax.plot(np.log(time / ts), gfunc_UBWT_unequal.gFunc, 'o')
Expand Down
Loading