Ejemplo n.º 1
0
def ainslie_full(nj, ni, h, k, u0=8.5, ct=ct_v90(u0), i0=8.0):
    star = time()
    nj += 1
    ni += 1
    Dmi = ct - 0.05 - (16.0 * ct - 0.5) * i0 / 1000.0

    u = [[0.0 for _ in range(ni)]]
    v = [[0.0 for _ in range(ni)] for _ in range(nj)]

    for g in range(ni):
        u[0][g] = u0 * (1.0 - Dmi * exp(- 3.56 * float(g * h) ** 2.0 / b(Dmi, ct) ** 2.0))

    for j in range(1, nj):
        # start = time()
        A = []
        B = []
        C = []
        R = []

        i = 0

        A.append(- k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct))
        B.append(2.0 * (h ** 2.0 * u[j-1][i] + k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct)))
        C.append(- k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct))
        R.append(k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct) * (2.0 * u[j-1][i+1] - 2.0 * u[j-1][i]) + 2.0 * h ** 2.0 * u[j-1][i] ** 2.0)

        for i in range(1, ni):

            #  Uncomment if v is not neglected. Radial velocity.
            if j == 1:
                v[j][i] = (i * h) / ((i * h) + h) * (v[j-1][i-1] - h / k * (u[j-1][i] - u[0][i]))
            elif j > 1:
                v[j][i] = (i * h) / ((i * h) + h) * (v[j-1][i-1] - h / k * (u[j-1][i] - u[j-2][i]))

            A.append(k * (h * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct) - (i * h) * h * v[j][i] - 2.0 * (i * h) * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct)))
            B.append(4.0 * (i * h) * (h ** 2.0 * u[j-1][i] + k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct)))
            C.append(k * ((i * h) * h * v[j][i] - 2.0 * (i * h) * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct) - h * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct)))
            if i < ni - 1:
                R.append(h * k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct) * (u[j-1][i+1] - u[j-1][i-1]) + 2.0 * k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct) * (i * h) * (u[j-1][i+1] - 2.0 * u[j-1][i] + u[j-1][i-1]) - (i * h) * h * k * v[j-1][i] * (u[j-1][i+1] - u[j-1][i-1]) + 4.0 * (i * h) * h ** 2.0 * u[j-1][i] ** 2.0)
            elif i == ni - 1:
                R.append(h * k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct) * (u0 - u[j-1][i-1]) + 2.0 * k * E(j * k, u[j-1][i], (u0 - u[j-1][i]) / u0, u0, i0, ct) * (i * h) * (u0 - 2.0 * u[j-1][i] + u[j-1][i-1]) - (i * h) * h * k * v[j-1][i] * (u0 - u[j-1][i-1]) + 4.0 * (i * h) * h ** 2.0 * u[j-1][i] ** 2.0)

        # print time() - start

        C[0] += A[0]
        del A[0]
        R[-1] -= C[-1] * u0
        del C[-1]
        # start3 = time()
        u.append(thomas(A, B, C, R))
        # print time() - start3
    print time() - star,
    print 's'
    print u[-1][0]
    return u
Ejemplo n.º 2
0
def Ct(U0):
    # return ct_bladed(U0)
    return ct_v90(U0)
