diff --git a/compass/ocean/tests/global_ocean/__init__.py b/compass/ocean/tests/global_ocean/__init__.py index b68a3f6d58..37daf5e206 100644 --- a/compass/ocean/tests/global_ocean/__init__.py +++ b/compass/ocean/tests/global_ocean/__init__.py @@ -1,33 +1,12 @@ from compass.ocean.tests.global_ocean.analysis_test import AnalysisTest from compass.ocean.tests.global_ocean.daily_output_test import DailyOutputTest from compass.ocean.tests.global_ocean.decomp_test import DecompTest +from compass.ocean.tests.global_ocean.dynamic_adjustment import ( + DynamicAdjustment, +) from compass.ocean.tests.global_ocean.files_for_e3sm import FilesForE3SM from compass.ocean.tests.global_ocean.init import Init from compass.ocean.tests.global_ocean.mesh import Mesh -from compass.ocean.tests.global_ocean.mesh.arrm10to60.dynamic_adjustment import ( # noqa: E501 - ARRM10to60DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.mesh.ec30to60.dynamic_adjustment import ( - EC30to60DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.mesh.kuroshio.dynamic_adjustment import ( - KuroshioDynamicAdjustment, -) -from compass.ocean.tests.global_ocean.mesh.qu240.dynamic_adjustment import ( - QU240DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.mesh.qu.dynamic_adjustment import ( - QUDynamicAdjustment, -) -from compass.ocean.tests.global_ocean.mesh.rrs6to18.dynamic_adjustment import ( - RRS6to18DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.mesh.so12to60.dynamic_adjustment import ( - SO12to60DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.mesh.wc14.dynamic_adjustment import ( - WC14DynamicAdjustment, -) from compass.ocean.tests.global_ocean.monthly_output_test import ( MonthlyOutputTest, ) @@ -51,7 +30,6 @@ def __init__(self, mpas_core): # we do a lot of tests for QU240/QUwISC240 self._add_tests(mesh_names=['QU240', 'Icos240', 'QUwISC240'], - DynamicAdjustment=QU240DynamicAdjustment, high_res_topography=False, include_rk4=True, include_regression=True, @@ -59,34 +37,27 @@ def __init__(self, mpas_core): include_en4_1900=True) # for other meshes, we do fewer tests - self._add_tests(mesh_names=['QU', 'Icos', 'QUwISC', 'IcoswISC'], - DynamicAdjustment=QUDynamicAdjustment) + self._add_tests(mesh_names=['QU', 'Icos', 'QUwISC', 'IcoswISC']) - self._add_tests(mesh_names=['EC30to60', 'ECwISC30to60'], - DynamicAdjustment=EC30to60DynamicAdjustment) + self._add_tests(mesh_names=['EC30to60', 'ECwISC30to60']) - self._add_tests(mesh_names=['ARRM10to60', 'ARRMwISC10to60'], - DynamicAdjustment=ARRM10to60DynamicAdjustment) + self._add_tests(mesh_names=['ARRM10to60', 'ARRMwISC10to60']) - self._add_tests(mesh_names=['SO12to60', 'SOwISC12to60'], - DynamicAdjustment=SO12to60DynamicAdjustment) + self._add_tests(mesh_names=['SO12to60', 'SOwISC12to60']) - self._add_tests(mesh_names=['WC14', 'WCwISC14'], - DynamicAdjustment=WC14DynamicAdjustment) + self._add_tests(mesh_names=['WC14', 'WCwISC14']) # RRS6to18: with and without cavities - self._add_tests(mesh_names=['RRS6to18', 'RRSwISC6to18'], - DynamicAdjustment=RRS6to18DynamicAdjustment) + self._add_tests(mesh_names=['RRS6to18', 'RRSwISC6to18']) # Kuroshio meshes without ice-shelf cavities - self._add_tests(mesh_names=['Kuroshio12to60', 'Kuroshio8to60'], - DynamicAdjustment=KuroshioDynamicAdjustment) + self._add_tests(mesh_names=['Kuroshio12to60', 'Kuroshio8to60']) # A test case for making E3SM support files from an existing mesh self.add_test_case(FilesForE3SM(test_group=self)) - def _add_tests(self, mesh_names, DynamicAdjustment, - high_res_topography=True, include_rk4=False, + def _add_tests(self, mesh_names, high_res_topography=True, + include_rk4=False, include_regression=False, include_phc=False, include_en4_1900=False): """ Add test cases for the given mesh(es) """ diff --git a/compass/ocean/tests/global_ocean/dynamic_adjustment.py b/compass/ocean/tests/global_ocean/dynamic_adjustment.py deleted file mode 100644 index cfafdad393..0000000000 --- a/compass/ocean/tests/global_ocean/dynamic_adjustment.py +++ /dev/null @@ -1,83 +0,0 @@ -import os -import xarray -import glob - -from compass.validate import compare_variables -from compass.ocean.tests.global_ocean.forward import ForwardTestCase - - -class DynamicAdjustment(ForwardTestCase): - """ - A parent test case for performing dynamic adjustment (dissipating - fast-moving waves) from an MPAS-Ocean initial condition. - - The final stage of the dynamic adjustment is assumed to be called - ``simulation``, and is expected to have a file ``output.nc`` that can be - compared against a baseline. - - Attributes - ---------- - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - - def __init__(self, test_group, mesh, init, time_integrator, - restart_filenames): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - name='dynamic_adjustment') - - self.restart_filenames = restart_filenames - - # no run() method is needed - - def validate(self): - """ - Test cases can override this method to perform validation of variables - and timers - """ - config = self.config - variables = ['temperature', 'salinity', 'layerThickness', - 'normalVelocity'] - - compare_variables(test_case=self, variables=variables, - filename1='simulation/output.nc') - - temp_max = config.getfloat('dynamic_adjustment', 'temperature_max') - max_values = {'temperatureMax': temp_max} - - for step_name in self.steps_to_run: - step = self.steps[step_name] - step_path = os.path.join(self.work_dir, step.subdir) - global_stats_path = os.path.join(step_path, 'analysis_members', - 'globalStats.*.nc') - global_stats_path = glob.glob(global_stats_path) - for filename in global_stats_path: - ds = xarray.open_dataset(filename) - for var, max_value in max_values.items(): - max_in_global_stats = ds[var].max().values - if max_in_global_stats > max_value: - raise ValueError( - f'Max of {var} > allowed threshold: ' - f'{max_in_global_stats} > {max_value} ' - f'in {filename}') diff --git a/compass/ocean/tests/global_ocean/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/dynamic_adjustment/__init__.py new file mode 100644 index 0000000000..1544f33b53 --- /dev/null +++ b/compass/ocean/tests/global_ocean/dynamic_adjustment/__init__.py @@ -0,0 +1,239 @@ +import glob +import importlib.resources +import os +from datetime import datetime, timedelta + +import xarray as xr +from ruamel.yaml import YAML + +from compass.ocean.tests.global_ocean.forward import ( + ForwardStep, + ForwardTestCase, +) +from compass.validate import compare_variables + + +class DynamicAdjustment(ForwardTestCase): + """ + A parent test case for performing dynamic adjustment (dissipating + fast-moving waves) from an MPAS-Ocean initial condition. + + The final stage of the dynamic adjustment is assumed to be called + ``simulation``, and is expected to have a file ``output.nc`` that can be + compared against a baseline. + + Attributes + ---------- + restart_filenames : list of str + A list of restart files from each dynamic-adjustment step + """ + + def __init__(self, test_group, mesh, init, time_integrator): + """ + Create the test case + + Parameters + ---------- + test_group : compass.ocean.tests.global_ocean.GlobalOcean + The global ocean test group that this test case belongs to + + mesh : compass.ocean.tests.global_ocean.mesh.Mesh + The test case that produces the mesh for this run + + init : compass.ocean.tests.global_ocean.init.Init + The test case that produces the initial condition for this run + + time_integrator : {'split_explicit', 'RK4'} + The time integrator to use for the forward run + """ + super().__init__(test_group=test_group, mesh=mesh, init=init, + time_integrator=time_integrator, + name='dynamic_adjustment') + + if time_integrator == 'split_explicit': + yaml_filename = 'dynamic_adjustment.yaml' + else: + yaml_filename = f'dynamic_adjustment_{time_integrator}.yaml' + + yaml_filename = str( + importlib.resources.files(mesh.package) / yaml_filename) + text = importlib.resources.files(mesh.package).joinpath( + yaml_filename).read_text() + yaml_data = YAML(typ='rt') + options_dict = yaml_data.load(text) + if 'dynamic_adjustment' not in options_dict: + raise ValueError(f'{yaml_filename} in {mesh.package} does not ' + f'start with "dynamic_adjustment:" as expected.') + options_dict = options_dict['dynamic_adjustment'] + if 'land_ice_flux_mode' in options_dict: + land_ice_flux_mode = options_dict['land_ice_flux_mode'] + else: + land_ice_flux_mode = 'pressure_only' + + if 'get_dt_from_min_res' not in options_dict: + raise ValueError(f'{yaml_filename} in {mesh.package} does not ' + f'have a "get_dt_from_min_res:" option as ' + f'expected.') + + get_dt_from_min_res = options_dict['get_dt_from_min_res'] + + shared_options = { + 'config_AM_globalStats_enable': '.true.', + 'config_AM_globalStats_compute_on_startup': '.true.', + 'config_AM_globalStats_write_on_startup': '.true.', + 'config_use_activeTracers_surface_restoring': '.true.' + } + if 'shared' in options_dict: + # replace the defaults with values from shared options + shared_options.update(options_dict['shared']) + + if 'steps' not in options_dict: + raise ValueError(f'{yaml_filename} in {mesh.package} does not ' + f'have a "steps:" item as expected.') + + start_time = '0001-01-01_00:00:00' + previous_restart_filename = None + restart_filenames = list() + for step_name in options_dict['steps']: + options = options_dict['steps'][step_name] + restart_time, restart_filename = self._add_step( + step_name, options, get_dt_from_min_res, time_integrator, + yaml_filename, start_time, previous_restart_filename, mesh, + init, land_ice_flux_mode, shared_options) + start_time = restart_time + previous_restart_filename = restart_filename + restart_filenames.append(restart_filename) + + self.restart_filenames = restart_filenames + + def validate(self): + """ + Test cases can override this method to perform validation of variables + and timers + """ + config = self.config + variables = ['temperature', 'salinity', 'layerThickness', + 'normalVelocity'] + + compare_variables(test_case=self, variables=variables, + filename1='simulation/output.nc') + + temp_max = config.getfloat('dynamic_adjustment', 'temperature_max') + max_values = {'temperatureMax': temp_max} + + for step_name in self.steps_to_run: + step = self.steps[step_name] + step_path = os.path.join(self.work_dir, step.subdir) + global_stats_path = os.path.join(step_path, 'analysis_members', + 'globalStats.*.nc') + global_stats_path = glob.glob(global_stats_path) + for filename in global_stats_path: + ds = xr.open_dataset(filename) + for var, max_value in max_values.items(): + max_in_global_stats = ds[var].max().values + if max_in_global_stats > max_value: + raise ValueError( + f'Max of {var} > allowed threshold: ' + f'{max_in_global_stats} > {max_value} ' + f'in {filename}') + + def _add_step(self, step_name, options, get_dt_from_min_res, + time_integrator, yaml_filename, start_time, + previous_restart_filename, mesh, init, land_ice_flux_mode, + shared_options): + required = ['run_duration', 'output_interval', 'restart_interval'] + if not get_dt_from_min_res: + required.append('dt') + if time_integrator == 'split_explicit': + required.append('btr_dt') + for option in required: + if option not in options: + raise ValueError( + f'In {yaml_filename} in {mesh.package}, step ' + f'{step_name} does not have required option {option}.') + + if get_dt_from_min_res: + omit = ['dt', 'btr_dt'] + for option in omit: + if option in options: + raise ValueError( + f'In {yaml_filename} in {mesh.package}, step ' + f'{step_name} is getting dt from the minimum ' + f'resolution of the mesh but dt and/or btr_dt ' + f'are also specified.') + + run_duration = options['run_duration'] + restart_time = _get_restart_time(start_time, run_duration) + + step = ForwardStep(test_case=self, mesh=mesh, init=init, + time_integrator=time_integrator, name=step_name, + subdir=step_name, + land_ice_flux_mode=land_ice_flux_mode, + get_dt_from_min_res=get_dt_from_min_res) + + namelist_options = dict(shared_options) + if previous_restart_filename is None: + namelist_options['config_do_restart'] = '.false.' + else: + namelist_options['config_do_restart'] = '.true.' + namelist_options['config_start_time'] = f"'{start_time}'" + + for option in ['run_duration', 'dt', 'btr_dt']: + if option in options: + namelist_options[f'config_{option}'] = \ + f"'{options[option]}'" + if ('Rayleigh_damping_coeff' in options and + options['Rayleigh_damping_coeff'] != 'None'): + namelist_options['config_implicit_bottom_drag_type'] = \ + "'constant_and_rayleigh'" + namelist_options['config_Rayleigh_damping_coeff'] = \ + f"{options['Rayleigh_damping_coeff']}" + else: + namelist_options['config_implicit_bottom_drag_type'] = \ + "'constant'" + + step.add_namelist_options(namelist_options) + + stream_replacements = { + 'output_interval': options['output_interval'], + 'restart_interval': options['restart_interval']} + package = 'compass.ocean.tests.global_ocean.dynamic_adjustment' + step.add_streams_file(package, 'streams.template', + template_replacements=stream_replacements) + + restart_filename = \ + f'restarts/rst.{restart_time.replace(":", ".")}.nc' + if previous_restart_filename is not None: + step.add_input_file(filename=f'../{previous_restart_filename}') + step.add_output_file(filename=f'../{restart_filename}') + step.add_output_file(filename='output.nc') + + self.add_step(step) + + return restart_time, restart_filename + + +def _get_restart_time(start_time, run_duration): + start = datetime.strptime(start_time, '%Y-%m-%d_%H:%M:%S') + duration = _parse_duration(run_duration) + restart = start + duration + restart_time = restart.strftime('%4Y-%m-%d_%H:%M:%S') + return restart_time + + +def _parse_duration(duration_str): + days = 0 + hours = 0 + minutes = 0 + split = duration_str.split('_') + hms = split[-1] + if len(split) > 1: + days = int(split[-2]) + + split = hms.split(':') + seconds = int(split[-1]) + if len(split) > 1: + minutes = int(split[-2]) + if len(split) > 2: + hours = int(split[-3]) + return timedelta(days=days, hours=hours, minutes=minutes, seconds=seconds) diff --git a/compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/dynamic_adjustment/streams.template similarity index 100% rename from compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment/streams.template rename to compass/ocean/tests/global_ocean/dynamic_adjustment/streams.template diff --git a/compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment.yaml new file mode 100644 index 0000000000..6f250eebc1 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment.yaml @@ -0,0 +1,60 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 00_06:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_06:00:00 + dt: 00:00:30 + btr_dt: 00:00:01.5 + Rayleigh_damping_coeff: 1.0e-3 + + damped_adjustment_2: + run_duration: 00_06:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_06:00:00 + dt: 00:01:00 + btr_dt: 00:00:03 + Rayleigh_damping_coeff: 4.0e-4 + + damped_adjustment_3: + run_duration: 00_12:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_12:00:00 + dt: 00:02:00 + btr_dt: 00:00:06 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_4: + run_duration: 01_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 01_00:00:00 + dt: 00:03:00 + btr_dt: 00:00:09 + Rayleigh_damping_coeff: 4.0e-5 + + damped_adjustment_5: + run_duration: 01_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 01_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:12 + Rayleigh_damping_coeff: 2.0e-5 + + damped_adjustment_6: + run_duration: 03_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 03_00:00:00 + dt: 00:07:30 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: None + + simulation: + run_duration: 24_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 06_00:00:00 + dt: 00:10:00 + btr_dt: 00:00:24 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment/__init__.py deleted file mode 100644 index 9a77a93a6c..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/arrm10to60/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,243 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class ARRM10to60DynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on the ARRM10to60 MPAS-Ocean mesh - - Attributes - ---------- - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - if time_integrator != 'split_explicit': - raise ValueError('{} dynamic adjustment not defined for {}'.format( - mesh.mesh_name, time_integrator)) - - restart_times = ['0001-01-01_06:00:00', '0001-01-01_12:00:00', - '0001-01-02_00:00:00', '0001-01-03_00:00:00', - '0001-01-04_00:00:00', '0001-01-07_00:00:00', - '0001-01-31_00:00:00'] - restart_filenames = [ - 'restarts/rst.{}.nc'.format(restart_time.replace(':', '.')) - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - shared_options = \ - {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.', - 'config_use_activeTracers_surface_restoring': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_06:00:00'", - 'config_dt': "'00:00:30'", - 'config_btr_dt': "'00:00:01.5'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-3'} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_06:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename='../{}'.format(restart_filenames[0])) - self.add_step(step) - - # second step - step_name = 'damped_adjustment_2' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_06:00:00'", - 'config_dt': "'00:01:00'", - 'config_btr_dt': "'00:00:03'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '4.0e-4', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[0])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_06:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[0])) - step.add_output_file(filename='../{}'.format(restart_filenames[1])) - self.add_step(step) - - # third step - step_name = 'damped_adjustment_3' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_12:00:00'", - 'config_dt': "'00:02:00'", - 'config_btr_dt': "'00:00:06'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[1])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_12:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[1])) - step.add_output_file(filename='../{}'.format(restart_filenames[2])) - self.add_step(step) - - # fourth step - step_name = 'damped_adjustment_4' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_dt': "'00:03:00'", - 'config_btr_dt': "'00:00:09'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '4.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[2])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[2])) - step.add_output_file(filename='../{}'.format(restart_filenames[3])) - self.add_step(step) - - # fifth step - step_name = 'damped_adjustment_5' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:12'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '2.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[3])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[3])) - step.add_output_file(filename='../{}'.format(restart_filenames[4])) - self.add_step(step) - - # sixth step - step_name = 'damped_adjustment_6' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-03_00:00:00'", - 'config_dt': "'00:07:30'", - 'config_btr_dt': "'00:00:15'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[4])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-03_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[4])) - step.add_output_file(filename='../{}'.format(restart_filenames[5])) - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-24_00:00:00'", - 'config_dt': "'00:10:00'", - 'config_btr_dt': "'00:00:24'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[5])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-06_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[5])) - step.add_output_file(filename='../{}'.format(restart_filenames[6])) - step.add_output_file(filename='output.nc') - self.add_step(step) - - self.restart_filenames = restart_filenames diff --git a/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment.yaml new file mode 100644 index 0000000000..ecf2fe5298 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment.yaml @@ -0,0 +1,36 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:15:00 + btr_dt: 00:00:30 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_2: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:15:00 + btr_dt: 00:00:30 + Rayleigh_damping_coeff: 1.0e-5 + + damped_adjustment_3: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:20:00 + btr_dt: 00:00:40 + Rayleigh_damping_coeff: 1.0e-6 + + simulation: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:30:00 + btr_dt: 00:01:00 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment/__init__.py deleted file mode 100644 index d10a3a3c17..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,133 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class EC30to60DynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on the EC30to60 MPAS-Ocean mesh - - Attributes - ---------- - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - if time_integrator != 'split_explicit': - raise ValueError(f'{mesh.mesh_name} dynamic adjustment not ' - f'defined for {time_integrator}') - - restart_times = ['0001-01-11_00:00:00', '0001-01-31_00:00:00', - '0001-02-10_00:00:00'] - restart_filenames = [ - f'restarts/rst.{restart_time.replace(":", ".")}.nc' - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - shared_options = \ - {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.', - 'config_use_activeTracers_surface_restoring': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-10_00:00:00'", - 'config_dt': "'00:15:00'", - 'config_btr_dt': "'00:00:10'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4'} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename=f'../{restart_filenames[0]}') - self.add_step(step) - - # second step - step_name = 'damped_adjustment_2' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-20_00:00:00'", - 'config_dt': "'00:15:00'", - 'config_btr_dt': "'00:00:10'", - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[0]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[0]}') - step.add_output_file(filename=f'../{restart_filenames[1]}') - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-10_00:00:00'", - 'config_dt': "'00:30:00'", - 'config_btr_dt': "'00:00:10'", - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[1]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[1]}') - step.add_output_file(filename=f'../{restart_filenames[2]}') - step.add_output_file(filename='output.nc') - self.add_step(step) - - self.restart_filenames = restart_filenames diff --git a/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment/streams.template deleted file mode 100644 index 31a4652e75..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/ec30to60/dynamic_adjustment/streams.template +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/compass/ocean/tests/global_ocean/mesh/kuroshio/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/kuroshio/dynamic_adjustment/__init__.py deleted file mode 100644 index 3f6188cea8..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/kuroshio/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,192 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class KuroshioDynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on a Kuroshio MPAS-Ocean mesh - - Attributes - ---------- - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - if time_integrator != 'split_explicit': - raise ValueError('{} dynamic adjustment not defined for {}'.format( - mesh.mesh_name, time_integrator)) - - restart_times = ['0001-01-03_00:00:00', '0001-01-11_00:00:00', - '0001-01-21_00:00:00', '0001-02-10_00:00:00', - '0001-02-20_00:00:00'] - restart_filenames = [ - 'restarts/rst.{}.nc'.format(restart_time.replace(':', '.')) - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - mesh_name = mesh.mesh_name - - if mesh_name == 'Kuroshio12to60': - dt = "'00:05:00'" - initial_btr_dt = "'00:00:15'" - elif mesh_name == 'Kuroshio8to60': - dt = "'00:03:00'" - initial_btr_dt = "'00:00:10'" - else: - raise ValueError(f'Unexpected mesh {mesh_name}') - - global_stats = {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-02_00:00:00'", - 'config_dt': dt, - 'config_btr_dt': initial_btr_dt, - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4'} - namelist_options.update(global_stats) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-02_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename='../{}'.format(restart_filenames[0])) - self.add_step(step) - - # second step - step_name = 'damped_adjustment_2' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-08_00:00:00'", - 'config_dt': dt, - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[0])} - namelist_options.update(global_stats) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-02_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[0])) - step.add_output_file(filename='../{}'.format(restart_filenames[1])) - self.add_step(step) - - # third step - step_name = 'damped_adjustment_3' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-10_00:00:00'", - 'config_dt': dt, - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-6', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[1])} - namelist_options.update(global_stats) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[1])) - step.add_output_file(filename='../{}'.format(restart_filenames[2])) - self.add_step(step) - - # fourth step - step_name = 'damped_adjustment_4' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-20_00:00:00'", - 'config_dt': dt, - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[2])} - namelist_options.update(global_stats) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[2])) - step.add_output_file(filename='../{}'.format(restart_filenames[3])) - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-10_00:00:00'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[3])} - namelist_options.update(global_stats) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[3])) - step.add_output_file(filename='../{}'.format(restart_filenames[4])) - step.add_output_file(filename='output.nc') - self.add_step(step) - - self.restart_filenames = restart_filenames diff --git a/compass/ocean/tests/global_ocean/mesh/kuroshio/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/mesh/kuroshio/dynamic_adjustment/streams.template deleted file mode 100644 index 31a4652e75..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/kuroshio/dynamic_adjustment/streams.template +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/compass/ocean/tests/global_ocean/mesh/kuroshio12to60/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/kuroshio12to60/dynamic_adjustment.yaml new file mode 100644 index 0000000000..61a82f4ab4 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/kuroshio12to60/dynamic_adjustment.yaml @@ -0,0 +1,44 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 02_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 02_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_2: + run_duration: 08_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 02_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: 1.0e-5 + + damped_adjustment_3: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: 1.0e-6 + + damped_adjustment_4: + run_duration: 20_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: None + + simulation: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:10:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/kuroshio8to60/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/kuroshio8to60/dynamic_adjustment.yaml new file mode 100644 index 0000000000..ebeab3e710 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/kuroshio8to60/dynamic_adjustment.yaml @@ -0,0 +1,44 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 02_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 02_00:00:00 + dt: 00:03:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_2: + run_duration: 08_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 02_00:00:00 + dt: 00:03:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: 1.0e-5 + + damped_adjustment_3: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:03:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: 1.0e-6 + + damped_adjustment_4: + run_duration: 20_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:03:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: None + + simulation: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment.yaml new file mode 100644 index 0000000000..339334ae02 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment.yaml @@ -0,0 +1,22 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: True + + steps: + damped_adjustment_1: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_2: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + Rayleigh_damping_coeff: 1.0e-5 + + simulation: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment/__init__.py deleted file mode 100644 index 99dbc97cb4..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,92 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class QUDynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on the QU240 MPAS-Ocean mesh - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - restart_times = ['0001-01-02_00:00:00', '0001-01-03_00:00:00'] - restart_filenames = [ - 'restarts/rst.{}.nc'.format(restart_time.replace(':', '.')) - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - shared_options = \ - {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.', - 'config_use_activeTracers_surface_restoring': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=True) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4'} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-01_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename='../{}'.format(restart_filenames[0])) - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=True) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[0])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-01_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[0])) - step.add_output_file(filename='../{}'.format(restart_filenames[1])) - step.add_output_file(filename='output.nc') - self.add_step(step) diff --git a/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment/streams.template deleted file mode 100644 index 31a4652e75..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/qu/dynamic_adjustment/streams.template +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment.yaml new file mode 100644 index 0000000000..5185f863a0 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment.yaml @@ -0,0 +1,20 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 1_00:00:00 + output_interval: 1_00:00:00 + restart_interval: 1_00:00:00 + dt: 02:00:00 + btr_dt: 00:06:00 + Rayleigh_damping_coeff: 1.0e-4 + + simulation: + run_duration: 1_00:00:00 + output_interval: 1_00:00:00 + restart_interval: 1_00:00:00 + dt: 02:00:00 + btr_dt: 00:06:00 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment/__init__.py deleted file mode 100644 index 1b36184d7e..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,92 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class QU240DynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on the QU240 MPAS-Ocean mesh - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - restart_times = ['0001-01-02_00:00:00', '0001-01-03_00:00:00'] - restart_filenames = [ - 'restarts/rst.{}.nc'.format(restart_time.replace(':', '.')) - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - shared_options = \ - {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.', - 'config_use_activeTracers_surface_restoring': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4'} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-01_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename='../{}'.format(restart_filenames[0])) - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[0])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-01_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[0])) - step.add_output_file(filename='../{}'.format(restart_filenames[1])) - step.add_output_file(filename='output.nc') - self.add_step(step) diff --git a/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment/streams.template deleted file mode 100644 index 31a4652e75..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/qu240/dynamic_adjustment/streams.template +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment.yaml new file mode 100644 index 0000000000..8dadf614bd --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment.yaml @@ -0,0 +1,68 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 00_06:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_06:00:00 + dt: 00:00:30 + btr_dt: 00:00:01 + Rayleigh_damping_coeff: 1.0e-3 + + damped_adjustment_2: + run_duration: 00_06:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_06:00:00 + dt: 00:01:00 + btr_dt: 00:00:02 + Rayleigh_damping_coeff: 4.0e-4 + + damped_adjustment_3: + run_duration: 00_12:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_12:00:00 + dt: 00:02:00 + btr_dt: 00:00:04 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_4: + run_duration: 01_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 01_00:00:00 + dt: 00:03:00 + btr_dt: 00:00:06 + Rayleigh_damping_coeff: 4.0e-5 + + damped_adjustment_5: + run_duration: 01_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 01_00:00:00 + dt: 00:04:00 + btr_dt: 00:00:08 + Rayleigh_damping_coeff: 2.0e-5 + + damped_adjustment_6: + run_duration: 03_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 03_00:00:00 + dt: 00:04:00 + btr_dt: 00:00:08 + Rayleigh_damping_coeff: 5.0e-6 + + damped_adjustment_7: + run_duration: 06_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 06_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: 5.0e-6 + + simulation: + run_duration: 18_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 06_00:00:00 + dt: 00:06:00 + btr_dt: 00:00:12 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment/__init__.py deleted file mode 100644 index 4fb6519d51..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,273 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class RRS6to18DynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on the RRS6to18 MPAS-Ocean mesh - - Attributes - ---------- - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - if time_integrator != 'split_explicit': - raise ValueError(f'{mesh.mesh_name} dynamic adjustment not ' - f'defined for {time_integrator}') - - restart_times = ['0001-01-01_06:00:00', '0001-01-01_12:00:00', - '0001-01-02_00:00:00', '0001-01-03_00:00:00', - '0001-01-04_00:00:00', '0001-01-07_00:00:00', - '0001-01-13_00:00:00', '0001-01-31_00:00:00'] - - restart_filenames = [ - f'restarts/rst.{restart_time.replace(":", ".")}.nc' - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - shared_options = \ - {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.', - 'config_use_activeTracers_surface_restoring': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_06:00:00'", - 'config_dt': "'00:00:30'", - 'config_btr_dt': "'00:00:01'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-3'} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_06:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename=f'../{restart_filenames[0]}') - self.add_step(step) - - # second step - step_name = 'damped_adjustment_2' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_06:00:00'", - 'config_dt': "'00:01:00'", - 'config_btr_dt': "'00:00:02'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '4.0e-4', - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[0]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_06:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[0]}') - step.add_output_file(filename=f'../{restart_filenames[1]}') - self.add_step(step) - - # third step - step_name = 'damped_adjustment_3' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_12:00:00'", - 'config_dt': "'00:02:00'", - 'config_btr_dt': "'00:00:04'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4', - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[1]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_12:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[1]}') - step.add_output_file(filename=f'../{restart_filenames[2]}') - self.add_step(step) - - # fourth step - step_name = 'damped_adjustment_4' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_dt': "'00:03:00'", - 'config_btr_dt': "'00:00:06'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '4.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[2]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[2]}') - step.add_output_file(filename=f'../{restart_filenames[3]}') - self.add_step(step) - - # fifth step - step_name = 'damped_adjustment_5' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_dt': "'00:04:00'", - 'config_btr_dt': "'00:00:08'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '2.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[3]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[3]}') - step.add_output_file(filename=f'../{restart_filenames[4]}') - self.add_step(step) - - # sixth step - step_name = 'damped_adjustment_6' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-03_00:00:00'", - 'config_dt': "'00:04:00'", - 'config_btr_dt': "'00:00:08'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '5.0e-6', - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[4]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-03_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[4]}') - step.add_output_file(filename=f'../{restart_filenames[5]}') - self.add_step(step) - - # seventh step - step_name = 'damped_adjustment_7' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-06_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:10'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '5.0e-6', - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[5]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-06_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[5]}') - step.add_output_file(filename=f'../{restart_filenames[6]}') - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-18_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:10'", - 'config_do_restart': '.true.', - 'config_start_time': f"'{restart_times[6]}'"} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-06_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename=f'../{restart_filenames[6]}') - step.add_output_file(filename=f'../{restart_filenames[7]}') - step.add_output_file(filename='output.nc') - self.add_step(step) - - self.restart_filenames = restart_filenames diff --git a/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment/streams.template deleted file mode 100644 index 6479939c6a..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/rrs6to18/dynamic_adjustment/streams.template +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - diff --git a/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment.yaml new file mode 100644 index 0000000000..39bb09c996 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment.yaml @@ -0,0 +1,44 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 02_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 02_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_2: + run_duration: 08_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 02_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: 1.0e-5 + + damped_adjustment_3: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: 1.0e-6 + + damped_adjustment_4: + run_duration: 20_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:10 + Rayleigh_damping_coeff: None + + simulation: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:10:00 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment/__init__.py deleted file mode 100644 index 1bc5f7a636..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,188 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class SO12to60DynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on the SO12to60 MPAS-Ocean mesh - - Attributes - ---------- - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - if time_integrator != 'split_explicit': - raise ValueError('{} dynamic adjustment not defined for {}'.format( - mesh.mesh_name, time_integrator)) - - restart_times = ['0001-01-03_00:00:00', '0001-01-11_00:00:00', - '0001-01-21_00:00:00', '0001-02-10_00:00:00', - '0001-02-20_00:00:00'] - restart_filenames = [ - 'restarts/rst.{}.nc'.format(restart_time.replace(':', '.')) - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - shared_options = \ - {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.', - 'config_use_activeTracers_surface_restoring': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-02_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:10'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4'} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-02_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename='../{}'.format(restart_filenames[0])) - self.add_step(step) - - # second step - step_name = 'damped_adjustment_2' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-08_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:10'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[0])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-02_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[0])) - step.add_output_file(filename='../{}'.format(restart_filenames[1])) - self.add_step(step) - - # third step - step_name = 'damped_adjustment_3' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-10_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:10'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-6', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[1])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[1])) - step.add_output_file(filename='../{}'.format(restart_filenames[2])) - self.add_step(step) - - # fourth step - step_name = 'damped_adjustment_4' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-20_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:10'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[2])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[2])) - step.add_output_file(filename='../{}'.format(restart_filenames[3])) - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-10_00:00:00'", - 'config_dt': "'00:10:00'", - 'config_btr_dt': "'00:00:15'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[3])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-10_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[3])) - step.add_output_file(filename='../{}'.format(restart_filenames[4])) - step.add_output_file(filename='output.nc') - self.add_step(step) - - self.restart_filenames = restart_filenames diff --git a/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment/streams.template deleted file mode 100644 index 31a4652e75..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/so12to60/dynamic_adjustment/streams.template +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment.yaml b/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment.yaml new file mode 100644 index 0000000000..31533f6563 --- /dev/null +++ b/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment.yaml @@ -0,0 +1,60 @@ +dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 00_06:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_06:00:00 + dt: 00:00:30 + btr_dt: 00:00:01.5 + Rayleigh_damping_coeff: 1.0e-3 + + damped_adjustment_2: + run_duration: 00_06:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_06:00:00 + dt: 00:01:00 + btr_dt: 00:00:03 + Rayleigh_damping_coeff: 4.0e-4 + + damped_adjustment_3: + run_duration: 00_12:00:00 + output_interval: 10_00:00:00 + restart_interval: 00_12:00:00 + dt: 00:02:00 + btr_dt: 00:00:06 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_4: + run_duration: 01_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 01_00:00:00 + dt: 00:03:00 + btr_dt: 00:00:09 + Rayleigh_damping_coeff: 4.0e-5 + + damped_adjustment_5: + run_duration: 01_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 01_00:00:00 + dt: 00:05:00 + btr_dt: 00:00:12 + Rayleigh_damping_coeff: 2.0e-5 + + damped_adjustment_6: + run_duration: 03_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 03_00:00:00 + dt: 00:07:30 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: None + + simulation: + run_duration: 24_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 06_00:00:00 + dt: 00:10:00 + btr_dt: 00:00:15 + Rayleigh_damping_coeff: None diff --git a/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment/__init__.py deleted file mode 100644 index 54f3267bdf..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment/__init__.py +++ /dev/null @@ -1,243 +0,0 @@ -from compass.ocean.tests.global_ocean.dynamic_adjustment import ( - DynamicAdjustment, -) -from compass.ocean.tests.global_ocean.forward import ForwardStep - - -class WC14DynamicAdjustment(DynamicAdjustment): - """ - A test case performing dynamic adjustment (dissipating fast-moving waves) - from an initial condition on the WC14 MPAS-Ocean mesh - - Attributes - ---------- - restart_filenames : list of str - A list of restart files from each dynamic-adjustment step - """ - - def __init__(self, test_group, mesh, init, time_integrator): - """ - Create the test case - - Parameters - ---------- - test_group : compass.ocean.tests.global_ocean.GlobalOcean - The global ocean test group that this test case belongs to - - mesh : compass.ocean.tests.global_ocean.mesh.Mesh - The test case that produces the mesh for this run - - init : compass.ocean.tests.global_ocean.init.Init - The test case that produces the initial condition for this run - - time_integrator : {'split_explicit', 'RK4'} - The time integrator to use for the forward run - """ - if time_integrator != 'split_explicit': - raise ValueError('{} dynamic adjustment not defined for {}'.format( - mesh.mesh_name, time_integrator)) - - restart_times = ['0001-01-01_06:00:00', '0001-01-01_12:00:00', - '0001-01-02_00:00:00', '0001-01-03_00:00:00', - '0001-01-04_00:00:00', '0001-01-07_00:00:00', - '0001-01-31_00:00:00'] - restart_filenames = [ - 'restarts/rst.{}.nc'.format(restart_time.replace(':', '.')) - for restart_time in restart_times] - - super().__init__(test_group=test_group, mesh=mesh, init=init, - time_integrator=time_integrator, - restart_filenames=restart_filenames) - - module = self.__module__ - - shared_options = \ - {'config_AM_globalStats_enable': '.true.', - 'config_AM_globalStats_compute_on_startup': '.true.', - 'config_AM_globalStats_write_on_startup': '.true.', - 'config_use_activeTracers_surface_restoring': '.true.'} - - # first step - step_name = 'damped_adjustment_1' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_06:00:00'", - 'config_dt': "'00:00:30'", - 'config_btr_dt': "'00:00:01.5'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-3'} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_06:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_output_file(filename='../{}'.format(restart_filenames[0])) - self.add_step(step) - - # second step - step_name = 'damped_adjustment_2' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_06:00:00'", - 'config_dt': "'00:01:00'", - 'config_btr_dt': "'00:00:03'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '4.0e-4', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[0])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_06:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[0])) - step.add_output_file(filename='../{}'.format(restart_filenames[1])) - self.add_step(step) - - # third step - step_name = 'damped_adjustment_3' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-00_12:00:00'", - 'config_dt': "'00:02:00'", - 'config_btr_dt': "'00:00:06'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '1.0e-4', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[1])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-00_12:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[1])) - step.add_output_file(filename='../{}'.format(restart_filenames[2])) - self.add_step(step) - - # fourth step - step_name = 'damped_adjustment_4' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_dt': "'00:03:00'", - 'config_btr_dt': "'00:00:09'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '4.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[2])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[2])) - step.add_output_file(filename='../{}'.format(restart_filenames[3])) - self.add_step(step) - - # fifth step - step_name = 'damped_adjustment_5' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-01_00:00:00'", - 'config_dt': "'00:05:00'", - 'config_btr_dt': "'00:00:12'", - 'config_implicit_bottom_drag_type': "'constant_and_rayleigh'", - 'config_Rayleigh_damping_coeff': '2.0e-5', - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[3])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-01_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[3])) - step.add_output_file(filename='../{}'.format(restart_filenames[4])) - self.add_step(step) - - # sixth step - step_name = 'damped_adjustment_6' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-03_00:00:00'", - 'config_dt': "'00:07:30'", - 'config_btr_dt': "'00:00:15'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[4])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-03_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[4])) - step.add_output_file(filename='../{}'.format(restart_filenames[5])) - self.add_step(step) - - # final step - step_name = 'simulation' - step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator, name=step_name, - subdir=step_name, get_dt_from_min_res=False) - - namelist_options = { - 'config_run_duration': "'00-00-24_00:00:00'", - 'config_dt': "'00:10:00'", - 'config_btr_dt': "'00:00:15'", - 'config_do_restart': '.true.', - 'config_start_time': "'{}'".format(restart_times[5])} - namelist_options.update(shared_options) - step.add_namelist_options(namelist_options) - - stream_replacements = { - 'output_interval': '00-00-10_00:00:00', - 'restart_interval': '00-00-06_00:00:00'} - step.add_streams_file(module, 'streams.template', - template_replacements=stream_replacements) - - step.add_input_file(filename='../{}'.format(restart_filenames[5])) - step.add_output_file(filename='../{}'.format(restart_filenames[6])) - step.add_output_file(filename='output.nc') - self.add_step(step) - - self.restart_filenames = restart_filenames diff --git a/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment/streams.template b/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment/streams.template deleted file mode 100644 index 31a4652e75..0000000000 --- a/compass/ocean/tests/global_ocean/mesh/wc14/dynamic_adjustment/streams.template +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/conda/compass_env/spec-file.template b/conda/compass_env/spec-file.template index 1c36525687..06c636a05f 100644 --- a/conda/compass_env/spec-file.template +++ b/conda/compass_env/spec-file.template @@ -34,6 +34,7 @@ pyamg >=4.2.2 pyproj pyremap>=1.0.1,<2.0.0 requests +ruamel.yaml # having pip check problems with this version scikit-image !=0.20.0 scipy>=1.8.0 diff --git a/docs/developers_guide/ocean/api.rst b/docs/developers_guide/ocean/api.rst index 7a241daf1f..d9e52dfe88 100644 --- a/docs/developers_guide/ocean/api.rst +++ b/docs/developers_guide/ocean/api.rst @@ -219,29 +219,20 @@ test cases and steps mesh.ec30to60.EC30to60BaseMesh mesh.ec30to60.EC30to60BaseMesh.build_cell_width_lat_lon - mesh.ec30to60.dynamic_adjustment.EC30to60DynamicAdjustment mesh.qu.IcosMeshFromConfigStep mesh.qu.IcosMeshFromConfigStep.setup mesh.qu.QUMeshFromConfigStep mesh.qu.QUMeshFromConfigStep.setup - mesh.qu.dynamic_adjustment.QUDynamicAdjustment - - mesh.qu240.dynamic_adjustment.QU240DynamicAdjustment mesh.rrs6to18.RRS6to18BaseMesh mesh.rrs6to18.RRS6to18BaseMesh.build_cell_width_lat_lon - mesh.rrs6to18.dynamic_adjustment.RRS6to18DynamicAdjustment - mesh.rrs6to18.dynamic_adjustment.RRS6to18DynamicAdjustment.configure - mesh.rrs6to18.dynamic_adjustment.RRS6to18DynamicAdjustment.run mesh.so12to60.SO12to60BaseMesh mesh.so12to60.SO12to60BaseMesh.build_cell_width_lat_lon - mesh.so12to60.dynamic_adjustment.SO12to60DynamicAdjustment mesh.wc14.WC14BaseMesh mesh.wc14.WC14BaseMesh.build_cell_width_lat_lon - mesh.wc14.dynamic_adjustment.WC14DynamicAdjustment performance_test.PerformanceTest performance_test.PerformanceTest.configure @@ -256,7 +247,7 @@ test cases and steps threads_test.ThreadsTest.run dynamic_adjustment.DynamicAdjustment - dynamic_adjustment.DynamicAdjustment.run + dynamic_adjustment.DynamicAdjustment.validate forward.ForwardTestCase forward.ForwardTestCase.configure diff --git a/docs/developers_guide/ocean/test_groups/global_ocean.rst b/docs/developers_guide/ocean/test_groups/global_ocean.rst index 4d2034d20f..8168e0cf67 100644 --- a/docs/developers_guide/ocean/test_groups/global_ocean.rst +++ b/docs/developers_guide/ocean/test_groups/global_ocean.rst @@ -1106,12 +1106,12 @@ when calling :ref:`dev_compass_setup`. dynamic_adjustment test case ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The parent class +The class :py:class:`compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment` descends from :ref:`dev_ocean_global_ocean_forward_test` and defines a test case for performing a series of forward model runs in sequence to allow the ocean model to dynamically adjust to the initial condition. This process -involves a rapid increase in ocean velocity. the dissipation of fast-moving +involves a rapid increase in ocean velocity, the dissipation of fast-moving waves, and adjustment of the sea-surface height to be in balance with the dynamic pressure (see :ref:`global_ocean_dynamic_adjustment` in the User's Guide). This process typically require smaller times steps and artificial @@ -1125,81 +1125,104 @@ The test case also takes care of validating the output from the final ``simulation`` step, comparing ``temperature``, ``salinity``, ``layerThickness``, and ``normalVelocity`` with a baseline if one is provided. -child classes -^^^^^^^^^^^^^ - -The modules ``compass.ocean.tests.global_ocean.mesh..dynamic_adjustment`` -define child classes of ``DynamicAdjustment``. Each of the -:ref`global_ocean_meshes` has its own adjustment step, since the needs -(duration of each step, amount of damping, time step, etc.) may be different -between meshes. - -Each module includes ``streams.template``, a Jinja2 template for defining -streams (see :ref:`dev_step_add_streams_file_template`): - -.. code-block:: xml - - - - - - - - -QU240 and QUwISC240 -^^^^^^^^^^^^^^^^^^^ - -The class :py:class:`compass.ocean.tests.global_ocean.mesh.qu240.dynamic_adjustment.QU240DynamicAdjustment` -defines a test case for performing dynamical adjustment on the mesh. In the -``damped_adjustment_1`` step, the model is run for 1 day with strong Rayleigh -friction (``1e-4`` 1/s) to damp the velocity field. In the -``simulation`` step, the model runs for an additional 1 day without Rayleigh -friction. The dynamic adjustment test case takes advantage of Jinja templating -for streams files to use the same streams template for each step in the test -case, see :ref:`dev_step_add_streams_file_template`. - - -EC30to60 and ECwISC30to60 -^^^^^^^^^^^^^^^^^^^^^^^^^ - -The class :py:class:`compass.ocean.tests.global_ocean.mesh.ec30to60.dynamic_adjustment.EC30to60DynamicAdjustment` -defines a test case for performing dynamical adjustment on the mesh. In the -``damped_adjustment_1`` step, the model is run for 10 days with strong Rayleigh -friction (``1e-4`` 1/s) to damp the velocity field. In the -``simulation`` step, the model runs for an additional 10 days without Rayleigh -friction. The dynamic adjustment test case takes advantage of Jinja templating -for streams files to use the same streams template for each step in the test -case, see :ref:`dev_step_add_streams_file_template`. +Each mesh needs to have a ``dynamic_adjustment.yaml`` (for the split-explicit +time integrator) and optionally a ``dynamic_adjustment_rk4.yaml`` (if +there is need to support dynamic adjustment with the RK4 time integrator). +The YAML file defines some shared properties of each dynamic adjustment step +and a list of properties (related to namelist options) for each step. Here is +and example: + +.. code-block:: yaml + + dynamic_adjustment: + land_ice_flux_mode: data + get_dt_from_min_res: False + + steps: + damped_adjustment_1: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:15:00 + btr_dt: 00:00:30 + Rayleigh_damping_coeff: 1.0e-4 + + damped_adjustment_2: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:15:00 + btr_dt: 00:00:30 + Rayleigh_damping_coeff: 1.0e-5 + + damped_adjustment_3: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:20:00 + btr_dt: 00:00:40 + Rayleigh_damping_coeff: 1.0e-6 + + simulation: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:30:00 + btr_dt: 00:01:00 + Rayleigh_damping_coeff: None + +The ``land_ice_flux_mode`` only matters for versions of the mesh with ice-shelf +cavities. Fluxes below ice shelves can be off +(``land_ice_flux_mode: pressure_only``), prognostic +(``land_ice_flux_mode: standalone``), or come from data +(``land_ice_flux_mode: data``, the suggested approach). All steps run with +the same ``land_ice_flux_mode``. + +The option ``get_dt_from_min_res`` determines whether the time step is +determined automatically from the mesh resolution or is specified in each +step. Typically, meshes will use ``get_dt_from_min_res: False`` unless they +have been generalized to support a range of resolutions, like the +:ref:`dev_ocean_global_ocean_qu_icos`. + +Under ``steps:``, each step can be named as you like except that the final +step must be called ``simulation``. The convention for the other steps is +to name and number them ``damped_adjustment_``. There can be any number of +damping steps, each of which typically define: + +.. code-block:: yaml -SO12to60 and SOwISC12to60 -^^^^^^^^^^^^^^^^^^^^^^^^^ - -The class :py:class:`compass.ocean.tests.global_ocean.mesh.so12to60.dynamic_adjustment.SO12to60DynamicAdjustment` -defines a test case for performing dynamical adjustment on the mesh. In the -``damped_adjustment_1`` through ``damped_adjustment_3`` steps, the model is run for -2, 4 and 4 days with gradually weakening Rayleigh friction (``1e-4``, ``4e-5``, -and ``1e-5`` 1/s) to damp the velocity field. In the ``simulation`` step, the -model runs for an additional 10 days without Rayleigh friction. The -dynamic adjustment test case takes advantage of Jinja templating for streams -files to use the same streams template for each step in the test case, see -:ref:`dev_step_add_streams_file_template`. - -WC14 and WCwISC14 -^^^^^^^^^^^^^^^^^ - -The class :py:class:`compass.ocean.tests.global_ocean.mesh.wc14.dynamic_adjustment.WC14DynamicAdjustment` -defines a test case for performing dynamical adjustment on the mesh. In the -``damped_adjustment_1`` through ``damped_adjustment_6`` steps, the model is run -for durations ranging from 6 hours to 3 days with gradually increasing time -step and gradually weakening Rayleigh friction (from ``1e-3`` 1/s to ``0``) to -damp the velocity field. In the ``simulation`` step, the model runs for an -additional 24 days without Rayleigh friction. The dynamic adjustment test case -takes advantage of Jinja templating for streams files to use the same streams -template for each step in the test case, see -:ref:`dev_step_add_streams_file_template`. + ... + damped_adjustment_1: + run_duration: 10_00:00:00 + output_interval: 10_00:00:00 + restart_interval: 10_00:00:00 + dt: 00:15:00 + btr_dt: 00:00:30 + Rayleigh_damping_coeff: 1.0e-4 + +Most of these entries are required. The ``run_duration`` is the length of the +simulation. The ``output_interval`` is the frequency of output to the +``output.nc`` file, which contains basic prognostic variables: temperature, +salinity, layer thickness and normal velocity. The ``restart_interval`` is +the frequency at which restart files are written out. Note that it is +important that there be an integer number of restart intervals from the +beginning of the dynamic adjustment to the start of the current step, which +limits the flexibility in selecting the restart interval. + +Typically, a goal of dynamic adjustment is to begin with a smaller baroclinic +time step ``dt`` and the barotropic time step ``btr_dt`` (not applicable for +RK4 time integration) and increase the values in subsequent damped adjustment +steps. The values in the ``simulation`` step should typically be the same as +what the mesh will use in E3SM production runs. + +Another goal of dynamic adjustment is to reduce the ``Rayleigh_damping_coeff`` +from a relatively high number (often ``1.0e-3`` or ``1.0e-4``) to nothing. The +Rayleigh friction is a linear damping on the momentum that can reduce the +amplitude and speed of fast barotropic waves as the ocean spins up from rest. +For steps where Rayleigh friction should be turned off, you can either omit +the line with ``Rayleigh_damping_coeff`` or use +``Rayleigh_damping_coeff: None``. The latter is slightly preferred because it +is more explicit. .. _dev_ocean_global_ocean_files_for_e3sm: @@ -1215,7 +1238,7 @@ case called ``assembled_files``. See :ref:`global_ocean_files_for_e3sm` in the User's Guide for more details. Output file names involve the "mesh short name", see :ref:`dev_ocean_global_ocean_metadata`. -The test case is constructed with an argument ``restart_filename``. the final +The test case is constructed with an argument ``restart_filename``, the final restart file produced by the :ref:`dev_ocean_global_ocean_dynamic_adjustment` for the given mesh. diff --git a/docs/users_guide/ocean/test_groups/global_ocean.rst b/docs/users_guide/ocean/test_groups/global_ocean.rst index 29f1d33f2e..7a64e72d0c 100644 --- a/docs/users_guide/ocean/test_groups/global_ocean.rst +++ b/docs/users_guide/ocean/test_groups/global_ocean.rst @@ -828,14 +828,11 @@ with aggressive damping, followed by 10 more days without damping. Higher resolution meshes in :ref:`legacy_compass` require several stages of damping, each over several days before damping can be removed. -As with the :ref:`global_ocean_performance_test`, ``dynamic_adjustment`` can -be run with either or both of the split-explicit or RK4 time integrator. -Thus, for a given mesh ```` and initial condition ````, one or -more of these versions of the ``performance_test`` will be available: - -* ``ocean/global_ocean///dynamic_adjustment/split_explicit`` +Currently ``dynamic_adjustment`` is only available for the split-explicit (not +the RK4) time integrator. Thus, for a given mesh ```` and initial +condition ````, the ``dynamic_adjustment`` will be available at: -* ``ocean/global_ocean///dynamic_adjustment/RK4`` +``ocean/global_ocean///dynamic_adjustment`` Versions of this test cases is currently available for all meshes, but not necessarily for all combinations of initial conditions and time integrators. diff --git a/setup.py b/setup.py index 88ce322f5b..5ac7e0a9cd 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ def package_files(directory, prefixes, extensions): 'pyamg', 'pyproj', 'requests', + 'ruamel.yaml', 'scipy>=1.8.0', 'shapely', 'xarray']