コード例 #1
0
def make_model(dic_, model_name, dens, ab0, n_column, ionpar):

    full_model_name = '{0}_nH{1:.2f}_Z{2:.1f}_NH{3:.1f}_U{4:.2f}'.format(
        model_name, dens, ab0, n_column, ionpar)
    emis_tab = [
        'H  1     1215.67A', 'h  1     6562.81A', 'c  4  1548.19A',
        'he 2     1640.43A'
    ]
    c_input = pc.CloudyInput('{0}{1}'.format(dic_, full_model_name))
    c_input.set_star(SED='table agn',
                     SED_params='6.0 -1.4 -0.5 -1.0',
                     lumi_unit='ionization parameter',
                     lumi_value=ionpar)
    c_input.set_sphere(sphere=False)
    c_input.set_radius(r_in=23, r_out=23.5)
    c_input.set_distance(dist=18544., unit='Mpc', linear=True)
    c_input.set_abund(predef='GASS', nograins=True, metals=ab0)
    c_input.set_cste_density(dens)
    c_input.set_other(
        ('covering factor 0.3', 'CMB redshift 2.3116', 'set trim -20',
         'turbulence 50 km/s', 'COSMIC RAY BACKGROUND', 'print last'))
    c_input.set_emis_tab(emis_tab)
    c_input.set_iterate(to_convergence=True)
    c_input.set_stop(stop_criter=[
        'temperature 10K linear',
        'column density %d' % n_column, 'neutral column density 17.2'
    ])
    c_input.print_input(to_file=True, verbose=False)
コード例 #2
0
ファイル: test_3D1.py プロジェクト: zsw6666/pyCloudy
def set_models(dir_, model_name):
    emis_tab = [
        'H  1  4861',
        'H  1  6563',
        'He 1  5876',
        'N  2  6584',
        'O  1  6300',
        'O II  3726',
        'O II  3729',
        'O  3  5007',
        'TOTL  4363',
    ]
    a = 2.
    b = 1.0
    thetas = np.linspace(0., 90., 6)
    thetas_rad = np.pi / 180. * thetas
    fact_elli = a * b / np.sqrt((b * np.sin(thetas_rad))**2 +
                                (a * np.cos(thetas_rad))**2)
    rs_in = 16.5 + np.log10(fact_elli)
    densities = 4 - np.log10(fact_elli) * 2

    model = pc.CloudyInput()
    model.set_BB(80000., 'q(H)', 47.3)
    model.set_grains()
    model.set_emis_tab(emis_tab)

    for theta, r_in, density in zip(thetas, rs_in, densities):
        model.model_name = '{0}/{1}_{2:.0f}'.format(dir_, model_name, theta)
        model.set_cste_density(density)
        model.set_radius(r_in)
        model.set_theta_phi(theta)
        model.print_input(to_file=True, verbose=False)
コード例 #3
0
ファイル: ex6_3.py プロジェクト: kakirastern/PyNeb_devel
def make_model(name, logU, logZ, models_dir='./'):
    """
    
    Z : log of Z/Zsol
    """
    pc.log_.level=3

    abund_AGSS09 = {'He' : 10.93, 'C' : 8.43, 'N' : 7.83, 'O' : 8.69, 'Ne' : 7.93, 'Mg' : 7.6,
             'S' : 7.12, 'Ar' : 6.40, 'Fe' : 7.5, 'Cl' : 5.5, 'Si' : 7.51}
    for elem in abund_AGSS09:
        abund_AGSS09[elem] -= 12
        if elem != 'He':
            abund_AGSS09[elem] += logZ

    options = ('no molecules',
               'no level2 lines',
               'no fine opacities',
               'atom h-like levels small',
               'atom he-like levels small',
               'COSMIC RAY BACKGROUND',
               'element limit off -8',
               )
    
    c_input = pc.CloudyInput('{0}/{1}'.format(models_dir, name))
    c_input.set_star(SED = 'table star "ISB_008.mod"', SED_params = 1000000, 
                     lumi_unit = 'ionization parameter', lumi_value=logU)
    # Defining the density. You may also use set_dlaw(parameters) if you have a density law defined in dense_fabden.cpp.
    c_input.set_cste_density(2)
    c_input.set_abund(ab_dict = abund_AGSS09, nograins = True)
    c_input.set_other(options)
    c_input.set_line_file('line_list.dat')
    c_input.set_iterate() # (0) for no iteration, () for one iteration, (N) for N iterations.
    c_input.set_sphere(False) # () or (True) : sphere, or (False): open geometry.
    c_input.set_distance(dist=10., unit='Mpc', linear=True) # unit can be 'kpc', 'Mpc', 'parsecs', 'cm'. If linear=False, the distance is in log.
    c_input.print_input()
