示例#1
0
    def __init__(self, left, right):
        self.left = left
        self.right = right
        import math
        u1 = left[0]
        u2 = right[0]
        # r1 = left[1];
        # r2 = right[1]
        T1 = left[1]
        T2 = right[1]
        p1 = left[2]
        p2 = right[2]
        # T1 = p1 / r1 / Rg();
        # T2 = p2 / r2 / Rg()
        r1 = p1 / Rg() / T1
        r2 = p2 / Rg() / T2
        k1 = k_Justi(T1)
        k2 = k_Justi(T2)
        a1 = math.sqrt(k1 * p1 / r1)
        a2 = math.sqrt(k2 * p2 / r2)

        print("-" * 100)
        print("{0:^50}|{1:^50}".format("ul=%.5gm/s" % u1, "ur=%.5gm/s" % u2))
        print("{0:^50}|{1:^50}".format("rhol=%.5gkg/m^3" % r1,
                                       "rhor=%.5gkg/m^3" % r2))
        print("{0:^50}|{1:^50}".format("pl=%sPa" % p1, "pr=%sPa" % p2))
        print("{0:^50}|{1:^50}".format("Tl=%sK" % T1, "Tr=%sK" % T2))
        print("-" * 100)
示例#2
0
def openEnd(p, p0=1.e5, T0=300, R=None, k=None):
    from GasProperty import k_Justi, Rg
    from math import sqrt
    if R is None:
        R = Rg()
    if k is None:
        k = k_Justi(T0)
    return sqrt(2 * k * R * T0 / (k - 1) * (1 - pow(p / p0, (k - 1) / k)))
示例#3
0
def openEnd2(u, p0=1.e5, T0=300, R=None, k=None):
    from GasProperty import k_Justi, Rg
    from math import sqrt
    if R is None:
        R = Rg()
    if k is None:
        k = k_Justi(T0)
    temp = 2 * k * R * T0 / (k - 1)
    temp2 = 1 - u ** 2 / temp
    return p0 * pow(temp2, k / (k - 1))
示例#4
0
    def airFlowExample(self, p1, T1, p2=None, T2=None, K2=None):
        from GasProperty import Rg, k_Justi
        R1 = Rg(T1)
        R2 = Rg(T2)
        k1 = k_Justi(T1)
        k2 = k_Justi(T2)
        step = 1.e-3 * p1
        import numpy as np
        for i in np.arange(0, p1, step):
            self.data.append([i / p1, self.__massFlowRate(p1, T1, R1, k1, i)])

        if p2 is not None and T2 is not None:
            step2 = 0.01 * p2
            for i in np.arange(0.5 * p2, p2, step):
                self.data.append([
                    p2 / i,
                    self.__massFlowRate(i, T1, R1, k1, p2, T2, R2, K2)
                ])

        return self.data
示例#5
0
def eqnozzle(p, u, p0=1.e5, T0=300, phi=1, R=None, k=None):
    from GasProperty import k_Justi, Rg
    from math import sqrt
    if R is None:
        R = Rg()
    if k is None:
        k = k_Justi(T0)
    temp = 2 * k * R * T0 / (k - 1)
    temp2 = pow(p / p0, (k - 1) / k) - 1
    temp3 = 1 / pow(phi, 2) * pow(p / p0, 2. / k) - 1
    # return u ** 2 * temp3 - temp * temp2
    return u ** 2 - temp * temp2*temp3
示例#6
0
def nozzle(p, p0=1.e5, T0=300, phi=0.5, R=None, k=None):
    from GasProperty import k_Justi, Rg
    from math import sqrt
    if R is None:
        R = Rg()
    if k is None:
        k = k_Justi(T0)
    temp = 2 * k * R * T0 / (k - 1)
    temp2 = pow(p / p0, (k - 1) / k) - 1
    temp3 = 1 / pow(phi, 2) * pow(p / p0, 2. / k) - 1

    return sqrt(temp * temp2 / temp3)
示例#7
0
def nozzle2(u, p0=1.e5, T0=300, phi=0.9, R=None, k=None):
    from GasProperty import k_Justi, Rg
    if R is None:
        R = Rg()
    if k is None:
        k = k_Justi(T0)
    pinit = 1.1 * p0

    def fun(p):
        # return nozzle(p,p0,T0,phi,R,k)-u
        return eqnozzle(p, u, p0, T0, phi, R, k)

    h = p0 / 1.e4
    # print(fun(pinit))
    while abs(fun(pinit)) > 1.e-5:
        # print(fun(pinit))
        # print(fun(pinit+h)-fun(pinit-h))
        pinit -= fun(pinit) / ((fun(pinit + h) - fun(pinit - h)) / 2. / h)

    return pinit
示例#8
0
    def solve(self, U=None, A=1, AFAK=1.e8):
        from GasProperty import Rg
        from GasProperty import k_Justi
        if U is None:
            U = self.U
        else:
            self.U = U

        self.rho = U[0] / A
        self.u = U[1] / U[0]
        self.e = U[2] / U[0] - 1. / 2. * pow(U[1] / U[0], 2)
        T = self.e * (1.4 - 1.) / Rg(AFAK)

        # def kite(T):
        #     return self.e - Rg(AFAK) * T / (k_Justi(T, AFAK) - 1)
        #
        # h = 1.
        # while abs(kite(T)) > 1.e-5:
        #     T -= kite(T) / ((kite(T + h) - kite(T - h)) / 2. / h)
        self.T = T
        self.k = k_Justi(T, AFAK)
        self.p = Rg(AFAK) * T * self.rho
