Example #1
0
    def __str__(self):
        thestr = "0"
        var = self.variable

        # Remove leading zeros
        coeffs = self.coeffs[NX.logical_or.accumulate(self.coeffs != 0)]
        N = len(coeffs) - 1

        def fmt_float(q):
            s = '%.4g' % q
            if s.endswith('.0000'):
                s = s[:-5]
            return s

        for k in range(len(coeffs)):
            if not iscomplex(coeffs[k]):
                coefstr = fmt_float(real(coeffs[k]))
            elif real(coeffs[k]) == 0:
                coefstr = '%sj' % fmt_float(imag(coeffs[k]))
            else:
                coefstr = '(%s + %sj)' % (fmt_float(real(
                    coeffs[k])), fmt_float(imag(coeffs[k])))

            power = (N - k)
            if power == 0:
                if coefstr != '0':
                    newstr = '%s' % (coefstr, )
                else:
                    if k == 0:
                        newstr = '0'
                    else:
                        newstr = ''
            elif power == 1:
                if coefstr == '0':
                    newstr = ''
                elif coefstr == 'b':
                    newstr = var
                else:
                    newstr = '%s %s' % (coefstr, var)
            else:
                if coefstr == '0':
                    newstr = ''
                elif coefstr == 'b':
                    newstr = '%s**%d' % (
                        var,
                        power,
                    )
                else:
                    newstr = '%s %s**%d' % (coefstr, var, power)

            if k > 0:
                if newstr != '':
                    if newstr.startswith('-'):
                        thestr = "%s - %s" % (thestr, newstr[1:])
                    else:
                        thestr = "%s + %s" % (thestr, newstr)
            else:
                thestr = newstr
        return _raise_power(thestr)
Example #2
0
    def __str__(self):
        thestr = "0"
        var = self.variable

        # Remove leading zeros
        coeffs = self.coeffs[NX.logical_or.accumulate(self.coeffs != 0)]
        N = len(coeffs) - 1

        def fmt_float(q):
            s = "%.4g" % q
            if s.endswith(".0000"):
                s = s[:-5]
            return s

        for k in range(len(coeffs)):
            if not iscomplex(coeffs[k]):
                coefstr = fmt_float(real(coeffs[k]))
            elif real(coeffs[k]) == 0:
                coefstr = "%sj" % fmt_float(imag(coeffs[k]))
            else:
                coefstr = "(%s + %sj)" % (
                    fmt_float(real(coeffs[k])),
                    fmt_float(imag(coeffs[k])),
                )

            power = N - k
            if power == 0:
                if coefstr != "0":
                    newstr = "%s" % (coefstr,)
                else:
                    if k == 0:
                        newstr = "0"
                    else:
                        newstr = ""
            elif power == 1:
                if coefstr == "0":
                    newstr = ""
                elif coefstr == "b":
                    newstr = var
                else:
                    newstr = "%s %s" % (coefstr, var)
            else:
                if coefstr == "0":
                    newstr = ""
                elif coefstr == "b":
                    newstr = "%s**%d" % (var, power)
                else:
                    newstr = "%s %s**%d" % (coefstr, var, power)

            if k > 0:
                if newstr != "":
                    if newstr.startswith("-"):
                        thestr = "%s - %s" % (thestr, newstr[1:])
                    else:
                        thestr = "%s + %s" % (thestr, newstr)
            else:
                thestr = newstr
        return _raise_power(thestr)
Example #3
0
    def __str__(self):
        thestr = "0"
        var = self.variable

        # Remove leading zeros
        coeffs = self.coeffs[NX.logical_or.accumulate(self.coeffs != 0)]
        N = len(coeffs)-1

        def fmt_float(q):
            s = '%.4g' % q
            if s.endswith('.0000'):
                s = s[:-5]
            return s

        for k in range(len(coeffs)):
            if not iscomplex(coeffs[k]):
                coefstr = fmt_float(real(coeffs[k]))
            elif real(coeffs[k]) == 0:
                coefstr = '%sj' % fmt_float(imag(coeffs[k]))
            else:
                coefstr = '(%s + %sj)' % (fmt_float(real(coeffs[k])),
                                          fmt_float(imag(coeffs[k])))

            power = (N-k)
            if power == 0:
                if coefstr != '0':
                    newstr = '%s' % (coefstr,)
                else:
                    if k == 0:
                        newstr = '0'
                    else:
                        newstr = ''
            elif power == 1:
                if coefstr == '0':
                    newstr = ''
                elif coefstr == 'b':
                    newstr = var
                else:
                    newstr = '%s %s' % (coefstr, var)
            else:
                if coefstr == '0':
                    newstr = ''
                elif coefstr == 'b':
                    newstr = '%s**%d' % (var, power,)
                else:
                    newstr = '%s %s**%d' % (coefstr, var, power)

            if k > 0:
                if newstr != '':
                    if newstr.startswith('-'):
                        thestr = "%s - %s" % (thestr, newstr[1:])
                    else:
                        thestr = "%s + %s" % (thestr, newstr)
            else:
                thestr = newstr
        return _raise_power(thestr)
    def __str__(self):
        thestr = "0"
        var = self.variable

        # Remove leading zeros
        coeffs = self.coeffs[NX.logical_or.accumulate(self.coeffs != 0)]
        N = len(coeffs) - 1

        def fmt_float(q):
            s = "%.4g" % q
            if s.endswith(".0000"):
                s = s[:-5]
            return s

        for k in range(len(coeffs)):
            if not iscomplex(coeffs[k]):
                coefstr = fmt_float(real(coeffs[k]))
            elif real(coeffs[k]) == 0:
                coefstr = "%sj" % fmt_float(imag(coeffs[k]))
            else:
                coefstr = "(%s + %sj)" % (fmt_float(real(coeffs[k])), fmt_float(imag(coeffs[k])))

            power = N - k
            if power == 0:
                if coefstr != "0":
                    newstr = "%s" % (coefstr,)
                else:
                    if k == 0:
                        newstr = "0"
                    else:
                        newstr = ""
            elif power == 1:
                if coefstr == "0":
                    newstr = ""
                elif coefstr == "b":
                    newstr = var
                else:
                    newstr = "%s %s" % (coefstr, var)
            else:
                if coefstr == "0":
                    newstr = ""
                elif coefstr == "b":
                    newstr = "%s**%d" % (var, power)
                else:
                    newstr = "%s %s**%d" % (coefstr, var, power)

            if k > 0:
                if newstr != "":
                    if newstr.startswith("-"):
                        thestr = "%s - %s" % (thestr, newstr[1:])
                    else:
                        thestr = "%s + %s" % (thestr, newstr)
            else:
                thestr = newstr
        return _raise_power(thestr)
def make_poly(facts):
    """ Create polynomial from factors """
    poly = [1]
    for factor in facts:
        poly = polymul(poly, [1, -factor])

    return real(poly)
Example #6
0
def make_poly(facts):
    """ Create polynomial from factors """
    poly = [1]
    for factor in facts:
        poly = polymul(poly, [1, -factor])

    return real(poly)
Example #7
0
    def GetTimeFlow(self, el, time):
        '''
        Calculating inlet flow (coefficients of the FFT  x(t)=A0+sum(2*Ck*exp(j*k*2*pi*f*t)))
        for a specific time value.
        If signal is specified, flow is computed from time values.
        '''
        try:
            period = self.SimulationContext.Context['period']
        except KeyError:
            print "Error, Please set period in Simulation Context XML File"
            raise

        try:
            signal = self.InFlows[el]['signal']
            try:
                timestep = self.SimulationContext.Context['timestep']
            except KeyError:
                print "Error, Please set timestep in Simulation Context XML File"
                raise
            t = arange(0.0,period+timestep,timestep)
            t2 = list(t)
            Flow = float(signal[t2.index(time)])/6.0e7
            self.Flow = Flow
            return Flow
        except KeyError:
            f_coeff = self.InFlows[el]['f_coeff']
            A0 = self.InFlows[el]['A0']
            Cc = f_coeff*1.0/2.0*1e-6
            Flow = A0
            for k in arange(0,f_coeff.shape[0]):
                Flow += real(2.0*complex(Cc[k,0],Cc[k,1])*exp(1j*(k+1)*2.0*pi*time/period))
            self.Flow = Flow
            return Flow
