@@ -45,7 +45,7 @@ def __init__(self, config):
45
45
self .c = (8.0 * self .sigma2 ) / (9.0 * (self .L_2d ** (2 / 3 )))
46
46
47
47
48
- def generate (self ):
48
+ def generate (self , eta_ones = False ):
49
49
50
50
# Fourier space
51
51
k_mag = self .k1 ** 2 + self .k2 ** 2
@@ -55,7 +55,11 @@ def generate(self):
55
55
C2 = 1j * phi_ * (- 1 * self .k1 )
56
56
57
57
# Random noise
58
- eta = np .fft .fft2 (np .random .normal (0 , 1 , size = (self .N1 , self .N2 )))
58
+ eta : np .ndarray
59
+ if eta_ones :
60
+ eta = np .ones_like (self .k1 )
61
+ else :
62
+ eta = np .random .normal (0 , 1 , size = (self .N1 , self .N2 ))
59
63
60
64
u1_freq = C1 * eta
61
65
u2_freq = C2 * eta
@@ -71,7 +75,15 @@ def generate(self):
71
75
return u1 , u2
72
76
73
77
74
- def mesh_study ():
78
+ def mesh_independence_study (von_karman = False ):
79
+ """
80
+ Mesh independence study.
81
+ """
82
+
83
+ print ("=" * 80 )
84
+ print ("MESH INDEPENDENCE STUDY" )
85
+ print ("=" * 80 )
86
+ print (" Square mesh" )
75
87
76
88
config = {
77
89
"sigma2" : 2.0 , # m²/s²
@@ -85,40 +97,98 @@ def mesh_study():
85
97
"N2" : 9 , # Grid points in y direction
86
98
}
87
99
88
-
89
- gen = generator (config )
90
-
91
- # Ok, x-axis = exponent of 2 for N1 and N2
92
-
93
- exponents = np .arange (4 , 12 )
100
+ exponents = np .arange (4 , 15 )
94
101
95
102
u1_norms = []
96
103
u2_norms = []
97
104
98
105
for x in exponents :
99
-
100
106
config ["N1" ] = x
101
107
config ["N2" ] = x
102
108
103
109
gen = generator (config )
110
+ u1 , u2 = gen .generate_von_karman (epsilon = 1.0 , L = 1.0 , eta_ones = True ) if von_karman else gen .generate (eta_ones = True )
104
111
105
- u1 , u2 = gen .generate ()
112
+ u1_norms .append (
113
+ np .linalg .norm (u1 ) * gen .dx * gen .dy
114
+ )
115
+ u2_norms .append (
116
+ np .linalg .norm (u2 ) * gen .dx * gen .dy
117
+ )
106
118
107
- u1_norm = np .linalg .norm (u1 ) * gen .dx * gen .dy
108
- u2_norm = np .linalg .norm (u2 ) * gen .dx * gen .dy
109
119
120
+ print ("\t variance of u1 norm" , np .var (u1_norms ))
121
+ print ("\t variance of u2 norm" , np .var (u2_norms ), "\n " )
122
+ print ("\t mean of u1 norm" , np .mean (u1_norms ))
123
+ print ("\t mean of u2 norm" , np .mean (u2_norms ))
110
124
111
- u1_norms .append (u1_norm )
112
- u2_norms .append (u2_norm )
125
+ plt .plot (exponents , u1_norms , label = "u1" )
126
+ plt .plot (exponents , u2_norms , label = "u2" )
127
+ plt .title (r"Square mesh, $N_1 = N_2 \in [4,14]$" )
128
+ plt .legend ()
129
+ plt .show ()
113
130
131
+ print (" Rectangular mesh" )
132
+
133
+ u1_norms = []
134
+ u2_norms = []
135
+
136
+ for x in exponents :
137
+ config ["N1" ] = x
138
+ config ["N2" ] = 4
139
+
140
+ gen = generator (config )
141
+ u1 , u2 = gen .generate_von_karman (epsilon = 1.0 , L = 1.0 ) if von_karman else gen .generate (eta_ones = True )
142
+
143
+ u1_norms .append (
144
+ np .linalg .norm (u1 ) * gen .dx * gen .dy
145
+ )
146
+ u2_norms .append (
147
+ np .linalg .norm (u2 ) * gen .dx * gen .dy
148
+ )
149
+
150
+ print ("\t variance of u1 norm" , np .var (u1_norms ))
151
+ print ("\t variance of u2 norm" , np .var (u2_norms ))
152
+ print ("\t mean of u1 norm" , np .mean (u1_norms ))
153
+ print ("\t mean of u2 norm" , np .mean (u2_norms ))
114
154
115
155
plt .plot (exponents , u1_norms , label = "u1" )
116
156
plt .plot (exponents , u2_norms , label = "u2" )
157
+ plt .title (r"Rectangular mesh, $N_1 \in [4,14], N_2 = 4$" )
117
158
plt .legend ()
118
159
plt .show ()
119
160
120
161
162
+ def length_independence_study ():
163
+ """
164
+ Tests several length scales L_2d as well as several L1_factor and L2_factor
165
+ values to determine how dependent the method is on these domain sizes.
166
+ """
167
+
168
+ print ("=" * 80 )
169
+ print ("LENGTH INDEPENDENCE STUDY" )
170
+ print ("=" * 80 )
171
+
172
+ config = {
173
+ "sigma2" : 2.0 ,
174
+ "L_2d" : 1.0 ,
175
+ "psi" : np .deg2rad (45.0 ),
176
+ "z_i" : 1.0 ,
177
+
178
+ "L1_factor" : 1 ,
179
+ "L2_factor" : 1 ,
180
+
181
+ "N1" : 9 ,
182
+ "N2" : 9 ,
183
+ }
184
+
185
+ pass
186
+
187
+
121
188
def debug_plot (u1 , u2 ):
189
+ """Recreates roughly fig 3 from simulation paper."""
190
+
191
+ fig , axs = plt .subplots (2 , 1 )
122
192
123
193
pass
124
194
@@ -137,14 +207,11 @@ def debug_plot(u1, u2):
137
207
"N2" : 9 , # Grid points in y direction
138
208
}
139
209
140
- gen = generator (fig2a_full_dom )
210
+ # gen = generator(fig2a_full_dom)
141
211
142
- u1 , u2 = gen .generate ()
212
+ # u1, u2 = gen.generate()
143
213
144
- mesh_study ( )
214
+ mesh_independence_study ( von_karman = True )
145
215
146
216
147
217
# for _ in range(10):
148
-
149
-
150
-
0 commit comments