(*     Module #18:  Lines of Potential for Charges *)

(*     Calculation of the Potential at a Point     *)

q = 1.6*(10^-19);epsilon=8.85*(10^-12);
V[x_,y_,z_] := N[q/(4*Pi*epsilon*Sqrt[x^2+y^2+z^2])];
V[1,y=0,z=0]

(*     Graph of a Line of Constant Potential-You must define
       the function F[x_,y_,z_] before using this. *)

ContourPlot[V[x,y,z=0],{x,-2,2},{y,-2,2},
           Contours->{1.4*(10^-9)}, Axes->{True,True},
           AxesOrigin->{0,0}, ContourShading->False]

(*     Graph of two lines of constant potential    *)

ContourPlot[V[x,y,z=0],{x,-2,2},{y,-2,2},
                        Contours->{1.4*(10^-9),9.6*(10^-10)},
                        Axes->{True,True},
                        AxesOrigin->{0,0},
                        ContourShading->False]

(*     Two Dimensional Graph of Potential vs. distance *)

Plot[V[x,y=0,z=0],{x,0.1,2},
                    AxesLabel->{"x","V[x]"}]

(*     Contour Plot of three lines of potential   *)

ContourPlot[V[x,y,z=0],{x,-2,2},{y,-2,2},
  Contours->{1.9*(10^-9),1.4*(10^-9),9.6*(10^-10)},
  Axes->{True,True},AxesOrigin->{0,0},ContourShading->False]

(*   The Contour Shading Feature   *)
  ContourPlot[V[x,y,z=0],{x,-2,2},{y,-2,2},
  Contours->{1.9*(10^-9),1.4*(10^-9),9.6*(10^-10)},
  Axes->{True,True},AxesOrigin->{0,0},ContourShading->True]

(*   The potential of a charge not at the origin  *)
q = 1.6*(10^-19);epsilon=8.85*(10^-12);
x0=1.0;y0=0.0; z0=0.0;
V[x_,y_,z_] := 
      N[q/(4*Pi*epsilon*Sqrt[(x0-x)^2+(y0-y)^2+(z0-z)^2])];
ContourPlot[V[x,y,z=0],{x,-3,3},{y,-3,3},
      Contours->{1.9*(10^-9),1.4*(10^-9),9.6*(10^-10)},
                        ContourShading->True]

(*   Potential of two charges   *)
..q0 = 1.6*(10^-19);q1 = 1.6*(10^-19);epsilon=8.85*(10^-12);
x0= 1.; y0=0.; x1 = -1.; y1 = 0.;Npi=N[Pi];
V[x_,y_] := q0/(4*Npi*epsilon*Sqrt[(x-x0)^2+(y-y0)^2]) +
                 q1/(4*Npi*epsilon*Sqrt[(x-x1)^2+(y-y1)^2]);

(*   Two dimensional graph of the potential of
           two charges     *)
  Plot[V[x,y=0],{x,-3,3},
                    AxesLabel->{"x","V[x]"},
                    PlotRange->{0,(10^-8)}]

(*    Potentials of two charges   *)
ContourPlot[V[x,y],{x,-3,3},{y,-3,3},
             Contours->{2.9*(10^-9),2.0*(10^-9),
                        1.5*(10^-9),1.*(10^-9)},
             ContourShading->True]