11# noinspection PyPackageRequirements
22import copy
3+ import math
34
45import matplotlib .pyplot as plt
56import numpy as np
1112from GHEtool .logger import ghe_logger
1213from GHEtool .Validation .cases import load_case
1314from GHEtool .VariableClasses .LoadData import MonthlyGeothermalLoadAbsolute , HourlyGeothermalLoad , HourlyBuildingLoad , \
14- HourlyBuildingLoadMultiYear
15+ HourlyBuildingLoadMultiYear , MonthlyBuildingLoadAbsolute
1516from GHEtool .VariableClasses .BaseClass import UnsolvableDueToTemperatureGradient
1617
1718data = GroundConstantTemperature (3 , 10 )
@@ -70,6 +71,7 @@ def test_nb_of_boreholes():
7071 borefield .set_ground_parameters (data_ground_flux )
7172 assert borefield .number_of_boreholes == 120
7273 borefield .set_borefield (gt .boreholes .rectangle_field (5 , 5 , 6 , 6 , 110 , 0.1 , 0.07 ))
74+ assert np .isclose (borefield .avg_tilt , 0 )
7375 assert np .isclose (borefield .H , 110 )
7476 assert np .isclose (borefield .r_b , 0.07 )
7577 assert np .isclose (borefield .D , 0.1 )
@@ -78,11 +80,13 @@ def test_nb_of_boreholes():
7880 assert np .any (borefield .gfunction_calculation_object .borehole_length_array )
7981 borefield .borefield = gt .boreholes .rectangle_field (6 , 5 , 6 , 6 , 100 , 1 , 0.075 )
8082 assert not np .any (borefield .gfunction_calculation_object .borehole_length_array )
83+ assert np .isclose (borefield .avg_tilt , 0 )
8184 assert np .isclose (borefield .H , 100 )
8285 assert np .isclose (borefield .r_b , 0.075 )
8386 assert np .isclose (borefield .D , 1 )
8487 borefield .gfunction (5000 , 110 )
8588 assert np .any (borefield .gfunction_calculation_object .borehole_length_array )
89+ assert np .isclose (borefield .avg_tilt , 0 )
8690 assert borefield .number_of_boreholes == 30
8791 borefield .borefield = None
8892 assert not np .any (borefield .gfunction_calculation_object .borehole_length_array )
@@ -91,6 +95,7 @@ def test_nb_of_boreholes():
9195 borefield .borefield = gt .boreholes .rectangle_field (6 , 5 , 6 , 6 , 100 , 1 , 0.075 )
9296 borefield .gfunction (5000 , 110 )
9397 assert np .any (borefield .gfunction_calculation_object .borehole_length_array )
98+ assert np .isclose (borefield .avg_tilt , 0 )
9499 borefield .set_borefield (None )
95100 assert not np .any (borefield .gfunction_calculation_object .borehole_length_array )
96101 assert borefield .number_of_boreholes == 0
@@ -105,6 +110,17 @@ def test_set_borefield():
105110 assert borefield .H == 125
106111
107112
113+ def test_tilt ():
114+ borefield = Borefield ()
115+ borefield .set_borefield ([
116+ gt .boreholes .Borehole (100 , 4 , 0.075 , 0 , 0 ),
117+ gt .boreholes .Borehole (150 , 4 , 0.075 , 10 , 0 , tilt = math .pi / 9 )
118+ ])
119+ assert borefield .H == 125
120+ assert np .isclose (borefield .avg_tilt , math .pi / 18 )
121+ assert np .isclose (borefield .depth , 4 + (100 + 150 * math .cos (math .pi / 9 )) / 2 )
122+
123+
108124def test_gfunction_with_irregular_borehole_depth ():
109125 borefield = Borefield ()
110126 borefield .ground_data = ground_data_constant
@@ -1166,3 +1182,33 @@ def test_repr_():
11661182 'Peak extraction duration [hour]: 6.0\n ' \
11671183 'Simulation period [year]: 20\n ' \
11681184 'First month of simulation [-]: 1' == borefield .__repr__ ()
1185+
1186+
1187+ def test_with_titled_borefield ():
1188+ # define params
1189+ ground_data = GroundFluxTemperature (1.9 , 10 )
1190+ pipe_data = DoubleUTube (1.5 , 0.013 , 0.016 , 0.4 , 0.035 )
1191+ fluid_data = FluidData (mfr = 0.2 )
1192+ fluid_data .import_fluid_from_pygfunction (gt .media .Fluid ('MPG' , 30 , 2 ))
1193+ load_data = MonthlyBuildingLoadAbsolute (
1194+ np .array ([.176 , .174 , .141 , .1 , .045 , 0 , 0 , 0 , 0.012 , 0.065 , 0.123 , 0.164 ]) * 8 * 1350 ,
1195+ np .array ([0 , 0 , 0 , 0 , .112 , .205 , .27 , .264 , .149 , 0 , 0 , 0 ]) * 4 * 700 ,
1196+ np .array ([1 , .991 , .802 , .566 , .264 , 0 , 0 , 0 , .0606 , .368 , .698 , .934 ]) * 8 ,
1197+ np .array ([0 , 0 , 0 , 0 , .415 , .756 , 1 , .976 , .549 , 0 , 0 , 0 ]) * 4
1198+ )
1199+
1200+ # define borefield
1201+ borefield_tilted = [gt .boreholes .Borehole (150 , 0.75 , 0.07 , - 3 , 0 , math .pi / 7 , orientation = math .pi ),
1202+ gt .boreholes .Borehole (150 , 0.75 , 0.07 , 3 , 0 , math .pi / 7 , orientation = 0 )]
1203+
1204+ # initiate GHEtool object with tilted borefield
1205+ borefield = Borefield (borefield = borefield_tilted , load = load_data )
1206+ borefield .set_ground_parameters (ground_data )
1207+ borefield .set_pipe_parameters (pipe_data )
1208+ borefield .set_fluid_parameters (fluid_data )
1209+ borefield .set_max_avg_fluid_temperature (17 )
1210+
1211+ assert np .isclose (borefield .depth , 150 * math .cos (math .pi / 7 ) + 0.75 )
1212+ assert np .isclose (borefield .ground_data .calculate_Tg (borefield .depth , borefield .D ), 12.157557845032045 )
1213+
1214+ assert np .isclose (borefield .size_L3 (), 111.58488656187147 )
0 commit comments