Ejemplo n.º 1
0
def create_particles():
    N = app.options.N or 20
    N += 1
    hfac = app.options.hfac or 1.2

    rho0 = 1.0
    #x,y = numpy.mgrid[-1.05:1.05+1e-4:dx, -0.105:0.105+1e-4:dx]
    x = numpy.mgrid[0:1:1j*N]
    dx = 1.0/(N-1)
    x = x.ravel()
    #y = y.ravel()
    bdry = (x<=0)
    print bdry, numpy.flatnonzero(bdry)
    m = rho0*numpy.ones_like(x)*dx
    h = numpy.ones_like(x)*hfac*dx
    rho = rho0*numpy.ones_like(x)
    y = z = numpy.zeros_like(x)

    p = z

    #cs = numpy.ones_like(x) * 10000.0

    u = -x
    u *= 0.1

    pa = get_particle_array(x=x, y=y, m=m, rho=rho, h=h, p=p, u=u, v=z, z=z,w=z,
                            name='solid', type=1,
                            bdry=bdry,)

    pa.constants['E'] = 1e9
    pa.constants['nu'] = 0.3
    pa.constants['G'] = pa.constants['E']/(2.0*(1+pa.constants['nu']))
    pa.constants['K'] = stress_funcs.get_K(pa.constants['G'], pa.constants['nu'])
    pa.constants['rho0'] = rho0
    pa.constants['dr0'] = dx
    pa.constants['c_s'] = numpy.sqrt(pa.constants['K']/pa.constants['rho0'])
    pa.cs = numpy.ones_like(x) * pa.constants['c_s']
    pa.set(idx=numpy.arange(len(pa.x)))
    print 'G:', pa.G
    print 'K', pa.K
    print 'c_s', pa.c_s
    print 'Number of particles: ', len(pa.x)

    return pa
Ejemplo n.º 2
0
def create_particles():
    #N = 21
    dx = 0.1

    #x,y = numpy.mgrid[-1.05:1.05+1e-4:dx, -0.105:0.105+1e-4:dx]
    x,y = numpy.mgrid[-0.2:5.01:dx, -0.2:0.21:dx]
    x = x.ravel()
    y = y.ravel()
    bdry = (x<0.01)*1.0
    print 'num_particles', len(x)
    print bdry, numpy.flatnonzero(bdry)
    m = numpy.ones_like(x)*dx*dx
    h = numpy.ones_like(x)*1.4*dx
    rho = numpy.ones_like(x)
    z = numpy.zeros_like(x)

    p = 0.5*1.0*100*100*(1 - (x**2 + y**2))

    cs = numpy.ones_like(x) * 10000.0

    u = -x
    u *= 1e0
    h *= 1
    v = 0.0*y
    p *= 0.0

    pa = get_particle_array(x=x, y=y, m=m, rho=rho, h=h, p=p, u=u, v=v, z=z,w=z,
                                 bdry=bdry)
    pa.constants['E'] = 1e9
    pa.constants['nu'] = 0.3
    pa.constants['G'] = pa.constants['E']/(2.0*(1+pa.constants['nu']))
    pa.constants['K'] = stress_funcs.get_K(pa.constants['G'], pa.constants['nu'])
    pa.constants['rho0'] = 1.
    pa.constants['dr0'] = dx
    pa.constants['c_s'] = numpy.sqrt(pa.constants['K']/pa.constants['rho0'])
    pa.cs = numpy.ones_like(x) * pa.constants['c_s']
    pa.set(idx=numpy.arange(len(pa.x)))
    print 'G_mu', pa.G/pa.K
    print 'Number of particles: ', len(pa.x)
    
    return pa
Ejemplo n.º 3
0
def create_particles(two_arr=False):
    #x,y = numpy.mgrid[-1.05:1.05+1e-4:dx, -0.105:0.105+1e-4:dx]
    dx = 0.001 # 1mm
    ri = 0.03 # 3cm inner radius
    ro = 0.04 # 4cm outer radius
    spacing = 0.041 # spacing = 2*5cm
    
    x,y = numpy.mgrid[-ro:ro:dx, -ro:ro:dx]
    x = x.ravel()
    y = y.ravel()
    
    d = (x*x+y*y)
    keep = numpy.flatnonzero((ri*ri<=d) * (d<ro*ro))
    x = x[keep]
    y = y[keep]

    print 'num_particles', len(x)*2
    
    if not two_arr:
        x = numpy.concatenate([x-spacing,x+spacing])
        y = numpy.concatenate([y,y])

    #print bdry, numpy.flatnonzero(bdry)
    m = numpy.ones_like(x)*dx*dx
    h = numpy.ones_like(x)*1.4*dx
    rho = numpy.ones_like(x)
    z = numpy.zeros_like(x)

    p = 0.5*1.0*100*100*(1 - (x**2 + y**2))

    cs = numpy.ones_like(x) * 10000.0

    # u is set later
    v = z
    u_f = 0.059

    p *= 0
    h *= 1
    #u = 0.1*numpy.sin(x*pi/2.0/5.0)
    #u[numpy.flatnonzero(x<0.01)] = 0
    pa = base.get_particle_array(x=x+spacing, y=y, m=m, rho=rho, h=h, p=p, u=z, v=v, z=z,w=z,
                                 ubar=z, vbar=z, wbar=z,
                                 name='right_ball', type=1,
                                 sigma00=z, sigma11=z, sigma22=z,
                                 sigma01=z, sigma12=z, sigma02=z,
                                 MArtStress00=z, MArtStress11=z, MArtStress22=z,
                                 MArtStress01=z, MArtStress12=z, MArtStress02=z,
                                 #bdry=bdry
                                 )

    pa.constants['E'] = 1e7
    pa.constants['nu'] = 0.3975
    pa.constants['G'] = pa.constants['E']/(2.0*(1+pa.constants['nu']))
    pa.constants['K'] = stress_funcs.get_K(pa.constants['G'], pa.constants['nu'])
    pa.constants['rho0'] = 1.0
    pa.constants['dr0'] = dx
    pa.constants['c_s'] = (pa.constants['K']/pa.constants['rho0'])**0.5
    pa.cs = numpy.ones_like(x) * pa.constants['c_s']
    print 'c_s:', pa.c_s
    print 'G:', pa.G/pa.c_s**2/pa.rho0
    pa.u = pa.c_s*u_f*(2*(x<0)-1)
    print 'u_f:', pa.u[0]/pa.c_s, '(%s)'%pa.u[0]

    pa.set(idx=numpy.arange(len(pa.x)))
    print 'Number of particles: ', len(pa.x)
    print 'CFL:', pa.c_s*dt/dx/2
    print 'particle_motion:', abs(pa.u[0]*dt)


    if two_arr:
        pb = base.get_particle_array(x=x-spacing, y=y, m=m, rho=rho, h=h, p=p, u=u, v=v, z=z,w=z,
                                     ubar=z, vbar=z, wbar=z,
                                     name='left_ball', type=1,
                                     sigma00=z, sigma11=z, sigma22=z,
                                     sigma01=z, sigma12=z, sigma02=z,
                                     MArtStress00=z, MArtStress11=z, MArtStress22=z,
                                     MArtStress01=z, MArtStress12=z, MArtStress02=z,
                                     #bdry=bdry
                                     )

        pb.constants['E'] = 1e7
        pb.constants['nu'] = 0.3975
        pb.constants['G'] = pb.constants['E']/(2.0*1+pb.constants['nu'])
        pb.constants['K'] = stress_funcs.get_K(pb.constants['G'], pb.constants['nu'])
        pb.constants['rho0'] = 1.0
        pb.constants['c_s'] = (pb.constants['K']/pb.constants['rho0'])**0.5
        pb.cs = numpy.ones_like(x) * pb.constants['c_s']
        print 'c_s:', pb.c_s
        print 'G:', pb.G/pb.c_s**2/pb.rho0
        print 'G_mu', pa.G/pa.K
        pa.u = pa.c_s*u_f*(2*(x<0)-1)
        print 'u_f:', pb.u[-1]/pb.c_s, '(%s)'%pb.u[-1]
        
        pb.set(idx=numpy.arange(len(pb.x)))
        print 'Number of particles: ', len(pb.x)

        return [pa, pb]
    else:
        return pa