コード例 #4
0
ファイル: make_3MdB_17.py プロジェクト: premvijay/pyCloudy
def test_labels(model_name, run_it = True):
    full_model_name = '{0}{1}'.format(dir_, model_name)
    dens = 4. #log cm-3
    Teff = 200000. #K
    qH = 47. #s-1
    r_min = 5e16 #cm
    dist = 1.26 #kpc
    options = ('no molecules',
                'COSMIC RAY BACKGROUND'
                )
    abund = {'He' : -0.92, 'C' : 6.85 - 12, 'N' : -4.0, 'O' : -3.40, 'Ne' : -4.00, 
             'S' : -5.35, 'Ar' : -5.80, 'Fe' : -7.4, 'Cl' : -7.00}

    c_input = pc.CloudyInput(full_model_name)
    c_input.set_BB(Teff = Teff, lumi_unit = 'q(H)', lumi_value = qH)
    c_input.set_cste_density(dens)
    # Defining the inner radius. A second parameter would be the outer radius (matter-bounded nebula).
    c_input.set_radius(r_in=np.log10(r_min))
    c_input.set_abund(ab_dict = abund, nograins = True)
    c_input.set_other(options)
    c_input.set_iterate() # (0) for no iteration, () for one iteration, (N) for N iterations.
    c_input.set_sphere() # () or (True) : sphere, or (False): open geometry.
    c_input.set_emis_tab(get_emis_tab()) # better use read_emis_file(file) for long list of lines, where file is an external file.
    c_input.set_distance(dist=dist, unit='kpc', linear=True) # unit can be 'kpc', 'Mpc', 'parsecs', 'cm'. If linear=False, the distance is in log.
    
    # Writing the Cloudy inputs. to_file for writing to a file (named by full_model_name). verbose to print on the screen.
    c_input.print_input(to_file = True, verbose = False)
    if run_it:
        c_input.run_cloudy()
コード例 #5
0
ファイル: pyCloudy_scriptCM.py プロジェクト: cfin6/Tc1
    def call_pyCloudy(self):

        #===============================================================
        # Verbosity level
        #===============================================================
        pc.log_.level = 1

        #===============================================================
        # Cloudy model object
        #===============================================================
        c_input = pc.CloudyInput('{0}{1}'.format(self.dir_, self.model_name))

        #===============================================================
        # filling the object
        #===============================================================

        # ionizing spectrum, Teff and L*
        if self.SED == 'WMbasic':
            c_input.set_star(SED='table star wmbasic',
                             SED_params='{} {} {}'.format(
                                 self.Temp, self.gStel, self.Zstel),
                             lumi_unit=self.luminosity_unit,
                             lumi_value=self.luminosity)
        elif self.SED == 'BB':
            c_input.set_BB(Teff=self.Temp,
                           lumi_unit=self.luminosity_unit,
                           lumi_value=self.luminosity)
        else:
            raise ValueError('ERROR: SED {} unknown'.format(self.SED))
        #gas density (nH)
        c_input.set_cste_density(self.densi, ff=self.ff)

        #Inner radius
        c_input.set_radius(r_in=self.inner_radius, r_out=self.outer_radius)

        #Abundances
        c_input.set_abund(ab_dict=self.abund, nograins=True)
        #c_input.set_grains('Orion graphite 6')
        c_input.set_grains('"{}" {}'.format(self.dust_type, self.dust))
        #Other options
        c_input.set_other(self.options)
        c_input.set_iterate()
        c_input.set_sphere(True)

        # Table with te lines to print the emissivities
        # Needed for the 3D model to simulate the maps

        c_input.set_emis_tab(self.emis_tab.values())

        # distance in kpc
        c_input.set_distance(self.distance)

        c_input.print_input()

        c_input.run_cloudy()
