/
motor_test.py
146 lines (116 loc) · 3.55 KB
/
motor_test.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
from gpkit import Model, parse_variables, SignomialsEnabled, SignomialEquality, units
from motor import Actuator_Propulsor,Propulsor, Motor, MotorPerf
from gpkitmodels.GP.aircraft.prop.propeller import Propeller
from gpkitmodels.GP.aircraft.wing.wing_test import FlightState
class Propulsor_Test(Model):
"""Propulsor Test Model
"""
def setup(self):
fs = FlightState()
p = Propulsor()
pp = p.flight_model(p,fs)
pp.substitutions[pp.prop.T] = 100
#pp.substitutions[pp.prop.AR_b] = 15
self.cost = 1./pp.motor.etam + p.W/(1000*units('lbf')) + 1./pp.prop.eta
return fs,p,pp
class Actuator_Propulsor_Test(Model):
"""Propulsor Test Model
"""
def setup(self):
fs = FlightState()
p = Actuator_Propulsor()
pp = p.flight_model(p,fs)
pp.substitutions[pp.prop.T] = 100
#pp.substitutions[pp.prop.AR_b] = 15
self.cost = pp.motor.Pelec/(1000*units('W')) + p.W/(1000*units('lbf'))
return fs,p,pp
def actuator_propulsor_test():
test = Actuator_Propulsor_Test()
#sol = test.debug()
sol = test.solve()
#sol = test.solve()
print sol.table()
def propulsor_test():
test = Propulsor_Test()
#sol = test.debug()
sol = test.localsolve(iteration_limit = 400)
#sol = test.solve()
print sol.table()
class Motor_P_Test(Model):
def setup(self):
fs = FlightState()
m = Motor()
mp = MotorPerf(m,fs)
self.mp = mp
mp.substitutions[m.Qmax] = 100
mp.substitutions[mp.Q] = 10
self.cost = 1./mp.etam
return self.mp, fs
class speed_280_motor(Model):
def setup(self):
fs = FlightState()
m = Motor()
mp = MotorPerf(m,fs)
self.mp = mp
mp.substitutions[m.Qmax] = 100
mp.substitutions[mp.R] = .7
mp.substitutions[mp.i0] = .16
mp.substitutions[mp.Kv] = 3800
mp.substitutions[mp.v] = 6
self.cost = 1./mp.etam
return self.mp, fs
class hacker_q150_45_motor(Model):
def setup(self):
fs = FlightState()
m = Motor()
mp = MotorPerf(m,fs)
self.mp = mp
mp.substitutions[m.Qmax] = 10000
mp.substitutions[mp.R] = .033
mp.substitutions[mp.i0] = 4.5
mp.substitutions[mp.Kv] = 29
self.cost = 1./mp.etam
return self.mp, fs
def speed_280_test():
test = speed_280_motor()
sol = test.solve()
print sol.table()
class graupner_cam_6x3(Model):
def setup(self):
self.fs = FlightState()
self.p = Propeller()
self.p.substitutions[self.p.R] = (3./12.) #Convert in to ft
return self.p, self.fs
class motorProp(Model):
def setup(self):
p = graupner_cam_6x3()
m = speed_280_motor()
p.fs.substitutions[p.fs.V] = 10
self.cost(1/p.eta)
def motor_test():
test = Motor_P_Test()
sol = test.solve()
#sol = test.debug()
#print sol.table()
def motor_eta_speed():
test = Motor_P_Test()
omega = [.01, 10, 100, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 3000, 4000, 10000, 100000]
eta = []
for o in omega:
test = Motor_P_Test()
test.substitutions[test.mp.omega] = o
sol = test.solve()
eta.append(sol["freevariables"]["etam"])
print omega
print eta
#sol = test.debug()
plt.plot(omega, eta)
plot.show()
print sol.table()
def test():
#motor_test()
actuator_propulsor_test()
#propulsor_test()
if __name__ == "__main__":
test()
#speed_280_test()