-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter 7.py
81 lines (68 loc) · 1.1 KB
/
chapter 7.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import math
import matplotlib.pyplot as plt
mi = 4000
mf = 27000
fr = 230
sg = 2500
g = 9.8
re = 6371000
y = 0.00001
distance = []
times = []
t = 0
dt = 0.01
v0 = 0
vf = 0
burnouttime = 0
def g(y):
return 9.8*(re/(re+y))**2
def m(t):
m = mi + mf - fr*t
if m >= mi:
return m
else:
return mi
def findburnouttime():
t = 0
m = mi + mf
while m >= mi:
m -= fr * dt
t+=dt
print("burnouttime: ", t)
def anet(t, m, g):
if m == mi:
return -g
else:
return (sg*fr - m*g)/m
def vertdist(t, v0, vf):
return dt*(v0 + vf)/2
while t <= mf/fr:
vf = v0 + anet(t, m(t), g(y))*dt
y += vertdist(t, v0, vf)
distance.append(y)
times.append(t)
# print(y, t)
t+=dt
v0 = vf
print(mf/fr)
print(vf)
print(y)
v0 = 0
vf = 0
y = 0
t = 0
while vf >=0:
vf = v0 + anet(t, m(t), g(y))*dt
y += vertdist(t, v0, vf)
distance.append(y)
times.append(t)
# print(y, t)
t+=dt
v0 = vf
print(y)
#
# plt.plot(times, distance)
# plt.ylabel('position (m)')
# plt.xlabel('t(s)')
# plt.title("graph")
# plt.show()