Ejemplo n.º 3
0
def ainslie_full(nj, ni, h, k, u0=8.5, ct=ct_v90(u0), i0=8.0):
    star = time()
    nj += 1
    ni += 1
    Dmi = ct - 0.05 - (16.0 * ct - 0.5) * i0 / 1000.0

    u = [[0.0 for _ in range(ni)]]
    v = [[0.0 for _ in range(ni)] for _ in range(nj)]

    for g in range(ni):
        u[0][g] = u0 * (1.0 -
                        Dmi * exp(-3.56 * float(g * h)**2.0 / b(Dmi, ct)**2.0))

    for j in range(1, nj):
        # start = time()
        A = []
        B = []
        C = []
        R = []

        i = 0

        A.append(-k * E(j * k, u[j - 1][i],
                        (u0 - u[j - 1][i]) / u0, u0, i0, ct))
        B.append(2.0 * (h**2.0 * u[j - 1][i] +
                        k * E(j * k, u[j - 1][i],
                              (u0 - u[j - 1][i]) / u0, u0, i0, ct)))
        C.append(-k * E(j * k, u[j - 1][i],
                        (u0 - u[j - 1][i]) / u0, u0, i0, ct))
        R.append(k *
                 E(j * k, u[j - 1][i], (u0 - u[j - 1][i]) / u0, u0, i0, ct) *
                 (2.0 * u[j - 1][i + 1] - 2.0 * u[j - 1][i]) +
                 2.0 * h**2.0 * u[j - 1][i]**2.0)

        for i in range(1, ni):

            #  Uncomment if v is not neglected. Radial velocity.
            if j == 1:
                v[j][i] = (i * h) / ((i * h) + h) * (v[j - 1][i - 1] - h / k *
                                                     (u[j - 1][i] - u[0][i]))
            elif j > 1:
                v[j][i] = (i * h) / (
                    (i * h) + h) * (v[j - 1][i - 1] - h / k *
                                    (u[j - 1][i] - u[j - 2][i]))

            A.append(k * (h * E(j * k, u[j - 1][i],
                                (u0 - u[j - 1][i]) / u0, u0, i0, ct) -
                          (i * h) * h * v[j][i] - 2.0 *
                          (i * h) * E(j * k, u[j - 1][i],
                                      (u0 - u[j - 1][i]) / u0, u0, i0, ct)))
            B.append(4.0 * (i * h) *
                     (h**2.0 * u[j - 1][i] +
                      k * E(j * k, u[j - 1][i],
                            (u0 - u[j - 1][i]) / u0, u0, i0, ct)))
            C.append(k * ((i * h) * h * v[j][i] - 2.0 *
                          (i * h) * E(j * k, u[j - 1][i],
                                      (u0 - u[j - 1][i]) / u0, u0, i0, ct) -
                          h * E(j * k, u[j - 1][i],
                                (u0 - u[j - 1][i]) / u0, u0, i0, ct)))
            if i < ni - 1:
                R.append(
                    h * k * E(j * k, u[j - 1][i],
                              (u0 - u[j - 1][i]) / u0, u0, i0, ct) *
                    (u[j - 1][i + 1] - u[j - 1][i - 1]) +
                    2.0 * k * E(j * k, u[j - 1][i],
                                (u0 - u[j - 1][i]) / u0, u0, i0, ct) *
                    (i * h) *
                    (u[j - 1][i + 1] - 2.0 * u[j - 1][i] + u[j - 1][i - 1]) -
                    (i * h) * h * k * v[j - 1][i] *
                    (u[j - 1][i + 1] - u[j - 1][i - 1]) + 4.0 *
                    (i * h) * h**2.0 * u[j - 1][i]**2.0)
            elif i == ni - 1:
                R.append(h * k * E(j * k, u[j - 1][i],
                                   (u0 - u[j - 1][i]) / u0, u0, i0, ct) *
                         (u0 - u[j - 1][i - 1]) +
                         2.0 * k * E(j * k, u[j - 1][i],
                                     (u0 - u[j - 1][i]) / u0, u0, i0, ct) *
                         (i * h) * (u0 - 2.0 * u[j - 1][i] + u[j - 1][i - 1]) -
                         (i * h) * h * k * v[j - 1][i] *
                         (u0 - u[j - 1][i - 1]) + 4.0 *
                         (i * h) * h**2.0 * u[j - 1][i]**2.0)

        # print time() - start

        C[0] += A[0]
        del A[0]
        R[-1] -= C[-1] * u0
        del C[-1]
        # start3 = time()
        u.append(thomas(A, B, C, R))
        # print time() - start3
    print time() - star,
    print 's'
    print u[-1][0]
    return u
def Ct(U0):
    # return ct_bladed(U0)
    return ct_v90(U0)