def test_wall_functions(self):
     from proteus import BoundaryConditions as bc
     from proteus.mprans import BoundaryConditions as mbc
     # input
     ct = get_context()
     b_or = np.array([[0., -1., 0.]])
     b_or_wall = np.array([0., -1., 0.])
     b_i = 0
     BC = create_BC(folder='mprans', b_or=b_or, b_i=b_i)
     Y = 0.01  # m
     U0 = np.array([0.1, 0., 0.])  # m/s
     U0abs = np.sqrt(np.sum(U0**2))
     Cmu = 0.09
     B = 5.57
     # Normal and tangential vectors
     nV = old_div(-b_or_wall, np.sqrt(np.sum(b_or_wall**2)))
     uTan = U0 - U0 * (nV**2)
     tV = old_div(uTan, np.sqrt(np.sum(uTan**2)))
     uTanAbs = np.sqrt(np.sum(uTan**2))
     # Calculation of turbulent variables
     Re0 = U0abs * Y / 1.004e-6
     cf = old_div(0.045, (Re0**0.25))
     ut = U0abs * np.sqrt(old_div(cf, 2.))
     Yplus = Y * ut / 1.004e-6
     turbModel = 'ke'  # 'kw'
     kappaP = old_div((ut**2), (Cmu**0.5))
     if turbModel is 'ke':
         dissipationP = old_div((ut**3), (0.41 * Y))  # ke model
     elif turbModel is 'kw':
         dissipationP = old_div(np.sqrt(kappaP),
                                (0.41 * Y * (Cmu**0.25)))  # kw model
     # Log law
     E = np.exp(0.41 * B)
     utStar = (kappaP**0.5) * (0.09**0.25)
     uStar = utStar * np.log(E * Yplus) / 0.41
     ut = utStar * np.sqrt(old_div(uTanAbs, uStar))
     gradU = (ut / 0.41 / Y) * tV
     uDir = uTan - gradU * Y
     # Wall objects
     kWall = mbc.kWall(Y=Y, Yplus=Yplus, b_or=b_or_wall)
     wall = mbc.WallFunctions(turbModel=turbModel,
                              kWall=kWall,
                              b_or=b_or_wall,
                              Y=Y,
                              Yplus=Yplus,
                              U0=U0)
     kWall.model = None
     wall.model = None
     # Boundary conditions
     x = np.array(get_random_x())
     t = random.uniform(0., 10.)
     BC.setWallFunction(wall)
     #        npt.assert_allclose(BC.u_dirichlet.uOfXT(x, t), uDir[0], atol=1e-10)
     #        npt.assert_allclose(BC.v_dirichlet.uOfXT(x, t), uDir[1], atol=1e-10)
     #        npt.assert_allclose(BC.w_dirichlet.uOfXT(x, t), uDir[2], atol=1e-10)
     npt.assert_allclose(BC.k_dirichlet.uOfXT(x, t), kappaP, atol=1e-10)
     npt.assert_allclose(BC.dissipation_dirichlet.uOfXT(x, t),
                         dissipationP,
                         atol=1e-10)
예제 #2
0
 def test_wall_functions(self):
     from proteus import BoundaryConditions as bc
     from proteus.mprans import BoundaryConditions as mbc
     # input 
     ct = get_context() 
     b_or = np.array([[0., -1., 0.]])
     b_or_wall = np.array([0., -1., 0.])
     b_i = 0
     BC = create_BC(folder='mprans', b_or=b_or, b_i=b_i)
     Y = 0.01 # m
     U0 = np.array( [0.1, 0., 0.]) # m/s
     U0abs = np.sqrt(np.sum(U0**2))
     Cmu = 0.09
     B = 5.57
     # Normal and tangential vectors
     nV = -b_or_wall/np.sqrt(np.sum(b_or_wall**2))
     uTan = U0 - U0*(nV**2)
     tV = uTan/np.sqrt(np.sum(uTan**2))
     uTanAbs = np.sqrt(np.sum(uTan**2))
     # Calculation of turbulent variables
     Re0 = U0abs * Y / 1.004e-6
     cf = 0.045 / (Re0**0.25)
     ut = U0abs * np.sqrt(cf/2.)
     Yplus = Y*ut/1.004e-6
     turbModel = 'ke' # 'kw'
     kappaP = (ut**2) / (Cmu**0.5)
     if turbModel is 'ke':
         dissipationP = (ut**3) / (0.41*Y) # ke model
     elif turbModel is 'kw':
         dissipationP = np.sqrt(kappaP) / (0.41*Y*(Cmu**0.25)) # kw model
     # Log law
     E = np.exp(0.41*B)
     utStar = (kappaP**0.5)*(0.09**0.25)
     uStar = utStar * np.log(E*Yplus) / 0.41
     ut = utStar * np.sqrt(uTanAbs/uStar)
     gradU = (ut/0.41/Y) * tV
     uDir = uTan - gradU*Y
     # Wall objects
     kWall = mbc.kWall(Y=Y, Yplus=Yplus, b_or=b_or_wall)
     wall = mbc.WallFunctions(turbModel=turbModel, kWall=kWall, b_or=b_or_wall, Y=Y, Yplus=Yplus, U0=U0)
     kWall.model = None
     wall.model = None
     # Boundary conditions
     x = np.array(get_random_x())  
     t = random.uniform(0., 10.)
     BC.setWallFunction(wall)
     npt.assert_allclose(BC.u_dirichlet.uOfXT(x, t), uDir[0], atol=1e-10)
     npt.assert_allclose(BC.v_dirichlet.uOfXT(x, t), uDir[1], atol=1e-10)
     npt.assert_allclose(BC.w_dirichlet.uOfXT(x, t), uDir[2], atol=1e-10)
     npt.assert_allclose(BC.k_dirichlet.uOfXT(x, t), kappaP, atol=1e-10)
     npt.assert_allclose(BC.dissipation_dirichlet.uOfXT(x, t), dissipationP, atol=1e-10)
