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

A first stab at a diagnostic surface temperature implementation #278

Merged
merged 54 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 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
2ea71e3
Update src/OceanSeaIceModels/CrossRealmFluxes/surface_temperature.jl
simone-silvestri Dec 2, 2024
c225076
Merge branch 'main' into ss/new-fluxes
simone-silvestri Dec 3, 2024
f915ed3
change comment + only one papa simulation
simone-silvestri Dec 5, 2024
08be1bb
add comment
simone-silvestri Dec 5, 2024
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ JLD2 = "0.4, 0.5"
KernelAbstractions = "0.9"
MPI = "0.20"
NCDatasets = "0.12, 0.13, 0.14"
Oceananigans = "0.94.3 - 0.99"
Oceananigans = "0.94.3 - 0.99" # This needs to be 0.94.4 when PolarBoundaryCondition is implemented
OffsetArrays = "1.14"
OrthogonalSphericalShellGrids = "0.1.8"
OrthogonalSphericalShellGrids = "0.1.9"
Scratch = "1"
SeawaterPolynomials = "0.3.4"
StaticArrays = "1"
Expand Down
2 changes: 1 addition & 1 deletion examples/generate_bathymetry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ grid = LatitudeLongitudeGrid(size = (Nλ, Nφ, 1),
# one interpolation passes and no restrictions on connected regions.
# - `h_smooth` shows the output of the function with 40 interpolation passes, which results
# in a smoother bathymetry.
# - `h_no_connected_regions` shows the output of the function with `connected_regions_allowed = 0`, which
# - `h_no_connected_regions` shows the output of the function with `major_basins = 1`, which
# means that the function does not allow connected regions in the bathymetry (e.g., lakes)
# and fills them with land.

Expand Down
3 changes: 3 additions & 0 deletions examples/single_column_os_papa_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ lines!(axq, t_days, qa)
current_figure()

# We continue constructing a simulation.
# For the fluxes computation we use a `SkinTemperature` formulation that computes
# the skin temperature from a balance between internal and external heat fluxes.

radiation = Radiation()
similarity_theory = SimilarityTheoryTurbulentFluxes(grid; surface_temperature_type=SkinTemperature())
coupled_model = OceanSeaIceModel(ocean; atmosphere, radiation)
simulation = Simulation(coupled_model, Δt=ocean.Δt, stop_time=30days)

Expand Down
2 changes: 2 additions & 0 deletions src/ClimaOcean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export
Radiation,
LatitudeDependentAlbedo,
SimilarityTheoryTurbulentFluxes,
SkinTemperature,
BulkTemperature,
JRA55_prescribed_atmosphere,
JRA55NetCDFBackend,
regrid_bathymetry,
Expand Down
2 changes: 1 addition & 1 deletion src/DataWrangling/ECCO/ECCO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function ECCO_field(metadata::ECCOMetadata;
inpainting = NearestNeighborInpainting(Inf),
mask = nothing,
horizontal_halo = (7, 7),
cache_inpainted_data = false)
cache_inpainted_data = true)

field = empty_ECCO_field(metadata; architecture, horizontal_halo)
inpainted_path = inpainted_metadata_path(metadata)
Expand Down
5 changes: 4 additions & 1 deletion src/OceanSeaIceModels/CrossRealmFluxes/CrossRealmFluxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ using Adapt
export Radiation,
OceanSeaIceSurfaceFluxes,
LatitudeDependentAlbedo,
SimilarityTheoryTurbulentFluxes
SimilarityTheoryTurbulentFluxes,
SkinTemperature,
BulkTemperature

using ..OceanSeaIceModels: default_gravitational_acceleration

