Why Galaxies Don’t Fly Apart: Modeling M101 with Python
In this post, I use Python to model the orbital mechanics of stars within a galaxy (using M-101 as a template). By defining a custom velocity function and using calculus to find the peak velocity point, we can visualize how star speeds change with distance and calculate the billions of years required for a single galactic orbit. Stars inside a galaxy continuously orbit to prevent falling into the center of galaxy. The galaxy has a radius of about 90000 light years. We used numpy arrays to hold distances, speeds of stars. The data was also plotted using matplotlib. Here is the code import numpy as np import matplotlib.pyplot as plt # Constants LY_TO_KM = 9.461e12 # More precise Light Year to KM YR_TO_SEC = 365.25 * 24 * 60 * 60 # Include leap year fraction def vel_star(x_frac): """ Models orbital speed v(x) = 350x / (1 + x^2)^(3/4) x_frac: distance in units of 10,000 ly """ return (350 * x_frac) / np.power((1 + x_frac**2), 0.75)...