/
motor.py
110 lines (81 loc) · 3.28 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
"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, ActuatorProp
from gpkitmodels import g
class MotorPerf(Model):
""" Electric Motor Performance Model
Note: The last two constraints may not be tight if there is a motor energy
constraint that does not size the motor. TCS removed to prevent
unnecessary warnings - for most normal useage they will be tight.
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
"""
def setup(self, static, state):
exec parse_variables(MotorPerf.__doc__)
Kv = static.Kv
R = static.R
i0 = static.i0
V_max = static.V_max
return [Pshaft == Q*omega,
Pelec == v*i,
etam == Pshaft/Pelec,
static.Qmax >= Q,
v <= V_max,
i >= Q*Kv+i0,
v >= omega/Kv + i*R]
class Motor(Model):
""" Electric Motor Model
Variables
---------
Qstar .8 [kg/(N*m)] motor specific torque
W [lbf] motor weight
Qmax [N*m] motor max. torque
V_max 300 [V] motor max voltage
Kv_min 1 [rpm/V] min motor voltage constant
Kv_max 1000 [rpm/V] max motor voltage constant
Kv [rpm/V] motor voltage constant
i0 4.5 [amps] zero-load current
R .033 [ohms] internal resistance
"""
flight_model = MotorPerf
def setup(self):
exec parse_variables(Motor.__doc__)
constraints = [W >= Qstar*Qmax*g,
Kv >= Kv_min,
Kv <= Kv_max]
return constraints
class PropulsorPerf(Model):
"""Propulsor Performance Model
"""
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
prop_flight_model = ActuatorProp
def setup(self):
exec parse_variables(Propulsor.__doc__)
Propeller.flight_model = self.prop_flight_model
self.prop = Propeller()
self.motor = Motor()
components = [self.prop, self.motor]
return [self.W >= self.prop.W + self.motor.W], components