示例#1
0
文件: stress1d.py 项目: sabago/pysph
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
示例#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
示例#3
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]