Skip to content

Commit 8a10921

Browse files
simone-silvestrinavidcyseamanticscience
authored
Continue sea-ice coupling effort (#365)
* this works best? * One degree simulation take 4 * add a biharmonic viscosity * infer maximum delta t * changes * add statistics * infer -> compute * compute -> infer * default for distribtued grid * all_reduce instead of allreduce * update other packages * let's see if it works * try it out * run simulation * remove all instances of diffusion * try a zstar grid * need a manifest for this * regrid the bathymetry * better * make it work * Update Project.toml * fix docs * fix docs * update project * just remove it for now * try out correct settings * Update examples/one_degree_simulation.jl Co-authored-by: Jonathan Lauderdale <[email protected]> * should work now * literate one-degree example * use GPU * nuke znode * add CairoMakie 0.13 compat * explain that there is also e * add comment for OrthogonalSphericalShellGrids * add comment for coupled ocean--sea ice * nuke ExplicitTimeDiscretization and fix typo * this should work * add another restoring file * correct videos * tamper with the time step * bugfix * remove for the moment * fix examples * already some bugfix * this should work? * go ahead * some changes * some more changes * some fixes * this should run * we do not need to remove fluxes as we adjust the ocean interior * don't need to do that * also don't need this * adjust temperature * remove unused stuff * remove other stuff * bugfixes * changes * add some tests * remo this line * fix tests * add frazil ice formation * try it like this * this should work * improve model * this works now? * this should work * add default inpainting * better set! function * small bug * bugfix * bugfix * correct fluxes * add the net fluxes * interface heat * Update coefficient_based_turbulent_fluxes.jl * some changes * add a bottom heat BC * add a bottom heat BC * tests should pass --------- Co-authored-by: Navid C. Constantinou <[email protected]> Co-authored-by: Jonathan Lauderdale <[email protected]>
1 parent f4ae354 commit 8a10921

File tree

8 files changed

+110
-120
lines changed

8 files changed

+110
-120
lines changed

experiments/coupled_simulation/ocean_sea_ice_coupled_simulation.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ set!(ocean.model, T=temperature, S=salinity)
8888
set!(sea_ice.model.ice_thickness, ice_thickness, inpainting=NearestNeighborInpainting(1))
8989
set!(sea_ice.model.ice_concentration, ice_concentration, inpainting=NearestNeighborInpainting(1))
9090

91-
adjust_ocean_temperature!(ocean, sea_ice)
9291
earth_model = OceanSeaIceModel(ocean, sea_ice; atmosphere, radiation)
93-
9492
earth = Simulation(earth_model; Δt=30minutes, stop_iteration=10, stop_time=30days)
9593

9694
u, v, _ = ocean.model.velocities

src/DataWrangling/ECCO/ECCO.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function ECCO_field(metadata::ECCOMetadata;
155155
mask = nothing,
156156
horizontal_halo = (7, 7),
157157
cache_inpainted_data = true)
158-
158+
159159
field = empty_ECCO_field(metadata; architecture, horizontal_halo)
160160
inpainted_path = inpainted_metadata_path(metadata)
161161

src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Oceananigans.Operators: ℑxᶠᵃᵃ, ℑyᵃᶠᵃ
44
using ClimaOcean.OceanSeaIceModels: sea_ice_concentration
55

66
@inline computed_sea_ice_ocean_fluxes(interface) = interface.fluxes
7-
@inline computed_sea_ice_ocean_fluxes(::Nothing) = (heat = ZeroField(), salt = ZeroField())
7+
@inline computed_sea_ice_ocean_fluxes(::Nothing) = (interface_heat = ZeroField(), frazil_heat = ZeroField(), salt = ZeroField())
88

99
function compute_net_ocean_fluxes!(coupled_model)
1010
ocean = coupled_model.ocean
@@ -131,7 +131,7 @@ end
131131

132132
@inbounds begin
133133
ℵᵢ = ℵ[i, j, 1]
134-
Qio = sea_ice_ocean_fluxes.heat[i, j, 1]
134+
Qio = sea_ice_ocean_fluxes.interface_heat[i, j, 1]
135135
Jˢio = sea_ice_ocean_fluxes.salt[i, j, 1]
136136
Jᵀio = Qio * ρₒ⁻¹ / cₒ
137137

@@ -142,19 +142,22 @@ end
142142
end
143143
end
144144

145-
compute_net_sea_ice_fluxes!(coupled_model) = nothing
146-
147-
#=
148145
function compute_net_sea_ice_fluxes!(coupled_model)
149-
ocean = coupled_model.ocean
150146
sea_ice = coupled_model.sea_ice
151-
grid = ocean.model.grid
152-
arch = architecture(grid)
147+
148+
if !(sea_ice isa SeaIceSimulation)
149+
return nothing
150+
end
151+
152+
ocean = coupled_model.ocean
153+
grid = ocean.model.grid
154+
arch = architecture(grid)
153155
clock = coupled_model.clock
154156

155-
top_heat_flux = coupled_model.interfaces.net_fluxes.sea_ice_top
156-
atmos_ocean_fluxes = coupled_model.interfaces.atmosphere_ocean_interface.fluxes
157+
top_heat_flux = coupled_model.interfaces.net_fluxes.sea_ice_top.heat
158+
bottom_heat_flux = coupled_model.interfaces.net_fluxes.sea_ice_bottom.heat
157159
sea_ice_ocean_fluxes = coupled_model.interfaces.sea_ice_ocean_interface.fluxes
160+
atmosphere_sea_ice_fluxes = coupled_model.interfaces.atmosphere_sea_ice_interface.fluxes
158161

159162
# Simplify NamedTuple to reduce parameter space consumption.
160163
# See https://github.com/CliMA/ClimaOcean.jl/issues/116.
@@ -165,69 +168,71 @@ function compute_net_sea_ice_fluxes!(coupled_model)
165168

166169
freshwater_flux = atmosphere_fields.Mp.data
167170

168-
sea_ice_concentration = sea_ice.model.ice_concentration
169-
ocean_salinity = ocean.model.tracers.S
170-
atmos_ocean_properties = coupled_model.interfaces.atmosphere_ocean_interface.properties
171-
ocean_properties = coupled_model.interfaces.ocean_properties
171+
atmos_sea_ice_properties = coupled_model.interfaces.atmosphere_sea_ice_interface.properties
172+
sea_ice_properties = coupled_model.interfaces.sea_ice_properties
173+
172174
kernel_parameters = interface_kernel_parameters(grid)
173175

174-
ocean_surface_temperature = coupled_model.interfaces.atmosphere_ocean_interface.temperature
176+
sea_ice_surface_temperature = coupled_model.interfaces.atmosphere_ocean_interface.temperature
175177

176178
launch!(arch, grid, kernel_parameters,
177179
_assemble_net_sea_ice_fluxes!,
178-
net_ocean_fluxes,
180+
top_heat_flux,
181+
bottom_heat_flux,
179182
grid,
180183
clock,
181-
atmos_ocean_fluxes,
184+
atmosphere_sea_ice_fluxes,
182185
sea_ice_ocean_fluxes,
183-
ocean_salinity,
184-
ocean_surface_temperature,
185-
sea_ice_concentration,
186-
downwelling_radiation,
187186
freshwater_flux,
188-
atmos_ocean_properties,
189-
ocean_properties)
187+
sea_ice_surface_temperature,
188+
downwelling_radiation,
189+
sea_ice_properties,
190+
atmos_sea_ice_properties)
190191

191192
return nothing
192193
end
193194

194-
@kernel function _assemble_atmosphere_sea_ice_fluxes!(net_heat_flux,
195-
grid,
196-
clock,
197-
surface_temperature,
198-
surface_temperature_units,
199-
turbulent_fluxes,
200-
downwelling_radiation,
201-
stefan_boltzmann_constant,
202-
albedo,
203-
emissivity)
195+
@kernel function _assemble_net_sea_ice_fluxes!(top_heat_flux,
196+
bottom_heat_flux,
197+
grid,
198+
clock,
199+
atmosphere_sea_ice_fluxes,
200+
sea_ice_ocean_fluxes,
201+
freshwater_flux, # Where do we add this one?
202+
surface_temperature,
203+
downwelling_radiation,
204+
sea_ice_properties,
205+
atmos_sea_ice_properties)
204206

205207
i, j = @index(Global, NTuple)
206208
kᴺ = size(grid, 3)
207209
time = Time(clock.time)
208-
210+
209211
@inbounds begin
210212
Ts = surface_temperature[i, j, kᴺ]
211-
Ts = convert_to_kelvin(surface_temperature_units, Ts)
212-
213-
Qs = downwelling_radiation.shortwave[i, j, 1]
214-
Qℓ = downwelling_radiation.longwave[i, j, 1]
215-
Qc = turbulent_fluxes.sensible_heat[i, j, 1] # sensible or "conductive" heat flux
216-
Qv = turbulent_fluxes.latent_heat[i, j, 1] # latent heat flux
213+
Ts = convert_to_kelvin(sea_ice_properties.temperature_units, Ts)
214+
215+
Qs = downwelling_radiation.Qs[i, j, 1]
216+
Qℓ = downwelling_radiation.Qℓ[i, j, 1]
217+
Qc = atmosphere_sea_ice_fluxes.sensible_heat[i, j, 1] # sensible or "conductive" heat flux
218+
Qv = atmosphere_sea_ice_fluxes.latent_heat[i, j, 1] # latent heat flux
219+
Qf = sea_ice_ocean_fluxes.frazil_heat[i, j, 1] # frazil heat flux
220+
Qi = sea_ice_ocean_fluxes.interface_heat[i, j, 1] # interfacial heat flux
217221
end
218222

219223
# Compute radiation fluxes
220-
σ = stefan_boltzmann_constant
221-
α = stateindex(albedo, i, j, 1, grid, time)
222-
ϵ = stateindex(emissivity, i, j, 1, grid, time)
224+
σ = atmos_sea_ice_properties.radiation.σ
225+
α = stateindex(atmos_sea_ice_properties.radiation.α, i, j, kᴺ, grid, time)
226+
ϵ = stateindex(atmos_sea_ice_properties.radiation.ϵ, i, j, kᴺ, grid, time)
223227
Qu = upwelling_radiation(Ts, σ, ϵ)
224228
Qd = net_downwelling_radiation(i, j, grid, time, α, ϵ, Qs, Qℓ)
225229

226-
ΣQ = Qd + Qu + Qc + Qv
230+
ΣQt = Qd + Qu + Qc + Qv
231+
ΣQb = Qf + Qi
227232

228233
# Mask fluxes over land for convenience
229234
inactive = inactive_node(i, j, kᴺ, grid, c, c, c)
230235

231-
@inbounds net_heat_flux[i, j, 1] = ifelse(inactive, zero(grid), ΣQ)
236+
@inbounds top_heat_flux[i, j, 1] = ifelse(inactive, zero(grid), ΣQt)
237+
@inbounds bottom_heat_flux[i, j, 1] = ifelse(inactive, zero(grid), ΣQb)
232238
end
233-
=#

src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function compute_atmosphere_sea_ice_fluxes!(coupled_model)
3333

