コード例 #1
0
ファイル: rbf_solver2.py プロジェクト: Haider-BA/pyrbf
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]
コード例 #2
0
ファイル: test2.py プロジェクト: Haider-BA/pyrbf
# solve rbf using c wrapper
if parameter.wrapper == 1:
    rbf_solver(particle.xi,particle.yi,particle.gj,particle.ei,
        particle.sigma,parameter.vis)

toc = tic
tic = cpu_time()

# generate clusters
particle,cluster = get_cluster(particle,cluster)

# set up reference data
if parameter.wrapper == 1:
    particle,cluster = get_trunc(particle,cluster)
    particle,cluster = get_vorticity(particle,cluster)
    particle.gj = exp(-(particle.xj**2+particle.yj**2)/\
    (4*parameter.vis*parameter.t))/(pi*4*parameter.vis*parameter.t)*particle.h**2
    particle.ei = particle.wi
    particle.wi = particle.gj/particle.h**2

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
コード例 #3
0
# solve rbf using c wrapper
if parameter.wrapper == 1:
    rbf_solver(particle.xi, particle.yi, particle.gj, particle.ei,
               particle.sigma, parameter.vis)

toc = tic
tic = cpu_time()

# generate clusters
particle, cluster = get_cluster(particle, cluster)

# set up reference data
if parameter.wrapper == 1:
    particle, cluster = get_trunc(particle, cluster)
    particle, cluster = get_vorticity(particle, cluster)
    particle.gj = particle.ei * particle.h**2
    particle.ei = particle.wi
    particle.wi = particle.gj / particle.h**2

toc = tic
tic = cpu_time()
t[0] += tic - toc

# RBF interpolation
it = -1
iconv = 0
err = []
grid.r = []
while iconv < 5:
    it = it + 1
コード例 #4
0
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]