Example #8
0
    def GetFlow(self):
        '''
        Calculating inlet flow (coefficients of the FFT  x(t)=A0+sum(2*Ck*exp(j*k*2*pi*f*t)))
        Timestep and period from SimulationContext are necessary.
        '''
        try:
            timestep = self.SimulationContext.Context['timestep']
        except KeyError:
            print "Error, Please set timestep in Simulation Context XML File"
            raise
        try:
            period = self.SimulationContext.Context['period']
        except KeyError:
            print "Error, Please set period in Simulation Context XML File"
            raise

        t = arange(0.0,period+timestep,timestep).reshape((1,ceil(period/timestep+1.0)))
        Cc = self.f_coeff*1.0/2.0*1e-6
        Flow = zeros((1, ceil(period/timestep+1.0)))
        for freq in arange(0,ceil(period/timestep+1.0)):
            Flow[0, freq] = self.A0_v
            for k in arange(0,self.f_coeff.shape[0]):
                Flow[0, freq] = Flow[0, freq]+real(2.0*complex(Cc[k,0],Cc[k,1])*exp(1j*(k+1)*2.0*pi*t[0,freq]/period))
        self.Flow = Flow
        return Flow
Example #9
0
 def transform(self, R, s, t, pos, ori=nan):
     """ Transform node position. """
     assert None not in (R, s, t)
     assert not imag(R).any()
     R = real(R)
     if not isnan(ori):
         # angle of rotation matrix R in ccw
         Rtheta = arctan2(R[1, 0], R[0, 0])
         ori = mod(ori - Rtheta, 2 * pi)
     return concatenate((t + dot(dot(s, R), pos), [ori]))
Example #10
0
 def transform(self, R, s, t, pos, ori=nan):
     """ Transform node position. """
     assert None not in (R, s, t)
     assert not imag(R).any()
     R = real(R)
     if not isnan(ori):
         # angle of rotation matrix R in ccw
         Rtheta = arctan2(R[1, 0], R[0, 0])
         ori = mod(ori - Rtheta, 2*pi)
     return concatenate((t + dot(dot(s, R), pos), [ori]))
Example #11
0
def TheoGarrAerofoil(alphaBar,betaBar,hBar,phi0,phi1,phi2,a,e,k,nT):
    """@brief Lift and drag of thin aerofoil oscillating in pitch, plunge and
    flap angle.
    @param alphaBar amplitude of pitching oscillations.
    @param betaBar amplitude of flap oscillations.
    @param hBar amplitude of plunging oscillations.
    @param phi0 Phase angle in pitch.
    @param phi1 Phase angle in flap angle.
    @param phi2 Phase angle in plunge.
    @param a Non-dim offset of pitching axis aft of mid-chord.
    @param e Non-dim offset of flap hinge aft of mid-chord.
    @param k Reduced frequency, k = omega*b/U.
    @param nT Number of periods in output.
    @details As this will likely be extended to also calculate moments there are
    many commented variables which may be of use later on - don't remove them."""
    
    # Time parameters.
    sFinal = 2 * pi * nT / k
    s = np.linspace(0.0, sFinal, nT * 100, True)
    
    # Kinematic Parameters
    # Sinusoidal variations, take imaginary part of Theodorsen's equations.
    alpha = alphaBar * sin(k*s + phi0)
    alphaDot = k * alphaBar * cos(k*s + phi0)
    alphaDotDot = - pow(k,2.0) * alphaBar * sin(k*s + phi0)
    # h = hBar * sin(k*s + phi1)
    hDot = k * hBar * cos(k*s + phi1)
    hDotDot = - pow(k,2.0) * hBar * sin(k*s + phi1)
    beta = betaBar * sin(k*s + phi2)
    betaDot = k * betaBar * cos(k*s + phi2)
    betaDotDot = - pow(k,2.0) * betaBar * sin(k*s + phi2)
    
    # Theodorsen's constants
    F1 = e * arccos(e) - 1.0/3.0 * (2 + pow(e, 2.0)) * np.sqrt(1 - pow(e, 2.0))
    F2 = (e * (1 - pow(e, 2.0)) - 
          (1 + pow(e, 2.0)) * np.sqrt(1 - pow(e, 2.0)) * arccos(e) +
          e*pow(arccos(e), 2.0))
#    F3 = (- (1.0/8.0 + pow(e, 2.0)) * pow(arccos(e),2.0) +
#            1.0/4.0 * e * np.sqrt(1 - pow(e, 2.0)) * arccos(e)
#                    * (7 + 2*pow(e, 2.0))
#          - 1.0/8.0 * (1 - pow(e, 2.0)) * (5 * pow(e, 2.0) + 4))
    F4 = e * np.sqrt(1 - pow(e, 2.0)) - arccos(e)
    F5 = (-(1 - pow(e, 2.0)) - pow(arccos(e),2.0) 
           + 2 * e * np.sqrt(1 - pow(e, 2.0)) * arccos(e))
#    F6 = F2
#    F7 = (-(1.0/8.0 + pow(e, 2.0)) * arccos(e) 
#          + 1.0/8.0 * e * np.sqrt(1 - pow(e, 2.0)) * (7 + 2 * pow(e, 2.0)))
#    F8 = (-1.0/3.0 * np.sqrt(1 - pow(e, 2.0)) * (2 * pow(e, 2.0) + 1) 
#          + e * arccos(e))
    F9 = 1.0/2.0 * (1.0/3.0 * pow(np.sqrt(1 - pow(e, 2.0)),3) + a * F4)
    F10 = np.sqrt(1 - pow(e, 2.0)) + arccos(e)
    F11 = (1 - 2 * e) * arccos(e) + (2 - e) * np.sqrt(1 - pow(e, 2.0))
#    F12 = np.sqrt(1 - pow(e, 2.0)) * (2 + e) - arccos(e) * (2 * e + 1)
#    F13 = 1.0/2.0 * (-F7 - (e - a) * F1)
    # F14 = -arccos(e) + e*np.sqrt(1-pow(e, 2.0)) 
#    F14 = 1.0/16.0 + 1.0/2.0 * a * e
    
#    F6 = F2

    # Garrick's constants
