コード例 #1
0
ファイル: test_D3Q41.py プロジェクト: Titan-C/python_scripts
def test_consPBC():
    """Test if on periodic boundary conditions density and fluid velocity are conserved"""
    U=[0.05,0.05,0.05]
    size=[20,20,20]
    metrics=[[1,1,1],[.5,1,1],[1,.5,1],[1,1,.5],[2.,1.,1.],[1.,2.,1.],[1.,1.,2.]]
    for metric in metrics:
#        import pdb; pdb.set_trace()
        lat = lb.lattice(size,U,tau,metric)
        for step in range(700):
           lat.updateMacroVariables()
           lat.collision()
           lat.streamming()
        print 'for metric: ', metric
        print 'rho_err= ',np.max(np.abs(lat.rho-r))
        print 'U_err0= ',np.max(np.abs(lat.U-U))
        U=np.array(U)
        assert ( np.abs(lat.rho-r) < 5e-13 ).all()
        assert ( np.abs(lat.U-U) < 6e-13 ).all()
        plot((lat.U-U)[:,5,5,0],'x-');show()
コード例 #2
0
ファイル: test_D3Q41.py プロジェクト: Titan-C/python_scripts
def test_consArbiWalls():
    """ Test if with top & bottom walls density is conserved"""
    U=[0.05,0.0,0.]
    size=[21,7,7]
    wall=np.zeros(size)
    wall[[0,1,2,-3,-2,-1]]=1
    metrics=[[2.,1.,1.],[1.,2.,1.],[1.,1.,2.],[.5,1,1],[1,.5,1],[1,1,.5],[1,1,1]]
    for metric in metrics:
        lat = lb.lattice(size,U,tau,metric)
        lat.setWalls(wall)
        for step in range(500):
           lat.updateMacroVariables()
           if step%20==0: plot(lat.U[:,5,5,0],'x-')#;import pdb;pdb.set_trace()
           lat.collision()
           lat.streamming()
           lat.onWallBBNS_BC(wall)
        show()
        print 'for metric: ', metric
        print 'rho_err= ',np.max(np.abs(lat.rho-r))
        assert ( np.abs(lat.rho - r) < 4e-15 ).all()