예제 #1
0
def compute_noise(config, analyses, noise_segment, noise_settings):
    """This method computes the noise of a turbofan aircraft
            
    Assumptions:
        N/A

    Source:
        N/A 

    Inputs:
        config.
        networks.turbofan     - SUAVE turbofan data structure               [None]
        output_file           - flag to write noise outout to file          [Boolean]
        output_file_engine    - flag to write engine outout to file         [Boolean]
        print_output          - flag to print outout to file                [Boolean]
        engine_flag           - flag to include engine in noise calculation [Boolean]
        
    Outputs: 
        noise_sum                                                           [dB]

    Properties Used:
        N/A 
        
    """

    turbofan = config.networks['turbofan']
    outputfile = config.output_file
    outputfile_engine = config.output_file_engine
    print_output = config.print_output
    engine_flag = config.engine_flag

    geometric = noise_geometric(noise_segment, analyses, config)

    airframe_noise = noise_airframe_Fink(noise_segment, analyses, config,
                                         noise_settings, print_output,
                                         outputfile)

    engine_noise = noise_SAE(turbofan, noise_segment, analyses, config,
                             noise_settings, print_output, outputfile_engine)

    noise_sum = 10. * np.log10(10**(airframe_noise.EPNL_total / 10) +
                               (engine_flag) * 10**
                               (engine_noise.EPNL_total / 10))

    return noise_sum
예제 #2
0
def compute_noise(config,analyses,noise_segment):

    turbofan = config.propulsors['turbofan']
    
    outputfile        = config.output_file
    outputfile_engine = config.output_file_engine
    print_output      = config.print_output
    engine_flag       = config.engine_flag  #remove engine noise component from the approach segment
    
    geometric = noise_geometric(noise_segment,analyses,config)
    
    airframe_noise = noise_airframe_Fink(config,analyses,noise_segment,print_output,outputfile)  

    engine_noise   = noise_SAE(turbofan,noise_segment,config,analyses,print_output,outputfile_engine)

    noise_sum = 10. * np.log10(10**(airframe_noise[0]/10)+ (engine_flag)*10**(engine_noise[0]/10))


    return noise_sum
예제 #3
0
파일: Procedure.py 프로젝트: michK/SUAVE
def compute_noise(config,analyses,noise_segment):

    turbofan = config.propulsors['turbofan']
    
    outputfile        = config.output_file
    outputfile_engine = config.output_file_engine
    print_output      = config.print_output
    engine_flag       = config.engine_flag  #remove engine noise component from the approach segment
    
    geometric = noise_geometric(noise_segment,analyses,config)
    
    airframe_noise = noise_airframe_Fink(config,analyses,noise_segment,print_output,outputfile)  

    engine_noise   = noise_SAE(turbofan,noise_segment,config,analyses,print_output,outputfile_engine)

    noise_sum = 10. * np.log10(10**(airframe_noise[0]/10)+ (engine_flag)*10**(engine_noise[0]/10))


    return noise_sum
예제 #4
0
    def evaluate_noise(self, segment):
        """ Process vehicle to setup geometry, condititon and configuration
    
        Assumptions:
        None
    
        Source:
        N/4
    
        Inputs:
        self.settings.
            ground_microphone_phi_angles   - azimuth measured from observer to aircraft body frame     [radians]
            ground_microphone_theta_angles - axial angle measured from observer to aircraft body frame [radians]
            center_frequencies             - 1/3 octave band frequencies                               [unitless]
    
        Outputs:
        None
    
        Properties Used:
        self.geometry
        """

        # unpack
        config = segment.analyses.noise.geometry
        analyses = segment.analyses
        settings = self.settings
        conditions = segment.state.conditions
        print_flag = settings.print_noise_output

        # unpack
        alt = -conditions.frames.inertial.position_vector[:, 2]
        gm_phi = settings.ground_microphone_phi_angles
        gm_theta = settings.ground_microphone_theta_angles
        cf = settings.center_frequencies

        dim_alt = len(alt)
        dim_phi = len(gm_phi)
        dim_theta = len(gm_theta)
        num_mic = dim_phi * dim_theta
        dim_cf = len(cf)

        # dimension:[control point, theta, phi]
        theta = np.repeat(np.repeat(np.atleast_2d(gm_theta).T, dim_phi,
                                    axis=1)[np.newaxis, :, :],
                          dim_alt,
                          axis=0)
        phi = np.repeat(np.repeat(np.atleast_2d(gm_phi), dim_theta,
                                  axis=0)[np.newaxis, :, :],
                        dim_alt,
                        axis=0)
        altitude = np.repeat(np.repeat(np.atleast_2d(alt).T, dim_theta,
                                       axis=1)[:, :, np.newaxis],
                             dim_phi,
                             axis=2)
        x_vals = altitude / np.tan(theta)
        y_vals = altitude / np.tan(phi)
        z_vals = altitude

        # store microphone locations
        mic_locations = np.zeros((dim_alt, num_mic, 3))
        mic_locations[:, :, 0] = x_vals.reshape(dim_alt, num_mic)
        mic_locations[:, :, 1] = y_vals.reshape(dim_alt, num_mic)
        mic_locations[:, :, 2] = z_vals.reshape(dim_alt, num_mic)

        # append microphone locations to conditions
        conditions.noise.microphone_theta_angles = gm_theta
        conditions.noise.microphone_phi_angles = gm_phi
        conditions.noise.microphone_locations = mic_locations
        conditions.noise.number_of_microphones = num_mic

        ctrl_pts = len(altitude)

        # create empty arrays for results
        num_src = len(config.propulsors) + 1
        if ('lift_cruise') in config.propulsors.keys():
            num_src += 1
        source_SPLs_dBA = np.zeros((ctrl_pts, num_src, num_mic))
        source_SPL_spectra = np.zeros((ctrl_pts, num_src, num_mic, dim_cf))

        si = 1
        # iterate through sources
        for source in conditions.noise.sources.keys():
            for network in config.propulsors.keys():
                if source == 'turbofan':
                    geometric = noise_geometric(segment, analyses, config)

                    # flap noise - only applicable for turbofan aircraft
                    if 'flap' in config.wings.main_wing.control_surfaces:
                        airframe_noise = noise_airframe_Fink(
                            segment, analyses, config, settings)
                        source_SPLs_dBA[:, si, :] = airframe_noise.SPL_dBA
                        source_SPL_spectra[:, si, :, 5:] = np.repeat(
                            airframe_noise.SPL_spectrum[:, np.newaxis, :],
                            num_mic,
                            axis=1)

                    if bool(conditions.noise.sources[source].fan) and bool(
                            conditions.noise.sources[source].core):

                        config.propulsors[
                            source].fan.rotation = 0  # FUTURE WORK: NEED TO UPDATE ENGINE MODEL WITH FAN SPEED in RPM
                        config.propulsors[
                            source].fan_nozzle.noise_speed = conditions.noise.sources.turbofan.fan.exit_velocity
                        config.propulsors[
                            source].core_nozzle.noise_speed = conditions.noise.sources.turbofan.core.exit_velocity
                        engine_noise = noise_SAE(config.propulsors[source],
                                                 segment,
                                                 analyses,
                                                 config,
                                                 settings,
                                                 ioprint=print_flag)
                        source_SPLs_dBA[:, si, :] = np.repeat(
                            np.atleast_2d(engine_noise.SPL_dBA).T,
                            num_mic,
                            axis=1
                        )  # noise measures at one microphone location in segment
                        source_SPL_spectra[:, si, :, 5:] = np.repeat(
                            engine_noise.SPL_spectrum[:, np.newaxis, :],
                            num_mic,
                            axis=1
                        )  # noise measures at one microphone location in segment

                elif (source == 'propeller') or (source == 'rotor'):
                    if bool(conditions.noise.sources[source]) == True:
                        net = config.propulsors[network]
                        prop = config.propulsors[network][source]
                        acoustic_data = conditions.noise.sources[source]
                        propeller_noise = propeller_mid_fidelity(
                            net, prop, acoustic_data, segment, settings)
                        source_SPLs_dBA[:, si, :] = propeller_noise.SPL_dBA
                        source_SPL_spectra[:,
                                           si, :, :] = propeller_noise.SPL_spectrum

                        si += 1

        conditions.noise.total_SPL_dBA = SPL_arithmetic(source_SPLs_dBA,
                                                        sum_axis=1)

        return
예제 #5
0
    def evaluate_noise(self, segment):
        """ Process vehicle to setup geometry, condititon and configuration
    
        Assumptions:
        None
    
        Source:
        N/4
    
        Inputs:
        self.settings.
            center_frequencies  - 1/3 octave band frequencies   [unitless]
    
        Outputs:
        None
    
        Properties Used:
        self.geometry
        """

        # unpack
        config = segment.analyses.noise.geometry
        analyses = segment.analyses
        settings = self.settings
        print_flag = settings.print_noise_output
        conditions = segment.state.conditions
        dim_cf = len(settings.center_frequencies)
        ctrl_pts = int(segment.state.numerics.number_control_points)
        min_x = settings.level_ground_microphone_min_x
        max_x = settings.level_ground_microphone_max_x
        min_y = settings.level_ground_microphone_min_y
        max_y = settings.level_ground_microphone_max_y
        x_resolution = settings.level_ground_microphone_x_resolution
        y_resolution = settings.level_ground_microphone_y_resolution

        # generate noise valuation points
        settings.ground_microphone_locations = generate_ground_microphone_points(
            min_x, max_x, min_y, max_y, x_resolution, y_resolution)

        GM_THETA, GM_PHI, GML, num_gm_mic = compute_ground_noise_evaluation_locations(
            settings, segment)

        BM_THETA, BM_PHI, UCML, num_b_mic = compute_building_noise_evaluation_locations(
            settings, segment)

        mic_locations = np.concatenate((GML, UCML), axis=1)
        THETA = np.concatenate((GM_THETA, BM_THETA), axis=1)
        PHI = np.concatenate((GM_PHI, BM_PHI), axis=1)

        num_mic = num_b_mic + num_gm_mic

        # append microphone locations to conditions
        conditions.noise.ground_microphone_theta_angles = GM_THETA
        conditions.noise.building_microphone_theta_angles = BM_THETA
        conditions.noise.total_microphone_theta_angles = THETA

        conditions.noise.ground_microphone_phi_angles = GM_PHI
        conditions.noise.building_microphone_phi_angles = BM_PHI
        conditions.noise.total_microphone_phi_angles = PHI

        conditions.noise.ground_microphone_locations = GML
        conditions.noise.building_microphone_locations = UCML
        conditions.noise.total_microphone_locations = mic_locations

        conditions.noise.number_ground_microphones = num_gm_mic
        conditions.noise.number_building_microphones = num_b_mic
        conditions.noise.total_number_of_microphones = num_mic

        # create empty arrays for results
        num_src = len(config.networks) + 1
        if ('lift_cruise') in config.networks.keys():
            num_src += 1
        source_SPLs_dBA = np.zeros((ctrl_pts, num_src, num_mic))
        source_SPL_spectra = np.zeros((ctrl_pts, num_src, num_mic, dim_cf))

        si = 1
        # iterate through sources
        for source in conditions.noise.sources.keys():
            for network in config.networks.keys():
                if source == 'turbofan':
                    geometric = noise_geometric(segment, analyses, config)

                    # flap noise - only applicable for turbofan aircraft
                    if 'flap' in config.wings.main_wing.control_surfaces:
                        airframe_noise = noise_airframe_Fink(
                            segment, analyses, config, settings)
                        source_SPLs_dBA[:, si, :] = airframe_noise.SPL_dBA
                        source_SPL_spectra[:, si, :, 5:] = np.repeat(
                            airframe_noise.SPL_spectrum[:, np.newaxis, :],
                            num_mic,
                            axis=1)

                    if bool(conditions.noise.sources[source].fan) and bool(
                            conditions.noise.sources[source].core):

                        config.networks[
                            source].fan.rotation = 0  # FUTURE WORK: NEED TO UPDATE ENGINE MODEL WITH FAN SPEED in RPM
                        config.networks[
                            source].fan_nozzle.noise_speed = conditions.noise.sources.turbofan.fan.exit_velocity
                        config.networks[
                            source].core_nozzle.noise_speed = conditions.noise.sources.turbofan.core.exit_velocity
                        engine_noise = noise_SAE(config.networks[source],
                                                 segment,
                                                 analyses,
                                                 config,
                                                 settings,
                                                 ioprint=print_flag)
                        source_SPLs_dBA[:, si, :] = np.repeat(
                            np.atleast_2d(engine_noise.SPL_dBA).T,
                            num_mic,
                            axis=1
                        )  # noise measures at one microphone location in segment
                        source_SPL_spectra[:, si, :, 5:] = np.repeat(
                            engine_noise.SPL_spectrum[:, np.newaxis, :],
                            num_mic,
                            axis=1
                        )  # noise measures at one microphone location in segment

                elif (source == 'propellers') or (source == 'lift_rotors'):
                    if bool(conditions.noise.sources[source]) == True:
                        net = config.networks[network]
                        acoustic_data = conditions.noise.sources[source]
                        propeller_noise = propeller_mid_fidelity(
                            net, acoustic_data, segment, settings, source)
                        source_SPLs_dBA[:, si, :] = propeller_noise.SPL_dBA
                        source_SPL_spectra[:,
                                           si, :, :] = propeller_noise.SPL_spectrum

                        si += 1

        conditions.noise.total_SPL_dBA = SPL_arithmetic(source_SPLs_dBA,
                                                        sum_axis=1)

        return
