Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate sea ice in the flux computation #294

Open
wants to merge 109 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
3114f74
this works best?
simone-silvestri Nov 22, 2024
9101d57
One degree simulation take 4
simone-silvestri Nov 22, 2024
5833d19
add a biharmonic viscosity
simone-silvestri Nov 22, 2024
96a64a2
Merge branch 'main' into ss/one-degree-take3
navidcy Nov 23, 2024
0aa74dc
infer maximum delta t
simone-silvestri Nov 23, 2024
ea8708f
Merge branch 'ss/one-degree-take3' of github.com:CliMA/ClimaOcean.jl …
simone-silvestri Nov 23, 2024
3a77b67
Merge remote-tracking branch 'origin/main' into ss/one-degree-take3
simone-silvestri Nov 26, 2024
7c87f2b
changes
simone-silvestri Nov 26, 2024
3e3b77d
this sohuld work
simone-silvestri Nov 26, 2024
d7ac6fa
using CUDA
simone-silvestri Nov 26, 2024
9eaa668
tests NaN
simone-silvestri Nov 26, 2024
6d094b1
test pass
simone-silvestri Nov 26, 2024
51328c8
regression test pass!
simone-silvestri Nov 26, 2024
33f69ab
regression tests pass!
simone-silvestri Nov 26, 2024
d1a3caf
now it works
simone-silvestri Nov 26, 2024
1f54525
reverted to false?
simone-silvestri Nov 26, 2024
3513848
the complete thing
simone-silvestri Nov 26, 2024
f754f7e
chnage defaults
simone-silvestri Nov 26, 2024
e6d8829
switched a couple of variables
simone-silvestri Nov 26, 2024
4e8faea
remove comment
simone-silvestri Nov 26, 2024
af28e4e
done better
simone-silvestri Nov 26, 2024
9b32122
better
simone-silvestri Nov 26, 2024
d2f3fea
pass also gravity
simone-silvestri Nov 26, 2024
552fd53
change water vapor saturation
simone-silvestri Nov 27, 2024
03c2849
change nomenclature
simone-silvestri Nov 27, 2024
6022a6f
finish changing nomenclature
simone-silvestri Nov 27, 2024
c261e36
Update src/OceanSimulations/OceanSimulations.jl
simone-silvestri Nov 27, 2024
b479f79
correct temperature
simone-silvestri Nov 27, 2024
c22cb73
Merge branch 'ss/new-fluxes' of github.com:CliMA/ClimaOcean.jl into s…
simone-silvestri Nov 27, 2024
846fda5
try new one degree
simone-silvestri Nov 27, 2024
c20b865
export
simone-silvestri Nov 27, 2024
54226bf
rebuilding the steps
simone-silvestri Nov 27, 2024
6848c54
change names to the types
simone-silvestri Nov 28, 2024
ae1b6a2
add a comment
simone-silvestri Nov 28, 2024
a0140ff
revert unrelated files
simone-silvestri Nov 28, 2024
3ddb3ad
lets not regularize...
simone-silvestri Nov 28, 2024
5625be1
move to examples
simone-silvestri Nov 28, 2024
a327606
not in this PR
simone-silvestri Nov 28, 2024
1d169f7
convert to FT
simone-silvestri Nov 28, 2024
ab7b78b
another bugfix
simone-silvestri Dec 2, 2024
84ec37b
rearrange signature
simone-silvestri Dec 2, 2024
9313373
remove tyep instability
simone-silvestri Dec 2, 2024
542efa1
better syntax
simone-silvestri Dec 2, 2024
0030b9d
&& -> &
simone-silvestri Dec 2, 2024
60ad704
another bugfix
simone-silvestri Dec 2, 2024
13622fc
Merge branch 'main' into ss/new-fluxes
simone-silvestri Dec 2, 2024
c8db739
do not change OceanSimulations.jl here
simone-silvestri Dec 2, 2024
8616feb
added a test for SkinTemperature zero fluxes
simone-silvestri Dec 2, 2024
54dd6c1
import types
simone-silvestri Dec 2, 2024
fc8ddc0
fix tests
simone-silvestri Dec 2, 2024
99d38ca
start this work
simone-silvestri Dec 2, 2024
93426b0
Merge remote-tracking branch 'origin/main' into ss/integrate-sea-ice
simone-silvestri Dec 11, 2024
d4f29a7
just surface
simone-silvestri Dec 11, 2024
75e54fd
vestigial file
simone-silvestri Dec 11, 2024
fb9b022
correct a couple of things
simone-silvestri Dec 11, 2024
28ef213
add spaces
simone-silvestri Dec 11, 2024
b84f7d0
add sea ice fluxes
simone-silvestri Dec 11, 2024
0d016f6
add sea ice fluxes
simone-silvestri Dec 11, 2024
0d4c2c3
adapt tests
simone-silvestri Dec 11, 2024
fd6ecb4
using SeaIceModel
simone-silvestri Dec 11, 2024
91f95ea
forgot sea-ice concentration
simone-silvestri Dec 11, 2024
c58d1b2
adding correct methods
simone-silvestri Dec 11, 2024
af4458d
restructuring
simone-silvestri Dec 12, 2024
bd08f9a
start with the changes
simone-silvestri Dec 12, 2024
576a92c
more restructuring
simone-silvestri Dec 12, 2024
129e688
more restructuring
simone-silvestri Dec 12, 2024
a98543b
tests should pass
simone-silvestri Dec 12, 2024
efbf91e
Update to Oceananigans 0.95
glwagner Dec 13, 2024
b04d030
Bump to 0.2.5
glwagner Dec 13, 2024
f3ff24c
update orthogonalsphericalshellgrids
simone-silvestri Dec 13, 2024
e5a2290
Update Project.toml
simone-silvestri Dec 13, 2024
ea19e95
adapt to new syntax
simone-silvestri Dec 13, 2024
fa0b27b
correct the formulation
simone-silvestri Dec 13, 2024
ab0ae0e
Merge branch 'glw/up-oceananigans' of github.com:CliMA/ClimaOcean.jl …
simone-silvestri Dec 13, 2024
6e5507f
Merge branch 'glw/up-oceananigans' into ss/integrate-sea-ice
simone-silvestri Dec 13, 2024
f44afab
will it work?
simone-silvestri Dec 13, 2024
f9a3798
last one
simone-silvestri Dec 13, 2024
52895c2
Merge branch 'glw/up-oceananigans' into ss/integrate-sea-ice
simone-silvestri Dec 13, 2024
b1019b3
slogging along
simone-silvestri Dec 13, 2024
056abfa
more fixes
simone-silvestri Dec 13, 2024
6b4ad54
will this work?
simone-silvestri Dec 13, 2024
2b8464f
should run now
simone-silvestri Dec 13, 2024
9009737
ok now the tests pass
simone-silvestri Dec 13, 2024
fe97067
this should work again
simone-silvestri Dec 13, 2024
fe7d608
bugfix
simone-silvestri Dec 13, 2024
fe4e82f
more SeaIceSimulations
simone-silvestri Dec 13, 2024
d95f7ef
continuing
simone-silvestri Dec 15, 2024
d112e64
Merge remote-tracking branch 'origin/main' into ss/integrate-sea-ice
simone-silvestri Dec 15, 2024
4f64bfc
some tests
simone-silvestri Dec 15, 2024
c49a333
now tests should pass
simone-silvestri Dec 15, 2024
d535f41
now tests pass, let's figure out the sea ice fluxes
simone-silvestri Dec 15, 2024
48cc74c
add some sea ice
simone-silvestri Dec 15, 2024
a53645e
seems to run with sea-ice
simone-silvestri Dec 15, 2024
c6f8840
add the forcing
simone-silvestri Dec 15, 2024
e38bb4e
rework
simone-silvestri Dec 15, 2024
3483964
correct coefficients
simone-silvestri Dec 15, 2024
528d855
Get single column sea ice model working
glwagner Dec 20, 2024
32a48fc
Bump compat for ClimaSeaIce
glwagner Dec 20, 2024
c09f367
Update figure
glwagner Dec 20, 2024
0f6e6ce
Merge remote-tracking branch 'origin/main' into ss/integrate-sea-ice
glwagner Dec 20, 2024
aca55ab
Delete mwe
glwagner Dec 20, 2024
8347f80
Merge remote-tracking branch 'origin/main' into ss/integrate-sea-ice
simone-silvestri Dec 23, 2024
dccc0fe
couple of fixes
simone-silvestri Dec 23, 2024
3338d06
it runs
simone-silvestri Dec 23, 2024
d9a5d6f
start with some thickness
simone-silvestri Dec 23, 2024
06e3e22
seems to work. Now we need to compute atmosphere-seaice fluxes
simone-silvestri Dec 23, 2024
7dee2be
Working on thermodynamic coupling
glwagner Jan 6, 2025
4fb1c50
Merge branch 'ss/integrate-sea-ice' of https://github.com/CliMA/Clima…
glwagner Jan 6, 2025
e1d0066
Merge remote-tracking branch 'origin/main' into ss/integrate-sea-ice
glwagner Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "ClimaOcean"
uuid = "0376089a-ecfe-4b0e-a64f-9c555d74d754"
license = "MIT"
authors = ["Climate Modeling Alliance and contributors"]
version = "0.3.2"
version = "0.4.0"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down Expand Up @@ -33,7 +33,7 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
Adapt = "4"
CFTime = "0.1"
CUDA = "4, 5"
ClimaSeaIce = "0.1.3"
ClimaSeaIce = "0.1.6"
CubicSplines = "0.2"
DataDeps = "0.7"
Downloads = "1.6"
Expand All @@ -42,7 +42,7 @@ JLD2 = "0.4, 0.5"
KernelAbstractions = "0.9"
MPI = "0.20"
NCDatasets = "0.12, 0.13, 0.14"
Oceananigans = "0.95.4 - 0.99"
Oceananigans = "0.95.5 - 0.99"
OffsetArrays = "1.14"
OrthogonalSphericalShellGrids = "0.2.1"
Scratch = "1"
Expand Down
93 changes: 64 additions & 29 deletions examples/idealized_single_column_simulation.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
using ClimaOcean
using ClimaSeaIce
using Oceananigans
using Oceananigans.Units
using SeawaterPolynomials

# Ocean state parameters
T₀ = 20 # Surface temperature, ᵒC
T₀ = 2 # Surface temperature, ᵒC
S₀ = 35 # Surface salinity
N² = 1e-4 # Buoyancy gradient due to temperature stratification
f = 0 # Coriolis parameter

# Atmospheric state parameters
Tₐ = 273.15 + 20 # Kelvin
Tₐ = 273.15 - 10 # Kelvin
u₁₀ = 10 # wind at 10 m, m/s
qₐ = 0.01 # specific humidity
Qℓ = 400 # shortwave radiation (W m⁻², positive means heating right now)

# Build the atmosphere
radiation = Radiation(ocean_albedo=0.1)
atmosphere_grid = RectilinearGrid(size=(), topology=(Flat, Flat, Flat))
atmosphere_times = range(0, 1day, length=3)
atmosphere = PrescribedAtmosphere(atmosphere_grid, atmosphere_times)
Expand All @@ -29,26 +31,52 @@ parent(atmosphere.downwelling_radiation.shortwave) .= Qℓ # W
grid = RectilinearGrid(size=100, z=(-400, 0), topology=(Flat, Flat, Bounded))
ocean = ocean_simulation(grid, coriolis=FPlane(; f))

eos = ocean.model.buoyancy.model.equation_of_state
g = ocean.model.buoyancy.model.gravitational_acceleration
eos = ocean.model.buoyancy.formulation.equation_of_state
g = ocean.model.buoyancy.formulation.gravitational_acceleration
α = SeawaterPolynomials.thermal_expansion(T₀, S₀, 0, eos)
dTdz = N² / (α * g)
Tᵢ(z) = T₀ + dTdz * z
set!(ocean.model, T=Tᵢ, S=S₀)

