Exemplo n.º 1
0
def iliev_test_5(N=10000,
                 L=15. | units.kpc,
                 source_luminosity=5.e48 | units.s**-1,
                 rhoinit=0.001 | (units.amu / units.cm**3),
                 Tinit=100. | units.K,
                 hydro_parameters=dict(),
                 rad_parameters=dict()):

    gamma = 5. / 3.
    mu = 1. | units.amu

    gas = Particles(N)
    # set particles homogeneously in space
    gas.x = L * numpy.random.uniform(-1., 1., N)
    gas.y = L * numpy.random.uniform(-1., 1., N)
    gas.z = L * numpy.random.uniform(-1., 1., N)
    # set other properties
    gas.h_smooth = 0. | units.parsec
    gas.vx = 0. | (units.km / units.s)
    gas.vy = 0. | (units.km / units.s)
    gas.vz = 0. | (units.km / units.s)
    gas.u = 1 / (gamma - 1) * constants.kB * Tinit / mu
    gas.rho = rhoinit
    gas.mass = rhoinit * (2 * L)**3 / N
    gas.flux = 0. | (units.s**-1)
    gas.xion = 0. | units.none

    # set source in the center of the box
    sources = Particles(1)
    sources.x = 0. * L
    sources.y = 0. * L
    sources.z = 0. * L
    sources.luminosity = source_luminosity

    return gas, sources
Exemplo n.º 2
0
def particles_from_input_file(input_file):
    x, y, z, n_H, flux, X_ion, u = read_input_file(input_file)
    particles = Particles(len(x))
    particles.x = x | units.parsec
    particles.y = y | units.parsec
    particles.z = z | units.parsec
    particles.rho = n_H | units.amu / units.cm**3
    particles.flux = flux | 1.0e48 / units.s
    particles.xion = X_ion | units.none
    particles.u = u | (units.cm**2 / units.s**2)
    return particles
Exemplo n.º 3
0
def particles_from_input_file(input_file):
    x, y, z, n_H, flux, X_ion,u = read_input_file(input_file)
    particles = Particles(len(x))
    particles.x = x | units.parsec
    particles.y = y | units.parsec
    particles.z = z | units.parsec
    particles.rho = n_H | units.amu / units.cm**3
    particles.flux = flux | 1.0e48 / units.s
    particles.xion = X_ion | units.none
    particles.u = u | (units.cm**2/units.s**2)
    return particles
Exemplo n.º 4
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