Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division
- from visual import *
- ##constants
- oofpez = 9e9
- q_proton = 1.6e-19
- obs_scalar = 1e10
- e_scalar = 2e-10
- ##objects
- particle = sphere(pos=(1e-10,0,0),rad=2e-11)
- ##initial values
- obslocation_1 = vector(3.1e-10,-2.1e-10,0)
- obslocation_2 = vector(4e-10,0,0)
- obslocation_3 = vector(3e-10,1e-10,0)
- obslocation_4 = vector(2e-10,2e-10,0)
- obslocation_5 = vector(3.1e-10,-2.1e-10,0)
- obslocation_6 = vector(3.1e-10,-2.1e-10,0)
- obslocation_7 = vector(3.1e-10,-2.1e-10,0)
- r = obslocation_1 - particle.pos
- ra = arrow(pos = particle.pos, axis=obs_scalar*r, color=color.green)
- rmag = mag(r)
- rhat = norm(r)
- #calculate field
- E_1 = oofpez * q_proton * rhat / rmag**2
- ea = arrow(pos = obslocation_1, axis =e_scalar*E_1, color=color.magenta)
- print oofpez
- print "relative position vector is ", r
- print "magnitude of r is ", rmag
- print "unit vector rhat is ", rhat
- print "Electric field vector #1 is: ", E_1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement