Python Using VPython program to calculate the E-field

Click For Summary
The discussion centers around creating a VPython program to calculate the electric field (E-field) generated by a charged ring of radius 5.0 cm and total charge of 50 nC. The relevant formula for the E-field above the ring is provided, but there are questions about its applicability beyond the z-axis. Participants suggest modeling the ring as a series of equally spaced point charges to compute the E-field as a vector sum of contributions from each charge. There is uncertainty about how to implement this model, particularly in drawing the vertices of a regular polygon on the circle, which is essential for representing the point charges accurately. The conversation highlights the need for clarity on both the mathematical modeling and the graphical representation of the charge distribution.
HaLAA
Messages
85
Reaction score
0

Homework Statement


Charge a ring of radius R=5.0cm laying in the x-y plane to 50nC.

Create a VPython program that will allow you to calculate the E-field due to the ring anywhere in space.

Homework Equations



E_ring=kQz/(R^2+z^2)^(3/2), point P above the xy-plane

The Attempt at a Solution

from visual import *

C = pi*.10 # meters
Q = 50.0*10**-9 #Coulombs
k = 8.99*10**9 # Nm^2/C^2
E = vector(0.0,0.0,0.0) # N/C

Lambda = Q/C # linear charge density
s=vector(0.025,0.0,0.025)

# we are looking for the E-field due to the ring at anywhere, I think we would have dD,
# but I don't know how to define it.

ds = vector(D/10000,D/10000,D/10000)
dq = mag(Lambda*ds)

while s.x < L+D:

rate=(10000)
dE = k*dq/(mag(s)**2)*norm(s)
E = E + dE
s = s + ds

print 'sx=',s.x,'dE=',dE,'E=',E
print 'E=',E,'N/C'[/B]
 
Technology news on Phys.org
Does your formula for the ring work everywhere? Or just on the axis?

It might better to model ring of charge as a set of equally spaced point charges on the ring.
Then at the point of interest, find the electric-field vector there as a vector sum of electric-field contributions from each point charge.

You can use your formula to check at a point where it is valid.
 
robphy said:
Does your formula for the ring work everywhere? Or just on the axis?

It might better to model ring of charge as a set of equally spaced point charges on the ring.
Then at the point of interest, find the electric-field vector there as a vector sum of electric-field contributions from each point charge.

You can use your formula to check at a point where it is valid.
The formula only model on the z-axis.

I don't know how to model ring of charge as a set of equally spaced point charges on the ring?

Can you give me a hit?
 
Can you draw the vertices of a regular polygon on a circle?
 
robphy said:
Can you draw the vertices of a regular polygon on a circle?
I don't know how to draw it.
 
If you had to draw a regular octagon, what angles would use?
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
485
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 16 ·
Replies
16
Views
1K
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
19
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 22 ·
Replies
22
Views
5K