Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into issue140-add-the-poss…
Browse files Browse the repository at this point in the history
…iblity-to-start-in-other-months-then-january-like-september
  • Loading branch information
wouterpeere committed Jan 18, 2024
2 parents edeb7f7 + 9c15c45 commit 722c12f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 86 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Move code related to the GUI to a separate repo (issue #210).

## fixed
- Problem with multiyear hourly data and L3 sizing (issue #153).
- Problem with negative g-function values (issue #187).
- Bug in load-duration curve when not working with optimize load profile (issue #189).
- Bug in hourly data (issue #196).
Expand Down
70 changes: 6 additions & 64 deletions GHEtool/main_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Borefield(BaseClass):
'_ground_data', '_borefield_load', \
'options_pygfunction', \
'THRESHOLD_WARNING_SHALLOW_FIELD', \
'gui', 'D', 'r_b', 'gfunction_calculation_object', \
'D', 'r_b', 'gfunction_calculation_object', \
'_calculation_setup', \
'_secundary_borefield_load', '_building_load', '_external_load'

Expand All @@ -56,7 +56,6 @@ def __init__(self, peak_heating: np.ndarray | list = None,
baseload_cooling: np.ndarray | list = None,
borefield=None,
custom_gfunction: CustomGFunction = None,
gui: bool = False,
load: _LoadData = None):
"""
Expand All @@ -74,9 +73,6 @@ def __init__(self, peak_heating: np.ndarray | list = None,
Set the borefield for which the calculations will be carried out
custom_gfunction : CustomGFunction
Custom gfunction dataset
gui : bool
True if the Borefield object is created by the GUI. This should not be used in the code version
of GHEtool itself.
Examples
--------
Expand Down Expand Up @@ -156,9 +152,6 @@ def __init__(self, peak_heating: np.ndarray | list = None,
self._calculation_setup: CalculationSetup = CalculationSetup()
self.calculation_setup()

# check if the GHEtool is used by the gui i
self.gui = gui

# load on the geothermal borefield, used in calculations
self._borefield_load = MonthlyGeothermalLoadAbsolute()
# geothermal load, but converted to a secundary demand in optimise_load_profile
Expand Down Expand Up @@ -1584,7 +1577,7 @@ def print_temperature_profile(self, legend: bool = True, plot_hourly: bool = Fal
Returns
-------
fig, ax
If the borefield object is part of the GUI, it returns the figure object
Figure object
"""
# calculate temperature profile
self._calculate_temperature_profile(hourly=plot_hourly)
Expand All @@ -1608,7 +1601,7 @@ def print_temperature_profile_fixed_depth(self, depth: float, legend: bool = Tru
Returns
-------
fig, ax
If the borefield object is part of the GUI, it returns the figure object
Figure object
"""
# calculate temperature profile
self._calculate_temperature_profile(H=depth, hourly=plot_hourly)
Expand All @@ -1618,8 +1611,6 @@ def print_temperature_profile_fixed_depth(self, depth: float, legend: bool = Tru
def _plot_temperature_profile(self, legend: bool = True, plot_hourly: bool = False) -> Tuple[plt.Figure, plt.Axes]:
"""
This function plots the temperature profile.
If the Borefield object exists as part of the GUI, than the figure is returned,
otherwise it is shown.
Parameters
----------
Expand All @@ -1631,7 +1622,7 @@ def _plot_temperature_profile(self, legend: bool = True, plot_hourly: bool = Fal
Returns
-------
fig, ax
If the borefield object is part of the GUI, it returns the figure object
Figure object
"""

# make a time array
Expand Down Expand Up @@ -1673,9 +1664,7 @@ def _plot_temperature_profile(self, legend: bool = True, plot_hourly: bool = Fal
if legend:
ax.legend()
ax.set_xlim(left=0, right=self.simulation_period)
# show figure if not in gui mode
if not self.gui:
plt.show()
plt.show()
return fig, ax

def _delete_calculated_temperatures(self) -> None:
Expand Down Expand Up @@ -2184,52 +2173,5 @@ def plot_load_duration(self, legend: bool = False) -> Tuple[plt.Figure, plt.Axes
# plot legend if wanted
if legend:
ax.legend() #
# show plt if not in gui
if not self.gui:
plt.show()
return fig, ax

def _plot_load_duration(self, legend: bool = False) -> Tuple[plt.Figure, plt.Axes]:
"""
This function makes a load-duration curve from the hourly values.
Parameters
----------
legend : bool
True if the figure should have a legend
Returns
----------
Tuple
plt.Figure, plt.Axes
"""

load = self._secundary_borefield_load if self._secundary_borefield_load != HourlyGeothermalLoad() else self.load

# sort heating and cooling load
heating = load.hourly_heating_load.copy()
heating[::-1].sort()

cooling = load.hourly_cooling_load.copy()
cooling.sort()
cooling = cooling * (-1)
# create new figure and axes if it not already exits otherwise clear it.
fig = plt.figure()
ax = fig.add_subplot(111)
# add sorted loads to plot
ax.step(np.arange(0, 8760, 1), heating, 'r-', label="Heating")
ax.step(np.arange(0, 8760, 1), cooling, 'b-', label="Cooling")
# create 0 line
ax.hlines(0, 0, 8759, color="black")
# add labels
ax.set_xlabel("Time [hours]")
ax.set_ylabel("Power [kW]")
# set x limits to 8760
ax.set_xlim(0, 8760)
# plot legend if wanted
if legend:
ax.legend() # pragma: no cover
# show plt if not in gui
if not self.gui:
plt.show() # pragma: no cover
plt.show()
return fig, ax
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ GHEtool is in constant development with new methods, enhancements and features a
## Requirements
This code is tested with Python 3.8, 3.9, 3.10, 3.11 and 3.12 and requires the following libraries (the versions mentioned are the ones with which the code is tested)

* Numpy (>=1.20.2)
* Scipy (>=1.6.2)
* Matplotlib (>=3.4.1)
* Pygfunction (>=2.2.2)
* Openpyxl (>=3.0.7)
* Pandas (>=1.2.4)
* matplotlib>=3.5.2
* numpy>=1.23.1
* pandas>=1.4.3
* pygfunction>=2.2.1
* scipy>=1.8.1
* scikit-optimize>=0.9.0

For the tests

Expand Down
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ The user manual for GHEtool Pro, together with instructions for installation, yo

.. image:: GHEtoolPro.png
:alt: Image of GHEtool Pro
:width: 500
:width: 450
:align: center


GHEtool Community
-----------------
Expand Down
20 changes: 8 additions & 12 deletions docs/sources/code/getting_started.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Installation

## Requirements
This code is tested with Python 3.8, 3.9, 3.10 and 3.11 and requires the following libraries:

* Numpy (>=1.20.2)
* Scipy (>=1.6.2)
* Matplotlib (>=3.4.1)
* Pygfunction (>=2.2.0)
* Openpyxl (>=3.0.7)
* Pandas (>=1.2.4)

For the GUI

* ScenarioGUI (>=0.3.0)
This code is tested with Python 3.8, 3.9, 3.10, 3.11 and 3.12 and requires the following libraries (the versions mentioned are the ones with which the code is tested)

* matplotlib>=3.5.2
* numpy>=1.23.1
* pandas>=1.4.3
* pygfunction>=2.2.1
* scipy>=1.8.1
* scikit-optimize>=0.9.0

For the tests

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ matplotlib>=3.5.2
numpy>=1.23.1
pandas>=1.4.3
pygfunction>=2.2.1
configparser>=5.3.0
scipy>=1.8.1
scikit-optimize>=0.9.0
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ install_requires =
numpy>=1.23.1
pandas>=1.4.3
pygfunction>=2.2.1
configparser>=5.3.0
scipy>=1.8.1
pytest>=7.1.2
scikit-optimize>=0.9.0

[flake8]
Expand Down

0 comments on commit 722c12f

Please sign in to comment.