radiation = Radiation(ocean_albedo=0.1)
model = OceanSeaIceModel(ocean; atmosphere, radiation)
simulation = Simulation(model, Δt=5minutes, stop_time=30days)

Q = model.fluxes.total.ocean.heat
Ql = model.fluxes.turbulent.fields.latent_heat
Qs = model.fluxes.turbulent.fields.sensible_heat
τx = model.fluxes.turbulent.fields.x_momentum
τy = model.fluxes.turbulent.fields.y_momentum
Fv = model.fluxes.turbulent.fields.water_vapor

fluxes = (; Q, Ql, Qs, τx, τy, Fv)
outputs = merge(ocean.model.velocities, ocean.model.tracers, fluxes)
sea_ice_grid = RectilinearGrid(size=(), topology=(Flat, Flat, Flat))
top_sea_ice_temperature = Field{Center, Center, Nothing}(sea_ice_grid)
top_heat_boundary_condition = PrescribedTemperature(top_sea_ice_temperature)
ice_thermodynamics = SlabSeaIceThermodynamics(sea_ice_grid; top_heat_boundary_condition)

top_sea_ice_heat_flux = Field{Center, Center, Nothing}(sea_ice_grid)
bottom_sea_ice_heat_flux = Field{Center, Center, Nothing}(sea_ice_grid)

