Ejemplo n.º 1
0
def main(args):
    fig = plt.figure()
    axU = fig.add_subplot(211)
    axR = fig.add_subplot(212)

    wall = createobstacle(args.diameter[0],111)
    lat = lb_D2Q9.lattice(wall.shape,[0.,0.],args.tau[0])
    lat.ux[:,0]=anSolution(5e-8,111,lat.nu) #set intel macroscopic eq vel
    lat.fd = lat.eqdistributions()#New equilibrium
    lat.setWalls(wall)
    finlet = np.copy( lat.fd[:,:,:1]) #get inlet macroscopic vel
    lat.updateMacroVariables()

    for i in range(400000):
        if i%50 == 0:
            axU.cla()
            axU.imshow(np.sqrt(lat.ux**2+lat.uy**2),vmin=0,vmax=0.2)
            fname = '%08d.png'%i
            dyUy,dxUy=np.gradient(lat.uy)
            dyUx,dxUx=np.gradient(lat.ux)
            vort=np.abs(dxUy-dyUx)
            axR.cla()
            axR.imshow(vort,vmin=0,vmax=0.1)
            fig.savefig('tot'+fname)
        
        lat.collision()
        lat.streamming()
        lat.onWallBBNS_BC(wall)
        lat.fd[:,:,-1]=np.copy(lat.fd[:,:,-2]) #gradient to cero on outlet
        lat.fd[:,:,:1]=np.copy(finlet)
        lat.updateMacroVariables()
    np.savez('out.npz',lat.ux,lat.uy,lat.rho,wall)
Ejemplo n.º 2
0
def main(args):
    size = args.size
    U = args.velocity
    lat = lb.lattice(args.size,args.velocity,args.tau[0])
    F=np.array(args.force)
    wall=np.zeros(args.size)
    wall[[0,-1]]=1
    lat.setWalls(wall)
    lat.updateMacroVariables(F)

    uxold=1
    step = 1
    while ( np.abs(uxold - lat.ux) > 1e-12 )[wall==0].all():
        lat.collision()
        lat.force(F)
        lat.streamming()
        lat.onWallBBNS_BC(wall)
        uxold=lat.ux
        lat.updateMacroVariables(F)
        step +=1
    print step, 'iter'
    domain = np.arange(len(lat.ux))- size[0]/2
    print lat.ux
    an= anSolution(args.force[0],size[0],lat.nu)
    print an
    print 'diff num - analytic: ', np.abs(lat.ux.reshape(size[0])-an)
    plot(domain,lat.ux,'x-')
    plot(domain,an)
    show()

    return lat.ux