# Using multiple boundary conditions with NDEigensystem

I'm quite new to Mathematica and to Stack Exchange so I apologise if this question has already been answered.

I've recently been trying to solve a partial differential equation to find the eigenvalues and eigenfunctions with NDEigensystem. I'm trying to enter multiple boundary conditions into NDEigensystem but I keep getting the following error:

NDEigensystem::dvlen: The function u[-x,y] does not have the same number of arguments as independent variables (3).

The following is my code.

keyhole = ImplicitRegion[x^2 + y^2 >= 1, {{x, -1/2, 1/2}, {y, 0.0001, 50}}];

NDEigensystem[{-y^2 (D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}]), u[-1/2, y] == u[1/2, y], DirichletCondition[u[x, y] ==  u[-x, y], x^2 + y^2 == 1]},u[x, y], {x, y} \[Element] keyhole, 2]


I believe the error may be due to a syntax error with the DirichletCondition option or because I have too many boundary conditions.

I would really appreciate your input on what I'm doing wrong currently.

Update Based on @user21's comments, I was able to implement PeriodicBoundaryCondition to get the boundary conditions that I wanted. However, I am now encountering a new problem when I specify the domain keyhole. Whenever I set 0.0001<=y <= ymax, and ymax >= 100, I get the following error message:

Eigensystem::herm: The matrix SparseArray[Automatic,<<2>>,{1,{{<<1>>},{<<1>>}},{(lots of numbers here)}] is not Hermitian or real and symmetric


Is there a way that I can modify my code to allow me to increase the domain where the eigenfunction gets solved?

Thank you again for all your help. My updated code is as follows.

keyhole = ImplicitRegion[x^2 + y^2 >= 1, {{x, -1/2, 1/2}, {y, 0.0001,100}}];
test = NDEigensystem[{-y^2 (D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}]),PeriodicBoundaryCondition[u[x, y], x == -1/2,TranslationTransform[{1, 0}]],PeriodicBoundaryCondition[u[x, y], x^2 + y^2 == 1, Function[x, {{-1, 0}, {0, 1}}.x]]}, u[x, y], {x, y} \[Element] keyhole, 4];
Table[Plot3D[test[[2]][[i]], {x, y} \[Element] keyhole, PlotRange -> All,MeshStyle -> None, PlotLabel -> test[[1]][[i]], AxesLabel -> {"x", "y", ""}], {i, 1, 4}]

• I think PeriodicBoundaryCondition might do what you want here. Commented May 16, 2019 at 3:59
• What do you want to express with DirichletCondition[u[x, y] == u[-x, y], x^2 + y^2 == 1]? Commented May 16, 2019 at 5:04
• @sr101studios Read the tutorial: Eigensystems with inhomogeneous Dirichlet conditions cannot be solved. Commented May 16, 2019 at 14:36
• @user21 I used PeriodicBoundaryCondition and I got the code to work. For example, when I specify keyhole = ImplicitRegion[x^2 + y^2 >= 1, {{x, -1/2, 1/2}, {y, 0.0001, ymax}}] with ymax <= 100, it works. However, I encounter a problem for ymax > 100. I keep getting the error Eigensystem::herm: The matrix SparseArray[Automatic,<<2>>,{1,{{<<1>>},{<<1>>}},{(lots of numbers here)}] is not Hermitian or real and symmetric. Do you know what might be going on and how I can resolve this? I've edited my original post with the new code. Commented May 17, 2019 at 23:18
• @ThiesHeidecke, thank you for your help. I have slightly new issue now which I was wondering if you could help with. It's in my above comment and I've edited my initial post to describe it. Thank you again for your help. Commented May 17, 2019 at 23:20

Here it is necessary to use homogeneous boundary conditions. We can also investigate the influence of the size of the area along y, including ymax=50 .

p[L_, n_] :=
Block[{ymax = L, nmax = n},
keyhole =
ImplicitRegion[x^2 + y^2 >= 1, {{x, -1/2, 1/2}, {y, 0.0001, ymax}}];
{v, f} =
NDEigensystem[{-y^2 (D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}]),
DirichletCondition[u[x, y] == 0, True]},
u[x, y], {x, y} \[Element] keyhole, nmax];
Table[Plot3D[f[[i]], {x, y} \[Element] keyhole, PlotRange -> All,
Mesh -> None, PlotLabel -> v[[i]], ColorFunction -> "Rainbow",
AxesLabel -> {"x", "y", ""}], {i, 1, nmax}]]
Table[p[L, 2], {L, {5, 10, 25, 50}}]


• Thank you, Alex! I really appreciate your comments and your updating of the code. The plots looks brilliant. However, I'm not sure how the necessary boundary conditions are being implemented in your example. I think it's important for this system to have the boundary condition u[1/2, y] = u[-1/2, y] and the condition that on the unit circle, u[x,y] = u[-x,y]. However, I'm not sure if your code is implementing those conditions. Do you think it's possible to have boundary conditions like that in our region? Thank you for your help. Commented May 16, 2019 at 16:40
• @sr101studios It is obvious that u[1/2,y]=u[-1/2,y]=0 and u[x,y]=u[-x,y]=0 at x^2+y^2=1, all this is in DirichletCondition[u[x, y] == 0, True]. Commented May 16, 2019 at 17:08