1
$\begingroup$

I am trying to simulate a static electric field (in 2d and 3d) as it passes through a couple of apertures in a 3D "metal sheet" (model imported as a .obj file) given here:

https://www.dropbox.com/s/std8wbw3vcq8pfn/meta.obj?dl=0

I setup an airbox and a "charged" plate at the top of an airbox. I place my "metal sheet" with the apertures in it in the center of the box.

When it comes time to define the DirichletConditions, I can set a charge on my "charged" plate at the top of the airbox just fine using DirichletConditions, but am having trouble defining the boundary conditions on the metal sheet with apertures. How would one go about defining Dirichlet boundary conditions on such an object with holes in it? I also need help plotting the fields in 3D as they pass through the apertures. Thank you!!!

Clear["Global`*"];
Needs["NDSolve`FEM`"]

R = Import["...\\meta.obj"];
RegionDimension[R];
M = BoundaryMeshRegion[MeshCoordinates[R], MeshCells[R, 2]];
*emphasized text*
r = RegionDifference[
  RegionDifference[Cuboid[{-1, -1, -1}, {2, 2, 1}], M], 
  Cuboid[{-1, -1, 0.9}, {2, 2, 1}]]
mesh = ToElementMesh[r]["Wireframe"]

V0 = 4000;
sol = NDSolveValue[{Laplacian[V[x, y, z], {x, y, z}] == 0, 
   DirichletCondition[
    V[x, y, z] == 
     V0/2, (0.9 <= z <= 1) && (-0.99 <= y <= 1.99) && (-0.99 <= x <= 
       1.99)], DirichletCondition[
    V[x, y, z] == -V0/
      2, (0 <= z <= 0.072) && (0 <= y <= 1) && (0 <= x <= 1)]}, 
  V, {x, y, z} \[Element] r]
ContourPlot[sol[x, 0.25, z], {x, -1, 2}, {z, -1, 1}]
New contributor
zak720 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

2 Answers 2

1
$\begingroup$

We don't need define potential in holes, we can use DirichletCondition[V[x, y, z] == -V0/2, (0 <= z <= 0.072) && (0 <= y <= 1) && (0 <= x <= 1)] to define boundary condition on a plate. To visualize solution we use Show as follows

Clear["Global`*"];
Needs["NDSolve`FEM`"]

R = Import["...\\meta.obj"];
RegionDimension[R];
M = BoundaryMeshRegion[MeshCoordinates[R], MeshCells[R, 2], 
  Axes -> True];
reg = RegionDifference[
   RegionDifference[Cuboid[{-1, -1, -1}, {2, 2, 1}], M], 
   Cuboid[{-1, -1, 0.9}, {2, 2, 1}]];
V0 = 1;
sol = NDSolveValue[{Laplacian[V[x, y, z], {x, y, z}] == 0, 
   DirichletCondition[
    V[x, y, z] == 
     V0/2, (0.9 <= z <= 1) && (-0.99 <= y <= 1.99) && (-0.99 <= x <= 
       1.99)], DirichletCondition[
    V[x, y, z] == -V0/
      2, (0 <= z <= 0.072) && (0 <= y <= 1) && (0 <= x <= 1)]}, 
  V, {x, y, z} \[Element] reg];
f = Evaluate[Grad[-sol[x, y, z], {x, y, z}]];

Show[VectorPlot3D[f, {x, 0, 1}, {y, 0, 1}, {z, -.1, .2}, 
  Boxed -> False, BoxRatios -> Automatic, VectorPoints -> 10, 
  VectorStyle -> Arrowheads[0]], M]

Figure 1 We can also visualize potential around plate and in holes

Table[ContourPlot[4000 sol[x, y, z], {x, -1, 2}, {y, -1, 2}, 
  Contours -> 20, ColorFunction -> "Pastel", PlotLegends -> Automatic,
   Frame -> False, PlotLabel -> z], {z, -.05, .1, .03}]

Figure 2

ContourPlot[4000 sol[x, y, .04], {x, 0, 1}, {y, 0, 1}, Contours -> 20,
  ColorFunction -> "Pastel", PlotLegends -> Automatic, Frame -> False,
  PlotPoints -> 50, PlotRange -> {-2000, -1900}]

Figure 3

$\endgroup$
1
  • $\begingroup$ Thank you Alex. I actually came up with a very similar solution today! I also had to modify my boundary conditions and geometry to make the problem more physical. I will also include my solution below. $\endgroup$
    – zak720
    Jun 24 at 5:18
1
$\begingroup$

.obj file with new geometry: https://www.dropbox.com/s/dds8rm3odg2m7gu/largeAp.obj?dl=0

Here is link to images of fields as well since I can't seem to embed the images properly: https://imgur.com/a/IpybJop

Clear["Global`*"];
Needs["NDSolve`FEM`"]

R = Import["C:...largeAp.obj"];
RegionDimension[R];
M = BoundaryMeshRegion[MeshCoordinates[R], MeshCells[R, 2]];
RegionDimension[M];
Volume[M];

r = RegionDifference[
   RegionDifference[
    RegionDifference[Cuboid[{0, 0, -0.5}, {2, 2, 0.5}], M], 
    Cuboid[{0, 0, 0.4}, {2, 2, 0.5}]], 
   Cuboid[{0, 0, -0.5}, {2, 2, -0.4}]];
mesh = ToElementMesh[r]["Wireframe"];

pol = -1;

V0 = 4000;
sol = NDSolveValue[{Laplacian[V[x, y, z], {x, y, z}] == 0, 
   DirichletCondition[
    V[x, y, z] == -pol*
      V0/2, (0.4 <= z <= 0.5) && (0 <= y <= 2) && (0 <= x <= 2)], 
   DirichletCondition[
    V[x, y, z] == 
     pol*V0/2, (0.0071 <= z <= 0.0072) && (0 <= y <= 2) && (0 <= x <= 
       2)], DirichletCondition[
    V[x, y, z] == 
     0, (0 <= z <= 0.0070) && (0 <= y <= 2) && (0 <= x <= 2)], 
   DirichletCondition[
    V[x, y, z] == 
     0, (-0.5 <= z <= -0.4) && (0 <= y <= 2) && (0 <= x <= 2)]}, 
  V, {x, y, z} \[Element] r]

plotXZ = ContourPlot[sol[x, 0.75, z], {x, 0, 2}, {z, -0.4, 0.1}, 
  ContourShading -> Automatic, ColorFunction -> "Rainbow", 
  Contours -> 100]
plotYZ = ContourPlot[sol[0.75, y, z], {y, 0, 2}, {z, -0.4, 0.1}, 
  ContourShading -> Automatic, ColorFunction -> "Rainbow", 
  Contours -> 100]
plotXY = ContourPlot[sol[x, y, -0.05], {x, 0.5, 1.5}, {y, 0.5, 1.5}, 
  ColorFunction -> "Rainbow", Contours -> 50, PlotLegends -> Automatic]

SliceContourPlot3D[sol[x, y, z], 
  "CenterPlanes", {x, 0.5, 1}, {y, 0.5, 1}, {z, 0, -0.1}, 
  ColorFunction -> "Rainbow", Contours -> 200];
DensityPlot3D[
  sol[x, y, z], {x, 0.5, 1}, {y, 0.5, 1}, {z, -0.4, -0.00001}, 
  PlotTheme -> "Detailed", ColorFunction -> "Rainbow", 
  PerformanceGoal -> "Quality"];

d = ContourPlot3D[
   sol[x, y, z], {x, 0.5, 1}, {y, 0.5, 1}, {z, -0.25, -0.00001}, 
   PlotTheme -> "Detailed", ColorFunction -> "Rainbow", 
   PerformanceGoal -> "Quality", Contours -> 1, Mesh -> None];

electricField[x_, y_, z_] = -Grad[sol[x, y, z], {x, y, z}];
v = Show[VectorPlot3D[
   electricField[x, y, z], {x, 0.5, 1}, {y, 0.5, 
    1}, {z, -0.25, -0.00001}, PlotTheme -> "Detailed", 
   ColorFunction -> "Rainbow", PerformanceGoal -> "Quality", 
   VectorScale -> 0.05, VectorPoints -> 7], M]

electric field vectors and xy-place contour plot

New contributor
zak720 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
1
  • $\begingroup$ There are 2 pictures uploaded with 2 and 1 chrest respectively. Is largeAp.obj corresponds to one chrest? $\endgroup$ Jun 24 at 5:53

Your Answer

zak720 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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