00001
00002
00003
00004 #include "cddefines.h"
00005 #include "cooling.h"
00006 #include "thermal.h"
00007 #include "dense.h"
00008 #include "atoms.h"
00009
00010 void AtomSeqBoron(
00011
00012
00013 EmLine * t10,
00014 EmLine * t20,
00015 EmLine * t30,
00016 EmLine * t21,
00017 EmLine * t31,
00018 EmLine * t41,
00019 double cs40,
00020 double cs32,
00021 double cs42,
00022 double cs43,
00023
00024 double pump_rate ,
00025
00026 const char *chLabel
00027 )
00028 {
00029
00030
00031
00032
00033
00034
00035
00036 # define N_SEQ_BORON 5
00037 static double
00038 **AulEscp ,
00039 **col_str ,
00040 **AulDest,
00041
00042 **AulPump,
00043 **CollRate,
00044 *pops,
00045 *create,
00046 *destroy,
00047 *depart,
00048
00049 *stat ,
00050
00051 *excit;
00052
00053 double b_cooling,
00054 dCoolDT;
00055 double EnrLU, EnrUL;
00056 float abundan;
00057
00058 static bool lgFirst=true,
00059 lgZeroPop;
00060 int i , j;
00061 int
00062
00063 lgNegPop;
00064
00065 bool lgDeBug;
00066
00067 DEBUG_ENTRY( "AtomSeqBoron()" );
00068
00069 if( lgFirst )
00070 {
00071
00072 lgFirst = false;
00073
00074 excit = (double *)MALLOC( sizeof(double)*(N_SEQ_BORON) );
00075 stat = (double *)MALLOC( sizeof(double)*(N_SEQ_BORON) );
00076 pops = (double *)MALLOC( sizeof(double)*(N_SEQ_BORON) );
00077 create = (double *)MALLOC( sizeof(double)*(N_SEQ_BORON) );
00078 destroy = (double *)MALLOC( sizeof(double)*(N_SEQ_BORON) );
00079 depart = (double *)MALLOC( sizeof(double)*(N_SEQ_BORON) );
00080
00081 AulPump = ((double **)MALLOC((N_SEQ_BORON)*sizeof(double *)));
00082 CollRate = ((double **)MALLOC((N_SEQ_BORON)*sizeof(double *)));
00083 AulDest = ((double **)MALLOC((N_SEQ_BORON)*sizeof(double *)));
00084 AulEscp = ((double **)MALLOC((N_SEQ_BORON)*sizeof(double *)));
00085 col_str = ((double **)MALLOC((N_SEQ_BORON)*sizeof(double *)));
00086 for( i=0; i<(N_SEQ_BORON); ++i )
00087 {
00088 AulPump[i] = ((double *)MALLOC((N_SEQ_BORON)*sizeof(double )));
00089 CollRate[i] = ((double *)MALLOC((N_SEQ_BORON)*sizeof(double )));
00090 AulDest[i] = ((double *)MALLOC((N_SEQ_BORON)*sizeof(double )));
00091 AulEscp[i] = ((double *)MALLOC((N_SEQ_BORON)*sizeof(double )));
00092 col_str[i] = ((double *)MALLOC((N_SEQ_BORON)*sizeof(double )));
00093 }
00094 }
00095
00096
00097 abundan = dense.xIonDense[ t10->nelem -1][t10->IonStg-1];
00098 if( abundan <= 0. )
00099 {
00100
00101 t10->PopLo = 0.;
00102 t20->PopLo = 0.;
00103 t30->PopLo = 0.;
00104 t21->PopLo = 0.;
00105 t31->PopLo = 0.;
00106 t41->PopLo = 0.;
00107
00108 t10->PopOpc = 0.;
00109 t20->PopOpc = 0.;
00110 t30->PopOpc = 0.;
00111 t21->PopOpc = 0.;
00112 t31->PopOpc = 0.;
00113 t41->PopOpc = 0.;
00114
00115 t10->PopHi = 0.;
00116 t20->PopHi = 0.;
00117 t30->PopHi = 0.;
00118 t21->PopHi = 0.;
00119 t31->PopHi = 0.;
00120 t41->PopHi = 0.;
00121
00122 t10->xIntensity = 0.;
00123 t20->xIntensity = 0.;
00124 t30->xIntensity = 0.;
00125 t21->xIntensity = 0.;
00126 t31->xIntensity = 0.;
00127 t41->xIntensity = 0.;
00128
00129 t10->cool = 0.;
00130 t20->cool = 0.;
00131 t30->cool = 0.;
00132 t21->cool = 0.;
00133 t31->cool = 0.;
00134 t41->cool = 0.;
00135
00136 t10->phots = 0.;
00137 t20->phots = 0.;
00138 t30->phots = 0.;
00139 t21->phots = 0.;
00140 t31->phots = 0.;
00141 t41->phots = 0.;
00142
00143 t10->ColOvTot = 0.;
00144 t20->ColOvTot = 0.;
00145 t30->ColOvTot = 0.;
00146 t21->ColOvTot = 0.;
00147 t31->ColOvTot = 0.;
00148 t41->ColOvTot = 0.;
00149
00150 t10->heat = 0.;
00151 t20->heat = 0.;
00152 t30->heat = 0.;
00153 t21->heat = 0.;
00154 t31->heat = 0.;
00155 t41->heat = 0.;
00156
00157 CoolAdd( chLabel, t10->WLAng , 0.);
00158 CoolAdd( chLabel, t20->WLAng , 0.);
00159 CoolAdd( chLabel, t30->WLAng , 0.);
00160 CoolAdd( chLabel, t21->WLAng , 0.);
00161 CoolAdd( chLabel, t31->WLAng , 0.);
00162 CoolAdd( chLabel, t41->WLAng , 0.);
00163
00164
00165
00166 ASSERT( N_SEQ_BORON <= LIMLEVELN);
00167 for( i=0; i < N_SEQ_BORON; i++ )
00168 {
00169 atoms.PopLevels[i] = 0.;
00170 atoms.DepLTELevels[i] = 1.;
00171 }
00172
00173 DEBUG_EXIT( "AtomSeqBoron()" );
00174 return;
00175 }
00176
00177 ASSERT( t10->cs > 0.);
00178 ASSERT( t20->cs > 0.);
00179 ASSERT( t30->cs > 0.);
00180 ASSERT( t21->cs > 0.);
00181 ASSERT( t31->cs > 0.);
00182 ASSERT( t41->cs > 0.);
00183 ASSERT( cs40>0.);
00184 ASSERT( cs32>0.);
00185 ASSERT( cs42>0.);
00186 ASSERT( cs43>0.);
00187
00188
00189 for( i=0; i < N_SEQ_BORON; i++ )
00190 {
00191 create[i] = 0.;
00192 destroy[i] = 0.;
00193 for( j=0; j < N_SEQ_BORON; j++ )
00194 {
00195
00196 AulEscp[j][i] = 0.;
00197 AulDest[j][i] = 0.;
00198 AulPump[j][i] = 0.;
00199 col_str[j][i] = 0.;
00200 }
00201 }
00202
00203
00204 stat[0] = t10->gLo;
00205 stat[1] = t10->gHi;
00206 stat[2] = t20->gHi;
00207 stat[3] = t30->gHi;
00208 stat[4] = t41->gHi;
00209 ASSERT( stat[0]>0. && stat[1]>0. &&stat[2]>0. &&stat[3]>0. &&stat[4]>0.);
00210 ASSERT( fabs(t10->gLo/2.-1.) < FLT_EPSILON);
00211 ASSERT( fabs(t10->gHi/4.-1.) < FLT_EPSILON);
00212 ASSERT( fabs(t20->gLo/2.-1.) < FLT_EPSILON);
00213 ASSERT( fabs(t20->gHi/2.-1.) < FLT_EPSILON);
00214 ASSERT( fabs(t30->gLo/2.-1.) < FLT_EPSILON);
00215 ASSERT( fabs(t30->gHi/4.-1.) < FLT_EPSILON);
00216 ASSERT( fabs(t21->gLo/4.-1.) < FLT_EPSILON);
00217 ASSERT( fabs(t21->gHi/2.-1.) < FLT_EPSILON);
00218 ASSERT( fabs(t31->gLo/4.-1.) < FLT_EPSILON);
00219 ASSERT( fabs(t31->gHi/4.-1.) < FLT_EPSILON);
00220 ASSERT( fabs(t41->gLo/4.-1.) < FLT_EPSILON);
00221 ASSERT( fabs(t41->gHi/6.-1.) < FLT_EPSILON);
00222
00223
00224 excit[0] = 0.;
00225 excit[1] = t10->EnergyK;
00226 excit[2] = t20->EnergyK;
00227 excit[3] = t30->EnergyK;
00228 excit[4] = t41->EnergyK + t10->EnergyK;
00229 ASSERT( excit[1]>0. &&excit[2]>0. &&excit[3]>0. &&excit[4]>0.);
00230
00231
00232
00233 AulEscp[1][0] = t10->Aul*(t10->Pesc + t10->Pelec_esc);
00234 AulDest[1][0] = t10->Aul*t10->Pdest;
00235
00236 col_str[1][0] = t10->cs;
00237 AulPump[0][1] = t10->pump;
00238
00239
00240 AulPump[0][1] += pump_rate;
00241
00242
00243 AulEscp[2][0] = t20->Aul*(t20->Pesc + t20->Pelec_esc);
00244 AulDest[2][0] = t20->Aul*t20->Pdest;
00245
00246 col_str[2][0] = t20->cs;
00247 AulPump[0][2] = t20->pump;
00248
00249
00250 AulEscp[3][0] = t30->Aul*(t30->Pesc + t30->Pelec_esc);
00251 AulDest[3][0] = t30->Aul*t30->Pdest;
00252
00253 col_str[3][0] = t30->cs;
00254 AulPump[0][3] = t30->pump;
00255
00256
00257 AulEscp[4][0] = 1e-8;
00258 AulDest[4][0] = 0.;
00259
00260 col_str[4][0] = cs40;
00261 AulPump[0][4] = 0.;
00262
00263
00264 AulEscp[2][1] = t21->Aul*(t21->Pesc + t21->Pelec_esc);
00265 AulDest[2][1] = t21->Aul*t21->Pdest;
00266
00267 col_str[2][1] = t21->cs;
00268 AulPump[1][2] = t21->pump;
00269
00270
00271 AulEscp[3][1] = t31->Aul*(t31->Pesc + t31->Pelec_esc);
00272 AulDest[3][1] = t31->Aul*t31->Pdest;
00273
00274 col_str[3][1] = t31->cs;
00275 AulPump[1][3] = t31->pump;
00276
00277
00278 AulEscp[4][1] = t41->Aul*(t41->Pesc + t41->Pelec_esc);
00279 AulDest[4][1] = t41->Aul*t41->Pdest;
00280
00281 col_str[4][1] = t41->cs;
00282 AulPump[1][4] = t41->pump;
00283
00284
00285 AulEscp[3][2] = 1e-8;
00286 AulDest[3][2] = 0.;
00287
00288 col_str[3][2] = cs32;
00289 AulPump[2][3] = 0.;
00290
00291
00292 AulEscp[4][2] = 1e-8;
00293 AulDest[4][2] = 0.;
00294
00295 col_str[4][2] = cs42;
00296 AulPump[2][4] = 0.;
00297
00298
00299 AulEscp[4][3] = 1e-8;
00300 AulDest[4][3] = 0.;
00301
00302 col_str[4][3] = cs43;
00303 AulPump[3][4] = 0.;
00304
00305 lgDeBug = false;
00306 # if 0
00307 if( strcmp( chLabel , "N 3" ) == 0)
00308 lgDeBug = true;
00309 # endif
00310
00311
00312 atom_levelN(N_SEQ_BORON,
00313 abundan,
00314 stat,
00315 excit,
00316 'K',
00317 pops,
00318 depart,
00319 &AulEscp,
00320 &col_str,
00321 &AulDest,
00322 &AulPump,
00323 &CollRate,
00324 create,
00325 destroy,
00326 false,
00327 &b_cooling,
00328 &dCoolDT,
00329 chLabel,
00330 &lgNegPop,
00331 &lgZeroPop,
00332 lgDeBug );
00333
00334
00335
00336
00337 if( lgNegPop < 0 )
00338 {
00339
00340
00341 atom_level2(t10);
00342
00343
00344
00345 t20->PopLo = atoms.PopLevels[0];
00346 t30->PopLo = atoms.PopLevels[0];
00347 t21->PopLo = atoms.PopLevels[1];
00348 t31->PopLo = atoms.PopLevels[1];
00349 t41->PopLo = atoms.PopLevels[1];
00350
00351 t20->PopOpc = atoms.PopLevels[0];
00352 t30->PopOpc = atoms.PopLevels[0];
00353 t21->PopOpc = atoms.PopLevels[1];
00354 t31->PopOpc = atoms.PopLevels[1];
00355 t41->PopOpc = atoms.PopLevels[1];
00356
00357 t20->PopHi = 0.;
00358 t30->PopHi = 0.;
00359 t21->PopHi = 0.;
00360 t31->PopHi = 0.;
00361 t41->PopHi = 0.;
00362
00363 t20->xIntensity = 0.;
00364 t30->xIntensity = 0.;
00365 t21->xIntensity = 0.;
00366 t31->xIntensity = 0.;
00367 t41->xIntensity = 0.;
00368
00369 t20->cool = 0.;
00370 t30->cool = 0.;
00371 t21->cool = 0.;
00372 t31->cool = 0.;
00373 t41->cool = 0.;
00374
00375 t20->phots = 0.;
00376 t30->phots = 0.;
00377 t21->phots = 0.;
00378 t31->phots = 0.;
00379 t41->phots = 0.;
00380
00381 # if 0
00382
00383 t20->ots = 0.;
00384 t30->ots = 0.;
00385 t21->ots = 0.;
00386 t31->ots = 0.;
00387 t41->ots = 0.;
00388 # endif
00389
00390 t20->ColOvTot = 0.;
00391 t30->ColOvTot = 0.;
00392 t21->ColOvTot = 0.;
00393 t31->ColOvTot = 0.;
00394 t41->ColOvTot = 0.;
00395
00396 t20->heat = 0.;
00397 t30->heat = 0.;
00398 t21->heat = 0.;
00399 t31->heat = 0.;
00400 t41->heat = 0.;
00401
00402 CoolAdd( chLabel, t20->WLAng , 0.);
00403 CoolAdd( chLabel, t30->WLAng , 0.);
00404 CoolAdd( chLabel, t21->WLAng , 0.);
00405 CoolAdd( chLabel, t31->WLAng , 0.);
00406 CoolAdd( chLabel, t41->WLAng , 0.);
00407
00408
00409
00410 ASSERT( N_SEQ_BORON <= LIMLEVELN);
00411 for( i=2; i < N_SEQ_BORON; i++ )
00412 {
00413 atoms.PopLevels[i] = 0.;
00414 atoms.DepLTELevels[i] = 1.;
00415 }
00416
00417 }
00418 else
00419 {
00420
00421
00422 ASSERT( N_SEQ_BORON <= LIMLEVELN);
00423 for( i=0; i< N_SEQ_BORON; ++i )
00424 {
00425 atoms.PopLevels[i] = pops[i];
00426 atoms.DepLTELevels[i] = depart[i];
00427 }
00428
00429 t10->PopLo = pops[0];
00430 t20->PopLo = pops[0];
00431 t30->PopLo = pops[0];
00432 t21->PopLo = pops[1];
00433 t31->PopLo = pops[1];
00434 t41->PopLo = pops[1];
00435
00436 t10->PopOpc = (pops[0] - pops[1]*t10->gLo/t10->gHi);
00437 t20->PopOpc = (pops[0] - pops[2]*t20->gLo/t20->gHi);
00438 t30->PopOpc = (pops[0] - pops[3]*t30->gLo/t30->gHi);
00439 t21->PopOpc = (pops[1] - pops[2]*t21->gLo/t21->gHi);
00440 t31->PopOpc = (pops[1] - pops[3]*t31->gLo/t31->gHi);
00441 t41->PopOpc = (pops[1] - pops[4]*t41->gLo/t41->gHi);
00442
00443 t10->PopHi = pops[1];
00444 t20->PopHi = pops[2];
00445 t30->PopHi = pops[3];
00446 t21->PopHi = pops[2];
00447 t31->PopHi = pops[3];
00448 t41->PopHi = pops[4];
00449
00450 t10->phots = t10->Aul*(t10->Pesc + t10->Pelec_esc)*pops[1];
00451 t20->phots = t20->Aul*(t20->Pesc + t20->Pelec_esc)*pops[2];
00452 t30->phots = t30->Aul*(t30->Pesc + t30->Pelec_esc)*pops[3];
00453 t21->phots = t21->Aul*(t21->Pesc + t21->Pelec_esc)*pops[2];
00454 t31->phots = t31->Aul*(t31->Pesc + t31->Pelec_esc)*pops[3];
00455 t41->phots = t41->Aul*(t41->Pesc + t41->Pelec_esc)*pops[4];
00456
00457 t10->xIntensity = t10->phots*t10->EnergyErg;
00458 t20->xIntensity = t20->phots*t20->EnergyErg;
00459 t30->xIntensity = t30->phots*t30->EnergyErg;
00460 t21->xIntensity = t21->phots*t21->EnergyErg;
00461 t31->xIntensity = t31->phots*t31->EnergyErg;
00462 t41->xIntensity = t41->phots*t41->EnergyErg;
00463
00464
00465 t10->ColOvTot = (float)(CollRate[0][1]/(CollRate[0][1]+t10->pump) );
00466 t20->ColOvTot = (float)(CollRate[0][2]/(CollRate[0][2]+t20->pump) );
00467 t30->ColOvTot = (float)(CollRate[0][3]/(CollRate[0][3]+t30->pump) );
00468 t21->ColOvTot = (float)(CollRate[1][2]/(CollRate[1][2]+t21->pump) );
00469 t31->ColOvTot = (float)(CollRate[1][3]/(CollRate[1][3]+t31->pump) );
00470 t41->ColOvTot = (float)(CollRate[1][4]/(CollRate[1][4]+t41->pump) );
00471
00472
00473 thermal.dCooldT += dCoolDT;
00474
00475
00476
00477
00478
00479
00480
00481
00482 EnrLU = t10->PopLo*CollRate[0][1]*t10->EnergyErg;
00483 EnrUL = t10->PopHi*CollRate[1][0]*t10->EnergyErg;
00484
00485
00486 t10->cool = EnrLU - EnrUL*t10->ColOvTot;
00487
00488 t10->heat = EnrUL*(1. - t10->ColOvTot);
00489
00490 CoolAdd( chLabel, t10->WLAng , t10->cool);
00491
00492 EnrLU = t20->PopLo*CollRate[0][2]*t20->EnergyErg;
00493 EnrUL = t20->PopHi*CollRate[2][0]*t20->EnergyErg;
00494 t20->cool = EnrLU - EnrUL*t20->ColOvTot;
00495 t20->heat = EnrUL*(1. - t20->ColOvTot);
00496
00497 CoolAdd( chLabel, t20->WLAng , t20->cool);
00498
00499 EnrLU = t30->PopLo*CollRate[0][3]*t30->EnergyErg;
00500 EnrUL = t30->PopHi*CollRate[3][0]*t30->EnergyErg;
00501 t30->cool = EnrLU - EnrUL*t30->ColOvTot;
00502 t30->heat = EnrUL*(1. - t30->ColOvTot);
00503
00504 CoolAdd( chLabel, t30->WLAng , t30->cool);
00505
00506 EnrLU = t21->PopLo*CollRate[1][2]*t21->EnergyErg;
00507 EnrUL = t21->PopHi*CollRate[2][1]*t21->EnergyErg;
00508 t21->cool = EnrLU - EnrUL*t21->ColOvTot;
00509 t21->heat = EnrUL*(1. - t21->ColOvTot);
00510
00511 CoolAdd( chLabel, t21->WLAng , t21->cool);
00512
00513 EnrLU = t31->PopLo*CollRate[1][3]*t31->EnergyErg;
00514 EnrUL = t31->PopHi*CollRate[3][1]*t31->EnergyErg;
00515 t31->cool = EnrLU - EnrUL*t31->ColOvTot;
00516 t31->heat = EnrUL*(1. - t31->ColOvTot);
00517
00518 CoolAdd( chLabel, t31->WLAng , t31->cool);
00519
00520 EnrLU = t41->PopLo*CollRate[1][4]*t41->EnergyErg;
00521 EnrUL = t41->PopHi*CollRate[4][1]*t41->EnergyErg;
00522 t41->cool = EnrLU - EnrUL*t41->ColOvTot;
00523 t41->heat = EnrUL*(1. - t41->ColOvTot);
00524
00525 CoolAdd( chLabel, t41->WLAng , t41->cool);
00526
00527 }
00528
00529 DEBUG_EXIT( "AtomSeqBoron()" );
00530
00531 return;
00532 }
00533