from __future__ import division from visual import * ## INITIAL VALUE OF B B0 = vector(0,0.2,0) ## THIS CODE DRAWS A FLOOR AND DISPLAYS THE MAGNETIC FIELD ************* xmax = .6 dx = .1 yg = -.1 for x in arange(-xmax, xmax+dx, dx): curve(pos=[(x,yg,-xmax),(x,yg,xmax)], color=(.7,.7,.7)) for z in arange(-xmax, xmax+dx, dx): curve(pos=[(-xmax,yg,z),(xmax,yg,z)],color=(.7,.7,.7)) bscale = 1 for x in arange(-xmax, xmax+dx, 2*dx): for z in arange(-xmax, xmax+dx, 2*dx): arrow(pos=(x,yg,z), axis=B0*bscale, color=(0,.8,.8)) ## YOUR PROGRAM BEGINS HERE ##******************************************* deltat = 1e-11 t = 0. while 1: ## Implement steps 1-3 after making the proton move in a straight line (step 4). ## 1) Add code to calculate the magnetic force on moving proton. ## The function cross(a,b) calculates the cross product axb. ## 2) Calculate the new momentum of the proton (see handout). ## 3) Calculate the new velocity of the proton (p/m). ## 4) Update the position of the proton (initially, it moved in a straight line).