Skip to content

Commit 2a66a5d

Browse files
committed
New files Added
1 parent 787fbfa commit 2a66a5d

26 files changed

+1949
-1200
lines changed

.ipynb_checkpoints/Astronomical Simulations-checkpoint.ipynb

Lines changed: 0 additions & 205 deletions
This file was deleted.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"from vpython import *\n",
10+
"\n",
11+
"# GlowScript 2.9 VPython\n",
12+
"scene.caption = \"\"\"In GlowScript programs:\n",
13+
"To rotate \"camera\", drag with right button or Ctrl-drag.\n",
14+
"To zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.\n",
15+
" On a two-button mouse, middle is left + right.\n",
16+
"To pan left/right and up/down, Shift-drag.\n",
17+
"Touch screen: pinch/extend to zoom, swipe or two-finger rotate.\"\"\"\n",
18+
"scene.forward = vector(0,-.3,-1)\n",
19+
"\n",
20+
"G = 6.7e-11 # Newton gravitational constant\n",
21+
"\n",
22+
"giant = sphere(pos=vector(-1e11,0,0), radius=2e10, color=color.red, \n",
23+
" make_trail=True, trail_type='points', interval=10, retain=50)\n",
24+
"giant.mass = 2e30\n",
25+
"giant.p = vector(0, 0, -1e4) * giant.mass\n",
26+
"\n",
27+
"dwarf = sphere(pos=vector(1.5e11,0,0), radius=1e10, color=color.yellow,\n",
28+
" make_trail=True, interval=10, retain=50)\n",
29+
"dwarf.mass = 1e30\n",
30+
"dwarf.p = -giant.p\n",
31+
"\n",
32+
"dt = 1e5\n",
33+
"while True:\n",
34+
" rate(200)\n",
35+
" r = dwarf.pos - giant.pos\n",
36+
" F = G * giant.mass * dwarf.mass * r.hat / mag2(r)\n",
37+
" giant.p = giant.p + F*dt\n",
38+
" dwarf.p = dwarf.p - F*dt\n",
39+
" giant.pos = giant.pos + (giant.p/giant.mass) * dt\n",
40+
" dwarf.pos = dwarf.pos + (dwarf.p/dwarf.mass) * dt"
41+
]
42+
}
43+
],
44+
"metadata": {
45+
"kernelspec": {
46+
"display_name": "Python 3",
47+
"language": "python",
48+
"name": "python3"
49+
},
50+
"language_info": {
51+
"codemirror_mode": {
52+
"name": "ipython",
53+
"version": 3
54+
},
55+
"file_extension": ".py",
56+
"mimetype": "text/x-python",
57+
"name": "python",
58+
"nbconvert_exporter": "python",
59+
"pygments_lexer": "ipython3",
60+
"version": "3.7.6"
61+
}
62+
},
63+
"nbformat": 4,
64+
"nbformat_minor": 4
65+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 4
6+
}

0 commit comments

Comments
 (0)