22         class my_Integrand: 
public std::unary_function<double, double>
 
   25                 double operator() (
double x)
 const 
   35         double mySin(
double x)
 
   56         if( strcmp(chJob,
"begin") == 0 )
 
   60         else if( strcmp(chJob,
"final") == 0 )
 
   66                 fprintf(
ioQQQ,
"SanityCheck called with insane argument.\n");
 
   96         double xMatrix[NDIM][NDIM] , yVector[NDIM] ,
 
  117         for( nelem=0; nelem<
LIMELM; ++nelem )
 
  127                                 fprintf(
ioQQQ,
" SanityCheck found insane H-like As.\n");
 
  164         for( nelem=1; nelem<
LIMELM; ++nelem )
 
  169                  0.       ,9.47e+006 ,3.44e+008 ,1.74e+009 ,5.51e+009 ,1.34e+010 ,
 
  170                 2.79e+010 ,5.32E+010 ,8.81e+010 ,1.46E+011 ,2.15e+011 ,3.15e+011 ,
 
  171                 4.46e+011 ,6.39E+011 ,8.26e+011 ,1.09e+012 ,1.41e+012 ,1.86E+012 ,
 
  172                 2.26e+012 ,2.80e+012 ,3.44e+012 ,4.18e+012 ,5.04e+012 ,6.02e+012 ,
 
  173                 7.14e+012 ,8.40e+012 ,9.83e+012 ,1.14e+013 ,1.32e+013 ,1.52e+013
 
  179                         if( fabs( as[nelem] - 
iso_sp[
ipHE_LIKE][nelem].trans(9,1).Emis().Aul() ) /as[nelem] > 0.025 )
 
  182                                         " SanityCheck found insane He-like As: expected, nelem=%li found: %.2e %.2e.\n",
 
  195                 for( i = 0; i <=110; i++ )
 
  197                         double DrakeTotalAuls[111] = {
 
  198                                 -1.0000E+00, -1.0000E+00, -1.0000E+00, 1.02160E+07,
 
  199                                 1.02160E+07, 1.02160E+07, 1.80090E+09, 2.78530E+07,
 
  200                                 1.82990E+07, 1.05480E+07, 7.07210E+07, 6.37210E+07,
 
  201                                 5.79960E+08, 1.60330E+07, 1.13640E+07, 7.21900E+06,
 
  202                                 3.11920E+07, 2.69830E+07, 1.38380E+07, 1.38330E+07,
 
  203                                 2.52270E+08, 9.20720E+06, 6.82220E+06, 4.56010E+06,
 
  204                                 1.64120E+07, 1.39290E+07, 7.16030E+06, 7.15560E+06,
 
  205                                 4.25840E+06, 4.25830E+06, 1.31150E+08, 5.62960E+06,
 
  206                                 4.29430E+06, 2.95570E+06, 9.66980E+06, 8.12340E+06,
 
  207                                 4.19010E+06, 4.18650E+06, 2.48120E+06, 2.48120E+06,
 
  208                                 1.64590E+06, 1.64590E+06, 7.65750E+07, 3.65330E+06,
 
  209                                 2.84420E+06, 1.99470E+06, 6.16640E+06, 5.14950E+06,
 
  210                                 2.66460E+06, 2.66200E+06, 1.57560E+06, 1.57560E+06,
 
  211                                 1.04170E+06, 1.04170E+06, 7.41210E+05, 7.41210E+05,
 
  212                                 4.84990E+07, 2.49130E+06, 1.96890E+06, 1.39900E+06,
 
  213                                 4.16900E+06, 3.46850E+06, 1.79980E+06, 1.79790E+06,
 
  214                                 1.06410E+06, 1.06410E+06, 7.02480E+05, 7.02480E+05,
 
  215                                 4.98460E+05, 4.98460E+05, -1.0000E+00, -1.0000E+00,
 
  216                                 3.26190E+07, 1.76920E+06, 1.41440E+06, 1.01460E+06,
 
  217                                 2.94830E+06, 2.44680E+06, 1.27280E+06, 1.27140E+06,
 
  218                                 7.52800E+05, 7.52790E+05, 4.96740E+05, 4.96740E+05,
 
  219                                 3.51970E+05, 3.51970E+05, -1.0000E+00, -1.0000E+00,
 
  220                                 -1.0000E+00, -1.0000E+00, 2.29740E+07, 1.29900E+06,
 
  221                                 1.04800E+06, 7.57160E+05, 2.16090E+06, 1.79030E+06,
 
  222                                 9.33210E+05, 9.32120E+05, 5.52310E+05, 5.52310E+05,
 
  223                                 3.64460E+05, 3.64460E+05, 2.58070E+05, 2.58070E+05,
 
  224                                 -1.0000E+00, -1.0000E+00, -1.0000E+00, -1.0000E+00,
 
  225                                 -1.0000E+00, -1.0000E+00, 1.67840E+07};
 
  227                         if( DrakeTotalAuls[i] > 0. && 
 
  233                                                 " SanityCheck found helium lifetime outside 0.1 pct of Drake values: index, expected, found: %li %.4e %.4e\n",
 
  251                 const int NHE1CS = 20;
 
  252                 double he1cs[NHE1CS] = 
 
  254                         5.480E-18 , 9.253E-18 , 1.598E-17 , 1.598E-17 , 1.598E-17 , 1.348E-17 , 
 
  255                         8.025E-18 , 1.449E-17 , 2.852E-17 , 1.848E-17 , 1.813E-17 , 2.699E-17 , 
 
  256                         1.077E-17 , 2.038E-17 , 4.159E-17 , 3.670E-17 , 3.575E-17 , 1.900E-17 , 
 
  257                         1.900E-17 , 4.175E-17 
 
  274                         if( fabs( he1cs[n-1] - 
opac.
OpacStack[i - 1] ) /he1cs[n-1] > 0.15 )
 
  277                                         " SanityCheck found insane HeI photo cs: expected, n=%li found: %.3e %.3e.\n",
 
  282                                         " n=%li, l=%li, s=%li\n",
 
  303                                         " SanityCheck found insane1 %s %s recom coef: expected, n=%i error: %.2e \n",
 
  316                                         " SanityCheck found insane2 %s %s recom coef: expected, n=%i error: %.2e \n",
 
  332         const int NSORT = 100 ;
 
  336         ipvector = (
long *)
MALLOC((NSORT)*
sizeof(
long int) );
 
  340         for( i=0; i<NSORT; ++i )
 
  355         if( lgFlag ) lgOK = 
false;
 
  357         for( i=1; i<NSORT; ++i )
 
  361                 if( fvector[ipvector[i]] <= fvector[ipvector[i-1]] )
 
  376                 fprintf(
ioQQQ , 
"SanityCheck finds insane te %e sqrt te %e sqrte %e dif %e\n",
 
  399         for( nelem=0; nelem<2; ++nelem )
 
  406                         Z4 = (double)(nelem+1);
 
  411                         double ans2 = 6.265e8*Z4;
 
  412                         if( fabs(ans1-ans2)/ans2 > 1e-3 )
 
  414                                 fprintf(
ioQQQ , 
"SanityCheck finds insane A for H Lya %g %g nelem=%li\n",
 
  415                                         ans1 , ans2 , nelem );
 
  422         for( nelem=0; nelem<
LIMELM; ++nelem )
 
  430                                 for( ipLo=0; ipLo<ipHi; ++ipLo )
 
  434                                 if( fabs(sum-1.)>0.01 ) 
 
  437                                                 "SanityCheck H branching ratio sum not unity for nelem=%li upper level=%i sum=%.3e\n",
 
  446         for( nelem=0; nelem<
LIMELM; ++nelem )
 
  453                                 double inverse_sum = 0.;
 
  461                                 for( ipLo=0; ipLo<ipHi; ++ipLo )
 
  466                                 inverse_sum = 1./sum;
 
  469                                 double percent_error = (1. - inverse_sum/lifetime)*100;
 
  474                                 if( fabs(percent_error) > 0.5 ) 
 
  477                                                 "SanityCheck hydrogenic lifetime not consistent with closed form for nelem=%2li upper level=%2i inverse-sum= %.3e lifetime= %.3e error= %.2f%%\n",
 
  478                                                 nelem, ipHi, inverse_sum, lifetime, percent_error );
 
  502                 double rel_photon_energy = 1. + FLT_EPSILON*2.;
 
  503                 for( 
long l=0; l < n; l++ )
 
  508                         cs = 
H_photo_cs( rel_photon_energy, n, l, nelem+1 );
 
  515                                 fprintf(
ioQQQ , 
"SanityCheck finds insane H photo cs, n,l = %li, %li, expected, found = %e, %e, error = %e\n",
 
  550                         double ans2 = 
expn( 1 , x );
 
  551                         error = 
safe_div(ans1-ans2,ans1+ans2,0.);
 
  552                         if( fabs(error) > 3e-7 )
 
  554                                 fprintf(
ioQQQ , 
"SanityCheck finds insane E1 %g %g %g error %g\n",
 
  555                                                   x , ans1 , ans2, error );
 
  562                         double ans2 = 
expn( 2 , x );
 
  563                         error = 
safe_div(ans1-ans2,ans1+ans2,0.);
 
  564                         if( fabs(error) > 1e-8 )
 
  566                                 fprintf(
ioQQQ , 
"SanityCheck finds insane E2 %g %g %g error %g\n",
 
  567                                                   x , ans1 , ans2, error );
 
  607         A = (
double*)
MALLOC( 
sizeof(
double)*NDIM*NDIM );
 
  610         for( i=0; i < 3; ++i )
 
  612                 for( j=0; j < 3; ++j )
 
  614                         A[i*NDIM+j] = xMatrix[i][j];
 
  653                 x = fabs( yVector[i]-i-1.);
 
  654                 rcond = 
MAX2( rcond, x );
 
  658         if( rcond>DBL_EPSILON)
 
  661                         "SanityCheck found too large a deviation in matrix solver = %g \n", 
 
  671         for( nelem=0; nelem<
LIMELM; ++nelem )
 
  701                         for( ion=0; ion<=nelem; ++ion )
 
  704                                 for( nshells=0; nshells<
Heavy.
nsShells[nelem][ion]; ++nshells )
 
  714                                                                 "SanityCheck found insane ipElement for nelem=%li ion=%li nshells=%li j=%li \n", 
 
  715                                                                 nelem , ion , nshells, j );
 
  717                                                                 "value was %li  \n", 
opac.
ipElement[nelem][ion][nshells][j] );
 
  726                                         vector<realnum> saveion;
 
  727                                         saveion.resize(nelem+2);
 
  729                                         for( j=0; j <= (nelem + 1); j++ )
 
  751                                                                 "SanityCheck found non-positive photo cs for nelem=%li ion=%li \n", 
 
  754                                                                 "value was %.2e + %.2e nelem %li ion %li at energy %.2e\n", 
 
  766                                         for( j=0; j <= (nelem + 1); j++ )
 
  806                 fprintf(
ioQQQ , 
"SanityCheck finds insanity so exiting\n");
 
  815         double gam2 = 
