Category Archives: Ramy

Conclusion: Electric Fields of Spherical Objects

Gauss’s Law is a powerful tool for understanding electric fields for all types of configurations. The most general case of Gauss’s Law is given by $ \oint \! \textbf{E} \cdot \mathrm{d} \textbf{a} = \frac{1}{\epsilon_0} Q_{enc} $. In this equation, $ \textbf{E} $ represents the electric field vector, $ \mathrm{d} \textbf{a} $ represents the differential area vector of the Gaussian surface through which the electric field is pointed, $ \epsilon_0 $ represents the permittivity of free space, and $Q_{enc}$ represents the charge enclosed by a Gaussian surface.

As stated in my project plan, the general case can be used to solve for the electric field of a point charge, which is given by $\textbf{E} = \frac{1}{4 \pi \epsilon_0} \frac{q}{r^2} \mathbf{\hat{r}} $. The unit vector indicates that the electric field for a point charge points in the radial direction. In my project, I managed to use this equation to model the electric fields for both positive and negative point charges.

I also worked to model the electric field for hollow spherical conductors. The above equation still holds, but with one caveat:

    \begin{displaymath} \textbf{E} = \left\{ \begin{array}{lr} 0 & : r \leq R\\ \frac{1}{4 \pi \epsilon_0} \frac{q}{r^2} \mathbf{\hat{r}} & : r > R \end{array} \right. \end{displaymath}

In the above, $R$ represents the radius of the sphere. This piecewise function describes the fact represented in Gauss’s Law that a electric fields only exist in regions in which a charge is enclosed. In conductors, all of the charge exists at the outer surface, so there is no electric field on the inside of a hollow spherical conductor. When the distance away from the conductor is greater than its radius, it obeys the second piece of the piecewise function.

This image shows the electric field produced by a positive point charge in free space.

This image shows the electric field produced by a positive point charge in free space.

My project was initially intended to be a project that produced visualizations of the above equations. From that point, I intended to develop more complex systems, work out the math for them, and then visually model them as well. However, due to my inexperience with Mathematica 9, I encountered many issues. The RegionFunction proved to be my saving grace, as described in my results post, but it happened too late for me to be able to model more complex systems.


This image shows the electric field produced by a negative point charge. Compare to Figure 1.

This image shows the electric field produced by a negative point charge in free space. Compare to the figure for a positive point charge.

My results do show good visual models for electric fields of single positive and negative point charges, and a positively charged spherical conductor. These visual models are incredibly useful tools for understand electric fields. Looking at an equation (Gauss’s Law) can only do so much for one’s understanding; a visual strongly aids this.

This shows the electric field produced by a spherical conductor with positive charge on the surface.

This shows the electric field produced in free space by a spherical conductor with positive charge on the surface.

I wish that Mathematica had even more tools for visually modeling these electric fields. I tried to create an animation that showed the graphing of the vector field arrows coming out of the point charge, but this did not work. I don’t believe Mathematica’s VectorFunction3D  works with its Animate function, but it may just require different inputs. I also tried to create a Manipulate object to demonstrate changes in the electric field as charge changed, but this was also not successful. Part of me believe this is an issue of scaling the image, and part of my believes that this function is also not compatible with VectorFunction3D.

In the future, this project could be expanded by modeling more complex systems. One way to complicate this would be to introduced additional spherical conducting shells with charge on them. Another complicating factor would be to put a point charge inside of a spherical shell. These systems could be modeled with differing signs and values of charges. Additionally, an infinite charged plane could be added to show other ways the electric field might change.

Additional investigations could also include modeling the electric fields of dielectrics instead of conductors. This analysis would be especially complex because it would include polarizations and bound charges. Additionally, this could include the modeling of the electric displacement in addition to the electric field.

Sources and Resources:

  1. Introduction to Electrodynamics, David Griffiths, 4th Edition
  2. Mathematica 9: Student Edition, created by Wolfram
  3. Collaborators: Brian Deer and Tewa Kpulun

Final Data – E Fields of Spherical Objects

I began by modeling the electric field for a point charge +q, equal to the value of an elementary charge.



I also modeled the electric field of a point charge of -q.



Next, I attempted to model the electric field due to spherical hollow conductor with total charge +q. First, I graphed a sphere of radius 5 using Mathematica’s SphericalPlot3D function. I superimposed the electric field of a positive point charge over this sphere, knowing that this would be incorrect. By Gauss’s Law, the stated configuration would result in an electric field of 0 inside of the spherical conductor, and an electric field following $\textbf{E} = \frac{1}{4 \pi \epsilon_0} \frac{q}{r^2} \mathbf{\hat{r}} $ for r > 5. The following image shows a partially transparent sphere with an electric field inside of it, violating Gauss’s Law.



However, thanks to Brian Deer, I learned to use Mathematica’s RegionFunction, which allowed me to specify which regions of the graph on which the vector function would apply. The following now shows a hollow conductor of radius 3, with an electric field only present outside of it. Unfortunately, this step took a lot of time to work out, as I tried many different ideas to only get the field to show for certain radius values (i.e. be 0 inside of the conductor). I was unaware of RegionFunction, and even when I did learn what it was, I had trouble getting it to work with my model.



My updated Mathematica file can be found here.


Preliminary Results – Electric Fields of Spherical Objects

My project is going interestingly. Using the equation of a point charge mentioned in my Project Plan, I achieved the following:



I was also able to successfully plot a sphere of radius 5 centered at the origin, using the SphericalPlot3D function in Mathematica 9. Superimposing the two, I achieved the following:



Clearly, however, this is incorrect, as the field lines should begin at radius of 5 (this is a hollow sphere, with all charge q [equal to the charge of an electron] at the surface), according to Gauss’s Law. I am having trouble getting this to work correctly. I have been experimenting doing it in one octant to get a better idea of how the functions work, but I am still stuck.



My trajectory for the next week is to gain a better understanding of vector functions in general and VectorFunction3D in Mathematica so that I can make better progress. My Mathematica file can be found here.


Project Plan: Modeling Electromagnetic Fields for Spherical Objects


I will be utilizing Introduction to Electrodynamics, 4th Edition, by David J. Griffiths. Specifically, I will begin with Gauss’s Law, as defined by Griffiths on page 69:

$ \oint \! \textbf{E} \cdot \mathrm{d} \textbf{a} = \frac{1}{\epsilon_0} Q_{enc} $

Further, I will utilize the formula for the electric field of a point charge below (found on Griffiths page 72), which can be generalized for a spherical object:

$\textbf{E} = \frac{1}{4 \pi \epsilon_0} \frac{q}{r^2} \mathbf{\hat{r}} $

I will additionally work with the magnetic field for the spherical object. Griffiths (page 263) gives the average magnetic field due to uniform current over a sphere as:

$ \textbf{B}_{ave} = \frac{\mu_0}{4 \pi} \frac{\textbf{m}}{R^3}$

Where m is the total dipole moment of the sphere and R is the radius of the sphere.

I will be using Mathematica 9 as my modeling tool.

Plan of Action

I will begin by using the equations above to start with modeling the electric field of a point charge. From there, I will model the electric field for a hollow spherical object. I will create a manipulatable object in Mathematica for changes in radius and charge. I will then move on to modeling the average magnetic field for a spherical object, and attempt to create a manipulatable object akin to the one for electric fields. Next, I will model the electric and magnetic fields for concentric spherical objects, with the goal of ultimately coming up with a very liberal approximation for modeling the magnetic field of the Earth, if the Earth is thought of as several concentric spheres (due to the crust, mantle, and outer/inner cores). However, this will only occur if time permits, as will a preliminary examination of dielectrics.


Week 1 (4/6-4/12): Work on the simplest case of a point charge, and learn to work within Mathematica

Week 2 (4/13-4/19): Work to create manipulatable object for electric field of sphere, and begin working on modeling the average magnetic field for a spherical object with uniform current density

Week 3 (4/20-4/26): Model electric and magnetic fields of concentric spherical objects, submit preliminary results on Tuesday on blog

Week 4 (4/27-5/3): Wrap up, submit final data and conclusion on Wednesday, dielectrics if time permits


I am working with Brian Deer, who is focusing on bar magnets, and Tewa Kpulun, who is focusing on cylindrical objects. We will be meeting weekly to discuss our progress, share Mathematica-related insights, and help each other in whatever ways we can.




Project Proposal: Modeling of EM Fields for Spheres in Mathematica

For my project, I propose the modeling of electromagnetic fields for spheres. I will use Mathematica to start, and possibly attempt to use other software products as well, such as OriginLab or MatLab. I will begin with the simplest case of a hollow sphere with radius approaching zero, or a point charge. I will then model electric fields for conducting spheres of different radii. From there, I will attempt other cases as well, potentially including: concentric spheres, spherical dielectrics, and systems of multiple spheres. Additionally, I will attempt to model magnetic fields for currents traveling in a spherical conductor, and magnetic fields within and surrounding spherical dielectrics.