From 98f3641653b6963ed32399f2db7224f9fac86c15 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Sep 2024 10:28:51 -0500 Subject: [PATCH 01/15] Add del2 and del4 tasks --- .../tasks/manufactured_solution/__init__.py | 37 +++++++++++++++++-- .../tasks/manufactured_solution/forward.py | 31 +++++++++++++++- .../tasks/manufactured_solution/forward.yaml | 4 ++ 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index 965fc0a9e..95da1f703 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -35,6 +35,14 @@ def add_manufactured_solution_tasks(component): component.add_task(ManufacturedSolution(component=component, config=config, refinement=refinement)) + component.add_task(ManufacturedSolution(component=component, + config=config, + refinement='space', + del2=True)) + component.add_task(ManufacturedSolution(component=component, + config=config, + refinement='space', + del4=True)) class ManufacturedSolution(Task): @@ -42,7 +50,8 @@ class ManufacturedSolution(Task): The convergence test case using the method of manufactured solutions """ - def __init__(self, component, config, refinement='both'): + def __init__(self, component, config, refinement='both', del2=False, + del4=False): """ Create the test case @@ -56,11 +65,32 @@ def __init__(self, component, config, refinement='both'): refinement : str, optional Whether to refine in space, time or both space and time + + del2 : bool + Whether to evaluate the momentum del2 operator + + del4 : bool + Whether to evaluate the momentum del4 operator """ - name = f'manufactured_solution_convergence_{refinement}' basedir = 'planar/manufactured_solution' subdir = f'{basedir}/convergence_{refinement}' + name = f'manufactured_solution_convergence_{refinement}' + if del2: + name = f'{name}_del2' + subdir = f'{subdir}/del2' + if del4: + del4 = False + print('Manufactured solution test does not currently support' + 'both del2 and del4 convergence; testing del2 alone.') + elif del4: + name = f'{name}_del4' + subdir = f'{subdir}/del4' + else: + name = f'{name}_default' + subdir = f'{subdir}/default' + config_filename = 'manufactured_solution.cfg' + super().__init__(component=component, name=name, subdir=subdir) self.set_shared_config(config, link=config_filename) @@ -108,7 +138,8 @@ def __init__(self, component, config, refinement='both'): refinement_factor=refinement_factor, name=f'forward_{mesh_name}_{timestep}s', subdir=subdir, - init=init_step) + init=init_step, + del2=del2, del4=del4) forward_step.set_shared_config( config, link=config_filename) self.add_step(forward_step, symlink=symlink) diff --git a/polaris/ocean/tasks/manufactured_solution/forward.py b/polaris/ocean/tasks/manufactured_solution/forward.py index 2b7b9882b..1e8b9027d 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.py +++ b/polaris/ocean/tasks/manufactured_solution/forward.py @@ -21,9 +21,18 @@ class Forward(ConvergenceForward): refinement : str Refinement type. One of 'space', 'time' or 'both' indicating both space and time + + resolution : float + The resolution of the test case in km + + del2 : bool + Whether to evaluate the momentum del2 operator + + del4 : bool + Whether to evaluate the momentum del4 operator """ def __init__(self, component, name, refinement_factor, subdir, - init, refinement='both'): + init, refinement='both', del2=False, del4=False): """ Create a new test case @@ -47,6 +56,12 @@ def __init__(self, component, name, refinement_factor, subdir, refinement : str, optional Refinement type. One of 'space', 'time' or 'both' indicating both space and time + + del2 : bool + Whether to evaluate the momentum del2 operator + + del4 : bool + Whether to evaluate the momentum del4 operator """ super().__init__(component=component, name=name, subdir=subdir, @@ -68,6 +83,8 @@ def setup(self): # TODO: remove as soon as Omega no longer hard-codes this file if model == 'omega': self.add_input_file(filename='OmegaMesh.nc', target='init.nc') + self.del2 = del2 + self.del4 = del4 def compute_cell_count(self): """ @@ -107,5 +124,15 @@ def dynamic_model_config(self, at_setup): 'config_manufactured_solution_wavelength_x': float(exact_solution.lambda_x), 'config_manufactured_solution_wavelength_y': - float(exact_solution.lambda_y)} + float(exact_solution.lambda_y), + 'config_disable_vel_hmix': + True} + + if self.del2: + options['config_disable_vel_hmix'] = False + options['config_use_mom_del2'] = True + if self.del4: + options['config_disable_vel_hmix'] = False + options['config_use_mom_del4'] = True + self.add_model_config_options(options, config_model='mpas-ocean') diff --git a/polaris/ocean/tasks/manufactured_solution/forward.yaml b/polaris/ocean/tasks/manufactured_solution/forward.yaml index 98e2ce8cb..358ba0a6e 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.yaml +++ b/polaris/ocean/tasks/manufactured_solution/forward.yaml @@ -11,6 +11,10 @@ mpas-ocean: config_bottom_drag_mode: implicit config_implicit_bottom_drag_type: constant config_implicit_constant_bottom_drag_coeff: 0.0 + hmix_del2: + config_mom_del2: 1000. + hmix_del4: + config_mom_del4: 1.e10 manufactured_solution: config_use_manufactured_solution: true debug: From 88ff75e0ae9e55a092bfaa60a3e8cc6d2b09bb6f Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 20 Sep 2024 13:47:26 -0500 Subject: [PATCH 02/15] Share init steps --- polaris/ocean/tasks/manufactured_solution/__init__.py | 2 +- polaris/ocean/tasks/manufactured_solution/init.py | 5 ++--- polaris/ocean/tasks/manufactured_solution/viz.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index 95da1f703..8c3f10b2d 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -136,7 +136,7 @@ def __init__(self, component, config, refinement='both', del2=False, component=component, refinement=refinement, refinement_factor=refinement_factor, - name=f'forward_{mesh_name}_{timestep}s', + name=f'{forward_name}_{timestep}s', subdir=subdir, init=init_step, del2=del2, del4=del4) diff --git a/polaris/ocean/tasks/manufactured_solution/init.py b/polaris/ocean/tasks/manufactured_solution/init.py index d08cf15fc..09c9b49d0 100644 --- a/polaris/ocean/tasks/manufactured_solution/init.py +++ b/polaris/ocean/tasks/manufactured_solution/init.py @@ -22,7 +22,7 @@ class Init(OceanIOStep): resolution : float The resolution of the test case in km """ - def __init__(self, component, resolution, subdir): + def __init__(self, component, resolution, subdir, name): """ Create the step @@ -37,9 +37,8 @@ def __init__(self, component, resolution, subdir): taskdir : str The subdirectory that the task belongs to """ - mesh_name = resolution_to_subdir(resolution) super().__init__(component=component, - name=f'init_{mesh_name}', + name=name, subdir=subdir) self.resolution = resolution diff --git a/polaris/ocean/tasks/manufactured_solution/viz.py b/polaris/ocean/tasks/manufactured_solution/viz.py index 1df29a89f..13e6c4bfe 100644 --- a/polaris/ocean/tasks/manufactured_solution/viz.py +++ b/polaris/ocean/tasks/manufactured_solution/viz.py @@ -109,7 +109,7 @@ def setup(self): forward = dependencies['forward'][refinement_factor] self.add_input_file( filename=f'mesh_r{refinement_factor:02g}.nc', - work_dir_target=f'{base_mesh.path}/base_mesh.nc') + work_dir_target=f'{base_mesh.path}/culled_mesh.nc') self.add_input_file( filename=f'init_r{refinement_factor:02g}.nc', work_dir_target=f'{init.path}/initial_state.nc') From 1eb1125b3b0f0fb86c3cc14925741b495ee1120b Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 1 Oct 2024 09:37:49 -0500 Subject: [PATCH 03/15] fixup omega cfg options --- .../tasks/manufactured_solution/forward.py | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/forward.py b/polaris/ocean/tasks/manufactured_solution/forward.py index 1e8b9027d..e73c145b4 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.py +++ b/polaris/ocean/tasks/manufactured_solution/forward.py @@ -72,6 +72,8 @@ def __init__(self, component, name, refinement_factor, subdir, graph_target=f'{init.path}/culled_graph.info', output_filename='output.nc', validate_vars=['layerThickness', 'normalVelocity']) + self.del2 = del2 + self.del4 = del4 def setup(self): """ @@ -83,8 +85,6 @@ def setup(self): # TODO: remove as soon as Omega no longer hard-codes this file if model == 'omega': self.add_input_file(filename='OmegaMesh.nc', target='init.nc') - self.del2 = del2 - self.del4 = del4 def compute_cell_count(self): """ @@ -119,20 +119,25 @@ def dynamic_model_config(self, at_setup): super().dynamic_model_config(at_setup=at_setup) exact_solution = ExactSolution(self.config) - options = {'config_manufactured_solution_amplitude': - float(exact_solution.eta0), - 'config_manufactured_solution_wavelength_x': - float(exact_solution.lambda_x), - 'config_manufactured_solution_wavelength_y': - float(exact_solution.lambda_y), - 'config_disable_vel_hmix': - True} - + mpas_options = {'config_manufactured_solution_amplitude': + float(exact_solution.eta0), + 'config_manufactured_solution_wavelength_x': + float(exact_solution.lambda_x), + 'config_manufactured_solution_wavelength_y': + float(exact_solution.lambda_y)} + shared_options = {} if self.del2: - options['config_disable_vel_hmix'] = False - options['config_use_mom_del2'] = True - if self.del4: - options['config_disable_vel_hmix'] = False - options['config_use_mom_del4'] = True - - self.add_model_config_options(options, config_model='mpas-ocean') + mpas_options['config_disable_vel_hmix'] = False + shared_options['config_use_mom_del2'] = True + shared_options['config_use_mom_del4'] = False + elif self.del4: + mpas_options['config_disable_vel_hmix'] = False + shared_options['config_use_mom_del2'] = False + shared_options['config_use_mom_del4'] = True + else: + mpas_options['config_disable_vel_hmix'] = True + shared_options['config_use_mom_del2'] = False + shared_options['config_use_mom_del4'] = False + + self.add_model_config_options(mpas_options, config_model='mpas-ocean') + self.add_model_config_options(shared_options, config_model='ocean') From 01ef992c4750a4209bde8382cfd4ca637e655627 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 1 Oct 2024 14:10:21 -0500 Subject: [PATCH 04/15] Add manufactured tests to convergence suite --- polaris/ocean/suites/convergence.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polaris/ocean/suites/convergence.txt b/polaris/ocean/suites/convergence.txt index 9a92ef47e..af9940a77 100644 --- a/polaris/ocean/suites/convergence.txt +++ b/polaris/ocean/suites/convergence.txt @@ -1,5 +1,7 @@ ocean/planar/inertial_gravity_wave/convergence_both -ocean/planar/manufactured_solution/convergence_both +ocean/planar/manufactured_solution/convergence_both/default +ocean/planar/manufactured_solution/convergence_both/del2 +ocean/planar/manufactured_solution/convergence_both/del4 ocean/spherical/icos/correlated_tracers_2d cached: icos_base_mesh_60km icos_base_mesh_120km icos_base_mesh_240km icos_base_mesh_480km ocean/spherical/qu/correlated_tracers_2d From cfbda7503a98ffd4bc280d3537b9226b8963429e Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 1 Oct 2024 14:17:00 -0500 Subject: [PATCH 05/15] Update docs --- .../ocean/tasks/manufactured_solution.md | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/users_guide/ocean/tasks/manufactured_solution.md b/docs/users_guide/ocean/tasks/manufactured_solution.md index 866f2d85d..3d58a1ae8 100644 --- a/docs/users_guide/ocean/tasks/manufactured_solution.md +++ b/docs/users_guide/ocean/tasks/manufactured_solution.md @@ -16,9 +16,9 @@ Currently, the there is only one task, the convergence test from These tasks support both MPAS-Ocean and Omega. -(ocean-manufactured-solution-convergence)= +(ocean-manufactured-solution-default)= -## convergence +## default ### description @@ -127,3 +127,22 @@ conv_thresh = 1.8 The number of cores is determined according to the config options ``max_cells_per_core`` and ``goal_cells_per_core``. + +(ocean-manufactured-solution-del2)= + +## del2 + +### description + +All settings are the same as the {ref}`ocean-manufactured-solution-default` case +except laplacian viscosity is turned on. + +(ocean-manufactured-solution-del4)= + +## del4 + +### description + +All settings are the same as the {ref}`ocean-manufactured-solution-default` case +except hyperviscosity is turned on. The expected convergence should not be +significantly different from the {ref}`ocean-manufactured-solution-default` case. From 95a29149ddcd7251dd5ce7188de09d6c55f8f50d Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Sun, 8 Dec 2024 09:47:08 -0600 Subject: [PATCH 06/15] Fixup rebase onto convergence changes --- polaris/ocean/tasks/manufactured_solution/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index 8c3f10b2d..bdf6a0059 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -37,11 +37,11 @@ def add_manufactured_solution_tasks(component): refinement=refinement)) component.add_task(ManufacturedSolution(component=component, config=config, - refinement='space', + refinement='both', del2=True)) component.add_task(ManufacturedSolution(component=component, config=config, - refinement='space', + refinement='both', del4=True)) @@ -116,7 +116,7 @@ def __init__(self, component, config, refinement='both', del2=False, init_step = component.steps[subdir] else: init_step = Init(component=component, resolution=resolution, - subdir=subdir) + name=f'init_{mesh_name}', subdir=subdir) init_step.set_shared_config(self.config, link=config_filename) if resolution not in resolutions: self.add_step(init_step, symlink=symlink) @@ -136,7 +136,7 @@ def __init__(self, component, config, refinement='both', del2=False, component=component, refinement=refinement, refinement_factor=refinement_factor, - name=f'{forward_name}_{timestep}s', + name=f'forward_{mesh_name}_{timestep}s', subdir=subdir, init=init_step, del2=del2, del4=del4) From 3edc74cbc7f55b67625b6f4024098c6fba2370e0 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Dec 2024 15:23:44 -0600 Subject: [PATCH 07/15] Add manufactured solution test suite --- polaris/ocean/suites/manufactured_solution.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 polaris/ocean/suites/manufactured_solution.txt diff --git a/polaris/ocean/suites/manufactured_solution.txt b/polaris/ocean/suites/manufactured_solution.txt new file mode 100644 index 000000000..ff95dcc96 --- /dev/null +++ b/polaris/ocean/suites/manufactured_solution.txt @@ -0,0 +1,5 @@ +ocean/planar/manufactured_solution/convergence_space/default +# ocean/planar/manufactured_solution/convergence_time/default +ocean/planar/manufactured_solution/convergence_both/default +ocean/planar/manufactured_solution/convergence_both/del2 +ocean/planar/manufactured_solution/convergence_both/del4 From eb4b32a5b4128675a70f6b779204572bb79ed7a2 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Dec 2024 15:24:39 -0600 Subject: [PATCH 08/15] Fixup forward step paths --- .../ocean/tasks/manufactured_solution/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index bdf6a0059..b6cac98c2 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -75,19 +75,20 @@ def __init__(self, component, config, refinement='both', del2=False, basedir = 'planar/manufactured_solution' subdir = f'{basedir}/convergence_{refinement}' name = f'manufactured_solution_convergence_{refinement}' + if del2: - name = f'{name}_del2' - subdir = f'{subdir}/del2' + test_name = 'del2' if del4: del4 = False print('Manufactured solution test does not currently support' 'both del2 and del4 convergence; testing del2 alone.') elif del4: - name = f'{name}_del4' - subdir = f'{subdir}/del4' + test_name = 'del4' else: - name = f'{name}_default' - subdir = f'{subdir}/default' + test_name = 'default' + + name = f'{name}_{test_name}' + subdir = f'{subdir}/{test_name}' config_filename = 'manufactured_solution.cfg' @@ -127,7 +128,7 @@ def __init__(self, component, config, refinement='both', del2=False, timestep = ceil(timestep) timesteps.append(timestep) - subdir = f'{basedir}/forward/{mesh_name}_{timestep}s' + subdir = f'{basedir}/{test_name}/forward/{mesh_name}_{timestep}s' symlink = f'forward/{mesh_name}_{timestep}s' if subdir in component.steps: forward_step = component.steps[subdir] From 1bb6b4e8d1d3fd5adfea4f697c0371a3afacce19 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Dec 2024 16:02:32 -0600 Subject: [PATCH 09/15] Fixup linting --- polaris/ocean/tasks/manufactured_solution/init.py | 1 - 1 file changed, 1 deletion(-) diff --git a/polaris/ocean/tasks/manufactured_solution/init.py b/polaris/ocean/tasks/manufactured_solution/init.py index 09c9b49d0..fa820b727 100644 --- a/polaris/ocean/tasks/manufactured_solution/init.py +++ b/polaris/ocean/tasks/manufactured_solution/init.py @@ -5,7 +5,6 @@ from polaris.mesh.planar import compute_planar_hex_nx_ny from polaris.ocean.model import OceanIOStep -from polaris.ocean.resolution import resolution_to_subdir from polaris.ocean.tasks.manufactured_solution.exact_solution import ( ExactSolution, ) From 5a60c8cd885c204c042c808561f8da1f0efb2162 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 6 Jan 2025 15:03:04 -0600 Subject: [PATCH 10/15] Convergence 2.043 for del2, 2.041 for del4 --- polaris/ocean/tasks/manufactured_solution/forward.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/forward.yaml b/polaris/ocean/tasks/manufactured_solution/forward.yaml index 358ba0a6e..f8d5141eb 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.yaml +++ b/polaris/ocean/tasks/manufactured_solution/forward.yaml @@ -12,13 +12,15 @@ mpas-ocean: config_implicit_bottom_drag_type: constant config_implicit_constant_bottom_drag_coeff: 0.0 hmix_del2: - config_mom_del2: 1000. + config_mom_del2: 1.5e6 hmix_del4: - config_mom_del4: 1.e10 + config_mom_del4: 5.e13 manufactured_solution: config_use_manufactured_solution: true debug: - config_disable_vel_hmix: true + config_compute_active_tracer_budgets: false + config_disable_vel_vmix: true + config_disable_tr_all_tend: true streams: mesh: filename_template: init.nc From 128a44c82e35e6c17cfcefb881fc946ce25f1ef3 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 6 Jan 2025 15:04:07 -0600 Subject: [PATCH 11/15] Increase precision of convergence rate --- polaris/ocean/convergence/analysis.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/polaris/ocean/convergence/analysis.py b/polaris/ocean/convergence/analysis.py index c644c02d0..59ef0bf46 100644 --- a/polaris/ocean/convergence/analysis.py +++ b/polaris/ocean/convergence/analysis.py @@ -218,7 +218,7 @@ def plot_convergence(self, variable_name, title, zidx): convergence_failed = False poly = np.polyfit(np.log10(refinement_array), np.log10(error_array), 1) convergence = poly[0] - conv_round = np.round(convergence, 3) + conv_round = convergence fit = refinement_array ** poly[0] * 10 ** poly[1] @@ -239,7 +239,7 @@ def plot_convergence(self, variable_name, title, zidx): ax.loglog(resolutions, order2, 'k', label='second order', alpha=0.3) ax.loglog(refinement_array, fit, 'k', - label=f'linear fit (order={conv_round})') + label=f'linear fit (order={convergence:1.3f})') ax.loglog(refinement_array, error_array, 'o', label='numerical') if self.baseline_dir is not None: @@ -255,14 +255,14 @@ def plot_convergence(self, variable_name, title, zidx): poly = np.polyfit( np.log10(refinement_array), np.log10(error_array), 1) base_convergence = poly[0] - conv_round = np.round(base_convergence, 3) + conv_round = base_convergence fit = refinement_array ** poly[0] * 10 ** poly[1] ax.loglog(refinement_array, error_array, 'o', color='#ff7f0e', label='baseline') ax.loglog(refinement_array, fit, color='#ff7f0e', label=f'linear fit, baseline ' - f'(order={conv_round})') + f'(order={base_convergence:1.3f})') ax.set_xlabel(x_label) ax.set_ylabel(f'{error_title}') ax.set_title(f'Error Convergence of {title}') @@ -273,11 +273,11 @@ def plot_convergence(self, variable_name, title, zidx): plt.close() logger.info(f'Order of convergence for {title}: ' - f'{conv_round}') + f'{conv_round:1.3f}') if conv_round < conv_thresh: logger.error(f'Error: order of convergence for {title}\n' - f' {conv_round} < min tolerance ' + f' {conv_round:1.3f} < min tolerance ' f'{conv_thresh}') convergence_failed = True From 071f244ea6772cfc4e9d8a17edb07882ed27ffa3 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 6 Jan 2025 15:04:35 -0600 Subject: [PATCH 12/15] Decrease time step for manufactured solution --- .../ocean/tasks/manufactured_solution/manufactured_solution.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polaris/ocean/tasks/manufactured_solution/manufactured_solution.cfg b/polaris/ocean/tasks/manufactured_solution/manufactured_solution.cfg index c6b270211..479555530 100644 --- a/polaris/ocean/tasks/manufactured_solution/manufactured_solution.cfg +++ b/polaris/ocean/tasks/manufactured_solution/manufactured_solution.cfg @@ -25,7 +25,7 @@ n_wavelengths_x = 2 n_wavelengths_y = 2 # Time step per resolution (s/km), since dt is proportional to resolution -dt_per_km = 3.0 +dt_per_km = 1.5 # Convergence threshold below which the test fails conv_thresh = 1.8 From c2de9bc15485b576c0f31d63b90c21db95073264 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Wed, 8 Jan 2025 09:35:43 -0600 Subject: [PATCH 13/15] Move omega ssh nVertLevels selection to convergence analysis --- polaris/ocean/convergence/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polaris/ocean/convergence/analysis.py b/polaris/ocean/convergence/analysis.py index 59ef0bf46..f3008091a 100644 --- a/polaris/ocean/convergence/analysis.py +++ b/polaris/ocean/convergence/analysis.py @@ -410,7 +410,7 @@ def get_output_field(self, refinement_factor, field_name, time, zidx=None): ds_out = ds_out.isel(Time=tidx) field_mpas = ds_out[field_name] - if zidx is not None: + if zidx is not None and 'nVertLevels' in field_mpas.dims: field_mpas = field_mpas.isel(nVertLevels=zidx) return field_mpas From d48ea7bf239c04d71ad7ab0a41a95b5646bcb6f2 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Wed, 8 Jan 2025 09:47:30 -0600 Subject: [PATCH 14/15] Fixup manufactured solution viz time --- .../ocean/tasks/manufactured_solution/viz.py | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/viz.py b/polaris/ocean/tasks/manufactured_solution/viz.py index 13e6c4bfe..a87306da9 100644 --- a/polaris/ocean/tasks/manufactured_solution/viz.py +++ b/polaris/ocean/tasks/manufactured_solution/viz.py @@ -1,9 +1,8 @@ -import datetime - import cmocean # noqa: F401 import matplotlib.pyplot as plt import numpy as np +from polaris.mpas import time_since_start from polaris.ocean.convergence import ( get_resolution_for_task, get_timestep_for_task, @@ -139,9 +138,13 @@ def run(self): use_mplstyle() fig, axes = plt.subplots(nrows=nres, ncols=3, figsize=(12, 2 * nres)) - rmse = [] error_range = None + section = config['convergence'] + eval_time = section.getfloat('convergence_eval_time') + s_per_hour = 3600.0 + time = eval_time * s_per_hour + for i, refinement_factor in enumerate(refinement_factors): ds_mesh = self.open_model_dataset( f'mesh_r{refinement_factor:02g}.nc') @@ -149,29 +152,25 @@ def run(self): f'init_r{refinement_factor:02g}.nc') ds = self.open_model_dataset( f'output_r{refinement_factor:02g}.nc', decode_times=False) + exact = ExactSolution(config, ds_init) if model == 'mpas-o': - t0 = datetime.datetime.strptime(ds.xtime.values[0].decode(), - '%Y-%m-%d_%H:%M:%S') - tf = datetime.datetime.strptime(ds.xtime.values[-1].decode(), - '%Y-%m-%d_%H:%M:%S') - t = (tf - t0).total_seconds() - + dt = time_since_start(ds.xtime.values) else: # time is seconds since the start of the simulation in Omega - t = ds.Time[-1].values + dt = ds.Time.values + tidx = np.argmin(np.abs(dt - time)) - ssh_model = ds.ssh.isel(Time=-1) + ssh_model = ds.ssh.isel(Time=tidx) if 'nVertLevels' in ssh_model.dims: # Omega v0 uses stacked shallow water where ssh has nVertLevels ssh_model = ssh_model.isel(nVertLevels=0) - rmse.append(np.sqrt(np.mean( - (ssh_model.values - exact.ssh(t).values)**2))) # Comparison plots - ds['ssh_exact'] = exact.ssh(t) - ds['ssh_error'] = ssh_model - exact.ssh(t) + ssh_exact = exact.ssh(time) + ds['ssh_exact'] = ssh_exact + ds['ssh_error'] = ssh_model - ssh_exact if error_range is None: error_range = np.max(np.abs(ds.ssh_error.values)) From 6e7b3b0dc09537fcfbf6454f066b809aa8cd96eb Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 9 Jan 2025 15:29:20 -0600 Subject: [PATCH 15/15] Update E3SM submodule to include del2,del4 changes --- e3sm_submodules/E3SM-Project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e3sm_submodules/E3SM-Project b/e3sm_submodules/E3SM-Project index 67ae4d5d7..3ad78d70b 160000 --- a/e3sm_submodules/E3SM-Project +++ b/e3sm_submodules/E3SM-Project @@ -1 +1 @@ -Subproject commit 67ae4d5d770e97ecf689aae239500de428d7153b +Subproject commit 3ad78d70bb60f4fc42d90b60b31b1e195bd7be75