Skip to content

Commit e85507d

Browse files
Implement Weertman Sliding Law (#152)
* Fix issue with times for save simulation not being consistent between UDE and PDE * Little comment * add p and q to glacier * Update files to pass tests * updated docstrings
1 parent 7ba94a3 commit e85507d

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

src/glaciers/glacier/Glacier2D.jl

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ manually, but rather through the `initialize_glaciers` function.
3333
- `A::F`: Flow law parameter.
3434
- `C::F`: Sliding law parameter.
3535
- `n::F`: Flow law exponent.
36+
- `p::F`: Power law exponent associated to Weertman sliding law (Power associated to basal drag).
37+
- `q::F`: Power law exponent associated to Weertman sliding law (Power associated to normal pressure).
3638
- `slope::Matrix{F}`: Surface slope matrix.
3739
- `dist_border::Matrix{F}`: Distance to the glacier border matrix.
3840
- `mask::BitMatrix`: Boolean matrix representing the glacier mask, where true values indicate regions constrained by the mask (i.e., no-ice zones)
@@ -61,6 +63,8 @@ mutable struct Glacier2D{F <: AbstractFloat, I <: Integer, CLIM <: Climate2D, TH
6163
A::F
6264
C::F
6365
n::F
66+
p::F
67+
q::F
6468
slope::Matrix{F}
6569
dist_border::Matrix{F}
6670
mask::BitMatrix
@@ -91,6 +95,8 @@ end
9195
A::F = 0.0,
9296
C::F = 0.0,
9397
n::F = 0.0,
98+
p::F = 0.0,
99+
q::F = 0.0,
94100
slope::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
95101
dist_border::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
96102
mask::BitMatrix = BitMatrix([;;]),
@@ -127,6 +133,8 @@ Constructs a `Glacier2D` object with the given parameters, including default one
127133
- `A::F`: Flow law parameter.
128134
- `C::F`: Sliding law parameter.
129135
- `n::F`: Flow law exponent.
136+
- `p::F`: Power law exponent associated to Weertman sliding law (Power associated to basal drag).
137+
- `q::F`: Power law exponent associated to Weertman sliding law (Power associated to normal pressure).
130138
- `slope::Matrix{F}`: Slope matrix.
131139
- `dist_border::Matrix{F}`: Distance to border matrix.
132140
- `mask::BitMatrix`: Boolean matrix representing the glacier mask, where true values indicate regions constrained by the mask (i.e., no-ice zones)
@@ -158,6 +166,8 @@ function Glacier2D(;
158166
A::F = 0.0,
159167
C::F = 0.0,
160168
n::F = 0.0,
169+
p::F = 0.0,
170+
q::F = 0.0,
161171
slope::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
162172
dist_border::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
163173
mask::BitMatrix = BitMatrix([;;]),
@@ -179,7 +189,7 @@ function Glacier2D(;
179189
}
180190
return Glacier2D{Sleipnir.Float,Sleipnir.Int,typeof(climate),typeof(thicknessData),typeof(velocityData)}(
181191
rgi_id, name, climate, H₀, H_glathida,
182-
S, B, V, Vx, Vy, A, C, n,
192+
S, B, V, Vx, Vy, A, C, n, p, q,
183193
slope, dist_border, mask, Coords,
184194
Δx, Δy, nx, ny,
185195
cenlon, cenlat, params_projection,
@@ -216,7 +226,8 @@ function Glacier2D(
216226
typeof(glacier.climate),typeof(thicknessData),typeof(velocityData)
217227
}(
218228
glacier.rgi_id, glacier.name, glacier.climate, glacier.H₀, glacier.H_glathida,
219-
glacier.S, glacier.B, glacier.V, glacier.Vx, glacier.Vy, glacier.A, glacier.C, glacier.n,
229+
glacier.S, glacier.B, glacier.V, glacier.Vx, glacier.Vy,
230+
glacier.A, glacier.C, glacier.n, glacier.p, glacier.q,
220231
glacier.slope, glacier.dist_border, glacier.mask, glacier.Coords,
221232
glacier.Δx, glacier.Δy, glacier.nx, glacier.ny,
222233
glacier.cenlon, glacier.cenlat, glacier.params_projection,
@@ -232,7 +243,7 @@ end
232243
Base.:(==)(a::Glacier2D, b::Glacier2D) = a.rgi_id == b.rgi_id && a.name == b.name &&
233244
a.climate == b.climate &&
234245
a.H₀ == b.H₀ && a.H_glathida == b.H_glathida && a.S == b.S && a.B == b.B && a.V == b.V &&
235-
a.A == b.A && a.C == b.C && a.n == b.n &&
246+
a.A == b.A && a.C == b.C && a.n == b.n && a.p == b.p && a.q == b.q &&
236247
a.slope == b.slope && a.dist_border == b.dist_border && a.mask == b.mask &&
237248
a.Coords == b.Coords && a.Δx == b.Δx && a.Δy == b.Δy && a.nx == b.nx && a.ny == b.ny &&
238249
a.cenlon == b.cenlon && a.cenlat == b.cenlat &&
@@ -244,7 +255,7 @@ Base.:(≈)(a::Glacier2D, b::Glacier2D) = a.rgi_id == b.rgi_id && a.name == b.na
244255
a.climate == b.climate &&
245256
safe_approx(a.H₀, b.H₀) && safe_approx(a.H_glathida, b.H_glathida) &&
246257
safe_approx(a.S, b.S) && safe_approx(a.B, b.B) && safe_approx(a.V, b.V) &&
247-
a.A == b.A && a.C == b.C && a.n == b.n &&
258+
a.A == b.A && a.C == b.C && a.n == b.n && a.p == b.p && a.q == b.q &&
248259
isapprox(a.slope, b.slope; rtol=1e-3) &&
249260
safe_approx(a.dist_border, b.dist_border) &&
250261
a.mask == b.mask &&
@@ -266,6 +277,8 @@ diffToDict(a::Glacier2D, b::Glacier2D) = Dict{Symbol, Bool}(
266277
:A => a.A == b.A,
267278
:C => a.C == b.C,
268279
:n => a.n == b.n,
280+
:p => a.p == b.p,
281+
:q => a.q == b.q,
269282
:slope => a.slope == b.slope,
270283
:dist_border => a.dist_border == b.dist_border,
271284
:mask => a.mask == b.mask,
@@ -314,12 +327,16 @@ function Base.show(io::IO, glacier::Glacier2D)
314327
print(io, "Mean,max ice thickness H₀ : ")
315328
printstyled(io, "$(round(mean(glacier.H₀[glacier.H₀.>0]);digits=1)) $(round(maximum(glacier.H₀[glacier.H₀.>0]);digits=1))\n";color=:blue)
316329

317-
print(io, "A= ")
330+
print(io, "A = ")
318331
printstyled(io, @sprintf("%.3e", glacier.A); color=:blue)
319-
print(io, " C= ")
332+
print(io, " C = ")
320333
printstyled(io, glacier.C; color=:blue)
321-
print(io, " n= ")
334+
print(io, " n = ")
322335
printstyled(io, glacier.n; color=:blue)
336+
print(io, " p = ")
337+
printstyled(io, glacier.p; color=:blue)
338+
print(io, " q = ")
339+
printstyled(io, glacier.q; color=:blue)
323340

324341
if isnothing(glacier.thicknessData)
325342
printstyled(io, "\nw/o";color=:red)

src/glaciers/glacier/glacier2D_utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ function Glacier2D(
327327
name = name,
328328
climate = climate,
329329
H₀ = H₀, S = S, B = B, V = V, Vx = Vx, Vy = Vy,
330-
A = Sleipnir.Float(4e-17), C = Sleipnir.Float(0.0), n = Sleipnir.Float(3.0),
330+
A = Sleipnir.Float(4e-17), C = Sleipnir.Float(0.0),
331+
n = Sleipnir.Float(3.0), p = Sleipnir.Float(3.0), q = Sleipnir.Float(2.0),
331332
slope = slope, dist_border = dist_border, mask = mask,
332333
Coords = Coords, Δx = Δx, Δy = Δy, nx = nx, ny = ny,
333334
cenlon = cenlon, cenlat = cenlat,
120 Bytes
Binary file not shown.
120 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)