def __init__(self, ac, eng=None): """Initialize FuelFlow object. Args: ac (string): ICAO aircraft type (for example: A320). eng (string): Engine type (for example: CFM56-5A3). Leave empty to use the default engine specified by in the aircraft database. """ self.aircraft = prop.aircraft(ac) if eng is None: eng = self.aircraft["engine"]["default"] self.engine = prop.engine(eng) self.thrust = Thrust(ac, eng) self.drag = Drag(ac) c3, c2, c1 = ( self.engine["fuel_c3"], self.engine["fuel_c2"], self.engine["fuel_c1"], ) # print(c3,c2,c1) self.fuel_flow_model = lambda x: c3 * x**3 + c2 * x**2 + c1 * x
def __init__(self, ac, eng=None): """Intitialize the generator. Args: ac (string): Aircraft type. eng (string): Engine type. Leave empty for default engine type in OpenAP. Returns: dict: flight trajectory """ super(Generator, self).__init__() self.ac = ac self.acdict = prop.aircraft(self.ac) if eng is None: self.eng = self.acdict['engine']['default'] else: self.eng = eng self.engdict = prop.engine(self.eng) self.wrap = WRAP(self.ac) # self.thrust = Thrust(self.ac, self.eng) # self.drag = Drag(self.ac) # self.fuelflow = Thrust(self.ac, self.eng) # for noise generation self.sigma_v = 0 self.sigma_vs = 0 self.sigma_h = 0 self.sigma_s = 0
def __init__(self, ac): """Initialize Drag object. Args: ac (string): ICAO aircraft type (for example: A320). """ super(Drag, self).__init__() self.ac = ac.lower() self.aircraft = prop.aircraft(ac) self.polar = self.dragpolar()
def __init__(self, aircraft_name, write_output: bool = False): self.write = write_output # General Variables self.aircraft_data = prop.aircraft(aircraft_name) self.dt = 1.0 / 60.0 # simulation timestep 60 per seconds aircraft_txt = open(f"./data/{aircraft_name}.json", 'r').read() self.aircraft = json.loads(aircraft_txt) eng_name = self.aircraft_data["engine"]["default"] self.ac_thrust = Thrust(ac=self.aircraft["Name"], eng=eng_name) # self.ac_thrust = Thrust(f"./data/{aircraft_name}_thrust.csv") # Performance Variables (all unit in SI except stated otherwise) self.lift_drag = LiftDrag(f"./data/{aircraft_name}_ld.csv") self.g = 9.81 self.mass = self.aircraft_data["limits"]["MTOW"] self.thrust_lever = 1.0 self.altitude = 0.0 self.pressure = 0.0 self.density = 0.0 self.temp = 0.0 self.cas = 0.0 self.tas = 0.0 self.v_y = 0.0 # vertical Speed self.vs = 0.0 # Vertical Speed [fpm] self.drag = 0.0 self.thrust = 0.0 self.lift = 0.0 self.weight = 0.0 self.t_d = 0.0 # thrust minus drag aka exceed thrust self.l_w = 0.0 # lift minus weight aka exceed lift self.pitch = 0.0 self.fpa = 0.0 self.aoa = 0.0 self.Q = 0.0 # tas² * density self.acc_x = 0.0 self.acc_y = 0.0 self.distance_x = 0.0 # total distance[m] self.d_x = 0.0 # instantaneous X distance[m] self.d_y = 0.0 # instantaneous Y distance[m] self.phase = 0 # Current phase self.cd = 0.0 self.cl = 0.0 self.drag0 = self.aircraft["Drag0"] self.lift0 = self.aircraft["Lift0"] self.gear = False self.flaps = 0 self.pitch_target = 0.0 self.pitch_rate_of_change = 3.0 # rate of change of the pitch [°/sec] self.ac_fuelflow = FuelFlow(ac=self.aircraft["Name"], eng=eng_name) if self.write: self.output = open("output.csv", 'w+') self.output.write(self.__get_header()) self.output.flush()
def __init__(self, ac): super(CruiseOptimizer, self).__init__() self.ac = ac self.aircraft = prop.aircraft(ac) self.thrust = Thrust(ac) self.fuelflow = FuelFlow(ac) self.drag = Drag(ac) # parameters to be optimized: # Mach number, altitude self.x0 = np.array([0.3, 25000 * aero.ft]) self.normfactor = calc_normfactor(self.x0) self.bounds = None self.update_bounds()
def __init__(self, ac, eng=None, **kwargs): """Initialize FuelFlow object. Args: ac (string): ICAO aircraft type (for example: A320). eng (string): Engine type (for example: CFM56-5A3). Leave empty to use the default engine specified by in the aircraft database. """ if not hasattr(self, "np"): self.np = importlib.import_module("numpy") if not hasattr(self, "Thrust"): self.Thrust = importlib.import_module("openap.thrust").Thrust if not hasattr(self, "Drag"): self.Drag = importlib.import_module("openap.drag").Drag if not hasattr(self, "WRAP"): self.WRAP = importlib.import_module("openap.kinematic").WRAP self.aircraft = prop.aircraft(ac, **kwargs) if eng is None: eng = self.aircraft["engine"]["default"] self.engine = prop.engine(eng) self.thrust = self.Thrust(ac, eng, **kwargs) self.drag = self.Drag(ac, **kwargs) self.wrap = self.WRAP(ac, **kwargs) polydeg = kwargs.get("polydeg", 3) if polydeg == 2: a, b = self.engine["fuel_a"], self.engine["fuel_b"] self.polyfuel = func_fuel2(a, b) elif polydeg == 3: c3, c2, c1 = ( self.engine["fuel_c3"], self.engine["fuel_c2"], self.engine["fuel_c1"], ) self.polyfuel = func_fuel3(c3, c2, c1) else: raise RuntimeError(f"polydeg must be 2 or 3")
def __init__(self, ac, eng=None): """Initialize FuelFlow object. Args: ac (string): ICAO aircraft type (for example: A320). eng (string): Engine type (for example: CFM56-5A3). Leave empty to use the default engine specified by in the aircraft database. """ self.ac = prop.aircraft(ac) self.n_eng = self.ac["engine"]["number"] if eng is None: eng = self.ac["engine"]["default"] self.engine = prop.engine(eng)
def __init__(self, ac, wave_drag=False): """Initialize Drag object. Args: ac (string): ICAO aircraft type (for example: A320). """ super(Drag, self).__init__() self.ac = ac.lower() self.aircraft = prop.aircraft(ac) self.polar = self.dragpolar() self.wave_drag = wave_drag if self.wave_drag: warnings.warn( "Performance warning: Wave drag model is inaccurate at the moment. This will be fixed in future release." )
def __init__(self, ac, eng=None, **kwargs): """Initialize Thrust object. Args: ac (string): ICAO aircraft type (for example: A320). eng (string): Engine type (for example: CFM56-5A3). """ if not hasattr(self, "np"): self.np = importlib.import_module("numpy") if not hasattr(self, "aero"): self.aero = importlib.import_module("openap").aero aircraft = prop.aircraft(ac, **kwargs) if eng is None: eng = aircraft["engine"]["default"] engine = prop.engine(eng) if type(aircraft["engine"]["options"]) == dict: eng_options = list(aircraft["engine"]["options"].values()) elif type(aircraft["engine"]["options"]) == list: eng_options = list(aircraft["engine"]["options"]) if engine["name"] not in eng_options: raise RuntimeError( f"Engine {eng} and aircraft {ac} mismatch. Available engines for {ac} are {eng_options}" ) self.cruise_alt = aircraft["cruise"]["height"] / self.aero.ft # self.cruise_alt = 30000 self.eng_bpr = engine["bpr"] self.eng_max_thrust = engine["max_thrust"] self.eng_number = aircraft["engine"]["number"] if engine["cruise_mach"] > 0: self.cruise_mach = engine["cruise_mach"] self.eng_cruise_thrust = engine["cruise_thrust"] else: self.cruise_mach = aircraft["cruise"]["mach"] self.eng_cruise_thrust = 0.2 * self.eng_max_thrust + 890
def __init__(self, ac, eng=None, **kwargs): """Initialize FuelFlow object. Args: ac (string): ICAO aircraft type (for example: A320). eng (string): Engine type (for example: CFM56-5A3). Leave empty to use the default engine specified by in the aircraft database. """ if not hasattr(self, "np"): self.np = importlib.import_module("numpy") if not hasattr(self, "Thrust"): self.Thrust = importlib.import_module("openap.thrust").Thrust if not hasattr(self, "Drag"): self.Drag = importlib.import_module("openap.drag").Drag if not hasattr(self, "WRAP"): self.WRAP = importlib.import_module("openap.kinematic").WRAP self.aircraft = prop.aircraft(ac, **kwargs) if eng is None: eng = self.aircraft["engine"]["default"] self.engine = prop.engine(eng) self.thrust = self.Thrust(ac, eng, **kwargs) self.drag = self.Drag(ac, **kwargs) self.wrap = self.WRAP(ac, **kwargs) c3, c2, c1 = ( self.engine["fuel_c3"], self.engine["fuel_c2"], self.engine["fuel_c1"], ) # print(c3,c2,c1) self.func_fuel = prop.func_fuel(c3, c2, c1)
def __init__(self, ac, eng=None): """Initialize Thrust object. Args: ac (string): ICAO aircraft type (for example: A320). eng (string): Engine type (for example: CFM56-5A3). """ super(Thrust, self).__init__() aircraft = prop.aircraft(ac) if eng is None: eng = aircraft['engine']['default'] engine = prop.engine(eng) if type(aircraft['engine']['options']) == dict: eng_options = list(aircraft['engine']['options'].values()) elif type(aircraft['engine']['options']) == list: eng_options = list(aircraft['engine']['options']) if engine['name'] not in eng_options: raise RuntimeError( 'Engine {eng} and aircraft {ac} mismatch. Available engines for {ac} are {eng_options}' ) self.cruise_alt = aircraft['cruise']['height'] / aero.ft # self.cruise_alt = 30000 self.eng_bpr = engine['bpr'] self.eng_max_thrust = engine['max_thrust'] self.eng_number = aircraft['engine']['number'] if engine['cruise_mach'] > 0: self.cruise_mach = engine['cruise_mach'] self.eng_cruise_thrust = engine['cruise_thrust'] else: self.cruise_mach = aircraft['cruise']['mach'] self.eng_cruise_thrust = 0.2 * self.eng_max_thrust + 890
def __init__(self, ac, eng=None, **kwargs): """Initialize Emission object. Args: ac (string): ICAO aircraft type (for example: A320). eng (string): Engine type (for example: CFM56-5A3). Leave empty to use the default engine specified by in the aircraft database. """ if not hasattr(self, "np"): self.np = importlib.import_module("numpy") if not hasattr(self, "aero"): self.aero = importlib.import_module("openap").aero self.ac = prop.aircraft(ac, **kwargs) self.n_eng = self.ac["engine"]["number"] if eng is None: eng = self.ac["engine"]["default"] self.engine = prop.engine(eng)
def calc_min_eta(m, mdl): ac = prop.aircraft(mdl) mtow = ac['limits']['MTOW'] oew = ac['limits']['OEW'] return 1 - 0.15 * (mtow - m) / (mtow - oew)
from openap import prop, FuelFlow, Emission, WRAP available_acs = prop.available_aircraft(use_synonym=True) for actype in available_acs: # print(actype) aircraft = prop.aircraft(ac=actype, use_synonym=True) wrap = WRAP(ac=actype, use_synonym=True) fuelflow = FuelFlow(ac=actype, use_synonym=True) emission = Emission(ac=actype, use_synonym=True) available_acs = prop.available_aircraft(use_synonym=False) for actype in available_acs: # print(actype) aircraft = prop.aircraft(ac=actype, use_synonym=False) wrap = WRAP(ac=actype, use_synonym=True) fuelflow = FuelFlow(ac=actype, use_synonym=True) emission = Emission(ac=actype, use_synonym=True)
from pprint import pprint from openap import prop ac = prop.aircraft("A320") pprint(ac) eng = prop.engine("CFM56-5B4") pprint(eng)
import numpy as np import matplotlib.pyplot as plt from openap import Emission, FuelFlow, prop from mpl_toolkits.mplot3d import Axes3D ac = "A320" aircraft = prop.aircraft(ac) fuelflow = FuelFlow(ac=ac) emission = Emission(ac=ac) tas = np.linspace(50, 500, 50) alt = np.linspace(100, 35000, 50) tas_, alt_ = np.meshgrid(tas, alt) mass = aircraft["limits"]["MTOW"] * 0.85 ff = fuelflow.enroute(mass=mass, tas=tas_, alt=alt_, path_angle=0) co2 = emission.co2(ff) h2o = emission.h2o(ff) nox = emission.nox(ff, tas=tas_, alt=alt_) co = emission.co(ff, tas=tas_, alt=alt_) hc = emission.hc(ff, tas=tas_, alt=alt_) fig = plt.figure() ax = fig.gca(projection="3d") surf = ax.plot_surface(tas_, alt_, ff) plt.title("fuel flow (kg/s)") plt.xlabel("TAS (kt)") plt.ylabel("Altitude (ft)") plt.show()
def __init__(self, **kwargs): self.ac = kwargs.get('ac') self.eng = kwargs.get('eng') self.time = kwargs.get('time') self.Y = kwargs.get('obs') # slightly increase the cov matrix (factor of 0.2), for better convergency self.noise = kwargs.get('noise') self.stdn = stdns[self.noise] * 1.2 self.R = np.zeros((nY, nY)) np.fill_diagonal(self.R, self.stdn**2) self.thrust = Thrust(self.ac, self.eng) self.drag = Drag(self.ac) aircraft = prop.aircraft(self.ac) self.mmin = aircraft['limits']['OEW'] self.mmax = aircraft['limits']['MTOW'] self.mrange = (self.mmin, self.mmax) self.eta_min = kwargs.get('eta_min', 0.80) self.eta_max = kwargs.get('eta_max', 1) self.kstd_m = kpm * (self.mmax - self.mmin) self.kstd_eta = kpe * (1 - self.eta_min) self.X = None self.nP = None self.now = 0 self.neff = None self.X_true = None logfn = kwargs.get('logfn', None) self.xlabels = [ 'm (kg)', '$\eta$ (-)', 'x (m)', 'y (m)', 'z (m)', '$v_{ax}$ (m/s)', '$v_{ay}$ (m/s)', '$v_z$ (m/s)', '$v_{wx}$ (m/s)', '$v_{wy}$ (m/s)', '$\\tau$ (K)' ] self.ylabels = [ 'x', 'y', 'z', '$v_{gx}$', '$v_{gy}$', '$v_z$', '$v_{wx}$', '$v_{wy}$', '$\\tau$' ] if (logfn is not None): if ('.log' not in logfn): raise RuntimeError('Log file must end with .log') self.log = root + '/smclog/' + logfn print('writing to log:', self.log) header = ['time'] + self.ylabels \ + [l+" avg" for l in self.xlabels] \ + [l+" med" for l in self.xlabels] \ + [l+" min" for l in self.xlabels] \ + [l+" max" for l in self.xlabels] with open(self.log, 'wt') as fcsv: writer = csv.writer(fcsv, delimiter=',') writer.writerow(header) else: self.log = None