示例#1
0
    def __init__ ( self, rad_src ):

        self.PC = physical.PhysicalConstants()        
        self.rad_src = rad_src

        # dont need to integrate for monochromatic spectra
        #-----------------------------------------------------------------
        if rad_src.monochromatic:

            self.Lu = rad_src.Lu
            self.Ln = self.Lu / rad_src.E

        # integrate for polychromatic spectra
        #-----------------------------------------------------------------
        else:

            self.Lu = utils.trap( rad_src.E, rad_src._dLu_over_dE )
            self.Ln = utils.trap( rad_src.E, rad_src._dLn_over_dE )


        # set units and docstrings
        #-----------------------------------------------------------------
        self.Lu.units = 'erg/s'
        self.Lu.__doc__ = 'optically thin energy luminosity'

        self.Ln.units = '1/s'
        self.Ln.__doc__ = 'optically thin photon luminosity'
示例#2
0
 def u(self,r):
     """ energy density at a given radius. """ 
     if not hasattr(r,'units'): 
         raise utils.NeedUnitsError, '\n r must have units \n'        
     if self.rad_src.monochromatic:
         u = self.Fu(r) / self.PC.c
     else:
         u = utils.trap( self.rad_src.E, self.rad_src._du_over_dE(r) )
     return u
示例#3
0
 def Fu(self,r):
     """ energy flux at a given radius. """ 
     if not hasattr(r,'units'): 
         raise utils.NeedUnitsError, '\n r must have units \n'        
     if self.rad_src.monochromatic:
         Fu = self.Lu / (4.0 * np.pi * r*r)
     else:
         Fu = utils.trap( self.rad_src.E, self.rad_src._dFu_over_dE(r) )
     return Fu
示例#4
0
 def n(self,r):
     """ photon density at a given radius. """ 
     if not hasattr(r,'units'): 
         raise utils.NeedUnitsError, '\n r must have units \n'
     if self.rad_src.monochromatic:
         n = self.Fn(r) / self.PC.c
     else:
         n = utils.trap( self.rad_src.E, self.rad_src._dn_over_dE(r) )
     return n
示例#5
0
 def Fn(self,r):
     """ photon flux at a given radius. """ 
     if not hasattr(r,'units'): 
         raise utils.NeedUnitsError, '\n r must have units \n'      
     if self.rad_src.monochromatic:
         Fn = self.Ln / (4.0 * np.pi * r*r)
     else:
         Fn = utils.trap( self.rad_src.E, self.rad_src._dFn_over_dE(r) )
     return Fn
示例#6
0
 def He2i(self,r):
     """ He2 photoion rate at a given radius. """ 
     if not hasattr(r,'units'): 
         raise utils.NeedUnitsError, '\n r must have units \n'
     if self.rad_src.monochromatic:
         He2i = self.Fn(r) * self.rad_src.sigma.He2
     else:
         He2i = utils.trap( self.rad_src.E, self.rad_src._dHe2i_over_dE(r) )
     He2i.units = '1/s'
     return He2i
示例#7
0
 def He2h(self,r):
     """ He2 photoheating rate at a given radius. """ 
     if not hasattr(r,'units'): 
         raise utils.NeedUnitsError, '\n r must have units \n'
     if self.rad_src.monochromatic:
         He2h = self.He2i(r) * (self.rad_src.E - self.rad_src.th.E_He2)
     else:
         He2h = utils.trap( self.rad_src.E, self.rad_src._dHe2h_over_dE(r) )
     He2h.units = 'erg/s'
     return He2h
示例#8
0
文件: general.py 项目: galtay/rabacus
    def ta( self, a):
        r""" Time since a=0 or age of the Universe, t(a). 

        .. math::
          t(a) = \int_0^a \frac{da'}{a' H(a')} 

        """ 

        # quad works but takes a long time. 
        #-------------------------------------------------------------------
