Skip to content

Commit

Permalink
not working eval fix vectorvars
Browse files Browse the repository at this point in the history
  • Loading branch information
mjburton committed Oct 18, 2017
1 parent 2605db2 commit 5cf3f34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion gpkitmodels/GP/aircraft/wing/chord_spar_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def setup(self, static, Wcent):
Mr = Variable("M_r", "N*m", "wing section root moment")

with Vectorize(static.N):
qbar = Variable("\\bar{q}", cbar, "-", "normalized loading")
qbar = Variable("\\bar{q}", "-", "normalized loading")

beam = Beam(static.N, qbar)

constraints = [
# dimensionalize moment of inertia and young's modulus
qbar == static["\\bar{c}"],
beam["\\bar{EI}"] <= (8*static["E"]*static["I"]/Nmax
/ Wcent/static["b"]**2),
Mr == (beam["\\bar{M}"][:-1]*Wcent*Nmax*static["b"]/4),
Expand Down
16 changes: 7 additions & 9 deletions gpkitmodels/GP/aircraft/wing/wing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import numpy as np
import pandas as pd
from gpkit import Variable, Model, Vectorize
from gpkit import Variable, Model, Vectorize, VectorVariable
from .wing_interior import WingInterior
from .wing_skin import WingSkin
from .capspar import CapSpar
Expand All @@ -27,14 +27,12 @@ def setup(self, N):
lam = Variable("\\lambda", 0.5, "-", "wing taper ratio")
return_cmac = lambda c: 2.0/3.0*(1+c[lam]+c[lam]**2)/(1+c[lam])
cbarmac = Variable("\\bar{c}_{MAC}", return_cmac, "-", "non-dim MAC")
with Vectorize(N):
eta = Variable("\\eta", "-", "(2y/b)")
cbar = Variable("\\bar{c}", "-",
"normalized chord at mid element")
eta = Variable("\\eta", "-", "(2y/b)")
eta = VectorVariable(N, "\\eta", np.linspace(0, 1, N), "-", "(2y/b)")
return_c = lambda c: [2.0/(1+c[lam])*(1+(c[lam]-1)*e) for e in c[eta]]
cbar = VectorVariable(N, "\\bar{c}", return_c, "-",
"normalized chord at nodes")
with Vectorize(N-1):
cbave = Variable("\\bar{c}_{ave}", "-",
"normalized mid section chord")
cbave = Variable("\\bar{c}_{ave}", "-", "non-dim mid section chord")
cave = Variable("c_{ave}", "ft", "mid section chord")
deta = Variable("d\\eta", "-", "\\Delta (2y/b)")

Expand Down Expand Up @@ -108,7 +106,7 @@ def setup(self, N=5, lam=0.5):
mfac = Variable("m_{fac}", 1.2, "-", "wing weight margin factor")

cb, eta, deta, cbarmac = c_bar(lam, N)
subdict = {"\\lambda": lam, "\\bar{c}": cb, "\\eta": eta,
subdict = {"\\lambda": lam, "\\eta": eta, "\\bar{c}": cb,
"\\bar{c}_{ave}": (cb[1:]+cb[:-1])/2,
"d\\eta": deta}

Expand Down

0 comments on commit 5cf3f34

Please sign in to comment.