예제 #1
0
def wJacobi(rho):
    global W
    global L, N

    temp_sol = np.zeros_like(rho)

    jCnt = 0
    while True:
        temp_sol[2:L, 1:N] = ((grid.hz2*(W[1:L-1, 1:N] + W[3:L+1, 1:N])*grid.xix2Stag[1:-1, npax] +
                               grid.hx2*(W[2:L, 0:N-1] + W[2:L, 2:N+1])*grid.ztz2Coll[:])*
                        gv.dt/(grid.hz2hx2*2.0*gv.Re) + rho[2:L, 1:N]) / \
                 (1.0 + gv.dt*(grid.hz2*grid.xix2Stag[1:-1, npax] + grid.hx2*grid.ztz2Coll[:])/(gv.Re*grid.hz2hx2))

        # SWAP ARRAYS AND IMPOSE BOUNDARY CONDITION
        W, temp_sol = temp_sol, W
        W = bc.imposeWBCs(W)

        maxErr = np.amax(
            np.fabs(rho[2:L, 1:N] -
                    (W[2:L, 1:N] - 0.5 * gv.dt *
                     ((W[1:L - 1, 1:N] - 2.0 * W[2:L, 1:N] + W[3:L + 1, 1:N]) *
                      grid.xix2Stag[1:-1, npax] / grid.hx2 +
                      (W[2:L, 0:N - 1] - 2.0 * W[2:L, 1:N] + W[2:L, 2:N + 1]) *
                      grid.ztz2Coll[:] / grid.hz2) / gv.Re)))

        if maxErr < gv.tolerance:
            break

        jCnt += 1
        if jCnt > grid.maxCount:
            print("ERROR: Jacobi not converging in W. Aborting")
            print("Maximum error: ", maxErr)
            quit()
예제 #2
0
def euler():
    global N, L
    global U, W, P
    global Hx, Hz, Pp

    Hx.fill(0.0)
    Hz.fill(0.0)

    computeNLinDiff_X(U, W)
    computeNLinDiff_Z(U, W)

    # Add constant pressure gradient forcing for channel flows
    if gv.probType == 1:
        Hx[:, :] += 1.0

    # Calculating guessed values of U implicitly
    Hx[1:L, 1:N +
       1] = U[1:L, 1:N +
              1] + gv.dt * (Hx[1:L, 1:N + 1] - grid.xi_xColl[:, npax] *
                            (P[2:L + 1, 1:N + 1] - P[1:L, 1:N + 1]) / grid.hx)
    uJacobi(Hx)

    # Calculating guessed values of W implicitly
    Hz[1:L + 1, 1:N] = W[1:L + 1, 1:N] + gv.dt * (
        Hz[1:L + 1, 1:N] - grid.zt_zColl[:] *
        (P[1:L + 1, 2:N + 1] - P[1:L + 1, 1:N]) / grid.hz)
    wJacobi(Hz)

    # Calculating pressure correction term
    rhs = np.zeros([L + 2, N + 2])
    rhs[1:L + 1, 1:N + 1] = ((U[1:L + 1, 1:N + 1] - U[0:L, 1:N + 1]) *
                             grid.xi_xStag[:, npax] / grid.hx +
                             (W[1:L + 1, 1:N + 1] - W[1:L + 1, 0:N]) *
                             grid.zt_zStag[:] / grid.hz) / gv.dt

    ps.multigrid(Pp, rhs)

    # Add pressure correction.
    P = P + Pp

    # Update new values for U and W
    U[1:L, 1:N +
      1] = U[1:L, 1:N + 1] - gv.dt * (Pp[2:L + 1, 1:N + 1] - Pp[1:L, 1:N + 1]
                                      ) * grid.xi_xColl[:, npax] / grid.hx
    W[1:L + 1, 1:N] = W[1:L + 1, 1:N] - gv.dt * (
        Pp[1:L + 1, 2:N + 1] - Pp[1:L + 1, 1:N]) * grid.zt_zColl[:] / grid.hz

    # Impose no-slip BC on new values of U and W
    U = bc.imposeUBCs(U)
    W = bc.imposeWBCs(W)

    print(U[30, 30], W[30, 30])
