-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathearth_sun_system.py
More file actions
44 lines (35 loc) · 938 Bytes
/
earth_sun_system.py
File metadata and controls
44 lines (35 loc) · 938 Bytes
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
from math import sqrt
from data import *
import matplotlib.pyplot as plt
# earth
xe,ye,ze = 1.0167*AU,0,0
xve,yve,zve = 0,e_ap_v,0
# sun
xs,ys,zs = 0,0,0
xvs,yvs,zvs = 0,0,0
t = 0.0
dt = 1*daysec # every frame move this time
xelist,yelist,zelist = [],[],[]
xslist,yslist,zslist = [],[],[]
while t<5*365*daysec:
# ################ earth #############
rx,ry,rz = xe - xs, ye - ys, ze - zs
modr3_e = (rx**2+ry**2)**1.5#+rz**2)**1.5
fx_e = -gravconst_e*rx/modr3_e
fy_e = -gravconst_e*ry/modr3_e
# fz_e = -gravconst_e*rz/modr3_e
# update quantities how is this calculated? F = ma -> a = F/m
xve += fx_e*dt/Me
yve += fy_e*dt/Me
# zve += fz_e*dt/Me
# update position
xe += xve*dt
ye += yve*dt
# ze += zve*dt
xelist.append(xe)
yelist.append(ye)
# zelist.append(ze)
# update dt
t +=dt
plt.scatter(xelist, yelist)
plt.show()