### Elasticity 2D answer not correct

315

views

1

Hi,

I am novice to FEniCS. I am trying to solve the 2D elasticity problem. I have not applied any body force. I have just applied a Dirichlet BC on right and fixed the left edge of a square plate. I expect a linear varying displacement. But I am not getting it. I am getting constant displacement throughout the domain. Please find the code and help me.

Thanks

Version: 1.6.0

I am novice to FEniCS. I am trying to solve the 2D elasticity problem. I have not applied any body force. I have just applied a Dirichlet BC on right and fixed the left edge of a square plate. I expect a linear varying displacement. But I am not getting it. I am getting constant displacement throughout the domain. Please find the code and help me.

Thanks

Version: 1.6.0

```
import numpy as np
from dolfin import *
mesh=UnitSquareMesh(5,5)
V = VectorFunctionSpace(mesh,'P',1)
E = 10e5
nu = 0.28
tol = 1e-14
mu = E/(2*(1+nu))
lamb = E*nu/((1+nu)*(1-2*nu))
def clamped_boundary(x,on_boundary):
return on_boundary and x[0]<tol
bc1 = DirichletBC(V,Constant((0,0)),clamped_boundary)
def right(x,on_boundary):
return on_boundary and (x[0]-1)<tol
bc2 = DirichletBC(V.sub(0),Constant((1.0)),right)
bc=[bc1,bc2]
def epsilon(u):
return 0.5*(grad(u)+grad(u).T)
def sigma(u):
return lamb*(tr(grad(u))*Identity(d))+2*mu*epsilon(u)
u = TrialFunction(V)
d = u.geometric_dimension()
v = TestFunction(V)
form = inner(sigma(u),epsilon(v))*dx
a = lhs(form)
L = rhs(form)
u = Function(V)
solve(a == L,u,bc)
u1,u2=u.split()
plot(u,mode='displacement',interactive=True)
```

Community: FEniCS Project

### 1 Answer

8

The problem is that in your definition of right, every point satisfies the condition (x[0]-1)<tol.

You should use abs(x[0]-1)<tol or, better yet, near(x[0], 1).

You should use abs(x[0]-1)<tol or, better yet, near(x[0], 1).

Thanks! It is resolved now.

written
13 days ago by
Peter James

Please login to add an answer/comment or follow this question.