-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelevator.py
70 lines (58 loc) · 1.98 KB
/
elevator.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
grav_const = 6.67430 * (10**(-11))
class celestial_body:
def __init__(self, m, r, ang_vel):
self.m = m # mass
self.r = r # radius
self.ang_vel = ang_vel
self.tan_vel = ang_vel * r
self.mu = grav_const * m # standard grav. param.
def get_tan_vel_at(self, h):
return self.ang_vel * (self.r + h)
class elevator:
def __init__(self, body, h, A, mtl):
self.body = body # the planet the elevator is on
self.h = h # height
self.A = A # area parallel to the body surface (a function)
self.mtl = mtl # material the elevator is mainly made out of
def get_A_at(self, h):
return self.A(h)
def get_gravitational_pull(self, hl, hh):
weight = 0
dh = (hh - hl)/1000
for i in range(1000):
hi = hl + i * dh
A = self.get_A_at(hi)
V = dh * A
dm = V * self.mtl.get_density()
dw = (self.body.mu * dm) / ((self.body.r + hi)**(2))
weight += dw
return weight
def get_inertial_pull(self, hl, hh):
inertial_pull = 0
dh = (hh - hl)/1000
for i in range(1000):
hi = hl + i * dh
A = self.get_A_at(hi)
V = dh * A
dm = V * self.mtl.get_density()
vel = self.body.get_tan_vel_at(hi)
dpull = (dm * vel**2)/(self.body.r + hi)
inertial_pull += dpull
return inertial_pull
def get_stress_at(self, h):
A = self.get_A_at(h)
P = -self.get_gravitational_pull(h, self.h) + self.get_inertial_pull(h, self.h)
stress = P/A
return stress
def get_mass_between(self, hl, hh):
mass = 0
dh = (hh - hl)/1000
for i in range(1000):
hi = hl + i * dh
A = self.get_A_at(hi)
V = dh * A
dm = V * self.mtl.get_density()
mass += dm
return mass
def get_tan_vel_at(self, h):
return self.body.get_tan_vel_at(h)