-
Notifications
You must be signed in to change notification settings - Fork 11
/
motor.py
118 lines (85 loc) · 3.24 KB
/
motor.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
"Electric motor model "
from gpkit import Model, parse_variables
from gpkit.constraints.tight import Tight as TCS
from gpkitmodels.GP.aircraft.prop.propeller import Propeller, Actuator_Propeller
from gpkitmodels import g
class MotorPerf(Model):
""" Electric Motor Performance Model
Variables
---------
Pshaft [kW] motor output shaft power
Pelec [kW] motor input shaft power
etam [-] motor efficiency
Q [N*m] torque
omega [rpm] propeller rotation rate
i [amps] current
v [V] woltage
i0 4.5 [amps] zero-load current
Kv 29 [rpm/V] motor voltage constant
R .033 [ohms] internal resistance
"""
def setup(self, static, state):
exec parse_variables(MotorPerf.__doc__)
return [Pshaft == Q*omega,
Pelec == v*i,
etam == Pshaft/Pelec,
static.Qmax >= Q,
v <= static.V_max,
TCS([i >= Q*Kv+i0]),
TCS([v >= omega/Kv + i*R])
]
class Motor(Model):
""" Electric Motor Model
Variables
---------
Qstar .5 [kg/(N*m)] motor specific torque
W [lbf] motor weight
Qmax [N*m] motor max. torque
V_max 300 [V] motor max voltage
"""
flight_model = MotorPerf
def setup(self):
exec parse_variables(Motor.__doc__)
constraints = [W >= Qstar*Qmax*g]
return constraints
class PropulsorPerf(Model):
"""Propulsor Performance Model
Variables
---------
V_static 1 [cm/s] inflow velocity for static thrust
"""
def setup(self, static, state):
exec parse_variables(PropulsorPerf.__doc__)
self.prop = static.prop.flight_model(static.prop, state)
self.motor = static.motor.flight_model(static.motor, state)
self.components = [self.prop, self.motor]
constraints = [self.prop.Q == self.motor.Q,
self.prop.omega == self.motor.omega
]
return constraints, self.components
class Propulsor(Model):
"""Propulsor model
Variables
---------
W [lbf] propulsor weight
"""
flight_model = PropulsorPerf
def setup(self):
exec parse_variables(Propulsor.__doc__)
self.prop = Propeller()
self.motor = Motor()
components = [self.prop, self.motor]
return [self.W >= self.prop.W + self.motor.W], components
class Actuator_Propulsor(Model):
"""Propulsor model
Variables
---------
W [lbf] propulsor weight
"""
flight_model = PropulsorPerf
def setup(self):
exec parse_variables(Propulsor.__doc__)
self.prop = Actuator_Propeller()
self.motor = Motor()
components = [self.prop, self.motor]
return [self.W >= self.prop.W + self.motor.W], components