Question: Please help with this VPython code for Physics: This is all the information I have. The book we are using is Matter & Interactions. Code
Please help with this VPython code for Physics: This is all the information I have. The book we are using is Matter & Interactions.

Code from VPEM02:
from __future__ import division, print_function from visual import * scene.width = scene.height = 800
##constants oofpez=9e9 #stands for one over 4 pi epsilon-zero qe=1.6e-19 s=4e-11 sf=1e-12 #ol=vector(0,-3e-10,0) first observation location ol=vector(-3e-10,0,0) thetamax=2*pi dtheta=pi/6 R=1e-8 #radius of circle
p1=sphere(pos=vector(0,s/2,0), radius=1e-11, color=color.red) q1=qe p2=sphere(pos=vector(0,-s/2,0), radius=1e-11, color=color.blue) q2=-qe p3=sphere(pos=vector(s,s/2,0), radius=1e-11, color=color.red) q3=-qe p4=sphere(pos=vector(s,-s/2,0), radius=1e-11, color=color.red) q4=qe
theta=0 while theta rate(500) e_net=vector(0,0,0) r_obs=R*vector(cos(theta), cos(pi/2-theta), 0) r1=r_obs-p1.pos E1=(oofpez*q1/mag(r1)**2)*norm(r1) r2=r_obs-p2.pos E2=(oofpez*q2/mag(r2)**2)*norm(r2) r3=r_obs-p3.pos E3=(oofpez*q3/mag(r3)**2)*norm(r3) r4=r_obs-p4.pos E4=(oofpez*q4/mag(r4)**2)*norm(r4) e_net=(E1+E2+E3+E4) arrow(pos=r_obs, color=color.orange, axis=sf*e_net) theta=theta+dtheta print(e_net)
theta=0 while theta rate(500) e_net=vector(0,0,0) r_obs=R*vector(0, cos(pi/2-theta), cos(theta)) r1=r_obs-p1.pos E1=(oofpez*q1/mag(r1)**2)*norm(r1) r2=r_obs-p2.pos E2=(oofpez*q2/mag(r2)**2)*norm(r2) r3=r_obs-p3.pos E3=(oofpez*q3/mag(r3)**2)*norm(r3) r4=r_obs-p4.pos E4=(oofpez*q4/mag(r4)**2)*norm(r4) e_net=(E1+E2+E3+E4) arrow(pos=r_obs, color=color.orange, axis=sf*e_net, ) theta=theta+dtheta print(e_net)
Motion in a Dipole Field Objectives Electric flelds affect charged particles. In this activity you will predict the motion of a proton in a region near a dipole. Before doing this activity you should have completed activity VPEM02, Electric Field of a Dipole. It l to have completed activity VPO3, Computational Models of Motion, Part 2, which you may have done previously during your study of mechanics. You should also have studied Section 13.9 of the Matter &Inteactions fe textbook. If you have not yet studied either Chapter G (The Energy Principle) or Chapter 16 (Electric Poten- tial) through Section 16.7 in Matter & Internctions fe 4e, you may omit the section on graphing energy in this activity After completing this activity you should be able to: Animate the motion of one or more charges under the influence of an electric field due to several source charges Monitor the sum of kinetic and potential energy for the system to check the accuracy of model predictions 1 Motion of a Proton Start with a copy of the program you wrote in activity VPEMO2: Electric Field of a Dipole. Make sure that your program calculates and displays the fheld of a dipole (not a quadrupole) Modify the program by adding a proton, at rest, at location (-38,0,0). Make it leave a trail by setting make trai1-True in the constructor At the end of the program, add a loop to animate the motion of the proton under the influence of the dipole's electric fleld. Inside this loop, calculate the electric fleld of the dipole at the current position of the proton. Use a value of about 1 x 10-1 s for At, and rate(300) Describe the motion of the proton. Can you explain this motion physically? It may be helpful to comment out the code that calulates and displays the electric fleld in the yz plane, so you can see the motion more easly Change the particle to an antiproton What happens to the particle's motion? Change the particle back to a proton. Position it at location (-3a, -28, D). Observe the trajectory. Try giving the proton a small initial p. Try a few other initial positions, keeping the proton at least 38 away from the center of the dipole. Experiment with initial locations that are not on either axis of the dipole. Describe any interesting trajectories you find. Motion in a Dipole Field Objectives Electric flelds affect charged particles. In this activity you will predict the motion of a proton in a region near a dipole. Before doing this activity you should have completed activity VPEM02, Electric Field of a Dipole. It l to have completed activity VPO3, Computational Models of Motion, Part 2, which you may have done previously during your study of mechanics. You should also have studied Section 13.9 of the Matter &Inteactions fe textbook. If you have not yet studied either Chapter G (The Energy Principle) or Chapter 16 (Electric Poten- tial) through Section 16.7 in Matter & Internctions fe 4e, you may omit the section on graphing energy in this activity After completing this activity you should be able to: Animate the motion of one or more charges under the influence of an electric field due to several source charges Monitor the sum of kinetic and potential energy for the system to check the accuracy of model predictions 1 Motion of a Proton Start with a copy of the program you wrote in activity VPEMO2: Electric Field of a Dipole. Make sure that your program calculates and displays the fheld of a dipole (not a quadrupole) Modify the program by adding a proton, at rest, at location (-38,0,0). Make it leave a trail by setting make trai1-True in the constructor At the end of the program, add a loop to animate the motion of the proton under the influence of the dipole's electric fleld. Inside this loop, calculate the electric fleld of the dipole at the current position of the proton. Use a value of about 1 x 10-1 s for At, and rate(300) Describe the motion of the proton. Can you explain this motion physically? It may be helpful to comment out the code that calulates and displays the electric fleld in the yz plane, so you can see the motion more easly Change the particle to an antiproton What happens to the particle's motion? Change the particle back to a proton. Position it at location (-3a, -28, D). Observe the trajectory. Try giving the proton a small initial p. Try a few other initial positions, keeping the proton at least 38 away from the center of the dipole. Experiment with initial locations that are not on either axis of the dipole. Describe any interesting trajectories you find
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
