This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Eigenvalues and Eigenmodes of Square

This example shows how to compute the eigenvalues and eigenmodes of a square domain using the programmatic workflow. For the PDE Modeler app solution, see Eigenvalues and Eigenmodes of Square: PDE Modeler App.

The eigenvalue PDE problem is -Δu=λu. This example finds the eigenvalues smaller than 10 and the corresponding eigenmodes.

Create a model. Import and plot the geometry. The geometry description file for this problem is called squareg.m.

model = createpde();
geometryFromEdges(model,@squareg);

pdegplot(model,'EdgeLabels','on')
ylim([-1.5,1.5])
axis equal

Specify the Dirichlet boundary condition u=0 for the left boundary.

applyBoundaryCondition(model,'dirichlet','Edge',4,'u',0);

Specify the zero Neumann boundary condition for the upper and lower boundary.

applyBoundaryCondition(model,'neumann','Edge',[1,3],'g',0,'q',0);

Specify the generalized Neumann condition un-34u=0 for the right boundary.

applyBoundaryCondition(model,'neumann','Edge',2,'g',0,'q',-3/4);

The eigenvalue PDE coefficients for this problem are c = 1, a = 0, and d = 1. You can enter the eigenvalue range r as the vector [-Inf 10].

specifyCoefficients(model,'m',0,'d',1,'c',1,'a',0,'f',0);
r = [-Inf,10];

Create a mesh and solve the problem.

generateMesh(model,'Hmax',0.05);
results = solvepdeeig(model,r);
              Basis= 10,  Time=   0.68,  New conv eig=  0
              Basis= 11,  Time=   0.71,  New conv eig=  0
              Basis= 12,  Time=   0.75,  New conv eig=  1
              Basis= 13,  Time=   0.79,  New conv eig=  1
              Basis= 14,  Time=   0.83,  New conv eig=  1
              Basis= 15,  Time=   0.88,  New conv eig=  1
              Basis= 16,  Time=   0.91,  New conv eig=  1
              Basis= 17,  Time=   0.95,  New conv eig=  1
              Basis= 18,  Time=   0.99,  New conv eig=  2
              Basis= 19,  Time=   1.02,  New conv eig=  2
              Basis= 20,  Time=   1.06,  New conv eig=  2
              Basis= 21,  Time=   1.09,  New conv eig=  3
              Basis= 22,  Time=   1.12,  New conv eig=  3
              Basis= 23,  Time=   1.14,  New conv eig=  4
              Basis= 24,  Time=   1.19,  New conv eig=  6
End of sweep: Basis= 24,  Time=   1.19,  New conv eig=  3
              Basis= 13,  Time=   1.44,  New conv eig=  0
              Basis= 14,  Time=   1.47,  New conv eig=  0
              Basis= 15,  Time=   1.52,  New conv eig=  0
              Basis= 16,  Time=   1.56,  New conv eig=  0
              Basis= 17,  Time=   1.62,  New conv eig=  0
              Basis= 18,  Time=   1.65,  New conv eig=  0
              Basis= 19,  Time=   1.68,  New conv eig=  0
              Basis= 20,  Time=   1.72,  New conv eig=  0
              Basis= 21,  Time=   1.79,  New conv eig=  0
              Basis= 22,  Time=   1.83,  New conv eig=  1
              Basis= 23,  Time=   1.88,  New conv eig=  2
End of sweep: Basis= 23,  Time=   1.88,  New conv eig=  0
              Basis= 13,  Time=   2.13,  New conv eig=  1
End of sweep: Basis= 13,  Time=   2.14,  New conv eig=  1
              Basis= 14,  Time=   2.31,  New conv eig=  0
              Basis= 15,  Time=   2.36,  New conv eig=  0
              Basis= 16,  Time=   2.42,  New conv eig=  0
              Basis= 17,  Time=   2.47,  New conv eig=  0
              Basis= 18,  Time=   2.52,  New conv eig=  0
              Basis= 19,  Time=   2.56,  New conv eig=  0
              Basis= 20,  Time=   2.59,  New conv eig=  0
              Basis= 21,  Time=   2.64,  New conv eig=  0
              Basis= 22,  Time=   2.69,  New conv eig=  0
              Basis= 23,  Time=   2.72,  New conv eig=  1
End of sweep: Basis= 23,  Time=   2.73,  New conv eig=  0
              Basis= 14,  Time=   2.98,  New conv eig=  1
End of sweep: Basis= 14,  Time=   2.98,  New conv eig=  1
              Basis= 15,  Time=   3.23,  New conv eig=  0
              Basis= 16,  Time=   3.26,  New conv eig=  0
              Basis= 17,  Time=   3.28,  New conv eig=  0
End of sweep: Basis= 17,  Time=   3.29,  New conv eig=  0

There are six eigenvalues smaller than 10 for this problem.

l = results.Eigenvalues
l = 5×1

   -0.4146
    2.0528
    4.8019
    7.2693
    9.4550

Plot the first and last eigenfunctions in the specified range.

u = results.Eigenvectors;
pdeplot(model,'XYData',u(:,1));

pdeplot(model,'XYData',u(:,length(l)));

This problem is separable, meaning

u(x,y)=f(x)g(y).

The functions f and g are eigenfunctions in the x and y directions, respectively. In the x direction, the first eigenmode is a slowly increasing exponential function. The higher modes include sinusoids. In the y direction, the first eigenmode is a straight line (constant), the second is half a cosine, the third is a full cosine, the fourth is one and a half full cosines, etc. These eigenmodes in the y direction are associated with the eigenvalues

0,π24,4π24,9π24,...

It is possible to trace the preceding eigenvalues in the eigenvalues of the solution. Looking at a plot of the first eigenmode, you can see that it is made up of the first eigenmodes in the x and y directions. The second eigenmode is made up of the first eigenmode in the x direction and the second eigenmode in the y direction.

Look at the difference between the first and the second eigenvalue compared to π2/4:

l(2) - l(1) - pi^2/4
ans = 1.6753e-07

Likewise, the fifth eigenmode is made up of the first eigenmode in the x direction and the third eigenmode in the y direction. As expected, l(5)-l(1) is approximately equal to π2:

l(5) - l(1) - pi^2
ans = 6.2135e-06

You can explore higher modes by increasing the search range to include eigenvalues greater than 10.