Skip to content

Commit

Permalink
prop and test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mjburton committed Apr 9, 2018
1 parent 737aeda commit be396d2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 105 deletions.
38 changes: 15 additions & 23 deletions gpkitmodels/GP/aircraft/prop/prop_test.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
" propeller tests "
from propeller import Actuator_Propeller
from propeller import One_Element_Propeller
from gpkit import units
#from qprop import QProp
from gpkitmodels.GP.aircraft.prop.propeller import Propeller, ActuatorProp
from gpkitmodels.GP.aircraft.prop.propeller import SimpleQProp
from gpkitmodels.GP.aircraft.wing.wing_test import FlightState
from gpkit import units, Model

def simpleprop_test():
" test simple propeller model "
fs = FlightState()
p = Actuator_Propeller()
Propeller.flight_model = ActuatorProp
p = Propeller()
pp = p.flight_model(p, fs)
m = Model(1/pp.eta+ pp.Q/(100.*units("N*m")), [fs, p, pp])
m.substitutions.update({"rho": 1.225, "V": 50, "T": 100})
m = Model(1/pp.eta + pp.Q/(100.*units("N*m")) + p.W/(100.*units("lbf")),
[fs, p, pp])
m.substitutions.update({"rho": 1.225, "V": 50, "T": 100, "T_m": 40})
m.solve()

def OE_eta_test():
" simple qprop test "

fs = FlightState()
p = One_Element_Propeller()
pp = p.flight_model(p,fs)
Propeller.flight_model = SimpleQProp
p = Propeller()
pp = p.flight_model(p, fs)
pp.substitutions[pp.T] = 1000
#pp.substitutions[pp.omega] = 500
pp.substitutions[pp.AR_b] = 12
pp.cost = 1/pp.eta + pp.Q/(10.*units("N*m"))
sol = pp.localsolve()
#sol = pp.debug()
print sol.table()
m = Model(1/pp.eta + pp.Q/(10.*units("N*m")) + p.W/(100.*units("lbf")),
[pp, p])
m.localsolve()

#def qprop_test():
#
# fs = FlightState()
# p = QProp(fs)
# p.substitutions[p.T] = 100
# p.cost = 1/p.eta
# sol = p.solve()
# print sol.table()

def test():
"tests"
simpleprop_test()
OE_eta_test()
#qprop_test()

if __name__ == "__main__":
test()
Expand Down
139 changes: 57 additions & 82 deletions gpkitmodels/GP/aircraft/prop/propeller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import os
import pandas as pd


class Actuator_Propeller_Performance(Model):
class ActuatorProp(Model):
""" Propeller Model
Variables
Expand All @@ -24,60 +23,38 @@ class Actuator_Propeller_Performance(Model):
CT [-] thrust coefficient
CP [-] power coefficient
Q [N*m] torque
omega [rpm] propeller rotation rate
omega_max 10000 [rpm] max rotation rate
omega [rpm] propeller rotation rate
omega_max 10000 [rpm] max rotation rate
P_shaft [kW] shaft power
M_tip .5 [-] Tip mach number
a 295 [m/s] Speed of sound at altitude
M_tip .5 [-] Tip mach number
a 295 [m/s] Speed of sound at altitude
"""

def helper(self, c):
return 2. - 1./c[self.etaadd]

def setup(self,parent, state):
exec parse_variables(Actuator_Propeller_Performance.__doc__)

V = state.V
rho = state.rho
R = parent.R
def setup(self, static, state):
exec parse_variables(ActuatorProp.__doc__)

V = state.V
rho = state.rho
R = static.R

constraints = [eta <= etav*etai,
Tc >= T/(0.5*rho*V**2*pi*R**2),
z2 >= Tc + 1,
etai*(z1 + z2**0.5/etaadd) <= 2,
lam >= V/(omega*R),
CT >= Tc*lam**2,
CP <= Q*omega/(.5*rho*(omega*R)**3*pi*R**2),
eta >= CT*lam/CP,
omega <= omega_max,
P_shaft == Q*omega,
(M_tip*a)**2 >= (omega*R)**2 + V**2

]
return constraints, state

class Actuator_Propeller(Model):
""" Propeller Model
Variables
---------
R [ft] prop radius
W [lbf] prop weight
K 4e-4 [1/ft^2] prop weight scaling factor
T_m_static 40. [lbf] prop max static thrust
"""

flight_model = Actuator_Propeller_Performance
def setup(self):
exec parse_variables(Actuator_Propeller.__doc__)

constraints = [W >= K*T_m_static*R**2]

Tc >= T/(0.5*rho*V**2*pi*R**2),
z2 >= Tc + 1,
etai*(z1 + z2**0.5/etaadd) <= 2,
lam >= V/(omega*R),
CT >= Tc*lam**2,
CP <= Q*omega/(.5*rho*(omega*R)**3*pi*R**2),
eta >= CT*lam/CP,
omega <= omega_max,
P_shaft == Q*omega,
(M_tip*a)**2 >= (omega*R)**2 + V**2
]
return constraints

