75 if( chAssertLimit1 ==
'=' )
77 else if( chAssertLimit1 ==
'<' )
79 else if( chAssertLimit1 ==
'>' )
115 fprintf(
ioQQQ,
" ParseMonitorResults called before InitAsserResults\n" );
169 vector<double> AssertVector;
181 fprintf(
ioQQQ,
"PROBLEM the file %s does not have enough values. sorry\n", chLabel );
215 fprintf(
ioQQQ,
" The default monitor error is being changed after"
216 " some asserts were entered. \n This will only affect asserts"
217 " that come after this command.\n");
240 " I could not identify an option on this ASSERT SET XXX command.\n");
241 fprintf(
ioQQQ,
" Sorry.\n" );
247 else if( p.
nMatch(
"IONI" ) )
266 if( (nelem = p.
GetElem()) < 0 )
269 " I could not identify an element name on this line.\n");
270 fprintf(
ioQQQ,
" Sorry.\n" );
283 p.
NoNumb(
"ionization stage");
289 " The ionization stage is inappropriate for this element.\n");
290 fprintf(
ioQQQ,
" Sorry.\n" );
304 p.
NoNumb(
"ionization fraction");
325 " The ionization fraction must be less than one.\n");
326 fprintf(
ioQQQ,
" Sorry.\n" );
334 " The ionization ionization fraction is too small, or zero. Check input\n");
335 fprintf(
ioQQQ,
" Sorry.\n" );
365 else if( p.
nMatch(
" CO " ) )
372 " I could not identify CO or H2 on this line.\n");
373 fprintf(
ioQQQ,
" Sorry.\n" );
384 p.
NoNumb(
"molecular fraction");
406 else if( p.
nMatch(
" LINE " ) )
430 if( chLabel[4] !=
'\0' )
433 " The label must be exactly 4 char long, between double quotes.\n");
434 fprintf(
ioQQQ,
" Sorry.\n" );
449 p.
NoNumb(
"intensity/luminosity");
458 " The asserted quantity is a log, but is too large or small, value is %e.\n",
460 fprintf(
ioQQQ,
" I would crash if I tried to use it.\n Sorry.\n" );
470 fprintf(
ioQQQ,
" Sorry.\n" );
484 else if( p.
nMatch(
"CASE" ) )
503 fprintf(
ioQQQ,
" The monitor Case B faint option must have a number,"
504 " the relative intensity of the fainest line to monitor.\n");
523 fprintf(
ioQQQ,
" The monitor Case B range option must have two numbers,"
524 " the lower and upper limit to the wavelengths in Angstroms.\n");
525 fprintf(
ioQQQ,
" There must be a total of three numbers on the line,"
526 " the relative error followed by the lower and upper limits to the "
527 "wavelength in Angstroms.\n");
548 if( (nelem = p.
GetElem()) < 0 )
551 fprintf(
ioQQQ,
"monitor H-like case B did not find an element on this line, sorry\n");
558 fprintf(
ioQQQ,
"monitor H-like cannot do elements heavier than O, sorry\n");
566 if( p.
nMatch(
"CASE A " ) )
571 else if( p.
nMatch(
"HE-L") )
583 " I could not identify an iso-sequence on this Case A/B command.\n");
584 fprintf(
ioQQQ,
" Sorry.\n" );
590 else if( p.
nMatch(
"DEPA") )
595 p.
NoNumb(
"average departure coefficient");
614 " I could not identify an element name on this line.\n");
615 fprintf(
ioQQQ,
" Sorry.\n" );
625 else if( p.
nMatch(
"HE-L" ) )
635 " I could not identify an element name on this line.\n");
636 fprintf(
ioQQQ,
" Sorry.\n" );
657 else if( p.
nMatch(
"HMIN" ) )
669 " There must be a second key: FEII, H-LIke, HMINus, or HE-Like followed by element.\n");
670 fprintf(
ioQQQ,
" Sorry.\n" );
688 else if( p.
nMatch(
" MAP" ) )
697 else if( p.
nMatch(
"COOL" ) )
704 " There must be a second key, HEATing or COOLing.\n");
705 fprintf(
ioQQQ,
" Sorry.\n" );
730 p.
NoNumb(
"heating/cooling");
750 else if( p.
nMatch(
"COLU" ) )
760 if ( p.
GetQuote(chLabel,
false) == 0 )
763 for (
long i=strlen(chLabel);i<
NCHAR-1;++i)
765 chLabel[
NCHAR-1] =
'\0';
812 else if( p.
nMatch(
" CO "))
816 else if( p.
nMatch(
"SIO "))
820 else if( p.
nMatch(
" OH "))
824 else if( p.
nMatch(
" CN ") )
828 else if( p.
nMatch(
" CH ") )
832 else if( p.
nMatch(
" CH+") )
839 " I could not identify H2, H3+, H2+, H2g, H2*, H2H+, CO, O2, SiO, OH, C2 or C3 or on this line.\n");
840 fprintf(
ioQQQ,
" Sorry.\n" );
848 fprintf(
ioQQQ,
" LEVEL option only implemented for H2.\n");
849 fprintf(
ioQQQ,
" Sorry.\n" );
875 p.
NoNumb(
"column density");
913 " I did not find a 2, as in H2, as the first number on this line.\n");
915 " The rate should be the second number.\n");
916 fprintf(
ioQQQ,
" Sorry.\n" );
923 p.
NoNumb(
"grain H2 formation");
958 p.
NoNumb(
"grain potential");
973 else if( p.
nMatch(
"TEMP") )
1006 else if( p.
nMatch(
"FACE") )
1014 else if( p.
nMatch(
" H2 ") )
1023 else if( (nelem = p.
GetElem()) >= 0 )
1032 " I could not identify an element name on this line.\n");
1033 fprintf(
ioQQQ,
" Sorry.\n" );
1059 p.
NoNumb(
"ionization stage");
1065 " The ionization stage is inappropriate for this element.\n");
1066 fprintf(
ioQQQ,
" Sorry.\n" );
1101 else if( p.
nMatch(
"HHEI") )
1113 p.
NoNumb(
"ionization correction factor");
1129 else if( p.
nMatch(
" H2 ") )
1142 " I could not identify a second keyword on this line.\n");
1143 fprintf(
ioQQQ,
" Sorry.\n" );
1149 if( p.
lgEOL() || n2 != 2 )
1151 p.
NoNumb(
"the 2 in H2 ?!");
1168 else if( p.
nMatch(
" MPI") )
1181 else if( p.
nMatch(
"NZON") )
1214 p.
NoNumb(
"pressure error");
1232 else if( p.
nMatch(
"PRADMAX") )
1265 else if( p.
nMatch(
"CSUP") )
1276 p.
NoNumb(
"secondary ionization rate");
1298 else if( p.
nMatch(
"HTOT") )
1310 p.
NoNumb(
"heating rate");
1332 else if( p.
nMatch(
"CTOT") )
1351 p.
NoNumb(
"cooling rate");
1374 else if( p.
nMatch(
"ITRZ") )
1385 p.
NoNumb(
"iterations per zone");
1397 else if( p.
nMatch(
"EDEN") )
1409 p.
NoNumb(
" electron density of the last zone");
1427 else if( p.
nMatch(
" TU ") )
1436 p.
NoNumb(
"energy density of last zone");
1470 p.
NoNumb(
"thickness or depth of model");
1488 else if( p.
nMatch(
"RADI") )
1499 p.
NoNumb(
"outer radius");
1517 else if( p.
nMatch(
"NITE") )
1530 p.
NoNumb(
"number of iterations");
1545 else if( p.
nMatch(
"VELO") )
1556 p.
NoNumb(
"terminal velocity");
1568 else if( p.
nMatch(
"NOTH") )
1580 " Unrecognized command. The line image was\n");
1583 " The options I know about are: ionization, line, departure coefficient, map, column, "
1584 "temperature, nzone, csupre, htot, itrz, eden, thickness, niter, \n");
1585 fprintf(
ioQQQ,
" Sorry.\n" );
1594 " ParseMonitorResults: too many asserts, limit is NASSERT=%d\n",
1612 double relint , absint;
1622 long lgDisambiguate =
false;
1623 char chCaps[5], chFind[5];
1664 ipDisambiguate[i][j] = -1;
1675 if( ipDisambiguate[i][0] <= 0 )
1678 " monitor error: lgCheckMonitors could not find a line with label %s ",
1681 fprintf( ioMONITOR,
"\n" );
1684 " monitor error: The \"save line labels\" command is a good way to get a list of line labels.\n\n");
1687 RelError[i] = 100000.;
1710 if( j==ipDisambiguate[i][0] )
1725 if( strcmp(chCaps,chFind) == 0 )
1727 double relint1, absint1, current_error;
1733 current_error < 2.*fabs(RelError[i]) )
1735 lgDisambiguate =
true;
1738 if( ipDisambiguate[i][1] > 0 )
1740 ipDisambiguate[i][2] = j;
1745 ipDisambiguate[i][1] = j;
1753 PredQuan[i] = relint;
1764 " monitor error: lgCheckMonitors could not find a line with label %s ",
1767 fprintf( ioMONITOR,
"\n" );
1770 " monitor error: The \"save line labels\" command is a good way to get a list of line labels.\n\n");
1773 RelError[i] = 10000000.;
1781 PredQuan[i] = pow(10.,absint);
1787 double hfrac , hefrac;
1802 " monitor error: lgCheckMonitors could not find h ionization fraction \n");
1822 " monitor error: lgCheckMonitors could not find h ionization fraction \n");
1830 PredQuan[i] = hefrac-hfrac;
1837 PredQuan[i] =
cpu.
i().
lgMPI() ? 1. : 0.;
1845 PredQuan[i] = (double)
nzone;
1881 double sumx=0., sumx2=0., average;
1884 for( n=0; n<
nzone; n++ )
1892 average = sumx/
nzone;
1896 PredQuan[i] = sumx / average;
1904 RelError[i] = PredQuan[i];
2009 long int nISOCaseB = (long)
Param[i][0];
2010 long int nelemCaseB = (long)
Param[i][1];
2011 char chElemLabelCaseB[5];
2015 sprintf( chNumb ,
"%2li" , nelemCaseB+1-nISOCaseB );
2016 strcat( chElemLabelCaseB , chNumb );
2031 fprintf(ioMONITOR,
" Species nHi nLo Wl Computed Asserted error\n");
2036 for(
long int ipLo=1+iCase; ipLo<
MIN2(10,nHighestPrinted-1); ++ipLo )
2038 for(
long int ipHi=ipLo+1; ipHi<
MIN2(25,nHighestPrinted); ++ipHi )
2046 double relint , absint,CBrelint , CBabsint;
2049 if( CBrelint <
Param[i][4] )
2051 CBabsint = pow( 10., CBabsint );
2054 if(
cdLine( chElemLabelCaseB , wl , &relint , &absint ) >0)
2056 absint = pow( 10., absint );
2057 error = (CBabsint - absint)/
MAX2(CBabsint , absint);
2058 double RelativeError = fabs(error) /
AssertError[i];
2060 if( RelativeError < 1. )
2062 if( RelativeError < 0.25 )
2064 fprintf( ioMONITOR,
" ChkMonitor ");
2066 else if( RelativeError < 0.50 )
2068 fprintf( ioMONITOR,
" ChkMonitor - ");
2070 else if( RelativeError < 0.75 )
2072 fprintf( ioMONITOR,
" ChkMonitor -- ");
2074 else if( RelativeError < 0.90 )
2076 fprintf( ioMONITOR,
" ChkMonitor --- ");
2078 else if( RelativeError < 0.95 )
2080 fprintf( ioMONITOR,
" ChkMonitor ---- ");
2082 else if( RelativeError < 0.98 )
2084 fprintf( ioMONITOR,
" ChkMonitor ----- ");
2088 fprintf( ioMONITOR,
" ChkMonitor ------ ");
2094 fprintf( ioMONITOR,
" ChkMonitor botch>>");
2096 fprintf(ioMONITOR,
" %s %3li %3li ",
2097 chElemLabelCaseB , ipHi , ipLo );
2099 fprintf(ioMONITOR,
" %.2e %.2e %10.3f",
2100 absint , CBabsint , error );
2105 fprintf(ioMONITOR ,
" botch \n");
2107 fprintf(ioMONITOR ,
"\n");
2111 RelError[i] =
MAX2( RelError[i] , fabs(error) );
2119 fprintf(ioMONITOR,
"\n");
2125 fprintf(
ioQQQ,
"PROBLEM monitor case B for a He is requested but He is not "
2127 fprintf(
ioQQQ,
"Do not turn off He if you want to monitor its spectrum.\n");
2132 fprintf(ioMONITOR,
" Wl Computed Asserted error\n");
2140 double relint , absint,CBrelint , CBabsint;
2142 if( CBrelint <
Param[i][4] )
2144 CBabsint = pow( 10., CBabsint );
2146 if(
cdLine( chElemLabelCaseB , wl , &relint , &absint ) >0)
2148 absint = pow( 10., absint );
2149 error = (CBabsint - absint)/
MAX2(CBabsint , absint);
2150 double RelativeError = fabs(error) /
AssertError[i];
2152 if( RelativeError < 1. )
2154 if( RelativeError < 0.25 )
2156 fprintf( ioMONITOR,
" ChkMonitor ");
2158 else if( RelativeError < 0.50 )
2160 fprintf( ioMONITOR,
" ChkMonitor - ");
2162 else if( RelativeError < 0.75 )
2164 fprintf( ioMONITOR,
" ChkMonitor -- ");
2166 else if( RelativeError < 0.90 )
2168 fprintf( ioMONITOR,
" ChkMonitor --- ");
2170 else if( RelativeError < 0.95 )
2172 fprintf( ioMONITOR,
" ChkMonitor ---- ");
2174 else if( RelativeError < 0.98 )
2176 fprintf( ioMONITOR,
" ChkMonitor ----- ");
2180 fprintf( ioMONITOR,
" ChkMonitor ------ ");
2186 fprintf( ioMONITOR,
" ChkMonitor botch>>");
2189 fprintf(ioMONITOR,
" %.2e %.2e %10.3f",
2190 absint , CBabsint , error );
2195 fprintf(ioMONITOR ,
" botch \n");
2197 fprintf(ioMONITOR ,
"\n");
2201 RelError[i] =
MAX2( RelError[i] , fabs(error) );
2207 fprintf(ioMONITOR,
"\n");
2218 long ipISO = (long)
Param[i][0];
2222 fprintf(
ioQQQ,
"PROBLEM asserted element %ld is not turned on!\n",nelem);
2235 PredQuan[i] +=
iso_sp[ipISO][nelem].
fb[n].DepartCoef;
2237 relerror =
iso_sp[ipISO][nelem].
fb[n].DepartCoef -1.;
2238 relerror =
MAX2( relerror , 1. -
iso_sp[ipISO][nelem].fb[n].DepartCoef );
2241 PredQuan[i] /= (double)(numPrintLevels);
2255 double BigError , StdDev;
2261 RelError[i] = StdDev;
2278 strcpy( chWeight ,
"VOLUME" );
2283 strcpy( chWeight ,
"RADIUS" );
2299 " monitor error: lgCheckMonitors could not find a line with label %s %f \n",
2309 PredQuan[i] = relint;
2323 fprintf(
ioQQQ,
" PROBLEM lgCheckMonitors did not find v=%li, J=%li for H2 column density.\n",
2345 " monitor error: lgCheckMonitors could not find a molecule with label %s %f \n",
2356 PredQuan[i] = relint;
2378 " monitor error: lgCheckMonitors could not find a molecule with label %s %f \n",
2387 PredQuan[i] = relint;
2400 " monitor error: lgCheckMonitors cannot check map since map not done.\n");
2411 " monitor error: lgCheckMonitors cannot check map since temperature not within range.\n");
2450 strcpy( chWeight ,
"VOLUME" );
2455 strcpy( chWeight ,
"RADIUS" );
2465 if( nd >=
gv.
bin.size() )
2468 fprintf(
ioQQQ,
"Use 1 for first grain that is turned on, " );
2469 fprintf(
ioQQQ,
"2 for second, etc....\n" );
2470 fprintf(
ioQQQ,
"Old style grain numbers are not valid anymore !!\n" );
2494 " monitor error: lgCheckMonitors could not find an ion with label %s ion %li \n",
2505 PredQuan[i] = relint;
2515 if( nd >=
gv.
bin.size() )
2518 fprintf(
ioQQQ,
"Use 1 for first grain that is turned on, " );
2519 fprintf(
ioQQQ,
"2 for second, etc....\n" );
2520 fprintf(
ioQQQ,
"Old style grain numbers are not valid anymore !!\n" );
2533 " monitor error: lgCheckMonitors received an insane chAssertType=%s, impossible\n",
2555 if( RelError[i] <= 0. )
2565 if( RelError[i] >= 0. )
2579 if( lgDisambiguate )
2583 double relint1, relint2, absint1;
2587 fprintf( ioMONITOR,
"=============Line Disambiguation=======================================================\n" );
2588 fprintf( ioMONITOR,
" Wavelengths || Intensities \n" );
2589 fprintf( ioMONITOR,
"Label line match1 match2 match3 || asserted match1 match2 match3\n" );
2593 if( ipDisambiguate[i][1] > 0 )
2597 fprintf( ioMONITOR ,
" " );
2599 fprintf( ioMONITOR ,
" " );
2601 fprintf( ioMONITOR ,
" " );
2602 if( ipDisambiguate[i][2] > 0 )
2605 cdLine_ip( ipDisambiguate[i][2], &relint2, &absint1 );
2609 fprintf( ioMONITOR ,
"--------" );
2612 fprintf( ioMONITOR ,
" ||" );
2614 cdLine_ip( ipDisambiguate[i][1], &relint1, &absint1 );
2618 fprintf( ioMONITOR ,
" %10.3e %10.3e %10.3e %10.3e\n",
2626 fprintf( ioMONITOR ,
" %10.4f %10.4f %10.4f %10.4f\n",
2634 fprintf( ioMONITOR,
"\n" );
2641 fprintf( ioMONITOR,
"=============Results of monitors: Cloudy %s ",
t_version::Inst().chVersion );
2650 fprintf(ioMONITOR,
"%s", ctime(&now) );
2654 fprintf(ioMONITOR,
"\n" );
2659 fprintf( ioMONITOR,
" No errors were found. Summary follows.\n");
2663 fprintf( ioMONITOR,
" Errors were found. Summary follows.\n");
2667 " Label line computed asserted Rel Err Set err\n");
2671 double prtPredQuan, prtAssertQuantity;
2681 prtPredQuan = PredQuan[i];
2693 fprintf( ioMONITOR,
" ChkMonitor ");
2695 else if( relative < 0.50 )
2697 fprintf( ioMONITOR,
" ChkMonitor - ");
2699 else if( relative < 0.75 )
2701 fprintf( ioMONITOR,
" ChkMonitor -- ");
2703 else if( relative < 0.90 )
2705 fprintf( ioMONITOR,
" ChkMonitor --- ");
2707 else if( relative < 0.95 )
2709 fprintf( ioMONITOR,
" ChkMonitor ---- ");
2711 else if( relative < 0.98 )
2713 fprintf( ioMONITOR,
" ChkMonitor ----- ");
2717 fprintf( ioMONITOR,
" ChkMonitor ------ ");
2723 fprintf( ioMONITOR,
" ChkMonitor botch>>");
2728 fprintf( ioMONITOR ,
"%4s ",
2735 fprintf( ioMONITOR ,
" %10.3e %c %10.3e %7.3f %7.3f ",
2744 fprintf( ioMONITOR ,
" %10.4f %c %10.4f %7.3f %7.3f ",
2753 enum {DEBUG_LOC=
false};
2769 fprintf(
ioQQQ,
"\t%li %li %li %li %li %li",
2786 fprintf( ioMONITOR ,
"%4s %6i %10.4f %c %10.4f %7.3f %7.3f ",
2801 if( !lg1OK[i] && (fabs(RelError[i]) > 3.*
AssertError[i]) && lgFound[i] )
2803 fprintf( ioMONITOR ,
" <<BIG BOTCH!!\n");
2808 fprintf( ioMONITOR ,
"\n");
2811 fprintf( ioMONITOR ,
" \n");
2818 fprintf( ioMONITOR,
" BIG BOTCHED MONITORS!!! Big Botched Monitors!!! \n");
2822 fprintf( ioMONITOR,
" BOTCHED MONITORS!!! Botched Monitors!!! \n");
2827 fprintf(ioMONITOR,
"\n The mean of the %li monitor Case A, B relative "
2828 "residuals is %.2f\n\n" ,
void AssertFeIIDep(double *pred, double *BigError, double *StdDev)
const int INPUT_LINE_LENGTH
void cap4(char *chCAP, const char *chLab)
bool fp_equal(sys_float x, sys_float y, int n=3)
NORETURN void TotalInsanity(void)
sys_float SDIV(sys_float x)
#define DEBUG_ENTRY(funcname)
int cdColm(const char *chLabel, long int ion, double *theocl)
void cdLine_ip(long int ipLine, double *relint, double *absint)
int cdIonFrac(const char *chLabel, long int IonStage, double *fracin, const char *chWeight, bool lgDensity)
long int cdLine(const char *chLabel, realnum wavelength, double *relint, double *absint)
int cdTemp(const char *chLabel, long int IonStage, double *TeMean, const char *chWeight)
double cdH2_colden(long iVib, long iRot)
double rate_h2_form_grains_used_total
long int GetElem(void) const
bool nMatch(const char *chKey) const
bool nMatchErase(const char *chKey)
bool GetParam(const char *chKey, double *val)
bool GetRange(const char *chKey, double *val1, double *val2)
NORETURN void NoNumb(const char *chDesc) const
int GetQuote(char *chLabel, bool lgABORT)
int PrintLine(FILE *fp) const
static t_version & Inst()
long int n_HighestResolved_max
long int nCollapsed_local
t_elementnames elementnames
diatomics h2("h2", 4100., &hmi.H2_total, Yan_H2_CS)
t_iso_sp iso_sp[NISO][LIMELM]
realnum WavlenErrorGet(realnum wavelength)
static bool lgSpaceAllocated
static int * lgQuantityLog
static const int NASSERTS
double ForcePass(char chAssertLimit1)
static realnum ErrorDefault
static char ** chAssertLineLabel
static char ** chAssertType
t_monitorresults MonitorResults
static realnum * wavelength
static double * AssertQuantity2
static double * AssertQuantity
static realnum ErrorDefaultPerformance
static double * AssertError
void InitMonitorResults(void)
static char * chAssertLimit
bool lgCheckMonitors(FILE *ioMONITOR)
void ParseMonitorResults(Parser &p)
UNUSED const double SPEEDLIGHT
void prt_wl(FILE *ioOUT, realnum wl)
t_secondaries secondaries
vector< realnum > CaseBWlHeI
realnum WaveLengthCaseB[8][25][24]
long int nTotalIoniz_start
double xIonDense[LIMELM][LIMELM+1]
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
char chElementNameShort[LIMELM][CHARS_ELEMENT_NAME_SHORT]
long int nSumErrorCaseMonitor
double SumErrorCaseMonitor