Created
June 18, 2018 23:36
-
-
Save uhho/494820d0badd031d992fe11651caa799 to your computer and use it in GitHub Desktop.
Gravitational accelleration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def g_at_distance(g_base, radius, distance): | |
""" | |
Calculate gravitational accelleration at a distance | |
- above the surface G * (radius / distance)^2 | |
- below the surface G * (distance / radius) | |
Parameters | |
---------- | |
g_base : float | |
gravitational accelleration at the surface | |
radius : int, float | |
surface radius | |
distance : ndarray | |
array of distances from the center of mass | |
Returns | |
------- | |
g : ndarray | |
Gravitational accelleration at a distance | |
""" | |
above = np.divide(radius, distance, where=distance != 0) ** 2 | |
below = (distance / radius) | |
g = g_base * np.where(distance < radius, below, above) | |
return g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment