Wednesday, April 15, 2015

Python Activity: Determine the Electric Potential of the 3 charge arrangement you did in class.

Python Challenges:

Challenge 1: Electric Potential on a ring around an arrangement of point charges.



Original arrangement of charges completed in class.


Picture of the loop used to create the circle and the labels for the points on the ring.



Electric Potential on a ring that surrounds the arrangement of charges.

How this was achieved: I created a while loop that would first create an orange sphere as a visual representation of the location in which we were measuring the electric potential, similar to how we did it in class. Then I repeated the steps we did in class of find the potential of each charge, then adding them together.  The loop would run based on a theta variable, which was the angle starting from 0 going to 2*pi. The radius of the circle used was 5 units. I was able to set each location sphere in rectangular form : (R*cosTHETA, R*sinTHETA, 0). The increment of pi/18 was used to create a solid circle. The only mistake I made was I forgot that this was based on floating point, and I could not use the syntax: while theta != 2pi. To fix this I just changed it to: while theta < 2pi.

Challenge 2: Electric Potential Between 2 uniformly charged Rods and 3 Point charges at 4 observation locations.





For this challenge I decided to create each rod inside of a loop. Each point in each rod had a charge of 1e-9 for the left and -1e-9 for the right. I had to calculate the potential for each observation point and add it to a summation variable for each spot that I would print out at the end of the loop. I decremented the loop by 0.2 to ensure I had plenty of spots to emulate a rod.







No comments:

Post a Comment