Changeset 21254 for issm/trunk-jpl/src/m/mech/mechanicalproperties.py
- Timestamp:
- 10/11/16 01:24:07 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/mech/mechanicalproperties.py
r19466 r21254 1 import numpy as np y1 import numpy as np 2 2 from GetNodalFunctionsCoeff import GetNodalFunctionsCoeff 3 3 from results import results … … 27 27 # raise StandardError('only 2D model supported currently') 28 28 29 if np y.any(md.flowequation.element_equation!=2):29 if np.any(md.flowequation.element_equation!=2): 30 30 print 'Warning: the model has some non SSA elements. These will be treated like SSA elements' 31 31 … … 35 35 if len(damage)!=md.mesh.numberofvertices: 36 36 raise ValueError('if damage is supplied it should be of size ' + md.mesh.numberofvertices) 37 if np y.ndim(damage)==2:37 if np.ndim(damage)==2: 38 38 damage=damage.reshape(-1,) 39 39 else: damage=None 40 40 41 if np y.ndim(vx)==2:41 if np.ndim(vx)==2: 42 42 vx=vx.reshape(-1,) 43 if np y.ndim(vy)==2:43 if np.ndim(vy)==2: 44 44 vy=vy.reshape(-1,) 45 45 … … 48 48 numberofvertices=md.mesh.numberofvertices 49 49 index=md.mesh.elements 50 summation=np y.array([[1],[1],[1]])51 directionsstress=np y.zeros((numberofelements,4))52 directionsstrain=np y.zeros((numberofelements,4))53 valuesstress=np y.zeros((numberofelements,2))54 valuesstrain=np y.zeros((numberofelements,2))50 summation=np.array([[1],[1],[1]]) 51 directionsstress=np.zeros((numberofelements,4)) 52 directionsstrain=np.zeros((numberofelements,4)) 53 valuesstress=np.zeros((numberofelements,2)) 54 valuesstrain=np.zeros((numberofelements,2)) 55 55 56 56 #compute nodal functions coefficients N(x,y)=alpha x + beta y +gamma … … 60 60 vxlist=vx[index-1]/md.constants.yts 61 61 vylist=vy[index-1]/md.constants.yts 62 ux=np y.dot((vxlist*alpha),summation).reshape(-1,)63 uy=np y.dot((vxlist*beta),summation).reshape(-1,)64 vx=np y.dot((vylist*alpha),summation).reshape(-1,)65 vy=np y.dot((vylist*beta),summation).reshape(-1,)62 ux=np.dot((vxlist*alpha),summation).reshape(-1,) 63 uy=np.dot((vxlist*beta),summation).reshape(-1,) 64 vx=np.dot((vylist*alpha),summation).reshape(-1,) 65 vy=np.dot((vylist*beta),summation).reshape(-1,) 66 66 uyvx=(vx+uy)/2. 67 67 #clear vxlist vylist 68 68 69 69 #compute viscosity 70 nu=np y.zeros((numberofelements,))71 B_bar=np y.dot(md.materials.rheology_B[index-1],summation/3.).reshape(-1,)70 nu=np.zeros((numberofelements,)) 71 B_bar=np.dot(md.materials.rheology_B[index-1],summation/3.).reshape(-1,) 72 72 power=((md.materials.rheology_n-1.)/(2.*md.materials.rheology_n)).reshape(-1,) 73 73 second_inv=(ux**2.+vy**2.+((uy+vx)**2.)/4.+ux*vy).reshape(-1,) 74 74 75 75 #some corrections 76 location=np y.nonzero(npy.logical_and(second_inv==0,power!=0))76 location=np.nonzero(np.logical_and(second_inv==0,power!=0)) 77 77 nu[location]=10^18 #arbitrary maximum viscosity to apply where there is no effective shear 78 78 79 79 if 'matice' in md.materials.__module__: 80 location=np y.nonzero(second_inv)80 location=np.nonzero(second_inv) 81 81 nu[location]=B_bar[location]/(second_inv[location]**power[location]) 82 location=np y.nonzero(npy.logical_and(second_inv==0,power==0))82 location=np.nonzero(np.logical_and(second_inv==0,power==0)) 83 83 nu[location]=B_bar[location] 84 location=np y.nonzero(npy.logical_and(second_inv==0,power!=0))84 location=np.nonzero(np.logical_and(second_inv==0,power!=0)) 85 85 nu[location]=10^18 86 86 elif 'matdamageice' in md.materials.__module__ and damage is not None: 87 87 print 'computing damage-dependent properties!' 88 Zinv=np y.dot(1-damage[index-1],summation/3.).reshape(-1,)89 location=np y.nonzero(second_inv)90 nu[location]=Zinv[location]*B_bar[location]/np y.power(second_inv[location],power[location])91 location=np y.nonzero(npy.logical_and(second_inv==0,power==0))88 Zinv=np.dot(1-damage[index-1],summation/3.).reshape(-1,) 89 location=np.nonzero(second_inv) 90 nu[location]=Zinv[location]*B_bar[location]/np.power(second_inv[location],power[location]) 91 location=np.nonzero(np.logical_and(second_inv==0,power==0)) 92 92 nu[location]=Zinv[location]*B_bar[location] 93 93 #clear Zinv … … 101 101 102 102 #compute principal properties of stress 103 for i in np y.arange(numberofelements):103 for i in np.arange(numberofelements): 104 104 105 105 #compute stress and strainrate matrices 106 stress=np y.array([ [tau_xx[i], tau_xy[i]], [tau_xy[i], tau_yy[i]] ])107 strain=np y.array([ [ux[i], uyvx[i]], [uyvx[i], vy[i]] ])106 stress=np.array([ [tau_xx[i], tau_xy[i]], [tau_xy[i], tau_yy[i]] ]) 107 strain=np.array([ [ux[i], uyvx[i]], [uyvx[i], vy[i]] ]) 108 108 109 109 #eigenvalues and vectors for stress 110 value,directions=np y.linalg.eig(stress);110 value,directions=np.linalg.eig(stress); 111 111 idx=abs(value).argsort()[::-1] # sort in descending order 112 112 value=value[idx] … … 116 116 117 117 #eigenvalues and vectors for strain 118 value,directions=np y.linalg.eig(strain);118 value,directions=np.linalg.eig(strain); 119 119 idx=abs(value).argsort()[::-1] # sort in descending order 120 120 value=value[idx] … … 133 133 stress.principalvalue2=valuesstress[:,1] 134 134 stress.principalaxis2=directionsstress[:,2:4] 135 stress.effectivevalue=1./np y.sqrt(2.)*npy.sqrt(stress.xx**2+stress.yy**2+2.*stress.xy**2)135 stress.effectivevalue=1./np.sqrt(2.)*np.sqrt(stress.xx**2+stress.yy**2+2.*stress.xy**2) 136 136 md.results.stress=stress 137 137 … … 144 144 strainrate.principalvalue2=valuesstrain[:,1]*md.constants.yts 145 145 strainrate.principalaxis2=directionsstrain[:,2:4] 146 strainrate.effectivevalue=1./np y.sqrt(2.)*npy.sqrt(strainrate.xx**2+strainrate.yy**2+2.*strainrate.xy**2)146 strainrate.effectivevalue=1./np.sqrt(2.)*np.sqrt(strainrate.xx**2+strainrate.yy**2+2.*strainrate.xy**2) 147 147 md.results.strainrate=strainrate 148 148 … … 155 155 deviatoricstress.principalvalue2=valuesstress[:,1] 156 156 deviatoricstress.principalaxis2=directionsstress[:,2:4] 157 deviatoricstress.effectivevalue=1./np y.sqrt(2.)*npy.sqrt(stress.xx**2+stress.yy**2+2.*stress.xy**2)157 deviatoricstress.effectivevalue=1./np.sqrt(2.)*np.sqrt(stress.xx**2+stress.yy**2+2.*stress.xy**2) 158 158 md.results.deviatoricstress=deviatoricstress 159 159
Note:
See TracChangeset
for help on using the changeset viewer.