예제 #3
0
def euler():
    global N, M, L
    global U, V, W, P
    global Hx, Hy, Hz, Pp

    Hx.fill(0.0)
    Hy.fill(0.0)
    Hz.fill(0.0)

    computeNLinDiff_X(U, V, W)
    computeNLinDiff_Y(U, V, W)
    computeNLinDiff_Z(U, V, W)

    # Add constant pressure gradient forcing for channel flows
    if gv.probType == 1:
        Hx[:, :, :] += 1.0

    # Calculating guessed values of U implicitly
    Hx[1:L, 1:M + 1, 1:N + 1] = U[1:L, 1:M + 1, 1:N + 1] + gv.dt * (
        Hx[1:L, 1:M + 1, 1:N + 1] -
        (P[2:L + 1, 1:M + 1, 1:N + 1] - P[1:L, 1:M + 1, 1:N + 1]) / grid.hx)
    uJacobi(Hx)

    # Calculating guessed values of V implicitly
    Hy[1:L + 1, 1:M, 1:N + 1] = V[1:L + 1, 1:M, 1:N + 1] + gv.dt * (
        Hy[1:L + 1, 1:M, 1:N + 1] -
        (P[1:L + 1, 2:M + 1, 1:N + 1] - P[1:L + 1, 1:M, 1:N + 1]) / grid.hy)
    vJacobi(Hy)

    # Calculating guessed values of W implicitly
    Hz[1:L + 1, 1:M + 1, 1:N] = W[1:L + 1, 1:M + 1, 1:N] + gv.dt * (
        Hz[1:L + 1, 1:M + 1, 1:N] -
        (P[1:L + 1, 1:M + 1, 2:N + 1] - P[1:L + 1, 1:M + 1, 1:N]) / grid.hz)
    wJacobi(Hz)

    # Calculating pressure correction term
    rhs = np.zeros([L + 2, M + 2, N + 2])
    rhs[1:L + 1, 1:M + 1, 1:N + 1] = (
        (U[1:L + 1, 1:M + 1, 1:N + 1] - U[0:L, 1:M + 1, 1:N + 1]) / grid.hx +
        (V[1:L + 1, 1:M + 1, 1:N + 1] - V[1:L + 1, 0:M, 1:N + 1]) / grid.hy +
        (W[1:L + 1, 1:M + 1, 1:N + 1] - W[1:L + 1, 1:M + 1, 0:N]) /
        grid.hz) / gv.dt

    if gv.solveMethod[0:2] == 'MG':
        ps.multigrid(Pp, rhs)

    # Add pressure correction.
    P = P + Pp

    # Update new values for U, V and W
    U[1:L, 1:M + 1, 1:N + 1] = U[1:L, 1:M + 1, 1:N + 1] - gv.dt * (
        Pp[2:L + 1, 1:M + 1, 1:N + 1] - Pp[1:L, 1:M + 1, 1:N + 1]) / grid.hx
    V[1:L + 1, 1:M, 1:N + 1] = V[1:L + 1, 1:M, 1:N + 1] - gv.dt * (
        Pp[1:L + 1, 2:M + 1, 1:N + 1] - Pp[1:L + 1, 1:M, 1:N + 1]) / grid.hy
    W[1:L + 1, 1:M + 1, 1:N] = W[1:L + 1, 1:M + 1, 1:N] - gv.dt * (
        Pp[1:L + 1, 1:M + 1, 2:N + 1] - Pp[1:L + 1, 1:M + 1, 1:N]) / grid.hz

    # Impose no-slip BC on new values of U, V and W
    U = bc.imposeUBCs(U)
    V = bc.imposeVBCs(V)
    W = bc.imposeWBCs(W)

    print(U[30, 30, 30], V[30, 30, 30], W[30, 30, 30])