1
$\begingroup$

I am trying to solve the following BVP in mathematica

enter image description here

using the following code:

    (*Define the parameters*)
radius = 1;
center = {0, 0};
startAngle = 0;
endAngle = Pi;
parameter = 10.0;(*Change this to your desired parameter*)(*Create a \
semi-circular mesh*)semiCircleMesh = 
 DiscretizeRegion[Disk[center, radius, {startAngle, endAngle}]];

(*Define the polar coordinates*)
r = Sqrt[x^2 + y^2];
\[Phi] = ArcTan[x, y];

(*Define the Poisson equation in polar coordinates with a parameter*)
\

\[CapitalOmega] = semiCircleMesh;
eqn = D[s[r, \[Phi]], {r, 2}] + (1/r) D[
      s[r, \[Phi]], {r, 1}] + (1/r^2) D[s[r, \[Phi]], {\[Phi], 2}] == 
   parameter^2*s[r, \[Phi]];

(*Define boundary conditions*)
boundaryCondition = {DirichletCondition[s[r, \[Phi]] == 0, True]};

(*Solve the polar PDE*)
sol = NDSolve[{eqn, boundaryCondition}, 
   s, {r, \[Phi]} \[Element] \[CapitalOmega]];

(*Visualize the solution*)
ContourPlot[
 Evaluate[s[r, \[Phi]] /. 
   sol], {r, \[Phi]} \[Element] \[CapitalOmega], AspectRatio -> 1, 
 Contours -> 20, ColorFunction -> "Potential", 
 PlotLegends -> Automatic, Axes -> True, AxesLabel -> {"r", "\[Phi]"}]

But I am confused how to define these four boundary condition and How to use FEM NDSolve for this problem?

$\endgroup$

1 Answer 1

2
$\begingroup$

in V 13.3.1

ClearAll["Global`*"];
k = 10;
pde = Laplacian[u[r, θ], {r, θ}, "Polar"] == k^2*u[r, θ];
bc = u[1, θ] == 1;
sol = NDSolveValue[{pde, bc}, u, {r, 0, 1}, {θ, 0, Pi}]

enter image description here

ParametricPlot3D[{r Cos[θ], r Sin[θ], sol[r, θ]}, {r, 0, 1}, {θ, 0, Pi}]

enter image description here

Neumann B.C. already build in by default so no need to specify.

Trying to draw a contour plot over a semi-circular region

ContourPlot[sol[Sqrt[x^2 + y^2], ArcTan[x, y]], {x, -1, 1}, {y, 0, 1},
  Contours -> 50, ColorFunction -> "Pastel", 
  AspectRatio -> Automatic,PlotLegends->Automatic]

enter image description here

ps. I tried ColorFunction -> "Potential" you used but that was not accepted, saying it could not find it.

$\endgroup$
1
  • $\begingroup$ Trying to get a contour plot of the solution over a semicircular region. Could you please help?? $\endgroup$
    – user94537
    Sep 22 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.