exp10(loggam2);
 
  816         double u = 
exp10(logu);
 
  817         double ZZ = double(Z);
 
  818         double Te = TE1RYD*
pow2(ZZ)/gam2;
 
  819         double anu = 
pow2(ZZ)*u/gam2;
 
  821         if( fabs(val/refval-1.) > relerr )
 
  823                 fprintf( 
ioQQQ, 
"Gaunt sanity check failed: log(gam2) = %e, log(u) = %e, Z = %ld, " 
  824                          "expected gff = %e, got gff = %e\n", loggam2, logu, Z, refval, val );
 
void OpacityAdd1Element(long int ipZ)
long int ipElement[LIMELM][LIMELM][7][3]
void getrs_wrapper(char trans, long N, long nrhs, double *A, long lda, int32 *ipiv, double *B, long ldb, int32 *info)
double iso_recomb_check(long ipISO, long nelem, long level, double temperature)
void SanityCheck(const char *chJob)
double expn(int n, double x)
double anu(size_t i) const 
void ValidateEdges() const 
t_elementnames elementnames
t_iso_sp iso_sp[NISO][LIMELM]
double xIonDense[LIMELM][LIMELM+1]
bool fp_equal(sys_float x, sys_float y, int n=3)
multi_arr< double, 2 > BranchRatio
long int n_HighestResolved_max
void getrf_wrapper(long M, long N, double *A, long lda, int32 *ipiv, int32 *info)
long int nsShells[LIMELM][LIMELM]
EmissionList::reference Emis() const 
STATIC void SanityCheckFinal()
sys_float safe_div(sys_float x, sys_float y, sys_float res_0by0)
double sum(double min, double max) const 
multi_arr< long, 3 > QuantumNumbers2Index
double gauntff(long Z, double Te, double anu)
TransitionProxy trans(const long ipHi, const long ipLo)
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
double H_photo_cs(double rel_photon_energy, long int n, long int l, long int iz)
STATIC void SanityCheckBegin()
double qg32(double, double, double(*)(double))
#define DEBUG_ENTRY(funcname)
double iso_state_lifetime(long ipISO, long nelem, long n, long l)
int fprintf(const Output &stream, const char *format,...)
double H_Einstein_A(long int n, long int l, long int np, long int lp, long int iz)
long int ipHeavy[LIMELM][LIMELM]
void spsort(realnum x[], long int n, long int iperm[], int kflag, int *ier)
STATIC void SanityCheckGaunt(long Z, double loggam2, double logu, double refval, double relerr)
bool lgNoRecombInterp[NISO]