Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
summer_2019:gravitation [2019/08/06 02:52] tallpaul |
summer_2019:gravitation [2019/08/06 02:56] tallpaul |
||
---|---|---|---|
Line 1: | Line 1: | ||
**Follow this link for the activity and the instructions: [[https://trinket.io/library/trinkets/4b1a7a7441|link]]** | **Follow this link for the activity and the instructions: [[https://trinket.io/library/trinkets/4b1a7a7441|link]]** | ||
+ | |||
+ | **Or, read the instructions after the image below, and copy the code into your own GlowScript file.** | ||
You should see something that looks like this: | You should see something that looks like this: | ||
Line 18: | Line 20: | ||
For more information on glowscript tools, check out: [[https://www.glowscript.org/docs/GlowScriptDocs/index.html]] | For more information on glowscript tools, check out: [[https://www.glowscript.org/docs/GlowScriptDocs/index.html]] | ||
+ | |||
+ | <code> | ||
+ | GlowScript 2.7 VPython | ||
+ | |||
+ | # Window setup | ||
+ | scene.width = 600 | ||
+ | scene.height = 400 | ||
+ | |||
+ | # Objects | ||
+ | Earth = sphere(pos=vec(0, 0, 0), radius=6.4e6, texture=textures.earth) | ||
+ | Satellite = sphere(pos=vec(7 * Earth.radius, 0, 0), radius=1e6, color=color.red, make_trail=True) | ||
+ | |||
+ | # Parameters and Initial Conditions | ||
+ | G = 6.7e-11 | ||
+ | mEarth = 6e24 | ||
+ | mSatellite = 20 | ||
+ | pSatellite = vector(0, 50000, 0) | ||
+ | |||
+ | # Time and time step | ||
+ | t = 0 | ||
+ | tFinal = 1 * 60 * 60 * 24 # 1 day | ||
+ | dt = 1 | ||
+ | |||
+ | ############################# Extra ############################## | ||
+ | ## energyGraph = graph(xtitle='time (s)', ytitle='energy (J)') ## | ||
+ | ## kineticGraph = gcurve(color=color.green, label='kinetic') ## | ||
+ | ## potentialGraph = gcurve(color=color.blue, label='potential') ## | ||
+ | ################################################################## | ||
+ | |||
+ | |||
+ | ################################# Extra Extra ################################### | ||
+ | ## FnetArrow = arrow(pos=Satellite.pos, axis=vec(0, 0, 0), color=color.yellow) ## | ||
+ | ################################################################################# | ||
+ | |||
+ | |||
+ | # Calculation Loop | ||
+ | while t < tFinal: | ||
+ | rate(10000) | ||
+ | |||
+ | Fnet = vec(0, 0, 0) | ||
+ | |||
+ | pSatellite = pSatellite + Fnet * dt | ||
+ | Satellite.pos = Satellite.pos + (pSatellite / mSatellite) * dt | ||
+ | |||
+ | t = t + dt | ||
+ | | ||
+ | ############ Extra ############ | ||
+ | ## kineticGraph.plot(t, 0) ## | ||
+ | ## potentialGraph.plot(t, 0) ## | ||
+ | ############################### | ||
+ | | ||
+ | | ||
+ | ########### Extra Extra ########### | ||
+ | ## FnetArrow.pos = vec(0, 0, 0) ## | ||
+ | ## FnetArrow.axis = vec(0, 0, 0) ## | ||
+ | ################################### | ||
+ | |||
+ | | ||
+ | # Earth Rotation (just for fun!) | ||
+ | theta = 2 * pi * dt / tFinal | ||
+ | Earth.rotate(angle=theta, axis=vec(0, 1, 0), origin=Earth.pos) | ||
+ | </code> |