コード例 #6
0
def make_model(dir_, model_name, dens, ab_O):
    full_model_name = '{0}_{1:.0f}_{2:.2f}'.format(model_name, dens, ab_O)
    r_min = 5e16
    dist = 1.26
    Teff = 45000
    qH = 47.
    options = (
        'no molecules',
        'no level2 lines',
        'no fine opacities',
        'atom h-like levels small',
        'atom he-like levels small',
        'COSMIC RAY BACKGROUND',
        'element limit off -8',
    )
    emis_tab = [
        'H  1  4861', 'H  1  6563', 'He 1  5876', 'N  2  6584', 'O  1  6300',
        'O II  3726', 'O II  3729', 'O  3  5007', 'TOTL  4363', 'O  1 63.17m',
        'O  1 145.5m', 'C  2 157.6m', 'H  1 4.051m'
    ]
    abund = {
        'He': -0.92,
        'C': -3.15,
        'N': -4.0,
        'Ne': -4.00,
        'S': -5.35,
        'Ar': -5.80,
        'Fe': -7.4,
        'Cl': -7.00
    }
    abund['O'] = ab_O
    # Defining the object that will manage the input file for Cloudy
    c_input = pc.CloudyInput('{0}{1}'.format(dir_, full_model_name))
    # Filling the object with the parameters
    # Defining the ionizing SED: Effective temperature and luminosity.
    # The lumi_unit is one of the Cloudy options, like "luminosity solar", "q(H)", "ionization parameter", etc...
    c_input.set_BB(Teff=Teff, lumi_unit='q(h)', lumi_value=qH)
    # Defining the density. You may also use set_dlaw(parameters) if you have a density law defined in dense_fabden.cpp.
    c_input.set_cste_density(dens)
    # Defining the inner radius. A second parameter would be the outer radius (matter-bounded nebula).
    c_input.set_radius(np.log10(r_min))
    c_input.set_abund(ab_dict=abund, nograins=True)
    c_input.set_other(options)
    c_input.set_iterate(
    )  # (0) for no iteration, () for one iteration, (N) for N iterations.
    c_input.set_sphere()  # () or (True) : sphere, or (False): open geometry.
    c_input.set_emis_tab(emis_tab)
    c_input.set_distance(dist, 'kpc')
    c_input.print_input(to_file=True, verbose=False)
コード例 #7
0
def model_TempDen_variation(Te, ne, simu_address):
    logTe = np.log10(Te)
    cloudy_model = pc.CloudyInput('{}M_i_Te{}_ne{}'.format(simu_address, Te, ne))
    cloudy_model.set_other(('init file "hheonly.ini"'))
    cloudy_model.set_other(('element helium abundance -3'))
    cloudy_model.set_BB(Teff=Teff, lumi_unit='q(H)', lumi_value=qH)
    cloudy_model.set_radius(r_in=dist)
    cloudy_model.set_other(('constant temperature {}'.format(logTe)))
    cloudy_model.set_cste_density(dens)
    cloudy_model.set_other(('database H-like levels large element hydrogen'))
    cloudy_model.set_other(('database H-like levels large element helium'))
    cloudy_model.set_other(('set dr 0'))
    cloudy_model.set_stop(('zone 1'))
    cloudy_model.set_emis_tab(emis_tab)  # better use read_emis_file(file) for long list of lines, where file is an external file
    cloudy_model.print_input()
    return cloudy_model
コード例 #8
0
def large_H_He_orders_grid(temp, dens, model_name, H_He_lines_labels):
    logTe = np.log10(temp)
    logne = np.log10(dens)
    cloudy_model = pc.CloudyInput(model_name)
    cloudy_model.set_other(('init file "hheonly.ini"'))
    cloudy_model.set_other(('element helium abundance -3'))
    cloudy_model.set_BB(Teff=Teff, lumi_unit='q(H)', lumi_value=qH)
    cloudy_model.set_radius(r_in=dist)
    cloudy_model.set_other(('constant temperature {}'.format(logTe)))
    cloudy_model.set_cste_density(logne)
    cloudy_model.set_other(('database H-like levels large element hydrogen'))
    cloudy_model.set_other(('database H-like levels large element helium'))
    cloudy_model.set_other(('set dr 0'))
    cloudy_model.set_stop(('zone 1'))
    cloudy_model.set_emis_tab(H_He_lines_labels)
    cloudy_model.print_input()
    return cloudy_model
