from __future__ import print_function, division #requested per VPython
import time
from visual import * #make sure this is asterisk char, copy/paste no go
## constants
mzofp = 1e-7
L = 2.5
q = 2*1.6e-19
scalefactor = 7e-9
deltat = 9e-20
#objects & initial conditions
particle = sphere(pos=vector(0,0,-4e-10), radius=1e-11, color=color.red)
velocity = vector(0,0,4e4)
barrow=arrow(pos=vector(-8e-11,0,0), axis=(0,0,0), color=color.cyan)
time.sleep(5) #delays the animation so I have enough time to hit record
scene.autoscale = 0 #starts the scene
while particle.y > -5e-10:
rate(10000) #ensures that only 10000 calculations are made per second
particle.pos = particle.pos + velocity*deltat
r = barrow.pos - particle.pos
rmag = sqrt(r.x**2+r.y**2+r.z**2)
rhat = r/rmag
B = mzofp*q*cross(velocity,rhat)/rmag**2
barrow.axis = B*scalefactor
well, this code runs well. I have a question - What will be the direction of the arrow representing the magnetic field? I was assuming based on the arrow position, that it's in the -y direction. Just need confirmation if either t or f.
Also another question - When the arrow representing magnetic field reaches its maximum length, what will the location of the particle be? I'm not certain how to calculate this part. Confused by this question. Any help appreciated.