<filename>aircraft framework lin/framework Bento/delta_CLmax_flap.py<gh_stars>0
"""" 
Title     : Section Clmax
Written by: <NAME>
Date      : 05/11/19
Language  : Python
Aeronautical Institute of Technology


Inputs:
Mach
AirportElevation
PROOT
Craiz
PKINK
Cquebra
PTIP
Cponta

Outputs:
clmax_airfoil
flagsuc
"""
########################################################################################
import numpy as np
import os
from atmosphere import atmosphere
from cf_flat_plate import cf_flat_plate
from scipy import interpolate
########################################################################################
"""Constants declaration"""
########################################################################################

def delta_CLmax_flap(ftype,tc,flapchord,fdeflec,phi14,fSwS):
    #--------------------------------------------------------------------------
    # ftype = 1 two slots ~=1 single slot
    # tc = maximum relative thickness (must be provided as fraction of chord)
    # flapchord = fraction of chord covered by the flap (a fractionary number)
    # fdeflec = flap deflectin angle [degrees]
    # phi14 = Quarter-chord sweepback angle [degrees]
    # fSwS = ratio betwwen flap covered area and actual reference area
    #--------------------------------------------------------------------------
    rad       = np.pi/180
    phi14_rad = phi14*rad
    #--------------------------------------------------------------------------
    # clc
    # ftype=1
    # tc=0.125
    # flapchord=0.25
    # fdeflec=45
    # clmaxbase ---------------------------------------------------------------
    if ftype == 1:
        F_2slot=np.array([[0. , 0.989204601706829],
        [0.9969704770013683, 0.9959368750371262],
        [2.8252975070787887, 0.9987169079064608],
        [3.2815080292259857, 1.0093222184820703],
        [4.265528780468488, 1.160861730986275],
        [5.494129061639901, 1.0407579747737756],
        [6.6872463021998705, 1.069049363404154],
        [7.7742312337880914, 1.1045957665881232],
        [8.615369383996988, 1.1366493079619029],
        [9.595271568025659, 1.190261964635764],
        [10.679088370987863, 1.2618458309407359],
        [11.796487337385898, 1.351432588163079],
        [12.668989960992413, 1.4267152446389322],
        [13.680573431281307, 1.519953270102766],
        [14.586975031186263, 1.6096350711838898],
        [15.494643882541627, 1.6849018870166126],
        [16.33356434271231, 1.421816525750944],
        [17.41959883571273, 1.7885392946953644],
        [18.33170306714452, 1.8133536621586834],
        [18.89467952398867, 1.8094964655565013]])

        VBase_2slot = interpolate.interp1d(F_2slot[:,0], F_2slot[:,1],kind='cubic')(tc*100)
    else:
        F_1slot=np.array([[0.0, 0.9927608260895391],
        [0.7162742807357994, 0.9888561075579665],
        [2.122923390689664, 0.9882224818327621],
        [2.755598677306299, 0.9915410965685205],
        [3.4586064194206294, 0.9948280300180183],
        [4.865255529374492, 0.9941944042928139],
        [5.286933449498049, 0.9976080628873529],
        [5.918658297526878, 1.011737916559412],
        [6.8665623824327255, 1.0293289507554004],
        [7.42732114923866, 1.0506979783379202],
        [8.478823040215433, 1.08986396847712],
        [9.249628734926636, 1.12194919113716],
        [10.194364691206461, 1.1755776884541511],
        [10.78902243431083, 1.2113458606419418],
        [11.138783834623684, 1.2328099320832422],
        [11.627942894481517, 1.2686256262004234],
        [12.221967011860677, 1.3116012910124148],
        [12.745025048016945, 1.361816129734867],
        [13.443280597192246, 1.4191592578658692],
        [14.105419480030886, 1.4873294655763023],
        [14.558461873552062, 1.5339722392729143],
        [15.046670494822088, 1.5805991723263961],
        [15.464546660594415, 1.6272577866661384],
        [15.709126190523335, 1.6451656337247291],
        [16.163119022632316, 1.6809971684850402],
        [16.82905965982219, 1.70592242045027],
        [17.6011326059838, 1.723592657861909],
        [18.269290933211884, 1.7232916856424367],
        [18.76225174742094, 1.7158624240144147],
        [19.220679959606358, 1.7012415104053222],
        [19.64362513118032, 1.69024018375146],
        [19.891055976872657, 1.6757143140011483]])
        VBase_1slot=interpolate.interp1d(F_1slot[:,0],F_1slot[:,1],kind='cubic')(tc*100)


    #------------------------ end clmaxbase -----------------------------------
    #---------------------- Begin K1 ------------------------------------------
    if ftype == 1:
        inclin= 1.2/30
        vk1_2slot = inclin*(flapchord*100)
    else:
        k1_1slot=np.array([[0., 0.],
        [0.5134753924319408,0.05058011678167884],
        [0.8383407901721398,0.09107454311063945],
        [1.2161674376279672,0.12069159020247211],
        [1.5943580799272015,0.1557321604610602],
        [2.026419959050581,0.19345415939940858],
        [2.619731553802988,0.23379692121028306],
        [3.2670963828012445,0.2795328732842952],
        [4.400030332903618,0.36024872980966116],
        [5.208826874952606,0.4113172063395769],
        [6.287161598544022,0.47850458785167216],
        [7.525836050655951,0.5347539243194056],
        [8.49551831349056,0.5830196405550921],
        [9.249351634185185,0.6151361189049822],
        [10.325866383559568,0.6552058845833018],
        [11.079153711989083,0.6791870781830591],
        [12.20935770076591,0.7192265109577614],
        [13.231637218472741,0.7511913247895654],
        [14.307423978160315,0.7804140441343748],
        [15.114400545992268,0.8043649048305149],
        [16.29756578448473,0.8335269583680898],
        [17.695305983165245,0.8598559187078183],
        [19.093592174110874,0.8943201637976794],
        [20.59852885417457,0.917876696746796],
        [22.37245772351559,0.9494168499279594],
        [23.447516493516346,0.9677925229392583],
        [24.737696215970278,0.9914703875028437],
        [26.188215666944725,1.004210207022067],
        [26.887085766284986,1.0173746871919314],
        [28.122484264806257,1.0248123151588686],
        [29.41175400015167,1.034931371805566],
        [29.89532114961705,1.0400818988397664],
        [32., 1.08]])
        vk1_1slot=interpolate.interp1d(k1_1slot[:,0],k1_1slot[:,1],kind='cubic')(flapchord*100)


        

    #------------------- End K1 -----------------------------------------------
    #---------------------- Begin K2 ------------------------------------------
    if ftype == 1:

        k2_2slot=np.array([ [0.,0.18463],
        [1.4173,0.22411],
        [3.3168,0.28115],
        [4.9897,0.32721],
        [7.1125,0.39083],
        [9.0040,0.43688],
        [13.126,0.54434],
        [16.790,0.62326],
        [21.009,0.71314],
        [24.219,0.77011],
        [29.084,0.84676],
        [32.726,0.89492],
        [36.806,0.94524],
        [40.433,0.97361],
        [42.632,0.99108],
        [45.153,1.00],
        [50.399,1.00]])
        vk2_2slot=interpolate.Akima1DInterpolator(k2_2slot[:,0],k2_2slot[:,1])(fdeflec)
    else:
        k2_1slot=np.array([[0. , 0.39782],
        [1.7880,0.43288],
        [4.4525,0.48988],
        [6.7859,0.54250],
        [8.8943,0.58634],
        [13.769,0.67618],
        [18.199,0.75725],
        [22.074,0.82517],
        [26.930,0.89084],
        [29.471,0.92806],
        [31.345,0.94994],
        [33.436,0.96960],
        [35.742,0.98486],
        [37.610,0.99794],
        [40.239,1.00],
        [45.000, 1.00],
        [50.000,1.00]])
        #
        vk2_1slot=interpolate.Akima1DInterpolator(k2_1slot[:,0],k2_1slot[:,1])(fdeflec)

    #------------------- End K2 -----------------------------------------------
    #---------------------- Begin K3 ------------------------------------------
    if ftype == 1:
        k3_2slot=np.array([[0.,0.0000061755],
        [0.037106, 0.0092602],
        [0.077410, 0.027926],
        [0.12248, 0.051278],
        [0.15339, 0.077039],
        [0.21045, 0.12387],
        [0.25096, 0.16842],
        [0.29864, 0.22471],
        [0.35120, 0.29979],
        [0.40631, 0.39840],
        [0.45426, 0.48762],
        [0.48072, 0.54870],
        [0.51658, 0.60267],
        [0.54760, 0.64255],
        [0.58333, 0.68006],
        [0.63093, 0.72458],
        [0.69508, 0.77139],
        [0.73082, 0.81125],
        [0.81152, 0.86034],
        [0.85906, 0.89780],
        [0.93500, 0.94221],
        [0.96117, 0.96564],
        [1.0, 0.99130]])
        df_ratio=min(1.,fdeflec/45)
        vk3_2slot=interpolate.Akima1DInterpolator(k3_2slot[:,0],k3_2slot[:,1])(df_ratio)
        
    else:
        k3_1slot=np.array([[0,0.0023498],
        [0.025443,0.028129],
        [0.051741,0.068026],
        [0.10428,0.14076],
        [0.15917,0.21113],
        [0.21878,0.28149],
        [0.26416,0.34484],
        [0.34995,0.44097],
        [0.43095,0.52772],
        [0.51197,0.61681],
        [0.57147,0.67305],
        [0.64045,0.73395],
        [0.74979,0.82058],
        [0.83769,0.88377],
        [0.92317,0.93990],
        [1.0086,0.98898]])

        if (fdeflec/40) <= max(k3_1slot[:,0]):
            vk3_1slot=interpolate.Akima1DInterpolator(k3_1slot[:,0],k3_1slot[:,1])(fdeflec/40)
        else:
            vk3_1slot=interpolate.interp1d(k3_1slot[:,0],k3_1slot[:,1],kind='cubic',fill_value="extrapolate")(fdeflec/40)

    #------------------- End K3 -----------------------------------------------
    if ftype == 1:

        DCLMAX_FLAP=VBase_2slot*vk1_2slot*vk2_2slot*vk3_2slot
    elif ftype == 2:
        DCLMAX_FLAP=VBase_1slot*vk1_1slot*vk2_1slot*vk3_1slot

    # fator de correcao devido ao enflechamento
    auxcos=np.cos(phi14_rad)
    K_w         = (1-0.08*(auxcos)**2)*(auxcos**(3/4))
    DCLMAX_FLAP = DCLMAX_FLAP*K_w
    # Fator de correcao para area de flape
    DCLMAX_FLAP=DCLMAX_FLAP*fSwS

    return(DCLMAX_FLAP)

