31 oss << setw(2) << setfill(
'0') << nelem+1;
32 string::size_type ptr = fnam1.find(
"xx" );
33 ASSERT( ptr != string::npos );
34 fnam1.replace( ptr, 2, oss.str() );
41 istringstream iss( line );
46 fprintf(
ioQQQ,
" t_gaunt::p_read_table() found wrong magic number in file %s.\n", fnam );
81 for(
size_t ipg2=0; ipg2 <
p_np_gam2; ++ipg2 )
86 for(
size_t ipu=0; ipu <
p_np_u; ++ipu )
104 for(
size_t ipu=0; ipu <
p_np_u; ++ipu )
108 for(
size_t ipg2=0; ipg2 <
p_np_gam2; ++ipg2 )
112 p_gff[nelem][0][ipu][ipg2] = log(val);
115 iss.clear( iss.rdstate() & ~iss.eofbit );
119 for(
size_t ipg2=0; ipg2 < p_np_gam2-i; ++ipg2 )
120 p_gff[nelem][i][ipu][ipg2] =
121 (
p_gff[nelem][i-1][ipu][ipg2+1]-
p_gff[nelem][i-1][ipu][ipg2])/
128 if( io.fail() || iss.fail() )
130 fprintf(
ioQQQ,
" An error occurred while reading the file %s. Bailing out.\n", fnam );
143 double gam2 =
pow2(
double(Z))*TE1RYD/Te;
144 double u = anu*TE1RYD/Te;
146 ASSERT( gam2 > 0. && u > 0. );
148 double lg_gam2 = log10(gam2);
149 double lg_u = log10(u);
161 N_GFF_INTERP, lg_gam2);
187 else if(
p_gff_ion[Z].nflux_used < nflux )
200 vector< realnum, allocator_avx<realnum> >& gff =
p_gff_ion[Z].
gff;
202 double lg_gam2 = log10(
pow2(
double(Z))*TE1RYD/Te);
206 double lg_u0 = log10(TE1RYD/Te);
212 for(
size_t ipu=ipumin; ipu < ipumax; ++ipu )
217 double val =
p_gff[Z-1][0][ipu][ipg2];
218 double fac = lg_gam2 - *plu++;
221 val += fac*
p_gff[Z-1][i][ipu][ipg2];
224 fac *= lg_gam2 - *plu++;
226 interp[0][ipu] = val;
231 for(
size_t ipu=ipumin; ipu < ipumax-i; ++ipu )
232 interp[i][ipu] = (interp[i-1][ipu+1]-interp[i-1][ipu])/(double(i)*
p_step);
237 for(
long j=nmin; j < nmax; ++j )
239 double lg_u = lg_u0 + anulog10[j];
240 while( lg_u >=
p_lg_u[ipu+2] )
245 const double* pin =
get_ptr(&interp[0][ipu]);
247 double fac = lg_u - *plu++;
252 if( ++i == N_GFF_INTERP )
254 fac *= lg_u - *plu++;
267 if( ion > 0 && ion <
LIMELM+1 )
280 double ion2 =
pow2(
double(ion));
320 if( ion > 0 && ion <
LIMELM+1 )
374 if( ion > 0 && ion <
LIMELM+1 )
376 ASSERT( arr.size() >= limit );
378 for(
size_t i=0; i < limit; ++i )
383 ASSERT( arr.size() >= limit );
385 for(
size_t i=0; i < limit; ++i )
400 if( ion > 0 && ion <
LIMELM+1 )
429 for(
long ion=1; ion <
LIMELM+1; ++ion )
457 double toler = 0.002;
459 for(
long logu=-13; logu <= 12; logu++ )
462 double gam2[3], gaunt[3];
463 double u =
exp10((
double)(logu));
464 for(
long loggamma2=-500; loggamma2 <= 900; loggamma2++ )
466 gam2[i] =
exp10(
double(loggamma2)/100.);
467 double Te =
pow2(Z)*(TE1RYD/gam2[i]);
468 double ERyd =
pow2(Z)*u/gam2[i];
476 if( abs((gaunt[2]+gaunt[0])/(2.*gaunt[1]) - 1.) > toler ) {
477 fprintf(
ioQQQ,
" PROBLEM DISASTER cont_gaunt_calc discontinuity in"
478 " gam2 direction at gam2 = %e u = %e\n", gam2[i], u );
479 fprintf(
ioQQQ,
" gam2 = %e gaunt = %e\n", gam2[0], gaunt[0] );
480 fprintf(
ioQQQ,
" gam2 = %e gaunt = %e\n", gam2[1], gaunt[1] );
481 fprintf(
ioQQQ,
" gam2 = %e gaunt = %e\n", gam2[2], gaunt[2] );
496 for(
long loggamma2=-5; loggamma2 <= 9; loggamma2++ )
499 double u[3], gaunt[3];
500 double gam2 =
exp10(
double(loggamma2));
501 double Te =
pow2(Z)*(TE1RYD/gam2);
502 for(
long logu=-1300; logu <= 1200; logu++ )
504 u[i] =
exp10((
double)(logu)/100.);
505 double ERyd =
pow2(Z)*u[i]/gam2;
513 if( abs((gaunt[2]+gaunt[0])/(2.*gaunt[1]) - 1.) > toler ) {
514 fprintf(
ioQQQ,
" PROBLEM DISASTER cont_gaunt_calc discontinuity in"
515 " u direction at gam2 = %e u = %e\n", gam2, u[2] );
516 fprintf(
ioQQQ,
" u = %e gaunt = %e\n", u[0], gaunt[0] );
517 fprintf(
ioQQQ,
" u = %e gaunt = %e\n", u[1], gaunt[1] );
518 fprintf(
ioQQQ,
" u = %e gaunt = %e\n", u[2], gaunt[2] );
t_mole_global mole_global
vector< double, allocator_avx< double > > ContBoltz
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
double brems_cool(long ion, double Te)
long int ipEnergyBremsThin
NORETURN void TotalInsanity(void)
double widflx(size_t i) const
void set_NaN(sys_float &x)
t_brems_vec p_cache_vec[LIMELM+1]
void p_gauntff_vec(long Z, double Te, const double anulog10[], long nflux)
void dgaunt_check(double Z)
molezone * findspecieslocal(const char buf[])
t_iso_sp iso_sp[NISO][LIMELM]
void vexp(const double x[], double y[], long nlo, long nhi)
long int nflux_with_check
const double TEMP_LIMIT_LOW
double xIonDense[LIMELM][LIMELM+1]
bool fp_equal(sys_float x, sys_float y, int n=3)
const ios_base::openmode mode_r
void p_setup_brems(long ion, double Te)
const double TEMP_LIMIT_HIGH
valarray< class molezone > species
static const long gaunt_magic
void p_read_table(const char *fnam, long nelem)
vector< realnum, allocator_avx< realnum > > gff
vector< double > brems_vec
double gauntff(long Z, double Te, double anu)
double lagrange(const double x[], const double y[], long n, double xval)
t_brems_sum p_cache[LIMELM+1]
static const char * gauntff_file
vector< realnum, allocator_avx< realnum > > p_vexp_arg
void p_gauntff_vec_sub(long Z, double Te, const double anulog10[], long nmin, long nmax)
#define DEBUG_ENTRY(funcname)
t_gff p_gff_ion[LIMELM+1]
multi_arr< double, 4 > p_gff
int fprintf(const Output &stream, const char *format,...)
vector< double > p_lg_gam2
void brems_sum_ions(t_brems_den &sum) const
void brems_opac(long ion, double Te, double abun, double arr[])
void brems_rt(long ion, double Te, double abun, vector< double > &arr)
const double * anulog10ptr() const
static const size_t N_GFF_INTERP