1
1
using Oceananigans. Operators: ℑxyᶜᶠᵃ, ℑxyᶠᶜᵃ
2
2
3
+ # ####
4
+ # #### Physical constants
5
+ # ####
6
+
7
+ const Ω_Earth = 7.292115e-5 # [s⁻¹] https://en.wikipedia.org/wiki/Earth%27s_rotation#Angular_speed
8
+ const R_Earth = 6371.0e3 # Mean radius of the Earth [m] https://en.wikipedia.org/wiki/Earth
9
+
3
10
# ####
4
11
# #### Functions for non-rotating models
5
12
# ####
@@ -23,26 +30,32 @@ struct FPlane{FT} <: AbstractRotation
23
30
end
24
31
25
32
"""
26
- FPlane([FT=Float64;] f=nothing, rotation_rate=nothing , latitude=nothing)
33
+ FPlane([FT=Float64;] f=nothing, rotation_rate=Ω_Earth , latitude=nothing)
27
34
28
35
Returns a parameter object for constant rotation at the angular frequency
29
36
`f/2`, and therefore with background vorticity `f`, around a vertical axis.
30
37
If `f` is not specified, it is calculated from `rotation_rate` and
31
38
`latitude` according to the relation `f = 2*rotation_rate*sind(latitude).
32
39
40
+ By default, `rotation_rate` is assumed to be Earth's.
41
+
33
42
Also called `FPlane`, after the "f-plane" approximation for the local effect of
34
- Earth 's rotation in a planar coordinate system tangent to the Earth 's surface.
43
+ a planet 's rotation in a planar coordinate system tangent to the planet 's surface.
35
44
"""
36
- function FPlane (FT:: DataType = Float64; f= nothing , rotation_rate= nothing , latitude= nothing )
45
+ function FPlane (FT:: DataType = Float64; f= nothing , rotation_rate= Ω_Earth , latitude= nothing )
37
46
38
- if f == nothing && rotation_rate != nothing && latitude != nothing
39
- return FPlane {FT} (2 rotation_rate* sind (latitude))
40
- elseif f != nothing && rotation_rate == nothing && latitude == nothing
47
+ use_f = ! isnothing (f)
48
+ use_planet_parameters = ! isnothing (latitude)
49
+
50
+ if ! xor (use_f, use_planet_parameters)
51
+ throw (ArgumentError (" Either both keywords rotation_rate and latitude must be " *
52
+ " specified, *or* only f must be specified." ))
53
+ end
54
+
55
+ if use_f
41
56
return FPlane {FT} (f)
42
- else
43
- throw (ArgumentError (" Either both keywords rotation_rate and
44
- latitude must be specified, *or* only f
45
- must be specified." ))
57
+ elseif use_planet_parameters
58
+ return FPlane {FT} (2 rotation_rate* sind (latitude))
46
59
end
47
60
end
48
61
57
70
"""
58
71
BetaPlane{T} <: AbstractRotation
59
72
60
- A parameter object for meridionally increasing Coriolis
61
- parameter (`f = f₀ + βy`).
73
+ A parameter object for meridionally increasing Coriolis parameter (`f = f₀ + βy`).
62
74
"""
63
75
struct BetaPlane{T} <: AbstractRotation
64
76
f₀ :: T
67
79
68
80
"""
69
81
BetaPlane([T=Float64;] f₀=nothing, β=nothing,
70
- rotation_rate=nothing , latitude=nothing, radius=nothing )
82
+ rotation_rate=Ω_Earth , latitude=nothing, radius=R_Earth )
71
83
72
84
A parameter object for meridionally increasing Coriolis parameter (`f = f₀ + βy`).
73
85
74
- The user may specify both `f₀` and `β`, or the three parameters
75
- `rotation_rate`, `latitude`, and `radius` that specify the rotation rate and radius
76
- of a planet, and the central latitude at which the `β`-plane approximation is to be made.
86
+ The user may specify both `f₀` and `β`, or the three parameters `rotation_rate`,
87
+ `latitude`, and `radius` that specify the rotation rate and radius of a planet, and
88
+ the central latitude at which the `β`-plane approximation is to be made.
89
+
90
+ By default, the `rotation_rate` and planet `radius` is assumed to be Earth's.
77
91
"""
78
92
function BetaPlane (T= Float64; f₀= nothing , β= nothing ,
79
- rotation_rate= nothing , latitude= nothing , radius= nothing )
93
+ rotation_rate= Ω_Earth , latitude= nothing , radius= R_Earth )
80
94
81
- f_and_β = f₀ != nothing && β != nothing
82
- planet_parameters = rotation_rate != nothing && latitude != nothing && radius != nothing
95
+ use_f_and_β = ! isnothing (f₀) && ! isnothing (β)
96
+ use_planet_parameters = ! isnothing ( latitude)
83
97
84
- (f_and_β && all ( Tuple (p === nothing for p in (rotation_rate, latitude, radius)))) ||
85
- (planet_parameters && all ( Tuple (p === nothing for p in (f₀, β)))) ||
86
- throw ( ArgumentError ( " Either both keywords f₀ and β must be specified,
87
- *or* all of rotation_rate, latitude, and radius. " ))
98
+ if ! xor (use_f_and_β, use_planet_parameters)
99
+ throw ( ArgumentError ( " Either both keywords f₀ and β must be specified, " *
100
+ " *or* all of rotation_rate, latitude, and radius. " ))
101
+ end
88
102
89
- if planet_parameters
103
+ if use_planet_parameters
90
104
f₀ = 2 rotation_rate * sind (latitude)
91
105
β = 2 rotation_rate * cosd (latitude) / radius
92
106
end
0 commit comments