コード例 #9
0
def make_mod(models_dir,
             name,
             Teff,
             qH,
             dens,
             r_in,
             ff=1.0,
             metals=None,
             nograins=True):

    pc.log_.level = 3

    options = (
        'no molecules',
        'no level2 lines',
        'no fine opacities',
        'atom h-like levels small',
        'atom he-like levels small',
        'COSMIC RAY BACKGROUND',
        'element limit off -8',
    )

    c_input = pc.CloudyInput('{0}/{1}'.format(models_dir, name))
    c_input.set_BB(Teff=Teff, lumi_unit='q(H)', lumi_value=qH)
    # Defining the density. You may also use set_dlaw(parameters) if you have a density law defined in dense_fabden.cpp.
    c_input.set_cste_density(dens, ff=ff)
    # Defining the inner radius. A second parameter would be the outer radius (matter-bounded nebula).
    c_input.set_radius(r_in=r_in)
    if nograins:
        # If nograins is set, then the metals option only acts on the metallicity
        c_input.set_abund(predef='ism', nograins=nograins, metals=metals)
    else:
        # If nograins is False (ism grains will thus be used), the dust abundance follows the metallicity
        c_input.set_abund(predef='ism', nograins=nograins, metalsgrains=metals)
    c_input.set_other(options)
    c_input.set_iterate(
    )  # (0) for no iteration, () for one iteration, (N) for N iterations.
    c_input.set_sphere()  # () or (True) : sphere, or (False): open geometry.
    c_input.set_distance(
        dist=1., unit='kpc', linear=True
    )  # unit can be 'kpc', 'Mpc', 'parsecs', 'cm'. If linear=False, the distance is in log.
    c_input.set_line_file(line_file='lines.dat', absolute=True)
    c_input.set_emis_tab(emis_tab_str=['H  1  4861A'])
    c_input.set_stop(['temperature off', 'pfrac 0.02'])
    c_input.print_input()
コード例 #10
0
 def __init__(self, pars):
     '''
     Program for setting up parameters for pyCloudy to compute
     properties of nebulae.
     '''
     self.numdensity = pars[0]
     self.Teff = pars[1]
     self.qH = pars[2]
     self.r_min = pars[3]
     self.dist = pars[4]
     self.dir_ = './models/'
     self.model_name = 'model_test'
     self.full_model_name = '{0}{1}'.format(self.dir_, self.model_name)
     self.options = ('no molecules', 'no level2 lines', 'no fine opacities',
                     'atom h-like levels small', 'element limit off -8')
     self.emis_tab = [
         'H  1  4861.33A',  #hbeta
         'H  1  6562.81A',  #halpha
         'N  2  6583.45A',  #nii
         'O  3  5006.84A'
     ]  #oiii
     self.abund = {
         'He': -0.92,
         'C': 6.85 - 12,
         'N': -4.0,
         'O': -3.40,
         'Ne': -4.00,
         'S': -5.35,
         'Ar': -5.80,
         'Fe': -7.4,
         'Cl': -7.00
     }
     c_input = pc.CloudyInput(self.full_model_name)
     c_input.set_BB(Teff=self.Teff, lumi_unit='q(H)', lumi_value=self.qH)
     c_input.set_cste_density(self.numdensity)
     c_input.set_radius(r_in=np.log10(self.r_min))
     c_input.set_abund(ab_dict=self.abund, nograins=True)
     c_input.set_other(self.options)
     c_input.set_iterate()
     c_input.set_sphere()  #
     c_input.set_emis_tab(self.emis_tab)  #
     c_input.set_distance(dist=self.dist, unit='kpc', linear=True)
     c_input.print_input(to_file=True, verbose=False)
     self.c_input = c_input
コード例 #11
0
ファイル: ex6_4.py プロジェクト: kakirastern/PyNeb_devel
 def print_model(self):
     """
     Preparing and printing the Cloudy input file
     """
     # define the name of the model
     model = pc.CloudyInput(self.model_name)
     # send the variables to the CloudyInput object to be printed
     model.set_radius(self.r_in)
     model.set_cste_density(self.dens)
     model.set_distance(self.distance, unit='Mpc')
     model.set_abund(ab_dict=self.abund_dict)
     model.set_grains(self.grains)
     model.set_BB(Teff=self.Teff, lumi_unit='q(H)', lumi_value=self.Q0)
     # this is the file containing the list of emissivities we want
     model.read_emis_file(emis_file)
     model.set_iterate(0)
     model.set_sphere()
     model.set_other(self.options)
     # print the input file
     model.print_input(to_file=True, verbose=False)
     # store the model in a self variable to further interactions if needed
     self.model = model
