Beispiel #1
0
def run_grid(models_dir, n_proc):
    pc.print_make_file(models_dir)

    # To have the full list of possible extensions:
    # print pc.config.SAVE_LIST
    # Here we set to nothing the list of cloudy's output files.
    # Only the .lin files will be output
    pc.config.SAVE_LIST = []
    pc.config.SAVE_LIST_ELEMS = []

    # Metallicity table
    Zs = np.array([0.1, 0.2, 0.3, 0.4, 0.6, 0.8, 1.0, 1.5])
    # Ionization parameter table
    logUs = [-2, -2.3, -2.7, -3, -3.3, -3.7, -4]

    # loop on the tables to write the input files
    for Z in Zs:
        for logU in logUs:
            make_model(name='G_{0:.1f}_{1:.1f}'.format(logU, Z), logU=logU,
                       logZ=np.log10(Z), models_dir=models_dir)
            
    # Run all the models
    pc.run_cloudy(dir_ = models_dir, n_proc = n_proc)
Beispiel #2
0
        'C': -3.60,
        'N': -3.45,
        'O': 8.55 - 12,
        'Ne': -4.3,
        'Mg': -4.95,
        'Si': -4.90,
        'S': -5.35,
        'Cl': -7.00,
        'Ar': -6.,
        'Fe': -7.40
    }

    pc.log_.level = 3
    # create the object that generates the input files
    #for i, Teff in enumerate([120000, 120000, 130000]):
    Min = In(models_dir, '{0}_{1}'.format(model_name, i), r_in, dens, Teff, Q0,
             ab_dict, distance)
    Min.print_model()

    # run the models
    pc.run_cloudy(dir_=models_dir,
                  n_proc=3,
                  use_make=True,
                  model_name=model_name)

    # read the models
    pc.log_.level = 2
    Mouts = Outs(models_dir, model_name)
    # output the parameters and line intensities, with the observations in 1rst column
    Mouts.print_res()
Beispiel #3
0
"""
Question 6.1.1
"""
models_dir = 'CloudyModels' #Create this directory if necessary
pc.config.cloudy_exe = '/usr/local/Cloudy/c10.00/cloudy.exe' # point to the location of Cloudy.exe

# Print the Makefile in th emodels_dir directory (only needed one time)
pc.print_make_file(models_dir)
# Print a file containing the line for intensities
ex6_1.print_line_file(models_dir)

# prepare models with different Q(H)
for qH in [43, 44, 45, 46, 47, 48]:
    ex6_1.make_mod(models_dir, name='M_61.1_{0}'.format(qH), Teff=5e4, qH=qH, dens=3, r_in=17)
# run all the models in models_dirs starting with M_61.1
pc.run_cloudy(dir_=models_dir, n_proc=3, use_make=True,  model_name='M_61.1')
M43 = pc.CloudyModel('{0}/M_61.1_43'.format(models_dir), read_lin = True)
# load all the models in the models list
models = pc.load_models('{0}/M_61.1_'.format(models_dir), read_lin = True)

# make some plots
ex6_1.plot_Hb(models)

for m in models:
    # A posteriori cut of the model
    # Line intensities are not changed. Integral of Emissivities are changed.
    m.r_out_cut = 1.5e17
# make the same plots
ex6_1.plot_Hb(models)

# prepare models with different Teff
Beispiel #4
0
pc.log_.timer('Init', quiet=True)
# Generic name of the models
model_name = 'model_2'
# tables for the values of the density and the log(O/H)
tab_dens = [3, 4, 5, 6]
tab_ab_O = [-3.1, -3.25, -3.4, -3.55, -3.7]

# defining the models and writing 20 input files
for dens in tab_dens:
    for ab_O in tab_ab_O:
        make_model(dir_, model_name, dens, ab_O)

# Running the models using the makefile and n_proc processors
n_proc = 3
pc.log_.timer('models defined')
pc.run_cloudy(dir_=dir_, n_proc=n_proc, model_name=model_name, use_make=True)
pc.log_.timer('models run')
# reading the Cloudy outputs and putting them in a list of CloudyModel objects
Ms = pc.load_models('{0}{1}'.format(dir_, model_name), read_grains=False)
pc.log_.timer('models loaded')

#Computing line intensity ratios
rO3 = [
    np.log10(M.get_emis_vol('O__3__5007A') / M.get_emis_vol('TOTL__4363A'))
    for M in Ms
]
rO2 = [
    np.log10(M.get_emis_vol('O_II__3726A') / M.get_emis_vol('O_II__3729A'))
    for M in Ms
]
# defining the colors associated to the Oxygen abundances
Beispiel #5
0
pc.log_.timer('Init', quiet = True)
# Generic name of the models
model_name = 'model_2'
# tables for the values of the density and the log(O/H)
tab_dens = [3, 4, 5, 6]
tab_ab_O = [-3.1, -3.25, -3.4, -3.55, -3.7]

# defining the models and writing 20 input files
for dens in tab_dens:
    for ab_O in tab_ab_O:
        make_model(dir_, model_name, dens, ab_O)

# Running the models using the makefile and n_proc processors
n_proc = 3
pc.log_.timer('models defined')
pc.run_cloudy(dir_ = dir_, n_proc = n_proc, model_name = model_name, use_make = True)
pc.log_.timer('models run')
# reading the Cloudy outputs and putting them in a list of CloudyModel objects
Ms = pc.load_models('{0}{1}'.format(dir_, model_name), read_grains = False)
pc.log_.timer('models loaded')

#Computing line intensity ratios 
rO3 = [np.log10(M.get_emis_vol('O__3__5007A')/M.get_emis_vol('TOTL__4363A')) for M in Ms]
rO2 = [np.log10(M.get_emis_vol('O_II__3726A')/M.get_emis_vol('O_II__3729A')) for M in Ms]
# defining the colors associated to the Oxygen abundances
col = [M.abund['O'] for M in Ms]
# defining the size as the density (at the first step, but in these models it's constant)
size = [np.log10(M.nH[0])*20 for M in Ms]

#plotting the result
plt.figure()
Beispiel #6
0
 def run_cloudy(self, model_name="", use_make=True, n_proc=2):
     pc.run_cloudy(dir_=self.path,
                   n_proc=n_proc,
                   model_name=model_name,
                   use_make=use_make)