Exemple #1
0
def equilibrium(x, v_inf, quadrotor, kwargs, called_from='trim'):
        alpha, omega = x
        n_azi_elements = kwargs['n_azi_elements']
        alt = kwargs['alt']
        allowable_Re = kwargs['allowable_Re']
        Cl_funs = kwargs['Cl_funs']
        Cd_funs = kwargs['Cd_funs']
        dens = get_dens(alt)
        pitch = kwargs['pitch']
        tip_loss = kwargs['tip_loss']
        mach_corr = kwargs['mach_corr']
        lift_curve_info_dict = kwargs['lift_curve_info_dict']
        bemt_converged = True
        try:
            thrust, rotor_drag, rotor_power = bemt.bemt_forward_flight(quadrotor, pitch, omega, alpha, v_inf,
                                                                       n_azi_elements, alt=alt, tip_loss=tip_loss,
                                                                       mach_corr=mach_corr, allowable_Re=allowable_Re,
                                                                       Cl_funs=Cl_funs, Cd_funs=Cd_funs,
                                                                       lift_curve_info_dict=lift_curve_info_dict)
        except Exception as e:
            #print "{} in ff bemt".format(type(e).__name__)
            raise
        f1 = thrust*np.sin(alpha) - rotor_drag*np.cos(alpha) - quadrotor.frame_drag(alpha, v_inf, dens)/4
        f2 = thrust*np.cos(alpha) + rotor_drag*np.sin(alpha) - quadrotor.weight/4
        return f1, f2, bemt_converged
Exemple #2
0
def equilibrium(x, v_inf, quadrotor):
        alpha, omega1, omega2 = x
        prop1, prop2 = quadrotor.propellers
        quad_length = quadrotor.length
        frame_drag = quadrotor.frame_drag(alpha)
        frame_lift = quadrotor.frame_lift(alpha)
        thrust1, rotor_drag1, rotor_power1 = bemt_forward_flight(prop1, pitch=0., omega=omega1, alpha=alpha,
                                                                 v_inf=v_inf, n_azi_elements=20)
        thrust2, rotor_drag2, rotor_power2 = bemt_forward_flight(prop2, pitch=0., omega=omega2, alpha=alpha,
                                                                 v_inf=v_inf, n_azi_elements=20)
        frame_normal = frame_drag*np.sin(alpha) + frame_lift*np.cos(alpha)    # Frame lift is positive down frame_normal is positive down
        f1 = thrust1*quad_length/2 + frame_normal*quad_length/4 - thrust2*quad_length/2
        f2 = thrust1*np.sin(alpha) + thrust2*np.sin(alpha) - rotor_drag1*np.cos(alpha) - rotor_drag2*np.cos(alpha) - \
             frame_drag
        f3 = thrust1*np.cos(alpha) + thrust2*np.cos(alpha) + rotor_drag1*np.sin(alpha) + rotor_drag2*np.sin(alpha) - \
             quadrotor.weight
        return f1, f2, f3
    def get_performance(o, c, t):
        chord_meters = c * radius
        prop = propeller.Propeller(t,
                                   chord_meters,
                                   radius,
                                   n_blades,
                                   r,
                                   y,
                                   dr,
                                   dy,
                                   airfoils=airfoils,
                                   Cl_tables=Cl_tables,
                                   Cd_tables=Cd_tables)
        quad = quadrotor.Quadrotor(prop, vehicle_weight)

        ff_kwargs = {
            'propeller': prop,
            'pitch': pitch,
            'n_azi_elements': n_azi_elements,
            'allowable_Re': allowable_Re,
            'Cl_funs': Cl_funs,
            'Cd_funs': Cd_funs,
            'tip_loss': tip_loss,
            'mach_corr': mach_corr,
            'alt': alt,
            'lift_curve_info_dict': lift_curve_info_dict
        }
        trim0 = np.array([alpha0, o])
        alpha_trim, omega_trim, converged = trim.trim(quad, v_inf, trim0,
                                                      ff_kwargs)
        T_ff, H_ff, P_ff = bemt.bemt_forward_flight(
            quad,
            pitch,
            omega_trim,
            alpha_trim,
            v_inf,
            n_azi_elements,
            alt=alt,
            tip_loss=tip_loss,
            mach_corr=mach_corr,
            allowable_Re=allowable_Re,
            Cl_funs=Cl_funs,
            Cd_funs=Cd_funs,
            lift_curve_info_dict=lift_curve_info_dict)

        dT_h, P_h = bemt.bemt_axial(prop,
                                    pitch,
                                    o,
                                    allowable_Re=allowable_Re,
                                    Cl_funs=Cl_funs,
                                    Cd_funs=Cd_funs,
                                    tip_loss=tip_loss,
                                    mach_corr=mach_corr,
                                    alt=alt)
        return sum(dT_h), P_h, T_ff, P_ff, alpha_trim, omega_trim
