I am trying to plot the first eigenvalue of the Laplacian operator with zero Dirichlet condition on following figure against decreasing values of $\varepsilon$.
I used Polygon
to create the first figure with $\varepsilon=0.9$:
r = Graphics[Polygon[{{0, 0}, {0, 1}, {1, 1}, {1, 0.9}, {2, 0.9}, {2, 1}, {3, 1}, {3, 0},
{2, 0}, {2, 0.1}, {1, 0.1}, {1, 0}}]];
Then used DiscretizeGraphics
to form the region:
dr = DiscretizeGraphics[r]
Using NDEigenSystem
the Eigenvalue was obatined.
{vals, funs} = NDEigensystem[
{-Laplacian[u[x, y], {x, y}], DirichletCondition[u[x, y] == 0, True]},
u[x, y], {x, y} ∈ dr, 1,
Method ->
{"SpatialDiscretization" -> {"FiniteElement",
{"MeshOptions" -> {"MaxCellMeasure" -> 0.01}}}}
];
For few epsilons I can use the process described above by changing the polygon, and drawing a new region. Like:
Clear[r, dr, vals, funs];
r = Graphics[Polygon[{{0, 0}, {0, 1}, {1, 1}, {1, 0.8}, {2, 0.8}, {2, 1}, {3, 1}, {3, 0},
{2, 0}, {2, 0.2}, {1, 0.2}, {1, 0}}]];
dr = DiscretizeGraphics[r]
{vals, funs} = NDEigensystem[
{-Laplacian[u[x, y], {x, y}], DirichletCondition[u[x, y] == 0, True]},
u[x, y], {x, y} ∈ dr, 1,
Method ->
{"SpatialDiscretization" -> {"FiniteElement",
{"MeshOptions" -> {"MaxCellMeasure" -> 0.01}}}}
];
list = Append[list, vals]
Flatten[%]
My question is, can this process by done within a loop?
Or is there in way to vary $\varepsilon$ without typing the above code block manually for different values of $\varepsilon$?
With[{ε = 0.2}, DiscretizeGraphics[Graphics[Polygon[{{0, 0}, {0, 1}, {1, 1}, {1, (1 + ε)/2}, {2, (1 + ε)/2}, {2, 1}, {3, 1}, {3, 0}, {2, 0}, {2, (1 - ε)/2}, {1, (1 - ε)/2}, {1, 0}}]]]]
. You can make aManipulate[]
out of this if you are so inclined. $\endgroup$Manipulate[]
. But that is not what I need. I need the whole process in a loop in the following logic order: (1) Draw and store the polygon (2) Discretize and store the polygon (3) Solve the eigensystem, append the required value in a list (4) Repeat steps 1 to 3 (5) Plot the list versus ε @J.M. $\endgroup$Table[]
. I've given you something to start with; you can embed the contents of theWith[]
in there along with the needed call toNDSolve[]
. $\endgroup$