-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved motor files to gplibrary; added motor_tests as separate file
- Loading branch information
Showing
2 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
"Electric motor model " | ||
from numpy import pi | ||
from gpkit import Model, parse_variables, SignomialsEnabled, SignomialEquality, units | ||
from gpkitmodels.GP.aircraft.prop.propeller import Propeller | ||
from gpkitmodels import g | ||
from gpkitmodels.GP.aircraft.wing.wing_test import FlightState | ||
import matplotlib.pyplot as plt | ||
from gpkit.constraints.tight import Tight as TCS | ||
class ElecMotor(Model): | ||
""" Electric Motor Model | ||
Variables | ||
--------- | ||
Qstar 1 [kg/(N*m)] motor specific torque | ||
W [lbf] motor weight | ||
Qmax [N*m] motor max. torque | ||
V_max 300 [V] motor max voltage | ||
""" | ||
def setup(self): | ||
exec parse_variables(ElecMotor.__doc__) | ||
|
||
constraints = [W >= Qstar*Qmax*g] | ||
|
||
return constraints | ||
|
||
def flight_model(self,state): | ||
return ElecMotor_Performance(self, state) | ||
|
||
class ElecMotor_Performance(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 .1 [amps] zero-load current | ||
Kv 100 [rpm/V] motor voltage constant | ||
R .05 [ohms] internal resistance | ||
""" | ||
def setup(self,parent, state): | ||
exec parse_variables(ElecMotor_Performance.__doc__) | ||
|
||
|
||
constraints = [Pshaft == Q*omega, | ||
Pelec == v*i, | ||
etam == Pshaft/Pelec, | ||
parent.Qmax >= Q, | ||
v <= parent.V_max, | ||
TCS([i >= Q*Kv+i0]), | ||
TCS([v >= omega/Kv + i*R]) | ||
] | ||
return constraints | ||
|
||
class Propulsor(Model): | ||
"""Propulsor model | ||
Variables | ||
--------- | ||
W [lbf] propulsor weight | ||
""" | ||
def setup(self): | ||
exec parse_variables(Propulsor.__doc__) | ||
|
||
self.prop = Propeller() | ||
self.motor = ElecMotor() | ||
|
||
components = [self.prop, self.motor] | ||
|
||
return [self.W >= self.prop.W + self.motor.W], components | ||
|
||
def flight_model(self,state): | ||
return Propulsor_Performance(self,state) | ||
|
||
class Propulsor_Performance(Model): | ||
"""Propulsor Performance Model | ||
Variables | ||
--------- | ||
V_static 1 [cm/s] inflow velocity for static thrust | ||
""" | ||
def setup(self, parent,state): | ||
exec parse_variables(Propulsor_Performance.__doc__) | ||
self.prop = parent.prop.flight_model(state) | ||
self.motor = parent.motor.flight_model(state) | ||
self.stat_FS = FlightState() | ||
#self.stat_FS.substitutions[V_static] | ||
#self.stat_prop = parent.prop.flight_model(stat_FS) | ||
|
||
self.components = [self.prop, self.motor] | ||
|
||
constraints = [self.prop.Q == self.motor.Q, | ||
self.prop.omega == self.motor.omega | ||
] | ||
|
||
return constraints, self.components, self.stat_FS | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from gpkit import Model, parse_variables, SignomialsEnabled, SignomialEquality, units | ||
from motor import Propulsor, ElecMotor, ElecMotor_Performance | ||
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(fs) | ||
pp.substitutions[pp.prop.T] = 50 | ||
self.cost = 1./pp.motor.etam + p.W/(10000000*units('lbf')) + 1./pp.prop.eta | ||
|
||
return fs,p,pp | ||
|
||
def propulsor_test(): | ||
|
||
test = Propulsor_Test() | ||
#sol = test.debug() | ||
sol = test.solve() | ||
#print sol.table() | ||
|
||
class Motor_P_Test(Model): | ||
def setup(self): | ||
fs = FlightState() | ||
m = ElecMotor() | ||
mp = ElecMotor_Performance(m,fs) | ||
self.mp = mp | ||
mp.substitutions[m.Qmax] = 100 | ||
mp.substitutions[mp.Q] = 10 | ||
self.cost = 1./mp.etam | ||
return self.mp, fs | ||
|
||
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() | ||
propulsor_test() | ||
|
||
if __name__ == "__main__": | ||
test() |