Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
summer_2018:gravitation [2018/06/19 03:27] tallpaul created |
summer_2018:gravitation [2018/06/19 03:52] (current) tallpaul [Part B] |
||
---|---|---|---|
Line 20: | Line 20: | ||
Carver is impressed with your work, but remains unconvinced by your predictions. He has asked you to write a simulation that models the orbit of the satellite. To truly convince Carver, the simulation should include representations of the net force acting on the spacecraft, which has a mass of $15\times10^3$ kg. Your simulation should be generalized enough to model other types of orbits including elliptical ones. | Carver is impressed with your work, but remains unconvinced by your predictions. He has asked you to write a simulation that models the orbit of the satellite. To truly convince Carver, the simulation should include representations of the net force acting on the spacecraft, which has a mass of $15\times10^3$ kg. Your simulation should be generalized enough to model other types of orbits including elliptical ones. | ||
- | <WRAP download 35%> Code for Project 3: Part B\\ Keep them in the same directory.\\ {{183_projects:satellite.py|Project 3 Code (satellite.py)}} \\ {{183_projects:physutil.py|PhysUtil Module}}</WRAP> | + | To begin, copy the code below into a glowscript file. |
- | [[:183_notes:learning goals:week 3|Learning Goals Week 3]] | + | <code> |
+ | get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js') | ||
+ | rom __future__ import division | ||
+ | from visual import * | ||
+ | from visual.graph import * | ||
+ | |||
+ | #Window setup | ||
+ | scene.range = 7e7 | ||
+ | scene.width = 1024 | ||
+ | scene.height = 760 | ||
+ | |||
+ | #Objects | ||
+ | Earth = sphere(pos=vector(0,0,0), radius=6.4e6, texture=textures.earth) | ||
+ | Satellite = sphere(pos=vector(7*Earth.radius, 0,0), radius=1e6, color=color.red, make_trail=True) | ||
+ | |||
+ | #Parameters and Initial Conditions | ||
+ | mSatellite = 1 | ||
+ | pSatellite = vector(0,5000,0) | ||
+ | |||
+ | #Time and time step | ||
+ | t = 0 | ||
+ | tf = 60*60*24 | ||
+ | dt = 1 | ||
+ | |||
+ | #MotionMap/Graph | ||
+ | SatelliteMotionMap = MotionMap(Satellite, tf, 20, markerScale=2000, labelMarkerOrder=False) | ||
+ | |||
+ | #Calculation Loop | ||
+ | while t < tf: | ||
+ | rate(10000) | ||
+ | Fnet = vector(0,0,0) | ||
+ | pSatellite = pSatellite + Fnet*dt | ||
+ | Satellite.pos = Satellite.pos + (pSatellite/mSatellite)*dt | ||
+ | SatelliteMotionMap.update(t, pSatellite/mSatellite) | ||
+ | t = t + dt | ||
+ | |||
+ | #Earth Rotation (IGNORE) | ||
+ | theta = 7.29e-5*dt | ||
+ | Earth.rotate(angle=theta, axis=vector(0,0,1), origin=Earth.pos) | ||
+ | </code> |