Exemplo n.º 1
0
def iliev_test_7_ic(N=10000, Ns=10, L=6.6 | units.kpc):
    print "Initializing iliev_test_7"

    mp = rhoinit * (2 * L)**3 / N
    Nc = ((rhoclump * 4 * constants.pi / 3 * (0.8 | units.kpc)**3) / mp)
    Nc = int(Nc)

    print Nc

    try:
        f = open("glass%9.9i.pkl" % N, "rb")
        x, y, z = cPickle.load(f)
        f.close()
    except:
        x, y, z = glass_unit_cube(N, target_rms=0.05).make_xyz()
        f = open("glass%9.9i.pkl" % N, "wb")
        cPickle.dump((x, y, z), f)
        f.close()

    sel = numpy.where(((x -
                        (5. / 6.6))**2 + y**2 + z**2)**0.5 > (0.8 / 6.6))[0]

    x = x[sel]
    y = y[sel]
    z = z[sel]

    p = Particles(len(x))
    print len(x)
    # set particles homogeneously in space
    p.x = L * x
    p.y = L * y
    p.z = L * z

    # set other properties
    p.h_smooth = 0. | units.parsec
    p.vx = 0. | (units.km / units.s)
    p.vy = 0. | (units.km / units.s)
    p.vz = 0. | (units.km / units.s)
    p.u = uinit
    p.rho = rhoinit
    p.mass = mp
    p.flux = 0. | (units.s**-1)
    p.xion = 0. | units.none

    sources = Particles(Ns)
    x, y, z = uniform_unit_sphere(Ns).make_xyz()
    if Ns == 1:
        x, y, z = 0., 0., 0.

    sources.x = -(5. | units.kpc) + L * x * (1. / N)**(1. / 3) / 10
    sources.y = L * y * (1. / N)**(1. / 3) / 10
    sources.z = L * z * (1. / N)**(1. / 3) / 10
    sources.luminosity = (1.2e52 / Ns) | (units.s**-1)
    sources.SpcType = 1.

    clump = Particles(Nc)
    x, y, z = uniform_unit_sphere(Nc).make_xyz()

    clump.x = (5. | units.kpc) + (0.8 | units.kpc) * x
    clump.y = (0.8 | units.kpc) * y
    clump.z = (0.8 | units.kpc) * z

    clump.h_smooth = 0. | units.parsec
    clump.vx = 0. | (units.km / units.s)
    clump.vy = 0. | (units.km / units.s)
    clump.vz = 0. | (units.km / units.s)
    clump.u = uclump
    clump.rho = rhoclump
    clump.mass = mp
    clump.flux = 0. | (units.s**-1)
    clump.xion = 0. | units.none

    p.add_particles(clump)

    return p, sources