From 13cad9065fa0d30b9f056b1c705a8320f903a041 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 6 May 2025 12:45:20 +0200 Subject: [PATCH 1/9] adapt to b-grid dynamics --- .../InterfaceComputations/assemble_net_fluxes.jl | 4 ++-- .../InterfaceComputations/sea_ice_ocean_fluxes.jl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl index 5542794ef..ccc80c91f 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl @@ -250,7 +250,7 @@ end inactive = inactive_node(i, j, kᴺ, grid, c, c, c) @inbounds top_fluxes.heat[i, j, 1] = ifelse(inactive, zero(grid), ΣQt) - @inbounds top_fluxes.u[i, j, 1] = ifelse(inactive, zero(grid), ℑxᶠᵃᵃ(i, j, 1, grid, ρτx)) - @inbounds top_fluxes.v[i, j, 1] = ifelse(inactive, zero(grid), ℑyᵃᶠᵃ(i, j, 1, grid, ρτy)) + @inbounds top_fluxes.u[i, j, 1] = ifelse(inactive, zero(grid), ℑxyᶠᶠᵃ(i, j, 1, grid, ρτx)) + @inbounds top_fluxes.v[i, j, 1] = ifelse(inactive, zero(grid), ℑxyᶠᶠᵃ(i, j, 1, grid, ρτy)) @inbounds bottom_heat_flux[i, j, 1] = ifelse(inactive, zero(grid), ΣQb) end diff --git a/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl index 29d00eee6..2b3adf492 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl @@ -148,7 +148,7 @@ end h⁻[i, j, 1] = hᵢ[i, j, 1] # Momentum stresses - τx[i, j, 1] = x_momentum_stress(i, j, Nz, grid, τₒᵢ, clock, sea_ice_fields) - τy[i, j, 1] = y_momentum_stress(i, j, Nz, grid, τₒᵢ, clock, sea_ice_fields) + τx[i, j, 1] = ℑxᶜᵃᵃ(i, j, Nz, grid, x_momentum_stress, τₒᵢ, clock, sea_ice_fields) + τy[i, j, 1] = ℑyᵃᶜᵃ(i, j, Nz, grid, y_momentum_stress, τₒᵢ, clock, sea_ice_fields) end end From 6645847356302cbcf754b56e73b873c7017f623f Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 14 May 2025 11:00:42 +0200 Subject: [PATCH 2/9] commit --- .../InterfaceComputations/assemble_net_fluxes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl index 27ca3f5b2..0e9cae693 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl @@ -1,5 +1,5 @@ using Printf -using Oceananigans.Operators: ℑxᶠᵃᵃ, ℑyᵃᶠᵃ +using Oceananigans.Operators: ℑxᶠᵃᵃ, ℑyᵃᶠᵃ, ℑxyᶠᶠᵃ using Oceananigans.Forcings: MultipleForcings using ClimaOcean.OceanSeaIceModels: sea_ice_concentration From 46d8dbba7e3930395c81034e84bc0a48c6db83cc Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 14 May 2025 11:09:08 +0200 Subject: [PATCH 3/9] correction --- .../InterfaceComputations/assemble_net_fluxes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl index 0e9cae693..abce62200 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl @@ -282,7 +282,7 @@ end Qs = transmitted_shortwave_radiation(i, j, kᴺ, grid, time, α, Qs) Qℓ = absorbed_longwave_radiation(i, j, kᴺ, grid, time, ϵ, Qℓ) - ΣQt = (Qs + Qℓ + Qu + Qc + Qv) * ℵi # If ℵi == 0 there is no heat flux from the top! + ΣQt = (Qs + Qℓ + Qu + Qc + Qv) * (ℵi > 0) # If ℵi == 0 there is no heat flux from the top! ΣQb = Qf + Qi # Mask fluxes over land for convenience From b6ba841656b9de5c929a19209cffa53b70f307dd Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 28 Jul 2025 10:33:18 +0200 Subject: [PATCH 4/9] try it out --- .../InterfaceComputations/atmosphere_sea_ice_fluxes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl index d12ae69b3..f916235c2 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl @@ -94,8 +94,8 @@ end Sᵢ = interior_state.Sₒ[i, j, kᴺ] # Sea ice properties - uᵢ = zero(FT) # ℑxᶜᵃᵃ(i, j, 1, grid, interior_state.u) - vᵢ = zero(FT) # ℑyᵃᶜᵃ(i, j, 1, grid, interior_state.v) + uᵢ = ℑxyᶜᶜᵃ(i, j, 1, grid, interior_state.u) + vᵢ = ℑxyᶜᶜᵃ(i, j, 1, grid, interior_state.v) hᵢ = interior_state.h[i, j, 1] ℵᵢ = interior_state.ℵ[i, j, 1] Tₛ = interface_temperature[i, j, 1] From 050fe41faea1d769c69e5a98a28925686a35d1e1 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 28 Jul 2025 11:48:17 +0200 Subject: [PATCH 5/9] use correct branch --- .buildkite/examples_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/examples_build.yml b/.buildkite/examples_build.yml index 66d2197e3..1ef478092 100644 --- a/.buildkite/examples_build.yml +++ b/.buildkite/examples_build.yml @@ -18,7 +18,7 @@ steps: TMPDIR: "$TARTARUS_HOME/tmp" command: - "echo '--- Instantiate project'" - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes -O0 --project -e 'using Pkg; Pkg.instantiate(; verbose=true); Pkg.precompile(; strict=true)'" + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes -O0 --project -e 'using Pkg; Pkg.add(url=\"https://github.com/CliMA/ClimaSeaIce.jl\", rev=\"ss/b-grid-dynamics\"); Pkg.instantiate(; verbose=true); Pkg.precompile(; strict=true)'" # force the initialization of the CUDA runtime as it is lazily loaded by default - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes -O0 --project -e 'using CUDA; CUDA.precompile_runtime()'" agents: From a375e05bf18ed9bdaed4985dd7a7c87ddcc33b93 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 28 Jul 2025 11:49:04 +0200 Subject: [PATCH 6/9] Update sea_ice_ocean_fluxes.jl --- .../InterfaceComputations/sea_ice_ocean_fluxes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl index 27e449d45..ca93bcc7b 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl @@ -141,7 +141,7 @@ end Jˢ[i, j, 1] = thermodynamic_tendency[i, j, 1] * (Sᵢ[i, j, 1] - Sₒ[i, j, Nz]) # Momentum stresses - τx[i, j, 1] = ℑxᶜᵃᵃ(i, j, Nz, grid, x_momentum_stress, τₒᵢ, clock, sea_ice_fields) - τy[i, j, 1] = ℑyᵃᶜᵃ(i, j, Nz, grid, y_momentum_stress, τₒᵢ, clock, sea_ice_fields) + τx[i, j, 1] = ℑyᵃᶜᵃ(i, j, Nz, grid, x_momentum_stress, τₒᵢ, clock, sea_ice_fields) + τy[i, j, 1] = ℑxᶜᵃᵃ(i, j, Nz, grid, y_momentum_stress, τₒᵢ, clock, sea_ice_fields) end end From 017054572cb51e619aeac9f830d22e63b52d63ba Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 28 Jul 2025 11:54:13 +0200 Subject: [PATCH 7/9] use correct location --- .../InterfaceComputations/assemble_net_fluxes.jl | 4 ++-- src/SeaIceSimulations.jl | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl index abce62200..9b4e4d474 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/assemble_net_fluxes.jl @@ -176,8 +176,8 @@ end τxao = ℑxᶠᵃᵃ(i, j, 1, grid, τᶜᶜᶜ, ρₒ⁻¹, ℵ, ρτxao) τyao = ℑyᵃᶠᵃ(i, j, 1, grid, τᶜᶜᶜ, ρₒ⁻¹, ℵ, ρτyao) - τxio = ρτxio[i, j, 1] * ρₒ⁻¹ * ℑxᶠᵃᵃ(i, j, 1, grid, ℵ) - τyio = ρτyio[i, j, 1] * ρₒ⁻¹ * ℑyᵃᶠᵃ(i, j, 1, grid, ℵ) + τxio = ℑyᵃᶜᵃ(i, j, 1, grid, ρτxio) * ρₒ⁻¹ * ℑxᶠᵃᵃ(i, j, 1, grid, ℵ) + τyio = ℑxᶜᵃᵃ(i, j, 1, grid, ρτyio) * ρₒ⁻¹ * ℑyᵃᶠᵃ(i, j, 1, grid, ℵ) # Stresses τx[i, j, 1] = τxao + τxio diff --git a/src/SeaIceSimulations.jl b/src/SeaIceSimulations.jl index 41aaf9cda..f00e5f70e 100644 --- a/src/SeaIceSimulations.jl +++ b/src/SeaIceSimulations.jl @@ -92,8 +92,8 @@ function sea_ice_dynamics(grid, ocean=nothing; SSU = Oceananigans.Fields.ZeroField() SSV = Oceananigans.Fields.ZeroField() else - SSU = view(ocean.model.velocities.u, :, :, grid.Nz) - SSV = view(ocean.model.velocities.v, :, :, grid.Nz) + SSU = Field(@at((Face, Face, Nothing), view(ocean.model.velocities.u, :, :, grid.Nz))) + SSV = Field(@at((Face, Face, Nothing), view(ocean.model.velocities.v, :, :, grid.Nz))) if isnothing(coriolis) coriolis = ocean.model.coriolis end @@ -102,8 +102,8 @@ function sea_ice_dynamics(grid, ocean=nothing; sea_ice_ocean_drag_coefficient = convert(eltype(grid), sea_ice_ocean_drag_coefficient) τo = SemiImplicitStress(uₑ=SSU, vₑ=SSV, Cᴰ=sea_ice_ocean_drag_coefficient) - τua = Field{Face, Center, Nothing}(grid) - τva = Field{Center, Face, Nothing}(grid) + τua = Field{Face, Face, Nothing}(grid) + τva = Field{Face, Face, Nothing}(grid) if isnothing(free_drift) free_drift = StressBalanceFreeDrift((u=τua, v=τva), τo) From 14a59329eabfe2d28afdb182c4722a529d86c751 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 28 Jul 2025 17:20:45 +0200 Subject: [PATCH 8/9] add this --- .../InterfaceComputations/atmosphere_sea_ice_fluxes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl b/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl index f916235c2..92b7ae39c 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl @@ -1,4 +1,4 @@ -using Oceananigans.Operators: intrinsic_vector +using Oceananigans.Operators: intrinsic_vector, ℑxyᶜᶜᵃ using Oceananigans.Grids: inactive_node using Oceananigans.Fields: ZeroField From 7c138394cea2a43fa5e9fe6d722f8e87b8aeaacb Mon Sep 17 00:00:00 2001 From: simone-silvestri Date: Mon, 25 Aug 2025 03:45:56 -0400 Subject: [PATCH 9/9] update --- .../InterfaceComputations/roughness_lengths.jl | 12 +++++++----- src/SeaIceSimulations.jl | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/OceanSeaIceModels/InterfaceComputations/roughness_lengths.jl b/src/OceanSeaIceModels/InterfaceComputations/roughness_lengths.jl index 62845744a..d7ca790a2 100644 --- a/src/OceanSeaIceModels/InterfaceComputations/roughness_lengths.jl +++ b/src/OceanSeaIceModels/InterfaceComputations/roughness_lengths.jl @@ -20,23 +20,25 @@ Base.show(io::IO, ::ScalarRoughnessLength{FT}) where FT = print(io, "ScalarRough struct WindDependentWaveFormulation{FT} Umax :: FT + αmin :: FT ℂ₁ :: FT ℂ₂ :: FT end """ WindDependentWaveFormulation(FT = Oceananigans.defaults.FloatType; - Umax = 19, ℂ₁ = 0.0017, ℂ₂ = -0.005) + Umax = 19, αmin = 0.011, ℂ₁ = 0.0017, ℂ₂ = -0.005) -A gravity wave parameter based on the wind speed `ΔU` with the formula `ℂ₁ * max(ΔU, Umax) + ℂ₂`. +A gravity wave parameter based on the wind speed `ΔU` with the formula `max(αmin, ℂ₁ * min(ΔU, Umax) + ℂ₂`). """ -WindDependentWaveFormulation(FT=Oceananigans.defaults.FloatType; Umax = 19, ℂ₁ = 0.0017, ℂ₂ = -0.005) = +WindDependentWaveFormulation(FT=Oceananigans.defaults.FloatType; Umax = 19, αmin = 0.011, ℂ₁ = 0.0017, ℂ₂ = -0.005) = WindDependentWaveFormulation(convert(FT, Umax), + convert(FT, αmin), convert(FT, ℂ₁), convert(FT, ℂ₂)) gravity_wave_parameter(α::Number, args...) = α -gravity_wave_parameter(α::WindDependentWaveFormulation, ΔU) = α.ℂ₁ * max(ΔU, α.Umax) + α.ℂ₂ +gravity_wave_parameter(α::WindDependentWaveFormulation, ΔU) = max(α.αmin, α.ℂ₁ * min(ΔU, α.Umax) + α.ℂ₂) """ ScalarRoughnessLength(FT = Float64; @@ -88,7 +90,7 @@ function MomentumRoughnessLength(FT=Oceananigans.defaults.FloatType; gravitational_acceleration = default_gravitational_acceleration, maximum_roughness_length = 1, air_kinematic_viscosity = 1.5e-5, - wave_formulation = 0.02, + wave_formulation = WindDependentWaveFormulation(FT), smooth_wall_parameter = 0.11) if wave_formulation isa Number diff --git a/src/SeaIceSimulations.jl b/src/SeaIceSimulations.jl index f00e5f70e..3228557a7 100644 --- a/src/SeaIceSimulations.jl +++ b/src/SeaIceSimulations.jl @@ -92,8 +92,8 @@ function sea_ice_dynamics(grid, ocean=nothing; SSU = Oceananigans.Fields.ZeroField() SSV = Oceananigans.Fields.ZeroField() else - SSU = Field(@at((Face, Face, Nothing), view(ocean.model.velocities.u, :, :, grid.Nz))) - SSV = Field(@at((Face, Face, Nothing), view(ocean.model.velocities.v, :, :, grid.Nz))) + SSU = view(ocean.model.velocities.u, :, :, grid.Nz) + SSV = view(ocean.model.velocities.v, :, :, grid.Nz) if isnothing(coriolis) coriolis = ocean.model.coriolis end