@@ -18,10 +18,18 @@ def _compute_a_b_p_d(
18
18
# TODO: All of these evaluations can be simplified and sped up
19
19
# We are doing the same things several times.
20
20
21
- a = 1 + 2 * (k1 * L_2D * np .cos (psi_rad )) ** 2
22
- b = 1 + 2 * (k1 * z_i * np .cos (psi_rad )) ** 2
23
- p = (L_2D ** 2 * b ) / (z_i ** 2 * a )
24
- d = (L_2D ** 2 - z_i ** 2 ) / (z_i ** 2 )
21
+ # Calculate a, b
22
+ common = 2 * (k1 * np .cos (psi_rad )) ** 2
23
+
24
+ square_L2D = L_2D ** 2
25
+ square_z_i = z_i ** 2
26
+
27
+ a = 1 + (common * square_L2D )
28
+ b = 1 + (common * square_z_i )
29
+
30
+ # Calculate p, d
31
+ p = (square_L2D * b ) / (square_z_i * a )
32
+ d = (square_L2D / square_z_i ) - 1
25
33
26
34
if p > 1 :
27
35
warnings .warn (f"p > 1, p: { p } " )
@@ -45,8 +53,8 @@ def analytic_F11_2d(
45
53
print (f"{ BLUE } " )
46
54
print (" F11 inputs, k1: " , k1 , " L_2D: " , L_2D , " z_i: " , z_i , " psi_rad: " , psi_rad )
47
55
48
- # TODO: Note that, without this, we get all the NaNs
49
56
# L_2D /= 1000.0
57
+ # z_i /= 1000.0
50
58
51
59
#############################
52
60
# CONSTANTS
@@ -108,35 +116,35 @@ def analytic_F22_2d(
108
116
109
117
110
118
if __name__ == "__main__" :
119
+ # NOTE: don't forget these when checking F22!
111
120
do_F11 = True
112
121
do_F22 = False
113
122
114
- # test_a, test_b, test_p, test_d = _compute_a_b_p_d(
115
- # 1.0, # k1
116
- # 5.0, # L_2D
117
- # 2.0, # z_i
118
- # 0 # psi_rad
119
- # )
120
-
121
- # assert test_a == 51
122
- # assert test_b == 9
123
- # assert test_p == (225/204)
124
- # assert test_d == (21/4)
123
+ test_a , test_b , test_p , test_d = _compute_a_b_p_d (
124
+ 1.0 , # k1
125
+ 5.0 , # L_2D
126
+ 2.0 , # z_i
127
+ 0 , # psi_rad
128
+ )
125
129
126
- # print(f"{GREEN}CONSTANTS CHECK OUT!{RESET}")
130
+ assert test_a == 51
131
+ assert test_b == 9
132
+ assert test_p == (225 / 204 )
133
+ assert test_d == (21 / 4 )
127
134
128
135
# TODO: Try everything in [km] instead of [m]
129
- k1_times_L2D = np .array ([10 , 100 , 1000 ])
130
136
c = 1.0
131
137
L_2D = 15_000.0
132
138
z_i = 500.0
133
139
psi_rad = np .pi / 4
134
- k1_vals = L_2D
140
+
141
+ k1_times_L2D = np .array ([10 , 100 , 1000 ])
142
+ k1 = k1_times_L2D / L_2D
135
143
136
144
if do_F11 :
137
- print (f"{ RED } k1*F11 @ k1*L_2D = 10: { RESET } " , analytic_F11_2d (k1_times_L2D [0 ] / L_2D , L_2D , z_i , psi_rad , c ))
138
- print (f"{ RED } k1*F11 @ k1*L_2D = 100: { RESET } " , analytic_F11_2d (k1_times_L2D [1 ] / L_2D , L_2D , z_i , psi_rad , c ))
139
- print (f"{ RED } k1*F11 @ k1*L_2D = 1000: { RESET } " , analytic_F11_2d (k1_times_L2D [2 ] / L_2D , L_2D , z_i , psi_rad , c ))
145
+ print (f"{ RED } k1*F11(k1) @ k1*L_2D = 10: { RESET } " , k1 [ 0 ] * analytic_F11_2d (k1 [0 ], c , L_2D , z_i , psi_rad ))
146
+ print (f"{ RED } k1*F11 @ k1*L_2D = 100: { RESET } " , analytic_F11_2d (k1 [1 ], c , L_2D , z_i , psi_rad ))
147
+ print (f"{ RED } k1*F11 @ k1*L_2D = 1000: { RESET } " , analytic_F11_2d (k1 [2 ], c , L_2D , z_i , psi_rad ))
140
148
141
149
if do_F22 :
142
150
print (f"{ RED } k1*F22 @ k1*L_2D = 10: { RESET } " , analytic_F22_2d (10 , c ))
0 commit comments