Commit 3491dbb
Compute surface elevation using IFFT (#250)
* Prevent nan values for zero-frequency component in spectrum
Previously providing a zero frequency when creating a spectrum (JONSWAP or Pierson Moskowitz) produced a NaN value. This is due the f^-5 and f^-4 terms in the calculation.
The zero frequency is a valid input and is important when calculating the surface elevation from the spectrum. We know, however, that the zero frequency should __always__ have zero amplitude as the surface elevation has a mean of zero.
This change ensures that if a zero frequency is provided, the amplitude is set to zero.
* Compute surface elevation using IFFT
Previously the surface elevation was only computed using the 'sum of sines' method. This has been found to be prohibitively slow when computing long duration surface elevation traces.
This commit introduces the capability to compute the surface elevation using the more computationally efficient IFFT. The IFFT routine is used by default if no frequency bins are provided and the input frequency vector is equally spaced.
For example a 1hr sea state realisation at 20Hz took 11s to compute using the 'sum of sines' and 0.007s using the IFFT.
Fixes #229
* add docstrings to surface_elevation
* update surface_elevation calls in examples
---------
Co-authored-by: akeeste <akeeste@sandia.gov>1 parent 008cba8 commit 3491dbb
File tree
6 files changed
+376
-296
lines changed- examples
- mhkit
- tests/wave
- wave
6 files changed
+376
-296
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Large diffs are not rendered by default.
Lines changed: 224 additions & 218 deletions
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
58 | 68 | | |
59 | 69 | | |
60 | 70 | | |
| |||
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
69 | 90 | | |
70 | 91 | | |
71 | 92 | | |
| |||
129 | 150 | | |
130 | 151 | | |
131 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
132 | 161 | | |
133 | 162 | | |
134 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
94 | 104 | | |
95 | 105 | | |
96 | 106 | | |
| |||
132 | 142 | | |
133 | 143 | | |
134 | 144 | | |
135 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
136 | 156 | | |
137 | 157 | | |
138 | 158 | | |
| |||
162 | 182 | | |
163 | 183 | | |
164 | 184 | | |
165 | | - | |
| 185 | + | |
166 | 186 | | |
167 | 187 | | |
168 | 188 | | |
| |||
175 | 195 | | |
176 | 196 | | |
177 | 197 | | |
| 198 | + | |
| 199 | + | |
178 | 200 | | |
179 | 201 | | |
180 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
181 | 210 | | |
182 | 211 | | |
183 | 212 | | |
| |||
194 | 223 | | |
195 | 224 | | |
196 | 225 | | |
| 226 | + | |
197 | 227 | | |
198 | 228 | | |
199 | 229 | | |
200 | 230 | | |
201 | 231 | | |
202 | 232 | | |
203 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
204 | 241 | | |
205 | 242 | | |
206 | 243 | | |
| |||
209 | 246 | | |
210 | 247 | | |
211 | 248 | | |
| 249 | + | |
212 | 250 | | |
213 | 251 | | |
214 | 252 | | |
215 | 253 | | |
| 254 | + | |
216 | 255 | | |
217 | 256 | | |
218 | 257 | | |
| |||
231 | 270 | | |
232 | 271 | | |
233 | 272 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
245 | 295 | | |
246 | 296 | | |
247 | 297 | | |
| |||
0 commit comments