2
$\begingroup$

This question is connected with reference to my previous question (Solution of Dimensionless Partial Differential Equation Over a Semi-Circular Domain), where I asked for a help to solve the following BVP. enter image description here

I would like to thank Nasser (https://mathematica.stackexchange.com/users/70/nasser) for his kind help with the following code.

ClearAll["Global`*"];
k=5;
\[Alpha]=3*\[Pi]/4;
\[Eta]=0;
pde=Laplacian[u[r,\[Theta]],{r,\[Theta]},"Polar"]==k^2*u[r,\[Theta]];
bc=u[1,\[Theta]]==1-(1-\[Eta])*Piecewise[{{0,\[Theta]<\[Alpha]},{1,True}}]
sol=NDSolveValue[{pde,bc},u,{r,0,1},{\[Theta],0,Pi}]
ContourPlot[sol[Sqrt[x^2 + y^2], ArcTan[x, y]], {x, -1, 1}, {y, 0, 1},
  Contours -> 30, ColorFunction -> "LakeColors", AspectRatio -> Automatic,
  PlotLegends -> Automatic, PerformanceGoal -> "Quality", 
 PlotPoints -> 100,ContourStyle->None]

Now I have the following BVP which uses the solution of first one. enter image description here

I am trying proceed using the following code.

ClearAll["Global`*"];
k=5;
\[Alpha]=3*\[Pi]/4;
\[Eta]=0;
L=1;
pde1=Laplacian[s[r,\[Theta]],{r,\[Theta]},"Polar"]==k^2*s[r,\[Theta]];
bc1=s[1,\[Theta]]==1-(1-\[Eta])*Piecewise[{{0,\[Theta]<\[Alpha]},{1,True}}];
sol1=NDSolveValue[{pde1,bc1},s,{r,0,1},{\[Theta],0,Pi}]
pde2=Laplacian[u[r,\[Theta]],{r,\[Theta]},"Polar"]==-(4.0*L)-(k^2*s[r,\[Theta]]/.sol1);
bc2=u[1,\[Theta]]==0;
sol2=NDSolveValue[{pde2,bc2},u,{r,0,1},{\[Theta],0,Pi}]
ContourPlot[sol2[Sqrt[x^2 + y^2], ArcTan[x, y]], {x, -1, 1}, {y, 0, 1},
  Contours -> 20, ColorFunction -> "LakeColors", AspectRatio -> Automatic,
  PlotLegends -> Automatic, PerformanceGoal -> "Quality", 
 PlotPoints -> 75,ContourStyle->None]

But it shows some errors. How should I proceed correctly?

$\endgroup$

1 Answer 1

3
$\begingroup$

Since you used NDSolveValue to solve the first PDE, then you can use that solution in the second PDE using sol1[r,θ] and not as you had it s[r,θ]/.sol1

I also took the chance to change Piecewise to UnitStep as suggested in comment by UlrichNeumann on your earlier question. It seems simpler than using Piecewise as I did before. UnitStep does not cause same problem with NDSolve as HeavisideTheta did.

ClearAll["Global`*"];
k = 5;
α = 3*π/4;
η = 0;
L = 1;
pde1 = Laplacian[s[r, θ], {r, θ}, "Polar"] == k^2*s[r, θ];
bc1 = s[1, θ] == 1 - (1 - η)*UnitStep[θ - α];
sol1 = NDSolveValue[{pde1, bc1}, s, {r, 0, 1}, {θ, 0, Pi}];
pde2 = Laplacian[u[r, θ], {r, θ}, "Polar"] == -4*L - k^2*sol1[r, θ];
bc2 = u[1, θ] == 0;
sol2 = NDSolveValue[{pde2, bc2}, u, {r, 0, 1}, {θ, 0, Pi}]

Mathematica graphics

ContourPlot[
 sol2[Sqrt[x^2 + y^2], ArcTan[x, y]], {x, -1, 1}, {y, 0, 1}, 
 Contours -> 20, ColorFunction -> "LakeColors", 
 AspectRatio -> Automatic, PlotLegends -> Automatic, 
 PerformanceGoal -> "Quality", PlotPoints -> 75, ContourStyle -> None]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Thanks a lot for your response. $\endgroup$
    – user94537
    Sep 26 at 16: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.