#        if utils.isiterable( a ):
#            t = np.array( [quad( self._dt_da, 0.0, aa )[0] for aa in a] )
#        else:
#            t = quad( self._dt_da, 0.0, a )[0]
#        t = t * self.cu.s
#        print 't = ', t.rescale("Myr/hh")

        # trap rule includes OmegaR and is fast and accurate to 6 decimals
        #-------------------------------------------------------------------
        N = 5000
        a_min = 1.0e-10
        if utils.isiterable( a ):
            t = np.zeros( a.size ) * self.cu.s
            for ii,aa in enumerate(a):
                xx = np.linspace( a_min, aa, N )
                yy = 1.0 / ( xx * self.Ha(xx) )
                t[ii] = utils.trap( xx, yy )
        else:
            xx = np.linspace( a_min, a, N )
            yy = 1.0 / ( xx * self.Ha(xx) )
            t = utils.trap( xx, yy )
        t.units = 'Myr/hh'

        # this is analytic but does not include OmegaR        
        #-------------------------------------------------------------------
#        pre = 2.0 / ( 3.0 * np.sqrt( self.OmegaL ) )
#        aeq = (self.OmegaM/self.OmegaL)**(1./3.)  
#        arg = (a/aeq)**(3./2.) + np.sqrt(1 + (a/aeq)**3)
#        t = pre * np.log(arg) * self.tH0

        return t 
示例#9
0
    def ta(self, a):
        r""" Time since a=0 or age of the Universe, t(a). 

        .. math::
          t(a) = \int_0^a \frac{da'}{a' H(a')} 

        """

        # quad works but takes a long time.
        #-------------------------------------------------------------------
        #        if utils.isiterable( a ):
        #            t = np.array( [quad( self._dt_da, 0.0, aa )[0] for aa in a] )
        #        else:
        #            t = quad( self._dt_da, 0.0, a )[0]
        #        t = t * self.cu.s
        #        print 't = ', t.rescale("Myr/hh")

        # trap rule includes OmegaR and is fast and accurate to 6 decimals
        #-------------------------------------------------------------------
        N = 5000
        a_min = 1.0e-10
        if utils.isiterable(a):
            t = np.zeros(a.size) * self.cu.s
            for ii, aa in enumerate(a):
                xx = np.linspace(a_min, aa, N)
                yy = 1.0 / (xx * self.Ha(xx))
                t[ii] = utils.trap(xx, yy)
        else:
            xx = np.linspace(a_min, a, N)
            yy = 1.0 / (xx * self.Ha(xx))
            t = utils.trap(xx, yy)
        t.units = 'Myr/hh'

        # this is analytic but does not include OmegaR
        #-------------------------------------------------------------------
        #        pre = 2.0 / ( 3.0 * np.sqrt( self.OmegaL ) )
        #        aeq = (self.OmegaM/self.OmegaL)**(1./3.)
        #        arg = (a/aeq)**(3./2.) + np.sqrt(1 + (a/aeq)**3)
        #        t = pre * np.log(arg) * self.tH0

        return t
示例#10
0
    def shld_He2h(self, tauH1_th, tauHe1_th, tauHe2_th):
        """ Integrates spectrum to calculate the HeII photoheating rate
        after passing through a column with optical depth tau. 

        .. seealso::

          :func:`shld_H1h`        
        """
        atten = self.return_attenuation( tauH1_th, tauHe1_th, tauHe2_th ) 
        if self.monochromatic:
            He2h = self.thin.He2h * atten
        else:
            He2h = utils.trap( self.E, self._dHe2h_over_dE * atten )
        He2h.units = 'erg/s'
        return He2h
示例#11
0
    def shld_He2h(self, tauH1_th, tauHe1_th, tauHe2_th):
        """ Integrates spectrum to calculate the HeII photoheating rate
        after passing through a column with optical depth tau. 

        .. seealso::

          :func:`shld_H1h`        
        """
        atten = self.return_attenuation(tauH1_th, tauHe1_th, tauHe2_th)
        if self.monochromatic:
            He2h = self.thin.He2h * atten
        else:
            He2h = utils.trap(self.E, self._dHe2h_over_dE * atten)
        He2h.units = 'erg/s'
        return He2h
