Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. from __future__ import division
  2. from visual import *
  3.  
  4. ##constants
  5. oofpez = 9e9
  6. q_proton = 1.6e-19
  7. obs_scalar = 1e10
  8. e_scalar = 2e-10
  9.  
  10. ##objects
  11. particle = sphere(pos=(1e-10,0,0),rad=2e-11)
  12.  
  13. ##initial values
  14. obslocation_1 = vector(3.1e-10,-2.1e-10,0)
  15. obslocation_2 = vector(4e-10,0,0)
  16. obslocation_3 = vector(3e-10,1e-10,0)
  17. obslocation_4 = vector(2e-10,2e-10,0)
  18. obslocation_5 = vector(3.1e-10,-2.1e-10,0)
  19. obslocation_6 = vector(3.1e-10,-2.1e-10,0)
  20. obslocation_7 = vector(3.1e-10,-2.1e-10,0)
  21.  
  22. r = obslocation_1 - particle.pos
  23. ra = arrow(pos = particle.pos, axis=obs_scalar*r, color=color.green)
  24. rmag = mag(r)
  25. rhat = norm(r)
  26.  
  27. #calculate field
  28. E_1 = oofpez * q_proton * rhat / rmag**2
  29. ea = arrow(pos = obslocation_1, axis =e_scalar*E_1, color=color.magenta)
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. print oofpez
  37. print "relative position vector is ", r
  38. print "magnitude of r is ", rmag
  39. print "unit vector rhat is ", rhat
  40. print "Electric field vector #1 is: ", E_1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement