# Message Boards

0
|
4827 Views
|
3 Replies
|
1 Total Likes
View groups...
Share

Posted 9 years ago
 Hi everyone, I have a small problem with this short computation. I want to plot the electrostatic field from a plate: isolines+field. The function I want to plot is: y := 0; Q = 1; \[Epsilon] = 1; R = 1; r := Sqrt[ x^2 + y^2]; p := Sqrt[(r + R)^2 + z^2]; n := ( 4 r R)/(r + R)^2; m := (4 r R)/p^2; Ud := 2/p (p^2*EllipticE[m] - (r^2 - R^2)*EllipticK[m] - z^2*(r - R)/(r + R) EllipticPi[n, m] ); Ui := Piecewise[{{-2 \[Pi]*Abs[z], r \[LessSlantEqual] R}, {0, r > R}}]; \[Phi] := 1/(4 \[Pi] \[Epsilon])*Q/(\[Pi] R^2) (Ud + Ui);  GradientFieldPlot is not fully plotting in an area. It is completely white between -1 {Abs[x] == 1}, PlotPoints -> 50, Contours -> 20, ColorFunction -> (ColorData["RedBlueTones"][1 - #] &), ContourStyle -> White, Frame -> True, FrameLabel -> {"x", "z"}, ClippingStyle -> Automatic, Axes -> False, StreamStyle -> Orange, Epilog -> {Thickness[0.006], Line[{{-1, 0}, {1, 0}}]}]  But ContourPlot is working perfectly. ContourPlot[\[Phi], {x, -2, 2}, {z, -2, 2}, Exclusions -> {Abs[x] == 1}, Contours -> 30, ColorFunction -> (ColorData["RedBlueTones"][1 - #] &), PlotPoints -> 200, Epilog -> {Thickness[0.006], Line[{{-1, 0}, {1, 0}}]}, FrameLabel -> {x, z}]  I don't understand the differences and how I can fix this issue in the gradientfieldplot. Thanks in advance for the support.
3 Replies
Sort By:
Posted 9 years ago
 The function Abs doesn't have a derivative for complex arguments (it doesn't obey the Schwarz Christoffel rule) so it's not defined. It can be defined by restricting the argument to real numbers. In:= D[Abs[z^2], z] Out= 2 Abs[z] Derivative[Abs][z] In:= FullSimplify[D[Abs[z^2], z], Assumptions -> Element[z, Reals]] Out= 2 z `
Posted 9 years ago
 Finally I solved the problem. It seems mathematica has problem with absolute values. I tried to plot the Vector plot of the gradient. I noticed there was a problem in the derivative of abs[x]. Therefore I replace abs[x] by Sqrt[x*x]. It works after that. Thanks for your help.
Posted 9 years ago
 GradientFieldPlot has been superseded by VectorPlot.