sea_ice_model = SeaIceModel(sea_ice_grid;
top_heat_flux = top_sea_ice_heat_flux,
bottom_heat_flux = bottom_sea_ice_heat_flux,
ice_thermodynamics)

set!(sea_ice_model.ice_concentration, 1.0)
set!(sea_ice_model.ice_thickness, 1.0)

sea_ice = Simulation(sea_ice_model, Δt=10minutes)

model = OceanSeaIceModel(ocean, sea_ice; atmosphere, radiation)
simulation = Simulation(model, Δt=10minutes, stop_time=10days)

Ql = model.fluxes.turbulent.fields.ocean.latent_heat
Qs = model.fluxes.turbulent.fields.ocean.sensible_heat
τx = model.fluxes.turbulent.fields.ocean.x_momentum
τy = model.fluxes.turbulent.fields.ocean.y_momentum
Fv = model.fluxes.turbulent.fields.ocean.water_vapor
Qib = sea_ice_model.external_heat_fluxes.bottom

# TODO: the total fluxes are defined on _interfaces_ between components:
# atmopshere_ocean, atmosphere_sea_ice, ocean_sea_ice. They aren't defined wrt to
# just one component
Qo = model.fluxes.total.ocean.heat
Qi = model.fluxes.total.sea_ice.heat

fluxes = (; Qo, Qi, Qib, Ql, Qs, τx, τy, Fv)
ocean_outputs = merge(ocean.model.velocities, ocean.model.tracers)
sea_ice_outputs = (; h=sea_ice.model.ice_thickness)
outputs = merge(ocean_outputs, sea_ice_outputs, fluxes)

ow = JLD2OutputWriter(ocean.model, outputs,
schedule = TimeInterval(1hour),
filename = "idealized_atmosphere.jld2",
Expand All @@ -58,25 +86,28 @@ simulation.output_writers[:ow] = ow

run!(simulation)

ut = FieldTimeSeries("idealized_atmosphere.jld2", "u")
vt = FieldTimeSeries("idealized_atmosphere.jld2", "v")
Tt = FieldTimeSeries("idealized_atmosphere.jld2", "T")
St = FieldTimeSeries("idealized_atmosphere.jld2", "S")
τx = FieldTimeSeries("idealized_atmosphere.jld2", "τx")
Q = FieldTimeSeries("idealized_atmosphere.jld2", "Q")
Nt = length(St)
ut = FieldTimeSeries("idealized_atmosphere.jld2", "u")
vt = FieldTimeSeries("idealized_atmosphere.jld2", "v")
Tt = FieldTimeSeries("idealized_atmosphere.jld2", "T")
St = FieldTimeSeries("idealized_atmosphere.jld2", "S")
τx = FieldTimeSeries("idealized_atmosphere.jld2", "τx")
Qo = FieldTimeSeries("idealized_atmosphere.jld2", "Qo")
Qib = FieldTimeSeries("idealized_atmosphere.jld2", "Qib")
h = FieldTimeSeries("idealized_atmosphere.jld2", "h")
Nt = length(St)

using GLMakie

fig = Figure(size=(1000, 800))

axτ = Axis(fig[1, 1:3], xlabel="Time (days)", ylabel="Zonal momentum \n flux (N m⁻²)", xaxisposition=:top)
axQ = Axis(fig[2, 1:3], xlabel="Time (days)", ylabel="Heat flux \n (W m⁻²)")
axT = Axis(fig[3, 1], xlabel="Temperature (ᵒC)", ylabel="z (m)")
axS = Axis(fig[3, 2], xlabel="Salinity (g kg⁻¹)", ylabel="z (m)")
axu = Axis(fig[3, 3], xlabel="Velocities (m s⁻¹)", ylabel="z (m)", yaxisposition=:right)
axh = Axis(fig[3, 1:3], xlabel="Time (days)", ylabel="Sea ice thickness \n (m)")
axT = Axis(fig[4, 1], xlabel="Temperature (ᵒC)", ylabel="z (m)")
axS = Axis(fig[4, 2], xlabel="Salinity (g kg⁻¹)", ylabel="z (m)")
axu = Axis(fig[4, 3], xlabel="Velocities (m s⁻¹)", ylabel="z (m)", yaxisposition=:right)

slider = Slider(fig[4, 1:3], startvalue=1, range=1:Nt)
slider = Slider(fig[5, 1:3], startvalue=1, range=1:Nt)
n = slider.value

un = @lift ut[$n]
Expand All @@ -96,11 +127,15 @@ tn = @lift t[$n]
lines!(axτ, t, τx[:], label="τx")
vlines!(axτ, tn)

lines!(axQ, t, Q[:])
lines!(axQ, t, Qo[:])
vlines!(axQ, tn)

lines!(axh, t, h[:])
vlines!(axh, tn)

rowsize!(fig.layout, 1, Relative(0.2))
rowsize!(fig.layout, 2, Relative(0.2))
rowsize!(fig.layout, 3, Relative(0.2))

xlims!(axS, 34.9, 35.1)
xlims!(axu, -0.1, 4.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using Oceananigans.Units
using ClimaOcean
using ClimaOcean.OceanSimulations
using ClimaOcean.OceanSeaIceModels
using ClimaOcean.OceanSeaIceModels.CrossRealmFluxes: Radiation, SimilarityTheoryTurbulentFluxes
using ClimaOcean.OceanSeaIceModels.CrossRealmFluxes: Radiation, SimilarityTheoryFluxes
using ClimaOcean.VerticalGrids: exponential_z_faces
using ClimaOcean.JRA55
using ClimaOcean.ECCO
Expand Down
27 changes: 20 additions & 7 deletions experiments/one_degree_simulation/one_degree_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bottom_height = regrid_bathymetry(underlying_grid;
tampered_bottom_height = deepcopy(bottom_height)
view(tampered_bottom_height, 102:103, 124, 1) .= -400

grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(tampered_bottom_height))
grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(tampered_bottom_height); active_cells_map=true)

#####
##### Closures
Expand Down Expand Up @@ -75,14 +75,24 @@ forcing = (T=FT, S=FS)
momentum_advection = VectorInvariant()
tracer_advection = Centered(order=2)

free_surface = SplitExplicitFreeSurface(grid; substeps=30)

# Should we add a side drag since this is at a coarser resolution?
ocean = ocean_simulation(grid; momentum_advection, tracer_advection,
closure, forcing,
tracers = (:T, :S, :e))
free_surface, forcing)

