Skip to content

Commit

Permalink
Both stages of futurize.
Browse files Browse the repository at this point in the history
  • Loading branch information
1ozturkbe committed Aug 15, 2019
1 parent 62fd801 commit d4b9660
Show file tree
Hide file tree
Showing 44 changed files with 91 additions and 59 deletions.
9 changes: 5 additions & 4 deletions gpkitmodels/GP/aircraft/engine/DF70/fitDF70.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import pandas as pd
import numpy as np
from numpy import logspace, log, log10
Expand All @@ -24,7 +25,7 @@
K = 2

cstrt, rmserror = fit(x, y, K, Type)
print "RMS error = %.4f" % rmserror
print("RMS error = %.4f" % rmserror)
yfit = cstrt.evaluate(x)

fig, ax = plt.subplots()
Expand All @@ -50,7 +51,7 @@
K = 2

cstrt, rmserror = fit(x,y,K,Type)
print "RMS error = %.4f" % rmserror
print("RMS error = %.4f" % rmserror)
yfit = cstrt.evaluate(x)

fig, ax = plt.subplots()
Expand All @@ -73,7 +74,7 @@
Type = 'SMA'
K = 1
cstrt, rmserror = fit(x,y,K,Type)
print "RMS error = %.4f" % rmserror
print("RMS error = %.4f" % rmserror)
yfit = cstrt.evaluate(x)

fig, ax = plt.subplots()
Expand Down Expand Up @@ -106,7 +107,7 @@

A = np.vstack([x, np.ones(len(x))]).T
m, c = np.linalg.lstsq(A, y)[0]
print "Equation: y = %.4gx + %.4f" % (m, c)
print("Equation: y = %.4gx + %.4f" % (m, c))
fig, ax = plt.subplots()
ax.plot(x, y, 'o', label='RCV Engine Data', markerfacecolor="None")
ax.plot(x, m*x + c, label='Fitted Line')
Expand Down
1 change: 1 addition & 0 deletions gpkitmodels/GP/aircraft/engine/df70.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
" engine_model.py "
from builtins import zip
from gpkit import Model, Variable, units

class DF70(Model):
Expand Down
1 change: 1 addition & 0 deletions gpkitmodels/GP/aircraft/engine/gas_engine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
" engine_model.py "
from builtins import zip
from gpkit import Model, Variable, units
import os
import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions gpkitmodels/GP/aircraft/fuselage/cylindrical_fuselage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
" cylindrical fuselage.py "
from __future__ import absolute_import
import numpy as np
from gpkit import Variable, Model
from fuel_tank import FuelTank
Expand Down
4 changes: 2 additions & 2 deletions gpkitmodels/GP/aircraft/fuselage/elliptical_fuselage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FuselageAero(Model):
"""
def setup(self, static, state):
exec parse_variables(FuselageAero.__doc__)
exec(parse_variables(FuselageAero.__doc__))

V = state.V
rho = state.rho
Expand Down Expand Up @@ -55,7 +55,7 @@ class Fuselage(Model):
flight_model = FuselageAero

def setup(self):
exec parse_variables(Fuselage.__doc__)
exec(parse_variables(Fuselage.__doc__))

rhocfrp = self.material.rho
tmin = self.material.tmin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
" fuselage drag fits "
from builtins import zip
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Expand Down
8 changes: 4 additions & 4 deletions gpkitmodels/GP/aircraft/motor/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MotorPerf(Model):
v [V] woltage
"""
def setup(self, static, state):
exec parse_variables(MotorPerf.__doc__)
exec(parse_variables(MotorPerf.__doc__))

Kv = static.Kv
R = static.R
Expand Down Expand Up @@ -56,7 +56,7 @@ class Motor(Model):
flight_model = MotorPerf

def setup(self):
exec parse_variables(Motor.__doc__)
exec(parse_variables(Motor.__doc__))

constraints = [W >= Qstar*Qmax*g,
Kv >= Kv_min,
Expand All @@ -70,7 +70,7 @@ class PropulsorPerf(Model):
"""

def setup(self, static, state):
exec parse_variables(PropulsorPerf.__doc__)
exec(parse_variables(PropulsorPerf.__doc__))
self.prop = static.prop.flight_model(static.prop, state)
self.motor = static.motor.flight_model(static.motor, state)

Expand All @@ -95,7 +95,7 @@ class Propulsor(Model):


def setup(self):
exec parse_variables(Propulsor.__doc__)
exec(parse_variables(Propulsor.__doc__))

Propeller.flight_model = self.prop_flight_model
self.prop = Propeller()
Expand Down
1 change: 1 addition & 0 deletions gpkitmodels/GP/aircraft/motor/motor_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
from gpkit import Model, parse_variables, SignomialsEnabled, SignomialEquality, units
from motor import Propulsor, Motor, MotorPerf
from gpkitmodels.GP.aircraft.prop.propeller import Propeller, ActuatorProp
Expand Down
3 changes: 2 additions & 1 deletion gpkitmodels/GP/aircraft/prop/arccos_fit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import unittest
from numpy import log, exp, log10, vstack
from numpy import arccos,arange
Expand All @@ -10,4 +11,4 @@
K = 1

cstrt, rmsErr = fit(x,y,K,"SMA")
print rmsErr
print(rmsErr)
4 changes: 2 additions & 2 deletions gpkitmodels/GP/aircraft/prop/propeller.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def helper(self, c):
return 2. - 1./c(self.etaadd)

def setup(self, static, state):
exec parse_variables(ActuatorProp.__doc__)
exec(parse_variables(ActuatorProp.__doc__))

V = state.V
rho = state.rho
Expand Down Expand Up @@ -74,6 +74,6 @@ class Propeller(Model):
flight_model = ActuatorProp

def setup(self, N = 5):
exec parse_variables(Propeller.__doc__)
exec(parse_variables(Propeller.__doc__))
self.N = N
return [W >= K*T_m*R**2]
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/tail/empennage.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Empennage(Model):
"""
def setup(self, N=2):
exec parse_variables(Empennage.__doc__)
exec(parse_variables(Empennage.__doc__))

self.htail = HorizontalTail()
self.hSparModel = self.htail.sparModel
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/tail/horizontal_tail.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class HorizontalTail(Wing):
sparModel = None

def setup(self, N=3):
exec parse_variables(HorizontalTail.__doc__)
exec(parse_variables(HorizontalTail.__doc__))

self.ascs = Wing.setup(self, N)
self.planform.substitutions.update(
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/tail/tail_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TailAero(Model):
"""
def setup(self, static, state):
self.state = state
exec parse_variables(TailAero.__doc__)
exec(parse_variables(TailAero.__doc__))

cmac = self.cmac = static.planform.cmac
b = self.b = static.planform.b
Expand Down
10 changes: 5 additions & 5 deletions gpkitmodels/GP/aircraft/tail/tail_boom.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TailBoomAero(Model):
"""
def setup(self, static, state):
self.state = state
exec parse_variables(TailBoomAero.__doc__)
exec(parse_variables(TailBoomAero.__doc__))

l = self.l = static.l
rho = self.rho = state.rho
Expand All @@ -57,7 +57,7 @@ class TailBoomState(Model):
"""
def setup(self):
exec parse_variables(TailBoomState.__doc__)
exec(parse_variables(TailBoomState.__doc__))


class VerticalBoomTorsion(Model):
Expand All @@ -82,7 +82,7 @@ class VerticalBoomTorsion(Model):
"""
def setup(self, tailboom, vtail, state):
exec parse_variables(VerticalBoomTorsion.__doc__)
exec(parse_variables(VerticalBoomTorsion.__doc__))

J = self.J = tailboom.J
d0 = self.d0 = tailboom.d
Expand Down Expand Up @@ -133,7 +133,7 @@ def setup(self, tailboom, htail, state):
self.state = state
self.htail = htail
self.tailboom = tailboom
exec parse_variables(TailBoomBending.__doc__)
exec(parse_variables(TailBoomBending.__doc__))

Beam.qbarFun = [1e-10]*N
Beam.SbarFun = [1.]*N
Expand Down Expand Up @@ -188,7 +188,7 @@ class TailBoom(TubeSpar):

def setup(self, N=5):
self.N = N
exec parse_variables(TailBoom.__doc__)
exec(parse_variables(TailBoom.__doc__))
self.spar = super(TailBoom, self).setup(N, self)

if self.secondaryWeight:
Expand Down
4 changes: 3 additions & 1 deletion gpkitmodels/GP/aircraft/tail/tailpolars/naca_cl0fits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"naca_polarfits.py"
from builtins import zip
from builtins import range
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -85,7 +87,7 @@ def plot_fits(naca_range, re_range):
return fig, ax

if __name__ == "__main__":
Re = range(200, 950, 50)
Re = list(range(200, 950, 50))
NACA = ["0005", "0008", "0009", "0010", "0015", "0020"]
X, Y = fit_setup(NACA, Re) # call fit(X, Y, 4, "SMA") to get fit
F, A = plot_fits(NACA, Re)
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/tail/tube_spar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TubeSpar(Model):
material = cfrpfabric

def setup(self, N, surface):
exec parse_variables(TubeSpar.__doc__)
exec(parse_variables(TubeSpar.__doc__))

deta = surface.deta
tmin = self.material.tmin
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/tail/vertical_tail.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VerticalTail(Wing):
sparModel = None

def setup(self, N=3):
exec parse_variables(VerticalTail.__doc__)
exec(parse_variables(VerticalTail.__doc__))

self.ascs = Wing.setup(self, N)
self.planform.substitutions.update(
Expand Down
3 changes: 2 additions & 1 deletion gpkitmodels/GP/aircraft/wing/arctan_fit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from gpfit.fit import fit
import os
import matplotlib.pyplot as plt
Expand All @@ -15,7 +16,7 @@ def arctanfit():

cn, err = fit(x, y, 1, "MA")
rm = err
print "RMS error: %.4f" % rm
print("RMS error: %.4f" % rm)

yfit = cn.evaluate(x)
df = cn.get_dataframe()
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/wing/boxspar.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BoxSpar(Model):

def setup(self, N, surface):
self.surface = surface
exec parse_variables(BoxSpar.__doc__)
exec(parse_variables(BoxSpar.__doc__))

b = self.b = surface.b
cave = self.cave = surface.cave
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/wing/capspar.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CapSpar(Model):

def setup(self, N, surface):
self.surface = surface
exec parse_variables(CapSpar.__doc__)
exec(parse_variables(CapSpar.__doc__))

cave = self.cave = surface.cave
b = self.b = surface.b
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/wing/gustloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def return_cosm1(self, c):
return hstack([adnumber(1e-10), 1-array(cos(eta[1:]*pi/2))])

def setup(self, wing, state, out=False):
exec parse_variables(GustL.__doc__)
exec(parse_variables(GustL.__doc__))
self.load = SparLoading.setup(self, wing, state, out=out)

cbar = self.wing.planform.cbar
Expand Down
4 changes: 3 additions & 1 deletion gpkitmodels/GP/aircraft/wing/jho1polars/jho1_polarfits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"jho1_polarfits.py"
from builtins import zip
from builtins import range
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -77,7 +79,7 @@ def plot_fits(re):
return fig, ax, fig1

if __name__ == "__main__":
Re = range(200, 750, 50)
Re = list(range(200, 750, 50))
X, Y = fit_setup(Re) # call fit(X, Y, 4, "SMA") to get fit
F, A, F1 = plot_fits([300, 350, 400, 450, 500])
F.savefig("jho1polarfit1.pdf", bbox_inches="tight")
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/wing/sparloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def new_qbarFun(self, c):

def setup(self, wing, state, out=False):
self.wing = wing
exec parse_variables(SparLoading.__doc__)
exec(parse_variables(SparLoading.__doc__))

b = self.b = self.wing.planform.b
I = self.I = self.wing.spar.I
Expand Down
7 changes: 4 additions & 3 deletions gpkitmodels/GP/aircraft/wing/wing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
" wing.py "
from builtins import range
from os import sep
from os.path import abspath, dirname
import numpy as np
Expand Down Expand Up @@ -81,7 +82,7 @@ def return_cmac(self, c):
return_deta = lambda self, c: np.diff(c(self.eta))

def setup(self, N):
exec parse_variables(Planform.__doc__)
exec(parse_variables(Planform.__doc__))

return [b**2 == S*AR,
cave == cbave*S/b,
Expand Down Expand Up @@ -121,7 +122,7 @@ def setup(self, static, state,
fitdata=dirname(abspath(__file__)) + sep + "jho_fitdata.csv"):
self.state = state
self.static = static
exec parse_variables(WingAero.__doc__)
exec(parse_variables(WingAero.__doc__))

df = pd.read_csv(fitdata)
fd = df.to_dict(orient="records")[0]
Expand Down Expand Up @@ -180,7 +181,7 @@ class Wing(Model):

def setup(self, N=5):
self.N = N
exec parse_variables(Wing.__doc__)
exec(parse_variables(Wing.__doc__))

self.planform = Planform(N)
self.components = []
Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/wing/wing_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WingCore(Model):

def setup(self, surface):
self.surface = surface
exec parse_variables(WingCore.__doc__)
exec(parse_variables(WingCore.__doc__))

cave = self.cave = surface.cave
b = self.b = surface.b
Expand Down
4 changes: 2 additions & 2 deletions gpkitmodels/GP/aircraft/wing/wing_skin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WingSkin(Model):
material = cfrpfabric

def setup(self, surface):
exec parse_variables(WingSkin.__doc__)
exec(parse_variables(WingSkin.__doc__))

croot = self.croot = surface.croot
S = self.S = surface.S
Expand Down Expand Up @@ -71,7 +71,7 @@ class WingSecondStruct(Model):
"""
def setup(self, surface):
exec parse_variables(WingSecondStruct.__doc__)
exec(parse_variables(WingSecondStruct.__doc__))

S = self.S = surface.S

Expand Down
2 changes: 1 addition & 1 deletion gpkitmodels/GP/aircraft/wing/wing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FlightState(Model):
"""
def setup(self):
exec parse_variables(FlightState.__doc__)
exec(parse_variables(FlightState.__doc__))

return [qne == V**2*rho*1.2]

Expand Down
Loading

0 comments on commit d4b9660

Please sign in to comment.