示例#9
0
def AnalyticalSolution(t, left=[], right=[], xlim=None):
    import math
    u1 = left[0]
    u2 = right[0]
    # r1 = left[1];
    # r2 = right[1]
    T1 = left[1]
    T2 = right[1]
    p1 = left[2]
    p2 = right[2]
    # T1 = p1 / r1 / Rg();
    # T2 = p2 / r2 / Rg()
    r1 = p1 / Rg() / T1
    r2 = p2 / Rg() / T2
    k1 = k_Justi(T1)
    k2 = k_Justi(T2)
    a1 = math.sqrt(k1 * p1 / r1)
    a2 = math.sqrt(k2 * p2 / r2)

    # print("-" * 100)
    # print("{0:^50}|{1:^50}".format("ul=%.5gm/s" % u1, "ur=%.5gm/s" % u2))
    # print("{0:^50}|{1:^50}".format("rhol=%.5gkg/m^3" % r1, "rhor=%.5gkg/m^3" % r2))
    # print("{0:^50}|{1:^50}".format("pl=%sPa" % p1, "pr=%sPa" % p2))
    # print("{0:^50}|{1:^50}".format("Tl=%sK" % T1, "Tr=%sK" % T2))
    # print("-" * 100)

    def function(pbar, pj, rhoj, gamma=1.4):
        if pbar == pj:
            return 0
        elif pbar > pj:
            import math
            aj = math.sqrt(gamma * pj / rhoj)
            return (pbar - pj) / rhoj / aj / math.sqrt(
                (gamma + 1) / 2. / gamma * pbar / pj +
                (gamma - 1) / 2. / gamma)
        elif pbar < pj:
            import math
            aj = math.sqrt(gamma * pj / rhoj)
            return 2. * aj / (gamma - 1.) * (pow(pbar / pj,
                                                 (gamma - 1) / 2. / gamma) - 1)

    def F(p):
        return function(p, p1, r1, k1) + function(p, p2, r2, k2)

    pbar = (p1 + p2) / 2
    h = 10.
    while abs(u1 - u2 - F(pbar)) > 1.e-5:
        pbar -= (u1 - u2 - F(pbar)) / ((-F(pbar + h) + F(pbar - h)) / 2. / h)
    # print(pbar)
    ubar = (u1 + u2 - function(pbar, p1, r1, k1) +
            function(pbar, p2, r2, k2)) / 2.
    # print(ubar)

    A1 = r1 * a1 * math.sqrt((k1 + 1.) / (2. * k1) * pbar / p1 +
                             (k1 - 1) / 2. / k1)
    A2 = r2 * a2 * math.sqrt((k2 + 1.) / (2. * k2) * pbar / p2 +
                             (k2 - 1) / 2. / k2)

    if pbar >= p1:
        Z1 = u1 - A1 / r1
    else:
        Z1 = u1 - a1

    if pbar >= p2:
        Z2 = u2 + A2 / r2
    else:
        Z2 = u2 + a2

    if pbar >= p1:
        Z1star = Z1
    elif pbar > 0:
        a1star = a1 + (k1 - 1) / 2. * (u1 - ubar)
        Z1star = ubar - a1star
    else:
        Z1star = u1 - 2. * a1 / (k1 - 1)

    if pbar >= p2:
        Z2star = Z2
    elif pbar > 0:
        a2star = a2 - (k2 - 1) / 2. * (u2 - ubar)
        Z2star = ubar + a2star
    else:
        Z2star = u2 + 2 * a2 / (k2 - 1)

    r1bar = r1 * A1 / (A1 - r1 * (u1 - ubar))
    r2bar = r2 * A2 / (A2 + r2 * (u2 - ubar))

    # print("Z1=", Z1)
    # print("Z1star=", Z1star)
    # print("ubar=", ubar)
    # print("Z2star=", Z2star)
    # print("Z2=", Z2)

    if xlim is None:
        Zlaggest = abs(Z1) if abs(Z1) > abs(Z2) else abs(Z2)
        xlim = [-1.5 * t * Zlaggest, 1.5 * t * Zlaggest]

    # print("Will draw air state between [{},{}]".format(xlim[0],xlim[1]))

    def fun(t, x):
        if x / t > Z2:
            return u2, r2, p2
        elif x / t < Z1:
            return u1, r1, p1
        elif Z1star < x / t < ubar:
            return ubar, r1bar, pbar
        elif ubar < x / t < Z2star:
            return ubar, r2bar, pbar
        elif Z1 < x / t < Z1star:
            a = (k1 - 1) / (k1 + 1) * (u1 - x / t) + 2 * a1 / (k1 + 1)
            u = x / t + a
            p = p1 * pow(a / a1, 2 * k1 / (k1 - 1))
            r = k1 * p / a / a
            return u, r, p
        elif Z2star < x / t < Z2:
            a = (k2 - 1) / (k2 + 1) * (x / t - u2) + 2 * a2 / (k2 - 1)
            u = x / t - a
            p = p2 * pow(a / a2, 2 * k2 / (k2 - 1))
            r = k2 * p / a / a
            return u, r, p

    result = ArrayTable(5, 0)
    result.setTableHeader(
        ["x", "Velocity", "Density", "Pressure", "Temperature"])
    result.setTableUnit(["m", "m/s", "kg/m^3", "Pa", "K"])
    import numpy as np
    step = (xlim[1] - xlim[0]) / 1000.
    xx = np.arange(xlim[0], xlim[1], step)
    for each in xx:
        u, r, p = fun(t, each)
        result.append([each, u, r, p, p / r / Rg()])
    return result
示例#10
0
 def fun(pt):
     Rge=Rg(setting["过量空气系数"])
     k=k_Justi(Tt,setting["过量空气系数"])
     temp=setting["涡轮当量流通面积,m^2"]*flowUnitArea(pt,Tt,Rge,k,Pt0)
     print("涡前压力{},流量{}".format(pt,temp))
     return (temp-ma)/ma