예제 #1
0
def analytical_pressure(mObj):

    dragModel = mObj.dragModel
    muf = mObj.dynamic_viscosity
    rhof = mObj.fluid_density
    Uf = mObj.Uf
    dp = mObj.diameter
    epsf = mObj.epsf
    xyzL = mObj.xyzL
    xyz_orig = mObj.xyz_orig

    # Obtain the pressure gradient across sample, and the inlet pressure
    # (assuming that the outlet pressure is zero)
    if dragModel == 'Drag' or dragModel == 'Stokes':
        fObj = Stokes(muf=muf, epsf=epsf, dp=dp)
    elif dragModel == 'DiFelice':
        fObj = DiFelice(muf=muf,
                        rhof=rhof,
                        epsf=epsf,
                        dp=dp,
                        Uf=Uf / epsf,
                        Vp=0.)
    elif dragModel == 'Ergun':
        fObj = Ergun(muf=muf, rhof=rhof, epsf=epsf, dp=dp, Uf=Uf / epsf, Vp=0.)
    else:
        raise ('Unknown drag force model specified')

    gradP = fObj.calculate_pressure_gradient(Uf=Uf / epsf, Vp=0.)
    pSol = gradP * (xyzL[1] - xyz_orig[1])

    return pSol
예제 #2
0
def analytical_pressure(mObj):

    dragModel = mObj.dragModel
    muf = mObj.muf
    rhof = mObj.rhof
    Uf = mObj.Uf
    dp = mObj.dp
    epsf = mObj.epsf
    xyzL = mObj.xyzL
    xyz_orig = mObj.xyz_orig

    if dragModel == 'Drag' or dragModel == 'Stokes':
        fObj = Stokes(muf=muf, epsf=epsf, dp=dp)
    elif dragModel == 'DiFelice':
        fObj = DiFelice(muf=muf,
                        rhof=rhof,
                        epsf=epsf,
                        dp=dp,
                        Uf=Uf / epsf,
                        Vp=0.)
    elif dragModel == 'Ergun':
        fObj = Ergun(muf=muf, rhof=rhof, epsf=epsf, dp=dp, Uf=Uf / epsf, Vp=0.)
    else:
        raise ValueError('Unknown drag force model specified')

    gradP = fObj.calculate_pressure_gradient(Uf=Uf / epsf, Vp=0.)
    pSol = gradP * (xyzL[1] - xyz_orig[1])

    return pSol
# Setup send and recv buffers
recvbuf, sendbuf = CPL.get_arrays(recv_size=8, send_size=9)

# Main time loop
for time in range(400):

    # print(time)
    if time == 0:
        Vp = 0.

    # Send data: Zero send buffer. Set only the fluid velocity and gradP in the
    # y-direction for the entire column.
    # [Ux, Uy, Uz, gradPx, gradPy, gradPz, divTaux, divTauy, divTauz]
    sendbuf[:,:,:,:] = 0
    sendbuf[4,:,:,:] = rhof*g - fObj.calculate_pressure_gradient(Uf=0., Vp=Vp)

    CPL.send(sendbuf)

    # Recieve data:
    # [UxSum, UySum, UzSum, FxSum, FySum, FzSum, CdSum, VolSum] 
    recvbuf, ierr = CPL.recv(recvbuf)

    # Extract particle velocity for UySum = volume*Vp. Note that when
    # particles are detected in multiple cells (unsure why this occurs when no
    # overlap is considered), sum the value to obtain the single particle
    # velocity.
    Vp = np.squeeze(recvbuf[1,:,:,:])/((np.pi/6)*(dp**3))
    Vp = Vp[np.nonzero(Vp)]
    if len(Vp) == 1:
        Vp = Vp[0]
comm = MPI.COMM_WORLD

# Initialise CPL
CPL = CPL()
CFD_COMM = CPL.init(CPL.CFD_REALM)
cart_comm = CFD_COMM.Create_cart([npxyz[0], npxyz[1], npxyz[2]])
CPL.setup_cfd(cart_comm, xyzL, xyz_orig, ncxyz)

# Setup send and recv buffers
recvbuf, sendbuf = CPL.get_arrays(recv_size=8, send_size=9)

# Main time loop
for time in range(20):

    # print(time)

    # Send data: Zero send buffer. Set only the fluid velocity and gradP in the
    # y-direction for the entire column.
    # [Ux, Uy, Uz, gradPx, gradPy, gradPz, divTaux, divTauy, divTauz]
    sendbuf[:, :, :, :] = 0
    sendbuf[4, :, :, :] = -fObj.calculate_pressure_gradient(Uf=0., Vp=vy0)

    CPL.send(sendbuf)

    # Recieve data:
    # [UxSum, UySum, UzSum, FxSum, FySum, Fz6Sum, CdSum, VolSum]
    recvbuf, ierr = CPL.recv(recvbuf)

CPL.finalize()
MPI.Finalize()