Skip to content

Commit 44bd945

Browse files
Merge pull request #74 from inwoo-park/main
2 parents 2192420 + 58ae8d4 commit 44bd945

File tree

2 files changed

+98
-7
lines changed

2 files changed

+98
-7
lines changed

src/m/mech/basalstress.m

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
function [bx by b]=basalstress(md)
22
%BASALSTRESS - compute basal stress from basal drag and geometric information.
33
%
4-
% Computes basal stress from geometric information and ice velocity in md.initialization.
4+
% Computes basal stress from geometric information and ice velocity in md.initialization. Follows the basal stress definition in "src/c/classes/Loads/Friction.cpp", lines 1102-1136.
55
%
66
% Usage:
77
% [bx by b]=basalstress(md);
88
%
99
% See also: plot_basaldrag
1010

11+
%Check md.friction class
12+
if ~isa(md.friction,friction)
13+
error('Error: md.friction only supports "friction.m" class.');
14+
end
15+
1116
%compute exponents
1217
s=averaging(md,1./md.friction.p,0);
1318
r=averaging(md,md.friction.q./md.friction.p,0);
1419

1520
%Compute effective pressure
21+
g =md.constants.g;
22+
rho_ice =md.materials.rho_ice;
23+
rho_water=md.materials.rho_water;
24+
25+
sealevel=0;
26+
p_ice=g*rho_ice*md.geometry.thickness;
1627
switch(md.friction.coupling)
17-
case 0
18-
N = max(md.constants.g*(md.materials.rho_ice*md.geometry.thickness+md.materials.rho_water*md.geometry.base),0);
19-
case 3
20-
N = max(md.friction.effective_pressure, 0);
21-
otherwise
22-
error('not supported yet');
28+
case 0
29+
p_water=g*rho_water*(sealevel-md.geometry.base);
30+
N = p_ice-p_water;
31+
case 1
32+
N = p_ice;
33+
case 2
34+
p_water=g*rho_water*(sealevel-md.geometry.base);
35+
p_water=max(p_water,0.0);
36+
N = p_ice-p_water;
37+
case 3
38+
N = max(md.friction.effective_pressure, 0);
39+
case 4
40+
error('md.friction.coupling=4 is not supported yet.');
41+
otherwise
42+
error('not supported yet');
2343
end
2444

2545
%compute sliding velocity

src/m/mech/basalstress.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from friction import friction
2+
from averaging import averaging
3+
import numpy as np
4+
5+
def basalstress(md):
6+
'''
7+
BASALSTRESS - compute basal stress from basal drag and geometric information.
8+
9+
Computes basal stress from geometric information and ice velocity in md.initialization. Follows the basal stress definition in "src/c/classes/Loads/Friction.cpp", lines 1102-1136.
10+
11+
Usage:
12+
[bx by b]=basalstress(md);
13+
14+
See also: plot_basaldrag
15+
'''
16+
17+
#Check md.friction class
18+
if not isinstance(md.friction,friction):
19+
raise Exception('Error: md.friction only supports "friction.m" class.')
20+
21+
#compute exponents
22+
s=averaging(md,1/md.friction.p,0)
23+
r=averaging(md,md.friction.q/md.friction.p,0)
24+
25+
#Compute effective pressure
26+
g =md.constants.g
27+
rho_ice =md.materials.rho_ice
28+
rho_water=md.materials.rho_water
29+
30+
sealevel=0
31+
p_ice=g*rho_ice*md.geometry.thickness
32+
33+
coupling=md.friction.coupling
34+
if coupling==0:
35+
p_water=g*rho_water*(sealevel-md.geometry.base)
36+
N = p_ice-p_water
37+
elif coupling==1:
38+
N = p_ice
39+
elif coupling==2:
40+
p_water=g*rho_water*(sealevel-md.geometry.base)
41+
p_water=np.maximum(p_water,0.0)
42+
N = p_ice-p_water
43+
elif coupling==3:
44+
N = np.maximum(md.friction.effective_pressure,0.0)
45+
elif coupling==4:
46+
raise Exception('md.friction.coupling=4 is not supported yet.')
47+
else:
48+
raise Exception('not supported yet')
49+
50+
#compute sliding velocity
51+
ub=np.sqrt(md.initialization.vx**2+md.initialization.vy**2)/md.constants.yts
52+
ubx=md.initialization.vx/md.constants.yts
53+
uby=md.initialization.vy/md.constants.yts
54+
55+
#compute basal drag (S.I.)
56+
#reshape array to vector (N,)
57+
coefficient=np.ravel(md.friction.coefficient)
58+
N =np.ravel(N)
59+
r =np.ravel(r)
60+
s =np.ravel(s)
61+
ub =np.ravel(ub)
62+
ubx =np.ravel(ubx)
63+
uby =np.ravel(uby)
64+
65+
alpha2 = (N**r)*(md.friction.coefficient**2)*(ub**(s-1))
66+
b = alpha2*ub
67+
bx = -alpha2*ubx
68+
by = -alpha2*uby
69+
70+
#return magnitude of only one output is requested
71+
return bx, by, b

0 commit comments

Comments
 (0)