Skip to content

Commit

Permalink
Starting last part of validation process and restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneMeertens committed Dec 3, 2024
1 parent ff49532 commit b746ac8
Show file tree
Hide file tree
Showing 10 changed files with 26,510 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def Sandbox():
fig = plt.figure()
ax = fig.add_subplot(111)
# set axes labelsv
ax.set_xlabel(r"Time (year)")
ax.set_xlabel(r"Time (hours)")
ax.set_ylabel(r"Temperature ($^\circ C$)")
ax.yaxis.label.set_color(plt.rcParams["axes.labelcolor"])
ax.xaxis.label.set_color(plt.rcParams["axes.labelcolor"])
Expand All @@ -140,7 +140,7 @@ def Sandbox():
ax.step(time_array, df_mod_Tb[:8760], "g-", where="post", lw=1, label="Tb mod")
ax.step(time_array, Tf_L4[:8760], "b-", where="post", lw=1, label="Tf L4")
ax.step(time_array, Tf_L4_ste[:8760], "b-", linestyle="dashed", where="post", lw=1, label="Tf incl. ste")
ax.step(time_array, Tf_mod, "g-", where="post", lw=1, label="Tf mod dynamic")
ax.step(time_array, Tf_mod, "m-", where="post", lw=1, label="Tf mod dynamic")
ax.step(time_array, Tf_exp, "r-", where="post", lw=1, label="Tf experimental")
ax.set_xticks(range(0, 52 + 1, 5))

Expand All @@ -154,13 +154,13 @@ def Sandbox():
plt.figure("PVT versus PV")
nb_subplots = 2
ax1 = plt.subplot(nb_subplots, 1, 1)
ax1.plot(time_array, DTf_mod_a, label='mod dyn', color='g')
ax1.plot(time_array, DTf_mod_a, label='mod dyn', color='m')
ax1.plot(time_array, DTf_L4_a, label='L4', color='b')
ax1.plot(time_array, DTf_L4_ste_a, label='L4 ste', color= "b", linestyle="dashed",)
ax1.legend()
ax1.grid()
ax2 = plt.subplot(nb_subplots, 1, 2, sharex=ax1)
ax2.plot(time_array, DTf_mod_r, label='mod dyn', color='g')
ax2.plot(time_array, DTf_mod_r, label='mod dyn', color='m')
ax2.plot(time_array, DTf_L4_r, label='L4', color='b')
ax2.plot(time_array, DTf_L4_ste_r, label='L4 ste', color= "b", linestyle="dashed",)
ax2.legend()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,194 +24,82 @@

from GHEtool import *

plot_load = True

def Auditorium():
## To do:
# check load (ground) ghetool is same as input to modelica
# put same pipe and grout vol. heat cap in modelica
# size this model with modelica (based on average fluid temp)

num_pipes = [1, 2]
gradients = [0, 1, 2]

plot_load = False

for pipes in num_pipes:
for grad in gradients:

# Rb calculated by tool
# initiate ground, fluid and pipe data
ground_data = GroundTemperatureGradient(k_s=3, T_g=10, volumetric_heat_capacity= 2.4 * 10**6, gradient=grad)
fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3)
pipe_data = MultipleUTube(1, 0.015, 0.02, 0.4, 0.05, pipes)

# initiate borefield
borefield = Borefield()

# set ground data in borefield
borefield.set_ground_parameters(ground_data)
borefield.set_fluid_parameters(fluid_data)
borefield.set_pipe_parameters(pipe_data)
borefield.create_rectangular_borefield(5, 4, 6, 6, 100, 4, 0.075)
#borefield.set_Rb(0.12)

# set temperature bounds
borefield.set_max_avg_fluid_temperature(17)
borefield.set_min_avg_fluid_temperature(3)

# load the hourly profile
load = HourlyGeothermalLoad(simulation_period=20)
load.load_hourly_profile(os.path.join(os.path.dirname(__file__), 'auditorium.csv'), header=True, separator=";",
decimal_seperator=".", col_extraction=1,
col_injection=0)
borefield.load = load

SEER = 20
SCOP = 4

