Skip to content

Commit d39853e

Browse files
committed
Use btr time step for RK4
1 parent 0b6b520 commit d39853e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

polaris/tasks/ocean/barotropic_gyre/forward.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import time
2-
from math import ceil, floor, pi
2+
from math import ceil, pi
33

44
import numpy as np
55

@@ -190,9 +190,24 @@ def dynamic_model_config(self, at_setup):
190190
f'maximum value is {nu_max}'
191191
)
192192

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

197212
nu_max = stability_parameter_max * (resolution * 1.0e3) ** 2.0 / dt
198213
if nu > nu_max:
@@ -234,17 +249,6 @@ def dynamic_model_config(self, at_setup):
234249
)
235250

236251
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-
)
248252

249253
replacements = dict(
250254
dt=dt_str,

0 commit comments

Comments
 (0)