00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "cddefines.h"
00043 #include "cddrive.h"
00044 #include "thermal.h"
00045 #include "physconst.h"
00046 #include "doppvel.h"
00047 #include "taulines.h"
00048 #include "dense.h"
00049 #include "rfield.h"
00050 #include "radius.h"
00051 #include "lines_service.h"
00052 #include "ipoint.h"
00053 #include "thirdparty.h"
00054 #include "hydrogenic.h"
00055 #include "lines.h"
00056 #include "rt.h"
00057 #include "trace.h"
00058 #include "punch.h"
00059 #include "phycon.h"
00060 #include "atomfeii.h"
00061 #include "iso.h"
00062 #include "pressure.h"
00063
00064
00065 STATIC void FeIIOvrLap(void);
00066
00067
00068 STATIC void FeIIContCreate(double xLamLow , double xLamHigh , long int ncell );
00069
00070
00071
00072
00073
00074 STATIC int FeIIBandsCreate( const char chFile[] );
00075
00076
00077
00078
00079
00080
00081 realnum CS2SMALL = (realnum)1e-5;
00082
00083
00084
00085
00086
00087 STATIC void FeIICollRatesBoltzmann(void);
00088
00089 STATIC void FeIILyaPump(void);
00090
00091
00092
00093
00094
00095
00096
00097 int **ncs1;
00098
00099
00100
00101
00102
00103 #define NPRADDAT 159
00104
00105
00106
00107
00108
00109 realnum **FeII_Bands;
00110
00111
00112
00113
00114
00115 realnum **FeII_Cont;
00116
00117
00118 long int nFeIIBands;
00119
00120
00121 long int nFeIIConBins;
00122
00123
00124
00125
00126 static long int *nnPradDat;
00127
00128
00129
00130
00131 static realnum ***sPradDat;
00132
00133
00134
00135
00136 static double **Fe2SavN;
00137
00138
00139 static double **Fe2A;
00140
00141
00142 static double **Fe2LPump, **Fe2CPump;
00143
00144
00145 realnum *Fe2Energies;
00146
00147
00148 static realnum **Fe2Coll;
00149
00150
00151
00152
00153 static double
00154
00155 *Fe2DepCoef ,
00156
00157 *Fe2LevelPop ,
00158
00159 *Fe2ColDen ,
00160
00161 *FeIIBoltzmann;
00162
00163
00164 static double EnerLyaProf1,
00165 EnerLyaProf4,
00166 PhotOccNumLyaCenter;
00167 static double
00168
00169 *yVector,
00170
00171
00172 **xMatrix ,
00173
00174
00175 *amat;
00176
00177
00178
00179 void FeII_Colden( const char *chLabel )
00180 {
00181 long int n;
00182
00183 DEBUG_ENTRY( "FeII_Colden()" );
00184
00185
00186
00187
00188
00189
00190 if( strcmp(chLabel,"ZERO") == 0 )
00191 {
00192
00193 for( n=0; n < FeII.nFeIILevel; ++n )
00194 {
00195
00196 Fe2ColDen[n] = 0.;
00197 }
00198 }
00199
00200 else if( strcmp(chLabel,"ADD ") == 0 )
00201 {
00202
00203 for( n=0; n < FeII.nFeIILevel; ++n )
00204 {
00205
00206 Fe2ColDen[n] += Fe2LevelPop[n]*radius.drad_x_fillfac;
00207 }
00208 }
00209
00210
00211 else if( strcmp(chLabel,"PRIN") != 0 )
00212 {
00213 fprintf( ioQQQ, " FeII_Colden does not understand the label %s\n",
00214 chLabel );
00215 cdEXIT(EXIT_FAILURE);
00216 }
00217
00218 return;
00219 }
00220
00221
00222
00223
00224
00225
00226 void FeIICreate(void)
00227 {
00228 FILE *ioDATA;
00229
00230 char chLine[FILENAME_PATH_LENGTH_2];
00231
00232 long int i,
00233 ipHi ,
00234 ipLo,
00235 lo,
00236 ihi,
00237 k,
00238 m1,
00239 m2,
00240 m3;
00241
00242 DEBUG_ENTRY( "FeIICreate()" );
00243
00244 if( lgFeIIMalloc )
00245 {
00246
00247
00248 return;
00249 }
00250
00251
00252
00253
00254 lgFeIIMalloc = true;
00255
00256
00257
00258 FeII.nFeIILevelAlloc = FeII.nFeIILevel;
00259
00260
00261 Fe2A = (double **)MALLOC(sizeof(double *)*(unsigned long)FeII.nFeIILevelAlloc );
00262
00263
00264 for( ipHi=0; ipHi < FeII.nFeIILevelAlloc; ++ipHi )
00265 {
00266 Fe2A[ipHi]=(double*)MALLOC(sizeof(double )*(unsigned long)FeII.nFeIILevelAlloc);
00267 }
00268
00269
00270 Fe2CPump = (double **)MALLOC(sizeof(double *)*(unsigned long)FeII.nFeIILevelAlloc );
00271
00272
00273 Fe2LPump = (double **)MALLOC(sizeof(double *)*(unsigned long)FeII.nFeIILevelAlloc );
00274
00275
00276 for( ipHi=0; ipHi < FeII.nFeIILevelAlloc; ++ipHi )
00277 {
00278 Fe2CPump[ipHi]=(double*)MALLOC(sizeof(double )*(unsigned long)FeII.nFeIILevelAlloc);
00279
00280 Fe2LPump[ipHi]=(double*)MALLOC(sizeof(double )*(unsigned long)FeII.nFeIILevelAlloc);
00281 }
00282
00283
00284 Fe2Energies = (realnum *)MALLOC(sizeof(realnum)*(unsigned long)FeII.nFeIILevelAlloc );
00285
00286
00287 Fe2Coll = (realnum **)MALLOC(sizeof(realnum *)*(unsigned long)FeII.nFeIILevelAlloc );
00288
00289
00290 for( ipHi=0; ipHi < FeII.nFeIILevelAlloc; ++ipHi )
00291 {
00292 Fe2Coll[ipHi]=(realnum*)MALLOC(sizeof(realnum )*(unsigned long)FeII.nFeIILevelAlloc);
00293 }
00294
00295
00296 xMatrix = (double **)MALLOC(sizeof(double *)*(unsigned long)FeII.nFeIILevelAlloc );
00297
00298
00299 for( i=0; i<FeII.nFeIILevelAlloc; ++i )
00300 {
00301 xMatrix[i] = (double *)MALLOC(sizeof(double)*(unsigned long)FeII.nFeIILevelAlloc );
00302 }
00303
00304 amat=(double*)MALLOC( (sizeof(double)*(unsigned long)(FeII.nFeIILevelAlloc*FeII.nFeIILevelAlloc) ));
00305
00306
00307 yVector=(double*)MALLOC( (sizeof(double)*(unsigned long)(FeII.nFeIILevelAlloc) ));
00308
00309
00310 Fe2SavN = (double **)MALLOC(sizeof(double *)*(unsigned long)FeII.nFeIILevelAlloc );
00311
00312
00313 for( ipHi=1; ipHi < FeII.nFeIILevelAlloc; ++ipHi )
00314 {
00315 Fe2SavN[ipHi]=(double*)MALLOC(sizeof(double )*(unsigned long)ipHi);
00316 }
00317
00318
00319 nnPradDat = (long*)MALLOC( (NPRADDAT+1)*sizeof(long) );
00320
00321
00322 Fe2DepCoef = (double*)MALLOC( (unsigned long)FeII.nFeIILevelAlloc*sizeof(double) );
00323
00324
00325 Fe2LevelPop = (double*)MALLOC( (unsigned long)FeII.nFeIILevelAlloc*sizeof(double) );
00326
00327
00328 Fe2ColDen = (double*)MALLOC( (unsigned long)FeII.nFeIILevelAlloc*sizeof(double) );
00329
00330
00331 FeIIBoltzmann = (double*)MALLOC( (unsigned long)FeII.nFeIILevelAlloc*sizeof(double) );
00332
00333
00334
00335
00336 sPradDat = ((realnum ***)MALLOC(NPRADDAT*sizeof(realnum **)));
00337
00338
00339 sPradDat[0] = NULL;
00340 for(ipHi=1; ipHi < NPRADDAT; ipHi++)
00341 {
00342
00343 sPradDat[ipHi] = (realnum **)MALLOC((unsigned long)ipHi*sizeof(realnum *));
00344
00345
00346 for( ipLo=0; ipLo< ipHi; ipLo++ )
00347 {
00348 sPradDat[ipHi][ipLo] = (realnum *)MALLOC(8*sizeof(realnum ));
00349 }
00350 }
00351
00352
00353 for(ipHi=0; ipHi < NPRADDAT; ipHi++)
00354 {
00355 for( ipLo=0; ipLo< ipHi; ipLo++ )
00356 {
00357 for( k=0; k<8; ++k )
00358 {
00359 sPradDat[ipHi][ipLo][k] = -FLT_MAX;
00360 }
00361 }
00362 }
00363
00364
00365 Fe2LevN=(transition**)MALLOC(sizeof(transition *)*(unsigned long)FeII.nFeIILevelAlloc);
00366 ncs1=(int**)MALLOC(sizeof(int *)*(unsigned long)FeII.nFeIILevelAlloc);
00367
00368 for( ipHi=1; ipHi < FeII.nFeIILevelAlloc; ++ipHi )
00369 {
00370 Fe2LevN[ipHi]=(transition*)MALLOC(sizeof(transition)*(unsigned long)ipHi);
00371
00372 ncs1[ipHi]=(int*)MALLOC(sizeof(int)*(unsigned long)ipHi);
00373 }
00374
00375 #if 0
00376
00377 for( ipLo=0; ipLo < (FeII.nFeIILevelAlloc - 1); ipLo++ )
00378 {
00379 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
00380 {
00381 TransitionJunk( &Fe2LevN[ipHi][ipLo] );
00382 }
00383 }
00384 #endif
00385
00386
00387 Fe2LevN[1][0].Lo = AddState2Stack();
00388
00389 for( ipHi=1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
00390 {
00391
00392 Fe2LevN[ipHi][0].Hi = AddState2Stack();
00393 for( ipLo=0; ipLo < ipHi; ipLo++ )
00394 {
00395 if( ipLo == 0 )
00396 {
00397 Fe2LevN[ipHi][ipLo].Lo = Fe2LevN[1][0].Lo;
00398 }
00399 else
00400 {
00401
00402 Fe2LevN[ipHi][ipLo].Lo = Fe2LevN[ipLo][0].Hi;
00403 }
00404
00405 Fe2LevN[ipHi][ipLo].Hi = Fe2LevN[ipHi][0].Hi;
00406 Fe2LevN[ipHi][ipLo].Emis = AddLine2Stack( true );
00407 }
00408 }
00409
00410 if( trace.lgTrace )
00411 {
00412 fprintf( ioQQQ," FeIICreate opening fe2nn.dat:");
00413 }
00414
00415 ioDATA = open_data( "fe2nn.dat", "r" );
00416
00417 ASSERT( ioDATA !=NULL );
00418
00419
00420
00421
00422
00423
00424 for( i=0; i < 8; i++ )
00425 {
00426 if( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) == NULL )
00427 {
00428 fprintf( ioQQQ, " fe2nn.dat error reading data\n" );
00429 cdEXIT(EXIT_FAILURE);
00430 }
00431
00432
00433 k = 20*i;
00434
00435 ASSERT( k+19 < NPRADDAT+1 );
00436 sscanf( chLine ,
00437 "%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld%4ld",
00438 &nnPradDat[k+0], &nnPradDat[k+1], &nnPradDat[k+2], &nnPradDat[k+3], &nnPradDat[k+4],
00439 &nnPradDat[k+5], &nnPradDat[k+6], &nnPradDat[k+7], &nnPradDat[k+8], &nnPradDat[k+9],
00440 &nnPradDat[k+10],&nnPradDat[k+11], &nnPradDat[k+12],&nnPradDat[k+13],&nnPradDat[k+14],
00441 &nnPradDat[k+15],&nnPradDat[k+16], &nnPradDat[k+17],&nnPradDat[k+18],&nnPradDat[k+19]
00442 );
00443 # if !defined(NDEBUG)
00444 for( m1=0; m1<20; ++m1 )
00445 {
00446 ASSERT( nnPradDat[k+m1] >= 0 && nnPradDat[k+m1] <= NFE2LEVN );
00447 }
00448 # endif
00449 }
00450 fclose(ioDATA);
00451
00452
00453 if( trace.lgTrace )
00454 {
00455 fprintf( ioQQQ," FeIICreate opening fe2energies.dat:");
00456 }
00457
00458 ioDATA = open_data( "fe2energies.dat", "r" );
00459
00460
00461 for( ipHi=0; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
00462 {
00463
00464
00465 chLine[0] = '#';
00466 while( chLine[0] == '#' )
00467 {
00468 if( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) == NULL )
00469 {
00470 fprintf( ioQQQ, " fe2energies.dat error reading data\n" );
00471 cdEXIT(EXIT_FAILURE);
00472 }
00473 }
00474
00475
00476 double help;
00477 sscanf( chLine, "%lf", &help );
00478 Fe2Energies[ipHi] = (realnum)help;
00479 }
00480 fclose(ioDATA);
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491 if( trace.lgTrace )
00492 {
00493 fprintf( ioQQQ," FeIICreate opening fe2rad.dat:");
00494 }
00495
00496 ioDATA = open_data( "fe2rad.dat", "r" );
00497
00498
00499 if( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) == NULL )
00500 {
00501 fprintf( ioQQQ, " fe2rad.dat error reading data\n" );
00502 cdEXIT(EXIT_FAILURE);
00503 }
00504
00505 sscanf( chLine ,"%ld%ld%ld",&lo, &ihi, &m1);
00506 if( lo!=3 || ihi!=1 || m1!=28 )
00507 {
00508 fprintf( ioQQQ, " fe2rad.dat has the wrong magic numbers, expected 3 1 28\n" );
00509 cdEXIT(EXIT_FAILURE);
00510 }
00511
00512
00513 for( ipHi=1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
00514 {
00515 for( ipLo=0; ipLo < ipHi; ipLo++ )
00516 {
00517
00518 double save[2];
00519
00520
00521 chLine[0] = '#';
00522 while( chLine[0] == '#' )
00523 {
00524 if( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) == NULL )
00525 {
00526 fprintf( ioQQQ, " fe2nn.dat error reading data\n" );
00527 cdEXIT(EXIT_FAILURE);
00528 }
00529 }
00530
00531
00532 sscanf( chLine ,
00533 "%ld%ld%ld%ld%lf%lf%ld",
00534 &lo, &ihi, &m1, &m2 ,
00535 &save[0], &save[1] , &m3);
00536
00537
00538 Fe2LevN[ihi-1][lo-1].Lo->g = (realnum)m1;
00539 Fe2LevN[ihi-1][lo-1].Hi->g = (realnum)m2;
00540 Fe2LevN[ihi-1][lo-1].Emis->Aul = (realnum)save[0];
00541
00542 # define USE_OLD true
00543 if( USE_OLD )
00544 Fe2LevN[ihi-1][lo-1].EnergyWN = (realnum)save[1];
00545 else
00546 Fe2LevN[ihi-1][lo-1].EnergyWN = Fe2Energies[ihi-1]-Fe2Energies[lo-1];
00547 if( Fe2LevN[ihi-1][lo-1].Emis->Aul == 1e3f )
00548 {
00549
00550
00551
00552
00553 Fe2LevN[ihi-1][lo-1].Emis->gf = 1e-5f;
00554
00555 Fe2LevN[ihi-1][lo-1].Emis->Aul = Fe2LevN[ihi-1][lo-1].Emis->gf*(realnum)TRANS_PROB_CONST*
00556 POW2(Fe2LevN[ihi-1][lo-1].EnergyWN)*Fe2LevN[ihi-1][lo-1].Lo->g/Fe2LevN[ihi-1][lo-1].Hi->g;
00557
00558
00559 }
00560
00561
00562
00563
00564
00565 ncs1[ihi-1][lo-1] = (int)m3;
00566
00567
00568
00569
00570
00571
00572
00573 }
00574 }
00575 fclose(ioDATA);
00576
00577
00578
00579
00580
00581
00582
00583
00584 if( trace.lgTrace )
00585 {
00586 fprintf( ioQQQ," FeIICreate opening fe2col.dat:");
00587 }
00588
00589 ioDATA = open_data( "fe2col.dat", "r" );
00590
00591 ASSERT( ioDATA !=NULL);
00592 for( ipHi=1; ipHi<NPRADDAT; ++ipHi )
00593 {
00594 for( ipLo=0; ipLo<ipHi; ++ipLo )
00595 {
00596
00597 double save[8];
00598 if( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) == NULL )
00599 {
00600 fprintf( ioQQQ, " fe2col.dat error reading data\n" );
00601 cdEXIT(EXIT_FAILURE);
00602 }
00603 sscanf( chLine ,
00604 "%ld%ld%lf%lf%lf%lf%lf%lf%lf%lf",
00605 &m1, &m2,
00606 &save[0], &save[1] , &save[2],&save[3], &save[4] , &save[5],
00607 &save[6], &save[7]
00608 );
00609 for( k=0; k<8; ++k )
00610 {
00611
00612
00613
00614 sPradDat[m2-1][m1-1][k] = max(CS2SMALL , (realnum)save[k] );
00615 }
00616 }
00617 }
00618
00619 fclose( ioDATA );
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630 for( ipLo=0; ipLo < (FeII.nFeIILevelAlloc - 1); ipLo++ )
00631 {
00632 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
00633 {
00634
00635
00636 ASSERT( Fe2LevN[ipHi][ipLo].EnergyWN > 0. );
00637 ASSERT( Fe2LevN[ipHi][ipLo].Emis->Aul> 0. );
00638
00639
00640
00641
00642
00643 Fe2LevN[ipHi][ipLo].WLAng =
00644 (realnum)(1.0e8/
00645 Fe2LevN[ipHi][ipLo].EnergyWN/
00646 RefIndex( Fe2LevN[ipHi][ipLo].EnergyWN ));
00647
00648
00649 Fe2LevN[ipHi][ipLo].Emis->gf =
00650 (realnum)(Fe2LevN[ipHi][ipLo].Emis->Aul*Fe2LevN[ipHi][ipLo].Hi->g/
00651 TRANS_PROB_CONST/POW2(Fe2LevN[ipHi][ipLo].EnergyWN));
00652
00653 Fe2LevN[ipHi][ipLo].Hi->IonStg = 2;
00654 Fe2LevN[ipHi][ipLo].Hi->nelem = 26;
00655
00656
00657
00658
00659
00660
00661
00662
00663 if( ipLo == 0 )
00664 {
00665 Fe2LevN[ipHi][ipLo].Emis->iRedisFun = FeII.ipRedisFcnResonance;
00666 }
00667 else
00668 {
00669
00670
00671 Fe2LevN[ipHi][ipLo].Emis->iRedisFun = FeII.ipRedisFcnSubordinate;
00672 }
00673 Fe2LevN[ipHi][ipLo].Emis->phots = 0.;
00674 Fe2LevN[ipHi][ipLo].Emis->ots = 0.;
00675 Fe2LevN[ipHi][ipLo].Emis->FracInwd = 1.;
00676 }
00677 }
00678
00679
00680 if( FeIIBandsCreate("") )
00681 {
00682 fprintf( ioQQQ," failed to open FeII bands file \n");
00683 cdEXIT(EXIT_FAILURE);
00684 }
00685
00686
00687
00688
00689 FeIIContCreate( FeII.fe2con_wl1 , FeII.fe2con_wl2 , FeII.nfe2con );
00690
00691
00692 ASSERT( FeII.nFeIILevelAlloc == FeII.nFeIILevel );
00693
00694 return;
00695 }
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715 void FeIILevelPops( void )
00716 {
00717 long int i,
00718 ipHi ,
00719 ipLo ,
00720 n;
00721
00722 bool lgPopNeg;
00723
00724 double
00725 EnergyWN,
00726 pop ,
00727 sum;
00728
00729 int32 info;
00730 int32 ipiv[NFE2LEVN];
00731
00732 DEBUG_ENTRY( "FeIILevelPops()" );
00733
00734 if( trace.lgTrace )
00735 {
00736 fprintf( ioQQQ," FeIILevelPops fe2 pops called\n");
00737 }
00738
00739
00740
00741 if( FeII.lgSimulate )
00742 {
00743
00744 return;
00745 }
00746
00747
00748 for( n=0; n<FeII.nFeIILevel; ++n)
00749 {
00750 for( ipLo=0; ipLo<FeII.nFeIILevel; ++ipLo )
00751 {
00752 Fe2CPump[ipLo][n] = 0.;
00753 Fe2LPump[ipLo][n] = 0.;
00754 Fe2A[ipLo][n] = 0.;
00755 xMatrix[ipLo][n] = 0.;
00756 }
00757 }
00758
00759
00760
00761
00762 FeIICollRatesBoltzmann();
00763
00764
00765 for( n=0; n<FeII.nFeIILevel; ++n)
00766 {
00767 for( ipHi=n+1; ipHi<FeII.nFeIILevel; ++ipHi )
00768 {
00769
00770 Fe2CPump[n][ipHi] = Fe2LevN[ipHi][n].Emis->pump;
00771
00772
00773 Fe2CPump[ipHi][n] = Fe2LevN[ipHi][n].Emis->pump*
00774 Fe2LevN[ipHi][n].Hi->g/Fe2LevN[ipHi][n].Lo->g;
00775
00776
00777 Fe2A[ipHi][n] = Fe2LevN[ipHi][n].Emis->Aul*(Fe2LevN[ipHi][n].Emis->Pesc + Fe2LevN[ipHi][n].Emis->Pelec_esc +
00778 Fe2LevN[ipHi][n].Emis->Pdest);
00779 }
00780 }
00781
00782
00783 FeIILyaPump();
00784
00785
00786
00787
00788
00789
00790
00791
00792 for( n=0; n<FeII.nFeIILevel; ++n)
00793 {
00794
00795 for( ipLo=0; ipLo<n; ++ipLo )
00796 {
00797 xMatrix[n][n] = xMatrix[n][n] + Fe2CPump[n][ipLo] + Fe2LPump[n][ipLo]+ Fe2A[n][ipLo] +
00798 Fe2Coll[n][ipLo]*dense.eden;
00799 }
00800
00801 for( ipHi=n+1; ipHi<FeII.nFeIILevel; ++ipHi )
00802 {
00803 xMatrix[n][n] = xMatrix[n][n] + Fe2CPump[n][ipHi] + Fe2LPump[n][ipHi] + Fe2Coll[n][ipHi]*dense.eden;
00804 }
00805
00806 for( ipLo=0; ipLo<n; ++ipLo )
00807 {
00808 xMatrix[ipLo][n] = xMatrix[ipLo][n] - Fe2CPump[ipLo][n] - Fe2LPump[ipLo][n] - Fe2Coll[ipLo][n]*dense.eden;
00809 }
00810
00811 for( ipHi=n+1; ipHi<FeII.nFeIILevel; ++ipHi )
00812 {
00813 xMatrix[ipHi][n] = xMatrix[ipHi][n] - Fe2CPump[ipHi][n] - Fe2LPump[ipHi][n] - Fe2Coll[ipHi][n]*dense.eden -
00814 Fe2A[ipHi][n];
00815 }
00816
00817
00818 xMatrix[n][0] = 1.0;
00819 }
00820
00821 {
00822
00823 enum {DEBUG_LOC=false};
00824 if( DEBUG_LOC )
00825 {
00826
00827 for( n=0; n<FeII.nFeIILevel; ++n)
00828 {
00829
00830
00831 for( ipLo=0; ipLo<FeII.nFeIILevel; ++ipLo )
00832 {
00833 fprintf(ioQQQ," %.1e", xMatrix[n][ipLo]);
00834 }
00835 fprintf(ioQQQ,"\n");
00836 }
00837 }
00838 }
00839
00840
00841
00842
00843 yVector[0] = 1.0;
00844 for( n=1; n < FeII.nFeIILevel; n++ )
00845 {
00846 yVector[n] = 0.0;
00847 }
00848
00849
00850
00851 # ifdef AMAT
00852 # undef AMAT
00853 # endif
00854 # define AMAT(I_,J_) (*(amat+(I_)*FeII.nFeIILevel+(J_)))
00855
00856
00857 for( ipHi=0; ipHi < FeII.nFeIILevel; ipHi++ )
00858 {
00859 for( i=0; i < FeII.nFeIILevel; i++ )
00860 {
00861 AMAT(i,ipHi) = xMatrix[i][ipHi];
00862 }
00863 }
00864
00865 info = 0;
00866
00867
00868 getrf_wrapper(FeII.nFeIILevel, FeII.nFeIILevel, amat, FeII.nFeIILevel, ipiv, &info);
00869 getrs_wrapper('N', FeII.nFeIILevel, 1, amat, FeII.nFeIILevel, ipiv, yVector, FeII.nFeIILevel, &info);
00870
00871 if( info != 0 )
00872 {
00873 fprintf( ioQQQ, "DISASTER FeIILevelPops: dgetrs finds singular or ill-conditioned matrix\n" );
00874 cdEXIT(EXIT_FAILURE);
00875 }
00876
00877
00878
00879
00880 lgPopNeg = false;
00881
00882 for( ipLo=0; ipLo < FeII.nFeIILevel; ipLo++ )
00883 {
00884 if(yVector[ipLo] < 0. )
00885 {
00886 lgPopNeg = true;
00887 fprintf(ioQQQ,"PROBLEM FeIILevelPops finds non-positive level population, level is %ld pop is %g\n",
00888 ipLo , yVector[ipLo] );
00889 }
00890
00891 Fe2LevelPop[ipLo] = yVector[ipLo] * dense.xIonDense[ipIRON][1];
00892 }
00893 if( lgPopNeg )
00894 {
00895
00896
00897 fprintf(ioQQQ , "PROBLEM FeIILevelPops exits with negative level populations.\n");
00898 }
00899
00900
00901
00902
00903
00904 for( ipLo=FeII.nFeIILevel; ipLo < FeII.nFeIILevelAlloc; ++ipLo )
00905 {
00906 Fe2LevelPop[ipLo] = 0.;
00907 }
00908
00909
00910
00911
00912 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
00913 {
00914
00915
00916
00917 for( ipHi=ipLo+1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
00918 {
00919
00920
00921
00922
00923 Fe2LevN[ipHi][ipLo].Emis->PopOpc = (Fe2LevelPop[ipLo] -
00924 Fe2LevelPop[ipHi]*Fe2LevN[ipHi][ipLo].Lo->g/Fe2LevN[ipHi][ipLo].Hi->g);
00925
00926 Fe2LevN[ipHi][ipLo].Lo->Pop = Fe2LevelPop[ipLo];
00927
00928 Fe2LevN[ipHi][ipLo].Hi->Pop = Fe2LevelPop[ipHi];
00929
00930 Fe2LevN[ipHi][ipLo].Emis->phots = Fe2LevelPop[ipHi]*
00931 Fe2LevN[ipHi][ipLo].Emis->Aul*(Fe2LevN[ipHi][ipLo].Emis->Pesc + Fe2LevN[ipHi][ipLo].Emis->Pelec_esc );
00932
00933 Fe2LevN[ipHi][ipLo].Emis->xIntensity = Fe2LevN[ipHi][ipLo].Emis->phots*
00934 Fe2LevN[ipHi][ipLo].EnergyErg;
00935
00936
00937
00938 Fe2LevN[ipHi][ipLo].Emis->ColOvTot = (realnum)(Fe2Coll[ipLo][ipHi]*dense.eden /
00939 SDIV( Fe2Coll[ipLo][ipHi]*dense.eden + Fe2CPump[ipLo][ipHi] + Fe2LPump[ipLo][ipHi] ) );
00940 }
00941 }
00942
00943
00944
00945 if( FeII.lgFeIILargeOn )
00946 {
00947
00948 hydro.dstfe2lya = 0.;
00949 EnergyWN = 0.;
00950
00951 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
00952 {
00953 for( ipHi=ipLo+1; ipHi < FeII.nFeIILevel; ipHi++ )
00954 {
00955 EnergyWN += Fe2LPump[ipLo][ipHi] + Fe2LPump[ipHi][ipLo];
00956 hydro.dstfe2lya += (realnum)(
00957 Fe2LevN[ipHi][ipLo].Lo->Pop*Fe2LPump[ipLo][ipHi] -
00958 Fe2LevN[ipHi][ipLo].Hi->Pop*Fe2LPump[ipHi][ipLo]);
00959 }
00960 }
00961
00962
00963 pop = StatesElem[ipH_LIKE][ipHYDROGEN][ipH2p].Pop*dense.xIonDense[ipHYDROGEN][1];
00964 if( pop > SMALLFLOAT )
00965 {
00966 hydro.dstfe2lya /= (realnum)(pop * Transitions[ipH_LIKE][ipHYDROGEN][ipH2p][ipH1s].Emis->Aul);
00967 }
00968 else
00969 {
00970 hydro.dstfe2lya = 0.;
00971 }
00972
00973
00974 }
00975
00976 {
00977 enum {DEBUG_LOC=false};
00978 if( DEBUG_LOC)
00979 {
00980
00981 fprintf(ioQQQ," sum all %.1e dest rate%.1e escR= %.1e\n",
00982 EnergyWN,hydro.dstfe2lya,
00983 Transitions[ipH_LIKE][ipHYDROGEN][ipH2p][ipH1s].Emis->Pesc);
00984
00985 }
00986 }
00987
00988
00989
00990
00991 Fe2DepCoef[0] = 1.0;
00992 sum = 1.0;
00993 for( i=1; i < FeII.nFeIILevel; i++ )
00994 {
00995
00996 Fe2DepCoef[i] = Fe2DepCoef[0]*FeIIBoltzmann[i]*
00997 Fe2LevN[i][0].Hi->g/ Fe2LevN[1][0].Lo->g;
00998
00999 sum += Fe2DepCoef[i];
01000 }
01001
01002
01003 for( i=0; i < FeII.nFeIILevel; i++ )
01004 {
01005
01006
01007 Fe2DepCoef[i] /= sum;
01008
01009
01010 if( Fe2DepCoef[i]>SMALLFLOAT )
01011 {
01012 Fe2DepCoef[i] = yVector[i]/Fe2DepCoef[i];
01013 }
01014 else
01015 {
01016 Fe2DepCoef[i] = 0.;
01017 }
01018 }
01019
01020
01021
01022 FeII.Fe2_large_cool = 0.0f;
01023
01024 FeII.Fe2_large_heat = 0.f;
01025
01026 FeII.ddT_Fe2_large_cool = 0.0f;
01027
01028
01029 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01030 {
01031 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
01032 {
01033 double OneLine;
01034
01035
01036 OneLine = (Fe2Coll[ipLo][ipHi]*Fe2LevelPop[ipLo] - Fe2Coll[ipHi][ipLo]*Fe2LevelPop[ipHi])*
01037 dense.eden*Fe2LevN[ipHi][ipLo].EnergyErg;
01038
01039
01040 FeII.Fe2_large_cool += (realnum)MAX2(0., OneLine);
01041
01042
01043 FeII.Fe2_large_heat += (realnum)MAX2(0., -OneLine);
01044
01045
01046 if( OneLine >= 0. )
01047 {
01048
01049 FeII.ddT_Fe2_large_cool += (realnum)OneLine*
01050 (Fe2LevN[ipHi][0].EnergyK*thermal.tsq1 - thermal.halfte);
01051 }
01052 else
01053 {
01054
01055 FeII.ddT_Fe2_large_cool -= (realnum)OneLine*thermal.halfte;
01056 }
01057 }
01058 }
01059
01060 return;
01061 }
01062
01063
01064
01065
01066
01067
01068 STATIC void FeIICollRatesBoltzmann(void)
01069 {
01070
01071 static double OldTemp = -1.;
01072 long int i,
01073 ipLo ,
01074 ipHi,
01075 ipTrim;
01076 realnum ag,
01077 cg,
01078 dg,
01079 gb,
01080 y;
01081 realnum FracLowTe , FracHighTe;
01082 static realnum tt[8]={1e3f,3e3f,5e3f,7e3f,1e4f,12e3f,15e3f,2e4f};
01083 long int ipTemp,
01084 ipTempp1 ,
01085 ipLoFe2,
01086 ipHiFe2;
01087 static long int nFeII_old = -1;
01088
01089 DEBUG_ENTRY( "FeIICollRatesBoltzmann()" );
01090
01091
01092
01093 if( fp_equal( phycon.te, OldTemp ) && FeII.nFeIILevel == nFeII_old )
01094 {
01095
01096 return;
01097 }
01098 OldTemp = phycon.te;
01099 nFeII_old = FeII.nFeIILevel;
01100
01101
01102
01103
01104 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01105 {
01106 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
01107 {
01108
01109 if( ncs1[ipHi][ipLo] == 3 )
01110 {
01111
01112 ag = 0.15f;
01113 cg = 0.f;
01114 dg = 0.f;
01115 }
01116
01117 else if( ncs1[ipHi][ipLo] == 1 )
01118 {
01119 ag = 0.6f;
01120 cg = 0.f;
01121 dg = 0.28f;
01122 }
01123
01124 else if( ncs1[ipHi][ipLo] == 2 )
01125 {
01126 ag = 0.0f;
01127 cg = 0.1f;
01128 dg = 0.0f;
01129 }
01130 else
01131 {
01132
01133 ag = 0.0f;
01134 cg = 0.1f;
01135 dg = 0.0f;
01136 fprintf(ioQQQ,">>>PROBLEM impossible ncs1 in FeIILevelPops\n");
01137 }
01138
01139
01140 y = Fe2LevN[ipHi][ipLo].EnergyWN/ (realnum)phycon.te_wn;
01141
01142 gb = (realnum)(ag + (-cg*POW2(y) + dg)*(log(1.0+1.0/y) - 0.4/
01143 POW2(y + 1.0)) + cg*y);
01144
01145 Fe2LevN[ipHi][ipLo].Coll.cs = 23.861f*1e5f*gb*
01146 Fe2LevN[ipHi][ipLo].Emis->Aul*Fe2LevN[ipHi][ipLo].Hi->g/
01147 POW3(Fe2LevN[ipHi][ipLo].EnergyWN);
01148
01149
01150 ASSERT( Fe2LevN[ipHi][ipLo].Coll.cs > 0.);
01151
01152
01153
01154 Fe2LevN[ipHi][ipLo].Coll.cs = MAX2( CS2SMALL, Fe2LevN[ipHi][ipLo].Coll.cs);
01155
01156
01157
01158
01159
01160
01161
01162 }
01163 }
01164
01165
01166
01167
01168 if( phycon.te <= tt[0] )
01169 {
01170
01171
01172
01173
01174 ipTemp = 0;
01175 ipTempp1 = 0;
01176 FracHighTe = 0.;
01177 }
01178 else if( phycon.te > tt[7] )
01179 {
01180
01181
01182
01183
01184 ipTemp = 7;
01185 ipTempp1 = 7;
01186 FracHighTe = 0.;
01187 }
01188 else
01189 {
01190
01191 ipTemp = -1;
01192 for( i=0; i < 8-1; i++ )
01193 {
01194 if( phycon.te <= tt[i+1] )
01195 {
01196 ipTemp = i;
01197 break;
01198 }
01199
01200 }
01201
01202 if( ipTemp < 0 )
01203 {
01204 fprintf( ioQQQ, " Insanity while looking for temperature in coll str array, te=%g.\n",
01205 phycon.te );
01206 cdEXIT(EXIT_FAILURE);
01207 }
01208
01209
01210 ipTemp = i;
01211 ipTempp1 = i+1;
01212 FracHighTe = ((realnum)phycon.te - tt[ipTemp])/(tt[ipTempp1] - tt[ipTemp]);
01213 }
01214
01215
01216
01217 FracLowTe = 1.f - FracHighTe;
01218
01219 for( ipHi=1; ipHi < NPRADDAT; ipHi++ )
01220 {
01221 for( ipLo=0; ipLo < ipHi; ipLo++ )
01222 {
01223
01224
01225 ipHiFe2 = MAX2( nnPradDat[ipHi] , nnPradDat[ipLo] );
01226 ipLoFe2 = MIN2( nnPradDat[ipHi] , nnPradDat[ipLo] );
01227 ASSERT( ipHiFe2-1 < NFE2LEVN );
01228 ASSERT( ipHiFe2-1 >= 0 );
01229 ASSERT( ipLoFe2-1 < NFE2LEVN );
01230 ASSERT( ipLoFe2-1 >= 0 );
01231
01232
01233 if( ipHiFe2-1 < FeII.nFeIILevel )
01234 {
01235
01236
01237 Fe2LevN[ipHiFe2-1][ipLoFe2-1].Coll.cs =
01238 sPradDat[ipHi][ipLo][ipTemp] * FracLowTe +
01239 sPradDat[ipHi][ipLo][ipTempp1] * FracHighTe;
01240
01241
01242
01243 ASSERT( Fe2LevN[ipHiFe2-1][ipLoFe2-1].Coll.cs > 0. );
01244 }
01245 }
01246 }
01247
01248
01249 FeIIBoltzmann[0] = 1.0;
01250 for( ipHi=1; ipHi < FeII.nFeIILevel; ipHi++ )
01251 {
01252
01253
01254
01255
01256 FeIIBoltzmann[ipHi] = dsexp( Fe2LevN[ipHi][0].EnergyWN/phycon.te_wn );
01257 }
01258
01259
01260 ipTrim = FeII.nFeIILevel - 1;
01261 while( FeIIBoltzmann[ipTrim] == 0. && ipTrim > 0 )
01262 {
01263 --ipTrim;
01264 }
01265
01266
01267
01268
01269 ASSERT( ipTrim > 0 );
01270
01271
01272
01273 if( ipTrim+1 < FeII.nFeIILevel )
01274 {
01275
01276 for( ipLo=0; ipLo<FeII.nFeIILevel; ++ipLo )
01277 {
01278 for( ipHi=ipTrim; ipHi<FeII.nFeIILevel; ++ipHi )
01279 {
01280 Fe2Coll[ipLo][ipHi] = 0.;
01281 Fe2Coll[ipHi][ipLo] = 0.;
01282 }
01283 }
01284 }
01285 FeII.nFeIILevel = ipTrim+1;
01286
01287
01288
01289 {
01290 enum {DEBUG_LOC=false};
01291 if( DEBUG_LOC)
01292 {
01293 for( ipLo=0; ipLo < 52; ipLo++ )
01294 {
01295 fprintf(ioQQQ,"%e %e\n",
01296 Fe2LevN[51][ipLo].Coll.cs,Fe2LevN[52][ipLo].Coll.cs);
01297 }
01298 cdEXIT(EXIT_FAILURE);
01299 }
01300 }
01301
01302
01303 for( ipLo=0; ipLo<FeII.nFeIILevel; ++ipLo)
01304 {
01305 for( ipHi=ipLo+1; ipHi<FeII.nFeIILevel; ++ipHi )
01306 {
01307
01308
01309
01310 Fe2Coll[ipHi][ipLo] = (realnum)(COLL_CONST/phycon.sqrte*Fe2LevN[ipHi][ipLo].Coll.cs/
01311 Fe2LevN[ipHi][ipLo].Hi->g);
01312
01313
01314
01315
01316
01317 Fe2Coll[ipLo][ipHi] = (realnum)(Fe2Coll[ipHi][ipLo]*FeIIBoltzmann[ipHi]/FeIIBoltzmann[ipLo]*
01318 Fe2LevN[ipHi][ipLo].Hi->g/Fe2LevN[ipHi][ipLo].Lo->g);
01319
01320 }
01321 }
01322
01323 return;
01324 }
01325
01326
01327
01328
01329
01330
01331
01332
01333 void FeIIPrint(void)
01334 {
01335
01336 DEBUG_ENTRY( "FeIIPrint()" );
01337
01338 return;
01339 }
01340
01341
01342
01343
01344
01345
01346
01347
01348 double FeIISumBand(
01349
01350 realnum wl1,
01351 realnum wl2)
01352 {
01353 long int ipHi,
01354 ipLo;
01355 double SumBandFe2_v;
01356
01357
01358
01359
01360 DEBUG_ENTRY( "FeIISumBand()" );
01361
01362
01363 if( dense.xIonDense[ipIRON][1] == 0. )
01364 {
01365
01366 return( 0. );
01367 }
01368 else
01369 {
01370
01371 SumBandFe2_v = 0.;
01372
01373
01374
01375
01376
01377
01378
01379 # if 0
01380
01381 ahi = 1.99e-8f/wl1;
01382 alo = 1.99e-8f/wl2;
01383 ASSERT( ahi > alo );
01384 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01385 {
01386 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
01387 {
01388 if( Fe2LevN[ipHi][ipLo].EnergyErg >= alo &&
01389 Fe2LevN[ipHi][ipLo].EnergyErg <= ahi )
01390 SumBandFe2_v += Fe2LevN[ipHi][ipLo].Emis->xIntensity;
01391 }
01392 }
01393 # endif
01394
01395
01396
01397 ASSERT( wl2 > wl1 );
01398 for( ipHi=1; ipHi < FeII.nFeIILevel; ++ipHi )
01399 {
01400 for( ipLo=0; ipLo < ipHi; ++ipLo )
01401 {
01402 if( Fe2LevN[ipHi][ipLo].WLAng >= wl1 &&
01403 Fe2LevN[ipHi][ipLo].WLAng < wl2 )
01404 SumBandFe2_v += Fe2LevN[ipHi][ipLo].Emis->xIntensity;
01405 }
01406 }
01407
01408 return( SumBandFe2_v );
01409 }
01410 }
01411
01412
01413
01414
01415
01416 void FeII_RT_TauInc(void)
01417 {
01418 long int ipHi,
01419 ipLo;
01420
01421 DEBUG_ENTRY( "FeII_RT_TauInc()" );
01422
01423 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01424 {
01425
01426
01427
01428
01429 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
01430 {
01431
01432 if( Fe2LevN[ipHi][ipLo].ipCont > 0 )
01433 RT_line_one_tauinc( &Fe2LevN[ipHi][ipLo] ,
01434 -8 , -8 , ipHi , ipLo );
01435 }
01436 }
01437
01438 return;
01439 }
01440
01441
01442
01443
01444
01445 void FeII_RT_tau_reset(void)
01446 {
01447 long int ipHi,
01448 ipLo;
01449
01450 DEBUG_ENTRY( "FeII_RT_tau_reset()" );
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461 for( ipHi=1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
01462 {
01463 for( ipLo=0; ipLo < ipHi; ipLo++ )
01464 {
01465 RT_line_one_tau_reset( &Fe2LevN[ipHi][ipLo],0.5 );
01466 }
01467 }
01468
01469
01470
01471
01472
01473
01474 FeIIOvrLap();
01475
01476
01477
01478
01479
01480 return;
01481 }
01482
01483
01484
01485
01486
01487 void FeIIPoint(void)
01488 {
01489 long int ipHi,
01490 ip,
01491 ipLo;
01492
01493 DEBUG_ENTRY( "FeIIPoint()" );
01494
01495
01496
01497 for( ipLo=0; ipLo < FeII.nFeIILevel-1; ipLo++ )
01498 {
01499 for( ipHi=ipLo+1; ipHi < FeII.nFeIILevel; ipHi++ )
01500 {
01501
01502
01503 if( fabs(Fe2LevN[ipHi][ipLo].Emis->Aul- 1e-5 ) > 1e-8 )
01504 {
01505 ip = ipoint(Fe2LevN[ipHi][ipLo].EnergyWN * WAVNRYD);
01506 Fe2LevN[ipHi][ipLo].ipCont = ip;
01507
01508
01509 if( strcmp( rfield.chLineLabel[ip-1], " " ) == 0 )
01510 strcpy( rfield.chLineLabel[ip-1], "FeII" );
01511
01512 Fe2LevN[ipHi][ipLo].Emis->ipFine = ipFineCont( Fe2LevN[ipHi][ipLo].EnergyWN * WAVNRYD);
01513 }
01514 else
01515 {
01516 Fe2LevN[ipHi][ipLo].ipCont = -1;
01517 Fe2LevN[ipHi][ipLo].Emis->ipFine = -1;
01518 }
01519
01520 Fe2LevN[ipHi][ipLo].Emis->dampXvel =
01521 (realnum)(Fe2LevN[ipHi][ipLo].Emis->Aul/
01522 Fe2LevN[ipHi][ipLo].EnergyWN/PI4);
01523
01524
01525 Fe2LevN[ipHi][ipLo].Emis->opacity =
01526 (realnum)abscf(Fe2LevN[ipHi][ipLo].Emis->gf,
01527 Fe2LevN[ipHi][ipLo].EnergyWN,
01528 Fe2LevN[ipHi][ipLo].Lo->g);
01529
01530
01531 Fe2LevN[ipHi][ipLo].EnergyK =
01532 (realnum)(T1CM*Fe2LevN[ipHi][ipLo].EnergyWN);
01533
01534
01535 Fe2LevN[ipHi][ipLo].EnergyErg =
01536 (realnum)(ERG1CM*Fe2LevN[ipHi][ipLo].EnergyWN);
01537 }
01538 }
01539
01540 return;
01541 }
01542
01543
01544
01545
01546
01547 void FeIIAccel(double *fe2drive)
01548 {
01549 long int ipHi,
01550 ipLo;
01551
01552 DEBUG_ENTRY( "FeIIAccel()" );
01553
01554
01555
01556
01557
01558 *fe2drive = 0.;
01559 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01560 {
01561 for( ipHi=ipLo+1; ipHi < FeII.nFeIILevel; ipHi++ )
01562 {
01563 *fe2drive += Fe2LevN[ipHi][ipLo].Emis->pump*
01564 Fe2LevN[ipHi][ipLo].EnergyErg*Fe2LevN[ipHi][ipLo].Emis->PopOpc;
01565 }
01566 }
01567
01568 return;
01569 }
01570
01571
01572
01573
01574
01575 void FeII_RT_Make( bool lgDoEsc , bool lgUpdateFineOpac )
01576 {
01577 long int ipHi,
01578 ipLo;
01579
01580 DEBUG_ENTRY( "FeII_RT_Make()" );
01581
01582 if( trace.lgTrace )
01583 {
01584 fprintf( ioQQQ," FeII_RT_Make called\n");
01585 }
01586
01587
01588 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01589 {
01590
01591
01592 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
01593 {
01594
01595 if( Fe2LevN[ipHi][ipLo].ipCont > 0 )
01596 {
01597
01598
01599 RT_line_one( &Fe2LevN[ipHi][ipLo] , lgDoEsc , lgUpdateFineOpac,true);
01600 }
01601 }
01602 }
01603
01604 return;
01605 }
01606
01607
01608
01609
01610
01611 void FeIIAddLines( void )
01612 {
01613 long int ipHi,
01614 ipLo;
01615
01616 DEBUG_ENTRY( "FeIIAddLines()" );
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626 if( LineSave.ipass == 0 )
01627 {
01628
01629 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01630 {
01631 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
01632 {
01633 Fe2SavN[ipHi][ipLo] = 0.;
01634 }
01635 }
01636 }
01637
01638
01639 else if( LineSave.ipass == 1 )
01640 {
01641
01642 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01643 {
01644 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
01645 {
01646 Fe2SavN[ipHi][ipLo] +=
01647 radius.dVeff*Fe2LevN[ipHi][ipLo].Emis->xIntensity;
01648 }
01649 }
01650 }
01651
01652 {
01653 enum {DEBUG_LOC=false};
01654 if( DEBUG_LOC )
01655 {
01656 fprintf(ioQQQ," 69-1\t%li\t%e\n", nzone , Fe2SavN[68][0] );
01657 }
01658 }
01659
01660 return;
01661 }
01662
01663
01664 void FeIIPunchLevels(
01665
01666 FILE *ioPUN )
01667 {
01668
01669 long int ipHi;
01670
01671 DEBUG_ENTRY( "FeIIPunchLevels()" );
01672
01673 fprintf(ioPUN , "%.2f\t%li\n", 0., (long)Fe2LevN[1][0].Lo->g );
01674 for( ipHi=1; ipHi < FeII.nFeIILevel; ++ipHi )
01675 {
01676 fprintf(ioPUN , "%.2f\t%li\n",
01677 Fe2LevN[ipHi][0].EnergyWN ,
01678 (long)Fe2LevN[ipHi][0].Hi->g);
01679 }
01680
01681 return;
01682 }
01683
01684
01685 void FeIIPunchColden(
01686
01687 FILE *ioPUN )
01688 {
01689
01690 long int n;
01691
01692 DEBUG_ENTRY( "FeIIPunchColden()" );
01693
01694 fprintf(ioPUN , "%.2f\t%li\t%.3e\n", 0., (long)Fe2LevN[1][0].Lo->g , Fe2ColDen[0]);
01695 for( n=1; n < FeII.nFeIILevel; ++n )
01696 {
01697 fprintf(ioPUN , "%.2f\t%li\t%.3e\n",
01698 Fe2LevN[n][0].EnergyWN ,
01699 (long)Fe2LevN[n][0].Hi->g,
01700 Fe2ColDen[n]);
01701 }
01702
01703 return;
01704 }
01705
01706
01707
01708
01709
01710 void FeIIPunchOpticalDepth(
01711
01712 FILE *ioPUN )
01713 {
01714 long int
01715 ipHi,
01716 ipLo;
01717
01718 DEBUG_ENTRY( "FeIIPunchOpticalDepth()" );
01719
01720
01721
01722
01723 for( ipLo=0; ipLo < (FeII.nFeIILevelAlloc - 1); ipLo++ )
01724 {
01725 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
01726 {
01727
01728
01729
01730
01731 fprintf( ioPUN, "%ld\t%ld\t%.2f\t%.2e\n",
01732 ipHi+1,
01733 ipLo+1,
01734 Fe2LevN[ipHi][ipLo].WLAng ,
01735 Fe2LevN[ipHi][ipLo].Emis->TauIn );
01736 }
01737 }
01738
01739 return;
01740 }
01741
01742
01743
01744
01745 void FeIIPunchLines(
01746
01747 FILE *ioPUN )
01748 {
01749 long int MaseHi,
01750 MaseLow,
01751 ipHi,
01752 ipLo;
01753 double hbeta, absint , renorm;
01754
01755 realnum TauMase,
01756 thresh;
01757
01758 DEBUG_ENTRY( "FeIIPunchLines()" );
01759
01760
01761
01762
01763
01764 if( LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent] > 0. )
01765 {
01766 renorm = LineSave.ScaleNormLine/LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent];
01767 }
01768 else
01769 {
01770 renorm = 1.;
01771 }
01772
01773 fprintf( ioPUN, " up low log I, I/I(LineSave), Tau\n" );
01774
01775
01776 MaseLow = -1;
01777 MaseHi = -1;
01778 TauMase = 0.f;
01779 for( ipLo=0; ipLo < (FeII.nFeIILevelAlloc - 1); ipLo++ )
01780 {
01781 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
01782 {
01783 if( Fe2LevN[ipHi][ipLo].Emis->TauIn < TauMase )
01784 {
01785 TauMase = Fe2LevN[ipHi][ipLo].Emis->TauIn;
01786 MaseLow = ipLo;
01787 MaseHi = ipHi;
01788 }
01789 }
01790 }
01791
01792 if( TauMase < 0.f )
01793 {
01794 fprintf( ioPUN, " Most negative optical depth was %4ld%4ld%10.2e\n",
01795 MaseHi, MaseLow, TauMase );
01796 }
01797
01798
01799 if( cdLine("TOTL", 4861 , &hbeta , &absint)<=0 )
01800 {
01801 fprintf( ioQQQ, " FeIILevelPops could not find Hbeta with cdLine.\n" );
01802 cdEXIT(EXIT_FAILURE);
01803 }
01804
01805 fprintf( ioPUN, "Hbeta=%7.3f %10.2e\n",
01806 absint ,
01807 hbeta );
01808
01809 if( renorm > SMALLFLOAT )
01810 {
01811
01812
01813 thresh = FeII.fe2thresh/(realnum)renorm;
01814 }
01815 else
01816 {
01817 thresh = 0.f;
01818 }
01819
01820
01821
01822 for( ipLo=0; ipLo < (FeII.nFeIILevelAlloc - 1); ipLo++ )
01823 {
01824 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevelAlloc; ipHi++ )
01825 {
01826
01827
01828
01829
01830 if( (Fe2SavN[ipHi][ipLo] > thresh &&
01831 Fe2LevN[ipHi][ipLo].EnergyWN > FeII.fe2ener[0]) &&
01832 Fe2LevN[ipHi][ipLo].EnergyWN < FeII.fe2ener[1] )
01833 {
01834 if( FeII.lgShortFe2 )
01835 {
01836
01837
01838 fprintf( ioPUN, "%ld\t%ld\t%.2f\t%.3f\n",
01839 ipHi+1,
01840 ipLo+1,
01841 Fe2LevN[ipHi][ipLo].WLAng ,
01842 log10(MAX2(1e-37,Fe2SavN[ipHi][ipLo])) + radius.Conv2PrtInten );
01843 }
01844 else
01845 {
01846
01847 fprintf( ioPUN, "%ld\t%ld\t%.2f\t%.3f\t%.2e\t%.2e\n",
01848 ipHi+1,
01849 ipLo+1,
01850 Fe2LevN[ipHi][ipLo].WLAng ,
01851 log10(MAX2(1e-37,Fe2SavN[ipHi][ipLo])) + radius.Conv2PrtInten,
01852 Fe2SavN[ipHi][ipLo]*renorm ,
01853 Fe2LevN[ipHi][ipLo].Emis->TauIn );
01854 }
01855 }
01856 }
01857 }
01858
01859 return;
01860 }
01861
01862
01863
01864
01865
01866
01867 void FeII_LineZero(void)
01868 {
01869 long int ipHi,
01870 ipLo;
01871
01872 DEBUG_ENTRY( "FeII_LineZero()" );
01873
01874
01875
01876
01877
01878 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
01879 {
01880 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
01881 {
01882
01883 TransitionZero( &Fe2LevN[ipHi][ipLo] );
01884 }
01885 }
01886
01887 return;
01888 }
01889
01890
01891
01892
01893 void FeIIIntenZero(void)
01894 {
01895 long int ipHi,
01896 ipLo;
01897
01898 DEBUG_ENTRY( "FeIIIntenZero()" );
01899
01900
01901
01902
01903 Fe2LevelPop[0] = 0.;
01904 for( ipHi=1; ipHi < FeII.nFeIILevel; ipHi++ )
01905 {
01906
01907 Fe2LevelPop[ipHi] = 0.;
01908 for( ipLo=0; ipLo < ipHi; ipLo++ )
01909 {
01910
01911
01912 Fe2LevN[ipHi][ipLo].Emis->PopOpc = 0.;
01913
01914
01915 Fe2LevN[ipHi][ipLo].Lo->Pop = 0.;
01916
01917
01918 Fe2LevN[ipHi][ipLo].Hi->Pop = 0.;
01919
01920
01921 Fe2LevN[ipHi][ipLo].Coll.cool = 0.;
01922 Fe2LevN[ipHi][ipLo].Coll.heat = 0.;
01923
01924
01925 Fe2LevN[ipHi][ipLo].Emis->xIntensity = 0.;
01926
01927 Fe2LevN[ipHi][ipLo].Emis->phots = 0.;
01928 Fe2LevN[ipHi][ipLo].Emis->ots = 0.;
01929 Fe2LevN[ipHi][ipLo].Emis->ColOvTot = 0.;
01930 }
01931 }
01932
01933 return;
01934 }
01935
01936
01937
01938
01939
01940
01941 void FeIIFillLow16(void)
01942 {
01943
01944 DEBUG_ENTRY( "FeIIFillLow16()" );
01945
01946
01947
01948
01949
01950 FeII.fe21308 = Fe2LevN[12][7].Emis->xIntensity;
01951 FeII.fe21207 = Fe2LevN[11][6].Emis->xIntensity;
01952 FeII.fe21106 = Fe2LevN[10][5].Emis->xIntensity;
01953 FeII.fe21006 = Fe2LevN[9][5].Emis->xIntensity;
01954 FeII.fe21204 = Fe2LevN[11][3].Emis->xIntensity;
01955 FeII.fe21103 = Fe2LevN[10][2].Emis->xIntensity;
01956 FeII.fe21104 = Fe2LevN[10][3].Emis->xIntensity;
01957 FeII.fe21001 = Fe2LevN[9][0].Emis->xIntensity;
01958 FeII.fe21002 = Fe2LevN[9][1].Emis->xIntensity;
01959 FeII.fe20201 = Fe2LevN[1][0].Emis->xIntensity;
01960 FeII.fe20302 = Fe2LevN[2][1].Emis->xIntensity;
01961 FeII.fe20706 = Fe2LevN[6][5].Emis->xIntensity;
01962 FeII.fe20807 = Fe2LevN[7][6].Emis->xIntensity;
01963 FeII.fe20908 = Fe2LevN[8][7].Emis->xIntensity;
01964 FeII.fe21007 = Fe2LevN[9][6].Emis->xIntensity;
01965 FeII.fe21107 = Fe2LevN[10][6].Emis->xIntensity;
01966 FeII.fe21108 = Fe2LevN[10][7].Emis->xIntensity;
01967 FeII.fe21110 = Fe2LevN[10][9].Emis->xIntensity;
01968 FeII.fe21208 = Fe2LevN[11][7].Emis->xIntensity;
01969 FeII.fe21209 = Fe2LevN[11][8].Emis->xIntensity;
01970 FeII.fe21211 = Fe2LevN[11][10].Emis->xIntensity;
01971 FeII.fe21406 = Fe2LevN[13][5].Emis->xIntensity;
01972 FeII.fe21507 = Fe2LevN[14][6].Emis->xIntensity;
01973 FeII.fe21508 = Fe2LevN[14][7].Emis->xIntensity;
01974 FeII.fe21609 = Fe2LevN[15][8].Emis->xIntensity;
01975
01976
01977 if( FeII.nFeIILevel > 43 )
01978 {
01979
01980
01981 FeII.fe25to6 = Fe2LevN[25-1][5].Emis->xIntensity;
01982 FeII.fe27to7 = Fe2LevN[27-1][6].Emis->xIntensity;
01983 FeII.fe28to8 = Fe2LevN[28-1][7].Emis->xIntensity;
01984 FeII.fe29to9 = Fe2LevN[29-1][8].Emis->xIntensity;
01985 FeII.fe32to6 = Fe2LevN[32-1][5].Emis->xIntensity;
01986 FeII.fe33to7 = Fe2LevN[33-1][6].Emis->xIntensity;
01987 FeII.fe37to7 = Fe2LevN[37-1][6].Emis->xIntensity;
01988 FeII.fe39to8 = Fe2LevN[39-1][7].Emis->xIntensity;
01989 FeII.fe40to9 = Fe2LevN[40-1][8].Emis->xIntensity;
01990 FeII.fe37to6 = Fe2LevN[37-1][5].Emis->xIntensity;
01991 FeII.fe39to7 = Fe2LevN[39-1][6].Emis->xIntensity;
01992 FeII.fe40to8 = Fe2LevN[40-1][7].Emis->xIntensity;
01993 FeII.fe41to9 = Fe2LevN[41-1][8].Emis->xIntensity;
01994 FeII.fe39to6 = Fe2LevN[39-1][5].Emis->xIntensity;
01995 FeII.fe40to7 = Fe2LevN[40-1][6].Emis->xIntensity;
01996 FeII.fe41to8 = Fe2LevN[41-1][7].Emis->xIntensity;
01997
01998 FeII.fe42to6 = Fe2LevN[42-1][5].Emis->xIntensity;
01999 FeII.fe43to7 = Fe2LevN[43-1][6].Emis->xIntensity;
02000 FeII.fe42to7 = Fe2LevN[42-1][6].Emis->xIntensity;
02001 FeII.fe36to2 = Fe2LevN[36-1][1].Emis->xIntensity;
02002 FeII.fe36to3 = Fe2LevN[36-1][2].Emis->xIntensity;
02003
02004 FeII.fe32to1 = Fe2LevN[32-1][0].Emis->xIntensity;
02005
02006 FeII.fe33to2 = Fe2LevN[33-1][1].Emis->xIntensity;
02007 FeII.fe36to5 = Fe2LevN[36-1][4].Emis->xIntensity;
02008 FeII.fe32to2 = Fe2LevN[32-1][1].Emis->xIntensity;
02009 FeII.fe33to3 = Fe2LevN[33-1][2].Emis->xIntensity;
02010 FeII.fe30to3 = Fe2LevN[30-1][2].Emis->xIntensity;
02011 FeII.fe33to6 = Fe2LevN[33-1][5].Emis->xIntensity;
02012 FeII.fe24to2 = Fe2LevN[24-1][1].Emis->xIntensity;
02013 FeII.fe32to7 = Fe2LevN[32-1][6].Emis->xIntensity;
02014 FeII.fe35to8 = Fe2LevN[35-1][7].Emis->xIntensity;
02015 FeII.fe34to8 = Fe2LevN[34-1][7].Emis->xIntensity;
02016 FeII.fe27to6 = Fe2LevN[27-1][5].Emis->xIntensity;
02017 FeII.fe28to7 = Fe2LevN[28-1][6].Emis->xIntensity;
02018 FeII.fe30to8 = Fe2LevN[30-1][7].Emis->xIntensity;
02019 FeII.fe24to6 = Fe2LevN[24-1][5].Emis->xIntensity;
02020 FeII.fe29to8 = Fe2LevN[29-1][7].Emis->xIntensity;
02021 FeII.fe24to7 = Fe2LevN[24-1][6].Emis->xIntensity;
02022 FeII.fe22to7 = Fe2LevN[22-1][6].Emis->xIntensity;
02023 FeII.fe38to11 =Fe2LevN[38-1][11-1].Emis->xIntensity;
02024 FeII.fe19to8 = Fe2LevN[19-1][7].Emis->xIntensity;
02025 FeII.fe17to6 = Fe2LevN[17-1][5].Emis->xIntensity;
02026 FeII.fe18to7 = Fe2LevN[18-1][6].Emis->xIntensity;
02027 FeII.fe18to8 = Fe2LevN[18-1][7].Emis->xIntensity;
02028 FeII.fe17to7 = Fe2LevN[17-1][6].Emis->xIntensity;
02029 }
02030 else
02031 {
02032 FeII.fe25to6 = 0.;
02033 FeII.fe27to7 = 0.;
02034 FeII.fe28to8 = 0.;
02035 FeII.fe29to9 = 0.;
02036 FeII.fe32to6 = 0.;
02037 FeII.fe33to7 = 0.;
02038 FeII.fe37to7 = 0.;
02039 FeII.fe39to8 = 0.;
02040 FeII.fe40to9 = 0.;
02041 FeII.fe37to6 = 0.;
02042 FeII.fe39to7 = 0.;
02043 FeII.fe40to8 = 0.;
02044 FeII.fe41to9 = 0.;
02045 FeII.fe39to6 = 0.;
02046 FeII.fe40to7 = 0.;
02047 FeII.fe41to8 = 0.;
02048
02049 FeII.fe42to6 = 0.;
02050 FeII.fe43to7 = 0.;
02051 FeII.fe42to7 = 0.;
02052 FeII.fe36to2 = 0.;
02053 FeII.fe36to3 = 0.;
02054 FeII.fe32to1 = 0.;
02055 FeII.fe33to2 = 0.;
02056 FeII.fe36to5 = 0.;
02057 FeII.fe32to2 = 0.;
02058 FeII.fe33to3 = 0.;
02059 FeII.fe30to3 = 0.;
02060 FeII.fe33to6 = 0.;
02061 FeII.fe24to2 = 0.;
02062 FeII.fe32to7 = 0.;
02063 FeII.fe35to8 = 0.;
02064 FeII.fe34to8 = 0.;
02065 FeII.fe27to6 = 0.;
02066 FeII.fe28to7 = 0.;
02067 FeII.fe30to8 = 0.;
02068 FeII.fe24to6 = 0.;
02069 FeII.fe29to8 = 0.;
02070 FeII.fe24to7 = 0.;
02071 FeII.fe22to7 = 0.;
02072 FeII.fe38to11 =0.;
02073 FeII.fe19to8 = 0.;
02074 FeII.fe17to6 = 0.;
02075 FeII.fe18to7 = 0.;
02076 FeII.fe18to8 = 0.;
02077 FeII.fe17to7 = 0.;
02078 }
02079
02080 if( FeII.nFeIILevel > 80 )
02081 {
02082 FeII.fe80to28 = Fe2LevN[80-1][28-1].Emis->xIntensity;
02083 }
02084 else
02085 {
02086 FeII.fe80to28 =0.;
02087 }
02088
02089 return;
02090 }
02091
02092
02093
02094 void FeIIPunData(
02095
02096 FILE* ioPUN ,
02097
02098 bool lgDoAll )
02099 {
02100 long int ipLo , ipHi;
02101
02102 DEBUG_ENTRY( "FeIIPunData()" );
02103
02104 if( lgDoAll )
02105 {
02106 fprintf( ioQQQ,
02107 " FeIIPunData ALL option not implemented yet 1\n" );
02108 cdEXIT(EXIT_FAILURE);
02109 }
02110 else
02111 {
02112 long int nSkip=0, limit=MIN2(64, FeII.nFeIILevel);
02113
02114
02115
02116 for( ipHi=1; ipHi<limit; ++ipHi )
02117 {
02118 for( ipLo=0; ipLo<ipHi; ++ipLo )
02119 {
02120 fprintf(ioPUN,"%4li%4li ",ipLo,ipHi );
02121 Punch1LineData( &Fe2LevN[ipHi][ipLo] , ioPUN, false);
02122 }
02123 }
02124 fprintf( ioPUN , "\n");
02125
02126 if( limit==64 )
02127 {
02128
02129
02130
02131 for( ipHi=limit; ipHi<FeII.nFeIILevel; ++ipHi )
02132 {
02133
02134
02135 for( ipLo=0; ipLo<ipHi; ++ipLo )
02136 {
02137
02138
02139
02140
02141
02142 if( ncs1[ipHi][ipLo] == 3 &&
02143 (fabs(Fe2LevN[ipHi][ipLo].Emis->Aul-1e-5) < 1e-8 ) )
02144 {
02145 ++nSkip;
02146 }
02147 else
02148 {
02149
02150
02151 fprintf(ioPUN,"%4li%4li ",ipLo+1,ipHi+1 );
02152 Punch1LineData( &Fe2LevN[ipHi][ipLo] , ioPUN , false);
02153 }
02154 }
02155 }
02156 fprintf( ioPUN , " %li lines skiped\n",nSkip);
02157 }
02158 }
02159
02160 return;
02161 }
02162
02163
02164
02165
02166 void FeIIPunDepart(
02167
02168 FILE* ioPUN ,
02169
02170 bool lgDoAll )
02171 {
02172
02173 # define NLEVDEP 11
02174
02175 const int LevDep[NLEVDEP]={1,10,25,45,64,124,206,249,295,347,371};
02176 long int i;
02177 static bool lgFIRST=true;
02178
02179 DEBUG_ENTRY( "FeIIPunDepart()" );
02180
02181
02182 if( lgFIRST && !lgDoAll )
02183 {
02184
02185 for( i=0; i<NLEVDEP; ++i )
02186 {
02187 fprintf( ioPUN , "%i\t", LevDep[i] );
02188 }
02189 fprintf( ioPUN , "\n");
02190 lgFIRST = false;
02191 }
02192
02193 if( lgDoAll )
02194 {
02195
02196 for( i=1; i<=FeII.nFeIILevel; ++i )
02197 {
02198 FeIIPun1Depart( ioPUN , i );
02199 fprintf( ioPUN , "\n");
02200 }
02201 }
02202 else
02203 {
02204
02205 for( i=0; i<NLEVDEP; ++i )
02206 {
02207 FeIIPun1Depart( ioPUN , LevDep[i] );
02208 fprintf( ioPUN , "\t");
02209 }
02210 fprintf( ioPUN , "\n");
02211 }
02212
02213 return;
02214 }
02215
02216
02217
02218
02219 void FeIIPun1Depart(
02220
02221 FILE * ioPUN ,
02222
02223 long int nPUN )
02224 {
02225
02226 DEBUG_ENTRY( "FeIIPun1Depart()" );
02227
02228 ASSERT( nPUN > 0 );
02229
02230 assert( ioPUN != NULL );
02231
02232
02233
02234 if( nPUN <= FeII.nFeIILevel )
02235 {
02236 fprintf( ioPUN , "%e ",Fe2DepCoef[nPUN-1] );
02237 }
02238 else
02239 {
02240 fprintf( ioPUN , "%e ",0. );
02241 }
02242
02243 return;
02244 }
02245
02246
02247
02248
02249 void FeIIReset(void)
02250 {
02251
02252 DEBUG_ENTRY( "FeIIReset()" );
02253
02254
02255 FeII.nFeIILevel = FeII.nFeIILevelAlloc;
02256
02257 return;
02258 }
02259
02260
02261
02262
02263
02264 void FeIIZero(void)
02265 {
02266
02267 DEBUG_ENTRY( "FeIIZero()" );
02268
02269
02270 FeII.Fe2_large_cool = 0.;
02271 FeII.ddT_Fe2_large_cool = 0.;
02272 FeII.Fe2_large_heat = 0.;
02273
02274
02275 FeII.lgLyaPumpOn = true;
02276
02277
02278
02279
02280
02281
02282 FeII.lgFeIILargeOn = false;
02283
02284
02285 FeII.fe2ener[0] = 0.;
02286 FeII.fe2ener[1] = 1e8;
02287
02288
02289
02290 FeII.ipRedisFcnResonance = ipCRD;
02291
02292 FeII.ipRedisFcnSubordinate = ipCRDW;
02293
02294
02295 FeII.fe2thresh = 0.;
02296
02297
02298
02299 FeII.lgSlow = false;
02300
02301
02302 FeII.lgPrint = false;
02303
02304
02305 FeII.lgSimulate = false;
02306
02307
02308
02309 if( lgFeIIMalloc )
02310 {
02311
02312 FeII.nFeIILevel = FeII.nFeIILevelAlloc;
02313 }
02314 else
02315 {
02316
02317 FeII.nFeIILevel = NFE2LEVN;
02318
02319
02320
02321 FeII.nFeIILevel = 16;
02322 }
02323
02324
02325 FeII.fe2con_wl1 = 1000.;
02326 FeII.fe2con_wl2 = 7000.;
02327 FeII.nfe2con = 1000;
02328
02329 return;
02330 }
02331
02332
02333 void FeIIPunPop(
02334
02335 FILE* ioPUN ,
02336
02337 bool lgPunchRange ,
02338
02339 long int ipRangeLo ,
02340
02341 long int ipRangeHi ,
02342
02343 bool lgPunchDensity )
02344 {
02345
02346 # define NLEVPOP 11
02347
02348 const int LevPop[NLEVPOP]={1,10,25,45,64,124,206,249,295,347,371};
02349 long int i;
02350 static bool lgFIRST=true;
02351 realnum denominator = 1.f;
02352
02353 DEBUG_ENTRY( "FeIIPunPop()" );
02354
02355
02356 if( !lgPunchDensity )
02357 denominator = SDIV( dense.xIonDense[ipIRON][1] );
02358
02359
02360
02361 if( lgFIRST && !lgPunchRange )
02362 {
02363
02364 for( i=0; i<NLEVPOP; ++i )
02365 {
02366
02367 fprintf( ioPUN , "%i\t", LevPop[i] );
02368 }
02369 fprintf( ioPUN , "\n");
02370 lgFIRST = false;
02371 }
02372
02373 if( lgPunchRange )
02374 {
02375
02376 ASSERT( ipRangeLo>=0 && ipRangeLo<ipRangeHi && ipRangeHi<=FeII.nFeIILevel );
02377
02378
02379
02380 for( i=ipRangeLo; i<ipRangeHi; ++i )
02381 {
02382
02383 fprintf( ioPUN , "%.3e\t", Fe2LevelPop[i]/denominator );
02384 }
02385 fprintf( ioPUN , "\n");
02386 }
02387 else
02388 {
02389
02390
02391 for( i=0; i<NLEVPOP; ++i )
02392 {
02393 fprintf( ioPUN , "%.3e\t", Fe2LevelPop[LevPop[i]-1]/denominator );
02394 }
02395 fprintf( ioPUN , "\n");
02396 }
02397
02398 return;
02399 }
02400
02401
02402
02403
02404 #if 0
02405 void FeIIPun1Pop(
02406
02407 FILE * ioPUN ,
02408
02409 long int nPUN )
02410 {
02411 DEBUG_ENTRY( "FeIIPun1Pop()" );
02412
02413 ASSERT( nPUN > 0 );
02414
02415 assert( ioPUN != NULL );
02416
02417
02418
02419
02420 if( nPUN <= FeII.nFeIILevel )
02421 {
02422 fprintf( ioPUN , "%e ",Fe2LevelPop[nPUN-1] );
02423 }
02424 else
02425 {
02426 fprintf( ioPUN , "%e ",0. );
02427 }
02428
02429 return;
02430 }
02431 #endif
02432
02433
02434
02435
02436 STATIC int FeIIBandsCreate(
02437
02438
02439
02440 const char chFile[] )
02441 {
02442
02443 char chLine[FILENAME_PATH_LENGTH_2];
02444 const char* chFile1;
02445 FILE *ioDATA;
02446
02447 bool lgEOL;
02448 long int i,k;
02449
02450
02451
02452 static bool lgCalled=false;
02453
02454 DEBUG_ENTRY( "FeIIBandsCreate()" );
02455
02456
02457 if( lgCalled )
02458 {
02459
02460 return 0;
02461 }
02462 lgCalled = true;
02463
02464
02465 chFile1 = ( strlen(chFile) == 0 ) ? "bands_Fe2.dat" : chFile;
02466
02467
02468 if( trace.lgTrace )
02469 {
02470 fprintf( ioQQQ, " FeIICreate opening %s:", chFile1 );
02471 }
02472
02473 ioDATA = open_data( chFile1, "r" );
02474
02475
02476 nFeIIBands = 0;
02477
02478
02479 if( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) == NULL )
02480 {
02481 fprintf( ioQQQ, " FeIICreate could not read first line of %s.\n", chFile1 );
02482 return 1;
02483 }
02484 while( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) != NULL )
02485 {
02486
02487
02488 if( chLine[0] != '#')
02489 ++nFeIIBands;
02490 }
02491
02492
02493 if( fseek( ioDATA , 0 , SEEK_SET ) != 0 )
02494 {
02495 fprintf( ioQQQ, " FeIICreate could not rewind %s.\n", chFile1 );
02496 return 1;
02497 }
02498
02499 FeII_Bands = (realnum **)MALLOC(sizeof(realnum *)*(unsigned)(nFeIIBands) );
02500
02501
02502 for( i=0; i<nFeIIBands; ++i )
02503 {
02504 FeII_Bands[i] = (realnum *)MALLOC(sizeof(realnum)*(unsigned)(3) );
02505 }
02506
02507
02508 if( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) == NULL )
02509 {
02510 fprintf( ioQQQ, " FeIICreate could not read first line of %s.\n", chFile1 );
02511 return 1;
02512 }
02513 i = 1;
02514 if( ( (long)FFmtRead(chLine,&i,INPUT_LINE_LENGTH,&lgEOL) != 99 ) ||
02515 ( (long)FFmtRead(chLine,&i,INPUT_LINE_LENGTH,&lgEOL) != 12 ) ||
02516 ( (long)FFmtRead(chLine,&i,INPUT_LINE_LENGTH,&lgEOL) != 1 ) )
02517 {
02518 fprintf( ioQQQ,
02519 " FeIICreate: the version of %s is not the current version.\n", chFile1 );
02520 return 1;
02521 }
02522
02523
02524 k = 0;
02525 while( read_whole_line( chLine , (int)sizeof(chLine) , ioDATA ) != NULL )
02526 {
02527
02528
02529 if( chLine[0] != '#')
02530 {
02531 i = 1;
02532 FeII_Bands[k][0] = (realnum)FFmtRead(chLine,&i,INPUT_LINE_LENGTH,&lgEOL);
02533 if( lgEOL )
02534 {
02535 fprintf( ioQQQ, " There should have been a number on this band line 1. Sorry.\n" );
02536 fprintf( ioQQQ, "string==%s==\n" ,chLine );
02537 return 1;
02538 }
02539 FeII_Bands[k][1] = (realnum)FFmtRead(chLine,&i,INPUT_LINE_LENGTH,&lgEOL);
02540 if( lgEOL )
02541 {
02542 fprintf( ioQQQ, " There should have been a number on this band line 2. Sorry.\n" );
02543 fprintf( ioQQQ, "string==%s==\n" ,chLine );
02544 return 1;
02545 }
02546 FeII_Bands[k][2] = (realnum)FFmtRead(chLine,&i,INPUT_LINE_LENGTH,&lgEOL);
02547 if( lgEOL )
02548 {
02549 fprintf( ioQQQ, " There should have been a number on this band line 3. Sorry.\n" );
02550 fprintf( ioQQQ, "string==%s==\n" ,chLine );
02551 return 1;
02552 }
02553
02554
02555 ++k;
02556 }
02557 }
02558
02559 for( i=0; i<nFeIIBands; ++i )
02560 {
02561
02562 if( FeII_Bands[i][0] <=0. || FeII_Bands[i][1] <=0. || FeII_Bands[i][2] <=0. )
02563 {
02564 fprintf( ioQQQ, " FeII band %li has none positive entry.\n",i );
02565 return 1;
02566 }
02567
02568 if( FeII_Bands[i][1] >= FeII_Bands[i][2] )
02569 {
02570 fprintf( ioQQQ, " FeII band %li has improper bounds.\n" ,i);
02571 return 1;
02572 }
02573
02574 }
02575
02576 fclose(ioDATA);
02577
02578
02579 return 0;
02580 }
02581
02582
02583
02584 void AssertFeIIDep( double *pred , double *BigError , double *StdDev )
02585 {
02586 long int n;
02587 double arg ,
02588 error ,
02589 sum2;
02590
02591 DEBUG_ENTRY( "AssertFeIIDep()" );
02592
02593 if( FeII.lgSimulate )
02594 {
02595
02596 *pred = 0.;
02597 *BigError = 0.;
02598 *StdDev = 0.;
02599
02600 return;
02601 }
02602
02603
02604 ASSERT( FeII.nFeIILevel > 0 );
02605
02606
02607 *BigError = 0.;
02608 *pred = 0.;
02609 sum2 = 0;
02610 for( n=0; n<FeII.nFeIILevel; ++n )
02611 {
02612
02613 *pred += Fe2DepCoef[n];
02614
02615
02616 error = fabs( Fe2DepCoef[n] -1. );
02617
02618 *BigError = MAX2( *BigError , error );
02619
02620
02621 sum2 += POW2( Fe2DepCoef[n] );
02622 }
02623
02624
02625 arg = sum2 - POW2( *pred ) / (double)FeII.nFeIILevel;
02626 ASSERT( (arg >= 0.) );
02627 *StdDev = sqrt( arg / (double)(FeII.nFeIILevel - 1.) );
02628
02629
02630 *pred /= (double)(FeII.nFeIILevel);
02631
02632 return;
02633 }
02634
02635
02636
02637
02638
02639 void FeII_OTS( void )
02640 {
02641 long int ipLo ,
02642 ipHi;
02643
02644 DEBUG_ENTRY( "FeII_OTS()" );
02645
02646 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
02647 {
02648 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
02649 {
02650
02651 if( Fe2LevN[ipHi][ipLo].ipCont < 1)
02652 continue;
02653
02654
02655 Fe2LevN[ipHi][ipLo].Emis->ots =
02656 Fe2LevN[ipHi][ipLo].Emis->Aul*
02657 Fe2LevN[ipHi][ipLo].Hi->Pop*
02658 Fe2LevN[ipHi][ipLo].Emis->Pdest;
02659
02660 ASSERT( Fe2LevN[ipHi][ipLo].Emis->ots >= 0. );
02661
02662
02663 RT_OTS_AddLine(Fe2LevN[ipHi][ipLo].Emis->ots,
02664 Fe2LevN[ipHi][ipLo].ipCont );
02665 }
02666 }
02667
02668 return;
02669 }
02670
02671
02672
02673
02674
02675
02676 void FeII_RT_Out(void)
02677 {
02678 long int ipLo , ipHi;
02679
02680 DEBUG_ENTRY( "FeIIRTOut()" );
02681
02682
02683 if( dense.xIonDense[ipIRON][1] > 0. )
02684 {
02685
02686 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
02687 {
02688 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
02689 {
02690
02691 if( Fe2LevN[ipHi][ipLo].ipCont < 1)
02692 continue;
02693
02694
02695 outline( &Fe2LevN[ipHi][ipLo] );
02696
02697 }
02698 }
02699 }
02700
02701 return;
02702 }
02703
02704
02705
02706
02707 STATIC void FeIIContCreate(
02708
02709 double xLamLow ,
02710
02711 double xLamHigh ,
02712
02713 long int ncell )
02714 {
02715
02716 double step , wl1;
02717 long int i;
02718
02719
02720
02721 static bool lgCalled=false;
02722
02723 DEBUG_ENTRY( "FeIIContCreate()" );
02724
02725
02726 if( lgCalled )
02727 {
02728
02729 return;
02730 }
02731 lgCalled = true;
02732
02733
02734 nFeIIConBins = ncell;
02735
02736 FeII_Cont = (realnum **)MALLOC(sizeof(realnum *)*(unsigned)(nFeIIConBins) );
02737
02738
02739 for( i=0; i<nFeIIConBins; ++i )
02740 {
02741 FeII_Cont[i] = (realnum *)MALLOC(sizeof(realnum)*(unsigned)(3) );
02742 }
02743
02744 step = log10( xLamHigh/xLamLow)/ncell;
02745 wl1 = log10( xLamLow);
02746 FeII_Cont[0][1] = (realnum)pow(10. ,wl1);
02747 for( i=1; i<ncell; ++i)
02748 {
02749
02750 FeII_Cont[i][1] = (realnum)pow(10. , ( wl1 + i*step ) );
02751 }
02752
02753 for( i=0; i<(ncell-1); ++i)
02754 {
02755
02756 FeII_Cont[i][2] = FeII_Cont[i+1][1];
02757 }
02758 FeII_Cont[ncell-1][2] = (realnum)(pow(10., log10(FeII_Cont[ncell-2][2]) + step) );
02759
02760 for( i=0; i<ncell; ++i)
02761 {
02762
02763 FeII_Cont[i][0] = ( FeII_Cont[i][1] + FeII_Cont[i][2] ) /2.f;
02764 }
02765 {
02766 enum {DEBUG_LOC=false};
02767 if( DEBUG_LOC )
02768 {
02769 FILE *ioDEBUG;
02770 ioDEBUG = fopen( "fe2cont.txt", "w" );
02771 if( ioDEBUG==NULL )
02772 {
02773 fprintf( ioQQQ," fe2con could not open fe2cont.txt for writing\n");
02774 cdEXIT(EXIT_FAILURE);
02775 }
02776 for( i=0; i<ncell; ++i)
02777 {
02778
02779 fprintf(ioDEBUG,"%.1f\t%.1f\t%.1f\n",
02780 FeII_Cont[i][0] , FeII_Cont[i][1] , FeII_Cont[i][2] );
02781 }
02782 fclose( ioDEBUG);
02783 }
02784 }
02785
02786 return;
02787 }
02788
02789
02790 STATIC void FeIIOvrLap(void)
02791 {
02792
02793 DEBUG_ENTRY( "FeIIOvrLap()" );
02794
02795 return;
02796 }
02797
02798
02799 void ParseAtomFeII(char *chCard )
02800 {
02801 long int i;
02802 bool lgEOL=false;
02803
02804 DEBUG_ENTRY( "ParseAtomFeII()" );
02805
02806
02807 FeII.lgFeIILargeOn = true;
02808
02809 if( lgFeIIMalloc )
02810 {
02811
02812 FeII.nFeIILevel = FeII.nFeIILevelAlloc;
02813 }
02814 else
02815 {
02816
02817 FeII.nFeIILevel = NFE2LEVN;
02818 }
02819
02820
02821
02822 if( nMatch("LEVE",chCard) )
02823 {
02824
02825 if( !lgFeIIMalloc )
02826 {
02827 i = 5;
02828
02829 FeII.nFeIILevel = (long int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
02830 if( lgEOL )
02831 {
02832
02833 NoNumb(chCard);
02834 }
02835 if( FeII.nFeIILevel <16 )
02836 {
02837 fprintf( ioQQQ, " This would be too few levels, must have at least 16.\n" );
02838 cdEXIT(EXIT_FAILURE);
02839 }
02840 else if( FeII.nFeIILevel > NFE2LEVN )
02841 {
02842 fprintf( ioQQQ, " This would be too many levels.\n" );
02843 cdEXIT(EXIT_FAILURE);
02844 }
02845 }
02846 }
02847
02848
02849 else if( nMatch("SLOW",chCard) )
02850 {
02851 FeII.lgSlow = true;
02852 }
02853
02854
02855 else if( nMatch("REDI",chCard) )
02856 {
02857 int ipRedis=0;
02858
02859
02860
02861
02862
02863 if( nMatch(" PRD",chCard) )
02864 {
02865 ipRedis = ipPRD;
02866 }
02867
02868 else if( nMatch(" CRD",chCard) )
02869 {
02870 ipRedis = ipCRD;
02871 }
02872
02873 else if( nMatch("CRDW",chCard) )
02874 {
02875 ipRedis = ipCRDW;
02876 }
02877
02878
02879 else if( !nMatch("SHOW",chCard) )
02880 {
02881 fprintf(ioQQQ," There should have been a second keyword on this command.\n");
02882 fprintf(ioQQQ," Options are _PRD, _CRD, CRDW (_ is space). Sorry.\n");
02883 cdEXIT(EXIT_FAILURE);
02884 }
02885
02886
02887 if( nMatch("RESO",chCard) )
02888 {
02889 FeII.ipRedisFcnResonance = ipRedis;
02890 }
02891
02892 else if( nMatch("SUBO",chCard) )
02893 {
02894 FeII.ipRedisFcnSubordinate = ipRedis;
02895 }
02896
02897 else if( nMatch("SHOW",chCard) )
02898 {
02899 fprintf(ioQQQ," FeII resonance lines are ");
02900 if( FeII.ipRedisFcnResonance ==ipCRDW )
02901 {
02902 fprintf(ioQQQ,"complete redistribution with wings\n");
02903 }
02904 else if( FeII.ipRedisFcnResonance ==ipCRD )
02905 {
02906 fprintf(ioQQQ,"complete redistribution with core only.\n");
02907 }
02908 else if( FeII.ipRedisFcnResonance ==ipPRD )
02909 {
02910 fprintf(ioQQQ,"partial redistribution.\n");
02911 }
02912 else
02913 {
02914 fprintf(ioQQQ," PROBLEM Impossible value for ipRedisFcnResonance.\n");
02915 TotalInsanity();
02916 }
02917
02918 fprintf(ioQQQ," FeII subordinate lines are ");
02919 if( FeII.ipRedisFcnSubordinate ==ipCRDW )
02920 {
02921 fprintf(ioQQQ,"complete redistribution with wings\n");
02922 }
02923 else if( FeII.ipRedisFcnSubordinate ==ipCRD )
02924 {
02925 fprintf(ioQQQ,"complete redistribution with core only.\n");
02926 }
02927 else if( FeII.ipRedisFcnSubordinate ==ipPRD )
02928 {
02929 fprintf(ioQQQ,"partial redistribution.\n");
02930 }
02931 else
02932 {
02933 fprintf(ioQQQ," PROBLEM Impossible value for ipRedisFcnSubordinate.\n");
02934 TotalInsanity();
02935 }
02936 }
02937 else
02938 {
02939 fprintf(ioQQQ," here should have been a second keyword on this command.\n");
02940 fprintf(ioQQQ," Options are RESONANCE, SUBORDINATE. Sorry.\n");
02941 cdEXIT(EXIT_FAILURE);
02942 }
02943 }
02944
02945
02946 else if( nMatch("TRAC",chCard) )
02947 {
02948 FeII.lgPrint = true;
02949 }
02950
02951
02952 else if( nMatch("SIMU",chCard) )
02953 {
02954
02955 FeII.lgSimulate = true;
02956 }
02957
02958
02959 else if( nMatch("CONT",chCard) )
02960 {
02961
02962 i=5;
02963
02964
02965 FeII.fe2con_wl1 = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
02966 FeII.fe2con_wl2 = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
02967 FeII.nfe2con = (long int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
02968 if( lgEOL )
02969 {
02970 fprintf(ioQQQ," there are three numbers on the FeII continuum command, start and end wavelengths, and number of intervals.\n");
02971
02972 NoNumb(chCard);
02973 }
02974
02975 if( FeII.fe2con_wl1<=0. || FeII.fe2con_wl2<=0. || FeII.nfe2con<= 0 )
02976 {
02977 fprintf(ioQQQ," there are three numbers on the FeII continuum command, start and end wavelengths, and number of intervals.\n");
02978 fprintf(ioQQQ," all three must be greater than zero, sorry.\n");
02979 cdEXIT(EXIT_FAILURE);
02980 }
02981
02982 if( FeII.fe2con_wl1>= FeII.fe2con_wl2 )
02983 {
02984 fprintf(ioQQQ," there are three numbers on the FeII continuum command, start and end wavelengths, and number of intervals.\n");
02985 fprintf(ioQQQ," the second wavelength must be greater than the first, sorry.\n");
02986 cdEXIT(EXIT_FAILURE);
02987 }
02988 }
02989
02990
02991
02992 return;
02993 }
02994
02995 void PunFeII( FILE * io )
02996 {
02997 long int n, ipHi;
02998
02999 DEBUG_ENTRY( "PunFeII()" );
03000
03001 for( n=0; n<FeII.nFeIILevel-1; ++n)
03002 {
03003 for( ipHi=n+1; ipHi<FeII.nFeIILevel; ++ipHi )
03004 {
03005 if( Fe2LevN[ipHi][n].ipCont > 0 )
03006 fprintf(io,"%li\t%li\t%.2e\n", n , ipHi ,
03007 Fe2LevN[ipHi][n].Emis->TauIn );
03008 }
03009 }
03010
03011 return;
03012 }
03013
03014
03015 void FeIIPunchLineStuff( FILE * io , realnum xLimit , long index)
03016 {
03017 long int n, ipHi;
03018
03019 DEBUG_ENTRY( "FeIIPunchLineStuff()" );
03020
03021 for( n=0; n<FeII.nFeIILevel-1; ++n)
03022 {
03023 for( ipHi=n+1; ipHi<FeII.nFeIILevel; ++ipHi )
03024 {
03025 pun1Line( &Fe2LevN[ipHi][n] , io , xLimit , index , 1. );
03026 }
03027 }
03028
03029 return;
03030 }
03031
03032
03033 double FeIIRadPress(void)
03034 {
03035
03036
03037 realnum smallfloat=SMALLFLOAT*10.f;
03038 double press,
03039 RadPres1;
03040 # undef DEBUGFE
03041 # ifdef DEBUGFE
03042 double RadMax;
03043 long ipLoMax , ipHiMax;
03044 # endif
03045 long int ipLo, ipHi;
03046
03047 DEBUG_ENTRY( "FeIIRadPress()" );
03048
03049 press = 0.;
03050 # ifdef DEBUGFE
03051 RadMax = 0;
03052 ipLoMax = -1;
03053 ipHiMax = -1;
03054 # endif
03055
03056 for( ipHi=1; ipHi<FeII.nFeIILevel; ++ipHi )
03057 {
03058 for( ipLo=0; ipLo<ipHi; ++ipLo)
03059 {
03060
03061 if( Fe2LevN[ipHi][ipLo].ipCont > 0 &&
03062 Fe2LevN[ipHi][ipLo].Hi->Pop > 1e-30 )
03063 {
03064 if( Fe2LevN[ipHi][ipLo].Hi->Pop > smallfloat &&
03065 Fe2LevN[ipHi][ipLo].Emis->PopOpc > smallfloat )
03066 {
03067 RadPres1 = PressureRadiationLine( &Fe2LevN[ipHi][ipLo], 1.0 );
03068
03069 # ifdef DEBUGFE
03070 if( RadPres1 > RadMax )
03071 {
03072 RadMax = RadPres1;
03073 ipLoMax = ipLo;
03074 ipHiMax = ipHi;
03075 }
03076 # endif
03077 press += RadPres1;
03078 }
03079 }
03080 }
03081 }
03082
03083 # ifdef DEBUGFE
03084
03085 if( iteration > 1 || nzone > 1558 )
03086 {
03087 fprintf(ioQQQ,"DEBUG FeIIRadPress finds P(FeII) = %.2e %.2e %li %li width %.2e\n",
03088 press ,
03089 RadMax ,
03090 ipLoMax ,
03091 ipHiMax ,
03092 RT_LineWidth(&Fe2LevN[9][0]) );
03093 DumpLine( &Fe2LevN[9][0] );
03094 }
03095 # endif
03096 # undef DEBUGFE
03097
03098 return press;
03099 }
03100
03101 #if 0
03102
03103 double FeII_InterEnergy(void)
03104 {
03105 double energy;
03106 long int n, ipHi;
03107
03108 DEBUG_ENTRY( "FeII_InterEnergy()" );
03109
03110 broken();
03111
03112
03113
03114
03115 energy = 0.;
03116 for( n=0; n<FeII.nFeIILevel-1; ++n)
03117 {
03118 for( ipHi=n+1; ipHi<FeII.nFeIILevel; ++ipHi )
03119 {
03120 if( Fe2LevN[ipHi][n].Hi->Pop > 1e-30 )
03121 {
03122 energy +=
03123 Fe2LevN[ipHi][n].Hi->Pop* Fe2LevN[ipHi][n].EnergyErg;
03124 }
03125 }
03126 }
03127
03128 return energy;
03129 }
03130 #endif
03131
03132
03133 #if defined(__HP_aCC)
03134 # pragma OPT_LEVEL 1
03135 #endif
03136
03137 STATIC void FeIILyaPump(void)
03138 {
03139
03140 long int ipLo ,
03141 ipHi;
03142 double EnerLyaProf2,
03143 EnerLyaProf3,
03144 EnergyWN,
03145 Gup_ov_Glo,
03146 PhotOccNum_at_nu,
03147 PumpRate,
03148 de,
03149 FeIILineWidthHz,
03150 taux;
03151
03152 DEBUG_ENTRY( "FeIILyaPump()" );
03153
03154
03155
03156
03157
03158
03159 if( FeII.lgLyaPumpOn )
03160 {
03161
03162
03163
03164
03165
03166
03167 de = 1.37194e-06*hydro.HLineWidth*2.0/3.0;
03168
03169 EnerLyaProf1 = 82259.0 - de*2.0;
03170 EnerLyaProf2 = 82259.0 - de;
03171 EnerLyaProf3 = 82259.0 + de;
03172 EnerLyaProf4 = 82259.0 + de*2.0;
03173
03174
03175 if( Transitions[ipH_LIKE][ipHYDROGEN][ipH2p][ipH1s].Hi->Pop > SMALLFLOAT )
03176 {
03177
03178 PhotOccNumLyaCenter =
03179 MAX2(0.,1.0- Transitions[ipH_LIKE][ipHYDROGEN][ipH2p][ipH1s].Emis->Pelec_esc -
03180 Transitions[ipH_LIKE][ipHYDROGEN][ipH2p][ipH1s].Emis->Pesc)/
03181 (StatesElem[ipH_LIKE][ipHYDROGEN][ipH1s].Pop/StatesElem[ipH_LIKE][ipHYDROGEN][ipH2p].Pop*3. - 1.0);
03182 }
03183 else
03184 {
03185
03186 PhotOccNumLyaCenter = 0.;
03187 }
03188 }
03189 else
03190 {
03191 PhotOccNumLyaCenter = 0.;
03192 de = 0.;
03193 EnerLyaProf1 = 0.;
03194 EnerLyaProf2 = 0.;
03195 EnerLyaProf3 = 0.;
03196 EnerLyaProf4 = 0.;
03197 }
03198
03199
03200 if( FeII.lgLyaPumpOn )
03201 {
03202 for( ipLo=0; ipLo < (FeII.nFeIILevel - 1); ipLo++ )
03203 {
03204 for( ipHi=ipLo + 1; ipHi < FeII.nFeIILevel; ipHi++ )
03205 {
03206
03207
03208 if( iteration == 1 )
03209 {
03210 taux = Fe2LevN[ipHi][ipLo].Emis->TauIn;
03211 }
03212 else
03213 {
03214 taux = Fe2LevN[ipHi][ipLo].Emis->TauTot;
03215 }
03216
03217
03218 Gup_ov_Glo = Fe2LevN[ipHi][ipLo].Hi->g/Fe2LevN[ipHi][ipLo].Lo->g;
03219
03220
03221 EnergyWN = Fe2LevN[ipHi][ipLo].EnergyWN;
03222
03223 if( EnergyWN >= EnerLyaProf1 && EnergyWN <= EnerLyaProf4 && taux > 1 )
03224 {
03225
03226
03227
03228
03229
03230
03231
03232
03233
03234
03235
03236
03237
03238
03239
03240 if( EnergyWN < EnerLyaProf2 )
03241 {
03242
03243 PhotOccNum_at_nu = PhotOccNumLyaCenter*(EnergyWN - EnerLyaProf1)/ de;
03244 }
03245 else if( EnergyWN < EnerLyaProf3 )
03246 {
03247
03248 PhotOccNum_at_nu = PhotOccNumLyaCenter;
03249 }
03250 else
03251 {
03252
03253 PhotOccNum_at_nu = PhotOccNumLyaCenter*(EnerLyaProf4 - EnergyWN)/de;
03254 }
03255
03256
03257
03258
03259
03261
03262 FeIILineWidthHz = 1.e8/(EnergyWN*299792.5)*sqrt(log(taux))*DoppVel.doppler[ipIRON];
03263
03264
03265 PumpRate = FeIILineWidthHz * PhotOccNum_at_nu * Fe2LevN[ipHi][ipLo].Emis->Aul*
03266 powi(82259.0f/EnergyWN,3);
03267
03268 PumpRate = Fe2LevN[ipHi][ipLo].Emis->Aul* PhotOccNum_at_nu;
03269
03270
03271 Fe2LPump[ipHi][ipLo] += PumpRate;
03272
03273
03274 Fe2LPump[ipLo][ipHi] += PumpRate*Gup_ov_Glo;
03275 }
03276 }
03277 }
03278 }
03279
03280 return;
03281 }
03282
03283
03284 #if defined(__HP_aCC)
03285 #pragma OPTIMIZE OFF
03286 #pragma OPTIMIZE ON
03287 #endif