#    F15 = F4 + F10
#    F16 = F1 - F8 - (e - a) * F4 + 1.0/2.0 * F11
#    F17 = -2 * F9 - F1 + (a - 0.5) * F4
#    F18 = F5 - F4 * F10
#    F19 = F4 * F11
    F20 = -np.sqrt(1 - pow(e, 2.0)) + arccos(e)
    
    M = (  2 * real(C(k)) * (alphaBar * cos(phi0)
                             - hBar * k * sin(phi2)
                             - (0.5 - a) * alphaBar * k * sin(phi0)
                             + F10/pi * betaBar * cos(phi1)
                             - F11/(2*pi) * betaBar * k * sin(phi1))
         - 2 * imag(C(k)) * (alphaBar * sin(phi0)
                             + hBar * k * cos(phi2)
                             + (0.5 - a) * alphaBar * k * cos(phi0)
                             + F10/pi * betaBar * sin(phi1)
                             + F11/(2*pi) * betaBar * k * cos(phi1))
         + alphaBar * k * sin(phi0)
         - 2.0/pi * np.sqrt(1 - pow(e, 2.0)) * betaBar * cos(phi1)
         - F4/pi * betaBar * k * sin(phi1)  )
    
    N = (  2 * real(C(k)) * (alphaBar * sin(phi0) 
                             + hBar * k * cos(phi2)
                             + (0.5 - a) * alphaBar * k * cos(phi0)
                             + F10/pi * betaBar * sin(phi1)
                             + F11/(2*pi) * betaBar * k * cos(phi1) )
         + 2 * imag(C(k)) * (alphaBar * cos(phi0) 
                             - hBar * k * sin(phi2)
                             - (0.5 - a) * alphaBar * k * sin(phi0)
                             + F10/pi * betaBar * cos(phi1)
                             - F11/(2*pi) * betaBar * k * sin(phi1))
         - alphaBar * k * cos(phi0)
         - 2.0/pi * np.sqrt(1 - pow(e, 2.0)) * betaBar * sin(phi1)
         - F4/pi * betaBar * k * cos(phi1) )
    
    # Loop through time steps
    p = ( -(pi*alphaDot + pi*hDotDot - pi*a*alphaDotDot 
            - F4*betaDot - F1*betaDotDot)
          - 2*pi*real(C(k)) * (alpha + hDot + (0.5 - a)*alphaDot + F10/pi*beta
                               + F11/(2*pi)*betaDot) 
          - 2*pi*imag(C(k))/k * (alphaDot + hDotDot + alphaDotDot 
                                     + F10/pi*betaDot + F11/(2*pi)*betaDotDot) )
    
    pBeta = ( -(-F4*alphaDot - F4*hDotDot + F9*alphaDotDot - F5/(2*pi)*betaDot
                - F2/(2*pi)*betaDotDot)
              - 2*np.sqrt(1 - pow(e,2.0)) * (0.5*(1 - e)*alphaDot
                                             + np.sqrt(1 - pow(e,2.0))/pi*beta
                                             + F10/(2*pi)*(1 - e)*betaDot)
              - 2*F20*real(C(k))*(alpha + hDot + (0.5 - a)*alphaDot
                                  + F10/pi*beta + F11/(2*pi)*betaDot)
              - 2*F20*imag(C(k))/k*(alphaDot + hDotDot
                                        + (0.5 - a)*alphaDotDot
                                        + F10/pi*betaDot
                                        + F11/(2*pi)*betaDotDot) )
    
    S = (np.sqrt(2.0) / 2.0) * (M * sin(k * s) + 
                                N * cos(k * s)  )

    d = - alpha*p - pi*pow(S, 2.0) - beta*pBeta
    
    Cl = - p
    Cd = d
        
    return Cl, Cd, alpha, beta, hDot, s
Example #12
0
    d = - alpha*p - pi*pow(S, 2.0) - beta*pBeta
    
    Cl = - p
    Cd = d
        
    return Cl, Cd, alpha, beta, hDot, s


if __name__ == '__main__':
    # Test Theodorsen function.
    if False:
        k = np.linspace(0,1,101,True)
        Ck = np.zeros_like(k,complex)
        for kIter in range(k.shape[0]):
            Ck[kIter] = C(k[kIter])
        plt.plot(k,real(Ck),k,imag(Ck))
        plt.grid()
        plt.xlabel('k')
        plt.legend(['Re(C(k))','Im(C(k))'])
        plt.show()
    
    # Test TheoGarr.
    if True:
        alphaBar = 0.0*pi/180.0
        betaBar = 0.1*pi/180.0
        hBar = 0.0
        phi0 =0.0*pi/180.0
        phi1 = 0.0*pi/180.0
        phi2 = 0.0*pi/180.0
        a = -0.5
        e = 0.6
