# Simplified Calculation Method for Active Anti-Floating of Elliptical Basements by Relief Wells
## Appendix A Calculation codes written in python. 1. # Load the libraries needed for the calculation
2. **import**numpy as np
3. **import**pandas as pd
4. **import**math
5. **from** scipy **import** special as special
6. **import** sympy
7. **from** sympy **import** sin, cos, asin
8. **from** scipy.optimize **import** fsolve
9. 10. # Reading data and parameter organization settings
11. **path** = 'data.xls'
12. **data** = pd.read_excel(path, sheet_name = 'ellipse', header = 0)
13. **df** = pd.DataFrameFrame(data)
14. **A** = np.array(df.values)
15. 16. **a** = A[0, 3] # Long side of pit
17. **b** = A[1, 3] # Short side of pit
18. **c** = np.sqrt(**2 - b**2 )
19. **r** = 1 # Equivalent radius of the pit (i.e., unit circle)
20. **n** = int(A[0, 4]) # Number of wells
21. **rw** = 1 # diameter of the well
22. **q** = ((a** - b)/(a** + b)) **2 # Elliptic q-parameters
23. 24. **def** cvfun_all(z, zw): # Single-well solution formula (original formula)
25. **solve**0 = ((z - zw)/(z - ((tr**2)/zw.conjugate()))) * r/np.abs(zw)
26. **solve1** = np.log(solve0)/(2 * math.pi)
27. **return** solve1
28. 29. **def** cvfun(z, zw): # Single-well solution formula (real part only)
30. **solve**0 = (np.abs(z - zw)/np.abs(z - ((tr**2)/zw.conjugate()))) * r/np.abs(zw)
31. **solve**1 = np.log(solve0)/(2 * math.pi)
32. **return** solve1
33. 34. **def** m_1(q_m): # Calculate the elliptic parameter m
35. **n_m** = sympy.Symbol(**n_m')
36. **theta_a** = q_m **(n_m * (n_m + 1))**
37. **theta_b** = q_m **(n_m **2)
38. **theta**2 = 2 * (q_m **(1/4)) * (sympy.summation(theta_a, (n_m, 0, 10)))39. theta3 = 1 + 2 * (sympy.summation(theta_b, (n_m, 1, 10)))
40. s0 = (theta2/theta3) ** 4
41. return s0
42. 43. qm = sympy.Symbol('qm')
44. m1 = sympy.lambdify(qm, m_1(qm), modules = 'numpy') # Convert sympy's format to a format usable by numpy. 45. m = m1(q)
46. s1 = special.ellipx(m)
47. 48. def es_cir1(zw): # SCT transformation of coordinates
49. n_q = sympy.Symbol('n_q')
50. u = (2 * s1/np.pi) * asin(zw/((a**2-b**2)*0.5))
51. z0 = (np.pi * u)/(2 * s1)
52. s21 = ((-1) ** n_q) * (** (n_q + (1/2))**2)) * sin((2 * n_q + 1) * 20)
53. s22 = ((-1) ** n_q) * (** (n_q * n_q)) * cos(2 * n_q * z0)
54. s2 = 2 * (sympy.summation(s21, (n_q, 0, 10)))/(1 + 2 * (sympy.summation(s22, (n_q, 1, 10))))
55. snu = (m ** (-0.25)) * s2
56. s3 = ((m ** 0.5) * 0.5) * snu
57. return s3
58. 59. zw0 = sympy.Symbol('zw0')
60. es_cir = sympy.lambdify(zw0, es_cir1(zw0), modules = 'numpy') # Convert sympy's format to a format usable by numpy. 61. 62. # Generate the matrix and compute the solution
63. zwp = np.zeros(n, dtype = complex)
64. for i in range(n):
65. zwp[i] = complex(A[i, 0], A[i, 1])
66. 67. es_zwp = np.zeros(n, dtype = complex)
68. for i in range(n): # The coordinates of the wells in the elliptical pit are converted to equivalent coordinates in the unit circle by the transformation formula and stored in an array. 69. es_zwp[i] = es_cir(complex(A[i, 0], A[i, 1]))
70. 71. T = np.zeros((n, n) # Create the n*n matrix of the ellipse, i.e., Tx = T in H
72. for i in range(0, n):
73. for j in range(0, n):
74. if i = ):
75. T[i][j] = cwfun(es_cir(zwp[i] + rw), es_zwp[j])
76. continue
77. T[i][j] = cwfun(es_zwp[i], es_zwp[j])
78. 79. H = np.zeros((n, 1)) # Create n*1 matrix, i.e., H,in Cv=H is omega, i.e., well point head value
80. for i in range(n):
81. H[i][0] = A[i, 2]
82.