|
| 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