I want to plot a complex potential

(potential of a pair of source lines)

where c is center, K is constant(amount of change), p is potential, y is psi.

And when I tried, set any constant at c and k

(ex. c=1,k=2)

p1:=K Log[z-c]
p2:=-k Log[z+c]
y1:=k Arg[z-c]
y2:=-k Arg[z-c]

Since, the complex potential is

F(z)=p + I y

There is figure that I want to make

enter image description here

Equipotential lines and lines of force (dashed)

Please tell me the method of plotting the complex potential.


1 Answer 1


Here is a function that plots real and imaginary parts with options that you can set to match your desired size and colors:

Options[fieldPlot] = {"xMax" -> 1, "yMax" -> 1, Contours -> 20, 
   "FieldLines" -> 20, 
   "FieldLineStyle" -> Directive[Thick, Dashed, Darker[Cyan]], 
   "PotentialStyle" -> {Directive[Thick, Darker[Cyan]]}, 
   ExclusionsStyle -> None, Exclusions -> None};

fieldPlot[g_, opts : OptionsPattern[]] := Module[{im, re, xM, yM},
  xM = OptionValue["xMax"];
  yM = OptionValue["yMax"];
  im = ContourPlot[
    Im[g[x + I y]],
    {x, -xM, xM}, {y, -yM, yM},
    ContourShading -> False,
    ContourStyle -> OptionValue["FieldLineStyle"],
    Contours -> OptionValue["FieldLines"]
  re = ContourPlot[
    Re[g[x + I y]],
    {x, -xM, xM}, {y, -yM, yM},
    ContourShading -> False,
    FrameLabel -> {"Re(z)", "Im(z)"},
    ContourStyle -> OptionValue["PotentialStyle"],
    Contours -> OptionValue[Contours],
    Exclusions -> OptionValue[Exclusions],
    ExclusionsStyle -> OptionValue[ExclusionsStyle]];
  Show[re, im, Background -> LightBlue, Frame -> None,AspectRatio->Automatic]]

f[z_] := Log[z - 1] - Log[z + 1]

fieldPlot[f, "xMax" -> 2, "yMax" -> 1]


I simplified your function to Log[z - 1] - Log[z + 1] in order to make the plot., because the definitions in the question had typos.

  • $\begingroup$ Perfectly,but why use string as a option name? $\endgroup$
    – yode
    Oct 27, 2016 at 12:27
  • $\begingroup$ @yode It's not necessary in principle, but strings are safer because they can't be assigned values. If you use an unprotected symbol name for an option, it can lead to confusion if that symbol has a value. $\endgroup$
    – Jens
    Oct 27, 2016 at 15:19

Your Answer

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.