示例#12
0
    def shld_He2i(self, r, tauH1_th, tauHe1_th, tauHe2_th):
        """ Integrates spectrum to calculate the HeII photoionization rate
        after passing through a column with optical depth tau. 

        .. seealso::

          :func:`shld_H1i`        
        """
        atten = self.return_attenuation( tauH1_th, tauHe1_th, tauHe2_th ) 
        if self.monochromatic:
            He2i = self.thin.He2i(r) * atten
        else:
            He2i = utils.trap( self.E, self._dHe2i_over_dE(r) * atten )
        He2i.units = '1/s'
        return He2i
示例#13
0
    def shld_H1h(self, tauH1_th, tauHe1_th, tauHe2_th):
        """ Integrates spectrum to calculate the HI photoheating rate
        after passing through a column with optical depth tau 

        Args:
          `tauH1_th` (float): H1 optical depth at the H1 ionizing threshold
        
          `tauHe1_th` (float): He1 optical depth at the He1 ionizing threshold

          `tauHe2_th` (float): He2 optical depth at the He2 ionizing threshold

        Returns:
          `H1h` (float): attenuated H1 photoheating rate 
           
        """ 
        atten = self.return_attenuation( tauH1_th, tauHe1_th, tauHe2_th ) 
        if self.monochromatic:
            H1h = self.thin.H1h * atten
        else:
            H1h = utils.trap( self.E, self._dH1h_over_dE * atten )
        H1h.units = 'erg/s'
        return H1h
示例#14
0
    def shld_H1h(self, tauH1_th, tauHe1_th, tauHe2_th):
        """ Integrates spectrum to calculate the HI photoheating rate
        after passing through a column with optical depth tau 

        Args:
          `tauH1_th` (float): H1 optical depth at the H1 ionizing threshold
        
          `tauHe1_th` (float): He1 optical depth at the He1 ionizing threshold

          `tauHe2_th` (float): He2 optical depth at the He2 ionizing threshold

        Returns:
          `H1h` (float): attenuated H1 photoheating rate 
           
        """
        atten = self.return_attenuation(tauH1_th, tauHe1_th, tauHe2_th)
        if self.monochromatic:
            H1h = self.thin.H1h * atten
        else:
            H1h = utils.trap(self.E, self._dH1h_over_dE * atten)
        H1h.units = 'erg/s'
        return H1h
示例#15
0
    def shld_H1i(self, r, tauH1_th, tauHe1_th, tauHe2_th):
        """ Integrates spectrum to calculate the HI photoionization rate
        after passing through a column with optical depth tau 

        Args:
          `r` (float): radial distance from point source

          `tauH1_th` (float): H1 optical depth at the H1 ionizing threshold
        
          `tauHe1_th` (float): He1 optical depth at the He1 ionizing threshold

          `tauHe2_th` (float): He2 optical depth at the He2 ionizing threshold

        Returns:
          `H1i` (float): attenuated H1 photoionization rate 
   
        """ 
        atten = self.return_attenuation( tauH1_th, tauHe1_th, tauHe2_th ) 
        if self.monochromatic:
            H1i = self.thin.H1i(r) * atten
        else:
            H1i = utils.trap( self.E, self._dH1i_over_dE(r) * atten )
        H1i.units = '1/s'
        return H1i
示例#16
0
    def __init__ ( self, rad_src ):

        self.PC = physical.PhysicalConstants()
        self.U = units.Units()

        # dont need to integrate for monochromatic spectra
        #-----------------------------------------------------------------
        if rad_src.monochromatic:

            four_pi_sr = 4 * np.pi * self.U.sr

            self.Fu = four_pi_sr * rad_src.Inu
            self.u = self.Fu / self.PC.c
            self.Fn = self.Fu / rad_src.E
            self.n = self.Fn / self.PC.c

            self.H1i = self.Fn * rad_src.sigma.H1
            self.H1h = self.H1i * (rad_src.E - rad_src.th.E_H1)
            self.He1i = self.Fn * rad_src.sigma.He1
            self.He1h = self.He1i * (rad_src.E - rad_src.th.E_He1)
            self.He2i = self.Fn * rad_src.sigma.He2
            self.He2h = self.He2i * (rad_src.E - rad_src.th.E_He2)


        # integrate for polychromatic spectra
        #-----------------------------------------------------------------
        else:

            self.Fu = utils.trap( rad_src.E, rad_src._dFu_over_dE )
            self.u = utils.trap( rad_src.E, rad_src._du_over_dE )
            self.Fn = utils.trap( rad_src.E, rad_src._dFn_over_dE )
            self.n = utils.trap( rad_src.E, rad_src._dn_over_dE )

            self.H1i = utils.trap( rad_src.E, rad_src._dH1i_over_dE )
            self.H1h = utils.trap( rad_src.E, rad_src._dH1h_over_dE ) 
            self.He1i = utils.trap(rad_src.E, rad_src._dHe1i_over_dE)
            self.He1h = utils.trap(rad_src.E, rad_src._dHe1h_over_dE) 
            self.He2i = utils.trap(rad_src.E, rad_src._dHe2i_over_dE)
            self.He2h = utils.trap(rad_src.E, rad_src._dHe2h_over_dE)


        # set units and docstrings
        #-----------------------------------------------------------------
        self.Fu.units = 'erg/s/cm^2'        
        self.Fu.__doc__ = 'optically thin energy flux' 

        self.u.units = 'erg/cm^3'
        self.u.__doc__ = 'optically thin energy density' 

        self.Fn.units = '1/s/cm^2'
        self.Fn.__doc__ = 'optically thin photon number flux' 

        self.n.units = '1/cm^3'
        self.n.__doc__ = 'optically thin photon number density' 

        self.H1i.units = '1/s'            
        self.H1i.__doc__ = 'optically thin H1 photoionization rate' 

        self.H1h.units = 'erg/s'
        self.H1h.__doc__ = 'optically thin H1 photoheating rate' 

        self.He1i.units = '1/s'            
        self.He1i.__doc__ = 'optically thin He1 photoionization rate' 

        self.He1h.units = 'erg/s'
        self.He1h.__doc__ = 'optically thin He1 photoheating rate' 

        self.He2i.units = '1/s'            
        self.He2i.__doc__ = 'optically thin He2 photoionization rate' 

        self.He2h.units = 'erg/s'
        self.He2h.__doc__ = 'optically thin He2 photoheating rate' 
