Beispiel #1
0
def init():
  global M_dm, M_disk, M_bulge, M_gas
  global N_dm, N_disk, N_bulge, N_gas
  global a_dm, a_bulge, Rd, z0
  global N_CORES, output
  global N_temp, N_range
  flags = parser(description="Description.")
  flags.add_argument('-o', help='The name of the output file.',
                     metavar="init.dat", default="init.dat")
  flags.add_argument('-cores', help='The number of cores to use.',
                     default=1)

  args = flags.parse_args()
  output = args.o
  N_CORES = int(args.cores)

  if not (path.isfile("header.txt") and path.isfile("galaxy_param.txt")):
    print "header.txt or galaxy_param.txt missing."
    exit(0)

  vars_ = process_input("galaxy_param.txt")
  M_dm, M_disk, M_bulge, M_gas = (float(i[0]) for i in vars_[0:4])
  N_dm, N_disk, N_bulge, N_gas = (int(i[0]) for i in vars_[4:8])
  a_dm, a_bulge, Rd, z0 = (float(i[0]) for i in vars_[8:12])
  N_temp = {'gas': int(1e4), 'dm': int(5e4), 'disk': int(2e4), 'bulge': int(2e4)}
  N_range = {'gas': np.linspace(N_temp['gas'], N_gas, 20), 
             'dm': np.linspace(N_temp['dm'], N_dm, 20), 
             'disk': np.linspace(N_temp['disk'], N_disk, 20), 
             'bulge': np.linspace(N_temp['bulge'], N_bulge, 20)}
Beispiel #2
0
def init():
  global M_halo, M_disk, M_bulge, M_gas
  global N_halo, N_disk, N_bulge, N_gas
  global a_halo, a_bulge, Rd, z0, z0_gas
  global N_total, M_total
  global phi_grid, rho_axis, z_axis, N_rho, Nz
  global halo_core, bulge_core, N_CORES, force_yes, output, gas, factor, Z
  flags = parser(description="Generates an initial conditions file for a\
                              galaxy simulation with halo, stellar disk,\
                              gaseous disk and bulge components.")
  flags.add_argument('--nogas', help='Generates a galaxy without gas.',
                     action='store_true')
  flags.add_argument('-cores', help='The number of cores to use during the\
                                     potential canculation. Make sure this\
                                     number is a factor of N_rho*N_z.',
                     default=1)
  flags.add_argument('--force-yes', help='Don\'t ask if you want to use the\
                                          existing potential_data.txt file.\
                                          Useful for automating the execution\
                                          of the script.', action='store_true')
  flags.add_argument('-o', help='The name of the output file.',
                     metavar="init.dat", default="init.dat")
  args = flags.parse_args()
  gas = not args.nogas
  N_CORES = int(args.cores)
  force_yes = args.force_yes
  output = args.o

  if not (path.isfile("header.txt") and path.isfile("params_galaxy.txt")):
    print "header.txt or params_galaxy.txt missing."
    exit(0)

  vars_ = process_input("params_galaxy.txt")
  M_halo, M_disk, M_bulge, M_gas = (float(i[0]) for i in vars_[0:4])
  N_halo, N_disk, N_bulge, N_gas = (float(i[0]) for i in vars_[4:8])
  a_halo, a_bulge, Rd, z0, z0_gas = (float(i[0]) for i in vars_[8:13])
  halo_core, bulge_core = (i[0][:-1] == 'True' for i in vars_[13:15])
  factor = float(vars_[15][0])
  Z = float(vars_[16][0])

  z0_gas *= z0
  if not gas:
    N_gas = 0
    M_gas = 0
  M_total = M_disk + M_bulge + M_halo + M_gas
  N_total = N_disk + N_bulge + N_halo + N_gas
  N_rho = Nz = 256 # Make sure N_CORES is a factor of N_rho*Nz.
  phi_grid = np.zeros((N_rho, Nz))
  rho_max = 300 * a_halo
  # This has to go far so I can estimate the integrals below.
  z_max = 3000 * a_halo 
  rho_axis = np.logspace(-2, log10(rho_max), N_rho)
  z_axis = np.logspace(-2, log10(z_max), Nz)
Beispiel #3
0
def init():
    global gas, dm, gas_core, dm_core, output
    global M_dm, a_dm, N_dm, M_gas, a_gas, N_gas
    global max_radius
    flags = parser(description="Generates an initial conditions file\
                                for a galaxy cluster halo simulation.")
    flags.add_argument('--gas-core', help='Sets the density profile for the\
                       gas to have a core.', action='store_true')
    flags.add_argument('--dm-core', help='The same, but for the dark matter.',
                       action='store_true')
    flags.add_argument('--no-dm', help='No dark matter particles in the\
                       initial conditions. The dark matter potential is\
                       still used when calculating the gas temperatures.',
                       action='store_true')
    flags.add_argument('--no-gas', help='No gas, only dark matter.',
                       action='store_true')
    flags.add_argument('-o', help='The name of the output file.',
                       metavar="init.dat", default="init.dat")
    args = flags.parse_args()
    gas_core = args.gas_core
    dm_core = args.dm_core
    output = args.o
    if not (path.isfile("header.txt") and path.isfile("params_cluster.txt")):
        print "header.txt or params_cluster.txt missing."
        exit(0)
    if args.no_dm:
        if args.no_gas:
            print "Neither gas or dark matter were selected!"
            exit(0)
        else:
            gas = True
            dm = False
    elif args.no_gas:
        gas = False
        dm = True
    else:
        gas = True
        dm = True
    vars_ = process_input("params_cluster.txt")
    M_dm, a_dm, N_dm = (float(i[0]) for i in vars_[0:3])
    if(gas):
        M_gas, a_gas, N_gas = (float(i[0]) for i in vars_[3:6])
    max_radius = float(vars_[6][0])
Beispiel #4
0
def init():
    global M_dm, M_disk, M_bulge, M_gas
    global N_dm, N_disk, N_bulge, N_gas
    global a_dm, a_bulge, Rd, z0
    global N_CORES, output
    global N_temp, N_range
    flags = parser(description="Description.")
    flags.add_argument('-o',
                       help='The name of the output file.',
                       metavar="init.dat",
                       default="init.dat")
    flags.add_argument('-cores', help='The number of cores to use.', default=1)

    args = flags.parse_args()
    output = args.o
    N_CORES = int(args.cores)

    if not (path.isfile("header.txt") and path.isfile("galaxy_param.txt")):
        print "header.txt or galaxy_param.txt missing."
        exit(0)

    vars_ = process_input("galaxy_param.txt")
    M_dm, M_disk, M_bulge, M_gas = (float(i[0]) for i in vars_[0:4])
    N_dm, N_disk, N_bulge, N_gas = (int(i[0]) for i in vars_[4:8])
    a_dm, a_bulge, Rd, z0 = (float(i[0]) for i in vars_[8:12])
    N_temp = {
        'gas': int(1e4),
        'dm': int(5e4),
        'disk': int(2e4),
        'bulge': int(2e4)
    }
    N_range = {
        'gas': np.linspace(N_temp['gas'], N_gas, 20),
        'dm': np.linspace(N_temp['dm'], N_dm, 20),
        'disk': np.linspace(N_temp['disk'], N_disk, 20),
        'bulge': np.linspace(N_temp['bulge'], N_bulge, 20)
    }