3434
flux_formulation = coupled_model.interfaces.atmosphere_sea_ice_interface.flux_formulation
3535
interface_fluxes = coupled_model.interfaces.atmosphere_sea_ice_interface.fluxes
36-
net_top_heat_flux = coupled_model.interfaces.net_fluxes.sea_ice_top.heat
3736
interface_temperature = coupled_model.interfaces.atmosphere_sea_ice_interface.temperature
3837
interface_properties = coupled_model.interfaces.atmosphere_sea_ice_interface.properties
3938
sea_ice_properties = coupled_model.interfaces.sea_ice_properties
@@ -48,7 +47,6 @@ function compute_atmosphere_sea_ice_fluxes!(coupled_model)
4847
_compute_atmosphere_sea_ice_interface_state!,
4948
interface_fluxes,
5049
interface_temperature,
51-
net_top_heat_flux,
5250
grid,
5351
clock,
5452
flux_formulation,
@@ -65,7 +63,6 @@ end
6563
""" Compute turbulent fluxes between an atmosphere and a interface state using similarity theory """
6664
@kernel function _compute_atmosphere_sea_ice_interface_state!(interface_fluxes,
6765
interface_temperature,
68-
net_top_heat_flux,
6966
grid,
7067
clock,
7168
turbulent_flux_formulation,
@@ -151,13 +148,6 @@ end
151148
u★ = interface_state.u★
152149
θ★ = interface_state.θ★
153150
q★ = interface_state.q★
154-
155-
#=
156-
Pr = similarity_theory.turbulent_prandtl_number
157-
θ★ = θ★ / Pr
158-
q★ = q★ / Pr
159-
=#
160-
161151
Ψₛ = interface_state
162152
Ψₐ = local_atmosphere_state
163153
Δu, Δv = velocity_difference(turbulent_flux_formulation.bulk_velocity, Ψₐ, Ψₛ)
@@ -169,26 +159,18 @@ end
169159
cₚ = AtmosphericThermodynamics.cp_m(ℂₐ, 𝒬ₐ) # moist heat capacity
170160
ℰs = AtmosphericThermodynamics.latent_heat_sublim(ℂₐ, 𝒬ₐ)
171161

172-
σ = interface_properties.radiation.σ
173-
α = stateindex(interface_properties.radiation.α, i, j, 1, grid, time)
174-
ϵ = stateindex(interface_properties.radiation.ϵ, i, j, 1, grid, time)
175-
Qu = upwelling_radiation(Ψₛ.T, σ, ϵ)
176-
Qd = net_downwelling_radiation(downwelling_radiation, α, ϵ)
177-
178162
# Store fluxes
179163
Qv = interface_fluxes.latent_heat
180164
Qc = interface_fluxes.sensible_heat
181165
Fv = interface_fluxes.water_vapor
182166
ρτx = interface_fluxes.x_momentum
183167
ρτy = interface_fluxes.y_momentum
184168
Ts = interface_temperature
185-
ΣQ = net_top_heat_flux
186169

187170
@inbounds begin
188171
# +0: cooling, -0: heating
189-
Qv[i, j, 1] = _Qv = - ρₐ * u★ * q★ * ℰs
190-
Qc[i, j, 1] = _Qc = - ρₐ * cₚ * u★ * θ★
191-
ΣQ[i, j, 1] = Qu + Qd + _Qv + _Qc
172+
Qv[i, j, 1] = - ρₐ * u★ * q★ * ℰs
173+
Qc[i, j, 1] = - ρₐ * cₚ * u★ * θ★
192174
Fv[i, j, 1] = - ρₐ * u★ * q★
193175
ρτx[i, j, 1] = + ρₐ * τx
194176
ρτy[i, j, 1] = + ρₐ * τy

src/OceanSeaIceModels/InterfaceComputations/component_interfaces.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ using ClimaSeaIce: SeaIceModel
1717
using Oceananigans: HydrostaticFreeSurfaceModel, architecture
1818
using Oceananigans.Grids: inactive_node, node
1919
using Oceananigans.BoundaryConditions: fill_halo_regions!
20-
using Oceananigans.Fields: ConstantField, interpolate, FractionalIndices
21-
using Oceananigans.Utils: launch!, Time
2220

23-
# using Oceananigans.OutputReaders: extract_field_time_series, update_field_time_series!
21+
using Oceananigans.Fields: ConstantField, interpolate, FractionalIndices
22+
using Oceananigans.Utils: launch!, Time, KernelParameters
2423

2524
using Oceananigans.Operators: ℑxᶜᵃᵃ, ℑyᵃᶜᵃ, ℑxᶠᵃᵃ, ℑyᵃᶠᵃ
2625

@@ -179,17 +178,24 @@ end
179178

180179
sea_ice_ocean_interface(sea_ice, ocean) = nothing
181180

182-
function sea_ice_ocean_interface(sea_ice::SeaIceSimulation, ocean)
181+
function sea_ice_ocean_interface(sea_ice::SeaIceSimulation, ocean;
182+
characteristic_melting_speed = 1e-5)
183+
183184
previous_ice_thickness = deepcopy(sea_ice.model.ice_thickness)
184185
previous_ice_concentration = deepcopy(sea_ice.model.ice_concentration)
185-
io_heat_flux = sea_ice.model.external_heat_fluxes.bottom
186+
io_bottom_heat_flux = Field{Center, Center, Nothing}(ocean.model.grid)
187+
io_frazil_heat_flux = Field{Center, Center, Nothing}(ocean.model.grid)
186188
io_salt_flux = Field{Center, Center, Nothing}(ocean.model.grid)
187189

188-
@assert io_heat_flux isa Field{Center, Center, Nothing}
190+
@assert io_frazil_heat_flux isa Field{Center, Center, Nothing}
191+
@assert io_bottom_heat_flux isa Field{Center, Center, Nothing}
189192
@assert io_salt_flux isa Field{Center, Center, Nothing}
190193

191-
io_fluxes = (heat=io_heat_flux, salt=io_salt_flux)
192-
io_properties = nothing
194+
io_fluxes = (interface_heat=io_bottom_heat_flux,
195+
frazil_heat=io_frazil_heat_flux,
196+
salt=io_salt_flux)
197+
198+
io_properties = (; characteristic_melting_speed)
193199

194200
return SeaIceOceanInterface(io_fluxes,
195201
io_properties,

0 commit comments

Comments
 (0)