Skip to content

Commit 4d4796e

Browse files
committed
Change variable names '_s' -> 'p'
1 parent 8490ca4 commit 4d4796e

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

examples/L96m/L96m.jl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@ using Parameters # lets you have defaults for fields
2424
G = nothing
2525
end
2626

27-
function full(rhs::Array{<:Real,1}, z::Array{<:Real,1}, _s::L96m, t)
27+
function full(rhs::Array{<:Real,1}, z::Array{<:Real,1}, p::L96m, t)
2828
"""
2929
Compute full RHS of the Lorenz '96 multiscale system.
3030
The convention is that the first K variables are slow, while the rest K*J
3131
variables are fast.
3232
3333
Input:
3434
- `z` : vector of size (K + K*J)
35-
- `_s` : parameters
35+
- `p` : parameters
3636
- `t` : time (not used here since L96m is autonomous)
3737
3838
Output:
3939
- `rhs` : RHS computed at `z`
4040
4141
"""
4242

43-
K = _s.K
44-
J = _s.J
43+
K = p.K
44+
J = p.J
4545
x = @view(z[1:K])
4646
y = @view(z[K+1:end])
4747

4848
### slow variables subsystem ###
4949
# compute Yk averages
50-
Yk = compute_Yk(_s, z)
50+
Yk = compute_Yk(p, z)
5151

5252
# three boundary cases
5353
rhs[1] = -x[K] * (x[K-1] - x[2]) - x[1]
@@ -58,10 +58,10 @@ function full(rhs::Array{<:Real,1}, z::Array{<:Real,1}, _s::L96m, t)
5858
rhs[3:K-1] = -x[2:K-2] .* (x[1:K-3] - x[4:K]) - x[3:K-1]
5959

6060
# add forcing
61-
rhs[1:K] .+= _s.F
61+
rhs[1:K] .+= p.F
6262

6363
# add coupling w/ fast variables via averages
64-
rhs[1:K] .+= _s.hx * Yk
64+
rhs[1:K] .+= p.hx * Yk
6565

6666
### fast variables subsystem ###
6767
# three boundary cases
@@ -74,56 +74,56 @@ function full(rhs::Array{<:Real,1}, z::Array{<:Real,1}, _s::L96m, t)
7474

7575
# add coupling w/ slow variables
7676
for k in 1:K
77-
rhs[K+1 + (k-1)*J : K + k*J] .+= _s.hy * x[k]
77+
rhs[K+1 + (k-1)*J : K + k*J] .+= p.hy * x[k]
7878
end
7979

8080
# divide by epsilon
81-
rhs[K+1:end] ./= _s.eps
81+
rhs[K+1:end] ./= p.eps
8282

8383
return rhs
8484
end
8585

86-
function balanced(rhs::Array{<:Real,1}, x::Array{<:Real,1}, _s::L96m, t)
86+
function balanced(rhs::Array{<:Real,1}, x::Array{<:Real,1}, p::L96m, t)
8787
"""
8888
Compute balanced RHS of the Lorenz '96 multiscale system; i.e. only slow
8989
variables with the linear closure.
90-
Both `rhs` and `x` are vectors of size _s.K.
90+
Both `rhs` and `x` are vectors of size p.K.
9191
9292
Input:
9393
- `x` : vector of size K
94-
- `_s` : parameters
94+
- `p` : parameters
9595
- `t` : time (not used here since L96m is autonomous)
9696
9797
Output:
9898
- `rhs` : balanced RHS computed at `x`
9999
100100
"""
101101

102-
K = _s.K
102+
K = p.K
103103

104104
# three boundary cases
105-
rhs[1] = -x[K] * (x[K-1] - x[2]) - (1 - _s.hx*_s.hy) * x[1]
106-
rhs[2] = -x[1] * (x[K] - x[3]) - (1 - _s.hx*_s.hy) * x[2]
107-
rhs[K] = -x[K-1] * (x[K-2] - x[1]) - (1 - _s.hx*_s.hy) * x[K]
105+
rhs[1] = -x[K] * (x[K-1] - x[2]) - (1 - p.hx*p.hy) * x[1]
106+
rhs[2] = -x[1] * (x[K] - x[3]) - (1 - p.hx*p.hy) * x[2]
107+
rhs[K] = -x[K-1] * (x[K-2] - x[1]) - (1 - p.hx*p.hy) * x[K]
108108

109109
# general case
110-
rhs[3:K-1] = -x[2:K-2] .* (x[1:K-3] - x[4:K]) - (1 - _s.hx*_s.hy) * x[3:K-1]
110+
rhs[3:K-1] = -x[2:K-2] .* (x[1:K-3] - x[4:K]) - (1 - p.hx*p.hy) * x[3:K-1]
111111

112112
# add forcing
113-
rhs .+= _s.F
113+
rhs .+= p.F
114114

115115
return rhs
116116
end
117117

118-
function compute_Yk(_s::L96m, z::Array{<:Real,1})
118+
function compute_Yk(p::L96m, z::Array{<:Real,1})
119119
"""
120120
Reshape a vector of y_{j,k} into a matrix, then sum along one dim and divide
121121
by J to get averages
122122
"""
123123
return dropdims(
124-
sum( reshape(z[_s.K+1:end], _s.J, _s.K), dims = 1 ),
124+
sum( reshape(z[p.K+1:end], p.J, p.K), dims = 1 ),
125125
dims = 1
126-
) / _s.J
126+
) / p.J
127127
end
128128

129129

0 commit comments

Comments
 (0)