def main(): # Dimensiones de la red H = 100 x = 32 y = 32 z = 32 dx = H/x omega = 1.4 #Magnitud de la velocidad en la frontera inferior y superior u = 0.1 # Estructuras de informacion macroscopica s = np.zeros((x,y,z)) s[0,:,:]=1 s[x-1,:,:]=1 s[:,0,:]=1 s[:,y-1,:]=1 s[:,:,0]=1 s[:,:,z-1]=1 s[:,:,1]=2 f = inicializar(x,y,z) p = fluido(f,x,y,z) u_x = p[0] u_y = p[1] u_z = p[2] rho = p[3] # Ciclo principal del algoritmo LBM # ------------------------------------------ # 1. Calcular Variables macroscopicas # 2. Streaming # 2.1 Bounce-back # 2.2 Fronteras microscopicas # 3. Colision # 4. Actualizar # ------------------------------------------ print "Iniciando..." tic = time.clock() for t in xrange(0,50): # 1. Calcular Variables macroscopicas print "Paso:", t p = fluido(f,x,y,z) u_x = p[0] u_y = p[1] u_z = p[2] rho = p[3] # 2. Streaming f = streaming(f,s,x,y,z) f = collide(f,s,x,y,z,omega) vs.guardarFluido(x,y,z,dx,rho,u_x,u_y,u_z,t) f[1]=f[0] toc=time.clock() print "Fin:\n", (toc-tic)
def main(): # Dimensiones de la red H = 100.0 x = 25 y = 25 z = 25 dx = H/x omega = 1.0 df = np.zeros((x,y,z,3)) # Estructuras de informacion macroscopica f = inicializar(x,y,z) s = np.zeros((x,y,z)) s[:,:,0]=3 s[:,:,z-1]=2 # Ciclo principal del algoritmo LBM # ------------------------------------------ # 1. Calcular Variables macroscopicas # 2. Streaming # 2.1 Bounce-back # 2.2 Fronteras microscopicas # 3. Colision # 4. Actualizar # ------------------------------------------ print "Iniciando..." tic = time.clock() for t in xrange(30): # 1. Calcular Variables macroscopicas print "Paso:", t p = fluido(f,s,x,y,z) u_x = p[0] u_y = p[1] u_z = p[2] rho = p[3] # 2. Streaming f = streaming(f,s,x,y,z) f = collide(f,s,df,x,y,z,omega) vs.guardarFluido(x,y,z,dx,rho,u_x,u_y,u_z,t) toc=time.clock() f[other]=f[current] print "Fin:\n", (toc-tic)
i_y = np.ones(membrana.vertices.shape[0])*((y-1)*dx)/2.0 i_z = np.ones(membrana.vertices.shape[0])*((z-1)*dx)/2.0 incremento = np.vstack((i_x,i_y)) incremento = np.vstack((incremento,i_z)) membrana.vertices +=np.transpose(incremento) referencia.vertices +=np.transpose(incremento) U = np.zeros(vertices) F = np.zeros(vertices) D = sp.calcularArea(membrana) - sp.calcularArea(referencia) # ---------------------------------------------------------------- # 3. Ciclo de simulacion principal # ---------------------------------------------------------------- vs.guardarMembrana(membrana,U,F,D,0) vs.guardarFluido(x,y,z,dx,rho,u_x,u_y,u_z,0) print "Iniciando...." tic = time.clock() for t in xrange(1,maxit): print "Paso: ", t # ---------------------------------------------------------------- # 3.1 Propagar velocidad hacia la membrana INTERPOLATION # ---------------------------------------------------------------- U = ibm.interpolation(membrana, fluido, x, y, z, dx, u_x, u_y, u_z) # ---------------------------------------------------------------- # 3.2 Encontrar nuevas posiciones de la membrana # ---------------------------------------------------------------- membrana.vertices += U*dt # ----------------------------------------------------------------