Skip to main content
edited tags
Link
user21
  • 40.7k
  • 8
  • 114
  • 170
Tweeted twitter.com/StackMma/status/1254334420603068417
added 318 characters in body
Source Link
james
  • 3.1k
  • 14
  • 30

EDIT 2: Just for beauty: Parallel Plate Capacitor Use this answer to make it work: FEM Simulation: Meshing Two Arbitrary Objects in an "Air" Mesh

enter image description here

EDIT 2: Just for beauty: Parallel Plate Capacitor Use this answer to make it work: FEM Simulation: Meshing Two Arbitrary Objects in an "Air" Mesh

enter image description here

added 1832 characters in body
Source Link
james
  • 3.1k
  • 14
  • 30

EDIT: Basend on the excellent answer below, I would like to use the answer here Get Perimeter Region from Object to automate the finding of the region boundaries for the DirichletCondition:

Needs["NDSolve`FEM`"];
(*Define Boundaries*)
air = Rectangle[{-5, -5}, {5, 5}];
object1 = Disk[];
object2 = Rectangle[{-2.5, -2.5}, {2.5, -2}];
reg12 = RegionUnion[object1, object2];
reg = RegionDifference[air, reg12]

mesh = ToElementMesh[reg, {{-5, 5}, {-5, 5}}, 
  MeshRefinementFunction -> 
   Function[{vertices, area}, 
    area > 0.001 (0.1 + 10 Norm[Mean[vertices]])]]
mesh["Wireframe"]

eq = Laplacian[u[x, y], {x, y}]; V1 = 1; V2 = -2;
bc = {DirichletCondition[u[x, y] == V1, 
    Region`RegionProperty[RegionBoundary[object1], {x, y}, 
       "FastDescription"][[1]][[2]]], 
   DirichletCondition[u[x, y] == V2, 
    Region`RegionProperty[RegionBoundary[object2], {x, y}, 
       "FastDescription"][[1]][[2]]]};
U = NDSolveValue[{eq == 0, bc}, u, {x, y} \[Element] mesh];

ef = -Grad[U[x, y], {x, y}];

DensityPlot[U[x, y], {x, y} \[Element] reg, 
 ColorFunction -> "Rainbow", PlotLegends -> Automatic, 
 FrameLabel -> Automatic, PlotPoints -> 50, 
 PlotRange -> {{-4, 4}, {-4, 4}}]

StreamDensityPlot[Evaluate[ef], {x, y} \[Element] reg, 
 ColorFunction -> "Rainbow", PlotLegends -> Automatic, 
 FrameLabel -> {x, y}, StreamStyle -> LightGray, VectorPoints -> Fine,
  PlotRange -> {{-3, 3}, {-2.5, 3}}]

enter image description here enter image description here

EDIT: Basend on the excellent answer below, I would like to use the answer here Get Perimeter Region from Object to automate the finding of the region boundaries for the DirichletCondition:

Needs["NDSolve`FEM`"];
(*Define Boundaries*)
air = Rectangle[{-5, -5}, {5, 5}];
object1 = Disk[];
object2 = Rectangle[{-2.5, -2.5}, {2.5, -2}];
reg12 = RegionUnion[object1, object2];
reg = RegionDifference[air, reg12]

mesh = ToElementMesh[reg, {{-5, 5}, {-5, 5}}, 
  MeshRefinementFunction -> 
   Function[{vertices, area}, 
    area > 0.001 (0.1 + 10 Norm[Mean[vertices]])]]
mesh["Wireframe"]

eq = Laplacian[u[x, y], {x, y}]; V1 = 1; V2 = -2;
bc = {DirichletCondition[u[x, y] == V1, 
    Region`RegionProperty[RegionBoundary[object1], {x, y}, 
       "FastDescription"][[1]][[2]]], 
   DirichletCondition[u[x, y] == V2, 
    Region`RegionProperty[RegionBoundary[object2], {x, y}, 
       "FastDescription"][[1]][[2]]]};
U = NDSolveValue[{eq == 0, bc}, u, {x, y} \[Element] mesh];

ef = -Grad[U[x, y], {x, y}];

DensityPlot[U[x, y], {x, y} \[Element] reg, 
 ColorFunction -> "Rainbow", PlotLegends -> Automatic, 
 FrameLabel -> Automatic, PlotPoints -> 50, 
 PlotRange -> {{-4, 4}, {-4, 4}}]

StreamDensityPlot[Evaluate[ef], {x, y} \[Element] reg, 
 ColorFunction -> "Rainbow", PlotLegends -> Automatic, 
 FrameLabel -> {x, y}, StreamStyle -> LightGray, VectorPoints -> Fine,
  PlotRange -> {{-3, 3}, {-2.5, 3}}]

enter image description here enter image description here

added 325 characters in body
Source Link
james
  • 3.1k
  • 14
  • 30
Loading
Source Link
james
  • 3.1k
  • 14
  • 30
Loading