Skip to content

Commit 8009a5f

Browse files
committed
Imaginary numbers and NaNs bugs caught
1 parent 1084cc7 commit 8009a5f

File tree

4 files changed

+6968
-23
lines changed

4 files changed

+6968
-23
lines changed

examples-unrendered/analytic_f11_f22.py

+30-22
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ def _compute_a_b_p_d(
1818
# TODO: All of these evaluations can be simplified and sped up
1919
# We are doing the same things several times.
2020

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
2533

2634
if p > 1:
2735
warnings.warn(f"p > 1, p: {p}")
@@ -45,8 +53,8 @@ def analytic_F11_2d(
4553
print(f"{BLUE}")
4654
print(" F11 inputs, k1: ", k1, " L_2D: ", L_2D, " z_i: ", z_i, " psi_rad: ", psi_rad)
4755

48-
# TODO: Note that, without this, we get all the NaNs
4956
# L_2D /= 1000.0
57+
# z_i /= 1000.0
5058

5159
#############################
5260
# CONSTANTS
@@ -108,35 +116,35 @@ def analytic_F22_2d(
108116

109117

110118
if __name__ == "__main__":
119+
# NOTE: don't forget these when checking F22!
111120
do_F11 = True
112121
do_F22 = False
113122

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+
)
125129

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)
127134

128135
# TODO: Try everything in [km] instead of [m]
129-
k1_times_L2D = np.array([10, 100, 1000])
130136
c = 1.0
131137
L_2D = 15_000.0
132138
z_i = 500.0
133139
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
135143

136144
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))
140148

141149
if do_F22:
142150
print(f"{RED}k1*F22 @ k1*L_2D = 10: {RESET}", analytic_F22_2d(10, c))

examples-unrendered/low_freq_prototype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
else:
3333
self.c = c
3434

35-
def _compute_kappa(self, kx, ky):
35+
def _compute_kappa(self, kx: float, ky: float) -> float:
3636
"""
3737
Compute the kappa value for a given kx, ky.
3838
"""

0 commit comments

Comments
 (0)