I have been trying to find the maximum value of the magnitude of an electric field in a bounded region. NDSolve
gives the value of the potential inside the region once we supply the boundary conditions; the negative gradient of the potential gives the the electric field. I have this code which works well, except that it is not giving the maximum value of the electric field. Can anyone suggest the correct way of using NMaximize
for this case?
Clear["Global`*"]
a = 3.6;
b = 6;
θ = 5*π/180;
Region1 = Rectangle[{0, 0}, {a, 6}];
Region2 = Triangle[{{a - b*Tan[θ], 0}, {a, 0}, {a, b}}]
reg = RegionDifference[Region1, Region2];
RegionPlot[reg]
solution =
NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] == 0,
DirichletCondition[u[x, y] == 0,
x/Tan[θ] + b - a/Tan[θ] == y],
DirichletCondition[u[x, y] == -180, x == 0],
DirichletCondition[u[x, y] == 180*x/(a - b*Tan[θ]) - 180,
y == 0], DirichletCondition[u[x, y] == 50 x - 180, y == 6]},
u, {x, y} ∈ reg]
EField[x_, y_] = -Grad[solution[x, y], {x, y}];
ContourPlot[solution[x, y], {x, y} ∈ reg]
VectorPlot[EField[x, y], {x, y} ∈ reg]
NMaximize[{Norm[EField[x, y]], {x, y} ∈ reg}, {x, y}]
EField2[x_?NumericQ, y_?NumericQ] := Evaluate[-Grad[solution[x, y], {x, y}]]; NMaximize[{Norm[EField2[x, y]], {x, y} \[Element] solution["ElementMesh"]}, {x, y}]
perhaps? $\endgroup$