Skip to content

Commit 8231f47

Browse files
authored
Better names for default constants (#660)
* better defaults * no need to redefine * import default_freshwater_density * cleanup imports
1 parent f22d571 commit 8231f47

11 files changed

+20
-33
lines changed

src/OceanSeaIceModels/InterfaceComputations/InterfaceComputations.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export
1818
atmosphere_ocean_stability_functions,
1919
atmosphere_sea_ice_stability_functions
2020

21-
using ..OceanSeaIceModels: default_gravitational_acceleration
21+
using ..OceanSeaIceModels: default_gravitational_acceleration,
22+
default_freshwater_density
2223

2324
import ClimaOcean: stateindex
2425

src/OceanSeaIceModels/InterfaceComputations/coefficient_based_turbulent_fluxes.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using DocStringExtensions
22

3-
g_Earth = Oceananigans.defaults.gravitational_acceleration
4-
53
"""
64
struct CoefficientBasedFluxes{CD, CH, CQ, S}
75

src/OceanSeaIceModels/InterfaceComputations/component_interfaces.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ using KernelAbstractions: @kernel, @index
2727

2828
import Oceananigans.Simulations: initialize!
2929

30-
g_Earth = Oceananigans.defaults.gravitational_acceleration
31-
3230
#####
3331
##### Container for organizing information related to fluxes
3432
#####
@@ -295,7 +293,7 @@ end
295293
"""
296294
ComponentInterfaces(atmosphere, ocean, sea_ice=nothing;
297295
radiation = Radiation(),
298-
freshwater_density = 1000,
296+
freshwater_density = default_freshwater_density,
299297
atmosphere_ocean_fluxes = SimilarityTheoryFluxes(),
300298
atmosphere_sea_ice_fluxes = SimilarityTheoryFluxes(eltype(ocean.model.grid)),
301299
atmosphere_ocean_interface_temperature = BulkTemperature(),
@@ -307,11 +305,11 @@ end
307305
sea_ice_temperature_units = DegreesCelsius(),
308306
sea_ice_reference_density = reference_density(sea_ice),
309307
sea_ice_heat_capacity = heat_capacity(sea_ice),
310-
gravitational_acceleration = g_Earth)
308+
gravitational_acceleration = default_gravitational_acceleration)
311309
"""
312310
function ComponentInterfaces(atmosphere, ocean, sea_ice=nothing;
313311
radiation = Radiation(),
314-
freshwater_density = 1000,
312+
freshwater_density = default_freshwater_density,
315313
atmosphere_ocean_fluxes = SimilarityTheoryFluxes(eltype(ocean.model.grid)),
316314
atmosphere_sea_ice_fluxes = SimilarityTheoryFluxes(eltype(ocean.model.grid)),
317315
atmosphere_ocean_interface_temperature = BulkTemperature(),
@@ -325,7 +323,7 @@ function ComponentInterfaces(atmosphere, ocean, sea_ice=nothing;
325323
sea_ice_temperature_units = DegreesCelsius(),
326324
sea_ice_reference_density = reference_density(sea_ice),
327325
sea_ice_heat_capacity = heat_capacity(sea_ice),
328-
gravitational_acceleration = g_Earth)
326+
gravitational_acceleration = default_gravitational_acceleration)
329327

330328
ocean_grid = ocean.model.grid
331329
FT = eltype(ocean_grid)

src/OceanSeaIceModels/InterfaceComputations/interpolate_atmospheric_state.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function interpolate_atmosphere_state!(interfaces, atmosphere::PrescribedAtmosph
7979
time_indexing = ua.time_indexing
8080
t = clock.time
8181
time_interpolator = TimeInterpolator(ua.time_indexing, times, clock.time)
82-
82+
8383
launch!(arch, grid, kernel_parameters,
8484
_interpolate_primary_atmospheric_state!,
8585
atmosphere_data,
@@ -250,4 +250,3 @@ end
250250
interp_atmos_time_series(ΣJ[2], args...) +
251251
interp_atmos_time_series(ΣJ[3], args...) +
252252
interp_atmos_time_series(ΣJ[4], args...)
253-

src/OceanSeaIceModels/InterfaceComputations/sea_ice_ocean_fluxes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ function compute_sea_ice_ocean_fluxes!(coupled_model)
66
ocean = coupled_model.ocean
77
sea_ice = coupled_model.sea_ice
88

9-
sea_ice_ocean_fluxes = coupled_model.interfaces.sea_ice_ocean_interface.fluxes
9+
sea_ice_ocean_fluxes = coupled_model.interfaces.sea_ice_ocean_interface.fluxes
1010
melting_speed = coupled_model.interfaces.sea_ice_ocean_interface.properties.characteristic_melting_speed
1111
ocean_properties = coupled_model.interfaces.ocean_properties
1212

1313
compute_sea_ice_ocean_fluxes!(sea_ice_ocean_fluxes, ocean, sea_ice, melting_speed, ocean_properties)
14-
14+
1515
return nothing
1616
end
1717

src/OceanSeaIceModels/InterfaceComputations/similarity_theory_turbulent_fluxes.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@ using Oceananigans.Utils: prettysummary
22
using Oceananigans.Grids: AbstractGrid
33

44
using Adapt
5-
using Thermodynamics: Liquid
6-
75
using Printf
8-
using Thermodynamics: PhasePartition
6+
using Thermodynamics: Liquid, PhasePartition
97
using KernelAbstractions.Extras.LoopInfo: @unroll
10-
118
using Statistics: norm
129

1310
import Thermodynamics as AtmosphericThermodynamics
1411
import Thermodynamics.Parameters: Rv_over_Rd
1512

16-
g_Earth = Oceananigans.defaults.gravitational_acceleration
17-
1813
#####
1914
##### Bulk turbulent fluxes based on similarity theory
2015
#####

src/OceanSeaIceModels/InterfaceComputations/tabulated_albedo.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,3 @@ Base.show(io::IO, α::TabulatedAlbedo) = print(io, summary(α))
165165

166166
return α
167167
end
168-

src/OceanSeaIceModels/OceanSeaIceModels.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ export
1010
SkinTemperature,
1111
BulkTemperature
1212

13-
using Oceananigans
1413
using SeawaterPolynomials
1514

15+
using Oceananigans
1616
using Oceananigans.Operators
17-
1817
using Oceananigans.Utils: launch!, Time, KernelParameters
1918
using Oceananigans.Architectures: architecture
2019
using Oceananigans.BoundaryConditions: fill_halo_regions!, BoundaryCondition
@@ -37,8 +36,8 @@ function freshwater_flux end
3736
function reference_density end
3837
function heat_capacity end
3938

40-
const default_gravitational_acceleration = 9.80665
41-
const default_freshwater_density = 1000
39+
const default_gravitational_acceleration = Oceananigans.defaults.gravitational_acceleration
40+
const default_freshwater_density = 1000 # kg m⁻³
4241

4342
const SeaIceSimulation = Simulation{<:SeaIceModel}
4443

src/OceanSeaIceModels/ocean_sea_ice_model.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ using Oceananigans.TimeSteppers: Clock
33
using Oceananigans: SeawaterBuoyancy
44
using ClimaSeaIce.SeaIceThermodynamics: melting_temperature
55
using KernelAbstractions: @kernel, @index
6-
76
using SeawaterPolynomials: TEOS10EquationOfState
87

98
import Thermodynamics as AtmosphericThermodynamics
@@ -12,12 +11,11 @@ import Thermodynamics as AtmosphericThermodynamics
1211
import Oceananigans: fields, prognostic_fields
1312
import Oceananigans.Architectures: architecture
1413
import Oceananigans.Fields: set!
15-
import Oceananigans.Models: timestepper, NaNChecker, default_nan_checker
14+
import Oceananigans.Models: timestepper, NaNChecker, default_nan_checker, initialization_update_state!
1615
import Oceananigans.OutputWriters: default_included_properties
1716
import Oceananigans.Simulations: reset!, initialize!, iteration
1817
import Oceananigans.TimeSteppers: time_step!, update_state!, time
1918
import Oceananigans.Utils: prettytime
20-
import Oceananigans.Models: timestepper, NaNChecker, default_nan_checker, initialization_update_state!
2119

2220
mutable struct OceanSeaIceModel{I, A, O, F, C, Arch} <: AbstractModel{Nothing, Arch}
2321
architecture :: Arch

src/OceanSimulations/OceanSimulations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ using Oceananigans.TurbulenceClosures.TKEBasedVerticalDiffusivities:
1818

1919
using SeawaterPolynomials.TEOS10: TEOS10EquationOfState
2020

21-
g_Earth = Oceananigans.defaults.gravitational_acceleration
22-
Ω_Earth = Oceananigans.defaults.planet_rotation_rate
21+
default_gravitational_acceleration = Oceananigans.defaults.gravitational_acceleration
22+
default_planet_rotation_rate = Oceananigans.defaults.planet_rotation_rate
2323

2424
struct Default{V}
2525
value :: V

0 commit comments

Comments
 (0)