Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division
- from visual import *
- #const vars
- e = 1.6e-19
- oofpez = 9e9
- scalefactor = 1
- Obslocation = vector(0,0,0)
- #objects
- atom1 = sphere(pos=vector(-500e-9,0,0), radius=10e-9,color=color.red)
- atom1.q = 12*e
- atom2 = sphere(pos = vector(600e-9,0,0), radius = 10e-9, color = color.blue)
- atom2.q = 5*e
- atom3 = sphere(pos = vector(-171e-9,0,0), radius = 10e-9, color = color.blue)
- atom3.q = -e
- Earrow = arrow(pos=Obslocation, axis=vector(0,0,0), color=color.cyan)
- #calc
- r1 = Earrow.pos - atom1.pos
- r2 = Earrow.pos - atom2.pos
- r3 = Earrow.pos - atom3.pos
- r1mag = mag(r1)
- r2mag = mag(r2)
- r3mag = mag(r3)
- r1hat = r1 / r1mag
- r2hat = r2 / r2mag
- r3hat = r3 / r3mag
- E3 = oofpez * (atom3.q / r3mag**2) * r3hat
- E1 = oofpez * (atom1.q / r1mag**2) * r1hat
- E2 = oofpez * (atom2.q / r2mag**2) * r2hat
- Enet = E1 + E2 + E3
- scalefactor = 1e-7/mag(Enet)
- Earrow.axis = scalefactor*Enet
- print "The magnitude of E1 field =",mag(E1),"N/C"
- print "The magnitude of E2 field =",mag(E2),"N/C"
- print "The magnitude of E3 field =",mag(E3),"N/C"
- print "Enet =",Enet,"N/C"
Advertisement
Add Comment
Please, Sign In to add comment