Python
Numerical Problem Set 9
Physics 204B
November 20, 2015 Paul Arpin
1 Electric Field Due to Continuous Charge Distributions in Python
1.1 Introduction
In the previous assignment you were asked to write a program that will divide a ring into N segments and then find the center of each of those segments. This week you will distribute charge over the ring and treat each segment like a point charge to find the total electric field due to the charged ring.
You are welcome this week to start from my solution to last weeks assignment. If you are confident in your solution from last week you are welcome to start there as well.
1.2 Geometry of A Ring
Similar to last week, we will be working with the ring shown in the figure below.
x
y
R
θθ +∆θ
Figure 1: Geometry of Ring.
In addition, you may want to reference figure 2 to help clarify how we find the vector ~r which points from a point charge to the place we are measuring the electric field.
1
charger
Q R
P
measurer
measure charger r r= −
Figure 2: Definition of ~r.
2
2 Assignment
Your assignment this week is to write a loop that will calculate the electric field at any point in space due to a uniformly charged ring centered on the origin in the x-y plane. You should assume a total charge on the ring Q, a ring radius R, and a vector location where the electric field will be measured ~rmeasure and calculate the field.
You are welcome to start from my solution to the previous assignment which already has a loop built in to divide the ring into N segments. For each segment you will need to write the steps to calculate the field due to that segment ∆ ~E = k∆q
r2 r̂ and calculate the running
total ~E = ∑
∆ ~E. (If you use my previous solution please comment out my print statement “print r charge”.)
Assume R = 10 cm and Q = 1.5 × 10−3 C. I would encourage you to reference previous assignments (in particular Numerical Assign-
ment 3 where we began practicing with vector math).
1. What is your name?
2. Find the current density λ given Q and R. (Note do not use “lambda” as your variable name.)
3. Find the charge on each segment given λ, R and ∆θ.
4. Calculate ∆ ~E = k∆q r2 r̂ inside the loop for each segment given the charge location and
electric field position. Notice that my previous solution has a commented out step that will sum the individual contributions to find the total electric field – you may use this by deleting the # at the start of the statement.
5. Check that your electric field calculation is working correctly. Using our analytic solu- tion for the electric field along the axis of a uniformly charged ring, I find that for this ring a height z = 10 cm above the ring the z-component of the electric field should be 4.77 × 107 N
m . (Note you likely have to increase N to find your solution converging to
this value.)
6. For what value of N did your solution converge to within 3 significant figures?
7. For values of N smaller than this is your calculated electric field larger or smaller than the analytic value? Explain why this makes sense.
8. Please include raw input() as your final line.
3
- Electric Field Due to Continuous Charge Distributions in Python
- Introduction
- Geometry of A Ring
- Assignment