Message Boards Message Boards

0
|
5175 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

GradientFieldPlot

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<x<1 despite exclusions options.

GradientFieldPlot[-\[Phi], {x, -2, 2}, {z, -2, 2}, 
 Exclusions -> {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.

POSTED BY: afreeka b
3 Replies

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[5]:= D[Abs[z^2], z]

Out[5]= 2 Abs[z] Derivative[1][Abs][z]

In[4]:= FullSimplify[D[Abs[z^2], z], Assumptions -> Element[z, Reals]]

Out[4]= 2 z
POSTED BY: Frank Kampas
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 BY: afreeka b

GradientFieldPlot has been superseded by VectorPlot.

POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract