Пример #1
0
 def deflections(self, xin, yin):
     from numpy import ones, arctan as atan, arctanh as atanh
     from math import cos, sin, pi
     from numpy import arcsin as asin, arcsinh as asinh
     x, y = self.align_coords(xin, yin)
     q = self.q
     if q == 1.:
         q = 1. - 1e-7  # Avoid divide-by-zero errors
     eps = (1. - q**2)**0.5
     if self.eta == 1.:
         # SIE models
         r = (x**2 + y**2)**0.5
         r[r == 0.] = 1e-9
         xout = self.b * asinh(eps * x / q / r) * q**0.5 / eps
         yout = self.b * asin(eps * y / r) * q**0.5 / eps
     else:
         from powerlaw import powerlawdeflections as pld
         b, eta = self.b, self.eta
         s = 1e-7
         if x.ndim > 1:
             yout, xout = pld(-1 * y.ravel(), x.ravel(), b, eta, s, q)
             xout, yout = xout.reshape(x.shape), -1 * yout.reshape(y.shape)
         else:
             yout, xout = pld(-1 * y, x, b, eta, s, q)
             yout = -1 * yout
     theta = -(self.theta - pi / 2.)
     ctheta = cos(theta)
     stheta = sin(theta)
     x = xout * ctheta + yout * stheta
     y = yout * ctheta - xout * stheta
     return x, y
Пример #2
0
 def deflections(self, xin, yin):
     from numpy import ones, arctan as atan, arctanh as atanh
     from math import cos, sin, pi
     from numpy import arcsin as asin, arcsinh as asinh
     x, y = self.align_coords(xin, yin)
     q = self.q
     if q == 1.:
         q = 1. - 1e-7  # Avoid divide-by-zero errors
     eps = (1. - q**2)**0.5
     if self.eta == 1.:
         # SIE models
         r = (x**2 + y**2)**0.5
         r[r == 0.] = 1e-9
         xout = self.b * asinh(eps * x / q / r) * q**0.5 / eps
         yout = self.b * asin(eps * y / r) * q**0.5 / eps
     else:
         from powerlaw import powerlawdeflections as pld
         b, eta = self.b, self.eta
         s = 1e-7
         if x.ndim > 1:
             yout, xout = pld(-1 * y.ravel(), x.ravel(), b, eta, s, q)
             xout, yout = xout.reshape(x.shape), -1 * yout.reshape(y.shape)
         else:
             yout, xout = pld(-1 * y, x, b, eta, s, q)
             yout = -1 * yout
     theta = -(self.theta - pi / 2.)
     ctheta = cos(theta)
     stheta = sin(theta)
     x = xout * ctheta + yout * stheta
     y = yout * ctheta - xout * stheta
     return x, y
Пример #3
0
def geodetic2isometric(geodetic_lat: ndarray,
                       ell: Ellipsoid = None,
                       deg: bool = True) -> float:
    """
    computes isometric latitude on an ellipsoid


    like Matlab map.geodesy.IsometricLatitudeConverter.forward()

    Parameters
    ----------
    lat : float
         geodetic latitude
    ell : Ellipsoid, optional
         reference ellipsoid (default WGS84)
    deg : bool, optional
         degrees input/output  (False: radians in/out)

    Returns
    -------
    isolat : float
         isometric latiude

    Notes
    -----
    Isometric latitude is an auxiliary latitude proportional to the spacing
    of parallels of latitude on an ellipsoidal mercator projection.
    Based on Deakin, R.E., 2010, 'The Loxodrome on an Ellipsoid', Lecture Notes,
    School of Mathematical and Geospatial Sciences, RMIT University,
    January 2010
    """

    geodetic_lat, ell = sanitize(geodetic_lat, ell, deg)

    e = ell.eccentricity

    isometric_lat = asinh(tan(geodetic_lat)) - e * atanh(e * sin(geodetic_lat))
    # same results
    # a1 = e * sin(geodetic_lat)
    # y = (1 - a1) / (1 + a1)
    # a2 = pi / 4 + geodetic_lat / 2
    # isometric_lat = log(tan(a2) * (y ** (e / 2)))
    # isometric_lat = log(tan(a2)) + e/2 * log((1-e*sin(geodetic_lat)) / (1+e*sin(geodetic_lat)))

    try:
        isometric_lat[abs(geodetic_lat - pi / 2) <= 1e-9] = inf
        isometric_lat[abs(-geodetic_lat - pi / 2) <= 1e-9] = -inf
    except TypeError:
        if abs(geodetic_lat - pi / 2) <= 1e-9:
            isometric_lat = inf
        elif abs(-geodetic_lat - pi / 2) <= 1e-9:
            isometric_lat = -inf

    return degrees(isometric_lat) if deg else isometric_lat
Пример #4
0
    def deflections(self, xin, yin, d=1):
        b = self.b * d
        from numpy import ones, arctan as atan, arctanh as atanh
        from math import cos, sin, pi
        from numpy import arcsin as asin, arcsinh as asinh
        x, y = self.align_coords(xin, yin, False)
        q = self.q
        if q == 1.:
            q = 1. - 1e-7  # Avoid divide-by-zero errors
        eps = (1. - q**2)**0.5
        if self.eta == 1.:
            # SIE models
            r = (x**2 + y**2)**0.5
            r[r == 0.] = 1e-9
            #            xout = self.b*asinh(eps*x/q/r)*q**0.5/eps
            #            yout = self.b*asin(eps*y/r)*q**0.5/eps
            xout = b * asinh(eps * y / q / r) * q**0.5 / eps
            yout = b * asin(eps * -x / r) * q**0.5 / eps
            xout, yout = -yout, xout
            x, y = self.align_coords(xout, yout, False, revert=True)
            return x - self.x, y - self.y

            theta = 2 - self.theta  #-(self.theta - pi/2.)
            ctheta = cos(theta)
            stheta = sin(theta)
            x = xout * ctheta + yout * stheta
            y = yout * ctheta - xout * stheta
            return x, y
        else:
            from powerlaw import powerlawdeflections as pld
            b, eta = b, self.eta
            s = 1e-4
            if x.ndim > 1:
                #                yout,xout = pld(-1*y.ravel(),x.ravel(),b,eta,s,q)
                #                xout,yout = xout.reshape(x.shape),-1*yout.reshape(y.shape)
                xout, yout = pld(x.ravel(), y.ravel(), b, eta, s, q)
                xout, yout = xout.reshape(x.shape), yout.reshape(y.shape)
            else:
                xout, yout = pld(x, y, b, eta, s, q)


#                yout,xout = pld(-1*y,x,b,eta,s,q)
#                yout = -1*yout
#        theta = -(self.theta - pi/2.)
#        ctheta = cos(theta)
#        stheta = sin(theta)
#        x = xout*ctheta+yout*stheta
#        y = yout*ctheta-xout*stheta
#        return x,y
        x, y = self.align_coords(xout, yout, False, revert=True)
        return x - self.x, y - self.y
Пример #5
0
def geodetic2isometric_point(geodetic_lat: float,
                             ell: Ellipsoid = None,
                             deg: bool = True) -> float:
    geodetic_lat, ell = sanitize(geodetic_lat, ell, deg)

    e = ell.eccentricity

    if abs(geodetic_lat - pi / 2) <= 1e-9:
        isometric_lat = inf
    elif abs(-geodetic_lat - pi / 2) <= 1e-9:
        isometric_lat = -inf
    else:
        isometric_lat = asinh(
            tan(geodetic_lat)) - e * atanh(e * sin(geodetic_lat))
        # same results
        # a1 = e * sin(geodetic_lat)
        # y = (1 - a1) / (1 + a1)
        # a2 = pi / 4 + geodetic_lat / 2
        # isometric_lat = log(tan(a2) * (y ** (e / 2)))
        # isometric_lat = log(tan(a2)) + e/2 * log((1-e*sin(geodetic_lat)) / (1+e*sin(geodetic_lat)))

    return degrees(isometric_lat) if deg else isometric_lat
Пример #6
0
 def caustic(self):
     if self.eta != 1:
         return None, None
     from numpy import ones, arctan as atan, arctanh as atanh
     from numpy import cos, sin, pi, linspace
     from numpy import arcsin as asin, arcsinh as asinh
     q = self.q
     if q == 1.:
         q = 1. - 1e-7  # Avoid divide-by-zero errors
     eps = (1. - q**2)**0.5
     theta = linspace(0, 2 * pi, 5000)
     ctheta = cos(theta)
     stheta = sin(theta)
     delta = (ctheta**2 + q**2 * stheta**2)**0.5
     xout = ctheta * q**0.5 / delta - asinh(eps * ctheta / q) * q**0.5 / eps
     yout = stheta * q**0.5 / delta - asin(eps * stheta) * q**0.5 / eps
     xout, yout = xout * self.b, yout * self.b
     theta = -(self.theta - pi / 2.)
     ctheta = cos(theta)
     stheta = sin(theta)
     x = xout * ctheta + yout * stheta
     y = yout * ctheta - xout * stheta
     return x + self.x, y + self.y
Пример #7
0
 def caustic(self):
     if self.eta != 1:
         return None, None
     from numpy import ones, arctan as atan, arctanh as atanh
     from numpy import cos, sin, pi, linspace
     from numpy import arcsin as asin, arcsinh as asinh
     q = self.q
     if q == 1.:
         q = 1. - 1e-7  # Avoid divide-by-zero errors
     eps = (1. - q**2)**0.5
     theta = linspace(0, 2 * pi, 5000)
     ctheta = cos(theta)
     stheta = sin(theta)
     delta = (ctheta**2 + q**2 * stheta**2)**0.5
     xout = ctheta * q**0.5 / delta - asinh(eps * ctheta / q) * q**0.5 / eps
     yout = stheta * q**0.5 / delta - asin(eps * stheta) * q**0.5 / eps
     xout, yout = xout * self.b, yout * self.b
     theta = -(self.theta - pi / 2.)
     ctheta = cos(theta)
     stheta = sin(theta)
     x = xout * ctheta + yout * stheta
     y = yout * ctheta - xout * stheta
     return x + self.x, y + self.y
Пример #8
0
    def test_unary_fun(self):

        import math

        data = [1., 2., 3.]
        c = np.array(data)

        d = np.acos(c / 3)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.acos(data[i] / 3))

        d = np.asin(c / 3)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.asin(data[i] / 3))

        d = np.atan(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.atan(data[i]))

        d = np.sin(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.sin(data[i]))

        d = np.cos(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.cos(data[i]))

        d = np.tan(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.tan(data[i]))

        d = np.acosh(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.acosh(data[i]))

        d = np.asinh(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.asinh(data[i]))

        d = np.atanh(c / 3.1)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.atanh(data[i] / 3.1))

        d = np.sinh(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.sinh(data[i]))

        d = np.cosh(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.cosh(data[i]))

        d = np.tanh(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.tanh(data[i]))

        d = np.ceil(c * 2.7)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.ceil(data[i] * 2.7))

        d = np.floor(c * 2.7)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.floor(data[i] * 2.7))

        d = np.erf(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.erf(data[i]))

        d = np.erfc(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.erfc(data[i]))

        d = np.exp(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.exp(data[i]))

        d = np.expm1(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.expm1(data[i]))

        d = np.gamma(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.gamma(data[i]))

        d = np.lgamma(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.lgamma(data[i]))

        d = np.log(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.log(data[i]))

        d = np.log10(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.log10(data[i]))

        d = np.log2(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.log2(data[i]))

        d = np.sqrt(c)
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.sqrt(data[i]))

        # slices
        data = [1., 2., 3.]
        c = np.array(data + data)

        d = np.cos(c[::2])
        mm = data + data
        for i, ei in enumerate(d):
            self.assertEqual(ei, math.cos(mm[2 * i]))

        # 2d array
        data = [1., 2., 3.]
        c = np.array([data, data])

        d = np.cos(c)
        mm = [data, data]
        for i, ei in enumerate(d):
            for j, eij in enumerate(ei):
                self.assertEqual(eij, math.cos(mm[i][j]))

        # 2d array slices
        data = [1., 2., 3.]
        c = np.array([data + data, data + data])

        d = np.cos(c[:, ::2])
        mm = [data + data, data + data]
        for i, ei in enumerate(d):
            for j, eij in enumerate(ei):
                self.assertEqual(eij, math.cos(mm[i][2 * j]))
