diff --git a/examples/bore_field_thermal_resistance.py b/examples/bore_field_thermal_resistance.py index 54a7079..f8b3193 100644 --- a/examples/bore_field_thermal_resistance.py +++ b/examples/bore_field_thermal_resistance.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import AutoMinorLocator -from scipy import pi import pygfunction as gt @@ -61,15 +60,11 @@ def main(): # 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) + x = np.arange(nBoreholes) * B + borefield = gt.borefield.Borefield(H, D, r_b, x, 0.) + # Boreholes are connected in series: The index of the upstream + # borehole is that of the previous borehole + bore_connectivity = [i - 1 for i in range(nBoreholes)] # ------------------------------------------------------------------------- # Evaluate the effective bore field thermal resistance @@ -91,16 +86,16 @@ def main(): # Fluid to inner pipe wall thermal resistance (Single U-tube) h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe( m_flow_pipe, r_in, mu_f, rho_f, k_f, cp_f, epsilon) - R_f = 1.0/(h_f*2*pi*r_in) + R_f = 1.0 / (h_f * 2 * np.pi * r_in) # Single U-tube, same for all boreholes in the bore field UTubes = [] - for borehole in boreField: + for borehole in borefield: SingleUTube = gt.pipes.SingleUTube( pos_pipes, r_in, r_out, borehole, k_s, k_g, R_f + R_p) UTubes.append(SingleUTube) network = gt.networks.Network( - boreField[:nBoreholes], + borefield[:nBoreholes], UTubes[:nBoreholes], bore_connectivity=bore_connectivity[:nBoreholes]) diff --git a/examples/comparison_gfunction_solvers.py b/examples/comparison_gfunction_solvers.py index f31528e..89ad678 100644 --- a/examples/comparison_gfunction_solvers.py +++ b/examples/comparison_gfunction_solvers.py @@ -58,22 +58,23 @@ def main(): # Field of 6x4 (n=24) boreholes N_1 = 6 N_2 = 4 - field = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + borefield = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # ------------------------------------------------------------------------- # Evaluate g-functions # ------------------------------------------------------------------------- t0 = perf_counter() gfunc_detailed = gt.gfunction.gFunction( - field, alpha, time=time, options=options, method='detailed') + borefield, alpha, time=time, options=options, method='detailed') t1 = perf_counter() t_detailed = t1 - t0 gfunc_similarities = gt.gfunction.gFunction( - field, alpha, time=time, options=options, method='similarities') + borefield, alpha, time=time, options=options, method='similarities') t2 = perf_counter() t_similarities = t2 - t1 gfunc_equivalent = gt.gfunction.gFunction( - field, alpha, time=time, options=options, method='equivalent') + borefield, alpha, time=time, options=options, method='equivalent') t3 = perf_counter() t_equivalent = t3 - t2 diff --git a/examples/comparison_load_aggregation.py b/examples/comparison_load_aggregation.py index 37833c7..2825f49 100644 --- a/examples/comparison_load_aggregation.py +++ b/examples/comparison_load_aggregation.py @@ -16,7 +16,6 @@ import matplotlib.pyplot as plt import numpy as np -from scipy.constants import pi from scipy.interpolate import interp1d from scipy.signal import fftconvolve @@ -64,12 +63,12 @@ def main(): # ------------------------------------------------------------------------- # The field contains only one borehole - boreField = [gt.boreholes.Borehole(H, D, r_b, x=0., y=0.)] + borehole = gt.boreholes.Borehole(H, D, r_b, x=0., y=0.) # Evaluate the g-function on a geometrically expanding time grid time_gFunc = gt.utilities.time_geometric(dt, tmax, 50) # Calculate g-function gFunc = gt.gfunction.gFunction( - boreField, alpha, time=time_gFunc, options=options) + borehole, alpha, time=time_gFunc, options=options) # ------------------------------------------------------------------------- # Simulation @@ -88,7 +87,7 @@ def main(): bounds_error=False, fill_value=(0., gFunc.gFunc[-1]))(time_req) # Initialize load aggregation scheme - LoadAgg.initialize(gFunc_int/(2*pi*k_s)) + LoadAgg.initialize(gFunc_int / (2 * np.pi * k_s)) tic = perf_counter() for i in range(Nt): @@ -116,7 +115,8 @@ def main(): g = interp1d(time_gFunc, gFunc.gFunc)(time) # Convolution in Fourier domain - T_b_exact = T_g - fftconvolve(dQ, g/(2.0*pi*k_s*H), mode='full')[0:Nt] + T_b_exact = T_g - fftconvolve( + dQ, g / (2.0 * np.pi * k_s * H), mode='full')[0:Nt] # ------------------------------------------------------------------------- # plot results @@ -186,14 +186,14 @@ def synthetic_load(x): func = (168.0-C)/168.0 for i in [1, 2, 3]: - func += 1.0/(i*pi)*(np.cos(C*pi*i/84.0) - 1.0) \ - *(np.sin(pi*i/84.0*(x - B))) - func = func*A*np.sin(pi/12.0*(x - B)) \ - *np.sin(pi/4380.0*(x - B)) + func += 1.0/(i*np.pi)*(np.cos(C*np.pi*i/84.0) - 1.0) \ + *(np.sin(np.pi*i/84.0*(x - B))) + func = func*A*np.sin(np.pi/12.0*(x - B)) \ + *np.sin(np.pi/4380.0*(x - B)) y = func + (-1.0)**np.floor(D/8760.0*(x - B))*abs(func) \ + E*(-1.0)**np.floor(D/8760.0*(x - B)) \ - /np.sign(np.cos(D*pi/4380.0*(x - F)) + G) + /np.sign(np.cos(D*np.pi/4380.0*(x - F)) + G) return -y diff --git a/examples/custom_bore_field.py b/examples/custom_bore_field.py index 96108c8..0048d22 100644 --- a/examples/custom_bore_field.py +++ b/examples/custom_bore_field.py @@ -2,6 +2,8 @@ """ Example of definition of a bore field using custom borehole positions. """ +import numpy as np + import pygfunction as gt @@ -20,32 +22,27 @@ def main(): # Position 1 has a borehole that is directly on top of another bore # Position 2 has a borehole with radius inside of another bore # The duplicates will be removed with the remove_duplicates function - pos = [(0.0, 0.0), - (0.0, 0.0), # Duplicate (for example purposes) - (0.03, 0.0), # Duplicate (for example purposes) - (5.0, 0.), - (3.5, 4.0), - (1.0, 7.0), - (5.5, 5.5)] + x = np.array([0., 0., 0.03, 5., 3.5, 1., 5.5]) + y = np.array([0., 0., 0., 0., 4., 7., 5.5]) # ------------------------------------------------------------------------- # Borehole field # ------------------------------------------------------------------------- # Build list of boreholes - field = [gt.boreholes.Borehole(H, D, r_b, x, y) for (x, y) in pos] + borefield = gt.borefield.Borefield(H, D, r_b, x, y) # ------------------------------------------------------------------------- # Find and remove duplicates from borehole field # ------------------------------------------------------------------------- - field = gt.boreholes.remove_duplicates(field, disp=True) + borefield = gt.boreholes.remove_duplicates(borefield, disp=True) # ------------------------------------------------------------------------- # Draw bore field # ------------------------------------------------------------------------- - gt.boreholes.visualize_field(field) + gt.boreholes.visualize_field(borefield) return diff --git a/examples/custom_bore_field_from_file.py b/examples/custom_bore_field_from_file.py index 576431c..da4e299 100644 --- a/examples/custom_bore_field_from_file.py +++ b/examples/custom_bore_field_from_file.py @@ -18,13 +18,13 @@ def main(): # ------------------------------------------------------------------------- # Build list of boreholes - field = gt.boreholes.field_from_file(filename) + borefield = gt.borefield.Borefield.from_file(filename) # ------------------------------------------------------------------------- # Draw bore field # ------------------------------------------------------------------------- - gt.boreholes.visualize_field(field) + gt.boreholes.visualize_field(borefield) return diff --git a/examples/discretize_boreholes.py b/examples/discretize_boreholes.py index 95b98ed..f4a03f3 100644 --- a/examples/discretize_boreholes.py +++ b/examples/discretize_boreholes.py @@ -88,9 +88,10 @@ def main(): # Field of 6x4 (n=24) boreholes N_1 = 6 N_2 = 4 - boreField = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) - gt.boreholes.visualize_field(boreField) - nBoreholes = len(boreField) + borefield = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) + gt.boreholes.visualize_field(borefield) + nBoreholes = len(borefield) # ------------------------------------------------------------------------- # Initialize pipe model @@ -107,14 +108,14 @@ def main(): # Single U-tube, same for all boreholes in the bore field UTubes = [] - for borehole in boreField: + for borehole in borefield: SingleUTube = gt.pipes.SingleUTube( pos_pipes, r_in, r_out, borehole, k_s, k_g, R_f + R_p) UTubes.append(SingleUTube) m_flow_network = m_flow_borehole*nBoreholes # Network of boreholes connected in parallel - network = gt.networks.Network(boreField, UTubes) + network = gt.networks.Network(borefield, UTubes) # ------------------------------------------------------------------------- # Evaluate the g-functions for the borefield @@ -128,7 +129,7 @@ def main(): # Calculate the g-function for uniform borehole wall temperature gfunc_UBWT_uniform = gt.gfunction.gFunction( - boreField, alpha, time=time, boundary_condition='UBWT', + borefield, alpha, time=time, boundary_condition='UBWT', options=options_uniform) # Compute g-function for the MIFT case with equal number of segments per @@ -139,7 +140,7 @@ def main(): # Calculate the g-function for uniform borehole wall temperature gfunc_UBWT_unequal = gt.gfunction.gFunction( - boreField, alpha, time=time, boundary_condition='UBWT', + borefield, alpha, time=time, boundary_condition='UBWT', options=options_unequal) # Compute the rmse between the reference cases and the discretized diff --git a/examples/equal_inlet_temperature.py b/examples/equal_inlet_temperature.py index b39cd65..2dab61a 100644 --- a/examples/equal_inlet_temperature.py +++ b/examples/equal_inlet_temperature.py @@ -10,7 +10,6 @@ import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import AutoMinorLocator -from scipy import pi import pygfunction as gt @@ -74,8 +73,9 @@ def main(): # Field of 6x4 (n=24) boreholes N_1 = 6 N_2 = 4 - boreField = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) - nBoreholes = len(boreField) + borefield = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) + nBoreholes = len(borefield) # ------------------------------------------------------------------------- # Initialize pipe model @@ -88,16 +88,16 @@ def main(): m_flow_pipe = m_flow_borehole h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe( m_flow_pipe, r_in, mu_f, rho_f, k_f, cp_f, epsilon) - R_f = 1.0/(h_f*2*pi*r_in) + R_f = 1.0 / (h_f * 2 * np.pi * r_in) # Single U-tube, same for all boreholes in the bore field UTubes = [] - for borehole in boreField: + for borehole in borefield: SingleUTube = gt.pipes.SingleUTube( pos_pipes, r_in, r_out, borehole, k_s, k_g, R_f + R_p) UTubes.append(SingleUTube) m_flow_network = m_flow_borehole * nBoreholes - network = gt.networks.Network(boreField, UTubes) + network = gt.networks.Network(borefield, UTubes) # ------------------------------------------------------------------------- # Evaluate the g-functions for the borefield @@ -105,12 +105,12 @@ def main(): # Calculate the g-function for uniform heat extraction rate gfunc_uniform_Q = gt.gfunction.gFunction( - boreField, alpha, time=time, boundary_condition='UHTR', + borefield, alpha, time=time, boundary_condition='UHTR', options=options) # Calculate the g-function for uniform borehole wall temperature gfunc_uniform_T = gt.gfunction.gFunction( - boreField, alpha, time=time, boundary_condition='UBWT', + borefield, alpha, time=time, boundary_condition='UBWT', options=options) # Calculate the g-function for equal inlet fluid temperature diff --git a/examples/fluid_temperature.py b/examples/fluid_temperature.py index 77bdc30..4055fd0 100644 --- a/examples/fluid_temperature.py +++ b/examples/fluid_temperature.py @@ -13,7 +13,6 @@ """ import matplotlib.pyplot as plt import numpy as np -from scipy.constants import pi import pygfunction as gt @@ -85,16 +84,13 @@ def main(): # The field contains only one borehole borehole = gt.boreholes.Borehole(H, D, r_b, x=0., y=0.) - boreField = [borehole] # Get time values needed for g-function evaluation time_req = LoadAgg.get_times_for_simulation() # Calculate g-function gFunc = gt.gfunction.gFunction( - boreField, alpha, time=time_req, options=options) - # gt.gfunction.uniform_temperature(boreField, time_req, alpha, - # nSegments=nSegments) + borehole, alpha, time=time_req, options=options) # Initialize load aggregation scheme - LoadAgg.initialize(gFunc.gFunc/(2*pi*k_s)) + LoadAgg.initialize(gFunc.gFunc / (2 * np.pi * k_s)) # ------------------------------------------------------------------------- # Initialize pipe models @@ -107,11 +103,11 @@ def main(): # U-tube in series) 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_ser = 1.0/(h_f*2*pi*rp_in) + R_f_ser = 1.0 / (h_f * 2 * np.pi * rp_in) # Fluid to inner pipe wall thermal resistance (Double U-tube in parallel) h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe( m_flow/2, rp_in, visc_f, den_f, k_f, cp_f, epsilon) - R_f_par = 1.0/(h_f*2*pi*rp_in) + R_f_par = 1.0 / (h_f * 2 * np.pi * rp_in) # Single U-tube SingleUTube = gt.pipes.SingleUTube(pos_single, rp_in, rp_out, @@ -284,13 +280,13 @@ def synthetic_load(x): func = (168.0-C)/168.0 for i in [1, 2, 3]: - func += 1.0/(i*pi)*(np.cos(C*pi*i/84.0)-1.0) \ - *(np.sin(pi*i/84.0*(x-B))) - func = func*A*np.sin(pi/12.0*(x-B)) \ - *np.sin(pi/4380.0*(x-B)) + func += 1.0/(i*np.pi)*(np.cos(C*np.pi*i/84.0)-1.0) \ + *(np.sin(np.pi*i/84.0*(x-B))) + func = func*A*np.sin(np.pi/12.0*(x-B)) \ + *np.sin(np.pi/4380.0*(x-B)) y = func + (-1.0)**np.floor(D/8760.0*(x-B))*abs(func) \ - + E*(-1.0)**np.floor(D/8760.0*(x-B))/np.sign(np.cos(D*pi/4380.0*(x-F))+G) + + E*(-1.0)**np.floor(D/8760.0*(x-B))/np.sign(np.cos(D*np.pi/4380.0*(x-F))+G) return -y diff --git a/examples/fluid_temperature_multiple_boreholes.py b/examples/fluid_temperature_multiple_boreholes.py index 4b8685c..cf5b8e9 100644 --- a/examples/fluid_temperature_multiple_boreholes.py +++ b/examples/fluid_temperature_multiple_boreholes.py @@ -11,7 +11,6 @@ """ import matplotlib.pyplot as plt import numpy as np -from scipy.constants import pi import pygfunction as gt @@ -82,8 +81,9 @@ def main(): # ------------------------------------------------------------------------- # The field is a retangular array - boreField = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) - nBoreholes = len(boreField) + borefield = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) + nBoreholes = len(borefield) # Pipe thermal resistance R_p = gt.pipes.conduction_thermal_resistance_circular_pipe( @@ -93,17 +93,17 @@ def main(): m_flow_pipe = m_flow_borehole/2 h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe( m_flow_pipe, r_in, mu_f, rho_f, k_f, cp_f, epsilon) - R_f = 1.0/(h_f*2*pi*r_in) + R_f = 1.0 / (h_f * 2 * np.pi * r_in) # Double U-tube (parallel), same for all boreholes in the bore field UTubes = [] - for borehole in boreField: + for borehole in borefield: UTube = gt.pipes.MultipleUTube( pos, r_in, r_out, borehole, k_s, k_g, R_f + R_p, nPipes=2, config='parallel') UTubes.append(UTube) # Build a network object from the list of UTubes - network = gt.networks.Network(boreField, UTubes) + network = gt.networks.Network(borefield, UTubes) # ------------------------------------------------------------------------- # Calculate g-function @@ -116,7 +116,7 @@ def main(): network, alpha, time=time_req, m_flow_network=m_flow_network, cp_f=cp_f, boundary_condition='MIFT', options=options) # Initialize load aggregation scheme - LoadAgg.initialize(gFunc.gFunc / (2 * pi * k_s)) + LoadAgg.initialize(gFunc.gFunc / (2 * np.pi * k_s)) # ------------------------------------------------------------------------- # Simulation @@ -231,13 +231,13 @@ def synthetic_load(x): func = (168.0-C)/168.0 for i in [1, 2, 3]: - func += 1.0/(i*pi)*(np.cos(C*pi*i/84.0)-1.0) \ - *(np.sin(pi*i/84.0*(x-B))) - func = func*A*np.sin(pi/12.0*(x-B)) \ - *np.sin(pi/4380.0*(x-B)) + func += 1.0/(i*np.pi)*(np.cos(C*np.pi*i/84.0)-1.0) \ + *(np.sin(np.pi*i/84.0*(x-B))) + func = func*A*np.sin(np.pi/12.0*(x-B)) \ + *np.sin(np.pi/4380.0*(x-B)) y = func + (-1.0)**np.floor(D/8760.0*(x-B))*abs(func) \ - + E*(-1.0)**np.floor(D/8760.0*(x-B))/np.sign(np.cos(D*pi/4380.0*(x-F))+G) + + E*(-1.0)**np.floor(D/8760.0*(x-B))/np.sign(np.cos(D*np.pi/4380.0*(x-F))+G) return -y diff --git a/examples/fluid_temperature_reversible_flow_direction.py b/examples/fluid_temperature_reversible_flow_direction.py index e722f41..ae0a370 100644 --- a/examples/fluid_temperature_reversible_flow_direction.py +++ b/examples/fluid_temperature_reversible_flow_direction.py @@ -13,7 +13,6 @@ """ import matplotlib.pyplot as plt import numpy as np -from scipy.constants import pi import pygfunction as gt @@ -93,9 +92,10 @@ def main(): # ------------------------------------------------------------------------- # The field is a retangular array - boreField = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) - nBoreholes = len(boreField) - H_tot = np.sum([b.H for b in boreField]) + borefield = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) + nBoreholes = len(borefield) + H_tot = np.sum([b.H for b in borefield]) # Boreholes are connected in series bore_connectivity = [i-1 for i in range(nBoreholes)] @@ -108,17 +108,17 @@ def main(): m_flow_pipe = np.max(np.abs(m_flow_borehole)) h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe( m_flow_pipe, r_in, mu_f, rho_f, k_f, cp_f, epsilon) - R_f = 1.0 / (h_f * 2 * pi * r_in) + R_f = 1.0 / (h_f * 2 * np.pi * r_in) # Double U-tube (parallel), same for all boreholes in the bore field UTubes = [] - for borehole in boreField: + for borehole in borefield: UTube = gt.pipes.SingleUTube( pos_pipes, r_in, r_out, borehole, k_s, k_g, R_f + R_p) UTubes.append(UTube) # Build a network object from the list of UTubes network = gt.networks.Network( - boreField, UTubes, bore_connectivity=bore_connectivity) + borefield, UTubes, bore_connectivity=bore_connectivity) # ------------------------------------------------------------------------- # Calculate g-function @@ -131,7 +131,7 @@ def main(): network, alpha, time=time_req, boundary_condition='MIFT', m_flow_network=m_flow_network, cp_f=cp_f, options=options) # Initialize load aggregation scheme - LoadAgg.initialize(gFunc.gFunc / (2 * pi * k_s)) + LoadAgg.initialize(gFunc.gFunc / (2 * np.pi * k_s)) # ------------------------------------------------------------------------- # Simulation diff --git a/examples/inclined_boreholes.py b/examples/inclined_boreholes.py index b2b9a0e..d25ac2f 100644 --- a/examples/inclined_boreholes.py +++ b/examples/inclined_boreholes.py @@ -67,14 +67,15 @@ def main(): gt.utilities.cardinal_point('E')] # "Optimal" field of 8 boreholes - boreField1 = [] + boreholes = [] for i, orientation in enumerate(borehole_orientations): borehole = gt.boreholes.Borehole( H, D, r_b, i * B, 0., tilt=tilt, orientation=orientation) - boreField1.append(borehole) + boreholes.append(borehole) + borefield1 = gt.borefield.Borefield.from_boreholes(boreholes) # Visualize the borehole field - fig1 = gt.boreholes.visualize_field(boreField1) + fig1 = gt.boreholes.visualize_field(borefield1) """ Bore field #2 @@ -87,23 +88,24 @@ def main(): R = 3. # Borehole spacing from the center of the field (m) # Field of 6 boreholes in a circle - boreField2 = gt.boreholes.circle_field(N, R, H, D, r_b, tilt=tilt) + borefield2 = gt.borefield.Borefield.circle_field( + N, R, H, D, r_b, tilt=tilt) # Visualize the borehole field - fig2 = gt.boreholes.visualize_field(boreField2) + fig2 = gt.boreholes.visualize_field(borefield2) # ------------------------------------------------------------------------- # Evaluate g-functions for all fields # ------------------------------------------------------------------------- # Bore field #1 gfunc1 = gt.gfunction.gFunction( - boreField1, alpha, time=time, options=options, method='similarities') + borefield1, alpha, time=time, options=options, method='similarities') fig3 = gfunc1.visualize_g_function() fig3.suptitle('"Optimal" field of 8 boreholes') fig3.tight_layout() # Bore field #2 gfunc2 = gt.gfunction.gFunction( - boreField2, alpha, time=time, options=options, method='similarities') + borefield2, alpha, time=time, options=options, method='similarities') fig4 = gfunc2.visualize_g_function() fig4.suptitle(f'Field of {N} boreholes in a circle') fig4.tight_layout() diff --git a/examples/load_aggregation.py b/examples/load_aggregation.py index 1da0cb6..c0604a9 100644 --- a/examples/load_aggregation.py +++ b/examples/load_aggregation.py @@ -9,7 +9,6 @@ """ import matplotlib.pyplot as plt import numpy as np -from scipy.constants import pi from scipy.interpolate import interp1d from scipy.signal import fftconvolve @@ -52,14 +51,14 @@ def main(): # ------------------------------------------------------------------------- # The field contains only one borehole - boreField = [gt.boreholes.Borehole(H, D, r_b, x=0., y=0.)] + borehole = gt.boreholes.Borehole(H, D, r_b, x=0., y=0.) # Get time values needed for g-function evaluation time_req = LoadAgg.get_times_for_simulation() # Calculate g-function gFunc = gt.gfunction.gFunction( - boreField, alpha, time=time_req, options=options) + borehole, alpha, time=time_req, options=options) # Initialize load aggregation scheme - LoadAgg.initialize(gFunc.gFunc/(2*pi*k_s)) + LoadAgg.initialize(gFunc.gFunc / (2 * np.pi * k_s)) # ------------------------------------------------------------------------- # Simulation @@ -89,7 +88,8 @@ def main(): g = interp1d(time_req, gFunc.gFunc)(time) # Convolution in Fourier domain - T_b_exact = T_g - fftconvolve(dQ, g/(2.0*pi*k_s*H), mode='full')[0:Nt] + T_b_exact = T_g - fftconvolve( + dQ, g / (2.0 * np.pi * k_s * H), mode='full')[0:Nt] # ------------------------------------------------------------------------- # plot results @@ -146,13 +146,13 @@ def synthetic_load(x): func = (168.0-C)/168.0 for i in [1,2,3]: - func += 1.0/(i*pi)*(np.cos(C*pi*i/84.0)-1.0) \ - *(np.sin(pi*i/84.0*(x-B))) - func = func*A*np.sin(pi/12.0*(x-B)) \ - *np.sin(pi/4380.0*(x-B)) + func += 1.0/(i*np.pi)*(np.cos(C*np.pi*i/84.0)-1.0) \ + *(np.sin(np.pi*i/84.0*(x-B))) + func = func*A*np.sin(np.pi/12.0*(x-B)) \ + *np.sin(np.pi/4380.0*(x-B)) y = func + (-1.0)**np.floor(D/8760.0*(x-B))*abs(func) \ - + E*(-1.0)**np.floor(D/8760.0*(x-B))/np.sign(np.cos(D*pi/4380.0*(x-F))+G) + + E*(-1.0)**np.floor(D/8760.0*(x-B))/np.sign(np.cos(D*np.pi/4380.0*(x-F))+G) return -y diff --git a/examples/mixed_inlet_conditions.py b/examples/mixed_inlet_conditions.py index b34fec2..32c6ba9 100644 --- a/examples/mixed_inlet_conditions.py +++ b/examples/mixed_inlet_conditions.py @@ -11,7 +11,6 @@ import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import AutoMinorLocator -from scipy import pi import pygfunction as gt @@ -81,15 +80,12 @@ def main(): # Borehole field # ------------------------------------------------------------------------- - boreField = [] - bore_connectivity = [] - for i, H in enumerate(H_boreholes): - 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) + nBoreholes = len(H_boreholes) + x = np.arange(nBoreholes) * B + borefield = gt.borefield.Borefield(H_boreholes, D, r_b, x, 0.) + # Boreholes are connected in series: The index of the upstream + # borehole is that of the previous borehole + bore_connectivity = [i - 1 for i in range(nBoreholes)] # ------------------------------------------------------------------------- # Initialize pipe model @@ -102,16 +98,16 @@ def main(): m_flow_pipe = np.max(np.abs(m_flow_borehole)) h_f = gt.pipes.convective_heat_transfer_coefficient_circular_pipe( m_flow_pipe, r_in, mu_f, rho_f, k_f, cp_f, epsilon) - R_f = 1.0/(h_f*2*pi*r_in) + R_f = 1.0 / (h_f * 2 * np.pi * r_in) # Single U-tube, same for all boreholes in the bore field UTubes = [] - for borehole in boreField: + for borehole in borefield: SingleUTube = gt.pipes.SingleUTube( pos_pipes, r_in, r_out, borehole, k_s, k_g, R_f + R_p) UTubes.append(SingleUTube) network = gt.networks.Network( - boreField, UTubes, bore_connectivity=bore_connectivity) + borefield, UTubes, bore_connectivity=bore_connectivity) # ------------------------------------------------------------------------- # Evaluate the g-functions for the borefield @@ -119,7 +115,7 @@ def main(): # Calculate the g-function for uniform temperature gfunc_Tb = gt.gfunction.gFunction( - boreField, alpha, time=time, boundary_condition='UBWT', + borefield, alpha, time=time, boundary_condition='UBWT', options=options, method=method) # Calculate the g-function for mixed inlet fluid conditions diff --git a/examples/multiple_independent_Utubes.py b/examples/multiple_independent_Utubes.py index ebb0444..658242a 100644 --- a/examples/multiple_independent_Utubes.py +++ b/examples/multiple_independent_Utubes.py @@ -13,7 +13,6 @@ import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import AutoMinorLocator -from scipy import pi import pygfunction as gt @@ -134,11 +133,11 @@ def main(): def _pipePositions(Ds, nPipes): """ Positions pipes in an axisymetric configuration. """ - dt = pi / float(nPipes) + dt = np.pi / float(nPipes) pos = [(0., 0.) for i in range(2*nPipes)] for i in range(nPipes): - pos[i] = (Ds*np.cos(2.0*i*dt+pi), Ds*np.sin(2.0*i*dt+pi)) - pos[i+nPipes] = (Ds*np.cos(2.0*i*dt+pi+dt), Ds*np.sin(2.0*i*dt+pi+dt)) + pos[i] = (Ds*np.cos(2.0*i*dt+np.pi), Ds*np.sin(2.0*i*dt+np.pi)) + pos[i+nPipes] = (Ds*np.cos(2.0*i*dt+np.pi+dt), Ds*np.sin(2.0*i*dt+np.pi+dt)) return pos diff --git a/examples/multipole_temperature.py b/examples/multipole_temperature.py index 3182948..7637538 100644 --- a/examples/multipole_temperature.py +++ b/examples/multipole_temperature.py @@ -13,7 +13,6 @@ import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import AutoMinorLocator -from scipy import pi import pygfunction as gt @@ -43,7 +42,7 @@ def main(): # Fluid properties # Fluid to outer pipe wall thermal resistance (m.K/W) - R_fp = 1.2/(2*pi*k_g)*np.ones(n_p) + R_fp = 1.2 / (2 * np.pi * k_g) * np.ones(n_p) # Borehole wall temperature (degC) T_b = 0.0 diff --git a/examples/regular_bore_field.py b/examples/regular_bore_field.py index 5213024..0224e1c 100644 --- a/examples/regular_bore_field.py +++ b/examples/regular_bore_field.py @@ -29,34 +29,39 @@ def main(): # ------------------------------------------------------------------------- # Rectangular field of 4 x 3 boreholes - rectangularField = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + rectangle_field = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # Rectangular field triangular field of 4 x 3 borehole rows - staggeredRectangularField = gt.boreholes.staggered_rectangle_field( + staggered_rectangle_field = gt.borefield.Borefield.staggered_rectangle_field( N_1, N_2, B, B, H, D, r_b, False) # Dense field triangular field of 4 x 3 borehole rows - denseRectangularField = gt.boreholes.dense_rectangle_field( + dense_rectangle_field = gt.borefield.Borefield.dense_rectangle_field( N_1, N_2, B, H, D, r_b, False) # Box-shaped field of 4 x 3 boreholes - boxField = gt.boreholes.box_shaped_field(N_1, N_2, B, B, H, D, r_b) + box_shaped_field = gt.borefield.Borefield.box_shaped_field( + N_1, N_2, B, B, H, D, r_b) # U-shaped field of 4 x 3 boreholes - UField = gt.boreholes.U_shaped_field(N_1, N_2, B, B, H, D, r_b) + U_shaped_field = gt.borefield.Borefield.U_shaped_field( + N_1, N_2, B, B, H, D, r_b) # L-shaped field of 4 x 3 boreholes - LField = gt.boreholes.L_shaped_field(N_1, N_2, B, B, H, D, r_b) + L_shaped_field = gt.borefield.Borefield.L_shaped_field( + N_1, N_2, B, B, H, D, r_b) # Circular field of 8 boreholes - circleField = gt.boreholes.circle_field(N_b, R, H, D, r_b) + circle_field = gt.borefield.Borefield.circle_field( + N_b, R, H, D, r_b) # ------------------------------------------------------------------------- # Draw bore fields # ------------------------------------------------------------------------- for field in [ - rectangularField, staggeredRectangularField, denseRectangularField, - boxField, UField, LField, circleField]: + rectangle_field, staggered_rectangle_field, dense_rectangle_field, + box_shaped_field, U_shaped_field, L_shaped_field, circle_field]: gt.boreholes.visualize_field(field) plt.show() diff --git a/examples/unequal_segments.py b/examples/unequal_segments.py index cc7dbf8..1746abb 100644 --- a/examples/unequal_segments.py +++ b/examples/unequal_segments.py @@ -40,8 +40,9 @@ def main(): # Field of 6x4 (n=24) boreholes N_1 = 6 N_2 = 4 - boreField = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) - gt.boreholes.visualize_field(boreField) + borefield = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) + gt.boreholes.visualize_field(borefield) # ------------------------------------------------------------------------- # Evaluate g-functions with different segment options @@ -60,7 +61,7 @@ def main(): 'disp': True} gfunc_equal = gt.gfunction.gFunction( - boreField, alpha, time=time, options=options, method=method) + borefield, alpha, time=time, options=options, method=method) # Calculate g-function with predefined number of segments for each # borehole, the segment lengths will be uniform along each borehole, but @@ -68,7 +69,7 @@ def main(): # Boreholes 12, 14 and 18 have more segments than the others and their # heat extraction rate profiles are plotted. - nSegments = [12] * len(boreField) + nSegments = [12] * len(borefield) nSegments[12] = 24 nSegments[14] = 24 nSegments[18] = 24 @@ -78,7 +79,7 @@ def main(): 'profiles': True} gfunc_unequal = gt.gfunction.gFunction( - boreField, alpha, time=time, options=options, method=method) + borefield, alpha, time=time, options=options, method=method) # Calculate g-function with equal number of segments for each borehole, # unequal segment lengths along the length of the borehole defined by @@ -94,7 +95,7 @@ def main(): 'profiles': True} g_func_predefined = gt.gfunction.gFunction( - boreField, alpha, time=time, options=options, method=method) + borefield, alpha, time=time, options=options, method=method) # ------------------------------------------------------------------------- # Plot g-functions diff --git a/examples/uniform_heat_extraction_rate.py b/examples/uniform_heat_extraction_rate.py index 9c1d30e..8a8eda2 100644 --- a/examples/uniform_heat_extraction_rate.py +++ b/examples/uniform_heat_extraction_rate.py @@ -67,17 +67,20 @@ def main(): # Field of 3x2 (n=6) boreholes N_1 = 3 N_2 = 2 - boreField1 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + borefield1 = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # Field of 6x4 (n=24) boreholes N_1 = 6 N_2 = 4 - boreField2 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + borefield2 = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # Field of 10x10 (n=100) boreholes N_1 = 10 N_2 = 10 - boreField3 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + borefield3 = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # ------------------------------------------------------------------------- # Load data from Cimmino and Bernier (2014) @@ -87,7 +90,7 @@ def main(): # ------------------------------------------------------------------------- # Evaluate g-functions for all fields # ------------------------------------------------------------------------- - for i, field in enumerate([boreField1, boreField2, boreField3]): + for i, field in enumerate([borefield1, borefield2, borefield3]): gfunc = gt.gfunction.gFunction( field, alpha, time=time, boundary_condition='UHTR', options=options[i], method=method) diff --git a/examples/uniform_temperature.py b/examples/uniform_temperature.py index 5cc01b9..6936dbe 100644 --- a/examples/uniform_temperature.py +++ b/examples/uniform_temperature.py @@ -54,17 +54,20 @@ def main(): # Field of 3x2 (n=6) boreholes N_1 = 3 N_2 = 2 - boreField1 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + borefield1 = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # Field of 6x4 (n=24) boreholes N_1 = 6 N_2 = 4 - boreField2 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + borefield2 = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # Field of 10x10 (n=100) boreholes N_1 = 10 N_2 = 10 - boreField3 = gt.boreholes.rectangle_field(N_1, N_2, B, B, H, D, r_b) + borefield3 = gt.borefield.Borefield.rectangle_field( + N_1, N_2, B, B, H, D, r_b) # ------------------------------------------------------------------------- # Load data from Cimmino and Bernier (2014) @@ -74,7 +77,7 @@ def main(): # ------------------------------------------------------------------------- # Evaluate g-functions for all fields # ------------------------------------------------------------------------- - for i, field in enumerate([boreField1, boreField2, boreField3]): + for i, field in enumerate([borefield1, borefield2, borefield3]): nBoreholes = len(field) # Compare 'similarities' and 'equivalent' solvers t0 = perf_counter()