physics/elliptical_orbit_plotter.ipynb

108 lines
83 KiB
Plaintext
Raw Permalink Normal View History

2022-11-19 22:41:30 +00:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"a = 5 # SEMI_MAJOR_AXIS Astronomical Units\n",
"b = 2 # SEMI_MINOR_AXIS Astronomical Units\n",
"M_star = 3 # Solar mass\n",
"\n",
"G = 6.67e-11\n",
"\n",
"E = np.sqrt(1 - b**2 / a**2)\n",
"T = np.sqrt(a ** 3 / M_star)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"theta = np.linspace(0, 2 * np.pi, 10_000)\n",
"r = a * (1 - E**2) / (1 + E * np.cos(theta))\n",
"x, y = r * np.cos(theta), r * np.sin(theta)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4d54dca5c1bf4c1ea47e63b0a9d18cb4",
"version_major": 2,
"version_minor": 0
},
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/av/WaAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB4B0lEQVR4nO3dd3hTZf8G8PskTdOZ7r1LoWVP2VM2goCKKAjCKzjxFeHn9kWcvE5cKC6GvjLEgQiIlA2yR4FCW1ra0r1HOtM0Ob8/UqIVChTanIz7c125yjk5J/nmIU3uPuec5xFEURRBRERERDZDJnUBRERERGRaDIBERERENoYBkIiIiMjGMAASERER2RgGQCIiIiIbwwBIREREZGMYAImIiIhsDAMgERERkY1hACQiIiKyMQyARERERDaGAZCIiIjIxjAAEhEREdkYBkAiIiIiG8MASERERGRjGACJiIiIbAwDIBEREZGNYQAkIiIisjEMgEREREQ2hgGQiIiIyMYwABIRERHZGAZAIiIiIhvDAEhERERkYxgAiYiIiGwMAyARERGRjWEAJCIiIrIxDIBERERENoYBkIiIiMjGMAASERER2RgGQCIiIiIbwwBIREREZGMYAImIiIhsDAMgERERkY1hACQiIiKyMQyARERERDaGAZCIWp0gCFi8eLFxedWqVRAEAenp6cZ1Q4cOxdChQ1v0edPT0yEIAlatWtWij3vZnj17IAgC9uzZ0yqP35RZs2bBxcXlhrb9Z9sTEQEMgER0ky6HuKZuhw8fNlkta9aswYcffmiy57tZ586dwwMPPICgoCAolUoEBgZi+vTpOHfunMlqOHjwIBYvXoyysjKTPScRmR87qQsgIsv22muvISIi4or1UVFRzXqc7du333QNa9asQXx8PObPn99ofVhYGGpqaqBQKG76sVvKzz//jPvvvx+enp546KGHEBERgfT0dHzzzTf48ccfsW7dOkyePLnFn7empgZ2dn991B88eBCvvvoqZs2aBXd39xZ/PiKyDAyARHRLxo4di169et3y49jb27dANY0JggAHB4cWf9zmunjxImbMmIHIyEjs27cPPj4+xvueeuopDBo0CDNmzMCZM2cQGRnZ5ONUVVXB2dm5Wc9tDq+fiMwPDwETkVn45zmAl8+vW79+PV588UX4+/vD2dkZd955JzIzMxvtt2XLFly6dMl4+Dk8PBxA0+cAJiYm4t5774WPjw8cHR0RHR2Nl156yXj/pUuX8PjjjyM6OhqOjo7w8vLClClTGp2z2Bzvvvsuqqur8eWXXzYKfwDg7e2NL774AlVVVXjnnXeM6xcvXgxBEHD+/HlMmzYNHh4eGDhwYKN9U1NTMXr0aDg7OyMwMBCvvfYaRFFstM3fzwFcvHgxnnnmGQBARESEsb1u9nURkeViDyAR3ZLy8nIUFRU1WicIAry8vFrk8d98800IgoDnnnsOBQUF+PDDDzFixAjExcXB0dERL730EsrLy5GVlYWlS5cCwDUvkDhz5gwGDRoEhUKBhx9+GOHh4bh48SJ+++03vPnmmwCAY8eO4eDBg7jvvvsQHByM9PR0fP755xg6dCjOnz8PJy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aRImTZqE+Ph4E1ZOREREZHpWMRfwtm3bGi2vWrUKvr6+OHHiBAYPHnzVfT766COMGTMGzzzzDADg9ddfR2xsLD799FMsX7681WsmIiIikopVBMB/Ki8vBwB4eno2uc2hQ4ewYMGCRutGjx6NjRs3NrmPRqOBRqMxLqvVagCGia8v3y4vU+thO5uGJbazXi+iqk6HSk09KmvrUaGpR0WtFpUaHWq0OtTV66Gp1zf81KGuXoS
"text/html": [
"\n",
" <div style=\"display: inline-block;\">\n",
" <div class=\"jupyter-widgets widget-label\" style=\"text-align: center;\">\n",
" Figure\n",
" </div>\n",
" <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/av/WaAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB4B0lEQVR4nO3dd3hTZf8G8PskTdOZ7r1LoWVP2VM2goCKKAjCKzjxFeHn9kWcvE5cKC6GvjLEgQiIlA2yR4FCW1ra0r1HOtM0Ob8/UqIVChTanIz7c125yjk5J/nmIU3uPuec5xFEURRBRERERDZDJnUBRERERGRaDIBERERENoYBkIiIiMjGMAASERER2RgGQCIiIiIbwwBIREREZGMYAImIiIhsDAMgERERkY1hACQiIiKyMQyARERERDaGAZCIiIjIxjAAEhEREdkYBkAiIiIiG8MASERERGRjGACJiIiIbAwDIBEREZGNYQAkIiIisjEMgEREREQ2hgGQiIiIyMYwABIRERHZGAZAIiIiIhvDAEhERERkYxgAiYiIiGwMAyARERGRjWEAJCIiIrIxDIBERERENoYBkIiIiMjGMAASERER2RgGQCIiIiIbwwBIREREZGMYAImIiIhsDAMgERERkY1hACQiIiKyMQyARERERDaGAZCIWp0gCFi8eLFxedWqVRAEAenp6cZ1Q4cOxdChQ1v0edPT0yEIAlatWtWij3vZnj17IAgC9uzZ0yqP35RZs2bBxcXlhrb9Z9sTEQE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J6JYsWrToqutXrlzZIgHwxRdfxJkzZ7BkyRJUVFRg+PDh+OyzzxqNxff4448jLi4OK1euxNKlSxEWFtZkAOzatSsOHz6M//znP/j8889RW1uLsLAw3HvvvcZtPvroI8jlcnz//feora3FgAEDsGPHDowePfqmX8eUKVMQExODJUuWGEOfl5cXhg0bhhdffPG6F6b8k1wux7Zt2/DYY4/hmWeegaurK1555ZUm/z8uu+222/D6669j+fLl2LZtG/R6PdLS0hgAiWyMIP7zOAcRkRnYs2cPhg0bhg0bNlwxJh8REd0angNIREREZGMYAImIiIhsDAMgERERkY3hOYBERERENoY9gEREREQ2hgGQiIiIyMYwABIRERHZGA4EfQv0ej1ycnLg6urK+TWJiIgshCiKqKioQGBgIGQy2+wLYwC8BTk5OQgJCZG6DCIiIroJmZmZCA4OlroMSTAA3gJXV1cAhjeQSqWCVqvF9u3bMWrUKCgUComrs15sZ9NgO5sG29k02M6mYwltrVarERISYvwet0UMgLfg8mFflUplDIBOTk5QqVRm+6a3Bmxn02A7mwbb2TTYzqZjSW1ty6dv2eaBbyIiIiIbxgBIREREZGMYAImIiIhsDAMgERERkY1hACQiIiKyMQyARERERDaGAZCIiIjIxjAAEhEREdkYBkAiIiIiG2MVAXDJkiW47bbb4OrqCl9fX0yaNAlJSUnX3W/Dhg2IiYmBg4MDOnfujK1bt5qgWiIiIiJpWUUA3Lt3L5544gkcPnwYsbGx0Gq1GDVqFKqqqprc5+DBg7j//vvx0EMP4dSpU5g0aRImTZqE+Ph4E1ZOREREZHpWMRfwtm3bGi2vWrUKvr6+OHHiBAYPHnzVfT766COMGTMGzzzzDADg9ddfR2xsLD799FMsX7681WsmIiIikopVBMB/Ki8vBwB4eno2uc2hQ4ewYMGCRutGjx6NjRs3NrmPRqOBRqMxLqvVagCGia8v3y4vU+thO5uGJbazXi+iqk6HSk09Kmv
" </div>\n",
" "
],
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.ion()\n",
"fig = plt.figure()\n",
"\n",
"ax = fig.add_subplot()\n",
"ax.plot(x, y)\n",
"ax.set_title(\"Elliptical Orbit\")\n",
"ax.set_xlabel(\"x / AU\")\n",
"ax.set_ylabel(\"y / AU\")\n",
"\n",
"plt.grid()\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.2 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}