示例#17
0
    def __init__( self, rad_src ):

        
        # make sure we have what we need
        #--------------------------------------------
        assert rad_src.segmented == True

        # setup containers
        #--------------------------------------------
        self.sigma = species.AbsorbingSpecies()
        self.E = species.AbsorbingSpecies()


        # integrate between H1 and He1 thresholds
        #--------------------------------------------
        ii = rad_src.th.i_H1
        ff = rad_src.th.i_He1
        xx = rad_src.E[ii:ff]
        yy = rad_src._dH1i_over_dE[ii:ff]
        H1i_thin = utils.trap( xx, yy )
        yy = rad_src._dFn_over_dE[ii:ff]
        Fn_thin = utils.trap( xx, yy )
        self.sigma.H1 = H1i_thin / Fn_thin
        self.sigma.H1.__doc__ = 'grey H1 photoionization cross section' 

        log_sig = np.log10( rad_src.sigma.H1[ii:ff].magnitude )
        log_gry = np.log10( self.sigma.H1.magnitude )
        log_E = np.log10( rad_src.E[ii:ff].magnitude )

        i_lo = np.argmin( np.abs( log_sig - log_gry ) )
        if log_sig[i_lo] < log_gry:
            i_hi = i_lo + 1
        else:
            i_hi = i_lo
            i_lo = i_lo - 1

        dlogsig = log_sig[i_hi] - log_sig[i_lo]
        frac = (log_gry - log_sig[i_lo]) / dlogsig
        dlogE = log_E[i_hi] - log_E[i_lo]
        grey_E = 10.0**(log_E[i_lo] + frac * dlogE)
        self.E.H1 = grey_E * rad_src.U.eV
        self.E.H1.__doc__ = 'grey H1 energy' 

        # integrate between He1 and He2 thresholds
        #--------------------------------------------
        ii = rad_src.th.i_He1
        ff = rad_src.th.i_He2
        xx = rad_src.E[ii:ff]
        yy = rad_src._dHe1i_over_dE[ii:ff]
        He1i_thin = utils.trap( xx, yy )
        yy = rad_src._dFn_over_dE[ii:ff]
        Fn_thin = utils.trap( xx, yy )
        self.sigma.He1 = He1i_thin / Fn_thin
        self.sigma.He1.__doc__ = 'grey He1 photoionization cross section' 
        
        log_sig = np.log10( rad_src.sigma.He1[ii:ff].magnitude )
        log_gry = np.log10( self.sigma.He1.magnitude )
        log_E = np.log10( rad_src.E[ii:ff].magnitude )

        i_lo = np.argmin( np.abs( log_sig - log_gry ) )
        if log_sig[i_lo] < log_gry:
            i_hi = i_lo + 1
        else:
            i_hi = i_lo
            i_lo = i_lo - 1
            
        dlogsig = log_sig[i_hi] - log_sig[i_lo]
        frac = (log_gry - log_sig[i_lo]) / dlogsig
        dlogE = log_E[i_hi] - log_E[i_lo]
        grey_E = 10.0**(log_E[i_lo] + frac * dlogE)
        self.E.He1 = grey_E * rad_src.U.eV
        self.E.He1.__doc__ = 'grey He1 energy' 
        
        # integrate above He2 threshold
        #--------------------------------------------
        ii = rad_src.th.i_He2
        xx = rad_src.E[ii:]
        yy = rad_src._dHe2i_over_dE[ii:]
        He2i_thin = utils.trap( xx, yy )
        yy = rad_src._dFn_over_dE[ii:]
        Fn_thin = utils.trap( xx, yy )
        self.sigma.He2 = He2i_thin / Fn_thin
        self.sigma.He2.__doc__ = 'grey He2 photoionization cross section' 
        
        log_sig = np.log10( rad_src.sigma.He2[ii:].magnitude )
        log_gry = np.log10( self.sigma.He2.magnitude )
        log_E = np.log10( rad_src.E[ii:].magnitude )
        
        i_lo = np.argmin( np.abs( log_sig - log_gry ) )
        if log_sig[i_lo] < log_gry:
            i_hi = i_lo + 1
        else:
            i_hi = i_lo
            i_lo = i_lo - 1
            
        dlogsig = log_sig[i_hi] - log_sig[i_lo]
        frac = (log_gry - log_sig[i_lo]) / dlogsig
        dlogE = log_E[i_hi] - log_E[i_lo]
        grey_E = 10.0**(log_E[i_lo] + frac * dlogE)
        self.E.He2 = grey_E * rad_src.U.eV
        self.E.He2.__doc__ = 'grey He2 energy' 
示例#18
0
    def __init__(self, rad_src):

        self.PC = physical.PhysicalConstants()

        # dont need to integrate for monochromatic spectra
        #-----------------------------------------------------------------
        if rad_src.monochromatic:

            self.Fu = rad_src.Fu
            self.u = self.Fu / self.PC.c
            self.Fn = self.Fu / rad_src.E
            self.n = self.Fn / self.PC.c

            self.H1i = self.Fn * rad_src.sigma.H1
            self.H1h = self.H1i * (rad_src.E - rad_src.th.E_H1)
            self.He1i = self.Fn * rad_src.sigma.He1
            self.He1h = self.He1i * (rad_src.E - rad_src.th.E_He1)
            self.He2i = self.Fn * rad_src.sigma.He2
            self.He2h = self.He2i * (rad_src.E - rad_src.th.E_He2)

        # integrate for polychromatic spectra
        #-----------------------------------------------------------------
        else:

            self.Fu = utils.trap(rad_src.E, rad_src._dFu_over_dE)
            self.u = utils.trap(rad_src.E, rad_src._du_over_dE)
            self.Fn = utils.trap(rad_src.E, rad_src._dFn_over_dE)
            self.n = utils.trap(rad_src.E, rad_src._dn_over_dE)

            self.H1i = utils.trap(rad_src.E, rad_src._dH1i_over_dE)
            self.H1h = utils.trap(rad_src.E, rad_src._dH1h_over_dE)
            self.He1i = utils.trap(rad_src.E, rad_src._dHe1i_over_dE)
            self.He1h = utils.trap(rad_src.E, rad_src._dHe1h_over_dE)
            self.He2i = utils.trap(rad_src.E, rad_src._dHe2i_over_dE)
            self.He2h = utils.trap(rad_src.E, rad_src._dHe2h_over_dE)

        # set units and docstrings
        #-----------------------------------------------------------------
        self.Fu.units = 'erg/s/cm^2'
        self.Fu.__doc__ = 'optically thin energy flux'

        self.u.units = 'erg/cm^3'
        self.u.__doc__ = 'optically thin energy density'

        self.Fn.units = '1/s/cm^2'
        self.Fn.__doc__ = 'optically thin photon number flux'

        self.n.units = '1/cm^3'
        self.n.__doc__ = 'optically thin photon number density'

        self.H1i.units = '1/s'
        self.H1i.__doc__ = 'optically thin H1 photoionization rate'

        self.H1h.units = 'erg/s'
        self.H1h.__doc__ = 'optically thin H1 photoheating rate'

        self.He1i.units = '1/s'
        self.He1i.__doc__ = 'optically thin He1 photoionization rate'

        self.He1h.units = 'erg/s'
        self.He1h.__doc__ = 'optically thin He1 photoheating rate'

        self.He2i.units = '1/s'
        self.He2i.__doc__ = 'optically thin He2 photoionization rate'

        self.He2h.units = 'erg/s'
        self.He2h.__doc__ = 'optically thin He2 photoheating rate'
