Instantly share code, notes, and snippets.

# dougmcnally/newtonian_gravity.py Created May 24, 2016

 # plot F_g vs. separation distance import numpy import pylab m_earth = 5.972e24 #kg r_earth = 6.371e6 #m m_person = 80 #kg G = 6.67408e-11 #m^3 / (kg * s^2) # average separation between Mars and Earth = 225e9 m # http://www.universetoday.com/14824/distance-from-earth-to-mars/ # ISS approximate distance from surface of Earth = 4e5 m max_dist = 4e5 #m dists = numpy.arange(0, max_dist, max_dist / 1000) F_g = list() for r in dists: F_g.append(G * m_earth * m_person / (r+r_earth)**2) print "F_g at the Earth's surface is %.2f N" % F_g[0] print "F_g at %.2f m is %.2f N" % (dists[-1], F_g[-1]) #plotting stuff: pylab.xlabel("y (m)", fontsize=18) pylab.ylabel("\$F_g\$ (N)", fontsize=18) pylab.title("Weight vs. Separation Distance from Earth (\$m = " + str(m_person) + "\$ kg)") pylab.plot(dists, F_g) pylab.ylim(ymax=10*m_person, ymin=0) pylab.savefig("F_gvsy_spacestation.png",bbox_inches="tight",dpi=600) pylab.show()