Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setup method for the engine model
"""
self.setvals(eng)
self.compressor = Compressor()
self.combustor = Combustor()
self.turbine = Turbine()
self.fanmap = FanMap()
self.lpcmap = LPCMap()
self.hpcmap = HPCMap()
self.thrust = Thrust()
self.sizing = Sizing()
self.constants = EngineConstants()
self.state = state
if Nfleet != 0:
with Vectorize(Nfleet):
with Vectorize(N):
#-------------------Specified Thrust or Tt4-----------------------
self.engineP = self.dynamic(self.state, res7)
if res7 == 0:
#variables for the thrust constraint
Fspec = Variable('F_{spec}', 'N', 'Specified Total Thrust')
if res7 == 1:
Tt4spec = Variable('T_{t_{4spec}}', 'K', 'Specified Combustor Exit (Station 4) Stagnation Temperature')
else:
with Vectorize(N):
#-------------------Specified Thrust or Tt4-----------------------
self.engineP = self.dynamic(self.state, res7)
if res7 == 0:
#variables for the thrust constraint
Ncruise = 2
eng = 0
# vectorize
with Vectorize(Nclimb + Ncruise):
enginestate = FlightState()
# build required submodels
aircraft = Aircraft(Nclimb, Ncruise, enginestate, eng)
# vectorize
with Vectorize(Nclimb):
climb = ClimbSegment(aircraft)
with Vectorize(Ncruise):
cruise = CruiseSegment(aircraft)
statelinking = StateLinking(climb.state, cruise.state, enginestate, Nclimb, Ncruise)
# declare new variables
W_ftotal = Variable('W_{f_{total}}', 'lbf', 'Total Fuel Weight')
W_fclimb = Variable('W_{f_{climb}}', 'lbf',
'Fuel Weight Burned in Climb')
W_fcruise = Variable('W_{f_{cruise}}', 'lbf',
'Fuel Weight Burned in Cruise')
W_total = Variable('W_{total}', 'lbf', 'Total Aircraft Weight')
W_dry = Variable('W_{dry}', 'lbf', 'Dry Aircraft Weight')
CruiseAlt = Variable('CruiseAlt', 'ft', 'Cruise Altitude [feet]')
ReqRng = Variable('ReqRng', 'nautical_miles', 'Required Cruise Range')
h = climb.state['h']
def setup(self,static, state, N=5):
with Vectorize(N):
blade = BladeElementPerf(static, state)
constraints = [blade.dr == static.R/(N),
blade.omega == omega,
blade.r[0] == static.R/(2.*N)]
for n in range(1,N):
constraints += [TCS([blade.r[n] >= blade.r[n-1] + static.R/N]),
blade.eta_i[n] == blade.eta_i[n-1],
]
constraints += [TCS([Q >= sum(blade.dQ)]),
eta == state.V*T/(omega*Q),
blade.M[-1] <= Mtip,
static.T_m >= T,
if conventional:
wingengine = True; tube = True;
# Multimission?
if Nmission == 1:
multimission = False
else:
multimission = True
# Defining fitDrag, boolean describing whether or not to use XFOIL tail drag fits
# False uses TASOPT tail drag model. Currently on.
fitDrag = True
# vectorize
with Vectorize(Nmission):
with Vectorize(Nclimb + Ncruise):
self.flightstate = flightstate = FlightState()
# Build required submodels
self.aircraft = aircraft = Aircraft(Nclimb, Ncruise, flightstate, eng, fitDrag, BLI, Nmission)
self.aircraft.config = config
# Vectorize dynamic variables
with Vectorize(Nmission):
with Vectorize(Nclimb+Ncruise):
self.flight = flight = FlightSegment(aircraft, flightstate, Nclimb, Ncruise)
# Declare Mission variables
if multimission:
with Vectorize(Nmission):
CruiseAlt = Variable('CruiseAlt', 'ft', 'Cruise Altitude [feet]')
ReqRng = Variable('R_{req}', 'nautical_miles', 'Required Cruise Range')
def __init__(self, ac, substitutions = None, **kwargs):
#define the number of each flight segment
Nclimb = 2
Ncruise = 2
#Vectorize
with Vectorize(Nclimb):
climb = ClimbSegment(ac)
with Vectorize(Ncruise):
cruise = CruiseSegment(ac)
#declare new variables
W_ftotal = Variable('W_{f_{total}}', 'N', 'Total Fuel Weight')
W_fclimb = Variable('W_{f_{climb}}', 'N', 'Fuel Weight Burned in Climb')
W_fcruise = Variable('W_{f_{cruise}}', 'N', 'Fuel Weight Burned in Cruise')
W_total = Variable('W_{total}', 'N', 'Total Aircraft Weight')
CruiseAlt = Variable('CruiseAlt', 'ft', 'Cruise Altitude [feet]')
ReqRng = Variable('ReqRng', 'nautical_miles', 'Required Cruise Range')
xcg = Variable('x_{CG}', 'm', 'CG location')
h = climb['h']
hftClimb = climb['hft']
dhft = climb['dhft']
hftCruise = cruise['hft']
"""
self.setvals(eng)
self.compressor = Compressor()
self.combustor = Combustor()
self.turbine = Turbine()
self.fanmap = FanMap()
self.lpcmap = LPCMap()
self.hpcmap = HPCMap()
self.thrust = Thrust()
self.sizing = Sizing()
self.constants = EngineConstants()
self.state = state
if Nfleet != 0:
with Vectorize(Nfleet):
with Vectorize(N):
#-------------------Specified Thrust or Tt4-----------------------
self.engineP = self.dynamic(self.state, res7)
if res7 == 0:
#variables for the thrust constraint
Fspec = Variable('F_{spec}', 'N', 'Specified Total Thrust')
if res7 == 1:
Tt4spec = Variable('T_{t_{4spec}}', 'K', 'Specified Combustor Exit (Station 4) Stagnation Temperature')
else:
with Vectorize(N):
#-------------------Specified Thrust or Tt4-----------------------
self.engineP = self.dynamic(self.state, res7)
if res7 == 0:
#variables for the thrust constraint
Fspec = Variable('F_{spec}', 'N', 'Specified Total Thrust')
def setup(self, **kwargs):
# define the number of each flight segment
Nclimb = 2
Ncruise = 2
eng = 0
# vectorize
with Vectorize(Nclimb + Ncruise):
enginestate = FlightState()
# build required submodels
aircraft = Aircraft(Nclimb, Ncruise, enginestate, eng)
# vectorize
with Vectorize(Nclimb):
climb = ClimbSegment(aircraft)
with Vectorize(Ncruise):
cruise = CruiseSegment(aircraft)
statelinking = StateLinking(climb.state, cruise.state, enginestate, Nclimb, Ncruise)
# declare new variables
W_ftotal = Variable('W_{f_{total}}', 'lbf', 'Total Fuel Weight')
def setup(self):
#define the number of each flight segment
Nclimb = 2
Ncruise = 2
#build required submodels
ac = Aircraft()
#vectorize
with Vectorize(Nclimb):
climb = ClimbSegment(ac)
with Vectorize(Ncruise):
cruise = CruiseSegment(ac)
#declare new variables
W_ftotal = Variable('W_{f_{total}}', 'N', 'Total Fuel Weight')
W_fclimb = Variable('W_{f_{climb}}', 'N', 'Fuel Weight Burned in Climb')
W_fcruise = Variable('W_{f_{cruise}}', 'N', 'Fuel Weight Burned in Cruise')
W_total = Variable('W_{total}', 'N', 'Total Aircraft Weight')
CruiseAlt = Variable('CruiseAlt', 'ft', 'Cruise Altitude [feet]')
ReqRng = Variable('ReqRng', 'nautical_miles', 'Required Cruise Range')
h = climb.state['h']
hftClimb = climb.state['hft']
dhft = climb.climbP['dhft']
hftCruise = cruise.state['hft']
#make overall constraints
M4a = .1025
Mexit = 1
M0 = .4596
## climb = [
## engine.state['P_{atm}'][1] == 72.4*units('kPa'), #36K feet
## engine.state["T_{atm}"][1] == 270*units('K'),
## engine.state['M'][1] == M0,
## engine.engineP['M_2'][1] == M2,
## engine.engineP['M_{2.5}'][1] == M25,
## ]
return rotation, toclimb, cruise
if __name__ == "__main__":
with Vectorize(3):
state = TestState()
engine = Engine(0, True, 3, state)
mission = TestMission(engine)
M4a = .1025
fan = 1.685
lpc = 4.744
hpc = 3.75
substitutions = {
'\\pi_{tn}': .989,
'\pi_{b}': .94,
'\pi_{d}': .998,
'\pi_{fn}': .98,
'T_{ref}': 288.15,
def __init__(self, subs = None, **kwargs):
#define the number of each flight segment
Nclimb = 2
Ncruise = 2
#build required submodels
ac = Aircraft()
#Vectorize
with Vectorize(Nclimb):
climb = ClimbSegment(ac)
with Vectorize(Ncruise):
cruise = CruiseSegment(ac)
#declare new variables
W_ftotal = Variable('W_{f_{total}}', 'N', 'Total Fuel Weight')
W_fclimb = Variable('W_{f_{climb}}', 'N', 'Fuel Weight Burned in Climb')
W_fcruise = Variable('W_{f_{cruise}}', 'N', 'Fuel Weight Burned in Cruise')
W_total = Variable('W_{total}', 'N', 'Total Aircraft Weight')
CruiseAlt = Variable('CruiseAlt', 'ft', 'Cruise Altitude [feet]')
ReqRng = Variable('ReqRng', 'nautical_miles', 'Required Cruise Range')
h = climb.state.alt['h']
hftClimb = climb.state.alt['hft']
dhft = climb.climbP['dhft']
hftCruise = cruise.state.alt['hft']
#make overall constraints