コード例 #12
0
ファイル: ex6_2.py プロジェクト: MJChimal/PyNeb_devel
def make_model(name, models_dir='./', SED='BB', qH=None, SED_params=None, n_zones = None, iterate=1):
    pc.log_.level=3

    abund_AGSS09 = {'He' : 10.93, 'C' : 8.43, 'N' : 7.83, 'O' : 8.69, 'Ne' : 7.93, 'Mg' : 7.6,
             'S' : 7.12, 'Ar' : 6.40, 'Fe' : 7.5, 'Cl' : 5.5, 'Si' : 7.51}
    for elem in abund_AGSS09:
        abund_AGSS09[elem] -= 12
        if elem != 'He':
            abund_AGSS09[elem] -= 0.3

    options = ('no molecules',
               'no level2 lines',
               'no fine opacities',
               'atom h-like levels small',
               'atom he-like levels small',
               'COSMIC RAY BACKGROUND',
               'element limit off -8',
               )
    
    c_input = pc.CloudyInput('{0}/{1}'.format(models_dir, name))
    if SED == 'BB':
        c_input.set_BB(Teff = SED_params, lumi_unit = 'q(H)', lumi_value = qH)
    else:
        c_input.set_star(SED = SED, SED_params = SED_params, lumi_unit = 'q(H)', lumi_value=qH)
    # Defining the density. You may also use set_dlaw(parameters) if you have a density law defined in dense_fabden.cpp.
    c_input.set_cste_density(2, ff = 1.)
    # Defining the inner radius. A second parameter would be the outer radius (matter-bounded nebula).
    c_input.set_radius(r_in = np.log10(pc.CST.PC/10))
    c_input.set_abund(ab_dict = abund_AGSS09, nograins = True)
    c_input.set_other(options)
    c_input.set_iterate(iterate) # (0) for no iteration, () for one iteration, (N) for N iterations.
    c_input.set_sphere() # () or (True) : sphere, or (False): open geometry.
    c_input.set_distance(dist=1., unit='kpc', linear=True) # unit can be 'kpc', 'Mpc', 'parsecs', 'cm'. If linear=False, the distance is in log.
    if n_zones is not None:
        c_input.set_stop('zones {0}'.format(n_zones))
    c_input.print_input()
    
    c_input.run_cloudy()
コード例 #13
0
ファイル: ex6_5.py プロジェクト: kakirastern/PyNeb_devel
 def print_model(self):
     """
     Preparing and printing the Cloudy input file
     """
     model = pc.CloudyInput(self.model_name)
     model.set_radius(self.r_in)
     model.set_dlaw(self.dlaw_params, self.ff)
     model.set_distance(self.distance)
     model.set_abund(ab_dict=self.abunds)
     for grains, grains_type in zip(self.grains, self.grains_type):
         model.set_grains('{0} {1}'.format(grains_type, grains))
     if self.SED == 'STAR':
         model.set_star('table star "mod103.mod"', 39390, 'q(H)', self.Q0)
     elif self.SED == 'BB':
         model.set_BB(Teff=self.Teff, lumi_unit='q(H)', lumi_value=self.Q0)
     else:
         pc.log_.error('unknown SED value: {0}'.format(self.SED))
     model.read_emis_file('ic418N.lines')
     model.set_iterate(0)
     model.set_sphere()
     model.set_other(self.options)
     model.print_input(to_file=True, verbose=False)
     self.model = model
コード例 #14
0
def get_Q02Lum(SED, logg):
    """
    Usage: get_Q02Lum('TL', 4)
    """
    if SED not in tabs_T:
        print('{0} is not in {1}'.format(SED, tabs_T.keys()))
        return None
    Q02l = {}
    lumi = 3
    for Teff in tabs_T[SED]:
        In = pc.CloudyInput('./M1')
        In.set_cste_density(2)
        In.set_radius(19)
        if SED[0:2] != 'BB':
            In.set_star('table star "{0}"'.format(dic_SEDs[SED]),
                        (Teff, logg, 0), 'luminosity total solar', lumi)
        else:
            In.set_BB(Teff, 'luminosity total solar', lumi)
        In.set_stop('zone 2')
        In.print_input()
        In.run_cloudy()
        Out = pc.CloudyModel('./M1', read_emis=False)
        print('{0} : {1:.2f},'.format(Teff, np.log10(Out.Q0) - lumi))
        Q02l[Teff] = np.log10(Out.Q0) - lumi
コード例 #15
0
def make_mod(name, logU, Z_str):
    assert Z_str in ('0.001', '0.004', '0.008', '0.020', '0.040')
    Z = np.float(Z_str)
    NH = 100
    ff = 1.0
    abund = abund_Asplund_2009.copy()
    delta_O = np.log10(Z / 0.020)
    for elem in abund:
        if elem != 'He':
            abund[elem] += delta_O
    c_input = pc.CloudyInput('{0}/{1}'.format(models_dir, name))
    c_input.set_star(SED='table star "ISB_{}.mod"'.format(Z_str.split('.')[1]),
                     SED_params=(1e6),
                     lumi_unit='ionization parameter',
                     lumi_value=logU)
    c_input.set_cste_density(np.log10(NH), ff=ff)
    c_input.set_abund(ab_dict=abund)
    c_input.set_distance(dist=1., unit='kpc', linear=True)
    c_input.set_other(options)
    c_input.set_stop(('temperature off', 'pfrac 0.02'))
    c_input.set_emis_tab([
        'H  1  4861.36A', 'H  1  6562.85A', 'N  2  6583.45A', 'O  3  5006.84A'
    ])
    c_input.print_input()
コード例 #16
0
 #Script name root
 name_big = 'bigCloud' + '_Mass' + mass + '_age'+ age + '_zStar' + zStar + '_zGas' + zGas
 name_big_trasnmit = name_big + transmitted_ext
 
 #Index grid point in popstar
 index       = (df_Popstar["Z"] == float(zGas)) & (df_Popstar["M_Msun"] == float(mass)) & (df_Popstar["t"] == float(age))
 
 #Physical parameters
 Q_H         = df_Popstar.loc[index, 'Q'].values[0]
 logR        = df_Popstar.loc[index, 'logR_cm'].values[0]
 phi_H       = np.log10((10.0**Q_H) / (4 * np.pi * (10**logR)**2))
 SED_params  = ('log age = {}'.format(age), 'log z = {}'.format(float(Grid_Values['zStars'][0])))
 metals_frac = str(float(zGas) / 0.02)
 
 #Generate the big cloud script
 bigCloud_sim = pc.CloudyInput(simu_folder + name_big)    
 bigCloud_sim.set_star('table stars "spkroz0001z05stellar.mod"', SED_params = SED_params, lumi_unit = 'phi(H)', lumi_value = phi_H)            
 bigCloud_sim.set_radius(r_in=logR)
 bigCloud_sim.set_cste_density(Grid_Values['den_big'])
 bigCloud_sim.set_abund(ab_dict = abund_Asplund_2009.copy(), metalsgrains = metals_frac)
 bigCloud_sim.set_stop(('temperature  8000.0'))
 bigCloud_sim.set_other(('grains ISM'))
 bigCloud_sim.set_distance(dist=dist_big/pc_to_cm/1000, unit='kpc', linear=True)
 bigCloud_sim.set_other(('cosmic rays background'))
 bigCloud_sim.set_other(('CMB'))
 bigCloud_sim.set_iterate(2)
 bigCloud_sim.set_other(('save last transmitted continuum file = "{}"'.format(transmitted_ext)))
 bigCloud_sim.read_emis_file('lines.dat')
 
 bigCloud_sim.print_input(to_file = True, verbose = False)
                        
コード例 #17
0
ファイル: model.py プロジェクト: emcalven/novadb
    def __init__(self,
                 teff=1e5,
                 lumi_unit="luminosity total",
                 lumi_val=35,
                 nh=None,
                 nh_power=None,
                 ff=1,
                 cf=1,
                 r_in=None,
                 r_out=None,
                 stop_crit=None,
                 verbose=1,
                 abund_ref="GASS10",
                 abund={},
                 abund_type="scale",
                 grains=None,
                 cr=True,
                 cmb=True,
                 sphere=True,
                 molecules=False,
                 theta=None,
                 emis_file=None,
                 path=None,
                 model_name="foo",
                 other_opt=[],
                 unique=True,
                 _uuid=None,
                 params={},
                 progenitor=None,
                 user=None,
                 project=None,
                 extras={},
                 **kwargs):
        """
        Module to help define and create consistent Cloudy input files.

        :param teff: int, float: Temperature of source blackbody [K]
        :param lumi_unit: str: Cloudy luminosity unit (e.g. "luminosity total")
        :param lumi_val: int, float: Luminosity value [log cm-3]
        :param nh: int, float: Hydrogen density (cm-3)
        :param nh_power: int, float: Index of hydrogen power law (optional)
        :param ff: int, float: Filling factor
        :param cf: int, float: Cover factor
        :param r_in: int, float: Inner radius of nebula [cm]
        :param r_out: int, float: Outer radius of nebula [cm] (optional)
        :param stop_crit: str, list(str): Stop criteria (optional)
        :param verbose: int: pyCloudy verbosity level (optional)
        :param abund_ref: str: Cloudy built-in abundances
        :param abund: dict: Dictionary with element : abundance (e.g. {He:2, O:3})
        :param abund_type: str:
        :param grains:
        :param cr:
        :param cmb:
        :param sphere:
        :param molecules: (False, "H2")
        :param theta:
        :param emis_file:
        :param path:
        :param model_name:
        :param other_opt:
        :param kwargs:
        """

        self.logger = logging.getLogger('NOVA.model.Model')
        self.logger.info('creating an instance of Model')

        if "cloudy_exe" in kwargs:
            os.putenv("CLOUDY_EXE", kwargs["cloudy_exe"])
            pc.config.cloudy_exe = kwargs["cloudy_exe"]
        if "cloudy_data_path" in kwargs:
            os.putenv("CLOUDY_DATA_PATH", kwargs["cloudy_data_path"])

        self.pc = pc
        self.teff = teff
        self.lumi_unit = lumi_unit
        self.lumi_val = lumi_val
        self.nh = nh
        self.nh_power = nh_power
        self.ff = ff
        self.cf = cf
        self.r_in = r_in
        self.r_out = r_out
        self.stop_crit = stop_crit
        self.abund_ref = abund_ref
        self.abund = abund
        self.abund_type = abund_type
        self.grains = grains
        self.cr = cr
        self.cmb = cmb
        self.sphere = sphere
        self.molecules = molecules
        self.theta = theta
        self.emis_file = emis_file
        self.path = path
        self.verbose = verbose
        self.kwargs = kwargs
        self.use_cste_density = True
        self.options = []
        self.model_name = model_name
        self.other_opt = other_opt
        self.params = params
        self.progenitor = progenitor  # Belongs to extras (print_extras())
        self.user = user  #extras.get("user")  # Belongs to extras (print_extras())
        self.project = project  #extras.get("project")  # Belongs to extras (print_extras())
        #self.user = user  # Belongs to extras (print_extras())
        #self.project = project  # Belongs to extras (print_extras())
        self.extras = extras
        self._uuid = _uuid

        if not self.path.endswith("/"):
            self.path += "/"
        make_dir(self.path, verbose=1)  # Creates directory to place models in
        if unique:
            if self._uuid is None:
                self._uuid = uuid()
                self.model_name_full = self.path + self._uuid + "_" + self.model_name
                self.c_input = pc.CloudyInput(self.model_name_full)
            else:
                if isinstance(self._uuid, (int, float)):
                    self._uuid = str(self._uuid)
                self.model_name_full = self.path + self._uuid + "_" + self.model_name
                self.c_input = pc.CloudyInput(self.model_name_full)
        else:
            self.model_name_full = self.path + self.model_name
            #self.model_name_full = self.path + self._uuid + "_" + self.model_name
            self.c_input = pc.CloudyInput(self.model_name_full)
コード例 #18
0
ファイル: Using_pyCloudy_1.py プロジェクト: indiajoe/pyCloudy
            'Cl 3 5538',
            'O  1 63.17m',
            'O  1 145.5m',
            'C  2 157.6m']


# In[8]:

abund = {'He' : -0.92, 'C' : 6.85 - 12, 'N' : -4.0, 'O' : -3.40, 'Ne' : -4.00, 
         'S' : -5.35, 'Ar' : -5.80, 'Fe' : -7.4, 'Cl' : -7.00}


# In[9]:

# Defining the object that will manage the input file for Cloudy
c_input = pc.CloudyInput(full_model_name)


# In[10]:

# Filling the object with the parameters
# Defining the ionizing SED: Effective temperature and luminosity.
# The lumi_unit is one of the Cloudy options, like "luminosity solar", "q(H)", "ionization parameter", etc... 
c_input.set_BB(Teff = Teff, lumi_unit = 'q(H)', lumi_value = qH)


# In[11]:

# Defining the density. You may also use set_dlaw(parameters) if you have a density law defined in dense_fabden.cpp.
c_input.set_cste_density(dens)