From 0b2d3645e480be9892533dcbd9df80412ca7210f Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 21 Oct 2017 16:08:14 -0400 Subject: [PATCH] Fix construction of small U-shaped and box-shaped fields --- pygfunction/boreholes.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pygfunction/boreholes.py b/pygfunction/boreholes.py index eb0bb6b4..a062092b 100644 --- a/pygfunction/boreholes.py +++ b/pygfunction/boreholes.py @@ -239,11 +239,14 @@ def U_shaped_field(N_1, N_2, B_1, B_2, H, D, r_b): """ borefield = [] - for i in range(N_1): - borefield.append(Borehole(H, D, r_b, x=i*B_1, y=0.)) - for j in range(1, N_2): - borefield.append(Borehole(H, D, r_b, x=0, y=j*B_2)) - borefield.append(Borehole(H, D, r_b, x=(N_1-1)*B_1, y=j*B_2)) + if N_1 > 2 and N_2 > 1: + for i in range(N_1): + borefield.append(Borehole(H, D, r_b, x=i*B_1, y=0.)) + for j in range(1, N_2): + borefield.append(Borehole(H, D, r_b, x=0, y=j*B_2)) + borefield.append(Borehole(H, D, r_b, x=(N_1-1)*B_1, y=j*B_2)) + else: + borefield = rectangle_field(N_1, N_2, B_1, B_2, H, D, r_b) return borefield @@ -291,13 +294,17 @@ def box_shaped_field(N_1, N_2, B_1, B_2, H, D, r_b): """ borefield = [] - for i in range(N_1): - borefield.append(Borehole(H, D, r_b, x=i*B_1, y=0.)) - for j in range(1, N_2-1): - borefield.append(Borehole(H, D, r_b, x=0., y=j*B_2)) - borefield.append(Borehole(H, D, r_b, x=(N_1-1)*B_1, y=j*B_2)) - for i in range(N_1): - borefield.append(Borehole(H, D, r_b, x=i*B_1, y=(N_2-1)*B_2)) + + if N_1 > 2 and N_2 > 2: + for i in range(N_1): + borefield.append(Borehole(H, D, r_b, x=i*B_1, y=0.)) + for j in range(1, N_2-1): + borefield.append(Borehole(H, D, r_b, x=0., y=j*B_2)) + borefield.append(Borehole(H, D, r_b, x=(N_1-1)*B_1, y=j*B_2)) + for i in range(N_1): + borefield.append(Borehole(H, D, r_b, x=i*B_1, y=(N_2-1)*B_2)) + else: + borefield = rectangle_field(N_1, N_2, B_1, B_2, H, D, r_b) return borefield