Example #13
0
def TheoGarrAerofoil(alphaBar, betaBar, hBar, phi0, phi1, phi2, a, e, k, nT):
    """@brief Lift and drag of thin aerofoil oscillating in pitch, plunge and
    flap angle.
    @param alphaBar amplitude of pitching oscillations.
    @param betaBar amplitude of flap oscillations.
    @param hBar amplitude of plunging oscillations.
    @param phi0 Phase angle in pitch.
    @param phi1 Phase angle in flap angle.
    @param phi2 Phase angle in plunge.
    @param a Non-dim offset of pitching axis aft of mid-chord.
    @param e Non-dim offset of flap hinge aft of mid-chord.
    @param k Reduced frequency, k = omega*b/U.
    @param nT Number of periods in output.
    @details As this will likely be extended to also calculate moments there are
    many commented variables which may be of use later on - don't remove them."""

    # Time parameters.
    sFinal = 2 * pi * nT / k
    s = np.linspace(0.0, sFinal, nT * 100, True)

    # Kinematic Parameters
    # Sinusoidal variations, take imaginary part of Theodorsen's equations.
    alpha = alphaBar * sin(k * s + phi0)
    alphaDot = k * alphaBar * cos(k * s + phi0)
    alphaDotDot = -pow(k, 2.0) * alphaBar * sin(k * s + phi0)
    # h = hBar * sin(k*s + phi1)
    hDot = k * hBar * cos(k * s + phi1)
    hDotDot = -pow(k, 2.0) * hBar * sin(k * s + phi1)
    beta = betaBar * sin(k * s + phi2)
    betaDot = k * betaBar * cos(k * s + phi2)
    betaDotDot = -pow(k, 2.0) * betaBar * sin(k * s + phi2)

    # Theodorsen's constants
    F1 = e * arccos(e) - 1.0 / 3.0 * (2 + pow(e, 2.0)) * np.sqrt(1 -
                                                                 pow(e, 2.0))
    F2 = (e * (1 - pow(e, 2.0)) -
          (1 + pow(e, 2.0)) * np.sqrt(1 - pow(e, 2.0)) * arccos(e) +
          e * pow(arccos(e), 2.0))
    #    F3 = (- (1.0/8.0 + pow(e, 2.0)) * pow(arccos(e),2.0) +
    #            1.0/4.0 * e * np.sqrt(1 - pow(e, 2.0)) * arccos(e)
    #                    * (7 + 2*pow(e, 2.0))
    #          - 1.0/8.0 * (1 - pow(e, 2.0)) * (5 * pow(e, 2.0) + 4))
    F4 = e * np.sqrt(1 - pow(e, 2.0)) - arccos(e)
    F5 = (-(1 - pow(e, 2.0)) - pow(arccos(e), 2.0) +
          2 * e * np.sqrt(1 - pow(e, 2.0)) * arccos(e))
    #    F6 = F2
    #    F7 = (-(1.0/8.0 + pow(e, 2.0)) * arccos(e)
    #          + 1.0/8.0 * e * np.sqrt(1 - pow(e, 2.0)) * (7 + 2 * pow(e, 2.0)))
    #    F8 = (-1.0/3.0 * np.sqrt(1 - pow(e, 2.0)) * (2 * pow(e, 2.0) + 1)
    #          + e * arccos(e))
    F9 = 1.0 / 2.0 * (1.0 / 3.0 * pow(np.sqrt(1 - pow(e, 2.0)), 3) + a * F4)
    F10 = np.sqrt(1 - pow(e, 2.0)) + arccos(e)
    F11 = (1 - 2 * e) * arccos(e) + (2 - e) * np.sqrt(1 - pow(e, 2.0))
    #    F12 = np.sqrt(1 - pow(e, 2.0)) * (2 + e) - arccos(e) * (2 * e + 1)
    #    F13 = 1.0/2.0 * (-F7 - (e - a) * F1)
    # F14 = -arccos(e) + e*np.sqrt(1-pow(e, 2.0))
    #    F14 = 1.0/16.0 + 1.0/2.0 * a * e

    #    F6 = F2

    # Garrick's constants
    #    F15 = F4 + F10
    #    F16 = F1 - F8 - (e - a) * F4 + 1.0/2.0 * F11
    #    F17 = -2 * F9 - F1 + (a - 0.5) * F4
    #    F18 = F5 - F4 * F10
    #    F19 = F4 * F11
    F20 = -np.sqrt(1 - pow(e, 2.0)) + arccos(e)

    M = (2 * real(C(k)) * (alphaBar * cos(phi0) - hBar * k * sin(phi2) -
                           (0.5 - a) * alphaBar * k * sin(phi0) +
                           F10 / pi * betaBar * cos(phi1) - F11 /
                           (2 * pi) * betaBar * k * sin(phi1)) -
         2 * imag(C(k)) * (alphaBar * sin(phi0) + hBar * k * cos(phi2) +
                           (0.5 - a) * alphaBar * k * cos(phi0) +
                           F10 / pi * betaBar * sin(phi1) + F11 /
                           (2 * pi) * betaBar * k * cos(phi1)) +
         alphaBar * k * sin(phi0) -
         2.0 / pi * np.sqrt(1 - pow(e, 2.0)) * betaBar * cos(phi1) -
         F4 / pi * betaBar * k * sin(phi1))

    N = (2 * real(C(k)) * (alphaBar * sin(phi0) + hBar * k * cos(phi2) +
                           (0.5 - a) * alphaBar * k * cos(phi0) +
                           F10 / pi * betaBar * sin(phi1) + F11 /
                           (2 * pi) * betaBar * k * cos(phi1)) +
         2 * imag(C(k)) * (alphaBar * cos(phi0) - hBar * k * sin(phi2) -
                           (0.5 - a) * alphaBar * k * sin(phi0) +
                           F10 / pi * betaBar * cos(phi1) - F11 /
                           (2 * pi) * betaBar * k * sin(phi1)) -
         alphaBar * k * cos(phi0) -
         2.0 / pi * np.sqrt(1 - pow(e, 2.0)) * betaBar * sin(phi1) -
         F4 / pi * betaBar * k * cos(phi1))

    # Loop through time steps
    p = (-(pi * alphaDot + pi * hDotDot - pi * a * alphaDotDot - F4 * betaDot -
           F1 * betaDotDot) - 2 * pi * real(C(k)) *
         (alpha + hDot + (0.5 - a) * alphaDot + F10 / pi * beta + F11 /
          (2 * pi) * betaDot) - 2 * pi * imag(C(k)) / k *
         (alphaDot + hDotDot + alphaDotDot + F10 / pi * betaDot + F11 /
          (2 * pi) * betaDotDot))

    pBeta = (-(-F4 * alphaDot - F4 * hDotDot + F9 * alphaDotDot - F5 /
               (2 * pi) * betaDot - F2 /
               (2 * pi) * betaDotDot) - 2 * np.sqrt(1 - pow(e, 2.0)) *
             (0.5 *
              (1 - e) * alphaDot + np.sqrt(1 - pow(e, 2.0)) / pi * beta + F10 /
              (2 * pi) * (1 - e) * betaDot) - 2 * F20 * real(C(k)) *
             (alpha + hDot + (0.5 - a) * alphaDot + F10 / pi * beta + F11 /
              (2 * pi) * betaDot) - 2 * F20 * imag(C(k)) / k *
             (alphaDot + hDotDot +
              (0.5 - a) * alphaDotDot + F10 / pi * betaDot + F11 /
              (2 * pi) * betaDotDot))

    S = (np.sqrt(2.0) / 2.0) * (M * sin(k * s) + N * cos(k * s))

    d = -alpha * p - pi * pow(S, 2.0) - beta * pBeta

    Cl = -p
    Cd = d

    return Cl, Cd, alpha, beta, hDot, s
Example #14
0
    d = -alpha * p - pi * pow(S, 2.0) - beta * pBeta

    Cl = -p
    Cd = d

    return Cl, Cd, alpha, beta, hDot, s


if __name__ == '__main__':
    # Test Theodorsen function.
    if False:
        k = np.linspace(0, 1, 101, True)
        Ck = np.zeros_like(k, complex)
        for kIter in range(k.shape[0]):
            Ck[kIter] = C(k[kIter])
        plt.plot(k, real(Ck), k, imag(Ck))
        plt.grid()
        plt.xlabel('k')
        plt.legend(['Re(C(k))', 'Im(C(k))'])
        plt.show()

    # Test TheoGarr.
    if True:
        alphaBar = 0.0 * pi / 180.0
        betaBar = 0.1 * pi / 180.0
        hBar = 0.0
        phi0 = 0.0 * pi / 180.0
        phi1 = 0.0 * pi / 180.0
        phi2 = 0.0 * pi / 180.0
        a = -0.5
        e = 0.6