mystery_force_mwp - r = magentaParticle.pos -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
from __future__ import division from visual import * ## Objects blueParticle = sphere(pos=vector(5,4,0), radius=0.25, color=color.blue) ## Object that remains still magentaParticle = sphere(pos=vector(-2.46, -2.64, 0), radius=0.25, color=color.magenta) ## Particle that will move trail = curve(color=magentaParticle.color) ## Constants k = 0.468 n = 3 magentaParticle.m = .00261 ## Initial conditions magentaParticle.p = magentaParticle.m*vector(978.1, 570.8, 0) ## Time setup t = 0 deltat = 5e-6 while t < 1.230: #rate(100) ## Comment out if you need to. ## Compute the net force on the magenta particle
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r = magentaParticle.pos - blueParticle.pos rmag = mag(r) rhat = r/rmag Fnet = -(k*rmag**n)*rhat ## Update the momentum of the magenta particle magentaParticle.p = magentaParticle.p + Fnet*deltat ## Position update of the magenta particle magentaParticle.pos = magentaParticle.pos + magentaParticle.p/magentaParticle.m*deltat ## Append trail to follow the magenta particle trail.append(pos=magentaParticle.pos) ## Increase time t = t + deltat print 'position = ', magentaParticle.pos print 'velocity = ', magentaParticle.p/magentaParticle.m...
View Full Document

Ask a homework question - tutors are online