-
Notifications
You must be signed in to change notification settings - Fork 6
/
ps12.py
58 lines (49 loc) · 1.38 KB
/
ps12.py
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
###############################################################################
#
# CSCI 4446 - Chaotic Dynamics
# File: ps12.py
# Author: Ken Sheedlo
#
# Home Automation Laboratory 9001
#
###############################################################################
from __future__ import division
import getopt
import numpy
import plot
import rungekutta
import sys
from mechanics import twobody
def main(argv=None):
argv = argv or sys.argv
file_prefix = None
try:
options, args = getopt.getopt(argv[1:], 'f:')
for opt, arg in options:
if opt == '-f':
file_prefix = arg
except getopt.GetoptError as err:
print str(err)
return 2
df = twobody(1.0, 0.5, 0.5)
x0 = numpy.array([
0, 0, 0,
0, 0, 0,
1, 0, 0,
0, 1, 0
], dtype=numpy.float64)
ts, xs = rungekutta.rk4(df, 0, x0, 0.005, 7600)
xs = xs.transpose()
plot.render(xs[:,0], xs[:,1], 'b', xs[:,6], xs[:,7], 'r',
xbound=(-10.0, 10.0),
ybound=(0.0, 20.0),
xlabel='x (normalized AU)',
ylabel='y (normalized AU)',
aspect='equal',
title='2-body Orbital Trajectory',
legend=('Star A', 'Star B'),
file_prefix=file_prefix
)
return 0
if __name__ == "__main__":
sys.exit(main())