Exemple #4
0
def equilibrium(x, v_inf, quadrotor, kwargs, called_from='trim'):
    try:
        # If x is a 2x1 np.matrix this will handle it
        alpha = x[0, 0]
        omega = x[1, 0]
    except (IndexError, TypeError):
        # If x is a list or tuple this will handle it
        alpha, omega = x
    n_azi_elements = kwargs['n_azi_elements']
    alt = kwargs['alt']
    allowable_Re = kwargs['allowable_Re']
    Cl_funs = kwargs['Cl_funs']
    Cd_funs = kwargs['Cd_funs']
    dens = get_dens(alt)
    pitch = kwargs['pitch']
    tip_loss = kwargs['tip_loss']
    mach_corr = kwargs['mach_corr']
    try:
        thrust, rotor_drag, rotor_power, bemt_converged = bemt_forward_flight(
            quadrotor,
            pitch,
            omega,
            alpha,
            v_inf,
            n_azi_elements,
            alt=alt,
            tip_loss=tip_loss,
            mach_corr=mach_corr,
            allowable_Re=allowable_Re,
            Cl_funs=Cl_funs,
            Cd_funs=Cd_funs)
    except Exception as e:
        print "{} in ff bemt".format(type(e).__name__)
        raise
    f1 = thrust * np.sin(alpha) - rotor_drag * np.cos(
        alpha) - quadrotor.frame_drag(alpha, v_inf, dens) / 4
    f2 = thrust * np.cos(alpha) + rotor_drag * np.sin(
        alpha) - quadrotor.weight / 4
    return f1, f2, bemt_converged
def objfun(xn, **kwargs):
    radius = kwargs['radius']
    r = kwargs['r']
    y = kwargs['y']
    dr = kwargs['dr']
    dy = kwargs['dy']
    n_blades = kwargs['n_blades']
    airfoils = kwargs['airfoils']
    pitch = kwargs['pitch']
    vehicle_weight = kwargs['vehicle_weight']
    max_chord = kwargs['max_chord']
    max_chord_tip = kwargs['max_chord_tip']
    tip_loss = kwargs['tip_loss']
    mach_corr = kwargs['mach_corr']
    Cl_tables = kwargs['Cl_tables']
    Cd_tables = kwargs['Cd_tables']
    Cl_funs = kwargs['Cl_funs']
    Cd_funs = kwargs['Cd_funs']
    lift_curve_info_dict = kwargs['lift_curve_info_dict']
    allowable_Re = kwargs['allowable_Re']
    alt = kwargs['alt']
    v_inf = kwargs['v_inf']
    alpha0 = kwargs['alpha0']
    n_azi_elements = kwargs['n_azi_elements']
    mission_time = kwargs['mission_time']
    omega_h = xn[0]
    twist0 = xn[1]
    chord0 = xn[
        2] * radius  # Convert to meters from c/R before we use in calculations
    dtwist = np.array(xn[3:len(r) + 2])
    dchord = np.array([x * radius for x in xn[len(r) + 2:2 * len(r) + 2]])

    twist = calc_twist_dist(twist0, dtwist)
    chord = calc_chord_dist(chord0, dchord)

    f = 10000000.
    fail = 0
    g = [1.0] * (2 * len(r) + 2)

    # Calculate geometric constraint values. If a genetic algorithm is used we can fail the case immediately if there
    # are any violations. If a gradient-based algorithm is used this will cause the gradient calculation to fail so the
    # constraints must be checked normally by the optimizer.
    g[1] = chord[-1] / radius - max_chord_tip
    g[2:] = get_geocons(chord, max_chord, radius)

    prop = propeller.Propeller(twist,
                               chord,
                               radius,
                               n_blades,
                               r,
                               y,
                               dr,
                               dy,
                               airfoils=airfoils,
                               Cl_tables=Cl_tables,
                               Cd_tables=Cd_tables)

    quad = quadrotor.Quadrotor(prop, vehicle_weight)

    try:
        dT_h, P_h = bemt.bemt_axial(prop,
                                    pitch,
                                    omega_h,
                                    allowable_Re=allowable_Re,
                                    Cl_funs=Cl_funs,
                                    Cd_funs=Cd_funs,
                                    tip_loss=tip_loss,
                                    mach_corr=mach_corr,
                                    alt=alt)
    except FloatingPointError:
        print "Floating point error in axial BEMT"
        fail = 1
        return f, g, fail
    except IndexError:
        print "Index error in axial BEMT"
        fail = 1
        return f, g, fail

    try:
        trim0 = [
            alpha0, omega_h
        ]  # Use alpha0 (supplied by user) and the hover omega as initial guesses for trim
        ff_kwargs = {
            'propeller': prop,
            'pitch': pitch,
            'n_azi_elements': n_azi_elements,
            'allowable_Re': allowable_Re,
            'Cl_funs': Cl_funs,
            'Cd_funs': Cd_funs,
            'tip_loss': tip_loss,
            'mach_corr': mach_corr,
            'alt': alt,
            'lift_curve_info_dict': lift_curve_info_dict
        }

        alpha_trim, omega_trim, converged = trim.trim(quad, v_inf, trim0,
                                                      ff_kwargs)
        if not converged or not 0 < alpha_trim < np.pi / 2 or omega_trim < 0:
            fail = 1
            return f, g, fail

        T_trim, H_trim, P_trim = bemt.bemt_forward_flight(
            quad,
            pitch,
            omega_trim,
            alpha_trim,
            v_inf,
            n_azi_elements,
            alt=alt,
            tip_loss=tip_loss,
            mach_corr=mach_corr,
            allowable_Re=allowable_Re,
            Cl_funs=Cl_funs,
            Cd_funs=Cd_funs,
            lift_curve_info_dict=lift_curve_info_dict)
    except Exception as e:
        print "{} in ff trim".format(type(e).__name__)
        fail = 1
        return f, g, fail

    # Find total energy mission_times = [time_in_hover, time_in_ff] in seconds
    energy = P_h * mission_time[0] + P_trim * mission_time[1]

    f = energy
    print "total energy = " + str(f)
    print "Thrust hover = %s" % str(sum(dT_h))
    print "(alpha, omega) = (%f, %f)" % (alpha_trim, omega_trim)

    # Evaluate performance constraints.
    g[0] = vehicle_weight / 4 - sum(dT_h)
    if g[0] > 0:
        print "hover thrust too low"

    return f, g, fail
