@@ -12,7 +12,7 @@ include("climaocean_helpers.jl")
1212"""
1313 ClimaSeaIceSimulation{SIM, A, OPROP, REMAP}
1414
15- The ClimaCoupler simulation object used to run with Oceananigans .
15+ The ClimaCoupler simulation object used to run with ClimaSeaIce .
1616This type is used by the coupler to indicate that this simulation
1717is an surface/ocean simulation for dispatch.
1818
@@ -21,15 +21,14 @@ It contains the following objects:
2121- `area_fraction::A`: A ClimaCore Field representing the surface area fraction of this component model on the exchange grid.
2222- `melting_speed::MS`: An constant characteristic speed for melting/freezing.
2323- `remapping::REMAP`: Objects needed to remap from the exchange (spectral) grid to Oceananigans spaces.
24- TODO add skin_temperature field, for now set skin temperature to top layer sea ice temperature
25- alt: compute skin temp from bulk temp and ocean surface temp, assuming linear profile in the top layer,
26- might need to limit min sea ice thickness to avoid crazy gradients
24+ - `ocean_sea_ice_fluxes::NT`: A NamedTuple of fluxes between the ocean and sea ice, computed at each coupling step.
2725"""
28- struct ClimaSeaIceSimulation{SIM, A, MS, REMAP} <: Interfacer.SeaIceModelSimulation
26+ struct ClimaSeaIceSimulation{SIM, A, MS, REMAP, NT } <: Interfacer.SeaIceModelSimulation
2927 sea_ice:: SIM
3028 area_fraction:: A
3129 melting_speed:: MS
3230 remapping:: REMAP
31+ ocean_sea_ice_fluxes:: NT
3332end
3433
3534"""
@@ -73,7 +72,28 @@ function ClimaSeaIceSimulation(area_fraction, ocean; output_dir)
7372 # sea_ice.output_writers[:diagnostics] = netcdf_writer
7473 # end
7574
76- sim = ClimaSeaIceSimulation (sea_ice, area_fraction, melting_speed, remapping)
75+ # Allocate space for the sea ice-ocean (io) fluxes
76+ io_bottom_heat_flux = OC. Field {Center, Center, Nothing} (grid)
77+ io_frazil_heat_flux = OC. Field {Center, Center, Nothing} (grid)
78+ io_salt_flux = OC. Field {Center, Center, Nothing} (grid)
79+ x_momentum = OC. Field {Face, Center, Nothing} (grid)
80+ y_momentum = OC. Field {Center, Face, Nothing} (grid)
81+
82+ ocean_sea_ice_fluxes = (
83+ interface_heat = io_bottom_heat_flux,
84+ frazil_heat = io_frazil_heat_flux,
85+ salt = io_salt_flux,
86+ x_momentum = x_momentum,
87+ y_momentum = y_momentum,
88+ )
89+
90+ sim = ClimaSeaIceSimulation (
91+ sea_ice,
92+ area_fraction,
93+ melting_speed,
94+ remapping,
95+ ocean_sea_ice_fluxes,
96+ )
7797 return sim
7898end
7999
@@ -164,6 +184,7 @@ function FluxCalculator.update_turbulent_fluxes!(sim::ClimaSeaIceSimulation, fie
164184 remapped_F_sh = sim. remapping. scratch_arr2
165185
166186
187+ # TODO update this for sea ice
167188 # TODO what is sim.sea_ice.model.ice_thermodynamics.top_surface_temperature? where is it set?
168189 # TODO ocean_reference_density -> sea_ice.model.ice_density ?
169190 oc_flux_T = surface_flux (sim. ocean. model. tracers. T)
@@ -186,28 +207,29 @@ function FluxCalculator.update_turbulent_fluxes!(sim::ClimaSeaIceSimulation, fie
186207 return nothing
187208end
188209
189- function Interfacer. update_field! (sim:: OceananigansSimulation , :: Val{:area_fraction} , field)
210+ function Interfacer. update_field! (sim:: ClimaSeaIceSimulation , :: Val{:area_fraction} , field)
190211 sim. area_fraction .= field
191212 return nothing
192213end
193214
194215"""
195- FieldExchanger.update_sim!(sim::OceananigansSimulation , csf, area_fraction)
216+ FieldExchanger.update_sim!(sim::ClimaSeaIceSimulation , csf, area_fraction)
196217
197- Update the ocean simulation with the provided fields, which have been filled in
218+ Update the sea ice simulation with the provided fields, which have been filled in
198219by the coupler.
199220
200221Update the portion of the surface_fluxes for T and S that is due to radiation and
201222precipitation. The rest will be updated in `update_turbulent_fluxes!`.
202223
203224A note on sign conventions:
204- ClimaAtmos and Oceananigans both use the convention that a positive flux is an upward flux.
225+ ClimaAtmos and ClimaSeaIce both use the convention that a positive flux is an upward flux.
205226No sign change is needed during the exchange, except for precipitation/salinity fluxes.
206227ClimaAtmos provides precipitation as a negative flux at the surface, and
207- Oceananigans represents precipitation as a positive salinity flux,
228+ ClimaSeaIce represents precipitation as a positive salinity flux,
208229so a sign change is needed when we convert from precipitation to salinity flux.
209230"""
210- function FieldExchanger. update_sim! (sim:: OceananigansSimulation , csf, area_fraction)
231+ function FieldExchanger. update_sim! (sim:: ClimaSeaIceSimulation , csf, area_fraction)
232+ # TODO update this for sea ice
211233 (; ocean_reference_density, ocean_heat_capacity, ocean_fresh_water_density) =
212234 sim. ocean_properties
213235
@@ -249,28 +271,35 @@ function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf, area_fract
249271 return nothing
250272end
251273
252- # TODO add stub to FluxCalculator
253- # TODO fill this in using ClimaOcean: https://github.com/CliMA/ClimaOcean.jl/pull/627
254- # TODO instead of cs we can take in the ocean and sea ice sims, dispatch on them to do nothing for other sea ice models
255- # TODO docstring
256- function ocean_seaice_fluxes! (cs)
257- seaice_sim = cs. models. sea_ice
258- ocean_sim = cs. models. ocean
274+ """
275+ ocean_seaice_fluxes!(ocean_sim, ice_sim)
259276
260- melting_speed = seaice_sim. melting_speed
277+ Compute the fluxes between the ocean and sea ice, storing them in the `ocean_sea_ice_fluxes`
278+ fields of the ocean and sea ice simulations.
279+ """
280+ function FluxCalculator. ocean_seaice_fluxes! (
281+ ocean_sim:: OceananigansSimulation ,
282+ ice_sim:: ClimaSeaIceSimulation ,
283+ )
284+ # TODO unify sea_ice vs ice naming convention in this file
285+ melting_speed = ice_sim. melting_speed
261286 ocean_properties = ocean_sim. ocean_properties
262287
263- # TODO what should fluxes be here?
288+ # Compute the fluxes and store them in the both simulations
264289 OC. compute_sea_ice_ocean_fluxes! (
265- fluxes ,
290+ ice_sim . ocean_sea_ice_fluxes ,
266291 ocean_sim. ocean,
267- seaice_sim . sea_ice,
292+ ice_sim . sea_ice,
268293 melting_speed,
269294 ocean_properties,
270295 )
296+ ocean_sim. ocean_sea_ice_fluxes = ice_sim. ocean_sea_ice_fluxes
297+
298+ # TODO what do we do with these fluxes now? They need to be passed to the component sims somehow
271299 return nothing
272300end
273301
302+
274303"""
275304 get_model_prog_state(sim::ClimaSeaIceSimulation)
276305
0 commit comments