2 Dimensional Plots of Dipole Electric Fields
 
 
Here we are studying forces due to electric charges.  A dipole is two charges of opposite signs.  These diagrams were produced by the program Transform by overlaying a color plot with a vector plot (arrows).  In a vector plot, the direction of the arrows indicates the direction of the force and the size of the arrows shows its magnitude (strength).
Equations Visualized: 
  • Ex (x,y) = ((k*qc)*(x-x1))/r13 + ((k*-qc)*(x-x2))/r23 
  • Ey (x,y) = ((k*qc)*(y-y1))/r13 + ((k*-qc)*(y-y2))/r23
  • Magnitude (strength) of E = sqrt[(Ex)2 + (Ey)2]
"Ex" is force in x direction/test charge, "Ey" is force in y direction/test charge, "k" is Coulomb's constant, "qc" is the charge of the positive pole, "r1" = sqrt[(x-x1)2+(y-y1)2] is the distance between the positive pole and a test charge, "x1" and "y1" are the coordinates of the positive pole, "x" and "y" are the coordinates of the test charge, "-qc" is the charge of the negative pole, "r2" = sqrt[(x-x2)2+(y-y2)2] is the distance between the negative pole and a test charge, "x2" and "y2" are the coordinates of the negative pole 
 
 
Both poles are the same color because the subroutine (Subroutine electricfield2D) used to create the data used absolute values.  The arrows indicate that the poles are actually oppositely charged.  Electricity flows toward the negative pole (bottom one).  The data used for this diagram was produced by program mj4 which is written in Fortran 90. 
 
 
Additional Equation Visualized: 
    • V(x,y) = (k*qc)/r1 + (k*-qc)/r2
    "V" is the electric potential, other constants and variables are defined above

The data used for this diagram was produced by program mj6 which is written in Fortran 90.  The poles are different colors because the subroutine (Subroutine potential2D) used to create the data allowed for positive and negative values.  To do this we used electric potential rather than magnitude of the electric field.  Now the arrows and colors correspond.
 
 
 
program mj4 
      use utility 
      use physics 
      implicit none 
      integer :: i, j 
      integer, parameter :: yd=50, xd=50 
      real :: q=50, xi, yi, r, v 
      real :: dx=2, dy=2 
      character*30 :: prompt = 'enter xi and yi' 
      real, dimension(xd) :: x 
      real, dimension(yd) :: y 
      real, dimension(xd,yd) :: fx, fy, fxsum, fysum, ftotal 
      print*, prompt 
      read (*,*) xi, yi 
      do i=1, xd 
         x(i)=dx*i 
      end do 
      do j=1,yd 
         y(j)=dy*j 
      end do 
      call write_asf(x,y,7) 
      call write_asf(x,y,8) 
      call write_asf(x,y,9) 
      call electricfield(fx,fy,xi,yi,x,y,q) 
      fxsum=fx; fysum=fy 
      call electricfield(fx,fy,xi+20,yi+20,x,y,-q) 
      fxsum=fxsum+fx 
      fysum=fysum+fy 
      ftotal=sqrt(fxsum**2+fysum**2) 
      do i=1, xd 
         write (7,*) fxsum(i,:) 
         write (8,*) fysum(i,:) 
         write (9,*) ftotal(i,:) 
      end do 
      end program mj4 



program mj6 
      use utility 
      use physics 
      implicit none 
      integer :: i, j 
      integer, parameter :: yd=50, xd=50 
      real :: q=50, xi, yi, r, v 
      real :: dx=2, dy=2 
      character*30 :: prompt = 'enter xi and yi' 
      real, dimension(xd) :: x, y 
      real, dimension(xd,yd) :: fx, fy, v, fxsum, fysum, vsum 
      print*, prompt 
      read (*,*) xi, yi 
      do i=1, xd 
         x(i)=dx*i 
      end do 
      do j=1,yd 
         y(j)=dy*j 
      end do 
      call write_asf(x,y,7) 
      call write_asf(x,y,8) 
      call write_asf(x,y,9) 
      call electricfield(fx,fy,xi,yi,x,y,q) 
      call potential(v,xi,yi,x,y,q) 
      fxsum=fx; fysum=fy 
      vsum=v 
      call electricfield(fx,fy,xi+20,yi+20,x,y,-q) 
      call potential(v,xi+20,yi+20,x,y,-q) 
      fxsum=fxsum+fx 
      fysum=fysum+fy 
      vsum=vsum+v 
      do i=1, xd 
         write (7,*) fxsum(i,:) 
         write (8,*) fysum(i,:) 
         write (9,*) vsum(i,:) 
      end do 
      end program mj6 


module utility 
! this module contains subroutines for writing header files 
      contains 
      subroutine write_asf(col,row,unitnum) 
! this subroutine writes ASCII special file headers 
! col contains column values and row contains row values 
! unitnum contains fortran unit number for output 
      real, dimension(:) :: col,row 
      integer :: unitnum 
      write (unit=unitnum,fmt=*) size(col), size(row) 
      write (unit=unitnum,fmt=*) 0,0 
      write (unit=unitnum,fmt=*) row 
      write (unit=unitnum,fmt=*) col 
      end subroutine write_asf 
      end module utility 



module physics 
! this module contains physics subroutines 
      contains 
      subroutine electricfield(ex,ey,xo,yo,x,y,q) 
! this subroutine calculates electric field of point charge 
! input variables are: xo,yo,q,x,y 
! output variables are: ex, ey 
! xo and yo are locations of point charge, q is the charge in coulombs 
! x and y are locations in space where electric field is calculated 
! ex and ey are the components of the electric field 
      real :: k=8.99E9, rad=1, v, r 
      real :: q, xo, yo 
      real, dimension(:) :: x, y 
      real, dimension(:,:) :: ex, ey 
      do i=1, size(x) 
         do j=1, size(y) 
            r=sqrt((x(i)-xo)**2+(y(j)-yo)**2) 
            If (r<rad) r=rad 
            v=(k*q)/r**2 
            ex(i,j)=v*(x(i)-xo)/r 
            ey(i,j)=v*(y(j)-yo)/r 
        end do 
      end do 
      end subroutine electricfield 
      end module physics 

Back to Main Page