 Contents of /trunk/doc/examples/usersguide/lame.py

Revision 5213 - (show annotations)
Wed Oct 22 05:59:37 2014 UTC (5 years ago) by jduplessis
File MIME type: text/x-python
File size: 2010 byte(s)
nlpde example for user guide
 1 #set up domain and symbols 2 from esys.escript import * 3 from esys.finley import Rectangle 4 from esys.weipa import saveSilo 5 mydomain = Rectangle(l0=1.,l1=1.,n0=10, n1=10) 6 u = Symbol('u',(2,), dim=2) 7 q = Symbol('q', (2,2)) 8 sigma=Symbol('sigma',(2,2)) 9 theta = Symbol('theta') 10 # q is a rotation matrix represented by a Symbol. Values can be substituted for 11 # theta. 12 q[0,0]=cos(theta) 13 q[0,1]=-sin(theta) 14 q[1,0]=sin(theta) 15 q[1,1]=cos(theta) 16 # Theta gets substituted by pi/4 and masked to lie between .3 and .7 in the 17 # vertical direction. Using this masking means that when q is used it will apply 18 # only to the specified area of the domain. 19 x = Function(mydomain).getX() 20 q=q.subs(theta,(symconstants.pi/4)*whereNonNegative(x-.30)*whereNegative(x-.70)) 21 # epsilon is defined in terms of u and has the rotation applied. 22 epsilon0 = symmetric(grad(u)) 23 epsilon = matrixmult(matrixmult(q,epsilon0),q.transpose(1)) 24 # For the purposes of demonstration, an arbitrary c with isotropic constraints 25 # is chosen here. In order to act as an isotropic material c is chosen such that 26 # c00 = c11 = c01+c1+2*c55 27 c00 = 10 28 c01 = 8; c11 = 10 29 c05 = 0; c15 = 0; c55 = 1 30 # sigma is defined in terms of epsilon 31 sigma[0,0] = c00*epsilon[0,0]+c01*epsilon[1,1]+c05*2*epsilon[1,0] 32 sigma[1,1] = c01*epsilon[0,0]+c11*epsilon[1,1]+c15*2*epsilon[1,0] 33 sigma[0,1] = c05*epsilon[0,0]+c15*epsilon[1,1]+c55*2*epsilon[1,0] 34 sigma[1,0] = sigma[0,1] 35 sigma0=matrixmult(matrixmult(q.transpose(1),sigma),q) 36 # set up boundary conditions 37 x=mydomain.getX() 38 gammaD=whereZero(x)*[1,1] 39 yconstraint = FunctionOnBoundary(mydomain).getX() 40 # The nonlinear PDE is set up, the values are substituted in and the solution is 41 # calculated y represents an external shearing force acting on the domain. 42 # In this case a force of magnitude 50 acting in the x direction. 43 p = NonlinearPDE(mydomain, u, debug=NonlinearPDE.DEBUG0) 44 p.setValue(X=sigma0,q=gammaD,y=[-50,0]*whereZero(yconstraint-1),r=[1,1]) 45 v = p.getSolution(u=[0,0]) 46 saveSilo("solution",solution=v)