-
Notifications
You must be signed in to change notification settings - Fork 18
OMIP prototype #456
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
base: main
Are you sure you want to change the base?
OMIP prototype #456
Changes from all commits
ae5f0be
42be4e9
1dab6e2
9d11295
27ebee4
7f4af88
8d9401e
a7a3268
f8e7fe7
6deb3b8
fdef030
f4d63a1
a130e73
c90b7f9
08b377f
2eb5556
ba4bce0
68dfdb0
f212e88
1a68d4e
c318e54
79b5935
91e1169
b6fb198
e81bdfb
afbd1cc
8599314
bb24633
4f05dbb
fe6dc72
787ebc9
7c519a1
78a53cd
1e71d67
4f7fdb2
58662d2
22c8d08
79f37eb
a98669f
5405ef3
b2ff520
992b4d7
e65b0ea
e7a0039
40a9f24
58d5c11
4fc2394
385a44a
54e5838
925981d
62c2f46
fb35d78
65ca9ba
18504c5
f35345c
97c91fd
182cbfb
a23c423
f42a187
0a6dd9f
790b5e6
1649353
739bc46
6ef9d7c
58c38c7
4e53f82
29d15c8
418fa99
f8cd74b
4761081
93c6b6f
0293afd
cffb7e1
1febc0e
ce7cbd3
fbfe5ce
46940e7
473dbd7
3ccc9f7
a35bf04
68b3ff3
5f53219
9209bbf
62b4629
4d963ea
52c91d9
1ee41af
1d58772
0c020d0
bafe3c7
350b657
4a49b40
fea1854
4441567
7c4aa61
24f7d93
d231995
ca1980c
f448eeb
fed209b
aeedd2f
f954c69
ddee7f0
daeb12f
629d582
54165a0
35fe01d
5548a99
dfb8590
a049dc1
d1e6faf
7186256
a6d758d
0b8624e
f18a772
6679bbd
50a7226
7975dd4
77e440b
5e3c729
b05fb83
501b3fa
f258e29
5751899
af67adc
d008026
83f97e9
03e7f19
1e02dd9
1eedc44
202212c
efa566c
0c8d8b1
0f04d0f
e28b9a4
0e1d4ca
2eeed4c
b27ac12
4d09283
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using ClimaOcean | ||
using ClimaOcean.JRA55 | ||
using ClimaOcean.DataWrangling: download_dataset | ||
|
||
atmosphere = JRA55PrescribedAtmosphere(; dir="forcing_data/", | ||
dataset=JRA55MultipleYears(), | ||
backend=JRA55NetCDFBackend(10), | ||
include_rivers_and_icebergs=true) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
using ClimaOcean | ||
using ClimaSeaIce | ||
using Oceananigans | ||
using Oceananigans.Grids | ||
using Oceananigans.Units | ||
using Oceananigans.OrthogonalSphericalShellGrids | ||
using ClimaOcean.OceanSimulations | ||
using ClimaOcean.ECCO | ||
using ClimaOcean.JRA55 | ||
using ClimaOcean.DataWrangling | ||
using ClimaSeaIce.SeaIceThermodynamics: IceWaterThermalEquilibrium | ||
using Printf | ||
using Dates | ||
using CUDA | ||
|
||
import Oceananigans.OutputWriters: checkpointer_address | ||
|
||
function synch!(clock1::Clock, clock2) | ||
# Synchronize the clocks | ||
clock1.time = clock2.time | ||
clock1.iteration = clock2.iteration | ||
clock1.last_Δt = clock2.last_Δt | ||
end | ||
|
||
synch!(model1, model2) = synch!(model1.clock, model2.clock) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you need this please put it in a separate PR and get that merged, because people want to use stuff |
||
|
||
arch = GPU() | ||
r_faces = ClimaOcean.exponential_z_faces(; Nz=60, depth=6200) | ||
z_faces = MutableVerticalDiscretization(r_faces) | ||
|
||
Nx = 2160 # longitudinal direction | ||
Ny = 1080 # meridional direction | ||
Nz = length(r_faces) - 1 | ||
|
||
grid = TripolarGrid(arch; | ||
size = (Nx, Ny, Nz), | ||
z = z_faces, | ||
halo = (7, 7, 7)) | ||
|
||
bottom_height = regrid_bathymetry(grid; minimum_depth=15, major_basins=1) | ||
grid = ImmersedBoundaryGrid(grid, GridFittedBottom(bottom_height); active_cells_map=true) | ||
|
||
##### | ||
##### A Propgnostic Ocean model | ||
##### | ||
|
||
using Oceananigans.TurbulenceClosures: ExplicitTimeDiscretization | ||
using Oceananigans.TurbulenceClosures.TKEBasedVerticalDiffusivities: CATKEVerticalDiffusivity, CATKEMixingLength, CATKEEquation | ||
|
||
momentum_advection = WENOVectorInvariant() | ||
tracer_advection = WENO(order=7) | ||
|
||
free_surface = SplitExplicitFreeSurface(grid; substeps=70) | ||
|
||
mixing_length = CATKEMixingLength(Cᵇ=0.01) | ||
turbulent_kinetic_energy_equation = CATKEEquation(Cᵂϵ=1.0) | ||
|
||
catke_closure = CATKEVerticalDiffusivity(ExplicitTimeDiscretization(); mixing_length, turbulent_kinetic_energy_equation) | ||
closure = (catke_closure, VerticalScalarDiffusivity(κ=1e-5, ν=1e-5)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @simone-silvestri, why change CATKE defaults? |
||
|
||
ocean = ocean_simulation(grid; Δt=1minutes, | ||
momentum_advection, | ||
tracer_advection, | ||
free_surface, | ||
closure) | ||
|
||
dataset = ECCO4Monthly() | ||
|
||
set!(ocean.model, T=Metadatum(:temperature; dataset), | ||
S=Metadatum(:salinity; dataset)) | ||
|
||
##### | ||
##### A Prognostic Sea-ice model | ||
##### | ||
|
||
# Remember to pass the SSS as a bottom bc to the sea ice! | ||
SSS = view(ocean.model.tracers.S.data, :, :, grid.Nz) | ||
bottom_heat_boundary_condition = IceWaterThermalEquilibrium(SSS) | ||
|
||
# Default sea-ice dynamics | ||
sea_ice_dynamics = ClimaOcean.SeaIceSimulations.default_sea_ice_dynamics(grid; ocean) | ||
|
||
sea_ice = sea_ice_simulation(grid; bottom_heat_boundary_condition, | ||
dynamics = sea_ice_dynamics, | ||
advection=WENO(order=7)) | ||
|
||
set!(sea_ice.model, h=Metadatum(:sea_ice_thickness; dataset), | ||
ℵ=Metadatum(:sea_ice_concentration; dataset)) | ||
|
||
##### | ||
##### A Prescribed Atmosphere model | ||
##### | ||
|
||
dir = "./forcing_data" | ||
dataset = MultiYearJRA55() | ||
backend = JRA55NetCDFBackend(40) | ||
|
||
atmosphere = JRA55PrescribedAtmosphere(arch; dir, dataset, backend, include_rivers_and_icebergs=true) | ||
radiation = Radiation() | ||
|
||
##### | ||
##### An ocean-sea ice coupled model | ||
##### | ||
|
||
omip = OceanSeaIceModel(ocean, sea_ice; atmosphere, radiation) | ||
omip = Simulation(omip, Δt=20, stop_time=60days) | ||
|
||
# Figure out the outputs.... | ||
|
||
checkpointer_address(::SeaIceModel) = "SeaIceModel" | ||
|
||
ocean.output_writers[:checkpointer] = Checkpointer(ocean.model, | ||
schedule = IterationInterval(10000), | ||
prefix = "ocean_checkpoint", | ||
overwrite_existing = true) | ||
|
||
sea_ice.output_writers[:checkpointer] = Checkpointer(sea_ice.model, | ||
schedule = IterationInterval(10000), | ||
prefix = "sea_ice_checkpoint", | ||
overwrite_existing = true) | ||
|
||
wall_time = Ref(time_ns()) | ||
|
||
using Statistics | ||
|
||
function progress(sim) | ||
sea_ice = sim.model.sea_ice | ||
ocean = sim.model.ocean | ||
hmax = maximum(sea_ice.model.ice_thickness) | ||
ℵmax = maximum(sea_ice.model.ice_concentration) | ||
Tmax = maximum(sim.model.interfaces.atmosphere_sea_ice_interface.temperature) | ||
Tmin = minimum(sim.model.interfaces.atmosphere_sea_ice_interface.temperature) | ||
umax = maximum(ocean.model.velocities.u) | ||
vmax = maximum(ocean.model.velocities.v) | ||
wmax = maximum(ocean.model.velocities.w) | ||
|
||
step_time = 1e-9 * (time_ns() - wall_time[]) | ||
|
||
msg1 = @sprintf("time: %s, iteration: %d, Δt: %s, ", prettytime(sim), iteration(sim), prettytime(sim.Δt)) | ||
msg2 = @sprintf("max(h): %.2e m, max(ℵ): %.2e ", hmax, ℵmax) | ||
msg4 = @sprintf("extrema(T): (%.2f, %.2f) ᵒC, ", Tmax, Tmin) | ||
msg5 = @sprintf("maximum(u): (%.2f, %.2f, %.2f) m/s, ", umax, vmax, wmax) | ||
msg6 = @sprintf("wall time: %s \n", prettytime(step_time)) | ||
|
||
@info msg1 * msg2 * msg4 * msg5 * msg6 | ||
|
||
wall_time[] = time_ns() | ||
|
||
return nothing | ||
end | ||
|
||
# And add it as a callback to the simulation. | ||
add_callback!(omip, progress, IterationInterval(50)) | ||
|
||
run!(omip) | ||
|
||
omip.Δt = 10minutes | ||
omip.stop_time = 58 * 365days | ||
|
||
run!(omip) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,8 +261,8 @@ end | |
@inbounds begin | ||
Ts = surface_temperature[i, j, kᴺ] | ||
Ts = convert_to_kelvin(sea_ice_properties.temperature_units, Ts) | ||
ℵi = ice_concentration[i, j, 1] | ||
ℵi = ice_concentration[i, j, kᴺ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a bug that exists on main? let's fix it in its own PR because it may be a while until this PR is merged? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #561 |
||
|
||
Qs = downwelling_radiation.Qs[i, j, 1] | ||
Qℓ = downwelling_radiation.Qℓ[i, j, 1] | ||
Qc = atmosphere_sea_ice_fluxes.sensible_heat[i, j, 1] # sensible or "conductive" heat flux | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to encourage people not to set this variable because it makes setups less portable (eg data will be re-downloaded everywhere)