diff --git a/E3SM-Project b/E3SM-Project index de075c76ac..c9a0d200a5 160000 --- a/E3SM-Project +++ b/E3SM-Project @@ -1 +1 @@ -Subproject commit de075c76ac53caa701952aa322777b7aca5c9758 +Subproject commit c9a0d200a5b0db964e7d8b862427c9a336d5e0f4 diff --git a/compass/ocean/suites/wetdry.txt b/compass/ocean/suites/wetdry.txt index c286926b91..31bdf04734 100644 --- a/compass/ocean/suites/wetdry.txt +++ b/compass/ocean/suites/wetdry.txt @@ -1,9 +1,15 @@ ocean/drying_slope/250m/sigma/default +ocean/drying_slope/250m/sigma/ramp ocean/drying_slope/250m/single_layer/default +ocean/drying_slope/250m/single_layer/ramp ocean/drying_slope/1km/sigma/default +ocean/drying_slope/1km/sigma/ramp ocean/drying_slope/1km/single_layer/default +ocean/drying_slope/1km/single_layer/ramp ocean/dam_break/40cm/default +ocean/dam_break/40cm/ramp ocean/dam_break/120cm/default +ocean/dam_break/120cm/ramp ocean/isomip_plus/planar/5km/sigma/thin_film_drying_Ocean0 ocean/isomip_plus/planar/5km/sigma/thin_film_wetting_Ocean0 ocean/isomip_plus/planar/5km/single_layer/thin_film_tidal_forcing_Ocean0 diff --git a/compass/ocean/tests/dam_break/__init__.py b/compass/ocean/tests/dam_break/__init__.py index 05ed6d82b8..c7b365f7fa 100644 --- a/compass/ocean/tests/dam_break/__init__.py +++ b/compass/ocean/tests/dam_break/__init__.py @@ -1,5 +1,6 @@ -from compass.testgroup import TestGroup from compass.ocean.tests.dam_break.default import Default +from compass.ocean.tests.dam_break.ramp import Ramp +from compass.testgroup import TestGroup class DamBreak(TestGroup): @@ -15,6 +16,7 @@ def __init__(self, mpas_core): super().__init__(mpas_core=mpas_core, name='dam_break') for resolution in [0.04, 0.12]: - for coord_type in ['sigma']: - self.add_test_case( - Default(test_group=self, resolution=resolution)) + self.add_test_case( + Default(test_group=self, resolution=resolution)) + self.add_test_case( + Ramp(test_group=self, resolution=resolution)) diff --git a/compass/ocean/tests/dam_break/ramp/__init__.py b/compass/ocean/tests/dam_break/ramp/__init__.py new file mode 100644 index 0000000000..d72b9234fc --- /dev/null +++ b/compass/ocean/tests/dam_break/ramp/__init__.py @@ -0,0 +1,82 @@ +from math import floor + +from compass.ocean.tests.dam_break.forward import Forward +from compass.ocean.tests.dam_break.initial_state import InitialState +from compass.ocean.tests.dam_break.viz import Viz +from compass.testcase import TestCase +from compass.validate import compare_variables + + +class Ramp(TestCase): + """ + The default dam_break test case + + Attributes + ---------- + resolution : float + The resolution of the test case in km + + """ + + def __init__(self, test_group, resolution): + """ + Create the test case + + Parameters + ---------- + test_group : compass.ocean.tests.dam_break.DamBreak + The test group that this test case belongs to + + resolution : float + The resolution of the test case in m + + """ + name = 'ramp' + + self.resolution = resolution + if resolution < 1.: + res_name = f'{int(resolution*1e3)}cm' + else: + res_name = f'{int(resolution)}m' + min_tasks = int(40 / (resolution / 0.04)**2) + ntasks = 10 * min_tasks + subdir = f'{res_name}/{name}' + super().__init__(test_group=test_group, name=name, + subdir=subdir) + + self.add_step(InitialState(test_case=self)) + forward_step = Forward(test_case=self, resolution=resolution, + ntasks=ntasks, min_tasks=min_tasks, + openmp_threads=1) + forward_step.add_namelist_options({'config_zero_drying_velocity_ramp': + ".true."}) + self.add_step(forward_step) + self.add_step(Viz(test_case=self)) + + def configure(self): + """ + Modify the configuration options for this test case. + """ + + resolution = self.resolution + config = self.config + dc = resolution # cell width in m + dx = 13 # width of the domain in m + dy = 28 # length of the domain in m + nx = round(dx / dc) + ny = int(2 * floor(dy / (2 * dc))) # guarantee that ny is even + + config.set('dam_break', 'nx', f'{nx}', comment='the number of ' + 'mesh cells in the x direction') + config.set('dam_break', 'ny', f'{ny}', comment='the number of ' + 'mesh cells in the y direction') + config.set('dam_break', 'dc', f'{dc}', comment='the distance ' + 'between adjacent cell centers') + + def validate(self): + """ + Validate variables against a baseline + """ + variables = ['layerThickness', 'normalVelocity', 'ssh'] + compare_variables(test_case=self, variables=variables, + filename1='forward/output.nc') diff --git a/compass/ocean/tests/drying_slope/__init__.py b/compass/ocean/tests/drying_slope/__init__.py index 56583b2ff8..044a3fb8a0 100644 --- a/compass/ocean/tests/drying_slope/__init__.py +++ b/compass/ocean/tests/drying_slope/__init__.py @@ -1,5 +1,6 @@ -from compass.testgroup import TestGroup from compass.ocean.tests.drying_slope.default import Default +from compass.ocean.tests.drying_slope.ramp import Ramp +from compass.testgroup import TestGroup class DryingSlope(TestGroup): @@ -14,8 +15,11 @@ def __init__(self, mpas_core): """ super().__init__(mpas_core=mpas_core, name='drying_slope') - for resolution in [0.25, 1]: + for resolution in [0.25, 1.]: for coord_type in ['sigma', 'single_layer']: self.add_test_case( Default(test_group=self, resolution=resolution, coord_type=coord_type)) + self.add_test_case( + Ramp(test_group=self, resolution=resolution, + coord_type=coord_type)) diff --git a/compass/ocean/tests/drying_slope/forward.py b/compass/ocean/tests/drying_slope/forward.py index f1a31b279c..64bd2e20ec 100644 --- a/compass/ocean/tests/drying_slope/forward.py +++ b/compass/ocean/tests/drying_slope/forward.py @@ -42,6 +42,9 @@ def __init__(self, test_case, resolution, name='forward', subdir=None, damping_coeff: float, optional the value of the rayleigh damping coefficient + coord_type: string, optional + the coordinate type + """ if min_tasks is None: min_tasks = ntasks diff --git a/compass/ocean/tests/drying_slope/ramp/__init__.py b/compass/ocean/tests/drying_slope/ramp/__init__.py new file mode 100644 index 0000000000..0c3ee1ea71 --- /dev/null +++ b/compass/ocean/tests/drying_slope/ramp/__init__.py @@ -0,0 +1,99 @@ +from compass.ocean.tests.drying_slope.forward import Forward +from compass.ocean.tests.drying_slope.initial_state import InitialState +from compass.ocean.tests.drying_slope.viz import Viz +from compass.testcase import TestCase +from compass.validate import compare_variables + + +class Ramp(TestCase): + """ + The default drying_slope test case + + Attributes + ---------- + resolution : float + The resolution of the test case in km + + coord_type : str + The type of vertical coordinate (``sigma``, ``single_layer``, etc.) + """ + + def __init__(self, test_group, resolution, coord_type): + """ + Create the test case + + Parameters + ---------- + test_group : compass.ocean.tests.drying_slope.DryingSlope + The test group that this test case belongs to + + resolution : float + The resolution of the test case in km + + coord_type : str + The type of vertical coordinate (``sigma``, ``single_layer``) + """ + name = 'ramp' + + self.resolution = resolution + self.coord_type = coord_type + if resolution < 1.: + res_name = f'{int(resolution*1e3)}m' + else: + res_name = f'{int(resolution)}km' + subdir = f'{res_name}/{coord_type}/{name}' + super().__init__(test_group=test_group, name=name, + subdir=subdir) + self.add_step(InitialState(test_case=self, coord_type=coord_type)) + if coord_type == 'single_layer': + forward_step = Forward(test_case=self, resolution=resolution, + ntasks=4, openmp_threads=1, + coord_type=coord_type) + damping_coeffs = None + forward_step.add_namelist_options( + {'config_zero_drying_velocity_ramp': ".true."}) + self.add_step(forward_step) + else: + damping_coeffs = [0.0025, 0.01] + for damping_coeff in damping_coeffs: + forward_step = Forward(test_case=self, resolution=resolution, + ntasks=4, openmp_threads=1, + damping_coeff=damping_coeff, + coord_type=coord_type) + forward_step.add_namelist_options( + {'config_zero_drying_velocity_ramp': ".true."}) + self.add_step(forward_step) + self.damping_coeffs = damping_coeffs + self.add_step(Viz(test_case=self, damping_coeffs=damping_coeffs)) + + def configure(self): + """ + Modify the configuration options for this test case. + """ + + resolution = self.resolution + config = self.config + ny = round(28 / resolution) + if resolution < 1.: + ny += 2 + dc = 1e3 * resolution + + config.set('drying_slope', 'ny', f'{ny}', comment='the number of ' + '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') diff --git a/compass/ocean/tests/drying_slope/streams.forward b/compass/ocean/tests/drying_slope/streams.forward index 49b6475ce2..a9c861ff35 100644 --- a/compass/ocean/tests/drying_slope/streams.forward +++ b/compass/ocean/tests/drying_slope/streams.forward @@ -29,7 +29,6 @@ clobber_mode="truncate"> - diff --git a/docs/developers_guide/ocean/test_groups/dam_break.rst b/docs/developers_guide/ocean/test_groups/dam_break.rst index 194980794e..de20692964 100644 --- a/docs/developers_guide/ocean/test_groups/dam_break.rst +++ b/docs/developers_guide/ocean/test_groups/dam_break.rst @@ -67,3 +67,13 @@ test performs one 10-minute run on 40 cores. It doesn't contain any is configured to have a 1 m by 1 m dammed region matching the experimental setup and a ~12 m by ~12 m flood plain to minimize reflections off the boundaries. + + +.. _dev_ocean_dam_break_ramp: + +ramp +---- + +The :py:class:`compass.ocean.tests.dam_break.ramp.Ramp` is identical to the +default class except it sets ``ramp`` to ``True`` for the forward step to enable +the ramp feature for wetting and drying. diff --git a/docs/developers_guide/ocean/test_groups/drying_slope.rst b/docs/developers_guide/ocean/test_groups/drying_slope.rst index d4267dd523..de438a5888 100644 --- a/docs/developers_guide/ocean/test_groups/drying_slope.rst +++ b/docs/developers_guide/ocean/test_groups/drying_slope.rst @@ -80,3 +80,13 @@ types are supported. For ``sigma`` coordinates, this case is hard-coded to run two cases at different values of ``config_Rayleigh_damping_coeff``, 0.0025 and 0.01, for which there is comparison data. The ``single_layer`` case runs at one value of the explicit bottom drag coefficient. + + +.. _dev_ocean_drying_slope_ramp: + +ramp +---- + +The :py:class:`compass.ocean.tests.drying_slope.ramp.Ramp` is identical to the +default class except it sets ``ramp`` to ``True`` for the forward step to enable +the ramp feature for wetting and drying. diff --git a/docs/users_guide/ocean/test_groups/dam_break.rst b/docs/users_guide/ocean/test_groups/dam_break.rst index 3566890f4e..5c9ace7152 100644 --- a/docs/users_guide/ocean/test_groups/dam_break.rst +++ b/docs/users_guide/ocean/test_groups/dam_break.rst @@ -40,6 +40,14 @@ The config options for this test case are: default ------- -``ocean/dam_break/40cm/default`` is the default version of the dam break +``ocean/dam_break/${RES}/default`` is the default version of the dam break test case for validation of sea surface height through visual inspection -against experimental data and ROMS solutions. +against experimental data and ROMS solutions. ``RES`` is either 40cm or 120cm. + +ramp +---- + +``ocean/dam_break/${RES}/ramp`` is identical to the ``default`` test except +the factor that scales velocities and velocity tendencies is ramped over a +given layer thickness range rather than a binary switch at the minimum +thickness. ``RES`` is either 40cm or 120cm. diff --git a/docs/users_guide/ocean/test_groups/drying_slope.rst b/docs/users_guide/ocean/test_groups/drying_slope.rst index 4d3f4ab399..24af0e3922 100644 --- a/docs/users_guide/ocean/test_groups/drying_slope.rst +++ b/docs/users_guide/ocean/test_groups/drying_slope.rst @@ -81,7 +81,16 @@ All units are mks. default ------- -``ocean/drying_slope/1km/default`` is the default version of the drying slope -test case for two short (12h) test runs with two different drag coefficients -and validation of sea surface height through visual inspection against analytic -and ROMS solutions. +``ocean/drying_slope/${RES}/${COORD}/default`` is the default version of the +drying slope test case for two short (12h) test runs with two different drag +coefficients and validation of sea surface height through visual inspection +against analytic and ROMS solutions. ``RES`` is either 250m or 1km. ``COORD`` is either ``single_layer`` or ``sigma``. + +ramp +---- + +``ocean/drying_slope/${RES}/${COORD}/ramp`` is identical to the ``default`` +test except the factor that scales velocities and velocity tendencies is +ramped over a given layer thickness range rather than a binary switch at the +minimum thickness. ``RES`` is either 250m or 1km. ``COORD`` is either +``single_layer`` or ``sigma``.