Detach ClimaOcean to ClimaCoupler#2039
Conversation
hgpeterson
left a comment
There was a problem hiding this comment.
Thanks @simone-silvestri, this looks good so far! I think most of the problems I caught have to do with the fact that you used v0.5.8 of NumericalEarth, but there were some important changes since then (like wiring in the clock/stop_time to the simulations, including mass fluxes, and a few other things). Once those get ported over, I think we're almost ready to merge.
| """ | ||
| simplified_ocean_closure(FT=Oceananigans.defaults.FloatType) | ||
|
|
||
| A minimal closure suitable for testing on memory-limited GPUs (e.g. P100). Uses `ConvectiveAdjustmentVerticalDiffusivity`with a background |
There was a problem hiding this comment.
| A minimal closure suitable for testing on memory-limited GPUs (e.g. P100). Uses `ConvectiveAdjustmentVerticalDiffusivity`with a background | |
| A minimal closure suitable for testing on memory-limited GPUs (e.g. P100). Uses `ConvectiveAdjustmentVerticalDiffusivity` with a background |
| # Ported from ClimaOcean v0.10.0, src/OceanConfigurations/{OceanConfigurations,one_degree_tripolar}.jl, | ||
| # and NumericalEarth v0.5.8, src/Oceans/ocean_simulation.jl |
There was a problem hiding this comment.
Maybe just state this in the PR but don't need it in the code? Also, should we be using the latest NE version (0.6.0)?
| @@ -0,0 +1,442 @@ | |||
| # Ported from NumericalEarth v0.5.8, src/Oceans/{ocean_simulation,Oceans,barotropic_potential_forcing}.jl | |||
| @inline default_gravitational_acceleration() = OC.defaults.gravitational_acceleration | ||
| @inline default_planet_rotation_rate() = OC.defaults.planet_rotation_rate |
There was a problem hiding this comment.
Shouldn't these come from the Coupler somewhere?
| # Only forward `clock` when supplied so the model keeps its own default otherwise. | ||
| clock_kw = isnothing(clock) ? NamedTuple() : (; clock) | ||
|
|
||
| ocean_model = OC.HydrostaticFreeSurfaceModel( | ||
| grid; | ||
| buoyancy, | ||
| closure, | ||
| biogeochemistry, | ||
| tracer_advection, | ||
| momentum_advection, | ||
| tracers, | ||
| timestepper, | ||
| free_surface, | ||
| coriolis, | ||
| forcing, | ||
| boundary_conditions, | ||
| clock_kw..., | ||
| ) | ||
|
|
||
| ocean = OC.Simulation(ocean_model; Δt, verbose) |
There was a problem hiding this comment.
| # Only forward `clock` when supplied so the model keeps its own default otherwise. | |
| clock_kw = isnothing(clock) ? NamedTuple() : (; clock) | |
| ocean_model = OC.HydrostaticFreeSurfaceModel( | |
| grid; | |
| buoyancy, | |
| closure, | |
| biogeochemistry, | |
| tracer_advection, | |
| momentum_advection, | |
| tracers, | |
| timestepper, | |
| free_surface, | |
| coriolis, | |
| forcing, | |
| boundary_conditions, | |
| clock_kw..., | |
| ) | |
| ocean = OC.Simulation(ocean_model; Δt, verbose) | |
| ocean_model = OC.HydrostaticFreeSurfaceModel( | |
| grid; | |
| clock, | |
| buoyancy, | |
| closure, | |
| biogeochemistry, | |
| tracer_advection, | |
| momentum_advection, | |
| tracers, | |
| timestepper, | |
| free_surface, | |
| coriolis, | |
| forcing, | |
| boundary_conditions) | |
| ocean = OC.Simulation(ocean_model; Δt, stop_time, verbose) |
We lost the clock changes from NE v0.5.9 again!
| kᴺ = size(ocean.model.grid, 3) | ||
| surface_ocean_salinity = OC.interior(ocean.model.tracers.S, :, :, kᴺ:kᴺ) |
There was a problem hiding this comment.
| kᴺ = size(ocean.model.grid, 3) | |
| surface_ocean_salinity = OC.interior(ocean.model.tracers.S, :, :, kᴺ:kᴺ) | |
| surface_ocean_salinity = ocean_surface_salinity(ocean) |
And port over ocean_surface_salinity() from v0.6.0?
| # Build the sea ice model | ||
| sea_ice_model = CSI.SeaIceModel( | ||
| grid; | ||
| ice_salinity, |
There was a problem hiding this comment.
| ice_salinity, | |
| clock, | |
| ice_salinity, |
| ) | ||
|
|
||
| verbose = false | ||
| sea_ice = OC.Simulation(sea_ice_model; Δt, verbose) |
There was a problem hiding this comment.
| sea_ice = OC.Simulation(sea_ice_model; Δt, verbose) | |
| sea_ice = OC.Simulation(sea_ice_model; Δt, stop_time, verbose) |
| # `ocean_surface_velocities(ocean)` is inlined here: the singleton vertical dimension is dropped, | ||
| # unlike the surface salinity slice in `sea_ice_simulation`, which keeps it. | ||
| if isnothing(ocean) | ||
| SSU = OC.Fields.ZeroField() | ||
| SSV = OC.Fields.ZeroField() | ||
| else | ||
| kᴺ = size(ocean.model.grid, 3) | ||
| SSU = view(ocean.model.velocities.u, :, :, kᴺ) | ||
| SSV = view(ocean.model.velocities.v, :, :, kᴺ) | ||
| end | ||
|
|
There was a problem hiding this comment.
| # `ocean_surface_velocities(ocean)` is inlined here: the singleton vertical dimension is dropped, | |
| # unlike the surface salinity slice in `sea_ice_simulation`, which keeps it. | |
| if isnothing(ocean) | |
| SSU = OC.Fields.ZeroField() | |
| SSV = OC.Fields.ZeroField() | |
| else | |
| kᴺ = size(ocean.model.grid, 3) | |
| SSU = view(ocean.model.velocities.u, :, :, kᴺ) | |
| SSV = view(ocean.model.velocities.v, :, :, kᴺ) | |
| end | |
| SSU, SSV = ocean_surface_velocities(ocean) |
and port over ocean_surface_velocities() from v0.6.0
| τua = OC.Field{OC.Face, OC.Center, Nothing}(grid) | ||
| τva = OC.Field{OC.Center, OC.Face, Nothing}(grid) |
There was a problem hiding this comment.
No boundary_conditions like in NE?
There are not too many lines we need to port over to completely detach ClimaCoupler from ClimaOcean and just depend on Oceananigans and ClimaSeaIce.
This PR does the initial port.