How to parameterize the linear elasticity example from tutorial?
5 months ago by
I am new to FeNiCS and beginner at coding in general. I was able to follow the Linear Elasticity example from the tutorial (3.3), and now I am trying to modify the code such that I can model the displacement according to variable values of young's modulus/poisson ratio. I am new to coding, so I am not sure how I can begin to change my constants into parameterized variables. Could someone show me an example program where this is done, or give me a push in the right direction?
Community: FEniCS Project
5 months ago by
from fenics import * mesh = UnitCubeMesh(4,4,4) FE = FiniteElement('Lagrange', mesh.ufl_cell(), 1) VFE = VectorElement(FE) V = FunctionSpace(mesh, VFE) u = Function(V) delu = TrialFunction(V) v = TestFunction(V) def bottom(x, on_boundary): return near(x,0.) def top(x, on_boundary): return near(x,1.) dbc = [DirichletBC(V, Constant((0.,0.,0.)), bottom), DirichletBC(V.sub(2), Constant(.1), top)] eye = Identity(3) eyOey = outer(eye,eye) eye4 = as_tensor(.5*(eye[i,k]*eye[j,l]+eye[i,l]*eye[j,k]), (i,j,k,l)) D4 = eye4 - 1./3.*eyOey # bulk and shear modulus, shear modulus as function of u K = 160e+9 def G(u): # just an example G0 = 80e+9 uzMax = .1 return G0*(1.-u/uzMax) #stiffness tensor def C4(u): return K*eyOey + G(u)*D4 #strain eps = sym(grad(u)) #stress def sigma(u): return as_tensor(C4(u)[i,j,k,l]*eps[k,l], (i,j)) #nonlinear form F = inner(grad(v),sigma(u))*dx #gateaux derivative J = derivative(F, u, delu) solve(F==0, u, dbc, J=J) File('disp.pvd') << u
Please login to add an answer/comment or follow this question.