lj_mwp - # -*- coding: utf-8 -*from __future__ import...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # -*- coding: utf-8 -*from __future__ import division from visual import * ## Objects - a massive ion and an oxygen atom molecule = sphere(pos=vector(1,0,0), radius=0.25, color=color.cyan) oxygen = sphere(pos=vector(-2.57, 5.73, 0), radius=0.1, color=color.red) ##ftanarr = arrow(color=color.magenta) ##fperparr = arrow(color=color.blue) ## Constants k = 3.126e-19 ## k is a known constant (strength parameter) oxygen.mass = 5e-23 ## mass of the oxygen atom voxygen = vector(-0.04, -2.417, 0) ## initial velocity of the oxygen atom poxygen = oxygen.mass*voxygen ## initial momentum of the oxygen atom fscale = 1e24 ## Trail to visualize the path of the oxygen atom trail = curve(color=oxygen.color) ## Time step and initialization deltat = 1e-5 t=0 while t < 6.3: ## The interaction that you will model is stated in the WebAssign question r = oxygen.pos - molecule.pos rmag = mag(r) rhat = r/rmag Fnet = -(k/(rmag**7))*rhat ## Update the oxygen atom's position (The ion is so massive, it moves very little) pi = mag(poxygen) poxygen = poxygen + Fnet*deltat ftan = (mag(poxygen)-pi)/deltat * poxygen/mag(poxygen) fperp = Fnet - ftan oxygen.pos = oxygen.pos + poxygen/oxygen.mass*deltat ## ftanarr.pos = oxygen.pos ## ftanarr.axis = ftan*fscale ## fperparr.pos = oxygen.pos ## fperparr.axis = fperp*fscale ## Add the position to the trail trail.append(pos=oxygen.pos) ## Update the time t = t + deltat print "Oxygen position = ", oxygen.pos print "Oxygen velocity = ", poxygen/oxygen.mass print "Ftan = ", mag(ftan) print "Fperp = ", mag(fperp) ...
View Full Document

This note was uploaded on 09/12/2011 for the course PHYISCS 2211 taught by Professor Jarrio during the Spring '10 term at Georgia Institute of Technology.

Page1 / 2

lj_mwp - # -*- coding: utf-8 -*from __future__ import...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online