Last active
August 24, 2021 11:43
-
-
Save glwagner/1f2713b1ebc1353906a7d7113b934341 to your computer and use it in GitHub Desktop.
Example parameter file interface for Oceananigans
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= | |
# This example implements the script | |
using Oceananigans | |
using Oceananigans.TurbulenceClosures: CATKEVerticalDiffusivity | |
using SeawaterPolynomials: TEOS10EquationOfState | |
gravitational_acceleration = 9.807 # m s⁻² | |
dissipation_parameter = 2.91 | |
grid = RegularRectilinearGrid(size = (1, 1, 1), | |
x = (0, 1), | |
y = (0, 1), | |
z = (-1, 0)) | |
equation_of_state = TEOS10EquationOfState() | |
boundary_layer_mixing_length = MixingLength(Cᴷu⁻ = 0.15, Cᴷc⁻ = 0.4) | |
boundary_layer_closure = CATKEVerticalDiffusivity(Cᴰ = dissipation_parameter, | |
mixing_length = boundary_layer_mixing_length) | |
model = HydrostaticFreeSurfaceModel(architecture = CPU(), | |
grid = grid | |
tracers = (:T, :S, :e), | |
free_surface = ImplicitFreeSurface(; gravitational_acceleration), | |
buoyancy = SeawaterBuoyancy(; gravitational_acceleration, equation_of_state), | |
closure = boundary_layer_closure) | |
=# | |
##### | |
##### Parameter files | |
##### | |
earth_file = """ | |
[gravitational_acceleration] | |
value = 9.807 | |
type = "Real" | |
prior = "Fixed" | |
transformation = "nothing" | |
description = "Earth's gravitational acceleration" | |
units = "m / s^2" | |
""" | |
parameters_file = """ | |
[CATKEVerticalDiffusivity] | |
[CATKEVerticalDiffusivity.dissipation_parameter] | |
value = 2.91 | |
type = "Real" | |
prior = "Fixed" | |
transformation = "nothing" | |
description = "Scaling parameter for the dissipation of subgrid turbulent kinetic energy" | |
units = "nothing" | |
[CATKEVerticalDiffusivity.MixingLength] | |
[CATKEVerticalDiffusivity.MixingLength.momentum_diffusivity_scaling] | |
value = 0.15 | |
type = "Real" | |
prior = "Fixed" | |
transformation = "nothing" | |
description = "Scaling parameter for CATKE momentum diffusivity" | |
units = "nothing" | |
[CATKEVerticalDiffusivity.MixingLength.tracer_diffusivity_scaling] | |
value = 0.40 | |
type = "Real" | |
prior = "Fixed" | |
transformation = "nothing" | |
description = "Scaling parameter for CATKE tracer diffusivity" | |
units = "nothing" | |
""" | |
##### | |
##### Template | |
##### | |
using Oceananigans | |
using Oceananigans.TurbulenceClosures.CATKEVerticalDiffusivities: CATKEVerticalDiffusivity, MixingLength | |
using SeawaterPolynomials: TEOS10EquationOfState | |
using TOML | |
earth_data = TOML.parse(earth_file) | |
parameters_data = TOML.parse(parameters_file) | |
gravitational_acceleration = earth_data["gravitational_acceleration"]["value"] | |
boundary_layer_closure_parameters = parameters_data["CATKEVerticalDiffusivity"] | |
dissipation_parameter = boundary_layer_closure_parameters["dissipation_parameter"]["value"] | |
momentum_diffusivity_scaling = boundary_layer_closure_parameters["MixingLength"]["momentum_diffusivity_scaling"]["value"] | |
tracer_diffusivity_scaling = boundary_layer_closure_parameters["MixingLength"]["tracer_diffusivity_scaling"]["value"] | |
grid = RegularRectilinearGrid(size = (1, 1, 1), | |
x = (0, 1), | |
y = (0, 1), | |
z = (-1, 0)) | |
equation_of_state = TEOS10EquationOfState() | |
boundary_layer_mixing_length = MixingLength(Cᴷu⁻ = momentum_diffusivity_scaling, | |
Cᴷc⁻ = tracer_diffusivity_scaling) | |
boundary_layer_closure = CATKEVerticalDiffusivity(Cᴰ = dissipation_parameter, | |
mixing_length = boundary_layer_mixing_length) | |
model = HydrostaticFreeSurfaceModel(architecture = CPU(), | |
grid = grid, | |
tracers = (:T, :S, :e), | |
free_surface = ImplicitFreeSurface(; gravitational_acceleration), | |
buoyancy = SeawaterBuoyancy(; gravitational_acceleration, equation_of_state), | |
closure = boundary_layer_closure) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment