Académique Documents
Professionnel Documents
Culture Documents
Eric Mayes
Department of Computer Science, Mathematics and Physics
Arkansas State University
State University, AR 72467
Abstract
A set of packages for visualizing electrostatic phenomena was developed using Mathematica as a programming language.
These packages allow users to plot potential fields, equipotential lines, 2-D and 3-D vector fields in order to gain a visual
understanding of electrostatic charges. They would be useful in accompanying undergraduate physics labs pertaining to
electrostatics, as they would enable students to connect experiment with mathematics through open-ended visual exploration.
Introduction
Mathematica (Wolfram, 1991) is a symbolic mathematics computer program that was first released in 1988. It
can perform symbolic calculations, produce beautiful
graphics, and give very accurate results limited only by
the system that it is run on. Its most powerful feature,
though, is that it is also a programming language. The
purpose of this project was to visualize electrostatic phenomena and Mathematical easily utilized, yet powerful,
graphics abilities made it a perfect choice. The project is
open-ended, in that others can easily create new change
distributions and view them.
Electrostatics Package
The first package (Listing 1), named "Electrostatics,"
is loaded into Mathematica Version 2.0 as:
In [l]:=ElectroStatics
Theory
E(r) =
g4^R|
or more explicitlyby:
_A
- +
h
Similarly the scalar potential is given explicitly by:
E(r)
{r)
gi
<(r) = Y,
As an example:
In[3]:= PlotPField[{-l,1,1, 1,-1, 1,2}, {x,-2,2}, {y,-2,2},
PlotPoints -> 40]
contour
plots using
These plots are the equipotential lines for the charge disributions. Figures 3a and 3b were created for the same
charge distribution with the MakeEField command.
Figures 4a and 4b are combinations of 2a, 2b and 3a, 3b
howing the electric field lines perpendicular to the
equipotential lines. The third and fourth list input commands allow the user to display charge configurations
generated by a function, rather then entering each charge
individually.
As one way to utilize these commands, we can introduce a function like this:
RingOCharge[{x0_, y0_}, radius_, pointsj
Block[{i, theta, charges
{}},
Do[AppendTo[charges, 1];
AppendTo[charges, (radius*Cos[theta] + x0)];
AppendTo[charges, (radius*Sin[theta] +y0)];
{theta, 0, 2*Pi, (2*Pi/points)}];
AppendTo[charges, points]; charges]
Electrostatics;}
D Package
user input and the other for list input. Both commands
create a 3-D plot of the electric field surrounding a set of
charges. The first command, MakeEField3D, is called in
almost the same manner as the MakeEField command,
with the addition of a Z-coordinate:
opts)]
Fig. 5. Potential energy field for a ring of charge approximated by 20 point charges.
Fig. 6. Electric field vectors for a ring of charge approximated by 20 point charges.
Discussion
Fig. 7. 3-D Electric field vectors for a system of four coplanar charges [inputs 2 at {0,0,0}, -1 at {0,1,0}, {-0.866,
0.5, 0} where the -1 charges are separated by 120].
L{chargel,xl,yl. .,chargeN,xN,yN,N}.";
n["'Private'"]
rePField[num_,
] :-
AppendTo[chargelist,answer];
= Input["XCoord: "];
AppendTo[chargelist,answer];
answer
answer
AppendTo[chargelist,answer],
{i.num}];
AppendTo[chargelist,num];
Do[
{i,
Dof
opts
] :=
= {},
field
= 0},
Printf" "];
(*:Name: ElectroStatics3D* *)
Printf'Charge #",ToString[i]];
Print ["
"];
answer = Inputf'Charge: "];
AppendTofchargelist, answer];
answer = Inputf'X Coord: "];
AppendTofchargelist, answer];
answer Input["Y Coord: "];
AppendTofchargelist, answer],
{i,num}];
AppendTofchargelist, num);
Do[(field = field + ((Partfchargelist.i]*
({(xO- Partfchargelist, (i+1)]),
(yO - Partfchargelist, (i+2)])}))/
((xO - (Part[charge!ist, (i+l)]+.0001))^2 +
*)
BeginPackage["ElectroStatics3D'",
ScaleFunction->(Log[Log[Log[Log[Log[Log[#+l]+l]+l]+l]+l]+l]&),
ScaleFactor -> .2, DisplayFunction > Identity};
(i+2)]}]],{i,l,(Last[chargelist]*3),3}];
dotsplot = Graphics[{PointSize[0.02], dots}, Display Function^
Identity];
Show[vectorplot,dotsplot,DisplayFunction -> $Display Function]]
Dof
] :=
Dof
Printf" "];
Printf'Charge #",ToStrinfi]];
"];
Inputf'Charge: "];
AppendTofchargelist.answer];
answer = Inputf'X Coord: "];
AppendTofchargelist.answer];
answer = Inputf'Y Coord: "];
AppendTofchargelist.answer];
answer = Inputf'Z Coord: "];
AppendTofchargelist.answer],
answer
{i,l,(Last[chargelist]*3),3}];
{xO, xl, x2}, {yO, yl, y2}, opts]]
EField[chargelist_, {xO_, xl_,x2_,}, {yO_, yl_, y2_}, opts
MakeEField3D[num_, {xO_, xl_, x2_}, {yO_, yl_, y2_}, {zO_, zl_, z2_},
] :=
opts
Block[{i, vectorplot, dotsplot, dots {},chargelist = {},field = 0},
Printf" =
IPlot3D[potential,
Begin["'Private'"]
ItPField[chargelist_,
{i,l,(List[chargelist]*3),3}];
"Graphics'PlotField3D"']
MakeEField3D::usage="MakeEField3D[N, {x,xmin,xmax},{y,ymin,ymax},
{z.zmin.zmax}, (other opts)] returns a 3-D graph of the electric
field of a set of N charges specified by the user."
*)
vectorplot
*)
] :=
{i.num}];
AppendTo[chargelist,num];
Do[
Do[AppendTo[dots,Point[{Part[chargelist,(i+l)],Part[chargelist, (i+2)],
Partfchargelist, (i+3]}]] {i,l,(Last[chargelist]*4),4}];
dotsplot = Graphics3D[{PointSize[0.02], dots},DisplayFunction ->
Identity];
Show[vectorplot,dotsplot,DisplayFunction -> $DisplayFunction]]
(
E)tect[MakeEField3D,
*)
PlotEField3D]
dPackagef] (*ElectroStatics3D* *)
Acknowledgements
This work acknowledges Charles A. Hughes for his
ssistance and the Department of Computer Science,
and Physics at Arkansas State University for
e use of their facilities.
I
Kathematics,
Literature Cited
rangsness,
John