Пример #9
0
def rsf_mu(dic):
    #Tt=Tn*mu
    #
    mu = 0
    kind = (dic["kind"])
    v = (dic["V"])
    Dc = (dic["Dc"])
    theta = (dic["theta"])
    mus = (dic["MuS"])
    a = (dic["a"])
    b = (dic["b"])
    Vstar = (dic["Vstar"])
    Vc = (dic["Vc"])
    tn = float((dic["Tn"]))
    if type(dic["theta"]) != list:  #si theta is scalaire
        theta = dic["theta"][0]
        if kind == 1:
            mu = mus + a * abs(v) / (abs(v) + Vstar) - b * theta / (
                theta + Dc
            )  #Strong velocity-weakening at high speed  as in Ampuero and Ben-Zion
        elif kind == 2 or kind == 3:
            mu = a * np.arcsinh(
                abs(v) / (2 * Vstar) * np.exp(
                    (mus + b * np.log(Vstar * theta / Dc)) / a)
            )  #Kaneko et al. (2008) Eq. 15 (regularize at v=0 as per Laupsta et al. (2000))
        elif kind == 4:
            mu = a * np.asinh(
                abs(v) / (2 * Vstar) * np.exp(
                    (mus + b * np.log(Vc * theta / Dc + 1)) / a))
        dic['Tt'] = -tn * mu
    else:  #theta is vecteur
        if type(Dc) != list:  #si Dc scalaire,theta is vecteur
            i = -1
            theta = dic["theta"][dic["thetaXn"] - 1:]
            mu = [0] * (len(theta))
            tt0 = [0] * (len(theta))
            dic['Tt'] = [0] * (len(theta) + dic['thetaXn'] - 1)
            dic['Tt'][0:dic['thetaXn']] = dic['theta'][0:dic['thetaXn']]
            for t in theta:
                i = i + 1
                if kind == 1:
                    mu[i] = mus + a * abs(v) / (abs(v) + Vstar) - b * t / (t +
                                                                           Dc)
                elif kind == 2 or kind == 3:
                    mu[i] = a * np.arcsinh(
                        abs(v) / (2 * Vstar) * np.exp(
                            (mus + b * np.log(Vstar * t / Dc)) / a))
                elif kind == 4:
                    mu[i] = a * np.arcsinh(
                        abs(v) / (2 * Vstar) * np.exp(
                            (mus + b * np.log(Vc * t / Dc + 1)) / a))
                tt0[i] = -tn * mu[i]
            dic['Tt'][dic["TtXn"] - 1:] = tt0
        elif len(Dc) == len(
                theta):  #si Dc ,theta is vecteur et sont de meme taille
            i = -1
            theta = dic["theta"][dic["thetaXn"] - 1:]
            Dc = dic["Dc"][dic["thetaXn"] - 1:]  #on definit en plus les Dci
            mu = [0] * (len(theta))
            tt0 = [0] * (len(theta))
            dic['Tt'] = [0] * (len(theta) + dic['thetaXn'] - 1)
            dic['Tt'][0:dic['thetaXn']] = dic['theta'][0:dic['thetaXn']]
            for t, dc in zip(theta, Dc):
                i = i + 1
                if kind == 1:
                    mu[i] = mus + a * abs(v) / (abs(v) + Vstar) - b * t / (t +
                                                                           dc)
                elif kind == 2 or kind == 3:
                    mu[i] = a * np.arcsinh(
                        abs(v) / (2 * Vstar) * np.exp(
                            (mus + b * np.log(Vstar * t / dc)) / a))
                elif kind == 4:
                    mu[i] = a * np.arcsinh(
                        abs(v) / (2 * Vstar) * np.exp(
                            (mus + b * np.log(Vc * t / dc + 1)) / a))
                tt0[i] = -tn * mu[i]
            dic['Tt'][dic["TtXn"] - 1:] = tt0
        else:
            print('problemme rsf_mu')
    return dic