예제 #6
0
def noise_airframe_Fink(config,
                        analyses,
                        noise_segment,
                        ioprint=0,
                        filename=0):
    """ SUAVE.Methods.Noise.Fidelity_One.noise_fidelity_one(config, analyses, noise_segment):
            Computes the noise from different sources of the airframe for a given vehicle for a constant altitude flight.

            Inputs:
                vehicle	 - SUAVE type vehicle

                includes these fields:
                    S                          - Wing Area
                    bw                         - Wing Span
                    Sht                        - Horizontal tail area
                    bht                        - Horizontal tail span
                    Svt                        - Vertical tail area
                    bvt                        - Vertical tail span
                    deltaf                     - Flap deflection
                    Sf                         - Flap area
                    cf                         - Flap chord
                    slots                      - Number of slots (Flap type)
                    Dp                         - Main landing gear tyre diameter
                    Hp                         - Main lading gear strut length
                    Dn                         - Nose landing gear tyre diameter
                    Hn                         - Nose landing gear strut length
                    wheels                     - Number of wheels

                airport   - SUAVE type airport data, with followig fields:
                    atmosphere                  - Airport atmosphere (SUAVE type)
                    altitude                    - Airport altitude
                    delta_isa                   - ISA Temperature deviation


            Outputs: One Third Octave Band SPL [dB]
                SPL_wing                         - Sound Pressure Level of the clean wing
                SPLht                            - Sound Pressure Level of the horizontal tail
                SPLvt                            - Sound Pressure Level of the vertical tail
                SPL_flap                         - Sound Pressure Level of the flaps trailing edge
                SPL_slat                         - Sound Pressure Level of the slat leading edge
                SPL_main_landing_gear            - Sound Pressure Level og the main landing gear
                SPL_nose_landing_gear            - Sound Pressure Level of the nose landing gear

            Assumptions:
                Correlation based."""

    # ==============================================
    # Unpack
    # ==============================================
    wing = config.wings

    Sw = wing.main_wing.areas.reference / (Units.ft)**2  #wing area, sq.ft
    bw = wing.main_wing.spans.projected / Units.ft  #wing span, ft
    Sht = wing.horizontal_stabilizer.areas.reference / (
        Units.ft)**2  #horizontal tail area, sq.ft
    bht = wing.horizontal_stabilizer.spans.projected / Units.ft  #horizontal tail span, ft
    Svt = wing.vertical_stabilizer.areas.reference / (
        Units.ft)**2  #vertical tail area, sq.ft
    bvt = wing.vertical_stabilizer.spans.projected / Units.ft  #vertical tail span, ft
    deltaf = wing.main_wing.flaps.angle  #flap delection, rad
    Sf = wing.main_wing.flaps.area / (Units.ft)**2  #flap area, sq.ft
    cf = wing.main_wing.flaps.chord_dimensional / Units.ft  #flap chord, ft
    Dp = config.landing_gear.main_tire_diameter / Units.ft  #MLG tyre diameter, ft
    Hp = config.landing_gear.nose_tire_diameter / Units.ft  #MLG strut length, ft
    Dn = config.landing_gear.main_strut_length / Units.ft  #NLG tyre diameter, ft
    Hn = config.landing_gear.nose_strut_length / Units.ft  #NLG strut length, ft
    gear = config.landing_gear.gear_condition  #Gear up or gear down

    nose_wheels = config.landing_gear.nose_wheels  #Number of wheels
    main_wheels = config.landing_gear.main_wheels  #Number of wheels
    main_units = config.landing_gear.main_units  #Number of main units
    velocity = np.float(noise_segment.conditions.freestream.velocity[0, 0])
    altitude = noise_segment.conditions.freestream.altitude[:, 0]
    time = noise_segment.conditions.frames.inertial.time[:, 0]

    noise_time = np.arange(0., time[-1], .5)
    altitude = np.interp(noise_time, time, altitude)

    # determining flap slot number
    if wing.main_wing.flaps.type == 'single_sloted':
        slots = 1
    elif wing.main_wing.flaps.type == 'double_sloted':
        slots = 2
    elif wing.main_wing.flaps.type == 'triple_sloted':
        slots = 3

    # Calls the function noise_geometric to calculate all the distance and emission angles
    geometric = noise_geometric(noise_segment, analyses, config)

    distance_vector = geometric[:][0]
    angle = geometric[:][1]
    phi = geometric[:][2]

    distance_vector = np.interp(noise_time, time, distance_vector)
    angle = np.interp(noise_time, time, angle)
    phi = np.interp(noise_time, time, phi)

    # Number of points on the discretize segment
    nsteps = len(noise_time)

    # Preparing matrix for noise calculation
    sound_speed = np.zeros(nsteps)
    density = np.zeros(nsteps)
    viscosity = np.zeros(nsteps)
    temperature = np.zeros(nsteps)
    M = np.zeros(nsteps)
    deltaw = np.zeros(nsteps)

    # ==============================================
    #         Computing atmospheric conditions
    # ==============================================

    for id in range(0, nsteps):
        atmo_data = analyses.atmosphere.compute_values(altitude[id])

        #unpack
        sound_speed[id] = np.float(atmo_data.speed_of_sound)
        density[id] = np.float(atmo_data.density)
        viscosity[id] = np.float(atmo_data.dynamic_viscosity *
                                 10.7639)  #units converstion - m2 to ft2
        temperature[id] = np.float(atmo_data.temperature)

        #Mach number
        M[id] = velocity / np.sqrt(1.4 * 287 * temperature[id])

        #Wing Turbulent Boundary Layer thickness, ft
        deltaw[id] = 0.37 * (Sw / bw) * ((velocity / Units.ft) * Sw /
                                         (bw * viscosity[id]))**(-0.2)

    #Units conversion - knots to ft/s
    kt2fts = 1.6878098571

    #Generate array with the One Third Octave Band Center Frequencies
    frequency = np.array((50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, \
            2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000))

    # Velocity in fts
    velocity_fst = velocity * Units.knot

    #number of positions of the aircraft to calculate the noise
    nrange = len(angle)
    i = 0
    SPL_wing_history = np.zeros((nrange, 24))
    SPLht_history = np.zeros((nrange, 24))
    SPLvt_history = np.zeros((nrange, 24))
    SPL_flap_history = np.zeros((nrange, 24))
    SPL_slat_history = np.zeros((nrange, 24))
    SPL_main_landing_gear_history = np.zeros((nrange, 24))
    SPL_nose_landing_gear_history = np.zeros((nrange, 24))
    SPL_total_history = np.zeros((nrange, 24))

    #Noise history in dBA
    SPLt_dBA_history = np.zeros((nrange, 24))

    #START LOOP FOR EACH POSITION OF AIRCRAFT
    for i in range(0, nrange - 1):
        #Emission angle theta
        theta = angle[i]
        #Distance from airplane to observer, evaluated at retarded time
        distance = distance_vector[i]

        #Atmospheric attenuation
        delta_atmo = atmospheric_attenuation(distance)

        #Call each noise source model
        SPL_wing = noise_clean_wing(
            Sw, bw, 0, 1, deltaw[i], velocity, viscosity[i], M[i], phi[i],
            theta, distance, frequency) - delta_atmo  #Wing Noise
        SPLht = noise_clean_wing(
            Sht, bht, 0, 1, deltaw[i], velocity, viscosity[i], M[i], phi[i],
            theta, distance, frequency) - delta_atmo  #Horizontal Tail Noise
        SPLvt = noise_clean_wing(Svt, bvt, 0, 0, deltaw[i], velocity,
                                 viscosity[i], M[i], phi[i], theta, distance,
                                 frequency) - delta_atmo  #Vertical Tail Noise

        SPL_slat = noise_leading_edge_slat(
            SPL_wing, Sw, bw, velocity, deltaw[i], viscosity[i], M[i], phi[i],
            theta, distance, frequency) - delta_atmo  #Slat leading edge

        if (deltaf == 0):
            SPL_flap = np.zeros(24)
        else:
            SPL_flap = noise_trailing_edge_flap(
                Sf, cf, deltaf, slots, velocity, M[i], phi[i], theta, distance,
                frequency) - delta_atmo  #Trailing Edge Flaps Noise

        if gear == 'up':  #0
            SPL_main_landing_gear = np.zeros(24)
            SPL_nose_landing_gear = np.zeros(24)
        else:
            SPL_main_landing_gear = noise_landing_gear(
                Dp, Hp, main_wheels, M[i], velocity, phi[i], theta, distance,
                frequency) - delta_atmo  #Main Landing Gear Noise
            SPL_nose_landing_gear = noise_landing_gear(
                Dn, Hn, nose_wheels, M[i], velocity, phi[i], theta, distance,
                frequency) - delta_atmo  #Nose Landing Gear Noise
        if main_units > 1:  #Incoherent summation of each main landing gear unit
            SPL_main_landing_gear = SPL_main_landing_gear + 3 * (main_units -
                                                                 1)

        #Total Airframe Noise
        SPL_total = 10.*np.log10(10.0**(0.1*SPL_wing)+10.0**(0.1*SPLht)+10**(0.1*SPL_flap)+ \
             10.0**(0.1*SPL_slat)+10.0**(0.1*SPL_main_landing_gear)+10.0**(0.1*SPL_nose_landing_gear)) - delta_atmo

        #Included 02nd September 2015
        SPLt_dBA = dbA_noise(SPL_total)
        SPLt_dBA_history[i][:] = SPLt_dBA[:]

        SPL_total_history[i][:] = SPL_total[:]
        SPL_wing_history[i][:] = SPL_wing[:]
        SPLvt_history[i][:] = SPLvt[:]
        SPLht_history[i][:] = SPLht[:]
        SPL_flap_history[i][:] = SPL_flap[:]
        SPL_slat_history[i][:] = SPL_slat[:]
        SPL_nose_landing_gear_history[i][:] = SPL_nose_landing_gear[:]
        SPL_main_landing_gear_history[i][:] = SPL_main_landing_gear[:]

#Calculation of dBA based on the sound pressure time history
# dbA_total                =       dbA_noise(SPL_total_history)    #(Not used to certification point)

