-
Notifications
You must be signed in to change notification settings - Fork 5
Implement a PotentialTemperatureThermodynamics formulation #218
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
Changes from all commits
64faae6
e2dcd69
09411da
a540880
6f67813
fd02adc
0d3e48d
e458b01
f8d0209
a7da5b3
8c92b6e
d4c3468
f8db090
b0717cd
410ae49
e1c6591
48b1251
abae30d
6f073dd
106f549
2b6c909
8fdd72e
d4b9257
6b0f7f9
f8b00ee
73fd949
cb0e46b
d3e21da
c4bc8a4
329f24c
39978ac
1e808e0
87bb7f8
5137306
095aa14
5698bea
c1debf2
886b80e
13fa7e1
269342f
8834ddd
a453a31
8a64f6d
7143ad0
7981ec7
d19c69b
ee20018
b72e966
780ef81
97670fc
4e25aee
b154727
3cb6f73
3d82653
98f2c8d
f3d49d7
da54a8b
926fb12
c3268c2
ea44f4e
27cc252
bcb1fc7
7d0e33c
68f40c4
11f0f9a
655dfd6
1b7a4af
235feb4
f20e3fb
b2d4b79
f6f051b
0b24cce
64f96af
4b651b5
575be02
2bdcb0b
f6591f6
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 |
|---|---|---|
|
|
@@ -28,11 +28,8 @@ using Printf | |
| # Grid resolution is modest but enough to clearly resolve the Kelvin-Helmholtz billows and | ||
| # rolled-up moisture filament. | ||
|
|
||
| Nx = 384 # horizontal resolution | ||
| Nz = 128 # vertical resolution | ||
|
|
||
| Lx = 10e3 # domain length | ||
| Lz = 3e3 # domain height | ||
| Nx, Nz = 384, 128 # resolution | ||
| Lx, Lz = 10e3, 3e3 # domain extent | ||
|
|
||
| grid = RectilinearGrid(; size = (Nx, Nz), x = (0, Lx), z = (0, Lz), | ||
| topology = (Periodic, Flat, Bounded)) | ||
|
|
@@ -53,14 +50,14 @@ model = AtmosphereModel(grid; advection=WENO(order=5), microphysics) | |
| # N² = \frac{g}{θ₀} \frac{∂θ}{∂z} , | ||
| # ``` | ||
| # | ||
| # We initialize the potential temperature that gives constant Brunt–Väisälä frequency, | ||
| # We initialize with a potential temperature that gives constant Brunt–Väisälä frequency, | ||
| # representative of mid-tropospheric stability. The (dry) Brunt–Väisälä frequency is | ||
| # | ||
| # ```math | ||
| # N² = \frac{g}{θ} \frac{∂θ}{∂z} | ||
| # ``` | ||
| # | ||
| # and thus, for constant ``N²`` the above implies ``θ = θ₀ \exp{(N² z / g)}``. | ||
| # and thus, for constant ``N²``, the above implies that ``θ = θ₀ \exp{(N² z / g)}``. | ||
|
|
||
| thermo = ThermodynamicConstants() | ||
| g = thermo.gravitational_acceleration | ||
|
|
@@ -81,17 +78,29 @@ N = 0.01 # target dry Brunt–Väisälä frequency (s⁻¹) | |
|
|
||
| # First, we set up the shear layer using a ``\tanh`` profile: | ||
|
|
||
| z₀ = 1e3 # center of shear & moist layer (m) | ||
| Δzᶸ = 150 # shear layer half-thickness (m) | ||
| U_top = 25 # upper-layer wind (m/s) | ||
| U_bot = 5 # lower-layer wind (m/s) | ||
| uᵇ(z) = U_bot + (U_top - U_bot) * (1 + tanh((z - z₀) / Δzᶸ)) / 2 | ||
| z₀ = 1e3 # center of shear & moist layer (m) | ||
| Δzᵘ = 150 # shear layer half-thickness (m) | ||
| U₀ = 5 # base wind speed (m/s) | ||
| ΔU = 20 # upper-layer wind (m/s) | ||
| uᵇ(z) = U₀ + ΔU * (1 + tanh((z - z₀) / Δzᵘ)) / 2 | ||
|
|
||
| # For the moisture layer, we use a Gaussian in ``z`` centered at ``z₀``: | ||
|
|
||
| q_max = 0.012 # peak specific humidity (kg/kg) | ||
| Δz_q = 200 # moist layer half-width (m) | ||
| qᵇ(z) = q_max * exp(-(z - z₀)^2 / 2Δz_q^2) | ||
| qᵗ₀ = 0.012 # peak specific humidity (kg/kg) | ||
| Δzᵗ = 200 # moist layer half-width (m) | ||
| qᵇ(z) = qᵗ₀ * exp(-(z - z₀)^2 / 2Δzᵗ^2) | ||
|
|
||
| # We initialize the model via Oceananigans `set!`, adding also a bit of random noise. | ||
|
|
||
| δθ = 0.01 | ||
| δu = 1e-3 | ||
| δq = 0.05 * qᵗ₀ | ||
|
|
||
| θᵢ(x, z) = θᵇ(z) + δθ * rand() | ||
| qᵗᵢ(x, z) = qᵇ(z) + δq * rand() | ||
| uᵢ(x, z) = uᵇ(z) + δu * rand() | ||
|
Comment on lines
+99
to
+101
Collaborator
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. Should use
Member
Author
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.
|
||
|
|
||
| set!(model; u=uᵢ, qᵗ=qᵗᵢ, θ=θᵢ) | ||
|
|
||
| # ## The Kelvin-Helmholtz instability | ||
| # | ||
|
|
@@ -107,12 +116,11 @@ qᵇ(z) = q_max * exp(-(z - z₀)^2 / 2Δz_q^2) | |
| # | ||
| # Let's plot the initial state as well as the Richardson number. | ||
|
|
||
| z = znodes(grid, Center()) | ||
|
|
||
| dudz = @. (U_top - U_bot) * sech((z - z₀) / Δzᶸ)^2 / 2Δzᶸ | ||
| Ri = N^2 ./ dudz.^2 | ||
| U = Field(Average(model.velocities.u, dims=(1, 2))) | ||
| Ri = N^2 / ∂z(U)^2 | ||
|
|
||
| using CairoMakie | ||
| Qᵗ = Field(Average(model.specific_moisture, dims=1)) | ||
| θ = Field(Average(liquid_ice_potential_temperature(model), dims=1)) | ||
|
|
||
| fig = Figure(size=(800, 500)) | ||
|
|
||
|
|
@@ -121,11 +129,12 @@ axq = Axis(fig[1, 2], xlabel = "qᵇ (kg/kg)", title="Total liquid") | |
| axθ = Axis(fig[1, 3], xlabel = "θᵇ (K)", title="Potential temperature") | ||
| axR = Axis(fig[1, 4], xlabel = "Ri", ylabel="z (m)", title="Richardson number") | ||
|
|
||
| lines!(axu, uᵇ.(z), z) | ||
| lines!(axq, qᵇ.(z), z) | ||
| lines!(axθ, θᵇ.(z), z) | ||
| lines!(axR, Ri, z) | ||
| lines!(axu, U) | ||
| lines!(axq, Qᵗ) | ||
| lines!(axθ, θ) | ||
| lines!(axR, Ri) | ||
| lines!(axR, [1/4, 1/4], [0, Lz], linestyle = :dash, color = :black) | ||
|
|
||
| xlims!(axR, 0, 0.8) | ||
| axR.xticks = 0:0.25:1 | ||
|
|
||
|
|
@@ -137,20 +146,6 @@ end | |
|
|
||
| fig | ||
|
|
||
| # ## Define initial conditions | ||
| # | ||
| # We initialize the model via Oceananigans `set!`, adding also a bit of random noise. | ||
|
|
||
| δθ = 0.01 | ||
| δu = 1e-3 | ||
| δq = 0.05 * q_max | ||
|
|
||
| θᵢ(x, z) = θᵇ(z) + δθ * rand() | ||
| qᵗᵢ(x, z) = qᵇ(z) + δq * rand() | ||
| uᵢ(x, z) = uᵇ(z) + δu * rand() | ||
|
|
||
| set!(model; u=uᵢ, qᵗ=qᵗᵢ, θ=θᵢ) | ||
|
|
||
| # ## Set up and run the simulation | ||
| # | ||
| # We construct a simulation and use the time-step wizard to keep the CFL number under control. | ||
|
|
@@ -176,7 +171,7 @@ add_callback!(simulation, progress, TimeInterval(1minute)) | |
| # the potential temperatures and the specific humidities (vapour, liquid, ice). | ||
| u, v, w = model.velocities | ||
| ξ = ∂z(u) - ∂x(w) | ||
| θ = PotentialTemperatureField(model) | ||
| θ = liquid_ice_potential_temperature(model) | ||
| outputs = merge(model.velocities, model.microphysical_fields, (; ξ, θ)) | ||
|
|
||
| filename = "wave_clouds.jld2" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.