# load hourly heating and cooling load and convert it to geothermal loads
primary_geothermal_load = HourlyGeothermalLoad(simulation_period=load.simulation_period)
primary_geothermal_load.set_hourly_injection_load(load.hourly_injection_load.copy() * (1 + 1 / SEER))
primary_geothermal_load.set_hourly_extraction_load(load.hourly_extraction_load.copy() * (1 - 1 / SCOP))
# set geothermal load
borefield.load = primary_geothermal_load

if plot_load:
#Plotting Load
heating = load.hourly_extraction_load.copy() * (1 + 1 / SCOP)
cooling = load.hourly_injection_load.copy() * (1 + 1 / SEER)
t = [i for i in range(8760)]
fig = plt.subplots(figsize =(12, 8))
plt.plot(t, heating, color ='orange', lw=2, label ='Heating')
plt.plot(t, cooling, color ='b', lw=2, label ='Cooling')
plt.xlabel('Time [h]', fontsize = 18)
plt.ylabel('Load [kW]', fontsize = 18)
plt.legend(fontsize = 16)
plt.title('Profile 1: Yearly geothermal load profile auditorium building', fontsize = 22)
plt.show()


options = {'nSegments': 12,
'disp': False,
'profiles': True,
'method': 'equivalent'
}

borefield.set_options_gfunction_calculation(options)

# according to L4
L4_start = time.time()
depth_L4 = borefield.size(100, L4_sizing=True)
Rb_L4 = borefield.Rb
L4_stop = time.time()
Tf_L4 = borefield.results.peak_injection
Tb_L4 = borefield.results.Tb

# initiate borefield
borefield = Borefield()

# set ground data in borefield
borefield.set_ground_parameters(ground_data)
borefield.set_fluid_parameters(fluid_data)
borefield.set_pipe_parameters(pipe_data)
borefield.create_rectangular_borefield(5, 4, 6, 6, 100, 4, 0.075)
#borefield.set_Rb(0.12)
# set temperature bounds
borefield.set_max_avg_fluid_temperature(17)
borefield.set_min_avg_fluid_temperature(3)

# load the hourly profile
borefield.load = primary_geothermal_load
# Addidional input data needed for short-term model
rho_cp_grout = 3800000.0
rho_cp_pipe = 2150000.0

# Sample dictionary with short-term effect parameters
short_term_effects_parameters = {
'rho_cp_grout': rho_cp_grout,
'rho_cp_pipe': rho_cp_pipe,
}

options = {'nSegments': 12,
'disp': False,
'profiles': True,
'method': 'equivalent',
'cylindrical_correction': True,
'short_term_effects': True,
'ground_data': ground_data,
'fluid_data': fluid_data,
'pipe_data': pipe_data,
'borefield': borefield,
'short_term_effects_parameters': short_term_effects_parameters,
}

borefield.set_options_gfunction_calculation(options)

# according to L4 including short-term effects
L4_ste_start = time.time()
depth_L4_ste = borefield.size(100, L4_sizing=True)
Rb_L4_ste = borefield.Rb
L4_ste_stop = time.time()
Tf_L4_ste = borefield.results.peak_injection
Tb_L4_ste = borefield.results.Tb

if pipes == 1:
print(f"Results for Single-U-tube boreholes and gradient equal to {grad} K/100m:")
else:
print(f"Results for Double-U-tube boreholes and gradient equal to {grad} K/100m:")
print(
f"The sizing according to L4 has a depth of {depth_L4:.2f}m (using dynamic Rb* of {Rb_L4:.3f})")
print(
f"The sizing according to L4 (including short-term effects) has a depth of {depth_L4_ste:.2f}m (using dynamic Rb* of {Rb_L4_ste:.3f})")
print(
f"Time needed for L4-sizing is {L4_stop-L4_start:.2f}s (using dynamic Rb*)")
print(
f"Time needed for L4-sizing including short-term effect is {L4_ste_stop-L4_ste_start:.2f}s (using dynamic Rb*)")


