00001
00002
00003
00004
00005 #include "cddefines.h"
00006 #include "taulines.h"
00007 #include "iso.h"
00008 #include "phycon.h"
00009 #include "physconst.h"
00010 #include "elementnames.h"
00011 #include "hydrogenic.h"
00012 #include "lines_service.h"
00013 #include "dense.h"
00014 #include "atomfeii.h"
00015 #include "conv.h"
00016 #include "lines.h"
00017 #include "atmdat.h"
00018 #include "prt.h"
00019 #include "h2.h"
00020 #include "thermal.h"
00021 #include "cooling.h"
00022 #include "save.h"
00023 #include "mole.h"
00024
00025 NORETURN void SaveLineData(FILE * ioPUN)
00026 {
00027
00028 long int i,
00029 j,
00030 limit ,
00031 nelem ,
00032 ipHi ,
00033 ipLo;
00034
00035 const long nskip=2;
00036 double tot;
00037 bool lgElemOff=false;
00038
00039 DEBUG_ENTRY( "SaveLineData()" );
00040
00041
00042
00043
00044
00045 fprintf( ioQQQ, " saving line data, then stopping\n" );
00046
00047
00048 for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem )
00049 {
00050 if( !dense.lgElmtOn[nelem] )
00051 {
00052 fprintf(ioQQQ," WARNING - I am saving line data but element %s is turned off.\n",
00053 elementnames.chElementName[nelem]);
00054 lgElemOff = true;
00055 }
00056 }
00057 if( lgElemOff )
00058 {
00059 fprintf(ioQQQ,"Some elements are turned off and save line data requested.\n");
00060 fprintf(ioQQQ,"Code is now designed to do save line data only with all elements on.\n");
00061 fprintf(ioQQQ,"Please try again with all elements on.\n");
00062 fprintf(ioQQQ,"Please try again with all elements on.\n");
00063 cdEXIT(EXIT_FAILURE);
00064 }
00065
00066
00067
00068 double TeNew;
00069 if( thermal.lgTemperatureConstant )
00070 {
00071 TeNew = thermal.ConstTemp;
00072 }
00073 else
00074 {
00075 TeNew = 1e4;
00076 }
00077 TempChange(TeNew , false);
00078
00079
00080 t_ADfA::Inst().rec_lines(phycon.te,LineSave.RecCoefCNO);
00081 fprintf( ioPUN, "\n Recombination lines of C, N, O\n" );
00082 fprintf( ioPUN, "#Ion\tWL(A)\tCoef\tIon\tWL(A)\tCoef\n" );
00083 for( i=0; i<471; i+=nskip)
00084 {
00085
00086 limit = MIN2(471,i+nskip);
00087 fprintf( ioPUN, " " );
00088 for( j=i; j < limit; j++ )
00089 {
00090 fprintf( ioPUN, "%2.2s%2ld\t%6ld\t%8.3f\t",
00091 elementnames.chElementSym[(long)(LineSave.RecCoefCNO[0][j])-1],
00092 (long)(LineSave.RecCoefCNO[0][j]-LineSave.RecCoefCNO[1][j]+1.01),
00093 (long)(LineSave.RecCoefCNO[2][j]+0.5),
00094 log10(SDIV(LineSave.RecCoefCNO[3][j]) ) );
00095 }
00096 fprintf( ioPUN, " \n" );
00097 }
00098 fprintf( ioPUN, "\n\n" );
00099
00100 dense.SetGasPhaseDensity( ipHYDROGEN, 1. );
00101 dense.EdenHCorr = 1.;
00102 EdenChange( 1. );
00103
00104
00105 dense.xIonDense[ipHYDROGEN][1] = 1.e-5f;
00106 findspecieslocal("H2")->den = 0.;
00107 dense.xIonDense[ipHYDROGEN][1] = 1.;
00108 for( i=1; i <= nLevel1; i++ )
00109 {
00110 TauLines[i].Lo()->Pop() = 1.;
00111 }
00112
00113 for( i=0; i < nWindLine; i++ )
00114 {
00115 TauLine2[i].Lo()->Pop() = 1.;
00116 }
00117
00118 for( i=0; i < nUTA; i++ )
00119 {
00120 (*UTALines[i].Lo()).Pop() = 1.;
00121 }
00122
00123 for( i=0; i < LIMELM; i++ )
00124 {
00125 for( j=0; j < LIMELM+1; j++ )
00126 {
00127 dense.xIonDense[i][j] = 1.;
00128 }
00129 }
00130
00131
00132 CoolEvaluate(&tot);
00133
00134 fprintf( ioPUN, " Level 1 transferred lines\n" );
00135 bool lgPrint = true;
00136 for( i=1; i <= nLevel1; i++ )
00137 {
00138
00139
00140
00141
00142 Save1LineData( TauLines[i] , ioPUN , true , lgPrint );
00143 }
00144
00145 fprintf( ioPUN, "\n\n\n end level 1, start level 2\n" );
00146 lgPrint = true;
00147 for( i=0; i < nWindLine; i++ )
00148 {
00149 if( (*TauLine2[i].Hi()).IonStg() < (*TauLine2[i].Hi()).nelem()+1-NISO )
00150 {
00151 Save1LineData( TauLine2[i] , ioPUN , true , lgPrint );
00152 }
00153 }
00154
00155 fprintf( ioPUN, "\n\n\n end level 2, start inner shell UTA\n" );
00156 lgPrint = true;
00157 for( i=0; i < nUTA; i++ )
00158 {
00159 Save1LineData( UTALines[i] , ioPUN , true , lgPrint);
00160 }
00161
00162 fprintf( ioPUN, "\n\n\n end inner shell, start H-like iso seq\n" );
00163
00164
00165 lgPrint = true;
00166 for( nelem=0; nelem < LIMELM; nelem++ )
00167 {
00168 iso_collide( ipH_LIKE, nelem );
00169 if( nelem < 2 || dense.lgElmtOn[nelem] )
00170 {
00171
00172
00173 for( ipLo=ipH1s; ipLo < iso_sp[ipH_LIKE][nelem].numLevels_max-1; ipLo++ )
00174 {
00175 for( ipHi=ipLo+1; ipHi < iso_sp[ipH_LIKE][nelem].numLevels_max; ipHi++ )
00176 {
00177 Save1LineData( iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo) , ioPUN , false,lgPrint );
00178 }
00179 }
00180 }
00181 }
00182
00183 fprintf( ioPUN, "\n\n\n end H-like iso seq, start He-like iso seq\n" );
00184 lgPrint = true;
00185 for( nelem=1; nelem < LIMELM; nelem++ )
00186 {
00187 if( nelem < 2 || dense.lgElmtOn[nelem] )
00188 {
00189
00190 for( ipLo=ipHe1s1S; ipLo < iso_sp[ipHE_LIKE][nelem].numLevels_max-1; ipLo++ )
00191 {
00192 for( ipHi=ipLo+1; ipHi < iso_sp[ipHE_LIKE][nelem].numLevels_max; ipHi++ )
00193 {
00194 Save1LineData( iso_sp[ipHE_LIKE][nelem].trans(ipHi,ipLo) , ioPUN , false,lgPrint );
00195 }
00196 }
00197 }
00198 }
00199
00200 fprintf( ioPUN, "\n\n\n end he-like iso seq, start hyperfine structure lines\n" );
00201
00202 lgPrint = true;
00203 for( i=0; i < nHFLines; i++ )
00204 {
00205 Save1LineData( HFLines[i] , ioPUN , true , lgPrint);
00206 }
00207
00208 fprintf( ioPUN, "\n\n\n end hyperfine, start database lines\n" );
00209
00210 lgPrint = true;
00211 for (int ipSpecies=0; ipSpecies < nSpecies; ++ipSpecies)
00212 {
00213 for( EmissionList::iterator em=dBaseTrans[ipSpecies].Emis().begin();
00214 em != dBaseTrans[ipSpecies].Emis().end(); ++em)
00215 {
00216 Save1LineData( (*em).Tran() , ioPUN , true , lgPrint);
00217 }
00218 }
00219
00220 fprintf( ioPUN, "\n\n\n end database, start satellite lines\n" );
00221 lgPrint = true;
00222 for( long ipISO = ipHE_LIKE; ipISO < NISO; ipISO++ )
00223 {
00224 for( long nelem = ipISO; nelem < LIMELM; nelem++ )
00225 {
00226
00227 if( nelem == ipISO || dense.lgElmtOn[nelem] )
00228 {
00229 for( i=0; i<iso_sp[ipISO][nelem].numLevels_max; i++ )
00230 {
00231 Save1LineData( SatelliteLines[ipISO][nelem][ipSatelliteLines[ipISO][nelem][i]],
00232 ioPUN , true , lgPrint );
00233 }
00234 }
00235 }
00236 }
00237
00238
00239 dense.SetGasPhaseDensity( ipHYDROGEN, 1e-6f );
00240 dense.EdenHCorr = 1e-6f;
00241 findspecieslocal("H2")->den = 1.;
00242 findspecieslocal("H2*")->den = 1.;
00243 dense.xIonDense[ipHYDROGEN][1] = 1e-6;
00244 EdenChange( 1e-6 );
00245
00246
00247 fprintf( ioPUN, "\n\n\n" );
00248 fprintf( ioPUN, " end satellite, start H2 lines\n" );
00249
00250
00251
00252 for( diatom_iter diatom = diatoms.begin(); diatom != diatoms.end(); ++diatom )
00253 {
00254 bool lgPopsConverged;
00255 double old_val, new_val;
00256 (*diatom)->H2_LevelPops( lgPopsConverged, old_val, new_val );
00257 (*diatom)->H2_Punch_line_data( ioPUN, false );
00258 }
00259
00260
00261 fprintf( ioPUN, "\n\n\n" );
00262 fprintf( ioPUN, " end H2, start FeII lines\n" );
00263
00264
00265
00266 FeIIPunData( ioPUN , false );
00267
00268
00269
00270 fprintf( ioQQQ , "\n The code is left in a disturbed state after creating the SAVE LINE DATA file.\n"
00271 " No calculation is actually performed, only the SAVE LINE DATA file is produced.\n"
00272 " Remove the SAVE LINE DATA command to do the calculation.\n\n ChkMonitorend is ok.\n" );
00273
00274
00275 cdEXIT(EXIT_SUCCESS);
00276 }
00277
00278
00279 void Save1LineData( const TransitionProxy& t , FILE * ioPUN ,
00280
00281
00282 bool lgCS_2 ,
00283
00284 bool &lgPrintHead )
00285 {
00286
00287 double CritDen;
00288
00289 char chLbl[11];
00290
00291 DEBUG_ENTRY( "Save1LineData()" );
00292
00293 if( lgPrintHead )
00294 fprintf( ioPUN, "#Ion\tWL\tgl\tgu\tgf\tA\tCS\tn(crt)\tdamp\n" );
00295 lgPrintHead = false;
00296
00297 if( t.ipCont() <= 0 )
00298 {
00299
00300 return;
00301 }
00302
00308
00309
00310 chIonLbl(chLbl , t );
00311 fprintf(ioPUN,"%s\t", chLbl );
00312
00313
00314
00315
00316 if( strcmp( save.chConPunEnr[save.ipConPun], "labl" )== 0 )
00317 {
00318 prt_wl( ioPUN , t.WLAng() );
00319 }
00320 else
00321 {
00322
00323 fprintf( ioPUN , "%.5e", AnuUnit((realnum)(t.EnergyRyd())) );
00324 }
00325
00326 fprintf( ioPUN, "\t%3ld\t%3ld",
00327
00328 (long)((*t.Lo()).g()),
00329 (long)((*t.Hi()).g()) );
00330
00331
00332 fprintf( ioPUN,PrintEfmt("\t%9.2e", t.Emis().gf()));
00333
00334
00335 fprintf( ioPUN,PrintEfmt("\t%9.2e", t.Emis().Aul()));
00336
00337
00338
00339 if( t.Coll().col_str() > 100. )
00340 {
00341 fprintf( ioPUN, "\t%7.1f", t.Coll().col_str() );
00342 }
00343 else if( t.Coll().col_str() > 10. )
00344 {
00345 fprintf( ioPUN, "\t%7.2f", t.Coll().col_str() );
00346 }
00347 else if( t.Coll().col_str() > 1. )
00348 {
00349 fprintf( ioPUN, "\t%7.3f", t.Coll().col_str() );
00350 }
00351 else if( t.Coll().col_str() > .01 )
00352 {
00353 fprintf( ioPUN, "\t%7.4f", t.Coll().col_str() );
00354 }
00355 else if( t.Coll().col_str() > 0.0 )
00356 {
00357 fprintf( ioPUN, "\t%.3e", t.Coll().col_str() );
00358 }
00359 else
00360 {
00361 fprintf( ioPUN, "\t%7.4f", 0. );
00362 }
00363
00364
00365
00366
00367 if( lgCS_2 && t.Coll().col_str()> 0. )
00368 {
00369 CritDen = t.Emis().Aul() * (*t.Hi()).g()*phycon.sqrte / (t.Coll().col_str()*COLL_CONST);
00370 }
00371 else
00372 {
00373 CritDen = 0.;
00374 }
00375 fprintf( ioPUN, "\t%.3e",CritDen );
00376
00377
00378 fprintf( ioPUN,PrintEfmt("\t%9.2e", t.Emis().damp() ));
00379
00380 fprintf( ioPUN, "\n" );
00381
00382 return;
00383 }