Tuesday, 28 April 2015
V Python2: E Potential two straight vertical lines
from visual import *
k = 8.988e9
#left line positive charges
#Charge 1
c1 = sphere(pos=(-2,3,0), radius=0.2,color=color.blue)
q1= 1e-9 #charge of Charge 1
#charge2
c2 = sphere(pos=(-2,2,0), radius=0.2,color=color.blue)
q2= 1e-9 #charge of Charge 2
#charge3
c3 = sphere(pos=(-2,1,0), radius=0.2,color=color.blue)
q3= 1e-9 #charge of Charge 3
#charge4
c4 = sphere(pos=(-2,0,0), radius=0.2,color=color.blue)
q4= 1e-9 #charge of Charge 4
#right line negative charges
#Charge 5
c5 = sphere(pos=(2,3,0), radius=0.2,color=color.red)
q5= -1e-9 #charge of charge 5
#charge6
c6 = sphere(pos=(2,2,0), radius=0.2,color=color.red)
q6= -1e-9 #charge of Charge 6
#charge7
c7 = sphere(pos=(2,1,0), radius=0.2,color=color.red)
q7= -1e-9 #charge of Charge 7
#charge8
c8= sphere(pos=(2,0,0), radius=0.2,color=color.red)
q8= -1e-9 #charge of Charge 8
#Observation Locations
loc1= sphere(pos=(0.5,2,0), radius = 0.1,color=color.green)
rc1= mag(loc1.pos-c1.pos)
rc2= mag(loc1.pos-c2.pos)
rc3= mag(loc1.pos-c3.pos)
rc4= mag(loc1.pos-c4.pos)
rc5= mag(loc1.pos-c5.pos)
rc6= mag(loc1.pos-c6.pos)
rc7= mag(loc1.pos-c7.pos)
rc8= mag(loc1.pos-c8.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vc4=k*q4/rc4
Vc5=k*q5/rc5
Vc6=k*q6/rc6
Vc7=k*q7/rc7
Vc8=k*q8/rc8
Vnet= Vc1 + Vc2 + Vc3+Vc4+Vc5+Vc6+Vc7+Vc8
L1 = label(pos=loc1.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
loc2= sphere(pos=(-0.5,1,0), radius = 0.1,color=color.green)
rc1= mag(loc1.pos-c1.pos)
rc2= mag(loc1.pos-c2.pos)
rc3= mag(loc1.pos-c3.pos)
rc4= mag(loc1.pos-c4.pos)
rc5= mag(loc1.pos-c5.pos)
rc6= mag(loc1.pos-c6.pos)
rc7= mag(loc1.pos-c7.pos)
rc8= mag(loc1.pos-c8.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vc4=k*q4/rc4
Vc5=k*q5/rc5
Vc6=k*q6/rc6
Vc7=k*q7/rc7
Vc8=k*q8/rc8
Vnet= Vc1 + Vc2 + Vc3+Vc4+Vc5+Vc6+Vc7+Vc8
L2 = label(pos=loc2.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment