# Boundary conditions for systems of equations

**URL:** <https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625>\
**Category:** Uncategorized\
**Created:** [November 26, 2020, 12:22pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625 "2020-11-26T12:22:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nico\_Su](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nico_su/32/1123_2.png) [@Nico\_Su](https://fenicsproject.discourse.group/u/Nico_Su)\
**Post date:** [November 26, 2020, 12:22pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/1 "2020-11-26T12:22:45Z")

</div>

Dear all,

i am still quite new to FEniCS and am working on the biharmonic equation by reducing the system, so i can use H1 elements. However i want to calculate the eigenvalues of a clamped plate, my code right now produces eigenvalues for a simply supported plate, i am certain that the boundary conditions are the problem.  
The boundary conditions are the dirichlet boundary 0 and the second needed boundary is that the normal derivative on the boundary is also 0. My initial thought was that the neumann boundary wasn’t neccesary to add, because it is either way 0.

Thanks in advance for every suggestion!  
The code is the following:

```auto
mesh = UnitSquareMesh(10,10)
X = FiniteElement('CG', mesh.ufl_cell(), 2)
Y = FiniteElement('CG', mesh.ufl_cell(), 2)
Z = X * Y
S = FunctionSpace(mesh, Z)

u = TrialFunctions(S)
phi = TestFunctions(S)

a = inner(grad(u[1]), grad(phi[0]))*dx + inner(grad(u[0]), grad(phi[1]))*dx

def boundary(x, on_boundary):
    return on_boundary

bc = DirichletBC(S, Constant((0.0,0.0)), boundary)

g = Constant(0.0)
L_dummy = Constant(0)*phi[0]*dx
m = u[0]*phi[0]*dx + u[1]*phi[1]*dx 

A, _ = assemble_system(a,L_dummy,bc)
B = assemble(m)
eigensolver = SLEPcEigenSolver(as_backend_type(A), as_backend_type(B))
eigensolver.parameters['spectrum'] = 'target real'
eigensolver.parameters['tolerance'] = 1e-6
eigensolver.solve()
r, c, rx, cx = eigensolver.get_eigenpair(0)
print("Eigenvalue: ", r)
ef = Function(S)
ef.vector()[:] = rx
plot(ef[0])
plt.show()
```

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [November 26, 2020, 3:46pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/2 "2020-11-26T15:46:52Z")

</div>

You can set a `DirichletBC` on subspaces, e.g.

```auto
DirichletBC(S.sub(0), Constant(0.0), boundary)

```

---

<div class="post-metadata">

**Author:** ![Nico\_Su](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nico_su/32/1123_2.png) [@Nico\_Su](https://fenicsproject.discourse.group/u/Nico_Su)\
**Post date:** [November 26, 2020, 3:58pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/3 "2020-11-26T15:58:51Z")

</div>

Hi, thanks for the hint! I immediately treid it, however i get an error indicating that the SLEPcEigensolver is now unable to extract the eigenpair. The message being:  
\*\*\* Error: Unable to extract eigenpair from SLEPc eigenvalue solver.  
\*\*\* Reason: Requested eigenpair (0) has not been computed.  
\*\*\* Where: This error was encountered inside SLEPcEigenSolver.cpp.  
\*\*\* Process: 0

* * *

\*\*\* DOLFIN version: 2019.2.0.dev0  
\*\*\* Git changeset: unknown

---

<div class="post-metadata">

**Author:** ![Nico\_Su](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nico_su/32/1123_2.png) [@Nico\_Su](https://fenicsproject.discourse.group/u/Nico_Su)\
**Post date:** [November 26, 2020, 4:16pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/4 "2020-11-26T16:16:57Z")

</div>

Minor update: i tried your solution for two subdomains and now don’t get any error message, however the same result, as to begin with. But still thanks for your hint and your time.

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [November 26, 2020, 4:28pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/5 "2020-11-26T16:28:39Z")

</div>

You could examine the output of the eigenvalue solver to see why it’s not converged with [`eps_view`](https://slepc.upv.es/documentation/current/docs/manualpages/EPS/EPSView.html).

Are you sure it’s possible to enforce a clamped BC with the Ciarlet Raviart element?

---

<div class="post-metadata">

**Author:** ![Nico\_Su](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nico_su/32/1123_2.png) [@Nico\_Su](https://fenicsproject.discourse.group/u/Nico_Su)\
**Post date:** [November 26, 2020, 4:37pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/6 "2020-11-26T16:37:00Z")

</div>

It does converge if i use your line of code twice

```auto
bc0 = DirichletBC(S.sub(0), Constant(0.0), boundary)
bc1 = DirichletBC(S.sub(1), Constant(0.0), boundary)

bcs = [bc0, bc1]
```

The element i use is the regular lagrange element “CG”. But i’ll keep in mind for future projects, that there is a possibility to examine the output more closely  
Now the value is the problem on a unit square plate the first eigenvalue is 35.9861 in the reference i want to validate my work with. The value i get is 19.74058961530659 which is the same value i found in a thesis about supported unit square plates.

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [November 26, 2020, 4:42pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/7 "2020-11-26T16:42:37Z")

</div>

The Ciarlet Raviart method solves the biharmonic problem by an operator splitting, see e.g. [here](https://epubs.siam.org/doi/abs/10.1137/0724048?journalCode=sjnaam). This seems to be exactly what you’re trying to do.

Applying the homogeneous BC to each subspace is equivalent to applying the homogeneous BC to the whole space.

Perhaps consider this excellent example of [Timoshenko beam buckling](https://comet-fenics.readthedocs.io/en/latest/demo/beam_buckling/beam_buckling.html), or [fenics-shells](https://bitbucket.org/unilucompmech/fenics-shells).

---

<div class="post-metadata">

**Author:** ![Nico\_Su](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nico_su/32/1123_2.png) [@Nico\_Su](https://fenicsproject.discourse.group/u/Nico_Su)\
**Post date:** [November 28, 2020, 4:27pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-systems-of-equations/4625/8 "2020-11-28T16:27:48Z")

</div>

Hi Nate, me and my supervisor reviewed what you linked in your last replay and we found it very usefull. I just wanted to give you an update and thank you for your help!