"""
# Load modelica data and experimental data for plotting
# import data
df_st = pd.read_csv(os.path.join(os.path.dirname(__file__), 'Modelica_Tf_static.csv'), header=0, decimal=".")
df_dyn = pd.read_csv(os.path.join(os.path.dirname(__file__), 'Modelica_Tf_dynamic.csv'), header=0, decimal=".")
# set data
Tf_mod_st = np.array(df_st.iloc[:, 0])
Tf_mod_dyn = np.array(df_dyn.iloc[:, 0])
### Plotting figures
legend = True
# make a time array
time_array = borefield.load.time_L4 / 3600
time_array = time_array[:8759]
print(time_array)
# plt.rc('figure')
# create new figure and axes if it not already exits otherwise clear it.
fig = plt.figure()
ax = fig.add_subplot(111)
# set axes labelsv
ax.set_xlabel(r"Time (year)")
ax.set_ylabel(r"Temperature ($^\circ C$)")
ax.yaxis.label.set_color(plt.rcParams["axes.labelcolor"])
ax.xaxis.label.set_color(plt.rcParams["axes.labelcolor"])
# plot Temperatures
ax.step(time_array, Tb_L4[:8759], "k-", where="post", lw=1.5, label="Tb")
ax.step(time_array, Tb_L4_ste[:8759], "k-", where="post", lw=1.5, label="Tb incl. ste")
ax.step(time_array, Tf_L4[:8759], "b-", where="post", lw=1, label="Tf")
ax.step(time_array, Tf_L4_ste[:8759], "r-", where="post", lw=1, label="Tf incl. ste")
ax.step(time_array, Tf_mod_st[:8759], "c-", where="post", lw=1, label="Tf mod static")
ax.step(time_array, Tf_mod_dyn[:8759], "g-", where="post", lw=1, label="Tf mod dynamic")
ax.set_xticks(range(0, 52 + 1, 5))
# Plot legend
if legend:
ax.legend()
ax.set_xlim(left=0, right=52)
plt.show()
"""
#plt.show()

# Rb calculated by tool
# initiate ground, fluid and pipe data
ground_data = GroundTemperatureGradient(k_s=3, T_g=10, volumetric_heat_capacity= 2.4 * 10**6, gradient=2)
fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3)
pipe_data = MultipleUTube(1, 0.015, 0.02, 0.4, 0.05, 1)

# initiate borefield
borefield = Borefield()

# set ground data in borefield
borefield.set_ground_parameters(ground_data)
borefield.set_fluid_parameters(fluid_data)
borefield.set_pipe_parameters(pipe_data)
borefield.create_rectangular_borefield(5, 4, 6, 6, 100, 4, 0.075)
#borefield.set_Rb(0.12)

# set temperature bounds
borefield.set_max_avg_fluid_temperature(17)
borefield.set_min_avg_fluid_temperature(3)

# load the hourly profile
load = HourlyGeothermalLoad(simulation_period=20)
load.load_hourly_profile(os.path.join(os.path.dirname(__file__), 'auditorium.csv'), header=True, separator=";",
decimal_seperator=".", col_extraction=1,
col_injection=0)
borefield.load = load

SEER = 20
SCOP = 4

# load hourly heating and cooling load and convert it to geothermal loads
primary_geothermal_load = HourlyGeothermalLoad(simulation_period=load.simulation_period)
primary_geothermal_load.set_hourly_injection_load(load.hourly_injection_load.copy() * (1 + 1 / SEER))
primary_geothermal_load.set_hourly_extraction_load(load.hourly_extraction_load.copy() * (1 - 1 / SCOP))
# set geothermal load
borefield.load = primary_geothermal_load

if plot_load:
#Plotting Load
heating = load.hourly_extraction_load.copy() * (1 + 1 / SCOP)
cooling = load.hourly_injection_load.copy() * (1 + 1 / SEER)
t = [i for i in range(8760)]
fig = plt.subplots(figsize =(12, 8))
plt.plot(t, heating, color ='orange', lw=2, label ='Heating')
plt.plot(t, cooling, color ='b', lw=2, label ='Cooling')
plt.xlabel('Time [h]', fontsize = 18)
plt.ylabel('Load [kW]', fontsize = 18)
plt.legend(fontsize = 16)
plt.title('Profile 1: Yearly geothermal load profile auditorium building', fontsize = 22)
plt.show()


options = {'nSegments': 12,
'disp': False,
'profiles': True,
'method': 'equivalent'
}

borefield.set_options_gfunction_calculation(options)

