Changeset 2127 for trunk/source/helike_recom.cpp
- Timestamp:
- 06/25/08 11:17:40 (5 months ago)
- Files:
-
- 1 modified
-
trunk/source/helike_recom.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/helike_recom.cpp
r1960 r2127 4 4 /*cross_section - calculates the photoionization cross_section for a given level and photon energy*/ 5 5 /*radrecomb - calculates radiative recombination coefficients. */ 6 /*RecomInt - Integral in milne relation. Called by qg32. */7 6 /*He_cross_section returns cross section (cm^-2), 8 7 * given EgammaRyd, the photon energy in Ryd, … … 31 30 STATIC double X1Int( double u ); 32 31 STATIC double X2Int( double u ); 33 34 STATIC double cross_section(double EgammaRyd); 35 36 static double RecomInt(double EE); 32 STATIC double cross_section(double EgammaRyd, long nelem, long ipLev); 37 33 38 34 #if 0 … … 46 42 #endif 47 43 48 static double kTRyd,EthRyd,Xn_S59; 49 static long int ipLev,globalZ; 44 static double EthRyd,Xn_S59; 50 45 51 46 /* Here are several structures containing fits to cross-sections calculated in the following: */ … … 1512 1507 1513 1508 /* 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] */ 1515 1510 /* >>refer He PCS Hummer, D.G., & Storey, P.J. 1998, MNRAS 297, 1073 */ 1516 1511 double PreferredThres[NUM_PREF_TCS] = { … … 1527 1522 13.54,26.58,55.71,-1.00,-1.00,-1.00,-1.00,-1.00,-1.00,58.07}; 1528 1523 1529 globalZ = nelem; 1530 1531 ipLev = ipLevel; 1532 1533 EthRyd = iso.xIsoLevNIonRyd[ipHE_LIKE][nelem][ipLev]; 1524 EthRyd = iso.xIsoLevNIonRyd[ipHE_LIKE][nelem][ipLevel]; 1534 1525 1535 1526 /* make sure this routine not called within collapsed high levels */ … … 1537 1528 1538 1529 /* this is a resolved level */ 1539 cs = (1.e-18)*cross_section( EgammaRyd );1530 cs = (1.e-18)*cross_section( EgammaRyd, nelem, ipLevel ); 1540 1531 1541 1532 /* Scale to preferred threshold values */ … … 1546 1537 if( ipCurrentLevel!=ipLevel ) 1547 1538 { 1548 ThreshCS = cross_section( EthRyd );1539 ThreshCS = cross_section( EthRyd, nelem, ipLevel ); 1549 1540 ipCurrentLevel = ipLevel; 1550 1541 } … … 1560 1551 1561 1552 /*cross_section calculates the photoionization cross_section for a given level and photon energy*/ 1562 STATIC double cross_section(double EgammaRyd )1553 STATIC double cross_section(double EgammaRyd, long nelem, long ipLev) 1563 1554 { 1564 1555 /* These fit parameters (E0, sigma, y_a, P, y_w, yzero, and yone) all come from the following work: */ … … 1627 1618 1628 1619 double pcs,Egamma,lnE,a,b,c,y,F,x; 1629 long nelem = globalZ;1630 1631 1620 int ipISO=ipHE_LIKE; 1632 1621 … … 2038 2027 #endif 2039 2028 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 from2064 * threshold tend to fall off more slowly. */2065 do2066 {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 arbitrary2079 * 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 2105 2029 /* >>refer He-like RR Seaton, M.J. 1959, MNRAS 119, 81S */ 2106 2030 double Recomb_Seaton59( long nelem, double temp, long n)