Ejemplo n.º 4
0
def create_particles():
    #x,y = numpy.mgrid[-1.05:1.05+1e-4:dx, -0.105:0.105+1e-4:dx]
    dx = 0.002 # 2mm
    R = 0.02
    xl = -0.05
    L = 0.2

    x,y,z = numpy.mgrid[xl:L+dx/2:dx, -R/2:(R+dx)/2:dx, -R/2:(R+dx)/2:dx]
    x = x.ravel()
    y = y.ravel()
    z = z.ravel()
    r2 = y**2+z**2
    keep = numpy.flatnonzero(r2<R*R/4)
    x = x[keep]
    y = y[keep]
    z = z[keep]

    bdry = (x<dx/2)*1.0
    bdry_indices = numpy.flatnonzero(bdry)
    rod_indices = numpy.flatnonzero(1-bdry)
    x2 = x[bdry_indices]
    y2 = y[bdry_indices]
    z2 = z[bdry_indices]
    x = x[rod_indices]
    y = y[rod_indices]
    z = z[rod_indices]

    print 'num_particles:', len(x), 'num_bdry_particles:', len(x2)
    #print bdry, numpy.flatnonzero(bdry)
    m = numpy.ones_like(x)*dx**dim
    m2 = numpy.ones_like(x2)*dx**dim
    h = numpy.ones_like(x)*1.5*dx
    h2 = numpy.ones_like(x2)*1.5*dx
    rho = numpy.ones_like(x)
    rho2 = numpy.ones_like(x2)

    p = u = x*0
    vel_max = 1
    v = z*vel_max/max(z)*sin(pi*x/2/L)
    w = -y*vel_max/max(y)*sin(pi*x/2/L)
    p2 = u2 = v2 = w2 = x2*0


    pa = get_particle_array(x=x, y=y, z=z, m=m, rho=rho, h=h, p=p, u=u, v=v, w=w,
                            name='solid',
                            )

    pa.constants['E'] = 1e9
    pa.constants['nu'] = 0.25
    pa.constants['G'] = pa.constants['E']/(2.0*(1+pa.constants['nu']))
    pa.constants['K'] = stress_funcs.get_K(pa.constants['G'], pa.constants['nu'])
    pa.constants['rho0'] = 1.0
    pa.constants['dr0'] = dx
    pa.constants['c_s'] = (pa.constants['K']/pa.constants['rho0'])**0.5
    pa.cs = numpy.ones_like(x) * pa.constants['c_s']
    print 'c_s:', pa.c_s
    print 'G:', pa.G/pa.c_s**2/pa.rho0

    print 'v_f:', pa.v[-1]/pa.c_s, '(%s)'%pa.v[-1]
    print 'T:', 2*numpy.pi/(pa.E*0.02**2*(1.875/0.2)**4/(12*pa.rho0*(1-pa.nu**2)))**0.5
    pa.set(idx=numpy.arange(len(pa.x)))
    print 'Number of particles: ', len(pa.x)
    #print 'CFL:', pa.c_s*dt/dx/2
    #print 'particle_motion:', -pa.u[-1]*dt

    # boundary particle array
    pb = get_particle_array(x=x2, x0=x2, y=y2, y0=y2, z=z2, z0=z2,
                            m=m2, rho=rho2,
                            h=h2, p=p2,
                            name='bdry', type=1,
                            )

    pb.constants['E'] = 1e7
    pb.constants['nu'] = 0.25
    pb.constants['G'] = pb.constants['E']/(2.0*(1+pb.constants['nu']))
    pb.constants['K'] = stress_funcs.get_K(pb.constants['G'], pb.constants['nu'])
    pb.constants['rho0'] = 1.0
    pb.constants['dr0'] = dx
    pb.constants['c_s'] = (pb.constants['K']/pb.constants['rho0'])**0.5
    pb.cs = numpy.ones_like(x2) * pb.constants['c_s']

    return [pa, pb]