Expand All @@ -31,6 +33,7 @@ include("tabulated_albedo.jl")
include("roughness_lengths.jl")
include("stability_functions.jl")
include("seawater_saturation_specific_humidity.jl")
include("surface_temperature.jl")
include("similarity_theory_turbulent_fluxes.jl")
include("ocean_sea_ice_surface_fluxes.jl")
include("atmosphere_ocean_fluxes.jl")
Expand Down
33 changes: 26 additions & 7 deletions src/OceanSeaIceModels/CrossRealmFluxes/atmosphere_ocean_fluxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ function compute_atmosphere_ocean_fluxes!(coupled_model)
grid,
clock,
ocean_state,
coupled_model.fluxes.ocean_reference_density,
coupled_model.fluxes.ocean_heat_capacity,
coupled_model.fluxes.ocean_temperature_units,
surface_atmosphere_state,
radiation_properties,
atmosphere.reference_height, # height at which the state is known
atmosphere.boundary_layer_height,
atmosphere.thermodynamics_parameters)
Expand Down Expand Up @@ -264,21 +267,27 @@ end
grid,
clock,
ocean_state,
ocean_density,
ocean_heat_capacity,
ocean_temperature_units,
surface_atmos_state,
radiation,
atmosphere_reference_height,
atmosphere_boundary_layer_height,
atmos_thermodynamics_parameters)

i, j = @index(Global, NTuple)
kᴺ = size(grid, 3) # index of the top ocean cell

kᴺ = size(grid, 3) # index of the top ocean cell
time = Time(clock.time)

@inbounds begin
uₐ = surface_atmos_state.u[i, j, 1]
vₐ = surface_atmos_state.v[i, j, 1]
Tₐ = surface_atmos_state.T[i, j, 1]
pₐ = surface_atmos_state.p[i, j, 1]
qₐ = surface_atmos_state.q[i, j, 1]
Rs = surface_atmos_state.Qs[i, j, 1]
Rℓ = surface_atmos_state.Qℓ[i, j, 1]

# Extract state variables at cell centers
# Ocean state
Expand Down Expand Up @@ -322,18 +331,27 @@ end
inactive = inactive_node(i, j, kᴺ, grid, c, c, c)
maxiter = ifelse(inactive, 1, similarity_theory.maxiter)

turbulent_fluxes = compute_similarity_theory_fluxes(similarity_theory,
dynamic_ocean_state,
dynamic_atmos_state,
atmosphere_boundary_layer_height,
ℂₐ, g, ϰ, maxiter)
prescribed_heat_fluxes = net_downwelling_radiation(i, j, grid, time, radiation, Rs, Rℓ)
radiative_properties = local_radiation_properties(i, j, kᴺ, grid, time, radiation)

turbulent_fluxes, surface_temperature = compute_similarity_theory_fluxes(similarity_theory,
dynamic_ocean_state,
dynamic_atmos_state,
prescribed_heat_fluxes,
radiative_properties,
Sₒ,
ocean_density,
ocean_heat_capacity,
atmosphere_boundary_layer_height,
ℂₐ, g, ϰ, maxiter)

# Store fluxes
Qv = similarity_theory.fields.latent_heat
Qc = similarity_theory.fields.sensible_heat
Fv = similarity_theory.fields.water_vapor
ρτx = similarity_theory.fields.x_momentum
ρτy = similarity_theory.fields.y_momentum
Ts = similarity_theory.fields.T_surface

@inbounds begin
# +0: cooling, -0: heating
Expand All @@ -342,6 +360,7 @@ end
Fv[i, j, 1] = ifelse(inactive, 0, turbulent_fluxes.water_vapor)
ρτx[i, j, 1] = ifelse(inactive, 0, turbulent_fluxes.x_momentum)
ρτy[i, j, 1] = ifelse(inactive, 0, turbulent_fluxes.y_momentum)
Ts[i, j, 1] = surface_temperature
end
end

Expand Down
9 changes: 9 additions & 0 deletions src/OceanSeaIceModels/CrossRealmFluxes/radiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,12 @@ function Base.show(io::IO, properties::SurfaceProperties)
print(io, "└── sea_ice: ", summary(properties.sea_ice))
end

@inline local_radiation_properties(i, j, k, grid, time, ::Nothing) = nothing

@inline function local_radiation_properties(i, j, k, grid, time, r::Radiation)
σ = r.stefan_boltzmann_constant
ϵ = stateindex(r.emission.ocean, i, j, k, grid, time)
α = stateindex(r.reflection.ocean, i, j, k, grid, time)

return (; ϵ, α, σ)
end
Loading
Loading