drag_exp = np.array([[-0.8, -0.25, 0., 0.25, 0.3], [-1.25, -0.5, -0.1, 0.2, 0.3], [-2.2, -0.9, -0.25, 0.2, 0.45]])
drag_exp = np.array([drag_exp[0], drag_exp[2]])
alphas_exp = np.array([-20., -10., -5., -2.5, 0.])[::-1]

q = 22.98252   # dynamic pressure in N/m**2
dens = 1.225
v_inf = np.sqrt(2*q/dens)
frame_drag = 0.27 * 0.092903 * q
omegas = np.array([2800., 4200.])
alphas = np.linspace(20., 0., 10)[::-1]
lift = np.empty([len(omegas), len(alphas)], dtype=float)
drag = np.empty([len(omegas), len(alphas)], dtype=float)
for j, o in enumerate(omegas*2*np.pi/60):
    for k, a in enumerate(alphas*2*np.pi/360):
        T, H, P = bemt.bemt_forward_flight(quad, pitch, o, a, v_inf, n_azi_elements, alt=alt,
                                           tip_loss=tip_loss, mach_corr=mach_corr, allowable_Re=allowable_Re,
                                           Cl_funs=Cl_funs, Cd_funs=Cd_funs,
                                           lift_curve_info_dict=lift_curve_info_dict)
        lift[j, k] = T*np.cos(a) + H*np.sin(a)
        drag[j, k] = H*np.cos(a) - T*np.sin(a) + frame_drag
        #print "drag = " + str(H*np.cos(a) - T*np.sin(a) + frame_drag)
        #print "frame drag = " + str(frame_drag)
lift *= 0.224809
drag *= 0.224809

# color_str = ['ko-', 'k*-', 'kv-', 'ks-', 'kD-']
# color_str_disc = ['ko-', 'k*-', 'kv-', 'ks-', 'kD-']
# l = []
# plt.figure(1)
# for i in xrange(len(omegas)):
#     lift[i, :][5:] *= 0.98
#     plt.plot(alphas*-1, lift[i, :]*4, color_str[i], markerfacecolor='white', markersize=8)