40 static const double aweigh[4]={-0.4305682,-0.1699905, 0.1699905, 0.4305682};
41 static const double fweigh[4]={ 0.1739274, 0.3260726, 0.3260726, 0.1739274};
72 double frac_beam_time;
74 double frac_beam_const;
76 double frac_isotropic;
90 ratio = fabs( log10( flux_now / flux_org ) );
91 BigLog =
max( ratio , BigLog );
96 fprintf(
ioQQQ ,
"DEBUG diff continua %.2e\n", BigLog );
129 double HCaseBRecCoeff,
148 double frac_beam_time , frac_beam_time1;
150 double frac_beam_const , frac_beam_const1;
152 double frac_isotropic , frac_isotropic1;
154 long int nelem , ion;
161 fprintf(
ioQQQ,
" ContSetIntensity called.\n" );
185 frac_beam_const = 0.;
188 for( j=0; j < 4; j++ )
213 amean += wanu[j]*wfun[j];
214 amean2 += wanu[j]*wanu[j]*wfun[j];
215 amean3 += wanu[j]*wanu[j]*wanu[j]*wfun[j];
216 frac_beam_time +=
fweigh[j]*frac_beam_time1;
217 frac_beam_const +=
fweigh[j]*frac_beam_const1;
218 frac_isotropic +=
fweigh[j]*frac_isotropic1;
221 ASSERT( fabs( 1.-frac_beam_time-frac_beam_const-frac_isotropic)<
226 fprintf(
ioQQQ,
"\n Cannot continue. The continuum is far too intense.\n" );
231 fprintf(
ioQQQ,
" Problem is with source number %li\n", j );
277 fprintf(
ioQQQ,
" negative continuum returned at%6ld%10.2e%10.2e\n",
320 fprintf(
ioQQQ,
"\n\n Compton heating, cooling coefficients \n" );
326 fprintf(
ioQQQ,
"\n" );
362 fprintf(
ioQQQ,
" ContSetIntensity: The peak of the H-ion continuum is at %.3e Ryd - its value is %.2e\n",
368 fprintf(
ioQQQ,
" PROBLEM DISASTER The continuum is too intense to compute. Use a fainter continuum. (This is the nu*f_nu test)\n" );
369 fprintf(
ioQQQ,
" Sorry.\n" );
379 enum {DEBUG_LOC=
false};
385 fprintf(
ioQQQ,
" consetintensityBUGGG\t%.2e\t%.2e\n" ,
434 fprintf(
ioQQQ,
" PROBLEM DISASTER This incident continuum appears to have no radiation.\n" );
435 fprintf(
ioQQQ,
" Sorry.\n" );
460 fprintf(
ioQQQ,
" NOTE Setcon: continuum has zero intensity starting at %11.4e Ryd.\n",
471 "%6ld cells in the incident continuum have zero intensity. Problems???\n\n",
482 " PROBLEM DISASTER Continuum has negative intensity at %.4e Ryd=%.2e %4.4s %4.4s\n",
489 " PROBLEM DISASTER cont_setintensity - internal error - continuum energies not in increasing order: energies follow\n" );
491 "%ld %e %ld %e %ld %e\n",
545 tcomp = tcompr/(4.*6.272e-6);
550 " mean photon energy=%10.3eR =%10.3eK low, high nu=%12.4e%12.4e\n",
575 fprintf(
ioQQQ,
" NOTE There is no hydrogen-ionizing radiation.\n" );
576 fprintf(
ioQQQ,
" Was this intended?\n\n" );
581 fprintf(
ioQQQ,
" NOTE There is no Balmer continuum radiation.<<<<\n" );
582 fprintf(
ioQQQ,
" Was this intended?\n\n" );
621 "\n WARNING: The energy density temperature (%g) is greater than the"
622 " black body temperature (%g). This is unphysical.\n\n",
641 ASSERT( plsFrqConstant > 2.7e-12 && plsFrqConstant < 2.8e-12 );
690 " !The plasma frequency is %.2e Ryd. The incident continuum is set to 0 below this.\n",
770 fprintf(
ioQQQ,
"\n >>>\n"
771 " >>> NOTE The incident continuum is surprisingly faint.\n" );
773 " >>> The total energy in the Balmer and Lyman continua is %.2e erg cm-2 s-1.\n"
775 fprintf(
ioQQQ,
" >>> This is many orders of magnitude fainter than the ISM galactic background.\n" );
776 fprintf(
ioQQQ,
" >>> This seems unphysical - please check that the continuum intensity has been properly set.\n" );
777 fprintf(
ioQQQ,
" >>> YOU MAY BE MAKING A BIG MISTAKE!!\n >>>\n\n\n\n" );
788 fprintf(
ioQQQ,
"\n\n"
789 " CAUTION The incident radiation field is surprisingly intense.\n" );
791 " The dimensionless hydrogen ionization parameter is %.2e.\n"
793 fprintf(
ioQQQ,
" This is many orders of magnitude brighter than commonly seen.\n" );
794 fprintf(
ioQQQ,
" This seems unphysical - please check that the radiation field intensity has been properly set.\n" );
795 fprintf(
ioQQQ,
" YOU MAY BE MAKING A BIG MISTAKE!!\n\n\n\n\n" );
808 TeNew = (20000.+log10(
rfield.
uh)*5000.);
809 TeNew =
MAX2(8000. , TeNew );
830 for( ion=0; ion<nelem+1; ++ion )
857 HCaseBRecCoeff = (-9.9765209 + 0.158607055*
phycon.
telogn[0] + 0.30112749*
862 HCaseBRecCoeff = pow(10.,HCaseBRecCoeff)/
phycon.
te;
867 double PhotonEnergy = 1.;
883 if( RatioIoniz<1e-3 )
896 else if( RatioIoniz>1e3 )
913 double alpha = HCaseBRecCoeff + CollIoniz ;
914 double beta = HCaseBRecCoeff*EdenExtraLocal + OtherIonization +
918 double discriminant =
POW2(beta) - 4.*alpha*gamma;
919 if( discriminant <0 )
922 fprintf(
ioQQQ,
" DISASTER PROBLEM cont_initensity found negative discriminant.\n");
930 fprintf(
ioQQQ,
" DISASTER PROBLEM cont_initensity found n(H+)>n(H).\n");
938 fprintf(
ioQQQ,
" DISASTER PROBLEM cont_initensity found n(H0)<0.\n");
977 double RecTot = HCaseBRecCoeff*
dense.
eden;
978 RatioIonizToRecomb = xIoniz/RecTot;
987 r3ov2 = xIoniz/RecTot;
990 if( RatioIonizToRecomb > 0. )
1028 while( loopCount < 10 && fabs(newEden/
dense.
eden - 1.) > 0.001 );
1034 fprintf(
ioQQQ,
"PROBLEM the derived atomic hydrogen density is zero.\n");
1037 fprintf(
ioQQQ,
"This is almost certainly due to floating point "
1038 "limits on this computer.\nThe ionization parameter is very large,"
1039 " the density is very small,\nand the H^0 density cannot be"
1040 " stored in a float.\n");
1052 fprintf(
ioQQQ,
"\n PROBLEM DISASTER - this simulation has no source"
1053 " of ionization. The electron density is zero. Consider "
1054 "adding a source of ionization such as cosmic rays.\n\n");
1117 for(
long nelem=ipISO; nelem<
LIMELM; ++nelem)
1165 fprintf(
ioQQQ,
" PROBLEM DISASTER Negative electron density results in ContSetIntensity.\n" );
1166 fprintf(
ioQQQ,
"%10.2e%10.2e%10.2e%10.2e%10.2e%10.2e\n",
1182 " ContSetIntensity sets initial EDEN to %.4e, contributors H+=%.2e He+, ++= %.2e %.2e Heav %.2e extra %.2e\n",
1200 fprintf(
ioQQQ,
"\ntrace continuum print of %li incident spectral "
1202 fprintf(
ioQQQ,
" # type Illum Beam? 1/cos TimeVary?\n");
1205 fprintf(
ioQQQ,
"%3li %6s %5i %c %.3f %c\n",
1213 fprintf(
ioQQQ,
"\n");
1216 fprintf(
ioQQQ,
" H2,1=%5ld%5ld NX=%5ld IRC=%5ld\n",
1221 fprintf(
ioQQQ,
" CARBON" );
1222 for( i=0; i < 6; i++ )
1224 fprintf(
ioQQQ,
"\n" );
1226 fprintf(
ioQQQ,
" OXY" );
1227 for( i=0; i < 8; i++ )
1236 fprintf(
ioQQQ,
"\n Sum DB96 photons %.2e", sum);
1240 fprintf(
ioQQQ,
", sum H-ioniz photons %.2e\n", sum);
1243 fprintf(
ioQQQ,
"\n\n PHOTONS PER CELL (NOT RYD)\n" );
1244 fprintf(
ioQQQ,
" nu, flux, wid, occ \n" );
1247 fprintf(
ioQQQ,
"%4ld%10.2e%10.2e%10.2e%10.2e\n", i,
1251 fprintf(
ioQQQ,
" \n" );
1261 fprintf(
ioQQQ,
" ContSetIntensity returns, nflux=%5ld anu(nflux)=%11.4e eden=%10.2e\n",
1288 for( i=il-1; i < iupper; i++ )
1307 FILE * ioERRORS=NULL;
1319 fprintf(
ioQQQ,
" There are two ways to do this:\n");
1320 fprintf(
ioQQQ,
" do you want me to test all the pointers (enter y)\n");
1321 fprintf(
ioQQQ,
" or do you want to enter energies yourself? (enter n)\n" );
1325 fprintf(
ioQQQ,
" error getting input \n" );
1335 fprintf(
ioQQQ,
" Enter energy (Ryd); 0 to stop; negative is log.\n" );
1341 fprintf(
ioQQQ,
" error getting input2 \n" );
1346 pnt =
FFmtRead(chCard,&i,
sizeof(chCard),&lgEOL);
1349 if( lgEOL || pnt==0. )
1362 fprintf(
ioQQQ,
" Cell num%4ld center:%10.2e width:%10.2e low:%10.2e hi:%10.2e convoc:%10.2e\n",
1370 else if( chKey ==
'y' )
1375 fprintf(
ioQQQ,
" ipoint would crash since lowest desired energy of %e ryd is below limit of %e\n",
1384 fprintf(
ioQQQ,
" ipoint would crash since highest desired energy of %e ryd is above limit of %e\n",
1388 fprintf(
ioQQQ,
" this, previous cells are %e %e\n",
1394 fprintf(
ioQQQ,
" errors output on errors.txt\n");
1395 fprintf(
ioQQQ,
" IP(cor),IP(fount),nu lower, upper of found, desired cell.\n" );
1408 if( ioERRORS == NULL )
1411 fprintf(
ioQQQ,
" created errors.txt file with error summary\n");
1414 fprintf(
ioQQQ,
" Pointers do not agree for lower bound of cell%4ld, %e\n",
1416 fprintf( ioERRORS,
" Pointers do not agree for lower bound of cell%4ld, %e\n",
1424 if( ioERRORS == NULL )
1427 fprintf(
ioQQQ,
" created errors.txt file with error summary\n");
1429 fprintf(
ioQQQ,
" Pointers do not agree for upper bound of cell%4ld, %e\n",
1431 fprintf( ioERRORS,
" Pointers do not agree for upper bound of cell%4ld, %e\n",
1440 fprintf(
ioQQQ,
"I do not understand this key, sorry. %c\n", chKey );
1444 if( ioERRORS!=NULL )
1476 for(
long i=0; i<low-1; ++i )
1500 double xLog_radius_inner,
1517 fprintf(
ioQQQ,
" UNKN spectral normalization cannot happen.\n" );
1518 fprintf(
ioQQQ,
" conorm punts.\n" );
1525 fprintf(
ioQQQ,
" chRSpec must be SQCM or 4 PI, and it was %4.4s. This cannot happen.\n",
1527 fprintf(
ioQQQ,
" conorm punts.\n" );
1538 fprintf(
ioQQQ,
"\n\n PROBLEM DISASTER At least one of the compiled stellar atmosphere"
1539 " grids has been compiled with a different energy grid resolution factor.\n" );
1540 fprintf(
ioQQQ,
" Please recompile this file using the COMPILE STARS command "
1541 "and make sure that you use the correct SET CONTINUUM RESOLUTION factor.\n" );
1549 fprintf(
ioQQQ,
"\n\n PROBLEM DISASTER The file read by the TABLE READ command "
1550 "has been compiled with a different energy grid resolution factor.\n" );
1551 fprintf(
ioQQQ,
" Please recompile this file using the SAVE TRANSMITTED CONTINUUM "
1552 "command and use the correct SET CONTINUUM RESOLUTION factor.\n" );
1560 for(
size_t nd=0; nd <
gv.
bin.size(); nd++ )
1564 fprintf(
ioQQQ,
"\n\n PROBLEM DISASTER At least one of the grain opacity files "
1565 "has been compiled with a different energy grid resolution factor.\n" );
1566 fprintf(
ioQQQ,
" Please recompile this file using the COMPILE GRAINS command "
1567 "and make sure that you use the correct SET CONTINUUM RESOLUTION factor.\n" );
1591 " conorm converts continuum %ld from luminosity to intensity.\n",
1600 fprintf(
ioQQQ,
"PROBLEM DISASTER conorm: - A continuum source was specified as a luminosity, but the inner radius of the cloud was not set.\n");
1601 fprintf(
ioQQQ,
"Please set an inner radius.\nSorry.\n");
1618 " conorm converts continuum %ld from ionizat par to q(h).\n",
1634 fprintf(
ioQQQ,
" conorm converts continuum%3ld from x-ray ionizat par to I.\n",
1645 fprintf(
ioQQQ,
" Cloudy will predict lumin into 4pi\n" );
1649 fprintf(
ioQQQ,
" Cloudy will do surface flux for lumin\n" );
1673 fprintf(
ioQQQ,
"PROBLEM DISASTER, a continuum source is a laser at %f Ryd, but the intensity was specified over a range from %f to %f Ryd.\n",
1677 fprintf(
ioQQQ,
"Please specify the continuum flux where the laser is active.\n");
1685 fprintf(
ioQQQ,
" conorm continuum number %ld is shape %s range is %.2e %.2e\n",
1690 fprintf(
ioQQQ,
"the continuum points follow\n");
1696 fprintf(
ioQQQ,
"%li %e %e\n",
1712 fprintf(
ioQQQ,
" conorm this is ratio to 1st con\n" );
1718 fprintf(
ioQQQ,
" I cant form a ratio if continuum is first source.\n" );
1730 fprintf(
ioQQQ,
" Previous continua were zero where ratio is desired.\n" );
1747 fprintf(
ioQQQ,
" conorm ratio will set scale fac to%10.3e at%10.2e Ryd.\n",
1762 fprintf(
ioQQQ,
"\n\n PROBLEM DISASTER\n The intensity of continuum source %ld is non-positive at the energy used to normalize it (%.3e Ryd). Something is seriously wrong.\n",
1766 fprintf(
ioQQQ,
" This continuum shape given by a table of points - check that the intensity is specified at an energy within the range of that table.\n");
1767 fprintf(
ioQQQ,
" Also check that the numbers used to specify the shape and intensity do not under or overflow on this cpu.\n\n");
1779 fprintf(
ioQQQ,
" conorm will set log fnu to%10.3e at%10.2e Ryd. Factor=%11.4e\n",
1790 fprintf(
ioQQQ,
" conorm calling qintr range=%11.3e %11.3e desired val is %11.3e\n",
1807 if( diff < -35. || diff > 35. )
1809 fprintf(
ioQQQ,
" PROBLEM DISASTER Continuum source specified is too extreme.\n" );
1811 " The integral over the continuum shape gave (log) %.3e photons, and the command requested (log) %.3e.\n" ,
1814 " The difference in the log is %.3e.\n" ,
1818 fprintf(
ioQQQ,
" The continuum source is too bright.\n" );
1822 fprintf(
ioQQQ,
" The continuum source is too faint.\n" );
1825 fprintf(
ioQQQ,
" The usual cause for this problem is an incorrect continuum intensity/luminosity or radius command.\n" );
1826 fprintf(
ioQQQ,
" There were a total of %li continuum shape commands entered - the problem is with number %li.\n",
1838 fprintf(
ioQQQ,
" conorm finds Q over range from%11.4e-%11.4e Ryd, integral= %10.4e Factor=%11.4e\n",
1857 fprintf(
ioQQQ,
" conorm finds luminosity range is %10.3e to %9.3e Ryd, factor is %11.4e\n",
1865 fprintf(
ioQQQ,
"PROBLEM DISASTER What chSpNorm label is this? =%s=\n",
rfield.
chSpNorm[i]);
1872 fprintf(
ioQQQ,
"PROBLEM DISASTER conorm finds infinite continuum scale factor.\n" );
1873 fprintf(
ioQQQ,
"The continuum is too intense to compute with this cpu.\n" );
1874 fprintf(
ioQQQ,
"Were the intensity and luminosity commands switched?\n" );
1875 fprintf(
ioQQQ,
"Sorry, but I cannot go on.\n" );
1896 fprintf(
ioQQQ,
"PROBLEM DISASTER conorm: Aperture slit specified, but not predicting luminosity.\n" );
1897 fprintf(
ioQQQ,
"conorm: Please specify an inner radius to determine L.\nSorry\n" );
1928 fprintf(
ioQQQ,
" PROBLEM DISASTER Sorry, but both luminosity and surface brightness have been requested for lines.\n" );
1929 fprintf(
ioQQQ,
" the PRINT LINE SURFACE BRIGHTNESS command can only be used when lines are predicted per unit cloud area.\n" );
1968 for( i=ipLo-1; i < (ipHi - 1); i++ )
1971 for( j=0; j < 4; j++ )
1984 fprintf(
ioQQQ,
" PROBLEM DISASTER Photon number sum in QINTR is %.3e\n",
1986 fprintf(
ioQQQ,
" This source has no ionizing radiation, and the number of ionizing photons was specified.\n" );
1987 fprintf(
ioQQQ,
" This was continuum source number%3ld\n",
1989 fprintf(
ioQQQ,
" Sorry, but I cannot go on. ANU and FLUX arrays follow. Enjoy.\n" );
1990 fprintf(
ioQQQ,
"\n\n This error is also caused by an old table read file whose energy mesh does not agree with the code.\n" );
1993 fprintf(
ioQQQ,
"%.2e\t%.2e\n",
2001 qintr_v = log10(sum);
2034 for( i=ip1-1; i < ip2-1; i++ )
2037 for( j=0; j < 4; j++ )
2049 pintr_v = log10(sum);
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
bool lgContinuumLoweringEnabled[NISO]
void iso_continuum_lower(long ipISO, long nelem)
NORETURN void TotalInsanity(void)
realnum * flux_beam_const_save
realnum ** flux_total_incident
double coll_ion_wrapper(long int z, long int n, double t)
vector< Energy > tNu[LIMSPC]
sys_float sexp(sys_float x)
vector< realnum > tslop[LIMSPC]
void TempChange(double TempNew, bool lgForceUpdate)
realnum ExtinguishEnergyPowerLow
double xIonDense[LIMELM][LIMELM+1]
STATIC double qintr(double *qenlo, double *qenhi)
t_iso_sp iso_sp[NISO][LIMELM]
realnum ExtinguishConvertColDen2OptDepth
bool lgTemperatureConstant
bool fp_equal(sys_float x, sys_float y, int n=3)
realnum SetIoniz[LIMELM][LIMELM+1]
realnum ExtinguishLeakage
long ipoint(double energy_ryd)
static const double aweigh[4]
STATIC void extin(realnum *ex1ryd)
long int IonHigh[LIMELM+1]
realnum * flux_time_beam_save
STATIC double pintr(double penlo, double penhi)
double ResolutionScaleFactor
Illuminate::IlluminationType Illumination[LIMSPC]
const int INPUT_LINE_LENGTH
bool lgSurfaceBrightness_SR
realnum * OccNumbIncidCont
realnum gas_phase[LIMELM]
long int IonLow[LIMELM+1]
void IncidentContinuumHere()
STATIC void sumcon(long int il, long int ih, realnum *q, realnum *p, realnum *panu)
realnum * flux_isotropic_save
#define DEBUG_ENTRY(funcname)
const double ELECTRON_MASS
const double ELEM_CHARGE_ESU
realnum ExtinguishColumnDensity
static const double fweigh[4]
realnum * ExtinguishFactor
realnum OpticalDepthScaleFactor[LIMSPC]
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
void EdenChange(double EdenNew)
t_secondaries secondaries
realnum * flux_beam_const
long int ipHeavy[LIMELM][LIMELM]
bool lgContMalloc[LIMSPC]
realnum ExtinguishLowEnergyLimit
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)