|
1 | 1 | import time |
2 | | -from math import ceil, floor, pi |
| 2 | +from math import ceil, pi |
3 | 3 |
|
4 | 4 | import numpy as np |
5 | 5 |
|
@@ -190,9 +190,24 @@ def dynamic_model_config(self, at_setup): |
190 | 190 | f'maximum value is {nu_max}' |
191 | 191 | ) |
192 | 192 |
|
193 | | - dt = floor(dt_max / 5.0) |
194 | | - dt_str = get_time_interval_string(seconds=dt) |
195 | | - dt_btr_str = get_time_interval_string(seconds=dt / 20.0) |
| 193 | + time_integrator = config.get('barotropic_gyre', 'time_integrator') |
| 194 | + time_integrator_map = dict([('RK4', 'RungeKutta4')]) |
| 195 | + if model == 'omega': |
| 196 | + if time_integrator in time_integrator_map.keys(): |
| 197 | + time_integrator = time_integrator_map[time_integrator] |
| 198 | + else: |
| 199 | + print( |
| 200 | + 'Warning: mapping from time integrator ' |
| 201 | + f'{time_integrator} to omega not found, ' |
| 202 | + 'retaining name given in config' |
| 203 | + ) |
| 204 | + if time_integrator == 'RK4': |
| 205 | + dt = dt_max / 20.0 |
| 206 | + dt_str = get_time_interval_string(seconds=dt) |
| 207 | + else: |
| 208 | + dt = dt_max / 5.0 |
| 209 | + dt_str = get_time_interval_string(seconds=dt) |
| 210 | + dt_btr_str = get_time_interval_string(seconds=dt_max / 20.0) |
196 | 211 |
|
197 | 212 | nu_max = stability_parameter_max * (resolution * 1.0e3) ** 2.0 / dt |
198 | 213 | if nu > nu_max: |
@@ -234,17 +249,6 @@ def dynamic_model_config(self, at_setup): |
234 | 249 | ) |
235 | 250 |
|
236 | 251 | slip_factor_dict = {'no-slip': 0.0, 'free-slip': 1.0} |
237 | | - time_integrator = config.get('barotropic_gyre', 'time_integrator') |
238 | | - time_integrator_map = dict([('RK4', 'RungeKutta4')]) |
239 | | - if model == 'omega': |
240 | | - if time_integrator in time_integrator_map.keys(): |
241 | | - time_integrator = time_integrator_map[time_integrator] |
242 | | - else: |
243 | | - print( |
244 | | - 'Warning: mapping from time integrator ' |
245 | | - f'{time_integrator} to omega not found, ' |
246 | | - 'retaining name given in config' |
247 | | - ) |
248 | 252 |
|
249 | 253 | replacements = dict( |
250 | 254 | dt=dt_str, |
|
0 commit comments