示例#19
0
    def __init__(self, rad_src):

        # make sure we have what we need
        #--------------------------------------------
        assert rad_src.segmented == True

        # setup containers
        #--------------------------------------------
        self.sigma = species.AbsorbingSpecies()
        self.E = species.AbsorbingSpecies()

        # integrate between H1 and He1 thresholds
        #--------------------------------------------
        ii = rad_src.th.i_H1
        ff = rad_src.th.i_He1
        xx = rad_src.E[ii:ff]
        yy = rad_src._dH1i_over_dE[ii:ff]
        H1i_thin = utils.trap(xx, yy)
        yy = rad_src._dFn_over_dE[ii:ff]
        Fn_thin = utils.trap(xx, yy)
        self.sigma.H1 = H1i_thin / Fn_thin
        self.sigma.H1.__doc__ = 'grey H1 photoionization cross section'

        log_sig = np.log10(rad_src.sigma.H1[ii:ff].magnitude)
        log_gry = np.log10(self.sigma.H1.magnitude)
        log_E = np.log10(rad_src.E[ii:ff].magnitude)

        i_lo = np.argmin(np.abs(log_sig - log_gry))
        if log_sig[i_lo] < log_gry:
            i_hi = i_lo + 1
        else:
            i_hi = i_lo
            i_lo = i_lo - 1

        dlogsig = log_sig[i_hi] - log_sig[i_lo]
        frac = (log_gry - log_sig[i_lo]) / dlogsig
        dlogE = log_E[i_hi] - log_E[i_lo]
        grey_E = 10.0**(log_E[i_lo] + frac * dlogE)
        self.E.H1 = grey_E * rad_src.U.eV
        self.E.H1.__doc__ = 'grey H1 energy'

        # integrate between He1 and He2 thresholds
        #--------------------------------------------
        ii = rad_src.th.i_He1
        ff = rad_src.th.i_He2
        xx = rad_src.E[ii:ff]
        yy = rad_src._dHe1i_over_dE[ii:ff]
        He1i_thin = utils.trap(xx, yy)
        yy = rad_src._dFn_over_dE[ii:ff]
        Fn_thin = utils.trap(xx, yy)
        self.sigma.He1 = He1i_thin / Fn_thin
        self.sigma.He1.__doc__ = 'grey He1 photoionization cross section'

        log_sig = np.log10(rad_src.sigma.He1[ii:ff].magnitude)
        log_gry = np.log10(self.sigma.He1.magnitude)
        log_E = np.log10(rad_src.E[ii:ff].magnitude)

        i_lo = np.argmin(np.abs(log_sig - log_gry))
        if log_sig[i_lo] < log_gry:
            i_hi = i_lo + 1
        else:
            i_hi = i_lo
            i_lo = i_lo - 1

        dlogsig = log_sig[i_hi] - log_sig[i_lo]
        frac = (log_gry - log_sig[i_lo]) / dlogsig
        dlogE = log_E[i_hi] - log_E[i_lo]
        grey_E = 10.0**(log_E[i_lo] + frac * dlogE)
        self.E.He1 = grey_E * rad_src.U.eV
        self.E.He1.__doc__ = 'grey He1 energy'

        # integrate above He2 threshold
        #--------------------------------------------
        ii = rad_src.th.i_He2
        xx = rad_src.E[ii:]
        yy = rad_src._dHe2i_over_dE[ii:]
        He2i_thin = utils.trap(xx, yy)
        yy = rad_src._dFn_over_dE[ii:]
        Fn_thin = utils.trap(xx, yy)
        self.sigma.He2 = He2i_thin / Fn_thin
        self.sigma.He2.__doc__ = 'grey He2 photoionization cross section'

        log_sig = np.log10(rad_src.sigma.He2[ii:].magnitude)
        log_gry = np.log10(self.sigma.He2.magnitude)
        log_E = np.log10(rad_src.E[ii:].magnitude)

        i_lo = np.argmin(np.abs(log_sig - log_gry))
        if log_sig[i_lo] < log_gry:
            i_hi = i_lo + 1
        else:
            i_hi = i_lo
            i_lo = i_lo - 1

        dlogsig = log_sig[i_hi] - log_sig[i_lo]
        frac = (log_gry - log_sig[i_lo]) / dlogsig
        dlogE = log_E[i_hi] - log_E[i_lo]
        grey_E = 10.0**(log_E[i_lo] + frac * dlogE)
        self.E.He2 = grey_E * rad_src.U.eV
        self.E.He2.__doc__ = 'grey He2 energy'
