# NDSolveValue and DirchletConditions for cylindrical disk

my aim in this is to model the current flow of a cylindrical disk with one end set to potential 0 and the other end set to potential 1. In this section of code I am trying to find the scalar potential function (so I can then find the electric field). I do not need to know the specific form of the potential function, I just want to make a streamplot of the field (or a 3D vector plot of the field).

Assign the cylindrical disk to R2

R2 = Cylinder[{{0, 0, -0.1}, {0, 0, 0.1}}, 1]

(*  sets left circle segment to 0 and right circle segment to 1.  *)

DBC1 = {DirichletCondition[
u[x, y, z] =
0, (-1 <= x <= -0.8 \[And] Abs[y] <= 0.6 \[And] Abs[z] == 0.1)],
DirichletCondition[
u[x, y, z] =
1, (0.8 <= x <= 1 \[And] Abs[y] <= 0.6 \[And] Abs[z] == 0.1)]}

Potential = NDSolveValue[{Laplacian[u[x, y, z], {x, y, z}] == 0,
DBC2}, u, Element[{x, y, z}, R2]]


ERROR:

NDSolveValue::deqn: Equation or list of equations expected instead of True in the first argument {True,{DirichletCondition[0,-1<=x<=-0.8&&Abs[y]<=0.6&&Abs[z]==0.1],DirichletCondition[1,0.8<=x<=1&&Abs[y]<=0.6&&Abs[z]==0.1]}}.

I'm not sure how to fix the issue I am facing, any help would be greatly appreciated! Also if anyone knows of an efficient way to get the magnetic field profile that would be great too... Thank you.

• It appears you are mistakenly using = where you need == in u[x, y, z] = , and you also have DBC1 is one place and DBC2 in another. However correcting this only throws others errors. – Mr.Wizard Jul 16 '15 at 9:30
• Yes, I am sorry that was a mistake in the post. I had corrected these beforehand but forgot to alter the post accordingly. Thank you. – Michael ponds Jul 16 '15 at 15:48
• The errors @Mr.Wizard pointed out are probably responsible for the message you're seeing. After correcting them and restarting the Kernel, I get the error that a mesh couldn't be generated. I'm guessing this is an issue in version 10.1 that got fixed in version 10.2 (which I haven't installed yet). Are you using version 10.1? – Jens Jul 16 '15 at 18:11

This works for me:

R2 = Cylinder[{{0, 0, -0.1}, {0, 0, 0.1}}, 1];
DBC1 = {DirichletCondition[
u[x, y, z] ==
0, (-1 <= x <= -0.8 \[And] Abs[y] <= 0.6 \[And] Abs[z] == 0.1)],
DirichletCondition[
u[x, y, z] ==
1, (0.8 <= x <= 1 \[And] Abs[y] <= 0.6 \[And] Abs[z] == 0.1)]};
Potential =
NDSolveValue[{Laplacian[u[x, y, z], {x, y, z}] == 0, DBC1}, u,
Element[{x, y, z}, R2]];
Needs["NDSolveFEM"]
ElementMeshSurfacePlot3D[Potential, Boxed -> False]


And here a SliceDensityPlot3D of the solution inside the object:

Show[
SliceDensityPlot3D[Potential[x, y, z], {x, y, z} \[Element] R2,
ColorFunction -> (ColorData["TemperatureMap"]), Boxed -> False,
Axes -> False],
Graphics3D[{Opacity[0.2], R2}]
]


Using the above solution of user21 you might look at the StreamPlot as follows:

    Show[{
StreamPlot[
Evaluate[{D[Potential, x], D[Potential, y]} /. z -> 0], {x, -1,
1}, {y, -1, 1}] // Quiet,
RegionPlot[RegionDifference[Rectangle[{-1, -1}, {1, 1}], Disk[]],
PlotStyle -> Opacity[1]]
}]


yielding the following:

Here the code part

RegionPlot[RegionDifference[Rectangle[{-1, -1}, {1, 1}], Disk[]],
PlotStyle -> Opacity[1]]


hides the artificial part of the image outside the disk.

Have fun!