-
Notifications
You must be signed in to change notification settings - Fork 7
Compute reference density with derivative #185
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?
Changes from 1 commit
6d3678c
d33613f
312e3b3
c2a44ba
df38360
0a49c6a
bf9dac5
fae0a01
a09cbcf
b0ecdd5
7972fca
1e3feca
b2c781e
31542cc
4c6ac15
cec296b
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 |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| using Oceananigans: Oceananigans, Center, Field, set!, fill_halo_regions! | ||
| using Oceananigans.Utils: launch! | ||
| using Oceananigans.Operators: Δzᶜᶜᶠ, ℑzᵃᵃᶠ | ||
|
|
||
| using Adapt: Adapt, adapt | ||
| using KernelAbstractions: @kernel, @index | ||
|
|
||
| ##### | ||
| ##### Reference state computations for Boussinesq and Anelastic models | ||
|
|
@@ -91,12 +95,35 @@ function ReferenceState(grid, thermo=ThermodynamicConstants(eltype(grid)); | |
| p₀ = convert(FT, base_pressure) | ||
| θ₀ = convert(FT, potential_temperature) | ||
|
|
||
| pᵣ = Field{Nothing, Nothing, Center}(grid) | ||
| ρᵣ = Field{Nothing, Nothing, Center}(grid) | ||
| set!(pᵣ, z -> adiabatic_hydrostatic_pressure(z, p₀, θ₀, thermo)) | ||
| set!(ρᵣ, z -> adiabatic_hydrostatic_density(z, p₀, θ₀, thermo)) | ||
| fill_halo_regions!(pᵣ) | ||
| fill_halo_regions!(ρᵣ) | ||
|
|
||
| pᵣ = Field{Nothing, Nothing, Center}(grid) | ||
| compute_reference_pressure!(pᵣ, grid, p₀, ρᵣ, thermo) | ||
| # set!(pᵣ, z -> adiabatic_hydrostatic_pressure(z, p₀, θ₀, thermo)) | ||
| fill_halo_regions!(pᵣ) | ||
|
|
||
| return ReferenceState(p₀, θ₀, pᵣ, ρᵣ) | ||
| end | ||
|
|
||
| @kernel function _compute_reference_pressure!(pᵣ, grid, p₀, ρᵣ, thermo) | ||
| i, j = @index(Global, NTuple) | ||
|
|
||
| # ∂z p = - ρᵣ g | ||
| # (p⁺ - pᵏ) / Δz = - ℑzᶠ(ρᵣ) * g | ||
| # p⁺ = pᵏ - ℑzᶠ(ρᵣ) * g Δz | ||
|
|
||
| @inbounds pᵣ[i, j, 1] = p₀ | ||
| g = thermo.gravitational_acceleration | ||
|
|
||
| for k = 2:grid.Nz | ||
| @inbounds pᵣ[i, j, k] = pᵣ[i, j, k-1] - ℑzᵃᵃᶠ(i, j, k, grid, ρᵣ) * g * Δzᶜᶜᶠ(i, j, k, grid) | ||
|
||
| end | ||
| end | ||
|
|
||
| function compute_reference_pressure!(pᵣ, grid, p₀, ρᵣ, thermo) | ||
| arch = grid.architecture | ||
| launch!(arch, grid, (1, 1), _compute_reference_pressure!, pᵣ, grid, p₀, ρᵣ, thermo) | ||
| return nothing | ||
| end | ||

Uh oh!
There was an error while loading. Please reload this page.