32 STATIC double TempInterp2(
double* TempArray ,
double* ValueArray,
long NumElements,
double Te );
48 trList.push_back( tr );
55 double &sum_inten,
double &sum_obs_inten,
double &sum_cool,
double &sum_heat )
58 sum_inten = sum_obs_inten = sum_cool = sum_heat = 0.;
60 if( trList.size() == 0)
64 for( vector<TransitionProxy>::iterator tr = trList.begin(); tr != trList.end(); tr++ )
66 sum_obs_inten += (*tr).Emis().xObsIntensity();
67 sum_inten += (*tr).Emis().xIntensity();
68 sum_cool += (*tr).Coll().cool();
69 sum_heat += (*tr).Coll().heat();
70 wl.push_back( (*tr).WLAng() );
76 std::sort( wl.begin(), wl.end(), std::less<realnum>() );
86 const double sumxInt,
const double sumxObsInt,
87 const double sumcool,
const double sumheat,
88 const char *chComment )
110 for( vector<TransitionProxy>::iterator tr = multiHe.begin(); tr != multiHe.end(); tr++ )
112 if( (*tr).ipHi() == ipHi && (*tr).ipLo() == ipLo )
148 " start He-like iso sequence");
158 for(
long nelem=ipISO; nelem <
LIMELM; nelem++ )
160 vector<TransitionProxy> multiplet;
161 vector<TransitionProxy> HeTrList;
162 double sumxInt = 0., sumxObsInt = 0., sumcool = 0., sumheat = 0.;
177 chLabel =
chIonLbl(nelem+1, nelem+1-ipISO);
179 for( vector<two_photon>::iterator tnu = sp->
TwoNu.begin(); tnu != sp->
TwoNu.end(); ++tnu )
181 fixit(
"This was multiplied by Pesc when treated as a line, now what? Only used for printout?");
182 fixit(
"below should be 'i' instead of 'r' ?");
184 string tpc_comment =
"";
187 tpc_comment =
" two photon continuum, " +
191 linadd( tnu->AulTotal * tnu->E2nu * EN1RYD * (*tnu->Pop),
192 2. *
wn2ang( (*sp).trans( (*tnu).ipHi, (*tnu).ipLo ).EnergyWN() ),
193 chLabel.c_str(),
'r', tpc_comment.c_str() );
208 multiplet_sum( multiplet, av_wl, sumxInt, sumxObsInt, sumcool, sumheat );
209 multiplet.resize( 0 );
212 " total emission in He-like intercombination lines from 2p3P to ground ");
226 for(
long ipLo=0; ipLo <
ipHe2p3P0; ipLo++ )
228 vector<long> EnterTheseLast;
229 for(
long ipHi=ipLo+1; ipHi < nLoop; ipHi++ )
239 sp->
st[ipLo].l())==1 )
240 && (sp->
st[ipLo].l()>1)
241 && (sp->
st[ipHi].l()>1)
242 && ( sp->
st[ipHi].n() ==
246 if( (sp->
st[ipHi].S()==1)
247 && (sp->
st[ipLo].S()==1) )
251 else if( (sp->
st[ipHi].S()==3)
252 && (sp->
st[ipLo].S()==3) )
254 string comment_trans =
"";
261 HeTrList.push_back( sp->
trans(ipHi , ipLo+1) );
262 HeTrList.push_back( sp->
trans(ipHi+1, ipLo+1) );
264 if( multiplet.size() == 0 )
continue;
266 multiplet_sum( multiplet, av_wl, sumxInt, sumxObsInt, sumcool, sumheat );
267 multiplet.resize( 0 );
271 comment_trans =
"singlet to singlet: ";
273 comment_trans +=
"; ";
277 sp->
trans(ipHi+1,ipLo+1).
WLAng(), sumxInt, sumxObsInt, sumcool, sumheat,
278 comment_trans.c_str() );
285 HeTrList.push_back( sp->
trans(ipHi , ipLo) );
286 HeTrList.push_back( sp->
trans(ipHi+1, ipLo) );
288 if( multiplet.size() == 0 )
continue;
290 multiplet_sum( multiplet, av_wl, sumxInt, sumxObsInt, sumcool, sumheat );
291 multiplet.resize( 0 );
295 comment_trans =
"triplet to triplet: ";
297 comment_trans +=
"; ";
301 sp->
trans(ipHi,ipLo).
WLAng(), sumxInt, sumxObsInt, sumcool, sumheat,
302 comment_trans.c_str() );
306 else if( ipLo==
ipHe2s3S && ipHi == ipHe2p3P0 )
313 for(
long i=ipHe2p3P0; i <=
ipHe2p3P2; i++ )
329 HeTrList.push_back( sp->
trans(i, ipLo) );
332 if( multiplet.size() == 0 )
continue;
333 multiplet_sum( multiplet, av_wl, sumxInt, sumxObsInt, sumcool, sumheat );
334 multiplet.resize( 0 );
337 linadd(sumxObsInt, av_wl,
"TOTL",
'i',
338 "total emission in He-like lines, use average of three line wavelengths " );
343 string comment_trans =
"";
348 PutLineSum( sp->
trans(ipHi,ipLo), av_wl, sumxInt, sumxObsInt, sumcool, sumheat,
349 comment_trans.c_str() );
353 string comment_trans =
"";
361 linadd(sumxObsInt, av_wl, chLabel.c_str(),
'i',
362 "total emission in He-like lines, use average of three line wavelengths " );
375 string comment_trans =
"";
392 if( abs(
L_(ipHi) -
L_(ipLo) ) != 1 )
394 EnterTheseLast.push_back( ipHi );
401 string comment_trans =
"";
411 enum {DEBUG_LOC=
false};
414 if( nelem==1 && ipLo==0 && ipHi==1 )
427 for( vector<long>::iterator it = EnterTheseLast.begin(); it != EnterTheseLast.end(); it++ )
429 string comment_trans =
"";
439 for(
long ipHi=
ipHe2p3P2+1; ipHi < nLoop; ipHi++ )
441 for(
long ipLo=ipHe2p3P0; ipLo <=
ipHe2p3P2; ++ipLo )
455 HeTrList.push_back( sp->
trans(ipHi, ipLo) );
460 multiplet.resize( 0 );
464 if( multiplet.size() == 0 )
continue;
465 multiplet_sum( multiplet, av_wl, sumxInt, sumxObsInt, sumcool, sumheat );
466 multiplet.resize( 0 );
468 string comment_trans =
"";
474 comment_trans.c_str() );
476 for(
long ipLo=
ipHe2p3P2+1; ipLo < nLoop-1; ipLo++ )
478 vector<long> EnterTheseLast;
479 for(
long ipHi=ipLo+1; ipHi < nLoop; ipHi++ )
494 EnterTheseLast.push_back( ipHi );
498 string comment_trans =
"";
507 for( vector<long>::iterator it = EnterTheseLast.begin(); it != EnterTheseLast.end(); it++ )
509 string comment_trans =
"";
527 for(
long ipDens = 0; ipDens <
NUMDENS; ++ipDens )
535 linadd( intens, wvlg, CaBLines[nelem][i].label,
'i',
"Case B intensity " );
551 double photons_3889_plus_7065 =
571 photons_3889_plus_7065 +=
578 linadd( photons_3889_plus_7065, 3889.,
"Pho+",
'i',
579 "photon sum given in Porter et al. 2007 (astro-ph/0611579)");
603 while (chLine[0] ==
'#');
613 # define chLine_LENGTH 1000
619 fprintf(
ioQQQ,
" lines_helium opening he1_case_b.dat\n");
621 ioDATA =
open_data(
"he1_case_b.dat",
"r" );
626 fprintf(
ioQQQ,
" lines_helium could not read first line of he1_case_b.dat.\n");
631 i1 = (long)
FFmtRead(chLine,&i,
sizeof(chLine),&lgEOL);
632 i2 = (long)
FFmtRead(chLine,&i,
sizeof(chLine),&lgEOL);
639 " lines_helium: the version of he1_case_ab.dat is not the current version.\n" );
641 " lines_helium: I expected to find the number %i and got %li instead.\n" ,
643 fprintf(
ioQQQ,
"Here is the line image:\n==%s==\n", chLine );
648 if (
read_data_line( chLine , (
int)
sizeof(chLine) , ioDATA ) == NULL )
650 fprintf(
ioQQQ,
" lines_helium could not find line of densities in he1_case_ab.dat.\n");
656 for(
long j=0; !lgEOL && j <
NUMDENS; ++j)
662 if (
read_data_line( chLine , (
int)
sizeof(chLine) , ioDATA ) == NULL )
664 fprintf(
ioQQQ,
" lines_helium could not find line of temperatures in he1_case_ab.dat.\n");
670 for (
long j=0; !lgEOL && j <
NUMTEMPS; ++j)
697 for(
long j = 0; j < i2; ++j )
701 CaBLines[nelem][j].
ipHi = -1;
702 CaBLines[nelem][j].
ipLo = -1;
703 strcpy( CaBLines[nelem][j].label ,
" " );
705 for(
long k = 0; k <
NUMDENS; ++k )
708 for(
long l = 0; l <
NUMTEMPS; ++l )
720 while(
read_data_line( chLine , (
int)
sizeof(chLine) , ioDATA ) != NULL )
723 if( (chLine[0] ==
' ') || (chLine[0]==
'\n') )
731 long ipLo = (long)
FFmtRead(chLine,&j,
sizeof(chLine),&lgEOL);
732 long ipHi = (long)
FFmtRead(chLine,&j,
sizeof(chLine),&lgEOL);
733 CaBLines[nelem][line].
ipLo = ipLo;
734 CaBLines[nelem][line].
ipHi = ipHi;
736 ASSERT( CaBLines[nelem][line].ipLo < CaBLines[nelem][line].ipHi );
738 strcpy( CaBLines[nelem][line].label,
"Ca B" );
746 for(
long ipDens = 0; ipDens <
NUMDENS; ++ipDens )
750 fprintf(
ioQQQ,
" lines_helium could not scan case B lines, current indices: %li %li\n",
751 CaBLines[nelem][line].ipHi,
752 CaBLines[nelem][line].ipLo );
756 char *chTemp = chLine;
758 long den = (long)
FFmtRead(chTemp,&j,
sizeof(chTemp),&lgEOL);
759 if( den != ipDens + 1 )
761 for(
long ipTe = 0; ipTe <
NUMTEMPS; ++ipTe )
764 if( (chTemp =
strchr_s( chTemp,
'\t' )) == NULL )
766 fprintf(
ioQQQ,
" lines_helium could not scan case B lines, current indices: %li %li\n",
767 CaBLines[nelem][line].ipHi,
768 CaBLines[nelem][line].ipLo );
772 sscanf( chTemp,
"%le" , &b );
788 STATIC double TempInterp2(
double* TempArray ,
double* ValueArray,
long NumElements,
double Te )
797 if( Te <= TempArray[0] )
799 return ValueArray[0] + log10( TempArray[0]/Te );
801 else if( Te >= TempArray[NumElements-1] )
803 return ValueArray[NumElements-1];
809 ASSERT( (ipTe >=0) && (ipTe < NumElements-1) );
813 i0 =
max(
min(ipTe-ORDER/2,NumElements-ORDER-1),0);
814 rate =
lagrange( &TempArray[i0], &ValueArray[i0], ORDER+1, Te );
832 double dr_rate =
iso_sp[ipISO][nelem].
fb[i].DielecRecomb;
840 PutLine( tr,
"iso satellite line" );
static double **** CaBIntensity
double wn2ang(double fenergyWN)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
string chIonLbl(const TransitionProxy &t)
NORETURN void TotalInsanity(void)
multi_arr< int, 3 > ipSatelliteLines
STATIC void randomize_inten(t_iso_sp *sp, long ipLo, long ipHi)
void set_xIntensity(const TransitionProxy &t)
string iso_comment_tran_levels(long ipISO, long nelem, long ipLo, long ipHi)
static double CaBDensities[NUMDENS]
double phots(const TransitionProxy &t)
long hunt_bisect(const T x[], long n, T xval)
t_iso_sp iso_sp[NISO][LIMELM]
STATIC void insert_trans(vector< TransitionProxy > &trList, TransitionProxy tr)
double xIonDense[LIMELM][LIMELM+1]
char * read_data_line(char *chLine, int size, FILE *ioDATA)
vector< two_photon > TwoNu
long int n_HighestResolved_max
realnum & EnergyWN() const
STATIC realnum get_multiplet_wl(vector< TransitionProxy > &multiHe, long ipHi, long ipLo)
STATIC void multiplet_sum(vector< TransitionProxy > &trList, realnum &av_wl, double &sum_inten, double &sum_obs_inten, double &sum_cool, double &sum_heat)
double & xIntensity() const
EmissionList::reference Emis() const
LinSv * linadd(double xEmiss, realnum wavelength, const char *chLab, char chInfo, const char *chComment)
const char * strchr_s(const char *s, int c)
vector< vector< TransitionList > > SatelliteLines
STATIC void PutLineSum(const TransitionProxy &tr, const realnum av_wl, const double sumxInt, const double sumxObsInt, const double sumcool, const double sumheat, const char *chComment)
STATIC void GetStandardHeLines(void)
multi_arr< long, 3 > QuantumNumbers2Index
TransitionProxy trans(const long ipHi, const long ipLo)
double lagrange(const double x[], const double y[], long n, double xval)
STATIC void DoSatelliteLines(long nelem)
multi_arr< extra_tr, 2 > ex
void PutLine(const TransitionProxy &t, const char *chComment, const char *chLabelTemp, const ExtraInten &extra)
static double CaBTemps[NUMTEMPS]
CollisionProxy Coll() const
#define DEBUG_ENTRY(funcname)
double linint(const double x[], const double y[], long n, double xval)
int fprintf(const Output &stream, const char *format,...)
double & xObsIntensity() const
static stdLines ** CaBLines
vector< realnum > CaseBWlHeI
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
STATIC double TempInterp2(double *TempArray, double *ValueArray, long NumElements, double Te)
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)
long int StuffComment(const char *chComment)