@@ -134,21 +134,25 @@ the salinity and temperature of the upper and lower layers.
134134function 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