Show
Ignore:
Timestamp:
06/25/08 11:17:40 (5 months ago)
Author:
rporter
Message:

/trunk/source - a bunch of relatively minor changes, essentially all refactoring and comments. One change to command parser. "atom XX-like error generation" now accepts "PESSimistic" option, which chooses the worst of two sets of data in the Monte Carlo calculation.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/helike_recom.cpp

    r1960 r2127  
    44/*cross_section - calculates the photoionization cross_section for a given level and photon energy*/ 
    55/*radrecomb - calculates radiative recombination coefficients. */ 
    6 /*RecomInt - Integral in milne relation.  Called by qg32.       */ 
    76/*He_cross_section returns cross section (cm^-2),  
    87 * given EgammaRyd, the photon energy in Ryd, 
     
    3130STATIC double X1Int( double u ); 
    3231STATIC double X2Int( double u ); 
    33  
    34 STATIC double cross_section(double EgammaRyd); 
    35  
    36 static double RecomInt(double EE); 
     32STATIC double cross_section(double EgammaRyd, long nelem, long ipLev); 
    3733 
    3834#if 0 
     
    4642#endif 
    4743 
    48 static double kTRyd,EthRyd,Xn_S59;  
    49 static long int ipLev,globalZ; 
     44static double EthRyd,Xn_S59;  
    5045 
    5146/* Here are several structures containing fits to cross-sections calculated in the following: */ 
     
    15121507 
    15131508        /* These corrections ensure helium cross-sections agree with the highly accurate  
    1514          * values given by Hummer and Storey (1998).  The index is [ipLev - 1]  */ 
     1509         * values given by Hummer and Storey (1998).  The index is [ipLevel - 1]        */ 
    15151510        /* >>refer He   PCS     Hummer, D.G., & Storey, P.J. 1998, MNRAS 297, 1073      */   
    15161511        double PreferredThres[NUM_PREF_TCS] = { 
     
    15271522                13.54,26.58,55.71,-1.00,-1.00,-1.00,-1.00,-1.00,-1.00,58.07}; 
    15281523 
    1529         globalZ = nelem; 
    1530  
    1531         ipLev = ipLevel; 
    1532  
    1533         EthRyd = iso.xIsoLevNIonRyd[ipHE_LIKE][nelem][ipLev]; 
     1524        EthRyd = iso.xIsoLevNIonRyd[ipHE_LIKE][nelem][ipLevel]; 
    15341525 
    15351526        /* make sure this routine not called within collapsed high levels */ 
     
    15371528 
    15381529        /* this is a resolved level */ 
    1539         cs = (1.e-18)*cross_section( EgammaRyd ); 
     1530        cs = (1.e-18)*cross_section( EgammaRyd, nelem, ipLevel ); 
    15401531 
    15411532        /* Scale to preferred threshold values */ 
     
    15461537                if( ipCurrentLevel!=ipLevel ) 
    15471538                { 
    1548                         ThreshCS = cross_section( EthRyd ); 
     1539                        ThreshCS = cross_section( EthRyd, nelem, ipLevel ); 
    15491540                        ipCurrentLevel = ipLevel; 
    15501541                } 
     
    15601551 
    15611552/*cross_section calculates the photoionization cross_section for a given level and photon energy*/ 
    1562 STATIC double cross_section(double EgammaRyd) 
     1553STATIC double cross_section(double EgammaRyd, long nelem, long ipLev) 
    15631554{ 
    15641555        /* These fit parameters (E0, sigma, y_a, P, y_w, yzero, and yone) all come from the following work: */ 
     
    16271618 
    16281619        double pcs,Egamma,lnE,a,b,c,y,F,x; 
    1629         long nelem = globalZ; 
    1630  
    16311620        int ipISO=ipHE_LIKE; 
    16321621 
     
    20382027#endif 
    20392028 
    2040 /*helike_radrecomb_from_cross_section calculates radiative recombination coefficients. */ 
    2041 double helike_radrecomb_from_cross_section(double temp, long nelem, long ipLo) 
    2042 { 
    2043         double alpha,RecomIntegral=0.,b,E1,E2,step,OldRecomIntegral,TotChangeLastFive; 
    2044         double change[5] = {0.,0.,0.,0.,0.}; 
    2045  
    2046         EthRyd = iso.xIsoLevNIonRyd[ipHE_LIKE][nelem][ipLo]; 
    2047  
    2048         /* Factors outside integral in Milne relation.  */ 
    2049         b = MILNE_CONST * StatesElem[ipHE_LIKE][nelem][ipLo].g * pow(temp,-1.5) / 4.; 
    2050         /* kT in Rydbergs.      */ 
    2051         kTRyd = temp / TE1RYD; 
    2052         globalZ = nelem; 
    2053         ipLev = ipLo; 
    2054  
    2055         /* Begin integration.   */ 
    2056         /* First define characteristic step */ 
    2057         E1 = EthRyd; 
    2058         step = MIN2( 0.25*kTRyd, 0.5*E1 ); 
    2059         E2 = E1 + step; 
    2060         /* Perform initial integration, from threshold to threshold + step.     */ 
    2061         RecomIntegral = qg32( E1, E2, RecomInt); 
    2062         /* Repeat the integration, adding each new result to the total,  
    2063          * except that the step size is doubled every time, since values away from  
    2064          * threshold tend to fall off more slowly.      */ 
    2065         do 
    2066         { 
    2067                 OldRecomIntegral = RecomIntegral; 
    2068                 E1 = E2; 
    2069                 step *= 1.25; 
    2070                 E2 = E1 + step; 
    2071                 RecomIntegral += qg32( E1, E2, RecomInt); 
    2072                 change[4] = change[3]; 
    2073                 change[3] = change[2]; 
    2074                 change[2] = change[1]; 
    2075                 change[1] = change[0]; 
    2076                 change[0] = (RecomIntegral - OldRecomIntegral)/RecomIntegral; 
    2077                 TotChangeLastFive = change[0] + change[1] + change[2] + change[3] + change[4]; 
    2078         /* Continue integration until the upper limit exceeds 100kTRyd, an arbitrary 
    2079          * point at which the integrand component exp(electron energy/kT) is very small, 
    2080          * making neglible cross-sections at photon energies beyond that point, 
    2081          * OR when the last five steps resulted in less than a 1 percent change.        */ 
    2082         } while ( ((E2-EthRyd) < 100.*kTRyd) && ( TotChangeLastFive > 0.0001) ); 
    2083  
    2084         /* Calculate recombination coefficient. */ 
    2085         alpha = b * RecomIntegral; 
    2086  
    2087         alpha = MAX2( alpha, SMALLDOUBLE ); 
    2088  
    2089         return alpha; 
    2090 } 
    2091  
    2092 /*RecomInt, used in comput milne relation for he rec - the energy is photon Rydbergs.   */ 
    2093 static double RecomInt(double ERyd) 
    2094 { 
    2095         double x1, temp; 
    2096  
    2097         /* Milne relation integrand     */ 
    2098         x1 = ERyd * ERyd * exp(-1.0 * ( ERyd - EthRyd ) / kTRyd); 
    2099         temp = He_cross_section( ERyd , ipLev, globalZ ); 
    2100         x1 *= temp; 
    2101  
    2102         return x1; 
    2103 } 
    2104  
    21052029/* >>refer      He-like RR      Seaton, M.J. 1959, MNRAS 119, 81S */ 
    21062030double Recomb_Seaton59( long nelem, double temp, long n)