numerical methods * Unhappy with the lab procedures. - they do not really work. they work on paper. - you do know enough to measure things now though - from now on, three things: * learning basic numerical simulations (realistic) * characterizing a real projectile experimentally * combining simulation & experiment to really hit targets * how? USB rocket launchers * first: learning to calculate things - we will still do some regular labs, but mostly not * meta-point - most of the time we say 'eqns with drag can't be solved analytically' - big deal, you all have computers in your pockets - why are we not using them? - at least learn the gist of coding - you will not all like it or learn it; need at least 1 per group ... * lab thurs: crash course in numerical calculations (Python) - from now on, bring a laptop if you want - can use any language / prog you like - I'll try to teach you just enough python to get the job done * after that: begin characterizing rocket launchers & working on code - launch velocity? - proper drag equation and parameters? - reliability / spread ? uncertainties ... * this will take time: semester-long project ============ * So, how do the equations look to a computer? - parametric x(t), y(t) and stepping through time projectile: a=const or a=0 for any axis v(t) = vi + at v(0) = vi v(dt) = vi + a*dt an instant later v(t+dt) = vi + a(t+dt) = vi + at + a*dt = v(t) + a*dt velocity at time dt later - just add a*dt! do the same for position x(t+dt) = xi + vi(t+dt) + 0.5*a*(t+dt)^2 = x(t) + v(t)*dt + 0.5*a*(dt)^2 if you know the initial conditions, you can just step through time - how to know when to stop? loops and conditions start with initial position, v, and accelerations step forward by dt update a, v, x (note: can have a depend on v or x!) repeat, keep stepping forward ! implement stop condition - when y=0 again, etc. - pseudocode - example: projectile without drag - example: adding a drag force, in brief * How do we do simple calculations with computers? - pseudocode - evaluating a function like f(x) = x^2 + 1 - direct calculation, print result - function that takes parameters - generating a list of values (array) - Python - declaring constants & variables (simple-math.py) - doing math (simple-math.py) - printing the result (simple-math.py) run and try different numbers repl.it search for python copy & paste code into interpreter: http://pleclair.ua.edu/ph125/python/tutorials/simple-math.py * How to calculate a trajectory? [Python] - set up initial conditions - stepping through time - updating v's, coordinates - constructing a loop - knowing when to stop - defining the function - taking parameters - returning values - first examples - loops and sums - sum n^2 and n^3 from 1 to 20 - starting example (sums.py) - check answer with wolframalpha.com - 1D motion without drag (dropped object) (1D-v2.py) - run and compare with known result for 3 heights without drag (b=0) - run one height with three different drag coefficients and compare - later: more tools, 2D motion - declaring a function (simple-function.py) - loops and sums with functions; recursion (sums2.py) - trajectory without drag - range, (x,y) list, time of flight (simple-no-drag.py) - sketch extension - repeating for different parameters (e.g., angles) (simple-drag.py) * What we will do - USB foam rocket launchers - do we need drag? how to characterize it? - can we accurately model the rocket?