コード例 #1
0
                                     ImageMethod=True,
                                     Mstar=Mstar,
                                     Steady=False,
                                     KJMeth=True,
                                     NewAIC=True,
                                     DelTime=delTime,
                                     NumCores=4)
    # Aero inputs.
    iMin = M - M / 4
    iMax = M
    jMin = 16  #N - N/4
    jMax = N
    typeMotion = 'asInput'
    betaBar = 0.0 * np.pi / 180.0
    omega = 30.0
    ctrlSurf = ControlSurf(iMin, iMax, jMin, jMax, typeMotion, betaBar, omega)

    # Gust inputs
    gust = Gust(uMag=17.07, l=10.0, r=0.0)

    VMINPUT = DerivedTypesAero.VMinput(c=c,
                                       b=XBINPUT.BeamLength,
                                       U_mag=0.0,
                                       alpha=0.0 * np.pi / 180.0,
                                       theta=0.0,
                                       WakeLength=WakeLength,
                                       ctrlSurf=ctrlSurf,
                                       gust=gust)

    # Aerolastic simulation.
    AELAOPTS = AeroelasticOps(ElasticAxis=ElasticAxis,
コード例 #2
0
ファイル: test_UVLM.py プロジェクト: cndaqiang/SHARPy
    def test_ctrlSurf(self):
        """Test K&P then Joukowski methods unsteady lift and drag."""

        # Declare UVLM solver options.
        VMOPTS = VMopts(M=25,
                        N=2,
                        ImageMethod=True,
                        Mstar=250,
                        Steady=False,
                        KJMeth=False,
                        NewAIC=True,
                        DelTime=0.0,
                        Rollup=False,
                        NumCores=4)

        # Define wing geometry parameters.
        c = 1.0
        b = 1000.0
        theta = 0.0 * np.pi / 180.0

        # Define free-stream conditions.
        U_mag = 1.0
        alpha = 0.0 * np.pi / 180.0

        # Define Control Surface
        k = 1.0
        omega = 2 * U_mag * k / c
        betaBar = 0.1 * np.pi / 180.0
        ctrlSurf = ControlSurf(20, 25, 0, 2, 'sin', betaBar, omega)

        # Length of simulation.
        nT = 2.0
        NumChordLengths = nT * np.pi / k

        VMINPUT = VMinput(c,
                          b,
                          U_mag,
                          alpha,
                          theta,
                          WakeLength=NumChordLengths,
                          ctrlSurf=ctrlSurf)

        # Define unsteady solver parameters.
        VMUNST = VMUnsteadyInput(VMOPTS,
                                 VMINPUT,
                                 WakeLength=10.0,
                                 DelS=1.0 / 25.0,
                                 NumChordLengths=NumChordLengths,
                                 VelA_G=np.array([0, 0, 0]),
                                 OmegaA_G=np.array([0, 0, 0]))

        # Define 'aeroelastic' options.
        ElasticAxis = -0.5
        AELOPTS = AeroelasticOps(ElasticAxis=ElasticAxis)  # Quarter chord.

        # Run C++ solver.
        CoeffHistoryKatz = Run_Cpp_Solver_UVLM(VMOPTS, VMINPUT, VMUNST,
                                               AELOPTS)

        # Run from Joukowski method.
        VMOPTS.KJMeth.value = True
        CoeffHistoryJouk = Run_Cpp_Solver_UVLM(VMOPTS, VMINPUT, VMUNST,
                                               AELOPTS)

        # Set parameters for analytical result.
        alphaBar = 0.0
        hBar = 0.0
        phi0 = 0.0
        phi1 = 0.0
        phi2 = 0.0
        a = ElasticAxis
        e = 0.6
        k = 1.0

        Cl, Cd, alpha, beta, hDot, s = TheoGarrAerofoil(
            alphaBar, betaBar, hBar, phi0, phi1, phi2, a, e, k, nT + 0.1)

        # Delete unused variables
        del hDot

        # Interpolate analytical result onto simulated time steps.
        ClTheo = np.interp(CoeffHistoryKatz[:, 0] * U_mag / (c / 2.0), s, Cl)
        CdGarr = np.interp(CoeffHistoryKatz[:, 0] * U_mag / (c / 2.0), s, Cd)

        # Calculate error as function of time in last period.
        kTimeMid = len(CoeffHistoryKatz[:, 0]) / 2
        ClErr = CoeffHistoryKatz[kTimeMid:, 3] - ClTheo[kTimeMid:]
        CdErr = -CoeffHistoryKatz[kTimeMid:, 2] - CdGarr[kTimeMid:]
        ClErrJouk = CoeffHistoryJouk[kTimeMid:, 3] - ClTheo[kTimeMid:]
        CdErrJouk = -CoeffHistoryJouk[kTimeMid:, 2] - CdGarr[kTimeMid:]

        # RMS error
        rmsCl = np.sqrt(np.mean(pow(ClErr, 2.0))) / max(CoeffHistoryKatz[:, 3])
        rmsCd = np.sqrt(np.mean(pow(CdErr,
                                    2.0))) / max(-CoeffHistoryKatz[:, 2])
        rmsClJouk = (np.sqrt(np.mean(pow(ClErrJouk, 2.0))) /
                     max(CoeffHistoryJouk[:, 3]))
        rmsCdJouk = (np.sqrt(np.mean(pow(CdErrJouk, 2.0))) /
                     max(-CoeffHistoryJouk[:, 2]))

        # Check RMS is same as on 23/05/13
        self.assertAlmostEqual(rmsCl, 0.0241589106969, 6, 'RMS error in lift.')
        self.assertAlmostEqual(rmsCd, 0.136290106597, 5, 'RMS error in drag.')

        Plotting = False
        if Plotting == True:
            # Define beta here for plotting purposes.
            betaSim = betaBar * np.sin(omega * CoeffHistoryKatz[:, 0])

            plt.subplot(2, 1, 1)
            plt.grid()
            plt.plot(betaSim, -CoeffHistoryKatz[:, 2], 'ko-', beta, Cd, 'k-.')
            plt.xlabel(r'$\beta$')
            plt.ylabel(r'$C_d$')
            plt.subplot(2, 1, 2)
            plt.grid()
            plt.plot(betaSim, CoeffHistoryKatz[:, 3], 'ko-', beta, Cl, 'k-.')
            plt.xlabel(r'$\beta$')
            plt.ylabel(r'$C_l$')

            plt.show()
コード例 #3
0
    return CoeffHistory


if __name__ == '__main__':
    # Define options for aero solver.
    M = 4
    N = 10
    Mstar = 80
    VMOPTS = VMopts(M, N, True, Mstar, False, False, True, 0.0, True, 4)

    # Define wing geometry parameters.
    c = 1
    b = 4  #semi-span

    # Define Control Surface
    ctrlSurf = ControlSurf(3, 4, 6, 9, 'sin', 1 * np.pi / 180.0, 2 * np.pi)

    # Define free stream conditions.
    U_mag = 1.0
    alpha = 0.0 * np.pi / 180.0
    theta = 10.0 * np.pi / 180.0

    VMINPUT = VMinput(c, b, U_mag, alpha, theta, 0.0, 15.0, ctrlSurf)

    # Define unsteady solver parameters.
    WakeLength = 10.0
    DeltaS = 1.0 / 4.0
    NumChordLengths = 10.0
    VelA_A = np.array([0, 0, 0])
    OmegaA_A = np.array([0, 0, 0])
    VMUNST = VMUnsteadyInput(VMOPTS,VMINPUT,\