-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtestProp.py
92 lines (66 loc) · 1.91 KB
/
testProp.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
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 15 21:35:00 2018
@author: carlos
"""
# Propulsive model for a heterogeneous rocket. Still on development!
from numpy import full
class modelPropulsion():
def __init__(self, p1: object, p2: object, tf: float, v1: float,
v2: float):
self.t1 = p1.tf[-1]
self.t2 = tf - p2.tb[-1]
self.t3 = tf
self.v1 = v1
self.v2 = v2
self.p1 = p1
self.p2 = p2
def __indexFinder(self, t: float, p)-> int:
ans = 0
for tf in p.tf:
if t > tf:
ans = ans + 1
return ans
def __intervalFinder(self, t: float)-> float:
if t <= self.t1:
interval = 1
elif t <= self.t2:
interval = 2
elif t <= self.t3:
interval = 3
else:
interval = 4
return interval
def beta(self, t: float)-> float:
interval = self.__intervalFinder(t)
if interval == 1 and interval == 3:
beta = self.v1
else:
beta = self.v2
return beta
def thrustIsp(self, t: float)-> float:
interval = self.__intervalFinder(t)
if interval == 1:
ii = self.__indexFinder(t)
T = self.p1.T[ii]
Isp = self.p1.Isp[ii]
elif interval == 3:
ii = self.__indexFinder(t - self.t2)
T = self.p2.T[ii]
Isp = self.p2.Isp[ii]
else:
T = 0.0
Isp = 1
return T, Isp
def value(self, t: float)-> float:
T, Isp = self.thrustIsp(t)
return self.beta(t), T, Isp
def mdlDer(self, t: float)-> tuple:
return self.beta(t), self.Isp, self.T
def multValue(self, t: float):
N = len(t)
ans = full((N, 1), 0.0)
for jj in range(0, N):
ans[jj] = self.value(t[jj])
return ans