52 else if( PopTot == 0 )
68 double e2p12 = 82258.9191133;
69 double e2p32 = 82259.2850014;
72 double e2p12_splitting = e2 / 24.;
73 double e2p32_splitting = e2 / 60.;
88 double e3 = e2p12 + 0.25 * e2p12_splitting;
89 double e4 = e2p32 - 0.625 * e2p32_splitting;
91 double de31 = e3 -
e1;
92 double de32 = e3 -
e2;
93 double de41 = e4 -
e1;
94 double de42 = e4 -
e2;
130 fixit(
"PopOpc <0 but Pesc > 0: We may need to review when Pesc is computed to get non-negative occupation numbers" );
140 double occnu_lya_23 = occnu_lya,
154 if( occnu_lya * Temp > 0. )
161 double texc1 =
sexp(
HFLines[0].EnergyK() / Temp );
162 double texc2 =
sexp( ((e2p32-e2p12)*T1CM) / Temp );
164 occnu_lya_23 = occnu_lya;
165 occnu_lya_13 = occnu_lya * texc1;
166 occnu_lya_24 = occnu_lya * texc2;
167 occnu_lya_14 = occnu_lya_13 * texc2;
170 enum { DEBUG_SPEC =
false };
173 fprintf(
ioQQQ,
"DEBUG texc %12.3e excitation %12.3e kinetic %12.3e\n",
179 occnu_lya_23 = occnu_lya;
180 occnu_lya_13 =
powi(de32/de31, 3) * occnu_lya;
181 occnu_lya_24 =
powi(de32/de42, 3) * occnu_lya;
182 occnu_lya_14 =
powi(de32/de41, 3) * occnu_lya;
200 double pump21 = pump12 * (*
HFLines[0].Lo()).g() / (*
HFLines[0].Hi()).g();
217 3.*a31*occnu_lya_13 *a32/(a31+a32)+
220 3.*a41*occnu_lya_14 *a42/(a41+a42);
233 occnu_lya_23*a32 * a31/(a31+a32)+
234 occnu_lya_24*a42*a41/(a41+a42);
237 double x = rate12 /
SDIV(a21 + rate21);
241 (*
HFLines[0].Hi()).Pop() = (x/(1.+x))* PopTot;
242 (*
HFLines[0].Lo()).Pop() = (1./(1.+x))* PopTot;
276 temp =
MIN2(1e4 , temp );
280 return exp10( -9.607 + log10( sqrt(temp)) *
sexp(
powpq(log10(temp),9,2) / 1800. ));
289 STATIC double h21_t_ge_20(
double temp )
295 temp =
MIN2( 1000.,temp );
297 y =-21.70880995483007-13.76259674006133*
x1;
303 if( teorginal > 1e3 )
305 y *= pow(teorginal/1e3 , 0.33 );
312 STATIC double h21_t_lt_20(
double temp )
318 temp =
MAX2( 1., temp );
320 y =9.720710314268267E-08+6.325515312006680E-08*
x1;
331 double teorginal = temp;
334 temp =
MIN2( 300., temp );
336 double y = 1.4341127e-9
337 + 9.4161077e-15 * temp
338 - 9.2998995e-9 / log(temp)
339 + 6.9539411e-9 / sqrt(temp)
340 + 1.7742293e-8 * log(temp)/
pow2(temp);
341 if( teorginal > 300. )
344 temp =
MIN2( 1000., teorginal );
345 y = -21.70880995483007 - 13.76259674006133 / sqrt(temp);
348 if( teorginal > 1e3 )
351 y *= pow( teorginal/1e3 , 0.33 );
359 temp =
MAX2(1., temp );
361 + 2.331358e-11 * temp
362 + 9.5640586e-11 *
pow2(log(temp))
363 - 4.6220869e-10 * sqrt(temp)
364 - 4.1719545e-10 / sqrt(temp);
413 temp =
MAX2( 2. , temp );
414 temp =
MIN2( 2e4 , temp );
417 return 9.588389834316704E-11
418 - 5.158891920816405E-14 * temp
419 + 5.895348443553458E-19 * temp * temp
420 + 2.053049602324290E-11 * sqrt(temp)
421 + 9.122617940315725E-10 * log(temp) / temp;
475 ioDATA =
open_data(
"hyperfine.dat",
"r" );
480 fprintf(
ioQQQ,
" Hyperfine could not read first line of hyperfine.dat.\n");
487 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioDATA ) != NULL )
489 if( chLine[0] ==
'#' )
493 else if( strstr(chLine,
"TDATA:") == NULL)
496 int Aiso = atoi(data[0].c_str());
497 int nelem = atoi(data[1].c_str());
508 if (data.size() <= 1)
510 fprintf(
ioQQQ,
"HyperfineCreate: Error: Invalid number of temperatures in 'TDATA:': %d\n",
515 Ntemp = data.size() - 1;
516 csTemp = (
double *)
MALLOC( (
size_t)Ntemp*
sizeof(double) );
519 for (std::vector<string>::const_iterator it = data.begin(); it != data.end() && i <=
Ntemp; it++, i++)
523 csTemp[i-1] = atof((*it).c_str());
530 ASSERT(nHFLines > 0 && Ntemp > 0);
531 for(
int i = 0; i <
Ntemp; i++)
536 ASSERT(csTemp[i] > csTemp[i-1]);
556 colstr[j].cs = (
double *)
MALLOC( (
size_t)(
Ntemp)*
sizeof(
double) );
557 colstr[j].cs2d= (
double *)
MALLOC( (
size_t)(
Ntemp)*
sizeof(
double) );
563 if( fseek( ioDATA , 0 , SEEK_SET ) != 0 )
565 fprintf(
ioQQQ,
" Hyperfine could not rewind hyperfine.dat.\n");
572 fprintf(
ioQQQ,
" Hyperfine could not read first line of hyperfine.dat.\n");
580 int year = (int)
FFmtRead(chLine,&j,
sizeof(chLine),&lgEOL);
581 int month = (int)
FFmtRead(chLine,&j,
sizeof(chLine),&lgEOL);
582 int day = (int)
FFmtRead(chLine,&j,
sizeof(chLine),&lgEOL);
585 static int iYR=13, iMN=10, iDY=18;
586 if( ( year != iYR ) || ( month != iMN ) || ( day != iDY ) )
589 " Hyperfine: the version of hyperfine.dat in the data directory is not the current version.\n" );
591 " I expected to find the number %i %i %i and got %i %i %i instead.\n" ,
593 year , month , day );
594 fprintf(
ioQQQ,
"Here is the line image:\n==%s==\n", chLine );
612 if( chLine[0] ==
'#' || strstr(chLine,
"TDATA:") != NULL)
616 int Aiso = atoi(data[0].c_str());
617 int nelem = atoi(data[1].c_str());
628 (*
HFLines[j].Hi()).nelem() = nelem;
631 (*
HFLines[j].Hi()).IonStg() = atoi(data[2].c_str());
646 double tmp = (*
HFLines[j].Hi()).g();
651 double fenergyWN =
MAX2(ENERGY_MIN_WN, 1.0 / wavelength);
671 if( data.size() > 6 )
674 for (
int ij = 6, ii = 0; ij < (int) data.size() && ii <
Ntemp; ij++, ii++)
676 colstr[j].cs[ii] = atof(data[ij].c_str());
677 ASSERT(colstr[j].cs[ii] >= 0.0);
681 spline(csTemp, colstr[j].cs, Ntemp, 2e31, 2e31, colstr[j].cs2d);
686 free( colstr[j].cs ); colstr[j].cs = NULL;
687 free( colstr[j].cs2d ); colstr[j].cs2d = NULL;
699 for(
long nelem = 0; nelem <
LIMELM; nelem++ )
717 q21 = COLL_CONST * upsilon / (
phycon.
sqrte * (*HFLines[i].Hi()).g());
719 q12 = (*HFLines[i].Hi()).g()/ (*HFLines[i].Lo()).g() * q21 * exp(-1 * h * c * HFLines[i].EnergyWN / (k *
phycon.
te));
721 x = Ne * q12 / (HFLines[i].Emis().Aul() * (1 + Ne * q21 / HFLines[i].Aul()));
722 HFLines[i].xIntensity() =
N * HFLines[i].Emis().Aul() * x / (1.0 + x) * h * c / (HFLines[i].EnergyAng() / 1e8);
740 if( colstr[i].cs == NULL )
741 return HFLines[i].Coll().col_str();
746 upsilon = colstr[i].cs[0];
748 else if(
phycon.
te >= csTemp[Ntemp-1])
752 double slope = log10(colstr[i].cs[j-1]/colstr[i].cs[j]) / log10(csTemp[j-1]/csTemp[j]);
753 upsilon = log10(
phycon.
te/csTemp[j])*slope + log10(colstr[i].cs[j]);
754 upsilon =
exp10( upsilon);
758 splint( csTemp, colstr[i].cs, colstr[i].cs2d, Ntemp,
phycon.
te, &upsilon );
double HyperfineCS(size_t i)
double TexcLine(const TransitionProxy &t)
STATIC double h21_t_ge_10(double temp)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
vector< double, allocator_avx< double > > ContBoltz
STATIC double h21_t_lt_10(double temp)
NORETURN void TotalInsanity(void)
double H21cm_H_atom(double temp)
void set_xIntensity(const TransitionProxy &t)
TransitionList HFLines("HFLines",&AnonStates)
sys_float sexp(sys_float x)
void HyperfineCreate(void)
void splint(const double xa[], const double ya[], const double y2a[], long int n, double x, double *y)
t_iso_sp iso_sp[NISO][LIMELM]
const double TEMP_LIMIT_LOW
double xIonDense[LIMELM][LIMELM+1]
double H21cm_proton(double temp)
double H21cm_electron(double temp)
void resize(size_t newsize)
void spline(const double x[], const double y[], long int n, double yp1, double ypn, double y2a[])
realnum getMagMom(int Anum)
realnum getSpin(int Anum)
const double TEMP_LIMIT_HIGH
const int INPUT_LINE_LENGTH
double powi(double, long int)
double OccupationNumberLine(const TransitionProxy &t)
LyaSourceFunctionShape LyaSourceFunctionShape_assumed
double GetGF(double trans_prob, double enercm, double gup)
#define DEBUG_ENTRY(funcname)
double powpq(double x, int p, int q)
static vector< realnum > wavelength
const double ENERGY_MIN_WN
int fprintf(const Output &stream, const char *format,...)
sys_float SDIV(sys_float x)
void Split(const string &str, const string &sep, vector< string > &lst, split_mode mode)
vector< TransitionList > AllTransitions
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
void MakeCS(const TransitionProxy &t)
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)