#Calculation of the Perceived Noise Level EPNL based on the sound time history
    PNL_total = pnl_noise(SPL_total_history)
    PNL_wing = pnl_noise(SPL_wing_history)
    PNL_ht = pnl_noise(SPLht_history)
    PNL_vt = pnl_noise(SPLvt_history)
    PNL_nose_landing_gear = pnl_noise(SPL_nose_landing_gear_history)
    PNL_main_landing_gear = pnl_noise(SPL_main_landing_gear_history)
    PNL_slat = pnl_noise(SPL_slat_history)
    PNL_flap = pnl_noise(SPL_flap_history)

    #Calculation of the tones corrections on the SPL for each component and total
    tone_correction_total = noise_tone_correction(SPL_total_history)
    tone_correction_wing = noise_tone_correction(SPL_wing_history)
    tone_correction_ht = noise_tone_correction(SPLht_history)
    tone_correction_vt = noise_tone_correction(SPLvt_history)
    tone_correction_flap = noise_tone_correction(SPL_flap_history)
    tone_correction_slat = noise_tone_correction(SPL_slat_history)
    tone_correction_nose_landing_gear = noise_tone_correction(
        SPL_nose_landing_gear_history)
    tone_correction_main_landing_gear = noise_tone_correction(
        SPL_main_landing_gear_history)

    #Calculation of the PLNT for each component and total
    PNLT_total = PNL_total + tone_correction_total
    PNLT_wing = PNL_wing + tone_correction_wing
    PNLT_ht = PNL_ht + tone_correction_ht
    PNLT_vt = PNL_vt + tone_correction_vt
    PNLT_nose_landing_gear = PNL_nose_landing_gear + tone_correction_nose_landing_gear
    PNLT_main_landing_gear = PNL_main_landing_gear + tone_correction_main_landing_gear
    PNLT_slat = PNL_slat + tone_correction_slat
    PNLT_flap = PNL_flap + tone_correction_flap

    #Calculation of the EPNL for each component and total
    EPNL_total = epnl_noise(PNLT_total)
    EPNL_wing = epnl_noise(PNLT_wing)
    EPNL_ht = epnl_noise(PNLT_ht)
    EPNL_vt = epnl_noise(PNLT_vt)
    EPNL_nose_landing_gear = epnl_noise(PNLT_nose_landing_gear)
    EPNL_main_landing_gear = epnl_noise(PNLT_main_landing_gear)
    EPNL_slat = epnl_noise(PNLT_slat)
    EPNL_flap = epnl_noise(PNLT_flap)

    if ioprint:
        # write header of file
        if not filename:
            filename = ('Noise_' + str(config.tag) + '.dat')

        fid = open(filename, 'w')  # Open output file

        fid.write('Reference speed =  ')
        fid.write(str('%2.2f' % (velocity / Units.kts)) + '  kts')
        fid.write('\n')
        fid.write('PNLT history')
        fid.write('\n')
        fid.write(
            'time       altitude      Mach    Polar angle    Azim angle   distance       wing  	 ht 	     vt 	flap   	    slat   	nose        main       total'
        )
        fid.write('\n')

        for id in range(0, nsteps):
            fid.write(str('%2.2f' % time[id]) + '        ')
            fid.write(str('%2.2f' % altitude[id]) + '        ')
            fid.write(str('%2.2f' % M[id]) + '        ')
            fid.write(str('%2.2f' % (angle[id] * 180 / np.pi)) + '        ')
            fid.write(str('%2.2f' % (phi[id] * 180 / np.pi)) + '        ')
            fid.write(str('%2.2f' % distance_vector[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_wing[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_ht[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_vt[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_flap[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_slat[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_nose_landing_gear[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_main_landing_gear[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_total[id]) + '        ')
            fid.write('\n')
        fid.write('\n')
        fid.write('PNLT max =  ')
        fid.write(str('%2.2f' % (np.max(PNLT_total))) + '  dB')
        fid.write('\n')
        fid.write('\n')
        fid.write('EPNdB')
        fid.write('\n')
        fid.write(
            'wing	       ht          vt         flap         slat    	nose        main	total'
        )
        fid.write('\n')
        fid.write(str('%2.2f' % EPNL_wing) + '        ')
        fid.write(str('%2.2f' % EPNL_ht) + '        ')
        fid.write(str('%2.2f' % EPNL_vt) + '        ')
        fid.write(str('%2.2f' % EPNL_flap) + '        ')
        fid.write(str('%2.2f' % EPNL_slat) + '        ')
        fid.write(str('%2.2f' % EPNL_nose_landing_gear) + '        ')
        fid.write(str('%2.2f' % EPNL_main_landing_gear) + '        ')
        fid.write(str('%2.2f' % EPNL_total) + '        ')
        fid.close

        filename1 = ('History_Noise_' + str(config.tag) + '.dat')
        fid = open(filename1, 'w')  # Open output file
        fid.write('Reference speed =  ')
        fid.write(str('%2.2f' % (velocity / Units.kts)) + '  kts')
        fid.write('\n')
        fid.write('Sound Pressure Level for the Total Aircraft Noise')
        fid.write('\n')

        for nid in range(0, nrange):
            fid.write('Polar angle = ' + str('%2.2f' % (angle[nid] *
                                                        (180 / np.pi))) +
                      '  degrees' + '\n')
            fid.write('f		total SPL(dB)    total SPL(dBA)' + '\n')
            for id in range(0, 24):
                fid.write(str((frequency[id])) + '           ')
                fid.write(
                    str('%3.2f' % SPL_total_history[nid][id]) + '          ')
                fid.write(str('%3.2f' % SPLt_dBA_history[nid][id]))
                fid.write('\n')
            fid.write('SPLmax (dB) =  ')
            fid.write(
                str('%3.2f' % (np.max(SPL_total_history[nid][:]))) + '  dB' +
                '\n')
            fid.write('SPLmax (dBA) =  ')
            fid.write(
                str('%3.2f' % (np.max(SPLt_dBA_history[nid][:]))) + '  dB')
            fid.write('\n')

        fid.close

    return (EPNL_total, SPL_total_history)
예제 #7
0
def noise_SAE (turbofan,noise_segment,config,analyses,ioprint = 0, filename = 0): 

    #SAE ARP*876D 1994
    """This method predicts the free-field 1/3 Octave Band SPL of coaxial subsonic
    jets for turbofan engines under the following conditions:
        a) Flyover (observer on ground)
        b) Static (observer on ground)
        c) In-flight or in-flow (observer on airplane or in a wind tunnel)

        Inputs:
                    vehicle	 - SUAVE type vehicle

                    includes these fields:
                        Velocity_primary           - Primary jet flow velocity
                        Temperature_primary        - Primary jet flow temperature
                        Pressure_primary           - Primary jet flow pressure
                        Area_primary               - Area of the primary nozzle
                        Velocity_secondary         - Secondary jet flow velocity
                        Temperature_secondary      - Secondary jet flow temperature
                        Pressure_secondary         - Secondary jet flow pressure
                        Area_secondary             - Area of the secondary nozzle
                        AOA                        - Angle of attack
                        Velocity_aircraft          - Aircraft velocity
                        Altitude                   - Altitude
                        N1                         - Fan rotational speed [rpm]
                        EXA                        - Distance from fan face to fan exit/ fan diameter
                        Plug_diameter              - Diameter of the engine external plug [m]
                        Engine_height              - Engine centerline height above the ground plane
                        distance_microphone        - Distance from the nozzle exhaust to the microphones
                        angles                     - Array containing the desired polar angles


                    airport   - SUAVE type airport data, with followig fields:
                        atmosphere                  - Airport atmosphere (SUAVE type)
                        altitude                    - Airport altitude
                        delta_isa                   - ISA Temperature deviation


                Outputs: One Third Octave Band SPL [dB]
                    SPL_p                           - Sound Pressure Level of the primary jet
                    SPL_s                           - Sound Pressure Level of the secondary jet
                    SPL_m                           - Sound Pressure Level of the mixed jet
                    SPL_total                       - Sound Pressure Level of the total jet noise

                Assumptions:
                    ."""


    #unpack
    
    Velocity_primary_1      =       np.float(turbofan.core_nozzle.noise_speed * 0.92*(turbofan.design_thrust/52700.))   
    Temperature_primary     =       noise_segment.conditions.propulsion.acoustic_outputs.core.exit_stagnation_temperature[:,0] 
    Pressure_primary        =       noise_segment.conditions.propulsion.acoustic_outputs.core.exit_stagnation_pressure[:,0] 
    
    Velocity_secondary_1    =       np.float(turbofan.fan_nozzle.noise_speed * (turbofan.design_thrust/52700.)) 
    Temperature_secondary   =       noise_segment.conditions.propulsion.acoustic_outputs.fan.exit_stagnation_temperature[:,0] 
    Pressure_secondary      =       noise_segment.conditions.propulsion.acoustic_outputs.fan.exit_stagnation_pressure[:,0] 
    
    N1                      =       np.float(turbofan.fan.rotation * 0.92*(turbofan.design_thrust/52700.))
    Diameter_primary        =       turbofan.core_nozzle_diameter
    Diameter_secondary      =       turbofan.fan_nozzle_diameter
    engine_height           =       turbofan.engine_height
    EXA                     =       turbofan.exa
    Plug_diameter           =       turbofan.plug_diameter 
    Xe                      =       turbofan.geometry_xe
    Ye                      =       turbofan.geometry_ye
    Ce                      =       turbofan.geometry_Ce
    
    Velocity_aircraft       =       np.float(noise_segment.conditions.freestream.velocity[0,0]) 
    Altitude                =       noise_segment.conditions.freestream.altitude[:,0] 
    AOA                     =       np.mean(noise_segment.conditions.aerodynamics.angle_of_attack / Units.deg)
    
    time                    =       noise_segment.conditions.frames.inertial.time[:,0]  
    
    noise_time = np.arange(0.,time[-1],.5)
    
    Temperature_primary   = np.interp(noise_time,time,Temperature_primary)
    Pressure_primary      = np.interp(noise_time,time,Pressure_primary)
    Temperature_secondary = np.interp(noise_time,time,Temperature_secondary)
    Pressure_secondary    = np.interp(noise_time,time,Pressure_secondary)
    Altitude              = np.interp(noise_time,time,Altitude)
    
    # Calls the function noise_geometric to calculate all the distance and emission angles
    geometric = noise_geometric(noise_segment,analyses,config)
    
    #unpack
    angles              = geometric[:][1]
    distance_microphone = geometric[:][0]    
    phi                 = geometric[:][2]    
    
    distance_microphone = np.interp(noise_time,time,distance_microphone)
    angles = np.interp(noise_time,time,angles)
    phi   = np.interp(noise_time,time,phi)    
    
    nsteps = len(noise_time)        
    
    #Preparing matrix for noise calculation
    sound_ambient       = np.zeros(nsteps)
    density_ambient     = np.zeros(nsteps)
    viscosity           = np.zeros(nsteps)
    temperature_ambient = np.zeros(nsteps)
    pressure_amb        = np.zeros(nsteps)
    Mach_aircraft       = np.zeros(nsteps)
    
    Velocity_primary = np.ones(nsteps)*Velocity_primary_1
    Velocity_secondary = np.ones(nsteps)*Velocity_secondary_1

    # ==============================================
    # Computing atmospheric conditions
    # ==============================================
    
    for id in range (0,nsteps):
        atmo_data = analyses.atmosphere.compute_values(Altitude[id])        
    
        sound_ambient[id]       =   np.float(atmo_data.speed_of_sound)
        density_ambient[id]     =   np.float(atmo_data.density)
        viscosity[id]           =   np.float(atmo_data.dynamic_viscosity)
        temperature_ambient[id] =   np.float(atmo_data.temperature)
        pressure_amb[id]        =   np.float(atmo_data.pressure)
    
    #Base parameters necessary input for the noise code
    pressure_isa = 101325 #[Pa]
    R_gas        = 287.1  #[J/kg K]
    gama_primary = 1.37   #Corretion for the primary jet
    gama         = 1.4

    #Calculation of nozzle areas
    Area_primary   = np.pi*(Diameter_primary/2)**2 
    Area_secondary =  np.pi*(Diameter_secondary/2)**2 

    Xo=0 #Acoustic center of reference [m] - Used for wind tunnel acoustic data

    #Flags for definition of near-fiel or wind-tunnel data
    near_field = 0
    tunnel     = 0

    """Starting the main program"""

    #Arrays for the calculation of atmospheric attenuation
    Acq = np.array((0, 0, 0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9, 1.2, 1.5, 1.9, 2.5, 2.9, 3.6, 4.9, 6.8))
    Acf = np.array((0, 0, 0, 0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.3, 1.8, 2.5, 3.0, 4.2, 6.1, 9.0))

    #Desired frequency range for noise evaluation
    frequency = np.array((50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, \
            2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000))


#Defining each array before the main loop
    B       = np.zeros(24)
    theta_p = np.ones(24)*np.pi/2
    theta_s = np.ones(24)*np.pi/2
    theta_m = np.ones(24)*np.pi/2
    EX_p    = np.zeros(24)
    EX_s    = np.zeros(24)
    EX_m    = np.zeros(24)
    exc     = np.zeros(24)
    SPL_p   = np.zeros(24)
    SPL_s   = np.zeros(24)
    SPL_m   = np.zeros(24)
    PG_p    = np.zeros(24)
    PG_s    = np.zeros(24)
    PG_m    = np.zeros(24)
    
    dspl_attenuation_p = np.zeros(24)
    dspl_attenuation_s = np.zeros(24)
    dspl_attenuation_m = np.zeros(24)
    
    SPL_total_history     = np.zeros((nsteps,24))
    SPL_primary_history   = np.zeros((nsteps,24))
    SPL_secondary_history = np.zeros((nsteps,24))
    SPL_mixed_history     = np.zeros((nsteps,24))

    # Open output file to print the results
    if ioprint:
        if not filename:
            filename = ('SAE_Noise_' + str(config.tag) + '.dat')
            
        fid      = open(filename,'w')
    
 #START LOOP FOR EACH POSITION OF AIRCRAFT   
    for id in range(0,nsteps):

        # Jet Flow Parameters
    
        #Primary and Secondary jets
        Cpp = R_gas/(1-1/gama_primary)
        Cp  = R_gas/(1-1/gama)
        
        density_primary   = Pressure_primary[id]/(R_gas*Temperature_primary[id]-(0.5*R_gas*Velocity_primary[id]**2/Cpp))
        density_secondary = Pressure_secondary[id]/(R_gas*Temperature_secondary[id]-(0.5*R_gas*Velocity_secondary[id]**2/Cp))
    
        mass_flow_primary   = Area_primary*Velocity_primary[id]*density_primary
        mass_flow_secondary = Area_secondary*Velocity_secondary[id]*density_secondary
    
        #Mach number of the external flow - based on the aircraft velocity
        Mach_aircraft[id] = Velocity_aircraft/sound_ambient[id]
    
        #Calculation Procedure for the Mixed Jet Flow Parameters
        Velocity_mixed = (mass_flow_primary*Velocity_primary[id]+mass_flow_secondary*Velocity_secondary[id])/ \
                (mass_flow_primary+mass_flow_secondary)
        Temperature_mixed =(mass_flow_primary*Temperature_primary[id]+mass_flow_secondary*Temperature_secondary[id])/ \
                (mass_flow_primary+mass_flow_secondary)
        density_mixed = pressure_amb[id]/(R_gas*Temperature_mixed-(0.5*R_gas*Velocity_mixed**2/Cp))
        Area_mixed = Area_primary*density_primary*Velocity_primary[id]*(1+(mass_flow_secondary/mass_flow_primary))/ \
                (density_mixed*Velocity_mixed)
        Diameter_mixed = (4*Area_mixed/np.pi)**0.5
    
        #**********************************************
        # START OF THE NOISE PROCEDURE CALCULATIONS
        #**********************************************
    
        XBPR = mass_flow_secondary/mass_flow_primary - 5.5
        if XBPR<0:
                XBPR=0
        elif XBPR>4:
                XBPR=4
    
        #Auxiliary parameter defined as DVPS
        DVPS = np.abs((Velocity_primary[id] - (Velocity_secondary[id]*Area_secondary+Velocity_aircraft*Area_primary)/(Area_secondary+Area_primary)))
        if DVPS<0.3:
            DVPS=0.3
    
        # Calculation of the Strouhal number for each jet component (p-primary, s-secondary, m-mixed)
        Str_p = frequency*Diameter_primary/(DVPS)  #Primary jet
        Str_s = frequency*Diameter_mixed/(Velocity_secondary[id]-Velocity_aircraft) #Secondary jet
        Str_m = frequency*Diameter_mixed/(Velocity_mixed-Velocity_aircraft) #Mixed jet
    
        #Calculation of the Excitation adjustment parameter
        #Excitation Strouhal Number
        excitation_Strouhal = (N1/60)*(Diameter_mixed/Velocity_mixed)
        if (excitation_Strouhal > 0.25 and excitation_Strouhal < 0.5):
            SX = 0.0
        else:
            SX = 50*(excitation_Strouhal-0.25)*(excitation_Strouhal-0.5)
    
        #Effectiveness
        exps = np.exp(-SX)
    
        #Spectral Shape Factor
        exs = 5*exps*np.exp(-(np.log10(Str_m/(2*excitation_Strouhal+0.00001)))**2)
    
        #Fan Duct Lenght Factor
        exd = np.exp(0.6-(EXA)**0.5)
    
        #Excitation source location factor (zk)
        zk = 1-0.4*(exd)*(exps)    

        #Main loop for the desired polar angles

        theta = angles[id]
    
      #Call function noise source location for the calculation of theta
        thetaj = noise_source_location(B,Xo,zk,Diameter_primary,theta_p,Area_primary,Area_secondary,distance_microphone[id],Diameter_secondary,theta,theta_s,theta_m,Diameter_mixed,Velocity_primary[id],Velocity_secondary[id],Velocity_mixed,Velocity_aircraft,sound_ambient[id],Str_m,Str_s)
    
      # Loop for the frequency array range
        for i in range(0,24):
               #Calculation of the Directivity Factor
                if (theta_m[i] <=1.4):
                    exc[i] = sound_ambient[id]/Velocity_mixed
                elif (theta_m[i]>1.4):
                    exc[i] =(sound_ambient[id]/Velocity_mixed)*(1-(1.8/np.pi)*(theta_m[i]-1.4))
    
                #Acoustic excitation adjustment (EX)
                EX_m[i] = exd*exs[i]*exc[i]   #mixed component - dependant of the frequency
        
        EX_p = +5*exd*exps   #primary component - no frequency dependance
        EX_s = 2*sound_ambient[id]/(Velocity_secondary[id]*(zk)) #secondary component - no frequency dependance    
    
        distance_primary   = distance_microphone[id] 
        distance_secondary = distance_microphone[id] 
        distance_mixed     = distance_microphone[id]
    
        #Noise attenuation due to Ambient Pressure
        dspl_ambient_pressure = 20*np.log10(pressure_amb[id]/pressure_isa)
    
        #Noise attenuation due to Density Gradientes
        dspl_density_p = 20*np.log10((density_primary+density_secondary)/(2*density_ambient[id]))
        dspl_density_s = 20*np.log10((density_secondary+density_ambient[id])/(2*density_ambient[id]))
        dspl_density_m = 20*np.log10((density_mixed+density_ambient[id])/(2*density_ambient[id]))
    
        #Noise attenuation due to Spherical divergence
        dspl_spherical_p = 20*np.log10(Diameter_primary/distance_primary)
        dspl_spherical_s = 20*np.log10(Diameter_mixed/distance_secondary)
        dspl_spherical_m = 20*np.log10(Diameter_mixed/distance_mixed)
    
       #Noise attenuation due to Geometric Near-Field
        if near_field ==0:
                dspl_geometric_p = 0.0
                dspl_geometric_s = 0.0
                dspl_geometric_m = 0.0
        elif near_field ==1:
                dspl_geometric_p = -10*np.log10(1+(2*Diameter_primary+(Diameter_primary*sound_ambient[id]/frequency))/distance_primary)
                dspl_geometric_s = -10*np.log10(1+(2*Diameter_mixed+(Diameter_mixed*sound_ambient[id]/frequency))/distance_secondary)
                dspl_geometric_m = -10*np.log10(1+(2*Diameter_mixed+(Diameter_mixed*sound_ambient[id]/frequency))/distance_mixed)
    
       #Noise attenuation due to Acoustic Near-Field
        if near_field ==0:
                dspl_acoustic_p = 0.0;
                dspl_acoustic_s = 0.0;
                dspl_acoustic_m = 0.0;
        elif near_field ==1:
                dspl_acoustic_p = 10*np.log10(1+0.13*(sound_ambient[id]/(distance_primary*frequency))**2)
                dspl_acoustic_s = 10*np.log10(1+0.13*(sound_ambient[id]/(distance_secondary*frequency))**2)
                dspl_acoustic_m = 10*np.log10(1+0.13*(sound_ambient[id]/(distance_mixed*frequency))**2)
    
        #Atmospheric attenuation coefficient
        if tunnel==0:
                f_primary   = frequency/(1-Mach_aircraft[id]*np.cos(theta_p))
                f_secondary = frequency/(1-Mach_aircraft[id]*np.cos(theta_s))
                f_mixed     = frequency/(1-Mach_aircraft[id]*np.cos(theta_m))
                Aci         = Acf + ((temperature_ambient[id]-0)-15)/10*(Acq-Acf)    
                
                Ac_primary   = np.interp(f_primary,frequency,Aci)
                Ac_secondary = np.interp(f_secondary,frequency,Aci)
                Ac_mixed     = np.interp(f_mixed,frequency,Aci)
                
                 #Atmospheric attenuation
                delta_atmo = atmospheric_attenuation(distance_primary)
                
                dspl_attenuation_p = -delta_atmo 
                dspl_attenuation_s = -delta_atmo 
                dspl_attenuation_m = -delta_atmo 
    
        elif tunnel==1: #These corrections are not applicable for jet rigs or static conditions
                dspl_attenuation_p = np.zeros(24)
                dspl_attenuation_s = np.zeros(24)
                dspl_attenuation_m = np.zeros(24)
                EX_m = np.zeros(24)
                EX_p = 0
                EX_s = 0
    
       #Calculation of the total noise attenuation (p-primary, s-secondary, m-mixed components)
        DSPL_p = dspl_ambient_pressure+dspl_density_p+dspl_geometric_p+dspl_acoustic_p+dspl_attenuation_p+dspl_spherical_p
        DSPL_s = dspl_ambient_pressure+dspl_density_s+dspl_geometric_s+dspl_acoustic_s+dspl_attenuation_s+dspl_spherical_s
        DSPL_m = dspl_ambient_pressure+dspl_density_m+dspl_geometric_m+dspl_acoustic_m+dspl_attenuation_m+dspl_spherical_m
    
    
      #Calculation of interference effects on jet noise
        ATK_m   = angle_of_attack_effect(AOA,Mach_aircraft[id],theta_m)
        INST_s  = jet_installation_effect(Xe,Ye,Ce,theta_s,Diameter_mixed)
        Plug    = external_plug_effect(Velocity_primary[id],Velocity_secondary[id], Velocity_mixed, Diameter_primary,Diameter_secondary,Diameter_mixed, Plug_diameter, sound_ambient[id], theta_p,theta_s,theta_m)
        GPROX_m = ground_proximity_effect(Velocity_mixed,sound_ambient[id],theta_m,engine_height,Diameter_mixed,frequency)
    
      #Calculation of the sound pressure level for each jet component
        SPL_p = primary_noise_component(SPL_p,Velocity_primary[id],Temperature_primary[id],R_gas,theta_p,DVPS,sound_ambient[id],Velocity_secondary[id],Velocity_aircraft,Area_primary,Area_secondary,DSPL_p,EX_p,Str_p) + Plug[0]
        
        SPL_s = secondary_noise_component(SPL_s,Velocity_primary[id],theta_s,sound_ambient[id],Velocity_secondary[id],Velocity_aircraft,Area_primary,Area_secondary,DSPL_s,EX_s,Str_s) + Plug[1] + INST_s
        
        SPL_m = mixed_noise_component(SPL_m,Velocity_primary[id],theta_m,sound_ambient[id],Velocity_secondary[id],Velocity_aircraft,Area_primary,Area_secondary,DSPL_m,EX_m,Str_m,Velocity_mixed,XBPR) + Plug[2] + ATK_m + GPROX_m
    
     #Sum of the Total Noise
        SPL_total = 10 * np.log10(10**(0.1*SPL_p)+10**(0.1*SPL_s)+10**(0.1*SPL_m))
        
     #Store the SPL history     
        SPL_total_history[id][:]     = SPL_total[:]
        SPL_primary_history[id][:]   = SPL_p[:]
        SPL_secondary_history[id][:] = SPL_s[:]
        SPL_mixed_history[id][:]     = SPL_m[:]
     
    #Calculation of the Perceived Noise Level EPNL based on the sound time history
    PNL_total               =  pnl_noise(SPL_total_history)    
    PNL_primary             =  pnl_noise(SPL_primary_history)  
    PNL_secondary           =  pnl_noise(SPL_secondary_history)  
    PNL_mixed               =  pnl_noise(SPL_mixed_history)  
    
   #Calculation of the tones corrections on the SPL for each component and total
    tone_correction_total     = noise_tone_correction(SPL_total_history) 
    tone_correction_primary   = noise_tone_correction(SPL_primary_history) 
    tone_correction_secondary = noise_tone_correction(SPL_secondary_history) 
    tone_correction_mixed     = noise_tone_correction(SPL_mixed_history) 
    
    #Calculation of the PLNT for each component and total
    PNLT_total     = PNL_total+tone_correction_total
    PNLT_primary   = PNL_primary+tone_correction_primary
    PNLT_secondary = PNL_secondary+tone_correction_secondary
    PNLT_mixed     = PNL_mixed+tone_correction_mixed
    
    #Calculation of the EPNL for each component and total
    EPNL_total     = epnl_noise(PNLT_total)
    EPNL_primary   = epnl_noise(PNLT_primary)
    EPNL_secondary = epnl_noise(PNLT_secondary)
    EPNL_mixed     = epnl_noise(PNLT_mixed)
    
    if ioprint:
       # print EPNL_total
        
         #Printing the output solution for the engine noise calculation
         
        fid.write('Engine noise module - SAE Model for Turbofan' + '\n')
        fid.write('Certification point = FLYOVER' + '\n')
        fid.write('EPNL = ' + str('%3.2f' % EPNL_total) + '\n')
        fid.write('PNLTM = ' + str('%3.2f' % np.max(PNLT_total)) + '\n')
        
        
        fid.write('Reference speed =  ')
        fid.write(str('%2.2f' % (Velocity_aircraft/Units.kts))+'  kts')
        fid.write('\n')
        fid.write('PNLT history')
        fid.write('\n')
        fid.write('time     	altitude     Mach     Core Velocity   Fan Velocity  Polar angle    Azim angle    distance    Primary	  Secondary 	 Mixed        Total')
        fid.write('\n')
        for id in range (0,nsteps):
            fid.write(str('%2.2f' % time[id])+'        ')
            fid.write(str('%2.2f' % Altitude[id])+'        ')
            fid.write(str('%2.2f' % Mach_aircraft[id])+'        ')
            fid.write(str('%3.3f' % Velocity_primary[id])+'        ')
            fid.write(str('%3.3f' % Velocity_secondary[id])+'        ')
            fid.write(str('%2.2f' % (angles[id]*180/np.pi))+'        ')
            fid.write(str('%2.2f' % (phi[id]*180/np.pi))+'        ')
            fid.write(str('%2.2f' % distance_microphone[id])+'        ')
            fid.write(str('%2.2f' % PNLT_primary[id])+'        ')
            fid.write(str('%2.2f' % PNLT_secondary[id])+'        ')
            fid.write(str('%2.2f' % PNLT_mixed[id])+'        ')
            fid.write(str('%2.2f' % PNLT_total[id])+'        ')
            fid.write('\n')
        fid.write('\n')
        fid.write('PNLT max =  ')
        fid.write(str('%2.2f' % (np.max(PNLT_total)))+'  dB')
        fid.write('\n')
        fid.write('EPNdB')
        fid.write('\n')
        fid.write('f	Primary    Secondary  	 Mixed       Total')
        fid.write('\n')
        fid.write(str('%2.2f' % EPNL_primary)+'        ')
        fid.write(str('%2.2f' % EPNL_secondary)+'        ')
        fid.write(str('%2.2f' % EPNL_mixed)+'        ')
        fid.write(str('%2.2f' % EPNL_total)+'        ')
        fid.write('\n')
        
        for id in range (0,nsteps):
            fid.write('\n')
            fid.write('Emission angle = ' + str(angles[id]*180/np.pi) + '\n')
            fid.write('Altitude = ' + str(Altitude[id]) + '\n')
            fid.write('Distance = ' + str(distance_microphone[id]) + '\n')
            fid.write('Time = ' + str(time[id]) + '\n')
            fid.write('f		Primary  Secondary  	Mixed  		Total' + '\n')
         
       
            for ijd in range(0,24):
                    fid.write(str((frequency[ijd])) + '       ')
                    fid.write(str('%3.2f' % SPL_primary_history[id][ijd]) + '       ')
                    fid.write(str('%3.2f' % SPL_secondary_history[id][ijd]) + '       ')
                    fid.write(str('%3.2f' % SPL_mixed_history[id][ijd]) + '       ')
                    fid.write(str('%3.2f' % SPL_total_history[id][ijd]) + '       ')
                    fid.write('\n')
              
        fid.close
    
    return(EPNL_total,SPL_total_history)
예제 #8
0
def noise_airframe_Fink(config, analyses, noise_segment,ioprint = 0, filename=0): 

    """ SUAVE.Methods.Noise.Fidelity_One.noise_fidelity_one(config, analyses, noise_segment):
            Computes the noise from different sources of the airframe for a given vehicle for a constant altitude flight.

            Inputs:
                vehicle	 - SUAVE type vehicle

                includes these fields:
                    S                          - Wing Area
                    bw                         - Wing Span
                    Sht                        - Horizontal tail area
                    bht                        - Horizontal tail span
                    Svt                        - Vertical tail area
                    bvt                        - Vertical tail span
                    deltaf                     - Flap deflection
                    Sf                         - Flap area
                    cf                         - Flap chord
                    slots                      - Number of slots (Flap type)
                    Dp                         - Main landing gear tyre diameter
                    Hp                         - Main lading gear strut length
                    Dn                         - Nose landing gear tyre diameter
                    Hn                         - Nose landing gear strut length
                    wheels                     - Number of wheels

                airport   - SUAVE type airport data, with followig fields:
                    atmosphere                  - Airport atmosphere (SUAVE type)
                    altitude                    - Airport altitude
                    delta_isa                   - ISA Temperature deviation


            Outputs: One Third Octave Band SPL [dB]
                SPL_wing                         - Sound Pressure Level of the clean wing
                SPLht                            - Sound Pressure Level of the horizontal tail
                SPLvt                            - Sound Pressure Level of the vertical tail
                SPL_flap                         - Sound Pressure Level of the flaps trailing edge
                SPL_slat                         - Sound Pressure Level of the slat leading edge
                SPL_main_landing_gear            - Sound Pressure Level og the main landing gear
                SPL_nose_landing_gear            - Sound Pressure Level of the nose landing gear

            Assumptions:
                Correlation based."""


    # ==============================================
        # Unpack
    # ==============================================
    wing = config.wings

    Sw      =       wing.main_wing.areas.reference  / (Units.ft)**2              #wing area, sq.ft
    bw      =       wing.main_wing.spans.projected / Units.ft                    #wing span, ft
    Sht     =       wing.horizontal_stabilizer.areas.reference / (Units.ft)**2   #horizontal tail area, sq.ft
    bht     =       wing.horizontal_stabilizer.spans.projected / Units.ft        #horizontal tail span, ft
    Svt     =       wing.vertical_stabilizer.areas.reference / (Units.ft)**2     #vertical tail area, sq.ft
    bvt     =       wing.vertical_stabilizer.spans.projected  / Units.ft         #vertical tail span, ft
    deltaf  =       wing.main_wing.flaps.angle                                   #flap delection, rad
    Sf      =       wing.main_wing.flaps.area  / (Units.ft)**2                   #flap area, sq.ft        
    cf      =       wing.main_wing.flaps.chord_dimensional  / Units.ft           #flap chord, ft
    Dp      =       config.landing_gear.main_tire_diameter  / Units.ft           #MLG tyre diameter, ft
    Hp      =       config.landing_gear.nose_tire_diameter  / Units.ft           #MLG strut length, ft
    Dn      =       config.landing_gear.main_strut_length   / Units.ft           #NLG tyre diameter, ft
    Hn      =       config.landing_gear.nose_strut_length   / Units.ft           #NLG strut length, ft
    gear    =       config.landing_gear.gear_condition                           #Gear up or gear down
    
    nose_wheels    =   config.landing_gear.nose_wheels                           #Number of wheels   
    main_wheels    =   config.landing_gear.main_wheels                           #Number of wheels   
    main_units     =   config.landing_gear.main_units                            #Number of main units   
    velocity       =   np.float(noise_segment.conditions.freestream.velocity[0,0]) 
    altitude       =   noise_segment.conditions.freestream.altitude[:,0] 
    time           =   noise_segment.conditions.frames.inertial.time[:,0]    

    noise_time = np.arange(0.,time[-1],.5)  
    altitude = np.interp(noise_time,time,altitude)

    # determining flap slot number
    if wing.main_wing.flaps.type   == 'single_sloted':
        slots = 1
    elif wing.main_wing.flaps.type == 'double_sloted':
        slots = 2
    elif wing.main_wing.flaps.type == 'triple_sloted':
        slots = 3
    
    # Calls the function noise_geometric to calculate all the distance and emission angles
    geometric = noise_geometric(noise_segment,analyses,config)
    
    distance_vector = geometric[:][0]    
    angle = geometric[:][1]
    phi   = geometric[:][2]
    
    distance_vector = np.interp(noise_time,time,distance_vector)
    angle = np.interp(noise_time,time,angle)
    phi   = np.interp(noise_time,time,phi)
        
    # Number of points on the discretize segment   
    nsteps=len(noise_time)
    
    # Preparing matrix for noise calculation
    sound_speed = np.zeros(nsteps)
    density     = np.zeros(nsteps)
    viscosity   = np.zeros(nsteps)
    temperature = np.zeros(nsteps)
    M           = np.zeros(nsteps)
    deltaw      = np.zeros(nsteps)
    
    # ==============================================
    #         Computing atmospheric conditions
    # ==============================================
    
    for id in range (0,nsteps):
        atmo_data = analyses.atmosphere.compute_values(altitude[id])
        
        #unpack    
        sound_speed[id] =    np.float(atmo_data.speed_of_sound)
        density[id]     =    np.float(atmo_data.density)
        viscosity[id]   =    np.float(atmo_data.dynamic_viscosity*10.7639) #units converstion - m2 to ft2
        temperature[id] =    np.float(atmo_data.temperature)
        
        #Mach number
        M[id] = velocity/np.sqrt(1.4*287*temperature[id])
    
        #Wing Turbulent Boundary Layer thickness, ft
        deltaw[id] = 0.37*(Sw/bw)*((velocity/Units.ft)*Sw/(bw*viscosity[id]))**(-0.2)
    

    #Units conversion - knots to ft/s
    kt2fts = 1.6878098571 

    #Generate array with the One Third Octave Band Center Frequencies
    frequency = np.array((50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, \
            2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000))


    # Velocity in fts
    velocity_fst = velocity * Units.knot
    
    #number of positions of the aircraft to calculate the noise
    nrange = len(angle) 
    i=0
    SPL_wing_history = np.zeros((nrange,24))
    SPLht_history    = np.zeros((nrange,24))
    SPLvt_history    = np.zeros((nrange,24))
    SPL_flap_history = np.zeros((nrange,24))
    SPL_slat_history = np.zeros((nrange,24))
    SPL_main_landing_gear_history = np.zeros((nrange,24))
    SPL_nose_landing_gear_history = np.zeros((nrange,24))
    SPL_total_history = np.zeros((nrange,24))
    
    #Noise history in dBA
    SPLt_dBA_history = np.zeros((nrange,24))    
    
    #START LOOP FOR EACH POSITION OF AIRCRAFT   
    for i in range(0,nrange-1):
        #Emission angle theta   
        theta = angle[i] 
        #Distance from airplane to observer, evaluated at retarded time
        distance = distance_vector[i]    
       
         #Atmospheric attenuation
        delta_atmo=atmospheric_attenuation(distance)

        #Call each noise source model
        SPL_wing = noise_clean_wing(Sw,bw,0,1,deltaw[i],velocity,viscosity[i],M[i],phi[i],theta,distance,frequency) - delta_atmo    #Wing Noise
        SPLht    = noise_clean_wing(Sht,bht,0,1,deltaw[i],velocity,viscosity[i],M[i],phi[i],theta,distance,frequency)  -delta_atmo    #Horizontal Tail Noise
        SPLvt    = noise_clean_wing(Svt,bvt,0,0,deltaw[i],velocity,viscosity[i],M[i],phi[i],theta,distance,frequency)  -delta_atmo    #Vertical Tail Noise
 
        SPL_slat = noise_leading_edge_slat(SPL_wing,Sw,bw,velocity,deltaw[i],viscosity[i],M[i],phi[i],theta,distance,frequency) -delta_atmo        #Slat leading edge
 
        if (deltaf==0):
            SPL_flap = np.zeros(24)
        else:
            SPL_flap = noise_trailing_edge_flap(Sf,cf,deltaf,slots,velocity,M[i],phi[i],theta,distance,frequency) - delta_atmo #Trailing Edge Flaps Noise
 
        if gear=='up': #0
            SPL_main_landing_gear = np.zeros(24)
            SPL_nose_landing_gear = np.zeros(24)
        else:
            SPL_main_landing_gear = noise_landing_gear(Dp,Hp,main_wheels,M[i],velocity,phi[i],theta,distance,frequency)  - delta_atmo     #Main Landing Gear Noise
            SPL_nose_landing_gear = noise_landing_gear(Dn,Hn,nose_wheels,M[i],velocity,phi[i],theta,distance,frequency)  - delta_atmo     #Nose Landing Gear Noise
        if main_units>1: #Incoherent summation of each main landing gear unit
            SPL_main_landing_gear = SPL_main_landing_gear+3*(main_units-1)
 
 
         #Total Airframe Noise
        SPL_total = 10.*np.log10(10.0**(0.1*SPL_wing)+10.0**(0.1*SPLht)+10**(0.1*SPL_flap)+ \
             10.0**(0.1*SPL_slat)+10.0**(0.1*SPL_main_landing_gear)+10.0**(0.1*SPL_nose_landing_gear)) - delta_atmo
             
        #Included 02nd September 2015
        SPLt_dBA = dbA_noise(SPL_total)       
        SPLt_dBA_history[i][:] = SPLt_dBA[:]
            
        SPL_total_history[i][:] = SPL_total[:]
        SPL_wing_history[i][:]  = SPL_wing[:]
        SPLvt_history[i][:]     = SPLvt[:]
        SPLht_history[i][:]     = SPLht[:]
        SPL_flap_history[i][:]  = SPL_flap[:]
        SPL_slat_history[i][:]  = SPL_slat[:]
        SPL_nose_landing_gear_history[i][:] = SPL_nose_landing_gear[:]
        SPL_main_landing_gear_history[i][:] = SPL_main_landing_gear[:]
       
       
   #Calculation of dBA based on the sound pressure time history
   # dbA_total                =       dbA_noise(SPL_total_history)    #(Not used to certification point)
          
   #Calculation of the Perceived Noise Level EPNL based on the sound time history
    PNL_total               =       pnl_noise(SPL_total_history)
    PNL_wing                =       pnl_noise(SPL_wing_history)
    PNL_ht                  =       pnl_noise(SPLht_history)
    PNL_vt                  =       pnl_noise(SPLvt_history)
    PNL_nose_landing_gear   =       pnl_noise(SPL_nose_landing_gear_history)
    PNL_main_landing_gear   =       pnl_noise(SPL_main_landing_gear_history)
    PNL_slat                =       pnl_noise(SPL_slat_history)
    PNL_flap                =       pnl_noise(SPL_flap_history)
    
    
   #Calculation of the tones corrections on the SPL for each component and total
    tone_correction_total = noise_tone_correction(SPL_total_history) 
    tone_correction_wing  = noise_tone_correction(SPL_wing_history)
    tone_correction_ht    = noise_tone_correction(SPLht_history)
    tone_correction_vt    = noise_tone_correction(SPLvt_history)
    tone_correction_flap  = noise_tone_correction(SPL_flap_history)
    tone_correction_slat  = noise_tone_correction(SPL_slat_history)
    tone_correction_nose_landing_gear = noise_tone_correction(SPL_nose_landing_gear_history)
    tone_correction_main_landing_gear = noise_tone_correction(SPL_main_landing_gear_history)
    
    #Calculation of the PLNT for each component and total
    PNLT_total = PNL_total+tone_correction_total
    PNLT_wing  = PNL_wing+tone_correction_wing
    PNLT_ht    = PNL_ht+tone_correction_ht
    PNLT_vt    = PNL_vt+tone_correction_vt
    PNLT_nose_landing_gear = PNL_nose_landing_gear+tone_correction_nose_landing_gear
    PNLT_main_landing_gear = PNL_main_landing_gear+tone_correction_main_landing_gear
    PNLT_slat = PNL_slat+tone_correction_slat
    PNLT_flap = PNL_flap+tone_correction_flap
    
    #Calculation of the EPNL for each component and total
    EPNL_total = epnl_noise(PNLT_total)
    EPNL_wing  = epnl_noise(PNLT_wing)
    EPNL_ht    = epnl_noise(PNLT_ht)
    EPNL_vt    = epnl_noise(PNLT_vt)    
    EPNL_nose_landing_gear = epnl_noise(PNLT_nose_landing_gear)
    EPNL_main_landing_gear = epnl_noise(PNLT_main_landing_gear)
    EPNL_slat = epnl_noise(PNLT_slat)
    EPNL_flap = epnl_noise(PNLT_flap)
    
    
    if ioprint:
        # write header of file
        if not filename:            
            filename = ('Noise_' + str(config.tag) + '.dat')
            
        fid = open(filename,'w')   # Open output file    
        
        fid.write('Reference speed =  ')
        fid.write(str('%2.2f' % (velocity/Units.kts))+'  kts')
        fid.write('\n')
        fid.write('PNLT history')
        fid.write('\n')
        fid.write('time       altitude      Mach    Polar angle    Azim angle   distance       wing  	 ht 	     vt 	flap   	    slat   	nose        main       total')
        fid.write('\n')
        
        for id in range (0,nsteps):
            fid.write(str('%2.2f' % time[id])+'        ')
            fid.write(str('%2.2f' % altitude[id])+'        ')
            fid.write(str('%2.2f' % M[id])+'        ')
            fid.write(str('%2.2f' % (angle[id]*180/np.pi))+'        ')
            fid.write(str('%2.2f' % (phi[id]*180/np.pi))+'        ')
            fid.write(str('%2.2f' % distance_vector[id])+'        ')
            fid.write(str('%2.2f' % PNLT_wing[id])+'        ')
            fid.write(str('%2.2f' % PNLT_ht[id])+'        ')
            fid.write(str('%2.2f' % PNLT_vt[id])+'        ')
            fid.write(str('%2.2f' % PNLT_flap[id])+'        ')
            fid.write(str('%2.2f' % PNLT_slat[id])+'        ')
            fid.write(str('%2.2f' % PNLT_nose_landing_gear[id])+'        ')
            fid.write(str('%2.2f' % PNLT_main_landing_gear[id])+'        ')
            fid.write(str('%2.2f' % PNLT_total[id])+'        ')
            fid.write('\n')
        fid.write('\n')
        fid.write('PNLT max =  ')
        fid.write(str('%2.2f' % (np.max(PNLT_total)))+'  dB')
        fid.write('\n')
        fid.write('\n')
        fid.write('EPNdB')
        fid.write('\n')
        fid.write('wing	       ht          vt         flap         slat    	nose        main	total')
        fid.write('\n')
        fid.write(str('%2.2f' % EPNL_wing)+'        ')
        fid.write(str('%2.2f' % EPNL_ht)+'        ')
        fid.write(str('%2.2f' % EPNL_vt)+'        ')
        fid.write(str('%2.2f' % EPNL_flap)+'        ')
        fid.write(str('%2.2f' % EPNL_slat)+'        ')
        fid.write(str('%2.2f' % EPNL_nose_landing_gear)+'        ')
        fid.write(str('%2.2f' % EPNL_main_landing_gear)+'        ')
        fid.write(str('%2.2f' % EPNL_total)+'        ')
        fid.close 
        
        
    
        filename1 = ('History_Noise_' + str(config.tag) + '.dat')
        fid = open(filename1,'w')   # Open output file
        fid.write('Reference speed =  ')
        fid.write(str('%2.2f' % (velocity/Units.kts))+'  kts')
        fid.write('\n')
        fid.write('Sound Pressure Level for the Total Aircraft Noise')
        fid.write('\n')
        
        for nid in range (0,nrange):
            fid.write('Polar angle = ' + str('%2.2f' % (angle[nid]*(180/np.pi))) + '  degrees' + '\n')
            fid.write('f		total SPL(dB)    total SPL(dBA)' + '\n')
            for id in range(0,24):
                fid.write(str((frequency[id])) + '           ')
                fid.write(str('%3.2f' % SPL_total_history[nid][id]) + '          ')
                fid.write(str('%3.2f' % SPLt_dBA_history[nid][id]))
                fid.write('\n')
            fid.write('SPLmax (dB) =  ')
            fid.write(str('%3.2f' % (np.max(SPL_total_history[nid][:])))+'  dB' + '\n')
            fid.write('SPLmax (dBA) =  ')
            fid.write(str('%3.2f' % (np.max(SPLt_dBA_history[nid][:])))+'  dB')
            fid.write('\n')
    
        fid.close
    
    return (EPNL_total,SPL_total_history)
예제 #9
0
def noise_SAE(turbofan,
              noise_segment,
              config,
              analyses,
              ioprint=0,
              filename=0):

    #SAE ARP*876D 1994
    """This method predicts the free-field 1/3 Octave Band SPL of coaxial subsonic
    jets for turbofan engines under the following conditions:
        a) Flyover (observer on ground)
        b) Static (observer on ground)
        c) In-flight or in-flow (observer on airplane or in a wind tunnel)

        Inputs:
                    vehicle	 - SUAVE type vehicle

                    includes these fields:
                        Velocity_primary           - Primary jet flow velocity
                        Temperature_primary        - Primary jet flow temperature
                        Pressure_primary           - Primary jet flow pressure
                        Area_primary               - Area of the primary nozzle
                        Velocity_secondary         - Secondary jet flow velocity
                        Temperature_secondary      - Secondary jet flow temperature
                        Pressure_secondary         - Secondary jet flow pressure
                        Area_secondary             - Area of the secondary nozzle
                        AOA                        - Angle of attack
                        Velocity_aircraft          - Aircraft velocity
                        Altitude                   - Altitude
                        N1                         - Fan rotational speed [rpm]
                        EXA                        - Distance from fan face to fan exit/ fan diameter
                        Plug_diameter              - Diameter of the engine external plug [m]
                        Engine_height              - Engine centerline height above the ground plane
                        distance_microphone        - Distance from the nozzle exhaust to the microphones
                        angles                     - Array containing the desired polar angles


                    airport   - SUAVE type airport data, with followig fields:
                        atmosphere                  - Airport atmosphere (SUAVE type)
                        altitude                    - Airport altitude
                        delta_isa                   - ISA Temperature deviation


                Outputs: One Third Octave Band SPL [dB]
                    SPL_p                           - Sound Pressure Level of the primary jet
                    SPL_s                           - Sound Pressure Level of the secondary jet
                    SPL_m                           - Sound Pressure Level of the mixed jet
                    SPL_total                       - Sound Pressure Level of the total jet noise

                Assumptions:
                    ."""

    #unpack

    Velocity_primary_1 = np.float(turbofan.core_nozzle.noise_speed * 0.92 *
                                  (turbofan.design_thrust / 52700.))
    Temperature_primary = noise_segment.conditions.propulsion.acoustic_outputs.core.exit_stagnation_temperature[:,
                                                                                                                0]
    Pressure_primary = noise_segment.conditions.propulsion.acoustic_outputs.core.exit_stagnation_pressure[:,
                                                                                                          0]

    Velocity_secondary_1 = np.float(turbofan.fan_nozzle.noise_speed *
                                    (turbofan.design_thrust / 52700.))
    Temperature_secondary = noise_segment.conditions.propulsion.acoustic_outputs.fan.exit_stagnation_temperature[:,
                                                                                                                 0]
    Pressure_secondary = noise_segment.conditions.propulsion.acoustic_outputs.fan.exit_stagnation_pressure[:,
                                                                                                           0]

    N1 = np.float(turbofan.fan.rotation * 0.92 *
                  (turbofan.design_thrust / 52700.))
    Diameter_primary = turbofan.core_nozzle_diameter
    Diameter_secondary = turbofan.fan_nozzle_diameter
    engine_height = turbofan.engine_height
    EXA = turbofan.exa
    Plug_diameter = turbofan.plug_diameter
    Xe = turbofan.geometry_xe
    Ye = turbofan.geometry_ye
    Ce = turbofan.geometry_Ce

    Velocity_aircraft = np.float(
        noise_segment.conditions.freestream.velocity[0, 0])
    Altitude = noise_segment.conditions.freestream.altitude[:, 0]
    AOA = np.mean(noise_segment.conditions.aerodynamics.angle_of_attack /
                  Units.deg)

    time = noise_segment.conditions.frames.inertial.time[:, 0]

    noise_time = np.arange(0., time[-1], .5)

    Temperature_primary = np.interp(noise_time, time, Temperature_primary)
    Pressure_primary = np.interp(noise_time, time, Pressure_primary)
    Temperature_secondary = np.interp(noise_time, time, Temperature_secondary)
    Pressure_secondary = np.interp(noise_time, time, Pressure_secondary)
    Altitude = np.interp(noise_time, time, Altitude)

    # Calls the function noise_geometric to calculate all the distance and emission angles
    geometric = noise_geometric(noise_segment, analyses, config)

    #unpack
    angles = geometric[:][1]
    distance_microphone = geometric[:][0]
    phi = geometric[:][2]

    distance_microphone = np.interp(noise_time, time, distance_microphone)
    angles = np.interp(noise_time, time, angles)
    phi = np.interp(noise_time, time, phi)

    nsteps = len(noise_time)

    #Preparing matrix for noise calculation
    sound_ambient = np.zeros(nsteps)
    density_ambient = np.zeros(nsteps)
    viscosity = np.zeros(nsteps)
    temperature_ambient = np.zeros(nsteps)
    pressure_amb = np.zeros(nsteps)
    Mach_aircraft = np.zeros(nsteps)

    Velocity_primary = np.ones(nsteps) * Velocity_primary_1
    Velocity_secondary = np.ones(nsteps) * Velocity_secondary_1

    # ==============================================
    # Computing atmospheric conditions
    # ==============================================

    for id in range(0, nsteps):
        atmo_data = analyses.atmosphere.compute_values(Altitude[id])

        sound_ambient[id] = np.float(atmo_data.speed_of_sound)
        density_ambient[id] = np.float(atmo_data.density)
        viscosity[id] = np.float(atmo_data.dynamic_viscosity)
        temperature_ambient[id] = np.float(atmo_data.temperature)
        pressure_amb[id] = np.float(atmo_data.pressure)

    #Base parameters necessary input for the noise code
    pressure_isa = 101325  #[Pa]
    R_gas = 287.1  #[J/kg K]
    gama_primary = 1.37  #Corretion for the primary jet
    gama = 1.4

    #Calculation of nozzle areas
    Area_primary = np.pi * (Diameter_primary / 2)**2
    Area_secondary = np.pi * (Diameter_secondary / 2)**2

    Xo = 0  #Acoustic center of reference [m] - Used for wind tunnel acoustic data

    #Flags for definition of near-fiel or wind-tunnel data
    near_field = 0
    tunnel = 0
    """Starting the main program"""

    #Arrays for the calculation of atmospheric attenuation
    Acq = np.array((0, 0, 0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.4, 0.5,
                    0.6, 0.7, 0.9, 1.2, 1.5, 1.9, 2.5, 2.9, 3.6, 4.9, 6.8))
    Acf = np.array((0, 0, 0, 0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.4,
                    0.5, 0.6, 0.8, 1.0, 1.3, 1.8, 2.5, 3.0, 4.2, 6.1, 9.0))

    #Desired frequency range for noise evaluation
    frequency = np.array((50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, \
            2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000))

    #Defining each array before the main loop
    B = np.zeros(24)
    theta_p = np.ones(24) * np.pi / 2
    theta_s = np.ones(24) * np.pi / 2
    theta_m = np.ones(24) * np.pi / 2
    EX_p = np.zeros(24)
    EX_s = np.zeros(24)
    EX_m = np.zeros(24)
    exc = np.zeros(24)
    SPL_p = np.zeros(24)
    SPL_s = np.zeros(24)
    SPL_m = np.zeros(24)
    PG_p = np.zeros(24)
    PG_s = np.zeros(24)
    PG_m = np.zeros(24)

    dspl_attenuation_p = np.zeros(24)
    dspl_attenuation_s = np.zeros(24)
    dspl_attenuation_m = np.zeros(24)

    SPL_total_history = np.zeros((nsteps, 24))
    SPL_primary_history = np.zeros((nsteps, 24))
    SPL_secondary_history = np.zeros((nsteps, 24))
    SPL_mixed_history = np.zeros((nsteps, 24))

    # Open output file to print the results
    if ioprint:
        if not filename:
            filename = ('SAE_Noise_' + str(config.tag) + '.dat')

        fid = open(filename, 'w')

#START LOOP FOR EACH POSITION OF AIRCRAFT
    for id in range(0, nsteps):

        # Jet Flow Parameters

        #Primary and Secondary jets
        Cpp = R_gas / (1 - 1 / gama_primary)
        Cp = R_gas / (1 - 1 / gama)

        density_primary = Pressure_primary[id] / (
            R_gas * Temperature_primary[id] -
            (0.5 * R_gas * Velocity_primary[id]**2 / Cpp))
        density_secondary = Pressure_secondary[id] / (
            R_gas * Temperature_secondary[id] -
            (0.5 * R_gas * Velocity_secondary[id]**2 / Cp))

        mass_flow_primary = Area_primary * Velocity_primary[
            id] * density_primary
        mass_flow_secondary = Area_secondary * Velocity_secondary[
            id] * density_secondary

        #Mach number of the external flow - based on the aircraft velocity
        Mach_aircraft[id] = Velocity_aircraft / sound_ambient[id]

        #Calculation Procedure for the Mixed Jet Flow Parameters
        Velocity_mixed = (mass_flow_primary*Velocity_primary[id]+mass_flow_secondary*Velocity_secondary[id])/ \
                (mass_flow_primary+mass_flow_secondary)
        Temperature_mixed =(mass_flow_primary*Temperature_primary[id]+mass_flow_secondary*Temperature_secondary[id])/ \
                (mass_flow_primary+mass_flow_secondary)
        density_mixed = pressure_amb[id] / (
            R_gas * Temperature_mixed - (0.5 * R_gas * Velocity_mixed**2 / Cp))
        Area_mixed = Area_primary*density_primary*Velocity_primary[id]*(1+(mass_flow_secondary/mass_flow_primary))/ \
                (density_mixed*Velocity_mixed)
        Diameter_mixed = (4 * Area_mixed / np.pi)**0.5

        #**********************************************
        # START OF THE NOISE PROCEDURE CALCULATIONS
        #**********************************************

        XBPR = mass_flow_secondary / mass_flow_primary - 5.5
        if XBPR < 0:
            XBPR = 0
        elif XBPR > 4:
            XBPR = 4

        #Auxiliary parameter defined as DVPS
        DVPS = np.abs(
            (Velocity_primary[id] - (Velocity_secondary[id] * Area_secondary +
                                     Velocity_aircraft * Area_primary) /
             (Area_secondary + Area_primary)))
        if DVPS < 0.3:
            DVPS = 0.3

        # Calculation of the Strouhal number for each jet component (p-primary, s-secondary, m-mixed)
        Str_p = frequency * Diameter_primary / (DVPS)  #Primary jet
        Str_s = frequency * Diameter_mixed / (
            Velocity_secondary[id] - Velocity_aircraft)  #Secondary jet
        Str_m = frequency * Diameter_mixed / (
            Velocity_mixed - Velocity_aircraft)  #Mixed jet

        #Calculation of the Excitation adjustment parameter
        #Excitation Strouhal Number
        excitation_Strouhal = (N1 / 60) * (Diameter_mixed / Velocity_mixed)
        if (excitation_Strouhal > 0.25 and excitation_Strouhal < 0.5):
            SX = 0.0
        else:
            SX = 50 * (excitation_Strouhal - 0.25) * (excitation_Strouhal -
                                                      0.5)

        #Effectiveness
        exps = np.exp(-SX)

        #Spectral Shape Factor
        exs = 5 * exps * np.exp(
            -(np.log10(Str_m / (2 * excitation_Strouhal + 0.00001)))**2)

        #Fan Duct Lenght Factor
        exd = np.exp(0.6 - (EXA)**0.5)

        #Excitation source location factor (zk)
        zk = 1 - 0.4 * (exd) * (exps)

        #Main loop for the desired polar angles

        theta = angles[id]

        #Call function noise source location for the calculation of theta
        thetaj = noise_source_location(
            B, Xo, zk, Diameter_primary, theta_p, Area_primary, Area_secondary,
            distance_microphone[id], Diameter_secondary, theta, theta_s,
            theta_m, Diameter_mixed, Velocity_primary[id],
            Velocity_secondary[id], Velocity_mixed, Velocity_aircraft,
            sound_ambient[id], Str_m, Str_s)

        # Loop for the frequency array range
        for i in range(0, 24):
            #Calculation of the Directivity Factor
            if (theta_m[i] <= 1.4):
                exc[i] = sound_ambient[id] / Velocity_mixed
            elif (theta_m[i] > 1.4):
                exc[i] = (sound_ambient[id] /
                          Velocity_mixed) * (1 - (1.8 / np.pi) *
                                             (theta_m[i] - 1.4))

            #Acoustic excitation adjustment (EX)
            EX_m[i] = exd * exs[i] * exc[
                i]  #mixed component - dependant of the frequency

        EX_p = +5 * exd * exps  #primary component - no frequency dependance
        EX_s = 2 * sound_ambient[id] / (
            Velocity_secondary[id] *
            (zk))  #secondary component - no frequency dependance

        distance_primary = distance_microphone[id]
        distance_secondary = distance_microphone[id]
        distance_mixed = distance_microphone[id]

        #Noise attenuation due to Ambient Pressure
        dspl_ambient_pressure = 20 * np.log10(pressure_amb[id] / pressure_isa)

        #Noise attenuation due to Density Gradientes
        dspl_density_p = 20 * np.log10(
            (density_primary + density_secondary) / (2 * density_ambient[id]))
        dspl_density_s = 20 * np.log10(
            (density_secondary + density_ambient[id]) /
            (2 * density_ambient[id]))
        dspl_density_m = 20 * np.log10(
            (density_mixed + density_ambient[id]) / (2 * density_ambient[id]))

        #Noise attenuation due to Spherical divergence
        dspl_spherical_p = 20 * np.log10(Diameter_primary / distance_primary)
        dspl_spherical_s = 20 * np.log10(Diameter_mixed / distance_secondary)
        dspl_spherical_m = 20 * np.log10(Diameter_mixed / distance_mixed)

        #Noise attenuation due to Geometric Near-Field
        if near_field == 0:
            dspl_geometric_p = 0.0
            dspl_geometric_s = 0.0
            dspl_geometric_m = 0.0
        elif near_field == 1:
            dspl_geometric_p = -10 * np.log10(
                1 + (2 * Diameter_primary +
                     (Diameter_primary * sound_ambient[id] / frequency)) /
                distance_primary)
            dspl_geometric_s = -10 * np.log10(
                1 + (2 * Diameter_mixed +
                     (Diameter_mixed * sound_ambient[id] / frequency)) /
                distance_secondary)
            dspl_geometric_m = -10 * np.log10(
                1 + (2 * Diameter_mixed +
                     (Diameter_mixed * sound_ambient[id] / frequency)) /
                distance_mixed)

    #Noise attenuation due to Acoustic Near-Field
        if near_field == 0:
            dspl_acoustic_p = 0.0
            dspl_acoustic_s = 0.0
            dspl_acoustic_m = 0.0
        elif near_field == 1:
            dspl_acoustic_p = 10 * np.log10(
                1 + 0.13 * (sound_ambient[id] /
                            (distance_primary * frequency))**2)
            dspl_acoustic_s = 10 * np.log10(
                1 + 0.13 * (sound_ambient[id] /
                            (distance_secondary * frequency))**2)
            dspl_acoustic_m = 10 * np.log10(1 + 0.13 *
                                            (sound_ambient[id] /
                                             (distance_mixed * frequency))**2)

        #Atmospheric attenuation coefficient
        if tunnel == 0:
            f_primary = frequency / (1 - Mach_aircraft[id] * np.cos(theta_p))
            f_secondary = frequency / (1 - Mach_aircraft[id] * np.cos(theta_s))
            f_mixed = frequency / (1 - Mach_aircraft[id] * np.cos(theta_m))
            Aci = Acf + ((temperature_ambient[id] - 0) - 15) / 10 * (Acq - Acf)

            Ac_primary = np.interp(f_primary, frequency, Aci)
            Ac_secondary = np.interp(f_secondary, frequency, Aci)
            Ac_mixed = np.interp(f_mixed, frequency, Aci)

            #Atmospheric attenuation
            delta_atmo = atmospheric_attenuation(distance_primary)

            dspl_attenuation_p = -delta_atmo
            dspl_attenuation_s = -delta_atmo
            dspl_attenuation_m = -delta_atmo

        elif tunnel == 1:  #These corrections are not applicable for jet rigs or static conditions
            dspl_attenuation_p = np.zeros(24)
            dspl_attenuation_s = np.zeros(24)
            dspl_attenuation_m = np.zeros(24)
            EX_m = np.zeros(24)
            EX_p = 0
            EX_s = 0

    #Calculation of the total noise attenuation (p-primary, s-secondary, m-mixed components)
        DSPL_p = dspl_ambient_pressure + dspl_density_p + dspl_geometric_p + dspl_acoustic_p + dspl_attenuation_p + dspl_spherical_p
        DSPL_s = dspl_ambient_pressure + dspl_density_s + dspl_geometric_s + dspl_acoustic_s + dspl_attenuation_s + dspl_spherical_s
        DSPL_m = dspl_ambient_pressure + dspl_density_m + dspl_geometric_m + dspl_acoustic_m + dspl_attenuation_m + dspl_spherical_m

        #Calculation of interference effects on jet noise
        ATK_m = angle_of_attack_effect(AOA, Mach_aircraft[id], theta_m)
        INST_s = jet_installation_effect(Xe, Ye, Ce, theta_s, Diameter_mixed)
        Plug = external_plug_effect(Velocity_primary[id],
                                    Velocity_secondary[id], Velocity_mixed,
                                    Diameter_primary, Diameter_secondary,
                                    Diameter_mixed, Plug_diameter,
                                    sound_ambient[id], theta_p, theta_s,
                                    theta_m)
        GPROX_m = ground_proximity_effect(Velocity_mixed, sound_ambient[id],
                                          theta_m, engine_height,
                                          Diameter_mixed, frequency)

        #Calculation of the sound pressure level for each jet component
        SPL_p = primary_noise_component(
            SPL_p, Velocity_primary[id], Temperature_primary[id], R_gas,
            theta_p, DVPS, sound_ambient[id], Velocity_secondary[id],
            Velocity_aircraft, Area_primary, Area_secondary, DSPL_p, EX_p,
            Str_p) + Plug[0]

        SPL_s = secondary_noise_component(
            SPL_s, Velocity_primary[id], theta_s, sound_ambient[id],
            Velocity_secondary[id], Velocity_aircraft, Area_primary,
            Area_secondary, DSPL_s, EX_s, Str_s) + Plug[1] + INST_s

        SPL_m = mixed_noise_component(
            SPL_m, Velocity_primary[id], theta_m, sound_ambient[id],
            Velocity_secondary[id], Velocity_aircraft, Area_primary,
            Area_secondary, DSPL_m, EX_m, Str_m, Velocity_mixed,
            XBPR) + Plug[2] + ATK_m + GPROX_m

        #Sum of the Total Noise
        SPL_total = 10 * np.log10(10**(0.1 * SPL_p) + 10**(0.1 * SPL_s) +
                                  10**(0.1 * SPL_m))

        #Store the SPL history
        SPL_total_history[id][:] = SPL_total[:]
        SPL_primary_history[id][:] = SPL_p[:]
        SPL_secondary_history[id][:] = SPL_s[:]
        SPL_mixed_history[id][:] = SPL_m[:]

    #Calculation of the Perceived Noise Level EPNL based on the sound time history
    PNL_total = pnl_noise(SPL_total_history)
    PNL_primary = pnl_noise(SPL_primary_history)
    PNL_secondary = pnl_noise(SPL_secondary_history)
    PNL_mixed = pnl_noise(SPL_mixed_history)

    #Calculation of the tones corrections on the SPL for each component and total
    tone_correction_total = noise_tone_correction(SPL_total_history)
    tone_correction_primary = noise_tone_correction(SPL_primary_history)
    tone_correction_secondary = noise_tone_correction(SPL_secondary_history)
    tone_correction_mixed = noise_tone_correction(SPL_mixed_history)

    #Calculation of the PLNT for each component and total
    PNLT_total = PNL_total + tone_correction_total
    PNLT_primary = PNL_primary + tone_correction_primary
    PNLT_secondary = PNL_secondary + tone_correction_secondary
    PNLT_mixed = PNL_mixed + tone_correction_mixed

    #Calculation of the EPNL for each component and total
    EPNL_total = epnl_noise(PNLT_total)
    EPNL_primary = epnl_noise(PNLT_primary)
    EPNL_secondary = epnl_noise(PNLT_secondary)
    EPNL_mixed = epnl_noise(PNLT_mixed)

    if ioprint:
        # print EPNL_total

        #Printing the output solution for the engine noise calculation

        fid.write('Engine noise module - SAE Model for Turbofan' + '\n')
        fid.write('Certification point = FLYOVER' + '\n')
        fid.write('EPNL = ' + str('%3.2f' % EPNL_total) + '\n')
        fid.write('PNLTM = ' + str('%3.2f' % np.max(PNLT_total)) + '\n')

        fid.write('Reference speed =  ')
        fid.write(str('%2.2f' % (Velocity_aircraft / Units.kts)) + '  kts')
        fid.write('\n')
        fid.write('PNLT history')
        fid.write('\n')
        fid.write(
            'time     	altitude     Mach     Core Velocity   Fan Velocity  Polar angle    Azim angle    distance    Primary	  Secondary 	 Mixed        Total'
        )
        fid.write('\n')
        for id in range(0, nsteps):
            fid.write(str('%2.2f' % time[id]) + '        ')
            fid.write(str('%2.2f' % Altitude[id]) + '        ')
            fid.write(str('%2.2f' % Mach_aircraft[id]) + '        ')
            fid.write(str('%3.3f' % Velocity_primary[id]) + '        ')
            fid.write(str('%3.3f' % Velocity_secondary[id]) + '        ')
            fid.write(str('%2.2f' % (angles[id] * 180 / np.pi)) + '        ')
            fid.write(str('%2.2f' % (phi[id] * 180 / np.pi)) + '        ')
            fid.write(str('%2.2f' % distance_microphone[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_primary[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_secondary[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_mixed[id]) + '        ')
            fid.write(str('%2.2f' % PNLT_total[id]) + '        ')
            fid.write('\n')
        fid.write('\n')
        fid.write('PNLT max =  ')
        fid.write(str('%2.2f' % (np.max(PNLT_total))) + '  dB')
        fid.write('\n')
        fid.write('EPNdB')
        fid.write('\n')
        fid.write('f	Primary    Secondary  	 Mixed       Total')
        fid.write('\n')
        fid.write(str('%2.2f' % EPNL_primary) + '        ')
        fid.write(str('%2.2f' % EPNL_secondary) + '        ')
        fid.write(str('%2.2f' % EPNL_mixed) + '        ')
        fid.write(str('%2.2f' % EPNL_total) + '        ')
        fid.write('\n')

        for id in range(0, nsteps):
            fid.write('\n')
            fid.write('Emission angle = ' + str(angles[id] * 180 / np.pi) +
                      '\n')
            fid.write('Altitude = ' + str(Altitude[id]) + '\n')
            fid.write('Distance = ' + str(distance_microphone[id]) + '\n')
            fid.write('Time = ' + str(time[id]) + '\n')
            fid.write('f		Primary  Secondary  	Mixed  		Total' + '\n')

            for ijd in range(0, 24):
                fid.write(str((frequency[ijd])) + '       ')
                fid.write(
                    str('%3.2f' % SPL_primary_history[id][ijd]) + '       ')
                fid.write(
                    str('%3.2f' % SPL_secondary_history[id][ijd]) + '       ')
                fid.write(
                    str('%3.2f' % SPL_mixed_history[id][ijd]) + '       ')
                fid.write(
                    str('%3.2f' % SPL_total_history[id][ijd]) + '       ')
                fid.write('\n')

        fid.close

    return (EPNL_total, SPL_total_history)