Skip to content

Commit dddbf1d

Browse files
committed
Add Omega support to Cosine Bell tests
1 parent bdd5ae4 commit dddbf1d

File tree

6 files changed

+59
-21
lines changed

6 files changed

+59
-21
lines changed

polaris/ocean/tasks/cosine_bell/analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def exact_solution(self, refinement_factor, field_name, time, zidx=None):
7979
ds_mesh = xr.open_dataset(f'mesh_r{refinement_factor:02g}.nc')
8080
sphere_radius = ds_mesh.sphere_radius
8181

82-
ds_init = xr.open_dataset(f'init_r{refinement_factor:02g}.nc')
82+
ds_init = self.open_model_dataset(f'init_r{refinement_factor:02g}.nc')
8383
latCell = ds_init.latCell.values
8484
lonCell = ds_init.lonCell.values
8585

polaris/ocean/tasks/cosine_bell/cosine_bell.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ error_type = l2
3636
# config options for convergence forward steps
3737
[convergence_forward]
3838

39-
# time integrator: {'split_explicit', 'RK4'}
39+
# time integrator
40+
# either: {'RK4'}
41+
# mpas-ocean: {'split_explicit'}
42+
# omega: {'Forward-Backward', 'RungeKutta2'}
4043
time_integrator = RK4
4144

4245
# RK4 time step per resolution (s/km), since dt is proportional to resolution

polaris/ocean/tasks/cosine_bell/forward.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,13 @@ def __init__(self, component, name, subdir, mesh, init,
4646
graph_target=f'{mesh.path}/graph.info',
4747
refinement_factor=refinement_factor,
4848
refinement=refinement)
49+
50+
def setup(self):
51+
"""
52+
TEMP: symlink initial condition to name hard-coded in Omega
53+
"""
54+
super().setup()
55+
model = self.config.get('ocean', 'model')
56+
# TODO: remove as soon as Omega no longer hard-codes this file
57+
if model == 'omega':
58+
self.add_input_file(filename='OmegaMesh.nc', target='init.nc')

polaris/ocean/tasks/cosine_bell/forward.yaml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
mpas-ocean:
2-
run_modes:
3-
config_ocean_run_mode: forward
1+
ocean:
42
time_management:
53
config_stop_time: none
64
config_run_duration: {{ run_duration }}
7-
decomposition:
8-
config_block_decomp_file_prefix: graph.info.part.
95
time_integration:
106
config_dt: {{ dt }}
117
config_time_integrator: {{ time_integrator }}
8+
9+
mpas-ocean:
10+
run_modes:
11+
config_ocean_run_mode: forward
12+
decomposition:
13+
config_block_decomp_file_prefix: graph.info.part.
1214
debug:
1315
config_disable_thick_all_tend: true
1416
config_disable_thick_hadv: true
@@ -65,3 +67,32 @@ mpas-ocean:
6567
- refLayerThickness
6668
- kineticEnergyCell
6769
- relativeVorticityCell
70+
71+
Omega:
72+
Tendencies:
73+
ThicknessFluxTendencyEnable : false
74+
PVTendencyEnable : false
75+
KETendencyEnable : false
76+
SSHTendencyEnable : false
77+
VelDiffTendencyEnable: false
78+
VelHyperDiffTendencyEnable: false
79+
TracerHorzAdvTendencyEnable : true
80+
TracerDiffTendencyEnable : false
81+
TracerHyperDiffTendencyEnable : false
82+
Dimension:
83+
NVertLevels: 1
84+
IOStreams:
85+
InitialState:
86+
Filename: init.nc
87+
Contents:
88+
- State
89+
- Tracers
90+
History:
91+
Filename: output.nc
92+
Freq: {{ output_freq }}
93+
FreqUnits: Seconds
94+
Contents:
95+
- Tracers
96+
- LayerThickness
97+
- NormalVelocity
98+
RestartRead: {}

polaris/ocean/tasks/cosine_bell/init.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import numpy as np
22
import xarray as xr
3-
from mpas_tools.io import write_netcdf
43
from mpas_tools.transects import lon_lat_to_cartesian
54
from mpas_tools.vector import Vector
65

7-
from polaris import Step
6+
from polaris.ocean.model import OceanIOStep
87
from polaris.ocean.vertical import init_vertical_coord
98

109

11-
class Init(Step):
10+
class Init(OceanIOStep):
1211
"""
1312
A step for an initial condition for for the cosine bell test case
1413
"""
@@ -36,10 +35,6 @@ def __init__(self, component, name, subdir, base_mesh):
3635
filename='mesh.nc',
3736
work_dir_target=f'{base_mesh.path}/base_mesh.nc')
3837

39-
self.add_input_file(
40-
filename='graph.info',
41-
work_dir_target=f'{base_mesh.path}/graph.info')
42-
4338
self.add_output_file(filename='initial_state.nc')
4439

4540
def run(self):
@@ -107,7 +102,7 @@ def run(self):
107102
ds['fEdge'] = xr.zeros_like(ds_mesh.xEdge)
108103
ds['fVertex'] = xr.zeros_like(ds_mesh.xVertex)
109104

110-
write_netcdf(ds, 'initial_state.nc')
105+
self.write_model_dataset(ds, 'initial_state.nc')
111106

112107

113108
def cosine_bell(max_value, ri, r):

polaris/ocean/tasks/cosine_bell/viz.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import cmocean # noqa: F401
2-
import xarray as xr
32

4-
from polaris import Step
3+
from polaris.ocean.model import OceanIOStep
54
from polaris.viz import plot_global_mpas_field
65

76

8-
class Viz(Step):
7+
class Viz(OceanIOStep):
98
"""
109
A step for plotting fields from the cosine bell output
1110
@@ -64,7 +63,7 @@ def run(self):
6463
mesh_name = self.mesh_name
6564
run_duration = config.getfloat('convergence_forward', 'run_duration')
6665

67-
ds_init = xr.open_dataset('initial_state.nc')
66+
ds_init = self.open_model_dataset('initial_state.nc')
6867
da = ds_init['tracer1'].isel(Time=0, nVertLevels=0)
6968

7069
plot_global_mpas_field(
@@ -73,11 +72,11 @@ def run(self):
7372
title=f'{mesh_name} tracer at init', plot_land=False,
7473
central_longitude=180.)
7574

76-
ds_out = xr.open_dataset('output.nc')
75+
ds_out = self.open_model_dataset('output.nc')
7776
da = ds_out['tracer1'].isel(Time=-1, nVertLevels=0)
7877

7978
plot_global_mpas_field(
8079
mesh_filename='mesh.nc', da=da, out_filename='final.png',
8180
config=config, colormap_section='cosine_bell_viz',
82-
title=f'{mesh_name} tracer after {run_duration/24.:g} days',
81+
title=f'{mesh_name} tracer after {run_duration / 24.:g} days',
8382
plot_land=False, central_longitude=180.)

0 commit comments

Comments
 (0)