Example #1
0
def gridprint (z, C_true):

        picgrid=pres.Gridpic(x,k,c_ary,threeD,pos,C_true)

        C = picgrid.calc_cval()

        # Variables
        point_data = np.zeros((nx + 1, ny + 1, nz + 1))
        # cell_data = np.zeros((nx, ny, nz))
        distribution = np.zeros((nx, ny, nz))
        for i in range(len(C)):
            x_dis = i % x
            z_dis = i // ((x)**2)
            y_dis = (i %((x) ** 2)) // x

            point_data[x_dis][y_dis][z_dis]=C[i]

        hl.gridToVTK("c_grid"+str(z), x_c, y_c, z_c, cellData={"distribution": distribution}, pointData={"point_data": point_data})
Example #2
0
def gridprint (z, C_true):

        picgrid=pres.Gridpic(x,k,c_ary,threeD,pos,C_true)

        C = picgrid.calc_cval()

        # Variables
        point_data = np.zeros((nx + 1, ny + 1, nz + 1))
        # cell_data = np.zeros((nx, ny, nz))
        distribution = np.zeros((nx, ny, nz))
        for i in range(len(C)):
            x_dis = i % x
            z_dis = i // ((x)**2)
            y_dis = (i %((x) ** 2)) // x

            point_data[x_dis][y_dis][z_dis]=C[i]

        hl.gridToVTK("c_grid"+str(z), x_c, y_c, z_c, cellData={"distribution": distribution}, pointData={"point_data": point_data})
        density[pos_x][pos_y][pos_z] += 1.0
    elif rand_num < 4.0 / 6.0:
        if 0 < pos_y:
            if boundary[pos_x][pos_y - 1][pos_z] == 1:
                molecule[pos_x][pos_y][pos_z] = 0.0
                pos_y -= 1
                molecule[pos_x][pos_y][pos_z] = 1.0
        density[pos_x][pos_y][pos_z] += 1.0
    elif rand_num < 5.0 / 6.0:
        if pos_z < nz - 1:
            if boundary[pos_x][pos_y][pos_z + 1] == 1:
                molecule[pos_x][pos_y][pos_z] = 0.0
                pos_z += 1
                molecule[pos_x][pos_y][pos_z] = 1.0
        density[pos_x][pos_y][pos_z] += 1.0
    else:
        if 0 < pos_z:
            if boundary[pos_x][pos_y][pos_z - 1] == 1:
                molecule[pos_x][pos_y][pos_z] = 0.0
                pos_z -= 1
                molecule[pos_x][pos_y][pos_z] = 1.0
        density[pos_x][pos_y][pos_z] += 1.0

    hl.gridToVTK(
        "output/diffusion_obstacle" + str(i),
        x,
        y,
        z,
        cellData={"particle": molecule, "density": density, "boundary": boundary},
    )
point_data = np.zeros((nx + 1, ny + 1, nz + 1))
#cell_data = np.zeros((nx, ny, nz))
distribution = np.zeros((nx, ny, nz))



D = 10.0
k = 0.5
lam = np.sqrt(D/k)
cell_radius = 2.0



def distribution_fct(x,y):
  x0 = 5.0
  y0 = 5.0
  r = max(cell_radius,np.sqrt((x-x0)**2 + (y-y0)**2))
  value = np.exp(-r/lam)/r
  return value

for i in range(0,nx):
    for j in range(0,ny):
      distribution[i][j][0] = distribution_fct(x[i],x[j])
      #print "x:" +  str(x[i])
      #print "y:" + str(y[j])
      #print "value:" + str(distribution[i][j][0])	



hl.gridToVTK("./test", x, y, z, cellData = {"distribution" : distribution}, pointData = {"temp" : point_data})
#! /usr/bin/env python

import hl
import numpy as np

# Dimensions
nx, ny, nz = 2, 2, 2
lx, ly, lz = 1.0, 1.0, 1.0
dx, dy, dz = lx/nx, ly/ny, lz/nz

ncells = nx * ny * nz
npoints = (nx + 1) * (ny + 1) * (nz + 1)

# Coordinates
x = np.arange(0, lx + dx, dx, dtype='float64')
y = np.arange(0, ly + dy, dy, dtype='float64')
z = np.arange(0, lz + dz, dz, dtype='float64')

# Variables
point_data = np.zeros((nx + 1, ny + 1, nz + 1))
cell_data = np.zeros((nx, ny, nz))

cell_data[1][1][1] = 1.0

point_data[2][1][1] = 1.0 

hl.gridToVTK("./visualization", x, y, z, cellData = {"pressure" : cell_data}, pointData = {"temp" : point_data})
      molecule[pos_x][pos_y][pos_z] = 0.0
      pos_x -= 1 
      molecule[pos_x][pos_y][pos_z] = 1.0
    density[pos_x][pos_y][pos_z] += 1.0 
  elif ( rand_num < 3.0/6.0):
    if (pos_y < ny - 1):
      molecule[pos_x][pos_y][pos_z] = 0.0
      pos_y += 1 
      molecule[pos_x][pos_y][pos_z] = 1.0
    density[pos_x][pos_y][pos_z] += 1.0      
  elif ( rand_num < 4.0/6.0):
    if ( 0 < pos_y):
      molecule[pos_x][pos_y][pos_z] = 0.0
      pos_y -= 1 
      molecule[pos_x][pos_y][pos_z] = 1.0
    density[pos_x][pos_y][pos_z] += 1.0 
  elif ( rand_num < 5.0/6.0):    
    if (pos_z < nz - 1):
      molecule[pos_x][pos_y][pos_z] = 0.0
      pos_z += 1 
      molecule[pos_x][pos_y][pos_z] = 1.0
    density[pos_x][pos_y][pos_z] += 1.0      
  else:
    if ( 0 < pos_z):
      molecule[pos_x][pos_y][pos_z] = 0.0
      pos_z -= 1 
      molecule[pos_x][pos_y][pos_z] = 1.0
    density[pos_x][pos_y][pos_z] += 1.0 
  
  hl.gridToVTK("output/diffusion_" + str(i), x, y, z, cellData = {"particle" : molecule, "density" : temp})
Example #7
0
point_data = np.zeros((nx + 1, ny + 1, nz + 1))
#cell_data = np.zeros((nx, ny, nz))
distribution = np.zeros((nx, ny, nz))

D = 10.0
k = 0.5
lam = np.sqrt(D / k)
cell_radius = 2.0


def distribution_fct(x, y):
    x0 = 5.0
    y0 = 5.0
    r = max(cell_radius, np.sqrt((x - x0)**2 + (y - y0)**2))
    value = np.exp(-r / lam) / r
    return value


for i in range(0, nx):
    for j in range(0, ny):
        distribution[i][j][0] = distribution_fct(x[i], x[j])
        #print "x:" +  str(x[i])
        #print "y:" + str(y[j])
        #print "value:" + str(distribution[i][j][0])

hl.gridToVTK("./test",
             x,
             y,
             z,
             cellData={"distribution": distribution},
             pointData={"temp": point_data})