@@ -127,8 +127,9 @@ function field_ts_timemean(field_ts::FieldTimeSeries)
127127
128128end
129129"""
130- function predicted_maximum_density()
131- Compute the predicted maximum density of water that can form along the mixing line.
130+ function predicted_maximum_density
131+ Compute the predicted maximum density of water that can form along the mixing line between
132+ the salinity and temperature of the upper and lower layers.
132133"""
133134function predicted_maximum_density! (simulation:: Simulation , dns:: TwoLayerDNS ; reference_pressure = 0 )
134135
@@ -137,8 +138,15 @@ function predicted_maximum_density!(simulation::Simulation, dns::TwoLayerDNS; re
137138 S_mix = range (Sᵘ, Sˡ, step = 0.000001 )
138139 T_mix = @. Tᵘ + slope * (Sᵘ - S_mix)
139140 ρ_mix_max = maximum (gsw_rho .(S_mix, T_mix, reference_pressure))
140- NCDataset (simulation. output_writers[:outputs ]. filepath, " a" ) do ds
141- ds. attrib[" Predicted maximum density" ] = ρ_mix_max
141+ file_type = find_file_type (simulation. output_writers[:outputs ]. filepath)
142+ if isequal (file_type, " .nc" )
143+ NCDataset (simulation. output_writers[:outputs ]. filepath, " a" ) do ds
144+ ds. attrib[" Predicted maximum density" ] = ρ_mix_max
145+ end
146+ elseif isequal (file_type, " .jld2" )
147+ jldopen (simulation. output_writers[:outputs ]. filepath, " a+" ) do f
148+ f[" Predicted maximum density" ] = ρ_mix_max
149+ end
142150 end
143151
144152 return nothing
@@ -208,15 +216,15 @@ function kolmogorov_and_batchelor_scale!(file::AbstractString)
208216 file_type = find_file_type (file)
209217 if isequal (file_type, " .nc" )
210218
211- ϵ = Raster (file, lazy = true , name = :ϵ )
212- ds = NCDataset (file, " a " )
213- ν_str = ds. attrib[" ν" ]
214- ν = parse (Float64, ν_str[1 : findfirst (' m' , ν_str)- 1 ])
215- Sc = ds. attrib[" Sc" ]
216- η_min = minimum_η (ϵ; ν)
217- ds. attrib[" η (min)" ] = η_min # minimum space and time Kolmogorov scale
218- ds. attrib[" λ_B" ] = η_min / sqrt (Sc) # minimum space and time Batchelor scale
219- close (ds)
219+ NCDataset (file, " a " ) do ds
220+ ϵ = Raster (file, lazy = true , name = :ϵ )
221+ ν_str = ds. attrib[" ν" ]
222+ ν = parse (Float64, ν_str[1 : findfirst (' m' , ν_str)- 1 ])
223+ Sc = ds. attrib[" Sc" ]
224+ η_min = minimum_η (ϵ; ν)
225+ ds. attrib[" η (min)" ] = η_min # minimum space and time Kolmogorov scale
226+ ds. attrib[" λ_B" ] = η_min / sqrt (Sc) # minimum space and time Batchelor scale
227+ end
220228
221229 elseif isequal (file_type, " .jld2" )
222230
@@ -234,6 +242,35 @@ function kolmogorov_and_batchelor_scale!(file::AbstractString)
234242
235243 return nothing
236244
245+ end
246+ """
247+ function batchelor_scale!
248+ Compute and append the minimum space-time Batchelor scale and append it to save output.
249+ """
250+ function batchelor_scale! (file:: AbstractString )
251+
252+ file_type = find_file_type (file)
253+ if isequal (file_type, " .nc" )
254+
255+ NCDataset (file, " a" ) do ds
256+ Sc = ds. attrib[" Sc" ]
257+ η_min = minimum (ds[" η_space" ][:])
258+ ds. attrib[" λ_B" ] = η_min / sqrt (Sc) # minimum space and time Batchelor scale
259+ end
260+
261+ elseif isequal (file_type, " .jld2" )
262+
263+ Sc = load (file, " Non_dimensional_numbers" )[" Sc" ]
264+ η = FieldTimeSeries (simulation. output_writers[:outputs ]. filepath, " η_space" )
265+ min_η = minimum (η)
266+ jldopen (file, " a+" ) do f
267+ f[" minimum_batchelor_scale" ] = min_η / sqrt (Sc)
268+ end
269+
270+ end
271+
272+ return nothing
273+
237274end
238275"""
239276 function non_dimensional_numbers(simulation::Simulation, dns::TwoLayerDNS)
@@ -263,16 +300,16 @@ function non_dimensional_numbers!(simulation::Simulation, dns::TwoLayerDNS)
263300
264301 if simulation. output_writers[:outputs ] isa NetCDFOutputWriter
265302
266- ds = NCDataset (simulation. output_writers[:outputs ]. filepath, " a" )
267- ds. attrib[" EOS" ] = summary (model. buoyancy. model. equation_of_state. seawater_polynomial)
268- ds. attrib[" Reference density" ] = " $(model. buoyancy. model. equation_of_state. reference_density) kgm⁻³"
269- ds. attrib[" ν" ] = " $(model. closure. ν) m²s⁻¹"
270- ds. attrib[" κₛ" ] = " $(model. closure. κ. S) m²s⁻¹"
271- ds. attrib[" κₜ" ] = " $(model. closure. κ. T) m²s⁻¹"
272- for key ∈ keys (nd_nums)
273- ds. attrib[key] = nd_nums[key]
303+ NCDataset (simulation. output_writers[:outputs ]. filepath, " a" ) do ds
304+ ds. attrib[" EOS" ] = summary (model. buoyancy. model. equation_of_state. seawater_polynomial)
305+ ds. attrib[" Reference density" ] = " $(model. buoyancy. model. equation_of_state. reference_density) kgm⁻³"
306+ ds. attrib[" ν" ] = " $(model. closure. ν) m²s⁻¹"
307+ ds. attrib[" κₛ" ] = " $(model. closure. κ. S) m²s⁻¹"
308+ ds. attrib[" κₜ" ] = " $(model. closure. κ. T) m²s⁻¹"
309+ for key ∈ keys (nd_nums)
310+ ds. attrib[key] = nd_nums[key]
311+ end
274312 end
275- close (ds)
276313
277314 else
278315
0 commit comments