示例#20
0
    def calc_weighted( self, wa ):
        """ Calculates all integrals weighted by wa. """ 

        wq = Averaged()

        xx = self.z_c

        # <xH1>_w 
        #------------------------------------------------
        yy = wa * self.xH1
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.xH1 = num / den

        # <xH2>_w 
        #------------------------------------------------
        yy = wa * self.xH2
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.xH2 = num / den

        # <xHe1>_w 
        #------------------------------------------------
        yy = wa * self.xHe1
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.xHe1 = num / den

        # <xHe2>_w 
        #------------------------------------------------
        yy = wa * self.xHe2
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.xHe2 = num / den

        # <xHe3>_w 
        #------------------------------------------------
        yy = wa * self.xHe3
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.xHe3 = num / den

        # <T>_w 
        #------------------------------------------------
        yy = wa * self.T
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.T = num / den

        # <mu>_w 
        #------------------------------------------------
        yy = wa * self.mu
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.mu = num / den

        # <H1i>_w 
        #------------------------------------------------
        yy = wa * self.H1i
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.H1i = num / den

        yy = wa * self.H1i_src
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.H1i_src = num / den

        yy = wa * self.H1i_rec
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.H1i_rec = num / den

        # <He1i>_w 
        #------------------------------------------------
        yy = wa * self.He1i
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He1i = num / den

        yy = wa * self.He1i_src
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He1i_src = num / den

        yy = wa * self.He1i_rec
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He1i_rec = num / den

        # <He2i>_w 
        #------------------------------------------------
        yy = wa * self.He2i
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He2i = num / den

        yy = wa * self.He2i_src
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He2i_src = num / den

        yy = wa * self.He2i_rec
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He2i_rec = num / den

        # <H1h>_w 
        #------------------------------------------------
        yy = wa * self.H1h
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.H1h = num / den

        yy = wa * self.H1h_src
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.H1h_src = num / den

        yy = wa * self.H1h_rec
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.H1h_rec = num / den

        # <He1h>_w 
        #------------------------------------------------
        yy = wa * self.He1h
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He1h = num / den

        yy = wa * self.He1h_src
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He1h_src = num / den

        yy = wa * self.He1h_rec
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He1h_rec = num / den

        # <He2h>_w 
        #------------------------------------------------
        yy = wa * self.He2h
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He2h = num / den

        yy = wa * self.He2h_src
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He2h_src = num / den

        yy = wa * self.He2h_rec
        num = utils.trap( xx, yy )
        den = utils.trap( xx, wa )
        wq.He2h_rec = num / den

        return wq
示例#21
0
    def calc_weighted(self, wa):
        """ Calculates all integrals weighted by wa. """

        wq = Averaged()

        xx = self.z_c

        # <xH1>_w
        #------------------------------------------------
        yy = wa * self.xH1
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.xH1 = num / den

        # <xH2>_w
        #------------------------------------------------
        yy = wa * self.xH2
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.xH2 = num / den

        # <xHe1>_w
        #------------------------------------------------
        yy = wa * self.xHe1
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.xHe1 = num / den

        # <xHe2>_w
        #------------------------------------------------
        yy = wa * self.xHe2
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.xHe2 = num / den

        # <xHe3>_w
        #------------------------------------------------
        yy = wa * self.xHe3
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.xHe3 = num / den

        # <T>_w
        #------------------------------------------------
        yy = wa * self.T
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.T = num / den

        # <mu>_w
        #------------------------------------------------
        yy = wa * self.mu
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.mu = num / den

        # <H1i>_w
        #------------------------------------------------
        yy = wa * self.H1i
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.H1i = num / den

        yy = wa * self.H1i_src
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.H1i_src = num / den

        yy = wa * self.H1i_rec
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.H1i_rec = num / den

        # <He1i>_w
        #------------------------------------------------
        yy = wa * self.He1i
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He1i = num / den

        yy = wa * self.He1i_src
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He1i_src = num / den

        yy = wa * self.He1i_rec
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He1i_rec = num / den

        # <He2i>_w
        #------------------------------------------------
        yy = wa * self.He2i
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He2i = num / den

        yy = wa * self.He2i_src
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He2i_src = num / den

        yy = wa * self.He2i_rec
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He2i_rec = num / den

        # <H1h>_w
        #------------------------------------------------
        yy = wa * self.H1h
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.H1h = num / den

        yy = wa * self.H1h_src
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.H1h_src = num / den

        yy = wa * self.H1h_rec
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.H1h_rec = num / den

        # <He1h>_w
        #------------------------------------------------
        yy = wa * self.He1h
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He1h = num / den

        yy = wa * self.He1h_src
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He1h_src = num / den

        yy = wa * self.He1h_rec
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He1h_rec = num / den

        # <He2h>_w
        #------------------------------------------------
        yy = wa * self.He2h
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He2h = num / den

        yy = wa * self.He2h_src
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He2h_src = num / den

        yy = wa * self.He2h_rec
        num = utils.trap(xx, yy)
        den = utils.trap(xx, wa)
        wq.He2h_rec = num / den

        return wq