Skip to content

Instantly share code, notes, and snippets.

@benrules2
Created November 13, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benrules2/537a133fd0bea29d47c485ecb1187e47 to your computer and use it in GitHub Desktop.
Save benrules2/537a133fd0bea29d47c485ecb1187e47 to your computer and use it in GitHub Desktop.
#planet info which can be added as parameters
sun = {"location":point(0,0,0), "mass":2e30, "velocity":point(0,0,0)}
mercury = {"location":point(0,5.0e7,0), "mass":3.285e23, "velocity":point(47000,0,0)}
venus = {"location":point(0,1.1e11,0), "mass":4.8e24, "velocity":point(35000,0,0)}
earth = {"location":point(0,1.5e11,0), "mass":6e24, "velocity":point(30000,0,0)}
mars = {"location":point(0,2.2e11,0), "mass":2.4e24, "velocity":point(24000,0,0)}
jupiter = {"location":point(0,7.7e11,0), "mass":1e28, "velocity":point(13000,0,0)}
saturn = {"location":point(0,1.4e12,0), "mass":5.7e26, "velocity":point(9000,0,0)}
uranus = {"location":point(0,2.8e12,0), "mass":8.7e25, "velocity":point(6835,0,0)}
neptune = {"location":point(0,4.5e12,0), "mass":1e26, "velocity":point(5477,0,0)}
pluto = {"location":point(0,3.7e12,0), "mass":1.3e22, "velocity":point(4748,0,0)}
if __name__ == "__main__":
#build parameter lists with consistent body order
locations = [sun["location"], earth["location"], mars["location"], venus["location"]]
masses = [sun["mass"], earth["mass"], mars["mass"], venus["mass"]]
velocities = [sun["velocity"], earth["velocity"], mars["velocity"], venus["velocity"]]
if(len(locations) != len(masses) or len(locations) != len(velocities)):
print("List lengths are unequal, check inputs")
motions = run_simulation(locations, velocities, masses, time_step = 50, number_of_steps = 80000, report_freq = 100)
plot_output(motions, max_range = 1e11, outfile = 'orbits.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment