def rbf_solver(x,y,g,e,sigma): tic = cpu_time() t = arange(10)*0. # define classes class PARAMETER: pass class PARTICLE: pass class CLUSTER: pass class GRID: pass class SOLVER: pass parameter = PARAMETER() particle = PARTICLE() cluster = CLUSTER() grid = GRID() solver = SOLVER() epsf = 1e-8 epsd = 1e-20 # physical parameters particle.ni = x.shape[0] particle.nj = particle.ni particle.sigma = sigma particle.xmin = x.min() particle.xmax = x.max() particle.ymin = y.min() particle.ymax = y.max() solver.method = 0 # cluster parameters cluster.nsigma_box = 8. cluster.nsigma_buffer = 12. cluster.nsigma_trunc = 24. # initialize particles particle.xi = x particle.yi = y particle.ei = e particle.wi = e particle.xj = x particle.yj = y particle.gj = g # generate clusters particle,cluster = get_cluster(particle,cluster) toc = tic tic = cpu_time() t[0] += tic-toc # RBF interpolation it = -1; iconv = 0; err = []; grid.r = [] while iconv < 5: it = it+1 # estimate vorticity field on particle from vortex strength particle,cluster = get_vorticity(particle,cluster) toc = tic tic = cpu_time() t[1] += tic-toc # solve the system of equations to calculate the vortex strength particle,cluster,solver = get_strength(particle,cluster,solver,it) toc = tic tic = cpu_time() t[2] += tic-toc # calculate the L2 norm error err.append(log10(std(particle.ri)/std(particle.ei))) print 'iteration : ',it,' error : ',err[it] if err[it] < -5: iconv = iconv+1 toc = tic tic = cpu_time() t[0] += tic-toc for i in range(3): t[9] += t[i] print 'matvec : ',t[1] print 'solver : ',t[2] print 'other : ',t[0] print '------------------' print 'total : ',t[9]
# RBF interpolation it = -1; iconv = 0; err = []; grid.r = [] while iconv < 5: it = it+1 # estimate vorticity field on particle from vortex strength vorticity_evaluation(particle.wi,particle.xi,particle.yi,\ particle.xj,particle.yj,particle.gj,particle.sigma) particle,cluster = get_vorticity(particle,cluster) toc = tic tic = cpu_time() t[1] += tic-toc # solve the system of equations to calculate the vortex strength particle,cluster,solver = get_strength(particle,cluster,solver,it) toc = tic tic = cpu_time() t[2] += tic-toc # calculate the L2 norm error err.append(log10(std(solver.r)/std(particle.ei))) print 'iteration : ',it,' error : ',err[it] if err[it] < -14: iconv = iconv+1 # plot the spatial variation of error particle.ri[particle.isort] = particle.ri.copy() grid.r.append(particle.ri.reshape(grid.ny,-1)) imshow(log10(abs(grid.r[it])/max(abs(particle.ei))+epsd)) if it == 0: colorbar()
it = -1 iconv = 0 err = [] grid.r = [] while iconv < 5: it = it + 1 # estimate vorticity field on particle from vortex strength particle, cluster = get_vorticity(particle, cluster) toc = tic tic = cpu_time() t[1] += tic - toc # solve the system of equations to calculate the vortex strength particle, cluster, solver = get_strength(particle, cluster, solver, it) toc = tic tic = cpu_time() t[2] += tic - toc # calculate the L2 norm error err.append(log10(std(solver.r) / std(particle.ei))) print 'iteration : ', it, ' error : ', err[it] if err[it] < -14: iconv = iconv + 1 # plot the spatial variation of error particle.ri[particle.isort] = particle.ri.copy() grid.r.append(particle.ri.reshape(grid.ny, -1)) imshow(log10(abs(grid.r[it]) / max(abs(particle.ei)) + epsd)) if it == 0: colorbar()
def rbf_solver(x, y, g, e, sigma): tic = cpu_time() t = arange(10) * 0. # define classes class PARAMETER: pass class PARTICLE: pass class CLUSTER: pass class GRID: pass class SOLVER: pass parameter = PARAMETER() particle = PARTICLE() cluster = CLUSTER() grid = GRID() solver = SOLVER() epsf = 1e-8 epsd = 1e-20 # physical parameters particle.ni = x.shape[0] particle.nj = particle.ni particle.sigma = sigma particle.xmin = x.min() particle.xmax = x.max() particle.ymin = y.min() particle.ymax = y.max() solver.method = 0 # cluster parameters cluster.nsigma_box = 8. cluster.nsigma_buffer = 12. cluster.nsigma_trunc = 24. # initialize particles particle.xi = x particle.yi = y particle.ei = e particle.wi = e particle.xj = x particle.yj = y particle.gj = g # generate clusters particle, cluster = get_cluster(particle, cluster) toc = tic tic = cpu_time() t[0] += tic - toc # RBF interpolation it = -1 iconv = 0 err = [] grid.r = [] while iconv < 5: it = it + 1 # estimate vorticity field on particle from vortex strength particle, cluster = get_vorticity(particle, cluster) toc = tic tic = cpu_time() t[1] += tic - toc # solve the system of equations to calculate the vortex strength particle, cluster, solver = get_strength(particle, cluster, solver, it) toc = tic tic = cpu_time() t[2] += tic - toc # calculate the L2 norm error err.append(log10(std(particle.ri) / std(particle.ei))) print 'iteration : ', it, ' error : ', err[it] if err[it] < -5: iconv = iconv + 1 toc = tic tic = cpu_time() t[0] += tic - toc for i in range(3): t[9] += t[i] print 'matvec : ', t[1] print 'solver : ', t[2] print 'other : ', t[0] print '------------------' print 'total : ', t[9]