Пример #10
0
    def ejecutar_trigo(self, funcion):
        if funcion.funcion == 'acos':
            try:

                return np.acos(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en acos ')
                return 0
        elif funcion.funcion == 'acosd':
            try:
                return np.acosd(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en acosd ')
                return 0
        elif funcion.funcion == 'asin':
            try:
                return np.asin(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en asin ')
                return 0
        elif funcion.funcion == 'asind':
            try:
                return np.asind(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en asind ')
                return 0
        elif funcion.funcion == 'atan':
            try:
                return np.atan(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores ')
                return 0
        elif funcion.funcion == 'atand':
            try:
                return np.atand(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores atand ')
                return 0
        elif funcion.funcion == 'atan2':
            try:
                return np.atan2(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en atan2 ')
                return 0
        elif funcion.funcion == 'cos':
            try:
                return np.cos(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en cos ')
                return 0
        elif funcion.funcion == 'cosd':
            try:
                return np.cosd(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores cosd cosd')
                return 0
        elif funcion.funcion == 'cot':
            try:
                return np.cot(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores cot')
                return 0
        elif funcion.funcion == 'cotd':
            try:
                return np.cotd(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en cotd ')
                return 0
        elif funcion.funcion == 'sin':
            try:
                return np.sin(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en sin ')
                return 0
        elif funcion.funcion == 'sind':
            try:
                return np.sind(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en sind ')
                return 0
        elif funcion.funcion == 'tan':
            try:
                return np.tan(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en tan ')
                return 0
        elif funcion.funcion == 'tand':
            try:
                return np.tand(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en tand')
                return 0
        elif funcion.funcion == 'sinh':
            try:
                return np.sinh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en sinh')
                return 0
        elif funcion.funcion == 'cosh':
            try:
                return np.cosh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en cosh ')
                return 0
        elif funcion.funcion == 'tanh':
            try:
                return np.tanh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en tanh ')
                return 0
        elif funcion.funcion == 'asinh':
            try:
                return np.asinh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en asinh')
                return 0
        elif funcion.funcion == 'acosh':
            try:
                return np.acosh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en acosh ')
                return 0
        elif funcion.funcion == 'atanh':
            try:
                return np.atanh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en atanh ')
                return 0
Пример #11
0
    def setup(self):
        delta = self.delta * pi / 180.0
        n = self.nPts

        # Set up theta evenly spaced (cosine clustering in x)
        theta = np.linspace(-pi, pi, n)

        # Compute x values along camber line
        s = 0.5 * (1.0 - cos(theta))

        # Compute nodal x and y coordinates for a symmetric airfoil
        t = float(self.naca[-2:]) * 0.01
        yt = 5.0 * t * (0.2969 * sqrt(s) - 0.1260 * s - 0.3516 * s**2 +
                        0.2843 * s**3 - 0.1015 * s**4) * sign(theta)

        # Get the max camber and location of max camber
        m = 0.01 * float(self.naca[0])  # Maximum camber (% chord)
        p = 0.1 * float(self.naca[1])  # Location of maximum chamber (% chord)

        # Compute x and y coordinates for a cambered airfoil
        ycamber = np.zeros(n)
        dydx = np.zeros(n)
        xcamber = np.copy(s)

        xf = self.xf
        yf = self.yf
        #Find vertical hinge point if not given
        if (yf == -100.0):
            if xf < p:
                yf = m / p**2 * (2.0 * p * xf - xf**2)
            else:
                yf = m / (1.0 - p)**2 * (1.0 - 2.0 * p + 2.0 * p * xf - xf**2)

        self.yf = yf
        #print("xf,yf = ",xf,yf)
        #Calculate camber line and slope
        for i in range(n):
            # Leading-edge Geometry
            if s[i] < p:
                ycamber[i] = m / p**2 * (2.0 * p * s[i] - s[i]**2)
                dydx[i] = 2.0 * m / p**2 * (p - s[i])
            # Trailing-edge Geometry
            else:
                ycamber[i] = m / (1.0 - p)**2 * (1.0 - 2.0 * p +
                                                 2.0 * p * s[i] - s[i]**2)
                dydx[i] = 2.0 * m / (1.0 - p)**2 * (p - s[i])

            #Flap Settings offset yc and dydx
            if ((s[i] > xf) and (self.flapType > 0) and (delta != 0.0)):
                if (self.flapType == 1):  #Traditional Flap
                    r = sqrt((ycamber[i] - yf)**2 + (s[i] - xf)**2)
                    psi = atan((ycamber[i] - yf) / (s[i] - xf))
                    xcamber[i] = xf + r * cos(delta - psi)
                    ycamber[i] = yf - r * sin(delta - psi)
                    dydx[i] = (dydx[i] - tan(delta)) / (1 +
                                                        dydx[i] * tan(delta))
                if (self.flapType == 2):  #Parabolic Flap
                    length = sqrt(yf**2 + (1 - xf)**2)
                    ghi = -atan(yf / (1 - xf))
                    R = sqrt(4 * tan(delta)**2 +
                             1) + asinh(2 * tan(delta)) / 2.0 / tan(delta)
                    #                    if(delta<0.01):
                    #                        R = 1.0+sqrt(4*delta**2+1.0)
                    xite = 2 * length / R
                    etate = -2 * length / R * tan(delta)
                    xio = (xcamber[i] - xf) * length / (1 - xf)
                    xip = opt.newton(self.f_eq_28,
                                     xite * xio / length,
                                     fprime=None,
                                     args=(xio, length, R, delta),
                                     tol=1.0e-12,
                                     maxiter=50,
                                     fprime2=None)
                    etap = -xip**2 / xite * tan(delta)
                    detadxi = -2 * xip / xite * tan(delta)
                    xp = xf + xip * cos(ghi) - etap * sin(ghi)
                    yp = yf + xip * sin(ghi) + etap * cos(ghi)
                    yo = yf * (1 - xio / length)
                    dyc = ycamber[i] - yo
                    xcamber[i] = xp + dyc * sin(
                        atan(2 * xip / xite * tan(delta)))
                    ycamber[i] = yp + dyc * cos(
                        atan(2 * xip / xite * tan(delta)))
                    dydx[i] = (dydx[i] - 2 * xip * tan(delta) / xite) / (
                        1 + 2 * xip * tan(delta) / xite * dydx[i])

        # Add thickness offset to camber location for airfoil surface
        angle = atan(dydx)
        self.x = xcamber - yt * sin(angle)
        self.y = ycamber + yt * cos(angle)
        self.theta = theta
        self.xcamber = xcamber
        self.ycamber = ycamber
        self.dydx = dydx
Пример #12
0
 def f_eq_28(self, x, xio, length, R, delta):
     return -xio + x / 2.0 * sqrt(
         (x / length * R * tan(delta))**2 + 1) + length * asinh(
             x * R * tan(delta) / length) / (2 * R * tan(delta))
Пример #13
0
    def caustic(self):
        if self.eta != 1:
            from powerlaw import powerlawmag as plm, powerlawdeflections as pld
            import numpy
            from scipy import interpolate
            q = self.q
            b, eta = self.b, self.eta
            gam = eta * 0.5
            q0 = (1.0 - gam) * b**(2.0 * gam) / (q**gam)
            r = numpy.linspace(q0 / 2., q0 * 2, 100)
            x0, y0, mag = plm(r, r * 0., b, eta, 1e-4, q)
            if mag[0] > 0:
                r = numpy.linspace(1e-7, q0 * 2, 200)
                x0, y0, mag = plm(r, r * 0., b, eta, 1e-4, q)
            while mag[-1] < 0:
                q0 *= 2
                r = numpy.linspace(q0 / 2., q0 * 2, 100)
                x0, y0, mag = plm(r, r * 0., b, eta, 1e-4, q)
            tmp = interpolate.splrep(r, mag)
            root = interpolate.sproot(tmp, 1)[0]

            theta = numpy.linspace(0, numpy.pi / 2, 500)
            ctheta = numpy.cos(theta)
            stheta = numpy.sin(theta)
            rvals = theta * 0. + root
            for i in range(1, theta.size):
                r = numpy.linspace(root * 0.9, root * 1.1, 20)
                x = r * ctheta[i]
                y = r * stheta[i]
                x0, y0, mag = plm(x, y, b, eta, 1e-4, q)
                while mag[0] > 0:
                    root *= 0.9
                    r = numpy.linspace(root * 0.9, root * 1.1, 20)
                    x = r * ctheta[i]
                    y = r * stheta[i]
                    x0, y0, mag = plm(x, y, b, eta, 1e-4, q)
                while mag[-1] < 0:
                    root *= 1.1
                    r = numpy.linspace(root * 0.9, root * 1.1, 20)
                    x = r * ctheta[i]
                    y = r * stheta[i]
                    x0, y0, mag = plm(x, y, b, eta, 1e-4, q)
                tmp = interpolate.splrep(r, mag)
                root = interpolate.sproot(tmp, 1)[0]
                rvals[i] = root
            x, y = rvals * ctheta, rvals * stheta
            x = numpy.concatenate(
                (x, -1 * x[::-1][1:], -1 * x[1:], x[::-1][1:]))
            y = numpy.concatenate(
                (y, y[::-1][1:], -1 * y[1:], -1 * y[::-1][1:]))
            x0, y0 = pld(x, y, b, eta, 1e-4, q)
            x0, y0 = self.align_coords(x - x0, y - y0, False, revert=True)
            return x0, y0
        from numpy import ones, arctan as atan, arctanh as atanh
        from numpy import cos, sin, pi, linspace
        from numpy import arcsin as asin, arcsinh as asinh
        q = self.q
        if q == 1.:
            q = 1. - 1e-7  # Avoid divide-by-zero errors
        eps = (1. - q**2)**0.5
        theta = linspace(0, 2 * pi, 5000)
        ctheta = cos(theta)
        stheta = sin(theta)
        delta = (ctheta**2 + q**2 * stheta**2)**0.5
        xout = ctheta * q**0.5 / delta - asinh(eps * ctheta / q) * q**0.5 / eps
        yout = stheta * q**0.5 / delta - asin(eps * stheta) * q**0.5 / eps
        xout, yout = xout * self.b, yout * self.b
        theta = -(self.theta - pi / 2.)
        ctheta = cos(theta)
        stheta = sin(theta)
        x = xout * ctheta + yout * stheta
        y = yout * ctheta - xout * stheta
        return x + self.x, y + self.y
Пример #14
0
 def asinh(self):
     rst = self.ensureVector(np.asinh(self))
     rst = self.setGradFn(rst, "asinh")
     return rst
Пример #15
0
def asinh(x: Number = 0.0) -> Number:
    return np.asinh(x)