# pdeeig

Solve eigenvalue PDE problem

## Syntax

• ``````[v,l] = pdeeig(model,c,a,d,r)``````
example
• ``````[v,l] = pdeeig(b,p,e,t,c,a,d,r)``````
example
• ``````[v,l] = pdeeig(Kc,B,M,r)``````
example

## Description

example

``````[v,l] = pdeeig(model,c,a,d,r)``` produces the solution to the FEM formulation of the scalar PDE eigenvalue problemor the system PDE eigenvalue problemwith geometry, boundary conditions, and mesh specified in `model`, a `PDEModel` object. See Solve Problems Using PDEModel Objects.The eigenvalue PDE problem is a homogeneous problem, i.e., only boundary conditions where g = 0 and r = 0 can be used. The nonhomogeneous part is removed automatically.```

example

``````[v,l] = pdeeig(b,p,e,t,c,a,d,r)``` solves for boundary conditions described in `b`, and the finite element mesh in `[p,e,t]`.```

example

``````[v,l] = pdeeig(Kc,B,M,r)``` produces the solution to the generalized sparse matrix eigenvalue problemKc ui = λB´MBuiu = Bui with Real(λ) in the interval r.```

## Examples

collapse all

### Eigenvalues and Eigenvectors of the L-Shaped Membrane

Compute the eigenvalues that are less than 100, and compute the corresponding eigenmodes for

–∇u = λu

on the geometry of the L-shaped membrane.

```model = createpde; geometryFromEdges(model,@lshapeg); applyBoundaryCondition(model,'Edge',1:model.Geometry.NumEdges,'u',0); generateMesh(model,'Hmax',0.02); c = 1; a = 0; d = 1; r = [-Inf 100]; [v,l] = pdeeig(model,c,a,d,r); l(1) % first eigenvalue```
```ans = 9.6481```

Display the first eigenmode, and compare it to the built-in `membrane` plot.

`pdeplot(model,'xydata',v(:,1),'zdata',v(:,1));`

```figure membrane(1,20,9,9) % the MATLAB function```

Compute the sixteenth eigenvalue, and plot the sixteenth eigenmode.

`l(16) % sixteenth eigenvalue`
```ans = 92.4658```
```figure pdeplot(model,'xydata',v(:,16),'zdata',v(:,16)); % sixteenth eigenmode```

### Eigenvalues and Eigenvectors of the L-Shaped Membrane Using Legacy Syntax

Compute the eigenvalues that are less than 100, and compute the corresponding eigenmodes for

–∇u = λu

on the geometry of the L-shaped membrane, using the legacy syntax.

Use the geometry in `lshapeg`. For more information about this syntax, see Create Geometry Using a Geometry Function.

```g = @lshapeg; pdegplot(g,'EdgeLabels','on') axis equal ylim([-1.1,1.1])```

Set zero Dirichlet boundary conditions using the `lshapeb` function. For more information about this syntax, see Boundary Conditions by Writing Functions.

`b = @lshapeb;`

Set coefficients c = 1, a = 0, and d = 1. Collect eigenvalues from 0 through 100.

```c = 1; a = 0; d = 1; r = [-Inf 100];```

Generate a mesh and solve the eigenvalue problem.

```[p,e,t] = initmesh(g,'Hmax',0.02); [v,l] = pdeeig(b,p,e,t,c,a,d,r);```

Find the first eigenvalue.

`l(1)`
```ans = 9.6481```

### Eigenvalues and Eigenvectors Using Finite Element Matrices

Import a simple 3-D geometry and find eigenvalues and eigenvectors from the associated finite element matrices.

Create a model and import the `'BracketWithHole.stl'` geometry.

```model = createpde(); importGeometry(model,'BracketWithHole.stl'); h = pdegplot(model,'FaceLabels','on'); h(1).FaceAlpha = 0.5;```

Set coefficients c = 1, a = 0, and d = 1. Collect eigenvalues from 0 through 100.

```c = 1; a = 0; d = 1; r = [-Inf 100];```

Generate a mesh for the model.

`generateMesh(model);`

Create the associated finite element matrices.

```[Kc,~,B,~] = assempde(model,c,a,0); [~,M,~] = assema(model,0,d,0);```

Solve the eigenvalue problem.

`[v,l] = pdeeig(Kc,B,M,r);`

Look at the first two eigenvalues.

`l([1,2])`
```ans = -0.0000 42.7872 ```

Plot the solution corresponding to eigenvalue 2.

`pdeplot3D(model,'colormapdata',v(:,2))`

## Input Arguments

collapse all

### `model` — PDE model`PDEModel` object

PDE model, specified as a `PDEModel` object.

Example: `model = createpde(1)`

### `c` — PDE coefficientscalar or matrix | character array | coefficient function

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. `c` represents the c coefficient in the scalar PDE

or the system PDE eigenvalue problem

There are a wide variety of ways of specifying `c`, detailed in c Coefficient for Systems. See also Scalar PDE Coefficients, Specify Scalar PDE Coefficients in String Form, Specify 2-D Scalar Coefficients in Function Form, Specify 3-D PDE Coefficients in Function Form, and Coefficients for Systems of PDEs.

Example: `'cosh(x+y.^2)'`

Data Types: `double` | `char` | `function_handle`
Complex Number Support: Yes

### `a` — PDE coefficientscalar or matrix | character array | coefficient function

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. `a` represents the a coefficient in the scalar PDE

or the system PDE eigenvalue problem

There are a wide variety of ways of specifying `a`, detailed in a or d Coefficient for Systems. See also Scalar PDE Coefficients, Specify Scalar PDE Coefficients in String Form, Specify 2-D Scalar Coefficients in Function Form, Specify 3-D PDE Coefficients in Function Form, and Coefficients for Systems of PDEs.

Example: `2*eye(3)`

Data Types: `double` | `char` | `function_handle`
Complex Number Support: Yes

### `d` — PDE coefficientscalar or matrix | character array | coefficient function

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. `d` represents the d coefficient in the scalar PDE

or the system PDE eigenvalue problem

There are a wide variety of ways of specifying `d`, detailed in a or d Coefficient for Systems. See also Scalar PDE Coefficients, Specify Scalar PDE Coefficients in String Form, Specify 2-D Scalar Coefficients in Function Form, Specify 3-D PDE Coefficients in Function Form, and Coefficients for Systems of PDEs.

Example: `2*eye(3)`

Data Types: `double` | `char` | `function_handle`
Complex Number Support: Yes

### `r` — Eigenvalue rangetwo-element real vector

Eigenvalue range, specified as a two-element real vector. Real parts of eigenvalues λ fall in the range `r(1)` ≤ λ ≤ `r(2)`. `r(1)` can be `-Inf`. The algorithm returns all eigenvalues in this interval in the `l` output, up to a maximum of 99 eigenvalues.

Example: `[-Inf,100]`

Data Types: `double`

### `b` — Boundary conditionsboundary matrix | boundary file

Boundary conditions, specified as a boundary matrix or boundary file. Pass a boundary file as a function handle or as a string naming the file.

For more information on boundary conditions, see Forms of Boundary Condition Specification.

Example: `b = 'circleb1'` or equivalently ```b = @circleb1```

Data Types: `double` | `char` | `function_handle`

### `p` — Mesh nodesoutput of `initmesh` | output of `meshToPet`

Mesh nodes, specified as the output of `initmesh` or `meshToPet`. For the structure of a `p` matrix, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

Example: `[p,e,t] = initmesh(g)`

Data Types: `double`

### `e` — Mesh edgesoutput of `initmesh` | output of `meshToPet`

Mesh edges, specified as the output of `initmesh` or `meshToPet`. For the structure of `e`, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

Example: `[p,e,t] = initmesh(g)`

Data Types: `double`

### `t` — Mesh elementsoutput of `initmesh` | output of `meshToPet`

Mesh elements, specified as the output of `initmesh` or `meshToPet`. Mesh elements are the triangles or tetrahedra that form the finite element mesh. For the structure of a `t` matrix, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

Example: `[p,e,t] = initmesh(g)`

Data Types: `double`

### `Kc` — Stiffness matrixsparse matrix | full matrix

Stiffness matrix, specified as a sparse matrix or as a full matrix. See Elliptic Equations. Typically, `Kc` is the output of `assempde`.

### `B` — Dirichlet nullspacesparse matrix

Dirichlet nullspace, returned as a sparse matrix. See Algorithms. Typically, `B` is the output of `assempde`.

### `M` — Mass matrixsparse matrix | full matrix

Mass matrix. specified as a sparse matrix or a full matrix. See Elliptic Equations.

To obtain the input matrices for `pdeeig`, `hyperbolic` or `parabolic`, run both `assema` and `assempde`:

```[Kc,Fc,B,ud] = assempde(model,c,a,f); [~,M,~] = assema(model,0,d,f);```
 Note:   Create the `M` matrix using `assema` with `d`, not `a`, as the argument before `f`.

Data Types: `double`
Complex Number Support: Yes

## Output Arguments

collapse all

### `v` — Eigenvectorsmatrix

Eigenvectors, returned as a matrix. Suppose

• `Np` is the number of mesh nodes

• N is the number of equations

• `ev` is the number of eigenvalues returned in `l`

Then `v` has size `Np`*N-by-`ev`. Each column of `v` corresponds to the eigenvectors of one eigenvalue. In each column, the first `Np` elements correspond to the eigenvector of equation 1 evaluated at the mesh nodes, the next `Np` elements correspond to equation 2, etc.

 Note:   Eigenvectors are determined only up to multiple by a scalar, including a negative scalar.

### `l` — Eigenvaluesvector

Eigenvalues, returned as a vector. The real parts of `l` are in the interval `r`. The real parts of `l` are monotone increasing.

## Limitations

In the standard case c and d are positive in the entire region. All eigenvalues are positive, and 0 is a good choice for a lower bound of the interval. The cases where either c or d is zero are discussed next.

• If d = 0 in a subregion, the mass matrix M becomes singular. This does not cause any trouble, provided that c > 0 everywhere. The pencil (K,M) has a set of infinite eigenvalues.

• If c = 0 in a subregion, the stiffness matrix `K` becomes singular, and the pencil (K,M) has many zero eigenvalues. With an interval containing zero, `pdeeig` goes on for a very long time to find all the zero eigenvalues. Choose a positive lower bound away from zero but below the smallest nonzero eigenvalue.

• If there is a region where both c = 0 and d = 0, we get a singular pencil. The whole eigenvalue problem is undetermined, and any value is equally plausible as an eigenvalue.

Some of the awkward cases are detected by `pdeeig`. If the shifted matrix is singular, another shift is attempted. If the matrix with the new shift is still singular a good guess is that the entire pencil (K,M) is singular.

If you try any problem not belonging to the standard case, you must use your knowledge of the original physical problem to interpret the results from the computation.

expand all

### Algorithms

`pdeeig` calls `sptarn` to calculate eigenvalues. For details of the algorithm, see the `sptarn` reference pages.