-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorbits.html
More file actions
168 lines (142 loc) · 7.98 KB
/
Copy pathorbits.html
File metadata and controls
168 lines (142 loc) · 7.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE HTML>
<!--
ZeroFour by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Orbit Simulator</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body class="no-sidebar is-preload">
<div id="page-wrapper">
<!-- Header Wrapper -->
<div id="header-wrapper">
<div class="container">
<!-- Header -->
<header id="header">
<div class="inner">
<!-- Nav -->
<nav id="nav" >
<ul>
<li>
<a href="index.html">Projects</a>
<ul>
<li><a href="orbits.html">Orbit Simulator</a></li>
<li><a href="projectiles.html">Projectiles in Atmospheres</a></li>
<li><a href="mazes.html">Maze Generation</a></li>
<li><a href="raytracing.html">Raytracing</a></li>
<li><a href="lightsout.html">Lights Out</a></li>
</ul>
</li>
<li><a href="astrophotos.html">Astrophotos</a></li>
<li><a href="about.html">About</a></li>
</ul>
</nav>
</div>
</header>
<div id="banner">
<h2><strong>Cian McDonnell</strong>
</div>
</div>
</div>
<!-- Main Wrapper -->
<div id="main-wrapper">
<div class="wrapper style2">
<div class="inner">
<div class="container">
<div id="content">
<!-- Content -->
<article>
<header class="major">
<h2>Orbit Simulator</h2>
</header>
<video controls="controls" src="images/orbits/orbit_sim_video.mp4">
Your browser does not support the HTML5 Video element.
</video>
<p>Code for this simulator can be found <a href="https://github.com/mcdc64/orbit_simulator">here</a>. Requires tkinter and matplotlib.</p>
<p>In the late 17th century, Isaac Newton published work outlining the nature of a force that causes all of the objects in the universe to attract each other. Today, we call this force gravity.
The gravitational force between any two objects in the universe is given by</p>
<img class="equation" src ="images/orbits/equation_1.png">
<p>where F is the force, G is the gravitational constant, M and m are the masses of the objects, and r is their distance. This is an example of an inverse-square law, a mathematical relation that commonly
appears in physics. If the distance between the objects is doubled, the force is reduced by a factor of four (four being the square of two). <br>As it turns out, a force following an inverse-square law tends to make
particles feeling the force move in repetitive ways or paths.
For gravity, we call these paths orbits. In the simulation above, we have three celestial bodies interacting gravitationally. The blue planet and the green planet both move in predictable paths that are more
or less circular.<br><br> The grey moon, though, moves around wildly, even when left to its own devices. It swings around the two planets unpredictably, sometimes even changing its mind about which of the two it wants
to orbit around.<br><br>Why?</p>
<h2>The Three Body Problem</h2>
<p> As it turns out, the paths on which objects move are only predictable if there are two bodies present that are interacting gravitationally. This scenario is called the "two body" problem, and analytical solutions
for it exist. That is, it is possible to obtain the positions of both bodies as explicit functions of time, given that we know the forces acting on them.<br><br>
However, if we add a third body to the problem, the situation becomes far more complicated. This is called the three body problem, and the equations have so many terms that no analytical solutions exist. This means the
bodies move in chaotic ways, which can change vastly if the initial state of the system is changed even slightly.<br><br>In the simulation shown, the mass of the moon is so small that the gravitational force it exerts
on the two planets is barely felt by them. Therefore the planets move as if they only had one body affecting them - the other planet. They move in predictable ways. However, the moon feels the force of both massive planets,
and it thus tends to move chaotically.
<h2>The semi-implicit Euler's method</h2>
<p>Due to the fact that the objects move unpredictably, we cannot chart their positions as explicit functions of time. Instead, we try to simulate what would actually happen if the objects were in the real world.
This can be broken down into a number of steps, if we know an object's position and velocity at time t:<br><br>
1. Look at the forces acting on each body at a time t.<br><br>
2. Calculate the acceleration of each body according to the forces acting on it (using Newton's 2nd Law, F = ma). <br><br>
3. Given the acceleration, calculate the object's velocity at a future time t + Δt (where Δt is small).<br><br>
4. Given the velocity, calculate the object's position at t + Δt.<br><br>
5. Now we know the position and velocity at t + Δt. Repeat from step 1 until the desired time is reached.<br><br>
This set of steps is a special case of Euler's method, a method of solving ordinary differential equations. We can sum up the steps in the following equations:</p>
<img class = "equation" src = "images/orbits/equation_2.png">
<p>where x(t) and v(t) are the position and velocity at time t, a is the acceleration, t is the current time, and Δt is the difference between the current time and future time.<br><br>
This method is a decent way of determining the positions at a given time, but unfortunately it is not very good for simulating processes that may take a long time.
Every time we make a "step" from t to t + Δt, there is a certain amount of error associated with the new position and velocity, because we approximate the acceleration as constant in the equations above.
With Euler's method, this error tends to make the energy of the system grow with time. If left unchecked, the planets would fly apart!<br><br>
Luckily, there is a small modification that we can make to the set of equations above to resolve this issue. If we use the velocity at t + Δt to calculate the position at t + Δt, the energy does not tend
to grow.</p>
<img class = "equation" src = "images/orbits/equation_3.png">
<p>This method is called the semi-implicit Euler's method. It is used in this simulator, and, assuming the timestep is small enough, the paths of the planets remain stable for many orbits.
</article>
</div>
</div>
</div>
</div>
</div>
<!-- Footer Wrapper -->
<div id="footer-wrapper">
<footer id="footer" class="container">
<div class="row">
<div class="col-6 col-12-medium imp-medium">
<!-- Contact -->
<section>
<h2>Contact</h2>
<div>
<div class="row">
<div class="col-6 col-12-small">
<dl class="contact">
<dt>Email</dt>
<dd>cian@mcdonnell.eu</dd>
<dt>Github</dt>
<dd><a href="https://github.com/mcdc64">Cian McDonnell<a></dd>
</dl>
</div>
</div>
</div>
</section>
</div>
<div class="col-12">
<div id="copyright">
<ul class="menu">
<li style="color:#ddd;">© Cian McDonnell</li><li style="color:#ddd;">Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>
</div>
</div>
</div>
</footer>
</div>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.dropotron.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>