Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- << NDSolve`FEM`
- r = 0.8;
- outerCirclePoints =
- With[{r = 2.},
- Table[{r Cos[[Theta]], r Sin[[Theta]]}, {[Theta],
- Range[0, 2 [Pi], 0.05 [Pi]] // Most}]];
- innerCirclePoints =
- With[{r = r},
- Table[{r Cos[[Theta]], r Sin[[Theta]]}, {[Theta],
- Range[0, 2 [Pi], 0.08 [Pi]] // Most}]];
- bmesh = ToBoundaryMesh[
- "Coordinates" -> Join[outerCirclePoints, innerCirclePoints],
- "BoundaryElements" -> {LineElement[
- Riffle[Range[Length@outerCirclePoints],
- RotateLeft[Range[Length@outerCirclePoints], 1]] //
- Partition[#, 2] &],
- LineElement[
- Riffle[Range[Length@outerCirclePoints + 1,
- Length@Join[outerCirclePoints, innerCirclePoints]],
- RotateLeft[
- Range[Length@outerCirclePoints + 1,
- Length@Join[outerCirclePoints, innerCirclePoints]], 1]] //
- Partition[#, 2] &]}];
- mesh = ToElementMesh[bmesh];
- {bmesh["Wireframe"], mesh["Wireframe"]}
- glass = 1.45; air = 1.; k0 = (2 [Pi])/1.55;
- n[x_, y_] := If[x^2 + y^2 <= r^2, glass, air]
- helm = !(
- *SubsuperscriptBox[([Del]), ({x, y}), (2)](u[x, y])) +
- n[x, y]^2*k0^2*u[x, y];
- boundary = DirichletCondition[u[x, y] == 0., True];
- (*region=ImplicitRegion[x^2+y^2[LessEqual]2.^2,{x,y}];*)
- {vals, funs} =
- NDEigensystem[{helm, boundary}, u[x, y], {x, y} [Element] mesh, 1,
- Method -> {"Eigensystem" -> {"FEAST",
- "Interval" -> {k0^2, glass^2 k0^2}}}];
- vals
- Table[Plot3D[funs[[i]], {x, y} [Element] mesh, PlotRange -> All,
- PlotLabel -> vals[[i]]], {i, Length[vals]}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement