Created
October 24, 2019 14:37
-
-
Save hannorein/456baa3ec816cb90adf62189147dcb2c to your computer and use it in GitHub Desktop.
This file contains 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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Starlink in REBOUND\n", | |
"Use [Cees Bassa](https://twitter.com/cgbassa)'s [notebook](https://nbviewer.jupyter.org/github/cbassa/satellite_analysis/blob/master/starlink_sunlit_satellites.ipynb) to generate the `tles.txt` file with the orbital parameters of the starlink constellation. " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import rebound\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sim = rebound.Simulation()\n", | |
"sim.G = 6.67408e-20 # m^3 / kg s^2\n", | |
"sim.add(m = 5.972e24) # earth mass in kg\n", | |
"sim.N_active = 1\n", | |
"with open(\"tles.txt\", \"r\") as fp:\n", | |
" lines = fp.readlines()\n", | |
" for i in range(len(lines)//3):\n", | |
" fields = lines[i*3+2].split()\n", | |
" n = float(fields[7])/24/60/60*np.pi*2.\n", | |
" a = np.power(sim.G*sim.particles[0].m/(n*n),1./3.)\n", | |
" sim.add(a=a,\n", | |
" inc=float(fields[2])/180.*np.pi,\n", | |
" Omega=float(fields[3])/180.*np.pi,\n", | |
" e=float(\"0.\"+fields[4]),\n", | |
" omega=float(fields[5])/180.*np.pi,\n", | |
" M=float(fields[6])/180.*np.pi)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sim.getWidget(size=(500,500),orbits=False)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sim.integrator = \"leapfrog\"\n", | |
"sim.dt = 0.1\n", | |
"sim.integrate(sim.t+1000)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Using the Moon the clear up the mess\n", | |
"Same as before, but now the simulation includes the Moon at a distance 50 times closer than in reality." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sim = rebound.Simulation()\n", | |
"sim.G = 6.67408e-20 # m^3 / kg s^2\n", | |
"sim.add(m=5.972e24) # earth mass in kg\n", | |
"sim.add(m=7.348e22, a=384400/50, inc=0.0898, e=0.0549) # moon in kg, km\n", | |
"sim.N_active = 2\n", | |
"with open(\"tles.txt\", \"r\") as fp:\n", | |
" lines = fp.readlines()\n", | |
" for i in range(len(lines)//3):\n", | |
" fields = lines[i*3+2].split()\n", | |
" n = float(fields[7])/24/60/60*np.pi*2.\n", | |
" a = np.power(sim.G*sim.particles[0].m/(n*n),1./3.)\n", | |
" sim.add(a=a,\n", | |
" inc=float(fields[2])/180.*np.pi,\n", | |
" Omega=float(fields[3])/180.*np.pi,\n", | |
" e=float(\"0.\"+fields[4]),\n", | |
" omega=float(fields[5])/180.*np.pi,\n", | |
" M=float(fields[6])/180.*np.pi)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sim.getWidget(size=(500,500),orbits=False)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sim.integrator = \"leapfrog\"\n", | |
"sim.dt = 0.5\n", | |
"sim.integrate(sim.t+10000)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"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.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment