40static const double aweigh[4]={-0.4305682,-0.1699905, 0.1699905, 0.4305682};
41static 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 )
895 else if( RatioIoniz>1e3 )
911 double alpha = HCaseBRecCoeff + CollIoniz ;
912 double beta = HCaseBRecCoeff*EdenExtraLocal + OtherIonization +
916 double discriminant =
POW2(beta) - 4.*alpha*gamma;
917 if( discriminant <0 )
920 fprintf(
ioQQQ,
" DISASTER PROBLEM cont_initensity found negative discriminant.\n");
928 fprintf(
ioQQQ,
" DISASTER PROBLEM cont_initensity found n(H+)>n(H).\n");
936 fprintf(
ioQQQ,
" DISASTER PROBLEM cont_initensity found n(H0)<0.\n");
975 double RecTot = HCaseBRecCoeff*
dense.
eden;
976 RatioIonizToRecomb = xIoniz/RecTot;
985 r3ov2 = xIoniz/RecTot;
988 if( RatioIonizToRecomb > 0. )
1026 while( loopCount < 10 && fabs(newEden/
dense.
eden - 1.) > 0.001 );
1032 fprintf(
ioQQQ,
"PROBLEM the derived atomic hydrogen density is zero.\n");
1035 fprintf(
ioQQQ,
"This is almost certainly due to floating point "
1036 "limits on this computer.\nThe ionization parameter is very large,"
1037 " the density is very small,\nand the H^0 density cannot be"
1038 " stored in a double.\n");
1050 fprintf(
ioQQQ,
"\n PROBLEM DISASTER - this simulation has no source"
1051 " of ionization. The electron density is zero. Consider "
1052 "adding a source of ionization such as cosmic rays.\n\n");
1115 for(
long nelem=ipISO; nelem<
LIMELM; ++nelem)
1163 fprintf(
ioQQQ,
" PROBLEM DISASTER Negative electron density results in ContSetIntensity.\n" );
1164 fprintf(
ioQQQ,
"%10.2e%10.2e%10.2e%10.2e%10.2e%10.2e\n",
1180 " ContSetIntensity sets initial EDEN to %.4e, contributors H+=%.2e He+, ++= %.2e %.2e Heav %.2e extra %.2e\n",
1198 fprintf(
ioQQQ,
"\ntrace continuum print of %li incident spectral "
1200 fprintf(
ioQQQ,
" # type Illum Beam? 1/cos TimeVary?\n");
1203 fprintf(
ioQQQ,
"%3li %6s %5i %c %.3f %c\n",
1211 fprintf(
ioQQQ,
"\n");
1214 fprintf(
ioQQQ,
" H2,1=%5ld%5ld NX=%5ld IRC=%5ld\n",
1219 fprintf(
ioQQQ,
" CARBON" );
1220 for( i=0; i < 6; i++ )
1222 fprintf(
ioQQQ,
"\n" );
1224 fprintf(
ioQQQ,
" OXY" );
1225 for( i=0; i < 8; i++ )
1234 fprintf(
ioQQQ,
"\n Sum DB96 photons %.2e", sum);
1238 fprintf(
ioQQQ,
", sum H-ioniz photons %.2e\n", sum);
1241 fprintf(
ioQQQ,
"\n\n PHOTONS PER CELL (NOT RYD)\n" );
1242 fprintf(
ioQQQ,
" nu, flux, wid, occ \n" );
1245 fprintf(
ioQQQ,
"%4ld%10.2e%10.2e%10.2e%10.2e\n", i,
1249 fprintf(
ioQQQ,
" \n" );
1259 fprintf(
ioQQQ,
" ContSetIntensity returns, nflux=%5ld anu(nflux)=%11.4e eden=%10.2e\n",
1286 for( i=il-1; i < iupper; i++ )
1305 FILE * ioERRORS=NULL;
1317 fprintf(
ioQQQ,
" There are two ways to do this:\n");
1318 fprintf(
ioQQQ,
" do you want me to test all the pointers (enter y)\n");
1319 fprintf(
ioQQQ,
" or do you want to enter energies yourself? (enter n)\n" );
1323 fprintf(
ioQQQ,
" error getting input \n" );
1333 fprintf(
ioQQQ,
" Enter energy (Ryd); 0 to stop; negative is log.\n" );
1339 fprintf(
ioQQQ,
" error getting input2 \n" );
1344 pnt =
FFmtRead(chCard,&i,
sizeof(chCard),&lgEOL);
1347 if( lgEOL || pnt==0. )
1360 fprintf(
ioQQQ,
" Cell num%4ld center:%10.2e width:%10.2e low:%10.2e hi:%10.2e convoc:%10.2e\n",
1368 else if( chKey ==
'y' )
1373 fprintf(
ioQQQ,
" ipoint would crash since lowest desired energy of %e ryd is below limit of %e\n",
1382 fprintf(
ioQQQ,
" ipoint would crash since highest desired energy of %e ryd is above limit of %e\n",
1386 fprintf(
ioQQQ,
" this, previous cells are %e %e\n",
1392 fprintf(
ioQQQ,
" errors output on errors.txt\n");
1393 fprintf(
ioQQQ,
" IP(cor),IP(fount),nu lower, upper of found, desired cell.\n" );
1406 if( ioERRORS == NULL )
1409 fprintf(
ioQQQ,
" created errors.txt file with error summary\n");
1412 fprintf(
ioQQQ,
" Pointers do not agree for lower bound of cell%4ld, %e\n",
1414 fprintf( ioERRORS,
" Pointers do not agree for lower bound of cell%4ld, %e\n",
1422 if( ioERRORS == NULL )
1425 fprintf(
ioQQQ,
" created errors.txt file with error summary\n");
1427 fprintf(
ioQQQ,
" Pointers do not agree for upper bound of cell%4ld, %e\n",
1429 fprintf( ioERRORS,
" Pointers do not agree for upper bound of cell%4ld, %e\n",
1438 fprintf(
ioQQQ,
"I do not understand this key, sorry. %c\n", chKey );
1442 if( ioERRORS!=NULL )
1474 for(
long i=0; i<low-1; ++i )
1498 double xLog_radius_inner,
1515 fprintf(
ioQQQ,
" UNKN spectral normalization cannot happen.\n" );
1516 fprintf(
ioQQQ,
" conorm punts.\n" );
1523 fprintf(
ioQQQ,
" chRSpec must be SQCM or 4 PI, and it was %4.4s. This cannot happen.\n",
1525 fprintf(
ioQQQ,
" conorm punts.\n" );
1536 fprintf(
ioQQQ,
"\n\n PROBLEM DISASTER At least one of the compiled stellar atmosphere"
1537 " grids has been compiled with a different energy grid resolution factor.\n" );
1538 fprintf(
ioQQQ,
" Please recompile this file using the COMPILE STARS command "
1539 "and make sure that you use the correct SET CONTINUUM RESOLUTION factor.\n" );
1547 fprintf(
ioQQQ,
"\n\n PROBLEM DISASTER The file read by the TABLE READ command "
1548 "has been compiled with a different energy grid resolution factor.\n" );
1549 fprintf(
ioQQQ,
" Please recompile this file using the SAVE TRANSMITTED CONTINUUM "
1550 "command and use the correct SET CONTINUUM RESOLUTION factor.\n" );
1558 for(
size_t nd=0; nd <
gv.
bin.size(); nd++ )
1562 fprintf(
ioQQQ,
"\n\n PROBLEM DISASTER At least one of the grain opacity files "
1563 "has been compiled with a different energy grid resolution factor.\n" );
1564 fprintf(
ioQQQ,
" Please recompile this file using the COMPILE GRAINS command "
1565 "and make sure that you use the correct SET CONTINUUM RESOLUTION factor.\n" );
1589 " conorm converts continuum %ld from luminosity to intensity.\n",
1598 fprintf(
ioQQQ,
"PROBLEM DISASTER conorm: - A continuum source was specified as a luminosity, but the inner radius of the cloud was not set.\n");
1599 fprintf(
ioQQQ,
"Please set an inner radius.\nSorry.\n");
1616 " conorm converts continuum %ld from ionizat par to q(h).\n",
1632 fprintf(
ioQQQ,
" conorm converts continuum%3ld from x-ray ionizat par to I.\n",
1643 fprintf(
ioQQQ,
" Cloudy will predict lumin into 4pi\n" );
1647 fprintf(
ioQQQ,
" Cloudy will do surface flux for lumin\n" );
1671 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",
1675 fprintf(
ioQQQ,
"Please specify the continuum flux where the laser is active.\n");
1683 fprintf(
ioQQQ,
" conorm continuum number %ld is shape %s range is %.2e %.2e\n",
1688 fprintf(
ioQQQ,
"the continuum points follow\n");
1694 fprintf(
ioQQQ,
"%li %e %e\n",
1710 fprintf(
ioQQQ,
" conorm this is ratio to 1st con\n" );
1716 fprintf(
ioQQQ,
" I cant form a ratio if continuum is first source.\n" );
1728 fprintf(
ioQQQ,
" Previous continua were zero where ratio is desired.\n" );
1745 fprintf(
ioQQQ,
" conorm ratio will set scale fac to%10.3e at%10.2e Ryd.\n",
1760 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",
1764 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");
1765 fprintf(
ioQQQ,
" Also check that the numbers used to specify the shape and intensity do not under or overflow on this cpu.\n\n");
1777 fprintf(
ioQQQ,
" conorm will set log fnu to%10.3e at%10.2e Ryd. Factor=%11.4e\n",
1788 fprintf(
ioQQQ,
" conorm calling qintr range=%11.3e %11.3e desired val is %11.3e\n",
1805 if( diff < -35. || diff > 35. )
1807 fprintf(
ioQQQ,
" PROBLEM DISASTER Continuum source specified is too extreme.\n" );
1809 " The integral over the continuum shape gave (log) %.3e photons, and the command requested (log) %.3e.\n" ,
1812 " The difference in the log is %.3e.\n" ,
1816 fprintf(
ioQQQ,
" The continuum source is too bright.\n" );
1820 fprintf(
ioQQQ,
" The continuum source is too faint.\n" );
1823 fprintf(
ioQQQ,
" The usual cause for this problem is an incorrect continuum intensity/luminosity or radius command.\n" );
1824 fprintf(
ioQQQ,
" There were a total of %li continuum shape commands entered - the problem is with number %li.\n",
1836 fprintf(
ioQQQ,
" conorm finds Q over range from%11.4e-%11.4e Ryd, integral= %10.4e Factor=%11.4e\n",
1855 fprintf(
ioQQQ,
" conorm finds luminosity range is %10.3e to %9.3e Ryd, factor is %11.4e\n",
1863 fprintf(
ioQQQ,
"PROBLEM DISASTER What chSpNorm label is this? =%s=\n",
rfield.
chSpNorm[i]);
1870 fprintf(
ioQQQ,
"PROBLEM DISASTER conorm finds infinite continuum scale factor.\n" );
1871 fprintf(
ioQQQ,
"The continuum is too intense to compute with this cpu.\n" );
1872 fprintf(
ioQQQ,
"Were the intensity and luminosity commands switched?\n" );
1873 fprintf(
ioQQQ,
"Sorry, but I cannot go on.\n" );
1894 fprintf(
ioQQQ,
"PROBLEM DISASTER conorm: Aperture slit specified, but not predicting luminosity.\n" );
1895 fprintf(
ioQQQ,
"conorm: Please specify an inner radius to determine L.\nSorry\n" );
1926 fprintf(
ioQQQ,
" PROBLEM DISASTER Sorry, but both luminosity and surface brightness have been requested for lines.\n" );
1927 fprintf(
ioQQQ,
" the PRINT LINE SURFACE BRIGHTNESS command can only be used when lines are predicted per unit cloud area.\n" );
1966 for( i=ipLo-1; i < (ipHi - 1); i++ )
1969 for( j=0; j < 4; j++ )
1982 fprintf(
ioQQQ,
" PROBLEM DISASTER Photon number sum in QINTR is %.3e\n",
1984 fprintf(
ioQQQ,
" This source has no ionizing radiation, and the number of ionizing photons was specified.\n" );
1985 fprintf(
ioQQQ,
" This was continuum source number%3ld\n",
1987 fprintf(
ioQQQ,
" Sorry, but I cannot go on. ANU and FLUX arrays follow. Enjoy.\n" );
1988 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" );
1991 fprintf(
ioQQQ,
"%.2e\t%.2e\n",
1999 qintr_v = log10(sum);
2032 for( i=ip1-1; i < ip2-1; i++ )
2035 for( j=0; j < 4; j++ )
2047 pintr_v = log10(sum);
sys_float sexp(sys_float x)
const int INPUT_LINE_LENGTH
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)
bool fp_equal(sys_float x, sys_float y, int n=3)
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
NORETURN void TotalInsanity(void)
#define DEBUG_ENTRY(funcname)
double coll_ion_wrapper(long int z, long int n, double t)
bool lgContinuumLoweringEnabled[NISO]
long ipoint(double energy_ryd)
static const double aweigh[4]
STATIC void sumcon(long int il, long int ih, realnum *q, realnum *p, realnum *panu)
static const double fweigh[4]
STATIC double qintr(double *qenlo, double *qenhi)
STATIC double pintr(double penlo, double penhi)
STATIC void extin(realnum *ex1ryd)
void IncidentContinuumHere()
void EdenChange(double EdenNew)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
UNUSED const realnum BIGFLOAT
t_iso_sp iso_sp[NISO][LIMELM]
void iso_continuum_lower(long ipISO, long nelem)
UNUSED const double AS1RAD
UNUSED const double FR1RYD
UNUSED const double HPLANCK
UNUSED const double SPEEDLIGHT
UNUSED const double ELECTRON_MASS
UNUSED const double SQAS_SKY
UNUSED const double EN1RYD
UNUSED const double HNU3C2
UNUSED const double ELEM_CHARGE_ESU
UNUSED const double TE1RYD
t_secondaries secondaries
long int ipHeavy[LIMELM][LIMELM]
double ResolutionScaleFactor
realnum SetIoniz[LIMELM][LIMELM+1]
long int IonLow[LIMELM+1]
long int IonHigh[LIMELM+1]
double xIonDense[LIMELM][LIMELM+1]
realnum gas_phase[LIMELM]
bool lgSurfaceBrightness_SR
realnum * OccNumbIncidCont
vector< Energy > tNu[LIMSPC]
realnum OpticalDepthScaleFactor[LIMSPC]
realnum ** flux_total_incident
realnum ExtinguishLowEnergyLimit
bool lgContMalloc[LIMSPC]
realnum ExtinguishConvertColDen2OptDepth
realnum ExtinguishEnergyPowerLow
realnum * flux_isotropic_save
realnum * flux_time_beam_save
realnum * flux_beam_const
realnum * ExtinguishFactor
vector< realnum > tslop[LIMSPC]
realnum ExtinguishColumnDensity
realnum ExtinguishLeakage
realnum * flux_beam_const_save
Illuminate::IlluminationType Illumination[LIMSPC]
bool lgTemperatureConstant
void TempChange(double TempNew, bool lgForceUpdate)