예제 #3
0
파일: tank.py 프로젝트: cekees/air-water-vv
                      segments=segments,
                      segmentFlags=segmentFlags,
                      regions=regions,
                      regionFlags=regionFlags,
                      boundaryTags=boundaryTags,
                      boundaryOrientations=boundaryOrientations)

#############################################################################################################################################################################################################################################################################################################################################################################################
# ----- BOUNDARY CONDITIONS ----- #
#############################################################################################################################################################################################################################################################################################################################################################################################

if opts.circle2D:

    for bc in circle.BC_list:
        if opts.circleBC == 'FreeSlip':
            bc.setFreeSlip()
        if opts.circleBC == 'NoSlip':
            bc.setNoSlip()

tank.BC['y-'].setFreeSlip()
tank.BC['y+'].setFreeSlip(
)  #.setAtmosphere(orientation=np.array([0., +1.,0.]),kInflow=kInflow,dInflow=dissipationInflow)

tank.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=steady_current,
                                               smoothing=3 * he,
                                               vert_axis=1)
tank.BC['x-'].pInit_advective.setConstantBC(0.0)
tank.BC['x-'].pInit_diffusive.setConstantBC(0.0)
tank.BC['x-'].pInc_diffusive.setConstantBC(0.0)
tank.BC['x-'].pInc_advective.uOfXT = lambda x, t: -opts.inflow_vel
tank.BC['x-'].p_advective.setConstantBC(0.0)
예제 #4
0
#####################################################
boundaryOrientations = {
    'y-': np.array([0., -1., 0.]),
    'x+': np.array([+1, 0., 0.]),
    'y+': np.array([0., +1., 0.]),
    'x-': np.array([-1., 0., 0.]),
}
boundaryTags = {
    'y-': 1,
    'x+': 2,
    'y+': 3,
    'x-': 4,
}

# Attached to 'kappa' in auxiliary variables
kWallTop = bc.kWall(Y=Y_, Yplus=Yplus, nu=opts.nu)
kWallBottom = bc.kWall(Y=Y_, Yplus=Yplus, nu=opts.nu)
kWalls = [kWallTop, kWallBottom]
# Attached to 'twp' in auxiliary variables
wallTop = bc.WallFunctions(turbModel=model,
                           kWall=kWallTop,
                           Y=Y_,
                           Yplus=Yplus,
                           U0=opts.U,
                           nu=opts.nu,
                           Cmu=opts.Cmu,
                           K=opts.K,
                           B=opts.B)
wallBottom = bc.WallFunctions(turbModel=model,
                              kWall=kWallBottom,
                              Y=Y_,
예제 #5
0
# for the boundary condition itself
U0 = opts.meanVelocity

# inlet values
kInflow = kappaP
dissipationInflow = dissipationP

#####################################################
# Wall class definition
#####################################################

from proteus.mprans import BoundaryConditions as bc

# Attached to 'kappa' in auxiliary variables
kWallTop = bc.kWall(Y=Y_,
                    Yplus=Yplus,
                    b_or=boundaryOrientations['y+'],
                    nu=nu_0)
kWallBottom = bc.kWall(Y=Y_,
                       Yplus=Yplus,
                       b_or=boundaryOrientations['y-'],
                       nu=nu_0)
kWalls = [kWallTop, kWallBottom]
# Attached to 'twp' in auxiliary variables
wallTop = bc.WallFunctions(turbModel=model,
                           kWall=kWallTop,
                           b_or=boundaryOrientations['y+'],
                           Y=Y_,
                           Yplus=Yplus,
                           U0=U0,
                           nu=nu_0,
                           Cmu=opts.Cmu,
예제 #6
0
파일: tank.py 프로젝트: cekees/air-water-vv

regions = [ [ 0.90*x1 , 0.50*tank_dim[1] ],
            [ 0.7 , 0.50*tank_dim[1] ],
            [ 0.95*tank_dim[0] , 0.50*tank_dim[1] ] ]

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



tank = st.CustomShape(domain, vertices=vertices, vertexFlags=vertexFlags,
                      segments=segments, segmentFlags=segmentFlags,
                      regions=regions, regionFlags=regionFlags,
                      boundaryTags=boundaryTags, boundaryOrientations=boundaryOrientations)

kWallWall = bc.kWall(Y=Y_, Yplus=Yplus, b_or=boundaryOrientations['y-'], nu=nu_0)
kWalls = [kWallWall]
wallWall = bc.WallFunctions(turbModel='ke', kWall=kWallWall, b_or=boundaryOrientations['y-'], Y=Y_, Yplus=Yplus, U0=[opts.inflow_vel, 0. , 0.], nu=nu_0, Cmu=opts.Cmu, K=opts.K, B=opts.B)
walls = [wallWall]


#############################################################################################################################################################################################################################################################################################################################################################################################
# ----- BOUNDARY CONDITIONS ----- #
#############################################################################################################################################################################################################################################################################################################################################################################################
tank.setTurbulentWall(walls)
tank.setTurbulentKWall(kWalls)
#tank.BC['y-'].setFreeSlip()
tank.BC['y-'].setWallFunction(walls[0])
tank.BC['y+'].setFreeSlip()#.setAtmosphere(orientation=np.array([0., +1.,0.]),kInflow=kInflow,dInflow=dissipationInflow)

tank.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=steady_current, smoothing = 3*he, vert_axis=1, kInflow = kInflow, dInflow = dissipationInflow)