Skip to content

Commit 1a652d8

Browse files
committed
Checkpointing; most plots correct, some issues with figure 2 target, possibly due to c. Starting work on averaged 15 and 16
1 parent eb5b12c commit 1a652d8

File tree

3 files changed

+826
-89
lines changed

3 files changed

+826
-89
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import numpy as np
2+
import scipy.integrate as integrate
3+
4+
# import scipy.special as special
5+
6+
7+
def _calculate_kappa(k1: float, k2: float, psi: float) -> float:
8+
"""
9+
Calculate the "augmented wavenumber" kappa
10+
"""
11+
12+
return np.sqrt(2 * ((k1 * np.cos(psi)) ** 2 + (k2 * np.sin(psi)) ** 2))
13+
14+
15+
def _E_kappa(kappa: float, L2D: float, c: float) -> float:
16+
"""
17+
Calculates the energy spectrum in terms of kappa = sqrt(2(k1^2cos^2psi + k2^2sin^2psi))
18+
"""
19+
numerator = c * (kappa**3)
20+
denominator = (L2D ** (-2) + kappa**2) ** (7 / 3)
21+
22+
return numerator / denominator
23+
24+
25+
def _E_kappa_attenuated(kappa: float, L2D: float, z_i: float, c: float) -> float:
26+
"""
27+
Attenuated energy spectrum in terms of kappa
28+
"""
29+
30+
return _E_kappa(kappa, L2D, c) / (1 + (kappa * z_i) ** 2)
31+
32+
33+
def _spectral_tensor_common(kappa: float, k: float, L2D: float, z_i: float, c: float) -> float:
34+
"""
35+
Common spectral tensor calculations
36+
"""
37+
38+
energy = _E_kappa_attenuated(kappa, L2D, z_i, c)
39+
40+
denom = np.pi * kappa
41+
42+
return energy / denom
43+
44+
45+
def _spectral_tensor_11(k1: float, k2: float, psi: float, L2D: float, z_i: float, c: float) -> float:
46+
"""
47+
Simulated spectral tensor i = j = 1 component
48+
49+
Note that all that varies between this and the 22 method is the "parenthetical"
50+
"""
51+
kappa = _calculate_kappa(k1, k2, psi)
52+
k = np.sqrt(k1**2 + k2**2)
53+
54+
leading_factor = _spectral_tensor_common(kappa, k, L2D, z_i, c)
55+
56+
parenthetical = 1 - (k1 / k) ** 2
57+
58+
return leading_factor * parenthetical
59+
60+
61+
######################################################################################################################
62+
# "Public" integrator methods
63+
64+
65+
def eq6_numerical_F11_2D(k1: float, psi: float, L2D: float, z_i: float, c: float) -> tuple[float, float]:
66+
"""
67+
By numerical integration, provides an "analytical" solution for F_11 2-dimensional spectrum
68+
"""
69+
res, err = integrate.quad(lambda k2: _spectral_tensor_11(k1, k2, psi, L2D, z_i, c), -np.inf, np.inf)
70+
71+
return res, err
72+
73+
74+
# def _spectral_tensor_22(k1: float, k2: float, psi: float, L2D: float, z_i: float, c: float) -> float:
75+
# """
76+
# Simulated spectral tensor i = j = 2 component
77+
78+
# Note that all that varies between this and the 11 method is the "parenthetical"
79+
# """
80+
# kappa = _calculate_kappa(k1, k2, psi)
81+
# k = np.sqrt(k1**2 + k2**2)
82+
83+
# leading_factor = _spectral_tensor_common(kappa, k, L2D, z_i, c)
84+
85+
# parenthetical = 1 - (k2/k)**2
86+
87+
# return leading_factor * parenthetical

examples-unrendered/MM_random_dev/eq6_numerical.ipynb

+468-89
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)