def test_with_dambreak_perform(steps): z_cnt = 50 spacing = 0.1 rho0 = 1000. visc = 0.00 kappa = 0.000 dt = 0.01 g = 0. pos, info = create_dam_break(z_cnt, lfact=2., wallthick=1, walldensfact=1, spacing=spacing) mass_part = spacing*spacing*spacing*rho0 maxneighs = 200 avgneighs = 100 h = pow(3.*avgneighs*mass_part/(4.*PI*rho0), 1./3.) solver = IISPHSolver() solver.particles.pos.value = pos solver.particles.rho0.value = np.ones((len(pos),1))*rho0 solver.particles.mass.value = np.ones((len(pos),1))*mass_part solver.particles.info.value = info solver.particles.visc.value = np.ones((len(pos),1))*visc solver.particles.kappa.value = np.ones((len(pos),1))*kappa solver.h = h solver.dt = dt solver.g = g solver.maxneighs = maxneighs solver.avgneighs = avgneighs solver.wkrn = 'WendlandC2' solver.setup() for i in range(steps): solver.update()
def test_with_cube(): z_cnt = 8 spacing = 0.1 rho0 = 1000. visc = 0.01 kappa = 0.000 dt = 0.04 g = 0. pos = create_pos_cube(z_cnt, spacing=spacing) mass_part = spacing*spacing*spacing*rho0 maxneighs = 200 avgneighs = 100 h = pow(3.*avgneighs*mass_part/(4.*PI*rho0), 1./3.) solver = IISPHSolver() solver.particles.pos.value = pos solver.particles.rho0.value = np.ones((len(pos),1))*rho0 solver.particles.mass.value = np.ones((len(pos),1))*mass_part solver.particles.info.value = np.ones((len(pos),1))*solver.consts['MAT_FLUID'] solver.particles.visc.value = np.ones((len(pos),1))*visc solver.particles.kappa.value = np.ones((len(pos),1))*kappa solver.h = h solver.dt = dt solver.g = g solver.maxneighs = maxneighs solver.avgneighs = avgneighs solver.wkrn = 'WendlandC2' solver.setup() display = GL_Window() display.register_points_display(solver.update, solver.particles.pos, solver.particles.rho) display.start()
def test_with_dambreak(): z_cnt = 20 spacing = 0.1 rho0 = 1000. visc = 10. kappa = 0.001 dt = 0.002 g = 9.81 slipcoeff = 1. avgdvar = 0.01 maxdvar = 0.1 dt_min = 0.01 auto_dt_coeff = 0.03 pos, info = create_dam_break(z_cnt, lfact=1., wallthick=2, walldensfact=1, spacing=spacing, fill=0.4) mass_part = spacing*spacing*spacing*rho0 maxneighs = 60 avgneighs = 40 h = pow(3.*avgneighs*mass_part/(4.*PI*rho0), 1./3.) solver = IISPHSolver() solver.particles.pos.value = pos solver.particles.rho0.value = np.ones((len(pos),1))*rho0 solver.particles.mass.value = np.ones((len(pos),1))*mass_part solver.particles.info.value = info solver.particles.visc.value = np.ones((len(pos),1))*visc solver.particles.kappa.value = np.ones((len(pos),1))*kappa solver.h = h solver.dt = dt solver.g = g solver.slipcoeff = slipcoeff solver.maxneighs = maxneighs solver.avgneighs = avgneighs solver.maxdvar = maxdvar solver.avgdvar = avgdvar solver.dt_min = dt_min solver.auto_dt_coeff = auto_dt_coeff solver.wkrn = 'WendlandC2' solver.setup() def update_and_count_neighs(): count = 10 times = 0. for i in range(count): t0 = timeit.default_timer() solver.update() t1 = timeit.default_timer() times += t1-t0 print "avg. looptime in ", count, " loops: ", times/count print int(len(pos)/(times/count)), 'parts per second' """ neighs = solver.neighsearch.neighbors.value np.place(neighs, neighs == -1, [0]) nnz = np.zeros(len(solver.neighsearch.neighbors)) for i in range(len(nnz)): nnz[i] = np.count_nonzero(neighs[i]) print 'neigh_count ', np.amax(nnz)""" display = GL_Window() display.register_points_display(update_and_count_neighs, solver.particles.pos, solver.particles.rho, z=-z_cnt*spacing*1.8) display.start()
def test_neighsearch(): z_cnt = 10 spacing = 0.1 rho0 = 1000. visc = 0.01 kappa = 0.000 dt = 0.04 g = 0. pos = create_pos_cube(z_cnt, spacing=spacing) mass_part = spacing*spacing*spacing*rho0 maxneighs = 200 avgneighs = 100 h = pow(3.*avgneighs*mass_part/(4.*PI*rho0), 1./3.) solver = IISPHSolver() solver.particles.pos.value = pos solver.particles.rho0.value = np.ones((len(pos),1))*rho0 solver.particles.mass.value = np.ones((len(pos),1))*mass_part solver.particles.info.value = np.ones((len(pos),1))*solver.consts['MAT_FLUID'] solver.particles.visc.value = np.ones((len(pos),1))*visc solver.particles.kappa.value = np.ones((len(pos),1))*kappa solver.h = h solver.dt = dt solver.g = g solver.maxneighs = maxneighs solver.avgneighs = avgneighs solver.wkrn = 'WendlandC2' solver.setup() solver.update() h = solver.h p = solver.particles.pos.value n = np.zeros((len(p), maxneighs), np.int32) - 1 for i in range(len(p)): count = 0 for j in range(len(p)): if not(i == j): pi = np.array(p[i,:3]) pj = np.array(p[j,:3]) d = np.linalg.norm(pi - pj) if d < h: n[i,count] = j count += 1 n_cl = solver.neighsearch.neighbors.value err = 0 errind = [] for i in range(len(p)): nu = np.sort(n[i][(n[i] > -1)]) nc = np.sort(n_cl[i][(n_cl[i] > -1)]) #print nu, nc if not np.all((nu == nc)): err += 1 errind.append(i) #print nu, '\n', nc, '\n', '\n' print 'neigh search errors: ' + str(err)
def test_with_dambreak_onerun(): z_cnt = 8 spacing = 0.1 rho0 = 1000. visc = 0.00 kappa = 0.000 dt = 0.01 g = 0. pos, info = create_dam_break(z_cnt, lfact=2., wallthick=1, walldensfact=1, spacing=spacing) mass_part = spacing*spacing*spacing*rho0 maxneighs = 200 avgneighs = 100 h = pow(3.*avgneighs*mass_part/(4.*PI*rho0), 1./3.) solver = IISPHSolver() solver.particles.pos.value = pos solver.particles.rho0.value = np.ones((len(pos),1))*rho0 solver.particles.mass.value = np.ones((len(pos),1))*mass_part solver.particles.info.value = info solver.particles.visc.value = np.ones((len(pos),1))*visc solver.particles.kappa.value = np.ones((len(pos),1))*kappa solver.h = h solver.dt = dt solver.g = g solver.maxneighs = maxneighs solver.avgneighs = avgneighs solver.wkrn = 'WendlandC2' solver.setup() solver.precompute_values() solver.update() print 'rho_max ', np.amax(solver.particles.rho.value) print 'rho_min ', np.amin(solver.particles.rho.value) neighs = solver.neighsearch.neighbors.value np.place(neighs, neighs == -1, [0]) nnz = np.zeros(len(solver.neighsearch.neighbors)) for i in range(len(nnz)): nnz[i] = np.count_nonzero(neighs[i]) print 'neigh_count ', np.amax(nnz) print 'force_max ', np.amax(solver.particles.force.value) print 'force_min ', np.amin(solver.particles.force.value) print 'vel_adv_max ', np.amax(solver.particles.vel_adv.value) print 'vel_adv_min ', np.amin(solver.particles.vel_adv.value) print 'dii_max ', np.amax(solver.particles.dii.value) print 'dii_min ', np.amin(solver.particles.dii.value) print 'rho_adv_max ', np.amax(solver.particles.rho_adv.value) print 'rho_adv_min ', np.amin(solver.particles.rho_adv.value) print 'aii_max ', np.amax(solver.particles.aii.value) print 'aii_min ', np.amin(solver.particles.aii.value) print 'sum_dijpjl_max ', np.amax(solver.particles.sum_dijpjl.value) print 'sum_dijpjl_min ', np.amin(solver.particles.sum_dijpjl.value) print 'new_press_max ', np.amax(solver.particles.new_press.value) print 'new_press_min ', np.amin(solver.particles.new_press.value) print 'press_max ', np.amax(solver.particles.press.value) print 'press_min ', np.amin(solver.particles.press.value) print 'new_rho_max ', np.amax(solver.particles.new_rho.value) print 'new_rho_min ', np.amin(solver.particles.new_rho.value) print 'rho_err_max ', np.amax(solver.particles.rho_err.value) print 'rho_err_min ', np.amin(solver.particles.rho_err.value) print 'pforce_max ', np.amax(solver.particles.pforce.value) print 'pforce_min ', np.amin(solver.particles.pforce.value) print 'vel_max ', np.amax(solver.particles.vel.value) print 'vel_min ', np.amin(solver.particles.vel.value)