# according to L4
L4_start = time.time()
depth_L4 = borefield.size(100, L4_sizing=True)
borefield.print_temperature_profile(plot_hourly=True)
Rb_L4 = borefield.Rb
L4_stop = time.time()
Tf_L4 = borefield.results.peak_injection #you can use this for comparing different scenario's of fluid temperature on one plot
Tb_L4 = borefield.results.Tb

print(
f"The sizing according to L4 has a depth of {depth_L4:.2f}m (using dynamic Rb* of {Rb_L4:.3f})")
print(
f"Time needed for L4-sizing is {L4_stop-L4_start:.2f}s (using dynamic Rb*)")

if __name__ == "__main__": # pragma: no cover
Auditorium()
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import os
import time

import numpy as np
import pandas as pd

import matplotlib.pyplot as plt

from GHEtool import *

plot_load = True

def Auditorium():
# Rb calculated by tool
# initiate ground, fluid and pipe data
ground_data = GroundTemperatureGradient(k_s=3, T_g=10, volumetric_heat_capacity= 2.4 * 10**6, gradient=2)
fluid_data = FluidData(0.2, 0.568, 998, 4180, 1e-3)
pipe_data = MultipleUTube(1, 0.015, 0.02, 0.4, 0.05, 1)

# initiate borefield
borefield = Borefield()

# set ground data in borefield
borefield.set_ground_parameters(ground_data)
borefield.set_fluid_parameters(fluid_data)
borefield.set_pipe_parameters(pipe_data)
borefield.create_rectangular_borefield(5, 4, 6, 6, 100, 4, 0.075)
#borefield.set_Rb(0.12)

# set temperature bounds
borefield.set_max_avg_fluid_temperature(17)
borefield.set_min_avg_fluid_temperature(3)

# load the hourly profile
load = HourlyGeothermalLoad(simulation_period=20)
load.load_hourly_profile(os.path.join(os.path.dirname(__file__), 'auditorium.csv'), header=True, separator=";",
decimal_seperator=".", col_extraction=1,
col_injection=0)
borefield.load = load

SEER = 20
SCOP = 4

# load hourly heating and cooling load and convert it to geothermal loads
primary_geothermal_load = HourlyGeothermalLoad(simulation_period=load.simulation_period)
primary_geothermal_load.set_hourly_injection_load(load.hourly_injection_load.copy() * (1 + 1 / SEER))
primary_geothermal_load.set_hourly_extraction_load(load.hourly_extraction_load.copy() * (1 - 1 / SCOP))
# set geothermal load
borefield.load = primary_geothermal_load

if plot_load:
#Plotting Load
heating = load.hourly_extraction_load.copy() * (1 + 1 / SCOP)
cooling = load.hourly_injection_load.copy() * (1 + 1 / SEER)
t = [i for i in range(8760)]
fig = plt.subplots(figsize =(12, 8))
plt.plot(t, heating, color ='orange', lw=2, label ='Heating')
plt.plot(t, cooling, color ='b', lw=2, label ='Cooling')
plt.xlabel('Time [h]', fontsize = 18)
plt.ylabel('Load [kW]', fontsize = 18)
plt.legend(fontsize = 16)
plt.title('Profile 1: Yearly geothermal load profile auditorium building', fontsize = 22)
plt.show()

#options for g-function calculation, given to other package pygfunction (Massimo)
options = {'nSegments': 12,
'disp': False,
'profiles': True,
'method': 'equivalent'
}

borefield.set_options_gfunction_calculation(options)

# according to L4
L4_start = time.time()
depth_L4 = borefield.size(100, L4_sizing=True)
borefield.print_temperature_profile(plot_hourly=True)
Rb_L4 = borefield.Rb
L4_stop = time.time()
Tf_L4 = borefield.results.peak_injection #you can use this for comparing different scenario's of fluid temperature on one plot
Tb_L4 = borefield.results.Tb

print(
f"The sizing according to L4 has a depth of {depth_L4:.2f}m (using dynamic Rb* of {Rb_L4:.3f})")
print(
f"Time needed for L4-sizing is {L4_stop-L4_start:.2f}s (using dynamic Rb*)")

if __name__ == "__main__": # pragma: no cover
Auditorium()
Loading

0 comments on commit b746ac8

Please sign in to comment.