Skip to content

Commit ef66a84

Browse files
authored
Merge pull request #135 from jbisits/predictedlowerlayerST
Predict `S` and `T` equilbrium lower layer
2 parents d89c978 + 29352a3 commit ef66a84

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

examples/twolayer_example.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ model = DNS(architecture, DOMAIN_EXTENT, resolution, diffusivities;
1111

1212
## set initial conditions
1313
T₀ᵘ = -1.5
14-
S₀ᵘ = (stable = 34.551, cabbeling = 34.568, unstable = 34.59)
15-
stable = StableUpperLayerInitialConditions(S₀ᵘ.cabbeling, T₀ᵘ)
16-
initial_conditions = TwoLayerInitialConditions(stable)
14+
S₀ᵘ = (stable = 34.551, cabbeling = 34.58, unstable = 34.59)
15+
cabbeling = CabbelingUpperLayerInitialConditions(S₀ᵘ.cabbeling, T₀ᵘ)
16+
initial_conditions = TwoLayerInitialConditions(cabbeling)
1717
transition_depth = find_depth(model, INTERFACE_LOCATION)
1818
profile_function = StepChange(transition_depth)#HyperbolicTangent(INTERFACE_LOCATION, 1.0)
1919
tracer_perturbation_depth = find_depth(model, INTERFACE_LOCATION / 2)

src/output_utils.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,25 @@ the salinity and temperature of the upper and lower layers.
134134
function predicted_maximum_density!(simulation::Simulation, dns::TwoLayerDNS; reference_gp_height = 0)
135135

136136
Sᵘ, Sˡ, ΔS, Tᵘ, Tˡ, ΔT = dns.initial_conditions
137-
slope = - ΔT / ΔS
137+
slope = ΔT / ΔS
138138
S_mix = range(Sᵘ, Sˡ, step = 0.000001)
139-
T_mix = @. Tᵘ + slope * (Sᵘ - S_mix)
139+
T_mix = @. Tᵘ + slope * (S_mix - Sᵤ)
140140
Zᵣ = similar(S_mix)
141141
fill!(Zᵣ, reference_gp_height)
142142
eos = dns.model.buoyancy.model.equation_of_state
143-
ρ_mix_max = maximum(ρ.(T_mix, S_mix, Zᵣ, fill(eos, length(S_mix))))
143+
ρ_mix_max, max_idx = findmax(ρ.(T_mix, S_mix, Zᵣ, fill(eos, length(S_mix))))
144144
file_type = find_file_type(simulation.output_writers[:outputs].filepath)
145145
if isequal(file_type, ".nc")
146146
NCDataset(simulation.output_writers[:outputs].filepath, "a") do ds
147147
ds.attrib["Predicted maximum density"] = ρ_mix_max
148+
ds.attrib["Predicted equilibrium Tₗ"] = T_mix[max_idx]
149+
ds.attrib["Predicted equilibrium Sₗ"] = S_mix[max_idx]
148150
end
149151
elseif isequal(file_type, ".jld2")
150152
jldopen(simulation.output_writers[:outputs].filepath, "a+") do f
151153
f["Predicted maximum density"] = ρ_mix_max
154+
f["Predicted equilibrium Tₗ"] = T_mix[max_idx]
155+
f["Predicted equilibrium Sₗ"] = S_mix[max_idx]
152156
end
153157
end
154158

0 commit comments

Comments
 (0)