From a038dfbdf06040e73139c17f18f810d9fa0ad676 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 12 Nov 2024 13:03:46 -0700 Subject: [PATCH] Apply Xylar's suggestions from code review --- polaris/ocean/tasks/barotropic_gyre/forward.py | 4 ++-- polaris/ocean/tasks/barotropic_gyre/init.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/polaris/ocean/tasks/barotropic_gyre/forward.py b/polaris/ocean/tasks/barotropic_gyre/forward.py index 8e2c56b8b..2424bdc5d 100644 --- a/polaris/ocean/tasks/barotropic_gyre/forward.py +++ b/polaris/ocean/tasks/barotropic_gyre/forward.py @@ -1,5 +1,5 @@ import time -from math import ceil +from math import ceil, floor from polaris.mesh.planar import compute_planar_hex_nx_ny from polaris.ocean.model import OceanModelStep, get_time_interval_string @@ -124,7 +124,7 @@ def dynamic_model_config(self, at_setup): rho_0 = config.getfloat("barotropic_gyre", "rho_0") dt_max = compute_max_time_step(config) - dt = dt_max / 3. + dt = floor(dt_max / 3.) dt_str = get_time_interval_string(seconds=dt) options = {'config_dt': dt_str, diff --git a/polaris/ocean/tasks/barotropic_gyre/init.py b/polaris/ocean/tasks/barotropic_gyre/init.py index ad5a9ac4b..e36448b14 100644 --- a/polaris/ocean/tasks/barotropic_gyre/init.py +++ b/polaris/ocean/tasks/barotropic_gyre/init.py @@ -50,12 +50,12 @@ def setup(self): nu_2 = config.getfloat("barotropic_gyre", "nu_2") # calculate the boundary layer thickness for specified parameters - M = (np.pi * 2) / np.sqrt(3) * (nu_2 / beta)**(1. / 3.) + m = (np.pi * 2) / np.sqrt(3) * (nu_2 / beta)**(1. / 3.) # ensure the boundary layer is at least 3 gridcells wide - if M >= 3. * resolution * 1.e3: + if m >= 3. * resolution * 1.e3: raise ValueError(f"Resolution {resolution} km is too coarse to " "properly resolve the lateral boundary layer " - f"with anticipated width of {(M * 1e-3):03g} km") + f"with anticipated width of {(m * 1e-3):03g} km") # check whether viscosity suitable for stability stability_parameter_max = 0.6