class One_Element_Propeller_Performance(Model):

class SimpleQProp(Model):
""" Propeller Model
Variables
Expand All @@ -88,7 +65,7 @@ class One_Element_Propeller_Performance(Model):
etai [-] inviscid losses
eta [-] overall efficiency
Q [N*m] torque
omega [rpm] propeller rotation rate
omega [rpm] propeller rotation rate
omega_max 10000 [rpm] max rotation rate
P_shaft [kW] shaft power
M_tip .5 [-] Tip mach number
Expand Down Expand Up @@ -117,42 +94,41 @@ class One_Element_Propeller_Performance(Model):
def helper(self, c):
return 2. - 1./c[self.etaadd]

def setup(self,parent, state):
exec parse_variables(One_Element_Propeller_Performance.__doc__)
def setup(self, static, state):
exec parse_variables(SimpleQProp.__doc__)

V = state.V
rho = state.rho
R = parent.R
mu = state.mu
V = state.V
rho = state.rho
R = static.R
mu = state.mu
path = os.path.dirname(__file__)
fd = pd.read_csv(path + os.sep + "dae51_fitdata.csv").to_dict(
orient="records")[0]

constraints = [TCS([eta == etap*etai]),
omega <= omega_max,
P_shaft == Q*omega,
TCS([W**2 >= (Wa**2+Wt**2)]),
Ut == omega*r,
TCS([G == (1./2.)*W*c*cl]),
r == .8*R, #Assume 80% chord is representative
f == (B/2.)*.2*(1./lam_w), #.2 = 1-.8 = 1-r/R
F == (2./pi)*(1.02232*f**.0458729)**(1./.1), #This is the GP fit of arccos(exp(-f))
#TCS([vt == (B*G/(4.*pi*r*F))]),
lam_w == (r/R)*(Wa/Wt),
va == vt*(Wt/Wa),
eps == cd/cl,
TCS([1 >= etai*(1+va/V)+vt/Ut]),
TCS([1 >= etap*(1+eps*Wt/Wa)+eps*Wt/Wa]),
TCS([Q >= rho*B*G*(Wa+eps*Wt)*R**2]),

#TCS([(M_tip*a)**2 >= Wa**2 + Wt**2]),
AR_b == R/c,
AR_b <= AR_b_max,
Re == V*c*rho/mu,
XfoilFit(fd, cd, [cl,Re], name="polar"),
parent.T_m >= T

]
omega <= omega_max,
P_shaft == Q*omega,
TCS([W**2 >= (Wa**2+Wt**2)]),
Ut == omega*r,
TCS([G == (1./2.)*W*c*cl]),
r == .8*R, #Assume 80% chord is representative
f == (B/2.)*.2*(1./lam_w), #.2 = 1-.8 = 1-r/R
F == (2./pi)*(1.02232*f**.0458729)**(1./.1),
#This is the GP fit of arccos(exp(-f))
#TCS([vt == (B*G/(4.*pi*r*F))]),
lam_w == (r/R)*(Wa/Wt),
va == vt*(Wt/Wa),
eps == cd/cl,
TCS([1 >= etai*(1+va/V)+vt/Ut]),
TCS([1 >= etap*(1+eps*Wt/Wa)+eps*Wt/Wa]),
TCS([Q >= rho*B*G*(Wa+eps*Wt)*R**2]),
#TCS([(M_tip*a)**2 >= Wa**2 + Wt**2]),
AR_b == R/c,
AR_b <= AR_b_max,
Re == V*c*rho/mu,
XfoilFit(fd, cd, [cl,Re], name="polar"),
static.T_m >= T
]
with SignomialsEnabled():
constraints += [TCS([Wa<=V + va]),
#SignomialEquality(Wt,omega*r-vt),
Expand All @@ -166,11 +142,11 @@ def setup(self,parent, state):
#SignomialEquality(1,etai*(1+va/V)+vt/Ut),
#SignomialEquality(Q,rho*B*G*(Wa+eps*Wt)*R**2),
#SignomialEquality(T,rho*B*G*(Wt-eps*Wa)*R),

]
return constraints, state

class One_Element_Propeller(Model):
class Propeller(Model):
""" Propeller Model
Variables
Expand All @@ -181,10 +157,9 @@ class One_Element_Propeller(Model):
T_m [lbf] prop max static thrust
"""

flight_model = One_Element_Propeller_Performance
flight_model = SimpleQProp
def setup(self):
exec parse_variables(One_Element_Propeller.__doc__)
exec parse_variables(Propeller.__doc__)

constraints = [W >= K*T_m*R**2]
return [W >= K*T_m*R**2]

return constraints

0 comments on commit be396d2

Please sign in to comment.