I want to solve a simple diffuse equation in a cylinder.
$\nabla\cdot(\hat{c}\nabla\rho_P)=0$
$\rho_P(x,y,\theta)==0,\sqrt{x^2+y^2}=R$
$\rho_P(0,0,\theta)==1,\sqrt{x^2+y^2}=0$
$\rho_P(x,y,2\pi)=\rho_P(x,y,0)$
$\hat{c}=\begin{pmatrix} D_t& 0& 0 \\ 0 & D_t &0\\0 &0 &D_r \end{pmatrix} \quad$
$D_t: transportation\ coefficient$
$D_r: rotation\ coefficient$
Needs["NDSolve`FEM`"]
{R, Difft, Diffr} = {29.5, 1, 0.01};
\[CapitalOmega] = Cylinder[{{0, 0, 0}, {0, 0, 2 \[Pi]}}, R];
c = {{Difft, 0, 0}, {0, Difft, 0}, {0, 0, Diffr}};
With[{rhop = rhop[x, y, \[Theta]]},
op1 = Div[c . Grad[rhop, {x, y, \[Theta]}], {x, y, \[Theta]}]];
Subscript[\[CapitalGamma], D1] =
DirichletCondition[rhop[x, y, \[Theta]] == 1,
x^2 + y^2 == 0 && \[Theta] != 2 \[Pi]];
Subscript[\[CapitalGamma], D2] =
DirichletCondition[rhop[x, y, \[Theta]] == 0,
x^2 + y^2 > 0 && \[Theta] != 0 && \[Theta] != 2 \[Pi]];
Subscript[\[CapitalGamma], p] =
PeriodicBoundaryCondition[rhop[x, y, \[Theta]], \[Theta] == 2 \[Pi],
Function[\[Theta], \[Theta] - 2 \[Pi]]];
cylinderMesh =
ToElementMesh[\[CapitalOmega], "MaxBoundaryCellMeasure" -> 0.04];
npfun = NDSolveValue[{op1 == 0, Subscript[\[CapitalGamma], p],
Subscript[\[CapitalGamma], D1], Subscript[\[CapitalGamma], D2]},
rhop, {x, y, \[Theta]} \[Element] cylinderMesh];
ContourPlot[npfun[x, y, 2 \[Pi]], {x, y} \[Element] Disk[{0, 0}, R],
PlotRange -> All]
Obviously, it is a symmetrical function, but when I solve it using NDSolveValue
, the result is not symmetric.
I think I can solve it by adding
additionalPoints = {{0, 0, 0}, {0, 0, 2 \[Pi]}}
cylinderMesh =
ToElementMesh[\[CapitalOmega], "IncludePoints" -> additionalPoints];
Subscript[\[CapitalGamma], D2] = DirichletCondition[rhop[x, y, \[Theta]] == 0, x^2 + y^2 ==R^2 && \[Theta] != 0 && \[Theta] != 2 \[Pi]]
$\endgroup$Cylinder
suggest a 3D problem, but I'm missing an axialz
coordinate!? $\endgroup$Subscript[\[CapitalGamma], D1] = DirichletCondition[rhop[x, y, \[Theta]] == 1, x^2 + y^2 == 0 && \[Theta] != 0 && \[Theta] != 2 \[Pi]];
,Subscript[\[CapitalGamma], D2] = DirichletCondition[rhop[x, y, \[Theta]] == 0, x^2 + y^2 == R^2 && \[Theta] != 0 && \[Theta] != 2 \[Pi]];
there is a error:NDSolveValue::bcnop: No position was found on the boundary where x^2+y^2==0&&\[Theta]!=0&\[Theta]!=2 \[Pi] is true, so DirichletCondition[rhop==1,x^2+y^2==0&&\[Theta]!=0&&[Theta]!=2 \[Pi]]. will be ignored
$\endgroup$Subscript[\[CapitalGamma], D2]
already determines the solution, you cannot force b.c. atx^2+y^2==0
, because it's the removable singularity in cylindrical coordinates. Related: mathematica.stackexchange.com/questions/245195/… $\endgroup$