Skip to content

Commit

Permalink
Merge pull request #370 from cbegeman/add-drying-slope-single-layer-case
Browse files Browse the repository at this point in the history
Add single layer drying slope case
  • Loading branch information
xylar authored Jul 4, 2022
2 parents e3056b8 + 00619ac commit a718af3
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 131 deletions.
2 changes: 1 addition & 1 deletion compass/ocean/tests/drying_slope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, mpas_core):
super().__init__(mpas_core=mpas_core, name='drying_slope')

for resolution in [0.25, 1]:
for coord_type in ['sigma']:
for coord_type in ['sigma', 'single_layer']:
self.add_test_case(
Default(test_group=self, resolution=resolution,
coord_type=coord_type))
34 changes: 29 additions & 5 deletions compass/ocean/tests/drying_slope/default/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from compass.ocean.tests.drying_slope.initial_state import InitialState
from compass.ocean.tests.drying_slope.forward import Forward
from compass.ocean.tests.drying_slope.viz import Viz
from compass.validate import compare_variables


class Default(TestCase):
Expand Down Expand Up @@ -43,13 +44,21 @@ def __init__(self, test_group, resolution, coord_type):
subdir = f'{res_name}/{coord_type}/{name}'
super().__init__(test_group=test_group, name=name,
subdir=subdir)

self.add_step(InitialState(test_case=self))
for damping_coeff in [0.0025, 0.01]:
self.add_step(InitialState(test_case=self, coord_type=coord_type))
if coord_type == 'single_layer':
self.add_step(Forward(test_case=self, resolution=resolution,
cores=4, threads=1,
damping_coeff=damping_coeff))
self.add_step(Viz(test_case=self))
coord_type=coord_type))
damping_coeffs = None
else:
damping_coeffs = [0.0025, 0.01]
for damping_coeff in damping_coeffs:
self.add_step(Forward(test_case=self, resolution=resolution,
cores=4, threads=1,
damping_coeff=damping_coeff,
coord_type=coord_type))
self.damping_coeffs = damping_coeffs
self.add_step(Viz(test_case=self, damping_coeffs=damping_coeffs))

def configure(self):
"""
Expand All @@ -67,3 +76,18 @@ def configure(self):
'mesh cells in the y direction')
config.set('drying_slope', 'dc', f'{dc}', comment='the distance '
'between adjacent cell centers')

def validate(self):
"""
Validate variables against a baseline
"""
damping_coeffs = self.damping_coeffs
variables = ['layerThickness', 'normalVelocity']
if damping_coeffs is not None:
for damping_coeff in damping_coeffs:
compare_variables(test_case=self, variables=variables,
filename1=f'forward_{damping_coeff}/'
'output.nc')
else:
compare_variables(test_case=self, variables=variables,
filename1='forward/output.nc')
3 changes: 0 additions & 3 deletions compass/ocean/tests/drying_slope/drying_slope.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# Number of vertical levels
vert_levels = 10

# The type of vertical coordinate (e.g. z-level, z-star)
coord_type = sigma

# config options for drying slope test cases
[drying_slope]

Expand Down
5 changes: 4 additions & 1 deletion compass/ocean/tests/drying_slope/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class Forward(Step):
test cases.
"""
def __init__(self, test_case, resolution, name='forward', subdir=None,
cores=1, min_cores=None, threads=1, damping_coeff=None):
cores=1, min_cores=None, threads=1, damping_coeff=None,
coord_type='sigma'):
"""
Create a new test case
Expand Down Expand Up @@ -58,6 +59,8 @@ def __init__(self, test_case, resolution, name='forward', subdir=None,
res_name = f'{int(resolution)}km'
self.add_namelist_file('compass.ocean.tests.drying_slope',
f'namelist.{res_name}.forward')
self.add_namelist_file('compass.ocean.tests.drying_slope',
f'namelist.{coord_type}.forward')
if damping_coeff is not None:
# update the Rayleigh damping coeff to the requested value
options = {'config_Rayleigh_damping_coeff': f'{damping_coeff}'}
Expand Down
16 changes: 15 additions & 1 deletion compass/ocean/tests/drying_slope/initial_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class InitialState(Step):
A step for creating a mesh and initial condition for drying slope test
cases
"""
def __init__(self, test_case):
def __init__(self, test_case, coord_type='sigma'):
"""
Create the step
Expand All @@ -26,6 +26,8 @@ def __init__(self, test_case):
super().__init__(test_case=test_case, name='initial_state', cores=1,
min_cores=1, threads=1)

self.coord_type = coord_type

self.add_namelist_file('compass.ocean.tests.drying_slope',
'namelist.init', mode='init')

Expand All @@ -45,6 +47,18 @@ def run(self):
config = self.config
logger = self.logger

config = self.config
section = config['vertical_grid']
coord_type = self.coord_type
if coord_type == 'single_layer':
options = {'config_tidal_boundary_vert_levels': '1'}
self.update_namelist_at_runtime(options)
else:
vert_levels = section.get('vert_levels')
options = {'config_tidal_boundary_vert_levels': f'{vert_levels}',
'config_tidal_boundary_layer_type': f"'{coord_type}'"}
self.update_namelist_at_runtime(options)

section = config['drying_slope']
nx = section.getint('nx')
ny = section.getint('ny')
Expand Down
3 changes: 0 additions & 3 deletions compass/ocean/tests/drying_slope/namelist.forward
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ config_zero_drying_velocity=.true.
config_verify_not_dry=.true.
config_thickness_flux_type='upwind'
config_use_cvmix=.false.
config_Rayleigh_friction=.true.
config_Rayleigh_damping_depth_variable=.true.
config_Rayleigh_damping_coeff=0.0025
config_use_implicit_bottom_drag=.false.
config_use_debugTracers=.true.
config_check_ssh_consistency=.true.
1 change: 0 additions & 1 deletion compass/ocean/tests/drying_slope/namelist.init
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
config_init_configuration='tidal_boundary'
config_ocean_run_mode = 'init'
config_tidal_boundary_vert_levels=10
config_tidal_boundary_layer_type='sigma'
config_tidal_start_dry=.true.
config_tidal_boundary_left_bottom_depth=0.0
Expand Down
4 changes: 4 additions & 0 deletions compass/ocean/tests/drying_slope/namelist.sigma.forward
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config_Rayleigh_friction=.true.
config_Rayleigh_damping_depth_variable=.true.
config_use_bulk_wind_stress = .false.
config_pressure_gradient_type = 'pressure_and_zmid'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
config_use_explicit_bottom_drag = .true.
config_explicit_bottom_drag_coeff = 3.0e-3
config_disable_thick_vadv = .true.
config_disable_thick_sflux = .true.
config_disable_vel_hmix = .true.
config_disable_vel_vmix = .true.
config_disable_vel_vadv = .true.
config_disable_tr_all_tend = .true.
config_pressure_gradient_type = 'ssh_gradient'
Loading

0 comments on commit a718af3

Please sign in to comment.