Esempio n. 1
0
def test_opacity_Fe_vald3(T, P):
    PH = P * H_He_HH_VMR[0]
    PHe = P * H_He_HH_VMR[1]
    PHH = P * H_He_HH_VMR[2]
    qt = np.ones_like(adbFe.A) * np.float32(adbFe.qr_interp('Fe 1', T))
    # ↑Unlike the case of HITRAN (using Qr_HAPI), we ignored the isotopes.
    Sij = SijT(T, adbFe.logsij0, adbFe.nu_lines, adbFe.elower, qt)
    sigmaD = doppler_sigma(adbFe.nu_lines, T, Amol)
    gammaL = atomll.gamma_vald3(T,
                                PH,
                                PHH,
                                PHe,
                                adbFe.ielem,
                                adbFe.iion,
                                adbFe.dev_nu_lines,
                                adbFe.elower,
                                adbFe.eupper,
                                adbFe.atomicmass,
                                adbFe.ionE,
                                adbFe.gamRad,
                                adbFe.gamSta,
                                adbFe.vdWdamp,
                                enh_damp=1.0)
    val = np.array([np.sum(Sij), np.sum(sigmaD), np.sum(gammaL)])
    diff = np.abs(REFS[0, :] - val)
    print(diff)
    assert (diff[0] < 1.e-11 and diff[1] < 1.e-3 and diff[2] < 1.e-3)
Esempio n. 2
0
def comperr(Nnu, plotfig=False):

    nus = np.logspace(np.log10(1.e7 / 2700),
                      np.log10(1.e7 / 2100.),
                      Nnu,
                      dtype=np.float64)

    #    nus=np.logspace(np.log10(3000),np.log10(6000.0),Nnu,dtype=np.float64)
    mdbCO = moldb.MdbHit('/home/kawahara/exojax/data/CO/05_hit12.par', nus)

    Mmol = 28.010446441149536
    Tref = 296.0
    Tfix = 1000.0
    Pfix = 1.e-3  #

    #USE TIPS partition function
    Q296=np.array([107.25937215917970,224.38496958496091,112.61710362499998,\
                   660.22969049609367,236.14433662109374,1382.8672147421873])
    Q1000=np.array([382.19096582031250,802.30952197265628,402.80326733398437,\
                    2357.1041210937501,847.84866308593757,4928.7215078125000])
    qr = Q1000 / Q296

    qt = np.ones_like(mdbCO.isoid, dtype=np.float64)
    for idx, iso in enumerate(mdbCO.uniqiso):
        mask = mdbCO.isoid == iso
        qt[mask] = qr[idx]

    Sij = SijT(Tfix, mdbCO.logsij0, mdbCO.nu_lines, mdbCO.elower, qt)
    gammaL = gamma_hitran(Pfix, Tfix, Pfix, mdbCO.n_air, mdbCO.gamma_air,
                          mdbCO.gamma_self)
    #+ gamma_natural(A) #uncomment if you inclide a natural width
    sigmaD = doppler_sigma(mdbCO.nu_lines, Tfix, Mmol)

    cnu, indexnu, R, dq = initspec.init_modit(mdbCO.nu_lines, nus)
    nsigmaD = normalized_doppler_sigma(Tfix, Mmol, R)
    ngammaL = gammaL / (mdbCO.nu_lines / R)
    ngammaL_grid = set_ditgrid(ngammaL)

    xs_modit_lp = modit_xsvector(cnu, indexnu, R, dq, nsigmaD, ngammaL, Sij,
                                 nus, ngammaL_grid)
    wls_modit = 100000000 / nus

    #ref (direct)
    d = 10000
    ll = mdbCO.nu_lines
    xsv_lpf_lp = lpf_xsection(nus, ll, sigmaD, gammaL, Sij, memory_size=30)

    dif = xs_modit_lp / xsv_lpf_lp - 1.
    med = np.median(dif)
    iju = 22940.
    ijd = 26400.
    limu, limd = np.searchsorted(wls_modit[::-1], [iju, ijd])
    std = np.std(dif[::-1][limu:limd])

    return med, std, R, ijd, iju, wls_modit, xs_modit_lp, xsv_lpf_lp, dif
Esempio n. 3
0
Q1000 = np.array([
    382.19096582031250, 802.30952197265628, 402.80326733398437,
    2357.1041210937501, 847.84866308593757, 4928.7215078125000
])
qr = Q1000 / Q296

qt = np.ones_like(mdbCO.isoid, dtype=np.float64)
for idx, iso in enumerate(mdbCO.uniqiso):
    mask = mdbCO.isoid == iso
    qt[mask] = qr[idx]

Sij = SijT(Tfix, mdbCO.logsij0, mdbCO.nu_lines, mdbCO.elower, qt)
gammaL = gamma_hitran(Pfix, Tfix, Pfix, mdbCO.n_air, mdbCO.gamma_air,
                      mdbCO.gamma_self)
# + gamma_natural(A) #uncomment if you inclide a natural width
sigmaD = doppler_sigma(mdbCO.nu_lines, Tfix, Mmol)

cnu, indexnu, R, pmarray = initspec.init_modit(mdbCO.nu_lines, nus)
nsigmaD = normalized_doppler_sigma(Tfix, Mmol, R)
ngammaL = gammaL / (mdbCO.nu_lines / R)
ngammaL_grid = set_ditgrid(ngammaL)

xs_modit_lp = modit_xsvector(cnu, indexnu, R, pmarray, nsigmaD, ngammaL, Sij,
                             nus, ngammaL_grid)
wls_modit = 100000000 / nus

#ref (direct)
d = 10000
ll = mdbCO.nu_lines
xsv_lpf_lp = lpf_xsection(nus, ll, sigmaD, gammaL, Sij, memory_size=30)
Esempio n. 4
0
    def xsection(self, T, P):
        """cross section.

        Args:
           T: temperature (K)
           P: pressure (bar)

        Returns:
           cross section (cm2)
        """

        mdb = self.mdb
        if self.database == 'ExoMol':
            gammaL = gamma_exomol(P, T, mdb.n_Texp,
                                  mdb.alpha_ref) + gamma_natural(mdb.A)
            molmass = mdb.molmass
        elif self.database == 'HITRAN' or self.database == 'HITEMP':
            gammaL = gamma_hitran(P, T, P, mdb.n_air, mdb.gamma_air,
                                  mdb.gamma_self) + gamma_natural(mdb.A)
            molmass = molinfo.molmass(self.molecules)

        Sij = self.linest(T)
        if self.xsmode == 'auto':
            xsmode = self.select_xsmode(len(mdb.nu_lines))
        else:
            xsmode = self.xsmode

        if xsmode == 'lpf' or xsmode == 'LPF':
            sigmaD = doppler_sigma(mdb.nu_lines, T, molmass)
            xsv = xsection(self.nus,
                           mdb.nu_lines,
                           sigmaD,
                           gammaL,
                           Sij,
                           memory_size=self.memory_size)
        elif xsmode == 'modit' or xsmode == 'MODIT':
            checknus = check_scale_nugrid(self.nus, gridmode='ESLOG')
            nus = self.autonus(checknus, 'ESLOG')
            cnu, indexnu, R_mol, pmarray = initspec.init_modit(
                mdb.nu_lines, nus)
            nsigmaD = normalized_doppler_sigma(T, molmass, R_mol)
            ngammaL = gammaL / (mdb.nu_lines / R_mol)
            ngammaL_grid = modit.ditgrid(ngammaL, res=0.1)
            xsv = modit.xsvector(cnu, indexnu, R_mol, pmarray, nsigmaD,
                                 ngammaL, Sij, nus, ngammaL_grid)
            if ~checknus and self.autogridconv:
                xsv = jnp.interp(self.nus, nus, xsv)
        elif xsmode == 'dit' or xsmode == 'DIT':
            sigmaD = doppler_sigma(mdb.nu_lines, T, molmass)
            checknus = check_scale_nugrid(self.nus, gridmode='ESLIN')
            nus = self.autonus(checknus, 'ESLIN')
            sigmaD_grid = dit.ditgrid(sigmaD, res=0.1)
            gammaL_grid = dit.ditgrid(gammaL, res=0.1)
            cnu, indexnu, pmarray = initspec.init_dit(mdb.nu_lines, nus)
            xsv = dit.xsvector(cnu, indexnu, pmarray, sigmaD, gammaL, Sij, nus,
                               sigmaD_grid, gammaL_grid)
            if ~checknus and self.autogridconv:
                xsv = jnp.interp(self.nus, nus, xsv)
        else:
            print('Error:', xsmode, ' is unavailable (auto/LPF/DIT).')
            xsv = None
        return xsv