50 unsigned long StrLen =
min(strlen(chLine),ArrLen);
51 ASSERT( StrLen < LineLen );
52 unsigned long pad = (LineLen-StrLen)/2;
53 for(
unsigned long i=0; i < pad; ++i )
67 double ratio = ( q2 >
SMALLFLOAT ) ? q1/q2 : 0.;
75 vector<realnum> sclsav, scaled;
76 vector<long int> ipSortLines;
77 vector<double> xLog_line_lumin;
78 vector<short int> lgPrt;
129 for( ipEmType=0; ipEmType<nEmType; ++ipEmType )
145 char wl_str[20] =
"";
149 " >>PROBLEM Normalization line (\"%s\" %s) has small or zero intensity, its value was %.2e and its intensity was set to 1.\n"
150 " >>Please consider using another normalization line (this is set with the NORMALIZE command).\n",
152 fprintf(
ioQQQ,
" >>The relative intensities will be meaningless, and many lines may appear too faint.\n" );
158 if( ipEmType == 1 || ipEmType == 3 )
176 xLog_line_lumin[i] = ( line_lumin > 0. ) ? log10(line_lumin) : 0.;
204 for(i=0; i< 32; i++ )
206 ipNegIntensity[i] = LONG_MAX;
215 const char chIntensityType[4][100]=
216 {
" Intrinsic" ,
" Emergent" ,
"Cumulative intrinsic" ,
"Cumulative emergent" };
217 ASSERT( ipEmType==0 || ipEmType==1 || ipEmType==2 || ipEmType==3 );
228 fprintf(
ioQQQ,
" Caution: emergent intensities are not reliable on the "
229 "first iteration.\n");
249 sclsav[iprnt] = scaled[i];
258 ipNegIntensity[nNegIntenLines] = i;
259 nNegIntenLines =
MIN2(32,nNegIntenLines+1);
265 xLog_line_lumin[iprnt] = 0.;
281 xLog_line_lumin[i] = 0.;
286 sclsav[i] = scaled[i];
291 ipNegIntensity[nNegIntenLines] = i;
292 nNegIntenLines =
MIN2(32,nNegIntenLines+1);
309 for( i=0; i<iprnt; ++i )
316 sclsav[j] = sclsav[i];
319 xLog_line_lumin[j] = xLog_line_lumin[i];
320 Slines[j] = Slines[i];
329 for( i=0; i<iprnt; ++i )
376 for( i=0; i<iprnt; ++i )
395 nline = (iprnt + 2)/3;
401 nline = (iprnt + 3)/4;
411 for( i=0; i < nline; i++ )
416 for( j=i; j<iprnt; j = j + nline)
419 long ipLin = ipSortLines[j];
452 if( sclsav[ipLin] < 9999.5 )
456 else if( sclsav[ipLin] < 99999.5 )
460 else if( sclsav[ipLin] < 999999.5 )
464 else if( sclsav[ipLin] < 9999999.5 )
475 if( j+nline < iprnt )
482 if( nNegIntenLines > 0 )
484 fprintf(
ioQQQ,
" Lines with negative intensities - Linear intensities relative to normalize line.\n" );
487 for( i=0; i < nNegIntenLines; ++i )
492 scaled[ipNegIntensity[i]] );
506 ipNegIntensity[j] = i;
516 for( i=0; i < j; i++ )
533 ipNegIntensity[j] = i;
542 for( i=0; i < j; i++ )
629 int repeat = (72-len)/2;
630 for( i=0; i < repeat; ++i )
633 for( i=0; i < 72-repeat-len; ++i )
646 if( strcmp(chCKey,
"CONT") != 0 )
661 " *********************************> Log(U):%6.2f <*********************************\n",
667 "\n This is a beta test version of the code, and is intended for testing only.\n\n" );
675 fprintf(
ioQQQ,
" >>>>>>>>>> Warning! Warnings exist, this calculation has serious problems.\n" );
683 " >>>>>>>>>> Cautions are present.\n" );
689 " >>>>>>>>>> The calculation stopped for unintended reasons.\n" );
695 " >>>>>>>>>> Another iteration is needed. Use the ITERATE command.\n" );
701 strcpy( chGeo,
"Closed" );
705 strcpy( chGeo,
" Open" );
711 strcpy( chPlaw,
" Constant Pressure " );
716 strcpy( chPlaw,
" Constant Density " );
722 strcpy( chPlaw,
" Power Law Density " );
727 strcpy( chPlaw,
" Rapid Fluctuations " );
732 strcpy( chPlaw,
" Special Density Lw " );
737 strcpy( chPlaw,
" Hydrostatic Equlib " );
742 strcpy( chPlaw,
" Radia Driven Wind " );
747 strcpy( chPlaw,
" Dynamical Flow " );
752 strcpy( chPlaw,
" Globule " );
757 strcpy( chPlaw,
" UNRECOGNIZED CPRES " );
761 "\n Emission Line Spectrum. %20.20sModel. %6.6s geometry. Iteration %ld of %ld.\n",
771 chUnit =
"/arcsec^2";
775 sprintf( chLine,
"Flux observed at the Earth (erg/s/cm^2%s).", chUnit );
786 sprintf( chLine,
"Surface brightness (erg/s/cm^2/%s).", chUnit );
797 chUnit =
"erg/s/cm^2";
803 sprintf( chCoverage,
"with full coverage" );
805 sprintf( chCoverage,
"with a covering factor of %.1f%%",
geometry.
covgeo*100. );
808 sprintf( chLine,
"Luminosity (%s) emitted by a partial cylinder %s.", chUnit, chCoverage );
810 sprintf( chLine,
"Luminosity (%s) emitted by a shell %s.", chUnit, chCoverage );
817 chAper =
"long slit";
819 chAper =
"pencil beam";
823 sprintf( chLine,
"Observed through a %s with aperture covering factor %.1f%%.",
831 sprintf( chLine,
"Intensity (erg/s/cm^2)." );
844 static const int NWLH = 21;
846 realnum wlh[NWLH] = { 6562.81e0f, 4861.33e0f, 4340.46e0f, 4101.73e0f, 1.87510e4f, 1.28180e4f,
847 1.09380e4f, 1.00493e4f, 2.62513e4f, 2.16551e4f, 1.94454e4f, 7.45777e4f,
848 4.65247e4f, 3.73951e4f, 4.05113e4f, 7.45777e4f, 3.29607e4f, 1215.67e0f,
849 1025.72e0f, 972.537e0f, 949.743e0f };
865 for( j=0; j<NWLH; ++j )
867 if( fabs(
LineSave.
lines[i].wavelength()-wlh[j] ) <= errorwave )
880 static const int NWLHE = 20;
881 realnum wlhe[NWLHE] = {1640.43e0f, 1215.13e0f, 1084.94e0f, 1025.27e0f, 4685.64e0f, 3203.04e0f,
882 2733.24e0f, 2511.15e0f, 1.01233e4f, 6559.91e0f, 5411.37e0f, 4859.18e0f,
883 1.86362e4f, 1.16260e4f, 9344.62, 8236.51e0f, 303.784e0f, 256.317e0f,
884 243.027e0f, 237.331e0f};
895 for( j=0; j<NWLHE; ++j )
897 if( fabs(
LineSave.
lines[i].wavelength()-wlhe[j] ) <= errorwave )
918 fprintf(
ioQQQ,
" PrtFinal could not find H 1 4861.33 with cdLine.\n" );
938 fprintf(
ioQQQ,
" PrtFinal could not find He 1 5876 with cdLine.\n" );
952 fprintf(
ioQQQ,
" PrtFinal could not find He 2 4686 with cdLine.\n" );
966 heabun = (he4686*0.078 + he5876*0.739)/hbeta;
987 if(
cdLine(
"blnd",5007,&o5007,&absint)<=0 )
992 fprintf(
ioQQQ,
" PrtFinal could not find O 3 5007 with cdLine.\n" );
997 if(
cdLine(
"blnd",4363,&o4363,&absint)<=0 )
1002 fprintf(
ioQQQ,
" PrtFinal could not find H 1 4363 with cdLine.\n" );
1010 if( (o4363 != 0.) && (o5007 != 0.) )
1014 bot = o5007 - o4363/o3enro;
1038 double a31 = 0.2262;
1048 ratio = ratio/1.3333/(o3cs13/o3cs12);
1050 ratio = ratio/o3enro/o3br32;
1063 if(
cdLine(
"Bac ",3646.,&bacobs,&absint)<=0 )
1065 fprintf(
ioQQQ,
" PrtFinal could not find Bac 3646 with cdLine.\n" );
1104 x = 1.e0/log10(bac);
1105 tel = -4.827969400906710 + x*(33.08493347410885 + x*(-56.08886262205931 +
1106 x*(52.44759454803217 + x*(-25.07958990094209 + x*(4.815046760060006)))));
1108 if( tel > 1. && tel < 5. )
1125 if(
cdLine(
"thin",3646.,&bacthn,&absint)<=0 )
1127 fprintf(
ioQQQ,
" PrtFinal could not find thin 3646 with cdLine.\n" );
1134 fprintf(
ioQQQ,
" PrtFinal could not find Ca B 4861.33 with cdLine.\n" );
1172 x = 1.e0/log10(bacthn);
1173 tel = -4.827969400906710 + x*(33.08493347410885 + x*(-56.08886262205931 +
1174 x*(52.44759454803217 + x*(-25.07958990094209 + x*(4.815046760060006)))));
1176 if( tel > 1. && tel < 5. )
1306 "\n IONIZE PARMET: U(1-)%8.4f U(4-):%8.4f U(sp):%6.2f "
1307 "Q(ion): %7.3f L(ion)%7.3f Q(low):%7.3f L(low)%7.3f\n",
1308 uhl, uhel, usp, qion, pion, qlow, plow );
1351 " ENERGY BUDGET: Heat:%8.3f Coolg:%8.3f Error:%5.1f%% Rec Lin:%8.3f F-F H%7.3f P(rad/tot)max ",
1462 chUnit =
"(gm/cm^2)";
1471 if(
cdTemp(
"opti",0,&THI,
"volume" ) )
1473 fprintf(
ioQQQ,
"\n>>>>>>>>>>>>>>>>> PrtFinal, impossible problem getting 21cm opt.\n");
1483 if(
cdTemp(
"21cm",0,&THI,
"radius" ) )
1485 fprintf(
ioQQQ,
"\n>>>>>>>>>>>>>>>>> PrtFinal, impossible problem getting 21cm temp.\n");
1493 if(
cdTemp(
"spin",0,&THI,
"radius" ) )
1495 fprintf(
ioQQQ,
"\n>>>>>>>>>>>>>>>>> PrtFinal, impossible problem getting 21cm spin.\n");
1578 rjeans =
exp10(rjeans);
1584 ajmass =
exp10(ajmass);
1601 ajmin =
exp10(ajmin);
1623 if( bottom > 1e-30 && top > 1e-30 )
1625 ratio = log10(top) - log10(bottom);
1626 if( ratio < 36. && ratio > -36. )
1628 ratio =
exp10(ratio);
1645 alfox = log(ratio)/log(freq_ratio);
1706 " Hatom level%3ld HatomType:%4.4s HInducImp %2c"
1707 " He tot level:%3ld He2 level: %3ld ExecTime%8.1f\n",
1720 " ConvrgError(%%) <eden>%7.3f MaxEden%7.3f <H-C>%7.2f Max(H-C)%8.2f <Press>%8.3f MaxPrs er%7.3f\n",
1729 " Continuity(%%) chng Te%6.1f elec den%6.1f n(H2)%7.1f n(CO) %7.1f\n",
1737 fprintf(
ioQQQ,
" Te Te(Ne) Te(NeNp) Te(NeHe+)Te(NeHe2+) Te(NeO+) Te(NeO2+)"
1738 " Te(H2) N(H) Ne(O2+) Ne(Np)\n" );
1739 static const char* weight[3] = {
"Radius",
"Area",
"Volume" };
1741 for(
int dim=0; dim < dmax; ++dim )
1802 fprintf(
ioQQQ,
" Be careful: grains exist. This spectrum was not corrected for reddening before analysis.\n" );
1812 double total_dust2gas = 0.;
1814 fprintf(
ioQQQ,
"\n Average Grain Properties (over radius):\n" );
1816 for(
size_t i0=0; i0 <
gv.
bin.size(); i0 += 10 )
1822 size_t i1 =
min(i0+10,
gv.
bin.size());
1825 for(
size_t nd=i0; nd < i1; nd++ )
1827 chQHeat = (char)(
gv.
bin[nd]->lgEverQHeat ?
'*' :
' ');
1833 for(
size_t nd=i0; nd < i1; nd++ )
1841 for(
size_t nd=i0; nd < i1; nd++ )
1849 for(
size_t nd=i0; nd < i1; nd++ )
1857 for(
size_t nd=i0; nd < i1; nd++ )
1865 for(
size_t nd=i0; nd < i1; nd++ )
1949 fprintf(
ioQQQ,
" Too many comments have been entered into line array; increase the value of NHOLDCOMMENTS.\n" );
1963 for( i=0; i<6; ++i )
1994 for( i=0; i <
nzone; i++ )
2014 for( i=0; i <
nzone; i++ )
2043 for( i=0; i <
nzone; i++ )
2064 for( i=0; i <
nzone; i++ )
void PrintE93(FILE *, double)
realnum WavlenErrorGet(realnum wavelength, long sig_figs)
NORETURN void TotalInsanity(void)
double widflx(size_t i) const
realnum UV_Cont_rel2_Draine_DB96_face
bool lgPrintLineCumulative
STATIC void PrintCenterLine(FILE *io, const char chLine[], size_t ArrLen, size_t LineLen)
realnum fine_opac_velocity_width
STATIC void gett2(realnum *tsqr)
long int nTotalIoniz_start
TransitionList HFLines("HFLines",&AnonStates)
int cdTemp(const char *chLabel, long int IonStage, double *TeMean, const char *chWeight)
sys_float sexp(sys_float x)
char chVersion[INPUT_LINE_LENGTH]
bool lgHCaseBOK[2][HS_NZ]
realnum AverHeatCoolError
void PrtMeanIon(char chType, bool lgDensity, FILE *)
void cap4(char *chCAP, const char *chLab)
double anu(size_t i) const
static t_version & Inst()
t_iso_sp iso_sp[NISO][LIMELM]
bool lgPrintBlockIntrinsic
bool fp_equal(sys_float x, sys_float y, int n=3)
bool lgdBaseSourceExists[LIMELM][LIMELM+1]
void PrintE71(FILE *, double)
long ipoint(double energy_ryd)
multi_arr< double, 2 > TempEdenMean
bool lgPrintBlockEmergent
STATIC void gett2o3(realnum *tsqr)
const int INPUT_LINE_LENGTH
multi_arr< double, 4 > TempIonEdenMean
bool lgSurfaceBrightness_SR
diatomics h2("h2", 4100.,&hmi.H2_total, Yan_H2_CS)
realnum wlAirVac(double wlAir)
sys_float safe_div(sys_float x, sys_float y, sys_float res_0by0)
STATIC void PrintSpectrum()
void PrtColumns(FILE *ioMEAN)
realnum UV_Cont_rel2_Habing_TH85_face
realnum gas_phase[LIMELM]
double totlin(int chInfo)
void sprt_wl(char *chString, realnum wl)
long int cdLine(const char *chLabel, realnum wavelength, double *relint, double *absint)
double extin_mag_V_extended
multi_arr< double, 4 > TempIonMean
#define DEBUG_ENTRY(funcname)
void PrintRatio(double q1, double q2)
static vector< realnum > wavelength
multi_arr< double, 2 > TempMean
void DatabasePrintReference()
static const int NHOLDCOMMENTS
int fprintf(const Output &stream, const char *format,...)
multi_arr< double, 4 > xIonMean
sys_float SDIV(sys_float x)
char chHoldComments[NHOLDCOMMENTS][INPUT_LINE_LENGTH]
void PrintE82(FILE *, double)
bool lgSortLineWavelength
void spsort(realnum x[], long int n, long int iperm[], int kflag, int *ier)
long int StuffComment(const char *chComment)