Skip to content

Commit

Permalink
flight state to parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mjburton committed Nov 16, 2017
1 parent d142708 commit 691ff0e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
6 changes: 4 additions & 2 deletions gpkitmodels/GP/aircraft/tail/tail_aero.py
Expand Up @@ -30,13 +30,15 @@ def setup(self, static, state):
cmac = self.cmac = static.planform.cmac
b = self.b = static.planform.b
S = self.S = static.planform.S
rho = self.rho = state.rho
V = self.V = state.V
mu = self.mu = state.mu
path = os.path.dirname(__file__)
fd = pd.read_csv(path + os.sep + "tail_dragfit.csv").to_dict(
orient="records")[0]

constraints = [
Re == (state["V"]*state["\\rho"]*S/b
/ state["\\mu"]),
Re == (V*rho*S/b/mu),
# XfoilFit(fd, Cd, [Re, static["\\tau"]],
# err_margin="RMS", airfoil="naca 0008")
XfoilFit(fd, Cd, [Re, static.planform.tau], err_margin="RMS")
Expand Down
5 changes: 4 additions & 1 deletion gpkitmodels/GP/aircraft/tail/tail_boom.py
Expand Up @@ -26,8 +26,11 @@ def setup(self, static, state):
exec parse_variables(TailBoomAero.__doc__)

l = self.l = static.l
rho = self.rho = state.rho
V = self.V = state.V
mu = self.mu = state.mu

return [Re == (state["V"]*state["\\rho"]*l/state["\\mu"]),
return [Re == (V*rho*l/mu),
Cf >= 0.455/Re**0.3,
]

Expand Down
5 changes: 4 additions & 1 deletion gpkitmodels/GP/aircraft/wing/wing.py
Expand Up @@ -120,14 +120,17 @@ def setup(self, static, state,

AR = self.AR = static.planform.AR
cmac = static.planform.cmac
rho = self.rho = state.rho
V = self.V = state.V
mu = self.mu = state.mu

if fd["d"] == 2:
independentvars = [self.CL, self.Re]
elif fd["d"] == 3:
independentvars = [self.CL, self.Re, static.planform.tau]

return [Cd >= cdp + CL**2/np.pi/AR/e,
Re == (state["\\rho"]*state["V"]*cmac/state["\\mu"]),
Re == (rho*V*cmac/mu),
# XfoilFit(fd, cdp, [CL, Re], airfoil="jho1.dat"),
XfoilFit(fd, cdp, independentvars),
CL <= CLstall
Expand Down
27 changes: 14 additions & 13 deletions gpkitmodels/GP/aircraft/wing/wing_test.py
@@ -1,21 +1,22 @@
" wing test "
from gpkitmodels.GP.aircraft.wing.wing import Wing
from gpkitmodels.GP.aircraft.wing.boxspar import BoxSpar
from gpkit import Variable, Model
from gpkit import Variable, Model, parse_variables

#pylint: disable=no-member

class FlightState(Model):
" state variables "
def setup(self):

V = Variable("V", 50, "m/s", "airspeed")
rho = Variable("\\rho", 1.255, "kg/m^3", "air density")
mu = Variable("\\mu", 1.5e-5, "N*s/m**2", "air viscosity")
""" Flight State
constraints = [V == V, rho == rho, mu == mu]
Variables
---------
V 50 [m/s] airspeed
rho 1.255 [kg/m^3] air density
mu 1.5e-5 [N*s/m**2] air viscosity
return constraints
"""
def setup(self):
exec parse_variables(FlightState.__doc__)

def wing_test():
" test wing models "
Expand All @@ -37,10 +38,10 @@ def wing_test():
l.substitutions[v] = 1e-3

m = Model(perf.Cd, [
loading[1].v == fs["V"],
loading[1].v == fs.V,
loading[1].cl == perf.CL,
loading[1].Ww == W.W,
loading[1].Ww <= 0.5*fs["\\rho"]*fs["V"]**2*perf.CL*W.planform.S,
loading[1].Ww <= 0.5*fs.rho*fs.V**2*perf.CL*W.planform.S,
W, fs, perf, loading])
m.solve(verbosity=0)

Expand All @@ -65,10 +66,10 @@ def box_spar():
l.substitutions[v] = 1e-3

m = Model(perf.Cd, [
loading[1].v == fs["V"],
loading[1].v == fs.V,
loading[1].cl == perf.CL,
loading[1].Ww == W.W,
loading[1].Ww <= 0.5*fs["\\rho"]*fs["V"]**2*perf.CL*W.planform.S,
loading[1].Ww <= 0.5*fs.rho*fs.V**2*perf.CL*W.planform.S,
W, fs, perf, loading])
m.solve(verbosity=0)

Expand Down

0 comments on commit 691ff0e

Please sign in to comment.