Changeset 21341 for issm/trunk/src/m/mech/thomasparams.py
- Timestamp:
- 11/04/16 13:48:43 (8 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/mech/thomasparams.py
r17989 r21341 1 import numpy as npy1 import numpy as np 2 2 from averaging import averaging 3 3 … … 75 75 76 76 # checks: any of e1 or e2 equal to zero? 77 pos=np y.nonzero(e1==0)78 if np y.any(pos==1):77 pos=np.nonzero(e1==0) 78 if np.any(pos==1): 79 79 print 'WARNING: first principal strain rate equal to zero. Value set to 1e-13 s^-1' 80 80 e1[pos]=1.e-13 81 pos=np y.nonzero(e2==0)82 if np y.any(pos==1):81 pos=np.nonzero(e2==0) 82 if np.any(pos==1): 83 83 print 'WARNING: second principal strain rate equal to zero. Value set to 1e-13 s^-1' 84 84 e2[pos]=1.e-13 … … 89 89 90 90 if coordsys=='principal': 91 b=np y.zeros((md.mesh.numberofvertices,))91 b=np.zeros((md.mesh.numberofvertices,)) 92 92 ex=e1 93 93 a=e2/e1 94 pos=np y.nonzero(npy.logical_and(e1<0,e2>0)) # longitudinal compression and lateral tension94 pos=np.nonzero(np.logical_and(e1<0,e2>0)) # longitudinal compression and lateral tension 95 95 a[pos]=e1[pos]/e2[pos] 96 96 ex[pos]=e2[pos] 97 pos2=np y.nonzero(e1<0 & e2<0 & npy.abs(e1)<npy.abs(e2)) # lateral and longitudinal compression97 pos2=np.nonzero(e1<0 & e2<0 & np.abs(e1)<np.abs(e2)) # lateral and longitudinal compression 98 98 a[pos2]=e1[pos2]/e2[pos2] 99 99 ex[pos2]=e2[pos2] 100 pos3=np y.nonzero(e1>0 & e2>0 & npy.abs(e1)<npy.abs(e2)) # lateral and longitudinal tension100 pos3=np.nonzero(e1>0 & e2>0 & np.abs(e1)<np.abs(e2)) # lateral and longitudinal tension 101 101 a[pos3]=e1[pos3]/e2[pos3] 102 102 ex[pos3]=e2[pos3] 103 ind=np y.nonzero(e1<0 & e2<0)103 ind=np.nonzero(e1<0 & e2<0) 104 104 a[ind]=-a[ind] # where both strain rates are compressive, enforce negative alpha 105 sigxx=(np y.abs(ex)/((1.+a+a**2)**((n-1.)/2.)))**(1./n)*B105 sigxx=(np.abs(ex)/((1.+a+a**2)**((n-1.)/2.)))**(1./n)*B 106 106 elif coordsys=='xy': 107 107 ex=exx … … 110 110 elif coordsys=='longitudinal': 111 111 # using longitudinal strain rates defined by observed velocity vector 112 velangle=np y.arctan(md.initialization.vy/md.initialization.vx)113 pos=np y.nonzero(md.initialization.vx==0)114 velangle[pos]=np y.pi/2115 ex=0.5*(exx+eyy)+0.5*(exx-eyy)*np y.cos(2.*velangle)+exy*npy.sin(2.*velangle)112 velangle=np.arctan(md.initialization.vy/md.initialization.vx) 113 pos=np.nonzero(md.initialization.vx==0) 114 velangle[pos]=np.pi/2 115 ex=0.5*(exx+eyy)+0.5*(exx-eyy)*np.cos(2.*velangle)+exy*np.sin(2.*velangle) 116 116 ey=exx+eyy-ex # trace of strain rate tensor is invariant 117 exy=-0.5*(exx-eyy)*np y.sin(2.*velangle)+exy*npy.cos(2.*velangle)117 exy=-0.5*(exx-eyy)*np.sin(2.*velangle)+exy*np.cos(2.*velangle) 118 118 a=ey/ex 119 119 b=exy/ex … … 124 124 # a < -1 in areas of strong lateral compression or longitudinal compression and 125 125 # theta flips sign at a = -2 126 pos=np y.nonzero(npy.abs((npy.abs(a)-2.))<1.e-3)126 pos=np.nonzero(np.abs((np.abs(a)-2.))<1.e-3) 127 127 if len(pos)>0: 128 128 print 'Warning: ', len(pos), ' vertices have alpha within 1e-3 of -2' … … 131 131 if eq=='Weertman1D': 132 132 theta=1./8 133 a=np y.zeros((md.mesh.numberofvertices,))133 a=np.zeros((md.mesh.numberofvertices,)) 134 134 elif eq=='Weertman2D': 135 135 theta=1./9 136 a=np y.ones((md.mesh.numberofvertices,))136 a=np.ones((md.mesh.numberofvertices,)) 137 137 elif eq=='Thomas': 138 theta=((1.+a+a**2+b**2)**((n-1.)/2.))/(np y.abs(2.+a)**n)138 theta=((1.+a+a**2+b**2)**((n-1.)/2.))/(np.abs(2.+a)**n) 139 139 else: 140 140 raise ValueError('argument passed to "eq" not valid')
Note:
See TracChangeset
for help on using the changeset viewer.