Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    def test_thrust_value_b734(self):
        nn = 5
        p = om.Problem()
        tas = np.linspace(0, 100, nn)
        tas_kt = tas * 1.94384
        alt = 0

        ivc = p.model.add_subsystem('ivc',
                                    subsys=om.IndepVarComp(),
                                    promotes_outputs=['*'])
        ivc.add_output(name='tas', val=tas, units='m/s')
        ivc.add_output(name='alt', val=alt, units='m')
        p.model.connect('alt', ['atmos.h', 'propulsion.elevation'])
        p.model.connect('tas', ['propulsion.tas'])

        p.model.add_subsystem(name='atmos', subsys=USatm1976Comp(num_nodes=1))
        p.model.connect('atmos.sos', 'propulsion.sos')
        p.model.connect('atmos.pres', ['propulsion.p_amb'])

        p.model.add_subsystem(name='propulsion',
                              subsys=PropulsionGroup(
                                  num_nodes=nn, airplane=self.airplane_734))

        p.setup()
        p.run_model()

        thrust = Thrust(ac='B734')
        reference_thrust = [thrust.takeoff(tas=v, alt=alt) for v in tas_kt]
        assert_near_equal(p.get_val('propulsion.thrust'),
                          reference_thrust,
                          tolerance=0.001)
Exemplo n.º 3
0
def plot():
    # Thrust = Thrust('A320', 'CFM56-5B4')
    thrust = Thrust('A320', 'V2500-A1')

    fig = plt.figure(figsize=(10,8))

    ax = fig.add_subplot(111, projection='3d')

    tas = np.arange(0, 500, 20)
    alt = np.arange(0, 35000, 2000)
    x, y = np.meshgrid(tas, alt)

    thr_to = thrust.takeoff(x, y)
    thr_cl = thrust.climb(x, y, 2000)

    c1, c2, c3 = .14231E+06, .51680E+05, .56809E-10
    thr_bada = c1 * (1 - y / c2 + c3 * y**2)

    plt.title('inflight')
    ax.plot_wireframe(x, y, thr_to, color='r', label='OpenAP-Thrust-TO')
    ax.plot_wireframe(x, y, thr_cl, color='g', label='Open-Thrust-CL')
    ax.plot_wireframe(x, y, thr_bada, color='b', label='BADA3')
    ax.set_xlabel('tas (kts)')
    ax.set_ylabel('alt (ft)')
    ax.set_zlabel('thr (N)')
    # ax.view_init(20, 40)
    ax.legend()
    plt.tight_layout()
    plt.show()
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
    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()
Exemplo n.º 6
0
def state_update(X, dt, mdl, eng):
    nrow, ncol = X.shape

    m, eta, x, y, z, vax, vay, vz, vwx, vwy, tau = X

    vgx = vax + vwx
    vgy = vay + vwy

    vg = np.sqrt(vgx**2 + vgy**2)
    va = np.sqrt(vax**2 + vay**2)

    psi = np.arctan2(vax, vay)

    gamma = np.arcsin(vz / va)

    thrust = Thrust(mdl, eng)
    T = thrust.climb(va / aero.kts, z / aero.ft, vz / aero.fpm)

    drag = Drag(mdl)
    D = drag.clean(m, va / aero.kts, z / aero.ft)

    a = (eta * T - D) / m - aero.g0 * np.sin(gamma)

    m1 = m
    eta1 = eta

    x1 = x + vgx * dt
    y1 = y + vgy * dt
    z1 = z + vz * dt

    va1 = va + a * dt
    vax1 = va1 * np.sin(psi)
    vay1 = va1 * np.cos(psi)

    vz1 = vz
    vwx1 = vwx
    vwy1 = vwy
    tau1 = aero.temperature(z)

    X = np.array([m1, eta1, x1, y1, z1, vax1, vay1, vz1, vwx1, vwy1, tau1])

    return X
Exemplo n.º 7
0
Arquivo: smc.py Projeto: junzis/acsmc
    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
Exemplo n.º 8
0
import pandas as pd
import numpy as np
from openap import Thrust
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D


thrust = Thrust(ac='A320', eng='CFM56-5B4')

print('-'*70)

T = thrust.takeoff(tas=100, alt=0)
print("thrust.takeoff(tas=100, alt=0)")
print(T)
print('-'*70)

T = thrust.climb(tas=200, alt=20000, roc=1000)
print("thrust.climb(tas=200, alt=20000, roc=1000)")
print(T)
print('-'*70)

T = thrust.cruise(tas=230, alt=32000)
print("thrust.cruise(tas=230, alt=32000)")
print(T)
print('-'*70)

T = thrust.climb(tas=[200], alt=[20000], roc=[1000])
print("thrust.climb(tas=[200], alt=[20000], roc=[1000])")
print(T)
print('-'*70)