49 #if defined(PRINT_DR) || defined(PRINT_RR)
50 static const char FILE_NAME_OUT[] =
"array.out";
60 long int atomic_number,
62 long int ionic_charge,
73 ASSERT( ionic_charge > 0 );
76 const double mu = 0.000;
77 const double w = 5.64586;
78 const double x_a0 = 10.1821;
84 const double c = 10.0;
86 double s, snew, x_a, E_c;
88 long int iso_sequence, N_1, N_2;
91 double Tlog = log10(T);
94 iso_sequence = atomic_number - ionic_charge;
95 ASSERT( iso_sequence > 0 );
98 double c10 = double(ionic_charge) / 10.;
103 if( (iso_sequence >= 1) && (iso_sequence <= 2) )
108 else if( (iso_sequence >= 3) && (iso_sequence <= 10) )
113 else if( (iso_sequence >= 11) && (iso_sequence <= 18) )
118 else if( (iso_sequence >= 19) && (iso_sequence <= 36) )
123 else if( (iso_sequence >= 37) && (iso_sequence <= 54) )
128 else if( (iso_sequence >= 55) && (iso_sequence <= 86) )
133 else if( iso_sequence >= 87 )
146 A_N = 12.0 + 10.0 * N_1 + (10.0 * N_1 - 2.0 * N_2) * (iso_sequence - N_1) / (N_1 - N_2);
154 if( iso_sequence == 1 )
159 else if( iso_sequence == 2 )
164 else if( iso_sequence == 3 )
166 E_c = 1.96274 + c10*(20.30014 + c10*(-0.97103 + c10*( 0.85453 + c10*( 0.13547 + 0.02401*c10))));
169 else if( iso_sequence == 4 )
171 E_c = 5.78908 + c10*(34.08270 + c10*( 1.51729 + c10*(-1.21227 + c10*( 0.77559 - 0.00410*c10))));
174 else if( iso_sequence == 5 )
179 else if( iso_sequence == 7 )
181 E_c = 11.37092 + c10*(36.22053 + c10*( 7.08448 + c10*(-5.16840 + c10*( 2.45056 - 0.16961*c10))));
183 else if( iso_sequence == 11 )
185 E_c = 2.24809 + c10*(22.27768 + c10*(-1.12285 + c10*( 0.90267 + c10*(-0.03860 + 0.01468*c10))));
187 else if( iso_sequence == 12 )
189 E_c = 2.74508 + c10*(19.18623 + c10*(-0.54317 + c10*( 0.78685 + c10*(-0.04249 + 0.01357*c10))));
191 else if( iso_sequence == 15 )
193 E_c = 1.42762 + c10*( 3.90778 + c10*( 0.73119 + c10*(-1.91404 + c10*( 1.05059 - 0.08992*c10))));
202 if( iso_sequence == 14 && ionic_charge == 2 )
205 double xic = double(ionic_charge);
208 if( iso_sequence <= 5 )
210 double pp1,pp2,pp3,pp4,pp5,pp6,AN0;
212 double Tscal = T/
pow2(xic);
213 A_N *= 2.0 / ( 1.0 + exp(-sqrt(25000.0 / Tscal)));
215 if( iso_sequence == 1 )
217 pp1 = 4.7902 + 0.32456 * pow(xic, 0.97838) * exp( -xic / 24.78084 );
218 pp2 = -0.0327 + 0.13265 * pow(xic, 0.29226);
219 pp3 = -0.66855 + 0.28711 * pow(xic, 0.29083) * exp( -xic / 6.65275 );
220 pp4 = 6.23776 + 0.11389 * pow(xic, 1.24036) * exp( -xic / 25.79559 );
221 pp5 = 0.33302 + 0.00654 * pow(xic, 5.67945) * exp( -xic / 0.92602 );
222 pp6 = -0.75788 + 1.75669 * pow(xic,-0.63105) * exp( -xic / 184.82361 );
224 else if( iso_sequence == 2 )
226 pp1 = 4.82857 + 0.3 * pow(xic, 1.04558) * exp( -xic / 19.6508 );
227 pp2 = -0.50889 + 0.6 * pow(xic, 0.17187) * exp( -xic / 47.19496 );
228 pp3 = -1.03044 + 0.35 * pow(xic, 0.3586 ) * exp( -xic / 39.4083 );
229 pp4 = 6.14046 + 0.15 * pow(xic, 1.46561) * exp( -xic / 10.17565 );
230 pp5 = 0.08316 + 0.08 * pow(xic, 1.37478) * exp( -xic / 8.54111 );
231 pp6 = -0.19804 + 0.4 * pow(xic, 0.74012) * exp( -xic / 2.54024 );
233 else if( iso_sequence == 3 )
235 pp1 = 4.55441 + 0.08 * pow(xic, 1.11864);
236 pp2 = 0.3 + 2.0 *
powi(xic, -2) * exp( -xic / 67.36368 );
237 pp3 = -0.4 + 0.38 * pow(xic, 1.62248) * exp( -xic / 2.78841 );
238 pp4 = 4.00192 + 0.58 * pow(xic, 0.93519) * exp( -xic / 21.28094 );
239 pp5 = 0.00198 + 0.32 * pow(xic, 0.84436) * exp( -xic / 9.73494 );
240 pp6 = 0.55031 - 0.32251 * pow(xic, 0.75493) * exp( -xic / 19.89169 );
242 else if( iso_sequence == 4 )
244 pp1 = 2.79861 + 1.0 * pow(xic, 0.82983) * exp( -xic / 18.05422 );
245 pp2 = -0.01897 + 0.05 * pow(xic, 1.34569) * exp( -xic / 10.82096 );
246 pp3 = -0.56934 + 0.68 * pow(xic, 0.78839) * exp( -xic / 2.77582 );
247 pp4 = 4.07101 + 1.0 * pow(xic, 0.7175 ) * exp( -xic / 25.89966 );
248 pp5 = 0.44352 + 0.05 * pow(xic, 3.54877) * exp( -xic / 0.94416 );
249 pp6 = -0.57838 + 0.68 * pow(xic, 0.08484) * exp( -xic / 6.70076 );
251 else if( iso_sequence == 5 )
253 pp1 = 6.75706 - 3.77435 * exp( -xic / 4.59785 );
254 pp2 = 0.0 + 0.08 * pow(xic, 1.34923) * exp( -xic / 7.36394 );
255 pp3 = -0.63 + 0.06 * pow(xic, 2.65736) * exp( -xic / 2.11946 );
256 pp4 = 7.74115 - 4.82142 * exp( -xic / 4.04344 );
257 pp5 = 0.26595 + 0.09 * pow(xic, 1.29301) * exp( -xic / 6.81342 );
258 pp6 = -0.39209 + 0.07 * pow(xic, 2.27233) * exp( -xic / 1.9958 );
265 AN0 = pp3 * exp( -0.5*
pow2((Tlog - pp1)/pp2) ) + pp6 * exp( -0.5*
pow2((Tlog - pp4)/pp5) );
277 double gg1,gg2,gg3,gg4,gg5,gg6,BN0=0.;
279 if( iso_sequence == 5 )
282 gg1 = 6.91078 - 1.6385 * pow(xic, 2.18197) * exp( -xic / 1.45091 );
283 gg2 = 0.4959 - 0.08348 * pow(xic, 1.24745) * exp( -xic / 8.55397 );
284 gg3 = -0.27525 + 0.132 * pow(xic, 1.15443) * exp( -xic / 3.79949 );
285 gg4 = 7.45975 - 2.6722 * pow(xic, 1.7423 ) * exp( -xic / 1.19649 );
286 gg5 = 0.51285 - 0.60987 * pow(xic, 5.15431) * exp( -xic / 0.49095 );
287 gg6 = -0.24818 + 0.125 * pow(xic, 0.59971) * exp( -xic / 8.34052 );
289 else if( iso_sequence == 6 )
291 gg1 = 5.90184 - 1.2997 * pow(xic, 1.32018) * exp( -xic / 2.10442 );
292 gg2 = 0.12606 + 0.009 * pow(xic, 8.33887) * exp( -xic / 0.44742 );
293 gg3 = -0.28222 + 0.018 * pow(xic, 2.50307) * exp( -xic / 3.83303 );
294 gg4 = 6.96615 - 0.41775 * pow(xic, 2.75045) * exp( -xic / 1.32394 );
295 gg5 = 0.55843 + 0.45 * exp( -xic / 2.06664 );
296 gg6 = -0.17208 - 0.17353 * exp( -xic / 2.57406 );
298 else if( iso_sequence == 13 )
300 gg1 = 6.59628 - 3.03115 * exp( -xic / 10.519821 );
301 gg2 = 1.20824 - 0.85509 * pow(xic, 0.21258) * exp( -xic / 25.56 );
302 gg3 = -0.34292 - 0.06013 * pow(xic, 4.09344) * exp( -xic / 0.90604 );
303 gg4 = 7.92025 - 3.38912 * exp( -xic / 10.02741 );
304 gg5 = 0.06976 + 0.6453 * pow(xic, 0.24827) * exp( -xic / 20.94907 );
305 gg6 = -0.34108 - 0.17353 * exp( -xic / 6.0384 );
307 else if( iso_sequence == 14 )
309 gg1 = 5.54172 - 1.54639 * pow(xic, 0.01056) * exp( -xic / 3.24604 );
310 gg2 = 0.39649 + 0.8 * pow(xic, 3.19571) * exp( -xic / 0.642068 );
311 gg3 = -0.35475 - 0.08912 * pow(xic, 3.55401) * exp( -xic / 0.73491 );
312 gg4 = 6.88765 - 1.93088 * pow(xic, 0.23469) * exp( -xic / 3.23495 );
313 gg5 = 0.58577 - 0.31007 * pow(xic, 3.30137) * exp( -xic / 0.83096 );
314 gg6 = -0.14762 - 0.16941 * exp( -xic / 18.53007 );
325 if( gg3 != 0. || gg6 != 0. )
328 BN0 = gg3 * exp( -0.5*
pow2((Tlog - gg1)/gg2) ) + gg6 * exp( -0.5*
pow2((Tlog - gg4)/gg5) );
334 fprintf(
ioQQQ,
"DEBUGDN an=%li q=%li logNe=%.2e Te=%.2e N_1=%li N_2=%li Niso=%li BN0=%.2e\n",
335 atomic_number, ionic_charge, eden, T ,
336 N_1 , N_2 , iso_sequence, BN0);
343 q_0 = 1.0 / sqrt((
double)ionic_charge);
344 q_0 = A_N * q_0 * (1.0 - 0.816497 * q_0);
348 T_0 = 50000.0 *
pow2( q_0 );
351 x_a = x_a0 + log10(
powi( ((
double)ionic_charge/q_0), 7 ) * sqrt( T/T_0 ) );
361 s = ( mu/( 1. +
pow2((eden-x_a)/w) ) +
362 (1. - mu) * exp( -LN_TWO *
pow2((eden-x_a)/w) ) );
371 if( iso_sequence == 1 || iso_sequence == 2 || iso_sequence == 10 )
372 snew = 1. + (s-1.)*exp(-(20.0*
erfc( 2.*(eden - x_a0) ) * EVDEGK)/(c*T));
374 snew = 1. + (s-1.)*exp(-(E_c*EVDEGK)/(c*T));
376 ASSERT( snew >= 0. && snew <= 1. );
395 int nAtomicNumberCScale,
397 int n_core_e_before_recomb )
400 double RateCoefficient, sum;
404 ASSERT( nAtomicNumberCScale>=0 && nAtomicNumberCScale<
LIMELM );
406 if( nAtomicNumberCScale==
ipIRON && n_core_e_before_recomb>=12 &&
407 n_core_e_before_recomb<=18 )
416 static const double cFe_q[7][8] =
418 {5.636e-4, 7.390e-3, 3.635e-2, 1.693e-1, 3.315e-2, 2.288e-1, 7.316e-2, 0.},
419 {1.090e-3, 7.801e-3, 1.132e-2, 4.740e-2, 1.990e-1, 3.379e-2, 1.140e-1, 1.250e-1},
420 {3.266e-3, 7.637e-3, 1.005e-2, 2.527e-2, 6.389e-2, 1.564e-1, 0., 0.},
421 {1.074e-3, 6.080e-3, 1.887e-2, 2.540e-2, 7.580e-2, 2.773e-1, 0., 0.},
422 {9.073e-4, 3.777e-3, 1.027e-2, 3.321e-2, 8.529e-2, 2.778e-1, 0., 0.},
423 {5.335e-4, 1.827e-3, 4.851e-3, 2.710e-2, 8.226e-2, 3.147e-1, 0., 0.},
424 {7.421e-4, 2.526e-3, 4.605e-3, 1.489e-2, 5.891e-2, 2.318e-1, 0., 0.}
428 static const double EFe_q[7][8] =
430 {3.628e3, 2.432e4, 1.226e5, 4.351e5, 1.411e6, 6.589e6, 1.030e7, 0},
431 {1.246e3, 1.063e4, 4.719e4, 1.952e5, 5.637e5, 2.248e6, 7.202e6, 3.999e9},
432 {1.242e3, 1.001e4, 4.466e4, 1.497e5, 3.919e5, 6.853e5, 0. , 0.},
433 {1.387e3, 1.048e4, 3.955e4, 1.461e5, 4.010e5, 7.208e5, 0. , 0.},
434 {1.525e3, 1.071e4, 4.033e4, 1.564e5, 4.196e5, 7.580e5, 0. , 0.},
435 {2.032e3, 1.018e4, 4.638e4, 1.698e5, 4.499e5, 7.880e5, 0. , 0.},
436 {3.468e3, 1.353e4, 3.690e4, 1.957e5, 4.630e5, 8.202e5, 0. , 0.}
439 long int nion = n_core_e_before_recomb - 12;
440 ASSERT( nion>=0 && nion <=6 );
444 for( i=0; i < 8; ++i )
446 sum += (cFe_q[nion][i] *
sexp( EFe_q[nion][i]/
phycon.
te));
451 strcpy(
chDRDataSource[nAtomicNumberCScale][nAtomicNumberCScale-n_core_e_before_recomb] ,
454 return RateCoefficient;
458 else if( nAtomicNumberCScale < n_core_e_before_recomb )
460 RateCoefficient = -2;
463 else if( nAtomicNumberCScale >=
LIMELM )
465 RateCoefficient = -2;
470 RateCoefficient = -1;
477 for(i=0; i<
nDRFitPar[nAtomicNumberCScale][n_core_e_before_recomb]; ++i )
479 sum += (
DRFitParPart1[nAtomicNumberCScale][n_core_e_before_recomb][i] *
483 strcpy(
chDRDataSource[nAtomicNumberCScale][nAtomicNumberCScale-n_core_e_before_recomb] ,
492 RateCoefficient = -99;
495 ASSERT( RateCoefficient < 1e-6 );
497 return RateCoefficient;
506 int nAtomicNumberCScale,
508 int n_core_e_before_recomb )
510 double RateCoefficient;
515 ASSERT( nAtomicNumberCScale>=0 && nAtomicNumberCScale<
LIMELM );
517 if( nAtomicNumberCScale==
ipIRON &&
518 n_core_e_before_recomb>=12 && n_core_e_before_recomb<=18 )
527 static const double parFeq[7][6] ={
528 {1.179e-9 , 0.7096, 4.508e2, 3.393e7, 0.0154, 3.977e6},
529 {1.050e-9 , 0.6939, 4.568e2, 3.987e7, 0.0066, 5.451e5},
530 {9.832e-10, 0.7146, 3.597e2, 3.808e7, 0.0045, 3.952e5},
531 {8.303e-10, 0.7156, 3.531e2, 3.554e7, 0.0132, 2.951e5},
532 {1.052e-9 , 0.7370, 1.639e2, 2.924e7, 0.0224, 4.291e5},
533 {1.338e-9 , 0.7495, 7.242e1, 2.453e7, 0.0404, 4.199e5},
534 {1.263e-9 , 0.7532, 5.209e1, 2.169e7, 0.0421, 2.917e5}
539 long int nion = n_core_e_before_recomb - 12;
540 ASSERT( nion>=0 && nion <=6 );
543 B = parFeq[nion][1] + parFeq[nion][4]*exp(temp);
544 D = sqrt(
phycon.
te/parFeq[nion][2]);
545 F = sqrt(
phycon.
te/parFeq[nion][3]);
546 RateCoefficient = parFeq[nion][0]/(D*pow((1.+D),(1.-B))*pow((1.+F),(1.+B)));
547 strcpy(
chRRDataSource[nAtomicNumberCScale][nAtomicNumberCScale-n_core_e_before_recomb] ,
"Bad06");
549 return RateCoefficient;
553 else if( nAtomicNumberCScale < n_core_e_before_recomb )
555 RateCoefficient = -2;
558 else if( nAtomicNumberCScale >=
LIMELM )
560 RateCoefficient = -2;
565 RateCoefficient = -1;
576 B =
RRFitPar[nAtomicNumberCScale][n_core_e_before_recomb][1] +
577 RRFitPar[nAtomicNumberCScale][n_core_e_before_recomb][4]*exp(temp);
578 D = sqrt(
phycon.
te/
RRFitPar[nAtomicNumberCScale][n_core_e_before_recomb][2]);
579 F = sqrt(
phycon.
te/
RRFitPar[nAtomicNumberCScale][n_core_e_before_recomb][3]);
580 RateCoefficient =
RRFitPar[nAtomicNumberCScale][n_core_e_before_recomb][0]/(D*pow((1.+D),(1.-B))*pow((1.+F),(1.+B)));
581 strcpy(
chRRDataSource[nAtomicNumberCScale][nAtomicNumberCScale-n_core_e_before_recomb] ,
"Bad06");
586 RateCoefficient = -99;
588 return RateCoefficient;
601 int NuclearCharge=-1, NumberElectrons=-1;
604 int M_state, W_state;
606 const int NBLOCK = 2;
607 int data_begin_line[NBLOCK];
610 const char* chFilename;
614 const int BIGGEST_INDEX_TO_USE = 103;
617 long TheirIndexToOurIndex[BIGGEST_INDEX_TO_USE];
622 long INDX=0,INDP=0,
N=0,
S=0,L=0,J=0,maxINDX=0,loopindex=0,max_N_of_data=-1;
625 static int nCalled = 0;
627 static const char* cdDATAFILE[] =
631 "UTA/nrb00_h_he1ic12.dat",
632 "UTA/nrb00_h_li2ic12.dat",
633 "UTA/nrb00_h_be3ic12.dat",
634 "UTA/nrb00_h_b4ic12.dat",
635 "UTA/nrb00_h_c5ic12.dat",
636 "UTA/nrb00_h_n6ic12.dat",
637 "UTA/nrb00_h_o7ic12.dat",
638 "UTA/nrb00_h_f8ic12.dat",
639 "UTA/nrb00_h_ne9ic12.dat",
640 "UTA/nrb00_h_na10ic12.dat",
641 "UTA/nrb00_h_mg11ic12.dat",
642 "UTA/nrb00_h_al12ic12.dat",
643 "UTA/nrb00_h_si13ic12.dat",
644 "UTA/nrb00_h_p14ic12.dat",
645 "UTA/nrb00_h_s15ic12.dat",
646 "UTA/nrb00_h_cl16ic12.dat",
647 "UTA/nrb00_h_ar17ic12.dat",
648 "UTA/nrb00_h_k18ic12.dat",
649 "UTA/nrb00_h_ca19ic12.dat",
650 "UTA/nrb00_h_sc20ic12.dat",
651 "UTA/nrb00_h_ti21ic12.dat",
652 "UTA/nrb00_h_v22ic12.dat",
653 "UTA/nrb00_h_cr23ic12.dat",
654 "UTA/nrb00_h_mn24ic12.dat",
655 "UTA/nrb00_h_fe25ic12.dat",
656 "UTA/nrb00_h_co26ic12.dat",
657 "UTA/nrb00_h_ni27ic12.dat",
658 "UTA/nrb00_h_cu28ic12.dat",
659 "UTA/nrb00_h_zn29ic12.dat"
672 # if defined(PRINT_DR) || defined(PRINT_RR)
673 FILE *ofp =
open_data( FILE_NAME_OUT,
"w" );
678 for(
long nelem=ipISO; nelem <
LIMELM; nelem++ )
685 iso_sp[ipISO][nelem].fb[ipHi].DielecRecombVsTemp[k] = 0.;
697 ioDATA=
open_data( cdDATAFILE[nelem],
"r" );
702 for(
long i=0; i<BIGGEST_INDEX_TO_USE; i++ )
703 TheirIndexToOurIndex[i] = -1;
710 if(
nMatch(
"INDX INDP ",
string) )
715 fprintf(
ioQQQ,
" Badnell data file appears to be corrupted.\n");
722 if( strcmp(
string,
"\n")==0 )
729 INDX=(long)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
730 if( INDX >= BIGGEST_INDEX_TO_USE )
737 ASSERT( INDX < BIGGEST_INDEX_TO_USE );
739 INDP=(long)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
744 if( (i1=
nMatch(
"1S1 ",
string)) > 0 )
747 N=(long)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
755 if( (i1=
nMatch(
" (",
string)) > 0 )
758 S=(long)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
769 L=(long)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
774 J=(long)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
775 ASSERT( J <= ( L + (
int)((
S+1)/2) ) &&
776 J >= ( L - (
int)((
S+1)/2) ) && J >= 0 );
791 if(
N==2 && L==1 &&
S==3 )
794 TheirIndexToOurIndex[INDX] = 3;
796 TheirIndexToOurIndex[INDX] = 4;
800 ASSERT( TheirIndexToOurIndex[INDX] == 5 );
803 max_N_of_data =
MAX2( max_N_of_data,
N );
822 ASSERT( maxINDX < BIGGEST_INDEX_TO_USE );
831 if(
nMatch(
"INDX TE= ",
string) )
838 fprintf(
ioQQQ,
" Badnell data file appears to be corrupted.\n");
846 if(
nMatch(
"PRTF",
string) || INDX >= maxINDX || INDX<0 )
850 INDX=(long)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
856 if( TheirIndexToOurIndex[INDX] <
iso_sp[
ipHE_LIKE][nelem].numLevels_max &&
857 TheirIndexToOurIndex[INDX] > 0 )
862 for(loopindex=0;loopindex<10;loopindex++)
864 value=(double)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
871 fprintf(
ioQQQ,
" Badnell data file appears to be corrupted.\n");
877 for(loopindex=10;loopindex<19;loopindex++)
879 value=(double)
FFmtRead(
string,&i1,
sizeof(
string),&lgEOL);
890 ASSERT( maxINDX < BIGGEST_INDEX_TO_USE );
891 ASSERT( max_N_of_data > 0 );
900 for(
long i=TheirIndexToOurIndex[maxINDX]+1;
911 for(loopindex=0;loopindex<19;loopindex++)
927 for(loopindex=0;loopindex<19;loopindex++)
939 for(
long i=0; i<NBLOCK; ++i )
942 data_begin_line[i] = INT_MIN;
945 chFilename =
"badnell_dr.dat";
961 data_begin_line[number] = count;
962 ASSERT( number < NBLOCK );
981 for(
long nelem=0; nelem<
LIMELM; nelem++ )
995 for(
long ion=0; ion<nelem+1; ++ion )
1023 fseek(ioDATA, 0, SEEK_SET);
1025 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioDATA ) == NULL )
1027 fprintf(
ioQQQ,
" DISASTER PROBLEM Badnell_rec_init could not read first line of badnell_dr.dat.\n");
1033 if( (chs =
strchr_s(chLine,
')'))==NULL )
1036 fprintf(
ioQQQ,
" DISASTER PROBLEM Badnell_rec_init data file incorrect format.\n");
1041 sscanf(chs,
"%4i%2i%2i",&yr, &mo, &dy);
1043 int dr_yr = 2012, dr_mo = 6, dr_dy = 28;
1044 if((yr != dr_yr) || (mo != dr_mo) || (dy != dr_dy))
1047 "DISASTER PROBLEM Badnell_rec_init The version of %s I found (%i %i %i) is not the current version (%i %i %i).\n",
1048 chFilename, yr, mo, dy, dr_yr, dr_mo, dr_dy);
1049 fprintf(
ioQQQ,
" The first line of the file is the following\n %s\n", chLine );
1056 length_of_line = (int)strlen(chLine);
1059 if( count > data_begin_line[0] && count < data_begin_line[1] && length_of_line >3 )
1066 sscanf(chLine,
"%i%i%i%i%lf%lf%lf%lf%lf%lf%lf%lf%lf",
1067 &NuclearCharge, &NumberElectrons, &M_state, &W_state, &par_C[0], &par_C[1], &par_C[2],
1068 &par_C[3], &par_C[4], &par_C[5], &par_C[6], &par_C[7], &par_C[8]);
1071 long int NuclearChargeM1 = NuclearCharge-1;
1073 if(M_state == 1 && NuclearChargeM1 < LIMELM )
1076 ASSERT( NumberElectrons < LIMELM );
1077 ASSERT( NuclearChargeM1 < LIMELM );
1081 nDRFitPar[NuclearChargeM1][NumberElectrons] = 9;
1082 for(
long i=8; i>=0; i-- )
1085 --
nDRFitPar[NuclearChargeM1][NumberElectrons];
1091 for(
long i=0; i<9; i++ )
1092 DRFitParPart1[NuclearChargeM1][NumberElectrons][i] = par_C[i];
1098 fseek(ioDATA, 0, SEEK_SET);
1103 length_of_line = (int)strlen(chLine);
1104 if( count > data_begin_line[1] && length_of_line > 3 )
1112 sscanf(chLine,
"%i%i%i%i%lf%lf%lf%lf%lf%lf%lf%lf%lf",
1113 &NuclearCharge, &NumberElectrons, &M_state, &W_state, &par_E[0], &par_E[1], &par_E[2],
1114 &par_E[3], &par_E[4], &par_E[5], &par_E[6], &par_E[7], &par_E[8]);
1116 long int NuclearChargeM1 = NuclearCharge-1;
1118 if(M_state == 1 && NuclearChargeM1<LIMELM)
1120 ASSERT( NumberElectrons < LIMELM );
1121 ASSERT( NuclearChargeM1 < LIMELM );
1125 nDRFitPar[NuclearChargeM1][NumberElectrons] = 9;
1126 for(
long i=8; i>=0; i-- )
1129 --
nDRFitPar[NuclearChargeM1][NumberElectrons];
1135 for(
long i=0; i<
nDRFitPar[NuclearChargeM1][NumberElectrons]; i++ )
1136 DRFitParPart2[NuclearChargeM1][NumberElectrons][i] = par_E[i];
1145 for(
long nelem=0; nelem<
LIMELM; nelem++ )
1147 for(
int ion=0; ion<nelem+1;++ion )
1151 fprintf(ofp,
"%i %i %e %e %e %e %e %e %e %e %e\n",
1160 for(
long nelem=0; nelem<
LIMELM; nelem++ )
1162 for(
int ion=0; ion<nelem+1; ion++ )
1166 fprintf(ofp,
"%i %i %e %e %e %e %e %e %e %e %e\n",
1180 bool lgDRBadnellBothDefined =
true;
1181 for(
int nelem=0; nelem<
LIMELM; nelem++ )
1183 for(
int ion=0; ion<nelem+1; ion++ )
1192 fprintf(
ioQQQ,
"PROBLEM ion_recomb_Badnell first and second half of Badnell DR not consistent.\n");
1193 lgDRBadnellBothDefined =
false;
1198 if( !lgDRBadnellBothDefined )
1202 "DISASTER PROBLEM The DR data files are corrupted - part 1 and 2 do not agree.\n");
1203 fprintf(
ioQQQ,
" Start again with a fresh copy of the data directory\n" );
1208 chFilename =
"badnell_rr.dat";
1213 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioDATA ) == NULL )
1215 fprintf(
ioQQQ,
" DISASTER PROBLEM Badnell_rec_init could not read first line of badnell_rr.dat.\n");
1219 if( (chs =
strchr_s(chLine,
')'))==NULL )
1222 fprintf(
ioQQQ,
" DISASTER PROBLEM Badnell_rec_init data file incorrect format.\n");
1226 sscanf(chs,
"%4i%2i%2i", &yr, &mo, &dy);
1227 int rr_yr = 2011, rr_mo = 4, rr_dy = 12;
1228 if((yr != rr_yr)||(mo != rr_mo)||(dy != rr_dy))
1230 fprintf(
ioQQQ,
"DISASTER PROBLEM The version of %s I found (%i %i %i) is not the current version (%i %i %i).\n",
1231 chFilename, yr, mo, dy, rr_yr, rr_mo, rr_dy);
1232 fprintf(
ioQQQ,
" The line was as follows:\n %s\n", chLine );
1244 if(chLine[0] !=
'#')
1246 sscanf(chLine,
"%i%i%i%i%lf%lf%lf%lf%lf%lf",
1247 &NuclearCharge, &NumberElectrons, &M_state, &W_state, &temp_par[0], &temp_par[1],
1248 &temp_par[2], &temp_par[3], &temp_par[4], &temp_par[5]);
1249 long NuclearChargeM1 = NuclearCharge-1;
1251 if(M_state == 1 && NuclearChargeM1<LIMELM)
1253 ASSERT( NuclearChargeM1 < LIMELM );
1254 ASSERT( NumberElectrons <= LIMELM );
1259 RRFitPar[NuclearChargeM1][NumberElectrons][i] = temp_par[i];
1267 for(
long nelem=0; nelem<
LIMELM; nelem++ )
1269 for(
long ion=0; ion<nelem+1; ion++ )
1273 fprintf(ofp,
"%li %li %e %e %e %e %e %e\n",
1274 nelem, ion,
RRFitPar[nelem][ion][0],
1282 fprintf(ofp,
"total lines are %i ", count);
1290 enum {DEBUG_LOC=
false};
1296 for(
int ion=0; ion<=nelem; ++ion )
1302 for(
int ion=0; ion<=nelem; ++ion )
1328 for(
long nelem=0; nelem<
LIMELM; ++nelem )
1337 static double TeUsed = -1 , EdenUsed = -1.;
1351 for(
long ion=0; ion < nelem+1; ++ion )
1353 long int n_bnd_elec_before_recom ,
1354 n_bnd_elec_after_recom;
1356 n_bnd_elec_before_recom = nelem-ion;
1357 n_bnd_elec_after_recom = nelem-ion+1;
1372 n_bnd_elec_before_recom )) >= 0. )
1389 n_bnd_elec_after_recom ,
1397 n_bnd_elec_before_recom )) >= 0. )
1413 static const double Fe_Gu_c[9][6] = {
1414 { 2.50507e-11, 5.60226e-11, 1.85001e-10, 3.57495e-9, 1.66321e-7, 0. },
1415 { 9.19610e-11, 2.92460e-10, 1.02120e-9, 1.14852e-8, 3.25418e-7, 0. },
1416 { 9.02625e-11, 6.22962e-10, 5.77545e-9, 1.78847e-8, 3.40610e-7, 0. },
1417 { 9.04286e-12, 9.68148e-10, 4.83636e-9, 2.48159e-8, 3.96815e-7, 0. },
1418 { 6.77873e-10, 1.47252e-9, 5.31202e-9, 2.54793e-8, 3.47407e-7, 0. },
1419 { 1.29742e-9, 4.10172e-9, 1.23605e-8, 2.33615e-8, 2.97261e-7, 0. },
1420 { 8.78027e-10, 2.31680e-9, 3.49333e-9, 1.16927e-8, 8.18537e-8, 1.54740e-7 },
1421 { 2.23178e-10, 1.87313e-9, 2.86171e-9, 1.38575e-8, 1.17803e-7, 1.06251e-7 },
1422 { 2.17263e-10, 7.35929e-10, 2.81276e-9, 1.32411e-8, 1.15761e-7, 4.80389e-8 }
1425 static const double Fe_Gu_E[9][6] = {
1426 { 8.30501e-2, 8.52897e-1, 3.40225e0, 2.23053e1, 6.80367e1, 0. },
1427 { 1.44392e-1, 9.23999e-1, 5.45498e0, 2.04301e1, 7.06112e1, 0. },
1428 { 5.79132e-2, 1.27852e0, 3.22439e0, 1.79602e1, 6.96277e1, 0. },
1429 { 1.02421e-1, 1.79393e0, 4.83226e0, 1.91117e1, 6.80858e1, 0. },
1430 { 1.24630e-1, 6.86045e-1, 3.09611e0, 1.44023e1, 6.42820e1, 0. },
1431 { 1.34459e-1, 6.63028e-1, 2.61753e0, 1.30392e1, 6.10222e1, 0. },
1432 { 7.79748e-2, 5.35522e-1, 1.88407e0, 8.38459e0, 3.38613e1, 7.89706e1 },
1433 { 8.83019e-2, 6.12756e-1, 2.36035e0, 9.61736e0, 3.64467e1, 8.72406e1 },
1434 { 1.51322e-1, 5.63155e-1, 2.57013e0, 9.08166e0, 3.69528e1, 1.08067e2 }
1444 for(
long ion=0; ion<9; ion++ )
1450 for(
long i=0; i<6; i++ )
1462 static const double BadnelDR_RateSave[
LIMELM] =
1464 3.78e-13, 1.70e-12, 8.14e-12, 1.60e-11, 2.38e-11,
1465 6.42e-11, 5.97e-11, 1.47e-10, 1.11e-10, 3.26e-10,
1466 1.88e-10, 2.06e-10, 4.14e-10, 3.97e-10, 2.07e-10,
1467 2.46e-10, 3.38e-10, 3.15e-10, 9.70e-11, 6.49e-11,
1468 6.93e-10, 3.70e-10, 3.29e-11, 4.96e-11, 5.03e-11,
1469 2.91e-12, 4.62e-14, 0.00e+00, 0.00e+00, 0.00e+00
1471 for(
long nelem=0; nelem <
LIMELM; ++nelem )
1474 BadnelDR_RateSave[nelem] *
RecNoise[nelem] *
1481 for(
long ion=0; ion <
ipIRON+1; ++ion )
1492 for(
long nelem=0; nelem <
LIMELM; ++nelem )
1494 for(
long ion=0; ion < nelem+1; ++ion )
1509 for(
long ion=0; ion < nelem; ++ion )
1535 static bool lgRunOnce =
true;
1542 FILE *ioREC =
ioQQQ;
1545 fprintf(ioREC,
"\n\n##################################################\n");
1546 fprintf(ioREC,
"radiative recombination data sources \n" );
1548 for(
long loop=0;loop<30;loop+=10)
1551 for(
long ion=loop; ion<loop+10; ++ion )
1556 for(
long nelem=loop; nelem<
LIMELM; ++nelem )
1559 long limit =
MIN2(nelem+1,loop+10);
1560 for(
long ion=loop; ion<limit; ++ion )
1564 for(
long ion=limit; ion<loop+10; ++ion )
1571 fprintf(ioREC,
"\nRadiative recombination data sources\n");
1572 fprintf(ioREC,
"Bad06: Badnell, N., 2006, ApJ, 167, 334B\n");
1573 fprintf(ioREC,
"Verner: Verner & Ferland, 1996, ApJS, 103, 467\n");
1575 fprintf(ioREC,
"\n\n##################################################\n");
1576 fprintf(ioREC,
"Dielectronic recombination data sources \n" );
1578 for(
long loop=0;loop<30;loop+=10)
1581 for(
long ion=loop; ion<loop+10; ++ion )
1586 for(
long nelem=loop; nelem<
LIMELM; ++nelem )
1590 long limit =
MIN2(nelem+1,loop+10);
1591 for(
long ion=loop; ion<limit; ++ion )
1595 for(
long ion=limit; ion<loop+10; ++ion )
1602 fprintf(ioREC,
"\nDielectronic data sources\nBadWeb: Badnell web site http://amdpp.phys.strath.ac.uk/tamoc/DR/\n");
1603 fprintf(ioREC,
"Bad06D: Badnell, N., 2006, ApJ, 651, L73\n");
1604 fprintf(ioREC,
"GuPC: Gu, M. private communication\n");
1605 fprintf(ioREC,
"mean: DR recombination ion mean (see below)\n");
1606 fprintf(ioREC,
"mean+: DR recombination ion mean (see below) + Arnaud & Raymond 1992, ApJ, 398, 394 \n");
1616 for(
long ion=0; ion<nelem+1; ++ion )
1621 for(
long ion=0; ion<nelem+1; ++ion )
1636 fprintf(
ioQQQ,
"\n\nCollisSuppres finds following dielectronic"
1637 " recom suppression factors, Te=%10.3e eden=%10.3e\n",
1642 for(
long ion=0; ion < nelem; ++ion )
double ** DR_Badnell_rate_coef
double ** RR_Badnell_rate_coef
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
STATIC double Badnell_DR_rate_eval(int nAtomicNumberCScale, int n_core_e_before_recomb)
double DielecRecombVsTemp[NUM_DR_TEMPS]
NORETURN void TotalInsanity(void)
double ** RR_Verner_rate_coef
static double DR_Badnell_rate_coef_mean_ion[LIMELM]
long nMatch(const char *chKey, const char *chCard)
static bool ** lgDRBadnellDefinedPart2
static const int MAX_FIT_PAR_DR
static bool ** lgDRBadnellDefined
sys_float sexp(sys_float x)
bool lgRecom_Badnell_print
t_elementnames elementnames
t_iso_sp iso_sp[NISO][LIMELM]
static double RecNoise[LIMELM]
STATIC double CollisSuppres(long int atomic_number, long int ionic_charge, double eden, double T)
bool fp_equal(sys_float x, sys_float y, int n=3)
void Badnell_rec_init(void)
long int n_HighestResolved_max
static char chRRDataSource[LIMELM][LIMELM][10]
static double *** DRFitParPart1
double atmdat_dielrec_fe(long int ion, double t)
static char chDRDataSource[LIMELM][LIMELM][10]
double DR_mean_scale[LIMELM]
static bool lgMustMallocRec
const int INPUT_LINE_LENGTH
void ion_recom_calculate(void)
static double *** DRFitParPart2
double powi(double, long int)
const char * strchr_s(const char *s, int c)
static double *** RRFitPar
char chElementNameShort[LIMELM][CHARS_ELEMENT_NAME_SHORT]
double RandGauss(double xMean, double s)
multi_arr< long, 3 > QuantumNumbers2Index
static bool ** lgRRBadnellDefined
double rad_rec(long int iz, long int in, double t)
#define DEBUG_ENTRY(funcname)
double powpq(double x, int p, int q)
multi_arr< double, 2 > DR_Badnell_suppress_fact
int fprintf(const Output &stream, const char *format,...)
STATIC double Badnell_RR_rate_eval(int nAtomicNumberCScale, int n_core_e_before_recomb)
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
static bool ** lgDR_BadWeb_exist
double ** RR_rate_coef_used
static const int MAX_FIT_PAR_RR
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)