set!(ocean.model, T=ECCOMetadata(:temperature; dates=first(dates)),
S=ECCOMetadata(:salinity; dates=first(dates)))

#####
##### Sea ice simulation
#####

sea_ice = sea_ice_simulation(grid)

set!(sea_ice.model.ice_thickness, ECCOMetadata(:sea_ice_thickness; dates=first(dates)); inpainting=NearestNeighborInpainting(0))
set!(sea_ice.model.ice_concentration, ECCOMetadata(:sea_ice_concentration; dates=first(dates)); inpainting=NearestNeighborInpainting(0))

#####
##### Atmospheric forcing
#####
Expand All @@ -94,8 +104,8 @@ atmosphere = JRA55PrescribedAtmosphere(arch; backend=JRA55NetCDFBackend(20))
##### Coupled simulation
#####

coupled_model = OceanSeaIceModel(ocean; atmosphere, radiation)
simulation = Simulation(coupled_model; Δt=15minutes, stop_time=2*365days)
coupled_model = OceanSeaIceModel(ocean, sea_ice; atmosphere, radiation)
simulation = Simulation(coupled_model; Δt=1minutes, stop_time=2*365days)

#####
##### Run it!
Expand All @@ -105,19 +115,22 @@ wall_time = Ref(time_ns())

function progress(sim)
ocean = sim.model.ocean
sea_ice = sim.model.sea_ice
u, v, w = ocean.model.velocities
T = ocean.model.tracers.T
h = sea_ice.model.ice_thickness
Tmax = maximum(interior(T))
Tmin = minimum(interior(T))
hmax = maximum(interior(h))
umax = (maximum(abs, interior(u)),
maximum(abs, interior(v)),
maximum(abs, interior(w)))

step_time = 1e-9 * (time_ns() - wall_time[])

@info @sprintf("Time: %s, n: %d, Δt: %s, max|u|: (%.2e, %.2e, %.2e) m s⁻¹, extrema(T): (%.2f, %.2f) ᵒC, wall time: %s \n",
@info @sprintf("Time: %s, n: %d, Δt: %s, max|u|: (%.2e, %.2e, %.2e) m s⁻¹, extrema(T): (%.2f, %.2f) ᵒC, max(h): %.2f m, wall time: %s \n",
prettytime(sim), iteration(sim), prettytime(sim.Δt),
umax..., Tmax, Tmin, prettytime(step_time))
umax..., Tmax, Tmin, hmax, prettytime(step_time))

wall_time[] = time_ns()

Expand Down
Loading
Loading