00001
00002
00003
00004
00005
00006 #include "cddefines.h"
00007 #include "physconst.h"
00008 #include "taulines.h"
00009 #include "thermal.h"
00010 #include "yield.h"
00011 #include "ionbal.h"
00012 #include "cddrive.h"
00013 #include "trace.h"
00014 #include "dense.h"
00015 #include "prt.h"
00016 #include "rt.h"
00017 #include "coolheavy.h"
00018 #include "rfield.h"
00019 #include "phycon.h"
00020 #include "elementnames.h"
00021 #include "iso.h"
00022 #include "hyperfine.h"
00023 #include "hydrogenic.h"
00024 #include "lines_service.h"
00025 #include "atmdat.h"
00026 #include "lines.h"
00027 #include "radius.h"
00028 static void Drive_cdLine( void );
00029
00030 void lines(void)
00031 {
00032 char chLabel[5];
00033 static bool lgRecOn;
00034 long int i,
00035 ipnt,
00036 nelem;
00037 double BigstExtra,
00038 ExtraCool,
00039 f2, sum;
00040
00041 DEBUG_ENTRY( "lines()" );
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 if( trace.lgTrace )
00063 {
00064 fprintf( ioQQQ, " lines called\n" );
00065 }
00066
00067
00068 if( trace.lgDrv_cdLine && LineSave.ipass > 0 )
00069 Drive_cdLine();
00070
00071
00072
00073 thermal.power += thermal.htot*radius.dVeff;
00074
00075
00076 thermal.FreeFreeTotHeat += CoolHeavy.brems_heat_total*radius.dVeff;
00077
00078
00079 rfield.comtot += rfield.cmheat*radius.dVeff;
00080 thermal.totcol += thermal.ctot*radius.dVeff;
00081
00082
00083 for( nelem=0; nelem<LIMELM; ++nelem )
00084 {
00085 hydro.cintot += iso.RecomInducCool_Rate[ipH_LIKE][nelem]*radius.dVeff;
00086 }
00087
00088
00089 LineSave.nsum = 0;
00090 LineSave.nsum = 0;
00091 LineSave.nComment = 0;
00092
00093
00094
00095
00096 rt.fracin = 0.5;
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 PntForLine(0.,"FILL",&i);
00113
00114
00115
00116
00117 t_ADfA::Inst().rec_lines(phycon.te,LineSave.RecCoefCNO);
00118
00119
00120 PutExtra(0.);
00121
00122
00123 linadd(0.f,0,"zero",'i');
00124
00125
00126
00127
00128 linadd( 1.e-10 , 1 , "Unit" , 'i' );
00129
00130
00131 lines_general();
00132
00133
00134 lines_continuum();
00135
00136
00137 lines_molecules();
00138
00139
00140 lines_grains();
00141
00142
00143 lines_hydro();
00144
00145
00146 lines_helium();
00147
00148 #if 0
00149
00150
00151
00152 {
00153 long ipHi, ipLo;
00154
00155 fprintf( ioQQQ,"ipHi\tipLo\tnu\tlu\tsu\tnl\tll\tsl\tWL\tintens\n" );
00156 for( ipHi=5; ipHi<= 419; ipHi++ )
00157 {
00158 for( ipLo=0; ipLo<ipHi; ipLo++ )
00159 {
00160 if( EmisLines[ipHE_LIKE][ipHELIUM][ipHi][ipLo].WLAng < 1.0E6 &&
00161 EmisLines[ipHE_LIKE][ipHELIUM][ipHi][ipLo].WLAng > 2.0E3 &&
00162 ipLo!=3 && ipLo!=4 )
00163 {
00164 fprintf( ioQQQ,"%li\t%li\t%li\t%li\t%li\t%li\t%li\t%li\t%e\t",
00165 ipHi,
00166 ipLo,
00167 iso.quant_desig[ipHE_LIKE][ipHELIUM][ipHi].n,
00168 iso.quant_desig[ipHE_LIKE][ipHELIUM][ipHi].l,
00169 iso.quant_desig[ipHE_LIKE][ipHELIUM][ipHi].s,
00170 iso.quant_desig[ipHE_LIKE][ipHELIUM][ipLo].n,
00171 iso.quant_desig[ipHE_LIKE][ipHELIUM][ipLo].l,
00172 iso.quant_desig[ipHE_LIKE][ipHELIUM][ipLo].s,
00173 EmisLines[ipHE_LIKE][ipHELIUM][ipHi][ipLo].WLAng );
00174
00175 if( ipHi==5 )
00176 {
00177 fprintf( ioQQQ,"%e\t",
00178 EmisLines[ipHE_LIKE][ipHELIUM][3][ipLo].xIntensity+
00179 EmisLines[ipHE_LIKE][ipHELIUM][4][ipLo].xIntensity+
00180 EmisLines[ipHE_LIKE][ipHELIUM][5][ipLo].xIntensity );
00181 }
00182 else if( ipLo==5 )
00183 {
00184 fprintf( ioQQQ,"%e\t",
00185 EmisLines[ipHE_LIKE][ipHELIUM][ipHi][3].xIntensity+
00186 EmisLines[ipHE_LIKE][ipHELIUM][ipHi][4].xIntensity+
00187 EmisLines[ipHE_LIKE][ipHELIUM][ipHi][5].xIntensity );
00188 }
00189 else
00190 {
00191 fprintf( ioQQQ,"%e\t",
00192 EmisLines[ipHE_LIKE][ipHELIUM][ipHi][ipLo].xIntensity );
00193 }
00194
00195 fprintf( ioQQQ, "\n");
00196 }
00197 }
00198 }
00199 }
00200 #endif
00201
00202
00203 lines_lv1_li_ne();
00204
00205
00206 lines_lv1_na_ar();
00207
00208
00209 lines_lv1_k_zn();
00210
00211
00212 sum = PrtLineSum( " SUM" );
00213
00214
00215 if( LineSave.ipass > 0 )
00216 LineSv[LineSave.nsum].sumlin[LineSave.lgLineEmergent] = 0.;
00217
00218 linadd(sum/radius.dVeff,0,"Stoy",'i' );
00219
00220
00221 i = StuffComment( "recombination" );
00222 linadd( 0., (float)i , "####", 'i' );
00223
00224
00225
00226
00227
00228 if( LineSave.ipass <= 0 )
00229 {
00230
00231 lgRecOn = true;
00232 }
00233
00234 for( i=0; i < 471; i++ )
00235 {
00236
00237 strcpy( chLabel, elementnames.chElementSym[(long)(LineSave.RecCoefCNO[0][i])-1] );
00238 strcat( chLabel, elementnames.chIonStage[(long)(LineSave.RecCoefCNO[0][i]-
00239 LineSave.RecCoefCNO[1][i]+1.01)-1] );
00240
00241
00242
00243
00244
00245
00246 if( dense.eden < 1e8 && lgRecOn )
00247 {
00248 f2 = LineSave.RecCoefCNO[3][i]*dense.eden*
00249 dense.xIonDense[(long)(LineSave.RecCoefCNO[0][i])-1][(long)(LineSave.RecCoefCNO[0][i]-LineSave.RecCoefCNO[1][i]+2)-1];
00250
00251
00252 f2 = f2*1.99e-8/LineSave.RecCoefCNO[2][i];
00253 }
00254 else
00255 {
00256 lgRecOn = false;
00257 f2 = 0.;
00258 }
00259
00260 PntForLine(LineSave.RecCoefCNO[2][i],chLabel,&ipnt);
00261 lindst(f2,LineSave.RecCoefCNO[2][i],chLabel,ipnt, 'r',true );
00262 }
00263
00264
00265 i = StuffComment( "level2 lines" );
00266 linadd( 0., (float)i , "####", 'i' );
00267
00268
00269
00270 ExtraCool = 0.;
00271 BigstExtra = 0.;
00272 for( i=0; i < nWindLine; i++ )
00273 {
00274 if( TauLine2[i].IonStg < TauLine2[i].nelem+1-NISO )
00275 {
00276 PutLine(&TauLine2[i]);
00277 if( TauLine2[i].cool > BigstExtra )
00278 {
00279 BigstExtra = TauLine2[i].cool;
00280 thermal.ipMaxExtra = i+1;
00281 }
00282 ExtraCool += TauLine2[i].cool;
00283 }
00284 }
00285
00286 thermal.GBarMax = MAX2(thermal.GBarMax,(float)(ExtraCool/thermal.ctot));
00287
00288
00289 i = StuffComment( "hyperfine structure" );
00290 linadd( 0., (float)i , "####", 'i' );
00291
00292
00293 linadd( hyperfine.cooling_total, 0., "hfin", 'i' );
00294
00295
00296 hyperfine.cooling_max = (float)MAX2(hyperfine.cooling_max,hyperfine.cooling_total/thermal.ctot);
00297
00298
00299 for( i=0; i < nHFLines; i++ )
00300 {
00301 PutLine(&HFLines[i]);
00302 }
00303
00304
00305 i = StuffComment( "inner shell" );
00306 linadd( 0., (float)i , "####", 'i' );
00307
00308
00309 for( i=0; i < t_yield::Inst().nlines(); ++i )
00310 {
00311 double xInten =
00312
00313 dense.xIonDense[t_yield::Inst().nelem(i)][t_yield::Inst().ion(i)] *
00314
00315 ionbal.PhotoRate_Shell[t_yield::Inst().nelem(i)][t_yield::Inst().ion(i)][t_yield::Inst().nshell(i)][0]*
00316
00317 t_yield::Inst().yield(i) *
00318
00319 t_yield::Inst().energy(i) * EN1RYD;
00320
00321
00322 if( LineSave.ipass == 0 )
00323 {
00324
00325 strcpy( chLabel , elementnames.chElementSym[t_yield::Inst().nelem(i)] );
00326 strcat( chLabel , elementnames.chIonStage[t_yield::Inst().ion_emit(i)] );
00327 # if 0
00328
00329 if( t_yield::Inst().ion(i) == 0 && t_yield::Inst().nelem(i) == ipIRON )
00330 fprintf(ioQQQ,"DEBUGyeild\t%s\t%.3f\t%.3e\n",
00331
00332 chLabel , t_yield::Inst().energy(i)*EVRYD, t_yield::Inst().yield(i) );
00333 # endif
00334 }
00335
00336
00337 lindst(
00338
00339 xInten,
00340
00341 (float)RYDLAM / t_yield::Inst().energy(i),
00342
00343 chLabel ,
00344
00345 t_yield::Inst().ipoint(i),
00346
00347 'r',
00348
00349 true );
00350 }
00351
00352
00353
00354 {
00355 static long nLineSave=-1 , ndLineSave=-1;
00356 if( LineSave.ipass == 0 )
00357 {
00358 nLineSave = LineSave.nsum;
00359 ndLineSave = LineSave.nsum;
00360 }
00361 else if( LineSave.ipass > 0 )
00362 {
00363
00364 if( nLineSave<= 0 || ndLineSave < 0 )
00365 TotalInsanity();
00366
00367
00368
00369
00370 if( nLineSave != LineSave.nsum )
00371 {
00372 fprintf( ioQQQ, "DISASTER number of lines in LineSave.nsum changed between pass 0 and 1 - this is impossible\n" );
00373 fprintf( ioQQQ, "DISASTER LineSave.nsum is %li and nLineSave is %li\n",
00374 LineSave.nsum ,
00375 nLineSave);
00376 ShowMe();
00377 puts( "[Stop in lines" );
00378 cdEXIT(EXIT_FAILURE);
00379 }
00380 if( ndLineSave != LineSave.nsum )
00381 {
00382 fprintf( ioQQQ, "DISASTER number of lines in LineSave.nsum changed between pass 0 and 1 - this is impossible\n" );
00383 fprintf( ioQQQ, "DISASTER LineSave.nsum is %li and ndLineSave is %li\n",
00384 LineSave.nsum ,
00385 ndLineSave);
00386 ShowMe();
00387 puts( "[Stop in lines" );
00388 cdEXIT(EXIT_FAILURE);
00389 }
00390 }
00391 }
00392
00393 if( trace.lgTrace )
00394 {
00395 fprintf( ioQQQ, " lines returns\n" );
00396 }
00397
00398 DEBUG_EXIT( "lines()" );
00399 return;
00400 }
00401
00402
00403 static void Drive_cdLine( void )
00404 {
00405 long int j;
00406 bool lgMustPrintHeader = true;
00407 double absval , rel;
00408
00409 DEBUG_ENTRY( "Drive_cdLine()" );
00410
00411 for( j=1; j < LineSave.nsum; j++ )
00412 {
00413 if( cdLine( LineSv[j].chALab , LineSv[j].wavelength , &absval , &rel ) <= 0 )
00414 {
00415
00416 if( lgMustPrintHeader )
00417 {
00418 fprintf(ioQQQ,"n\tlab\twl\n");
00419 lgMustPrintHeader = false;
00420 }
00421
00422 fprintf(ioQQQ,"%li\t%s\t%f\n", j, LineSv[j].chALab , LineSv[j].wavelength );
00423 }
00424 }
00425 fprintf( ioQQQ, " Thanks for checking on the cdLine routine!\n" );
00426 puts( "[Stop in Drive_cdLine]" );
00427 cdEXIT(EXIT_FAILURE);
00428 }