00001 
00002 
00003 
00004 #include "cddefines.h"
00005 #include "taulines.h"
00006 #include "dense.h"
00007 #include "phycon.h"
00008 #include "ligbar.h"
00009 #include "thermal.h"
00010 #include "lines_service.h"
00011 #include "embesq.h"
00012 #include "atoms.h"
00013 #include "cooling.h"
00014 #include "nitro.h"
00015 
00016 
00017 
00018 
00019 
00020 
00021 static const int N1_SIZE = 10;
00022 
00023 static double aNI[N1_SIZE] = {2.755e-5,4.123e-5,7.536e-6,1.486e-5,4.516e-5,-2.935e-6,4.000e-6,3.751e-6,-2.176e-6,1.024e-5};
00024 static double bNI[N1_SIZE] = {-8.150e-8,-1.220e-7,-2.226e-8,-4.390e-8,-1.130e-7,8.000e-9,-1.1447e-8,-1.061e-8,5.610e-9,-3.227e-8};
00025 static double cNI[N1_SIZE] = {2.140e-4,3.272e-4,-4.944e-6,3.473e-6,-8.772e-4,1.654e-3,1.675e-3,1.123e-3,3.867e-3,3.376e-4};
00026 
00027 static double NI[6][6][3]; 
00028 
00029 
00030 STATIC double xNI_coll_stren(int init, int final)
00031 {
00032         
00033 
00034 
00035         int i, j;
00036         double CS; 
00037         int index = 0;
00038         double temp_max = 50e3;
00039         double temp_min = 0;
00040         double temp = 0;
00041 
00042          
00043         for(i=0; i<6; i++)
00044         {
00045                 for(j=0; j<6; j++)
00046                 {
00047                         NI[i][j][0] = 0; 
00048                         NI[i][j][1] = 0; 
00049                         NI[i][j][2] = 0; 
00050                 }
00051         }
00052 
00053            
00054         
00055         for(i=1; i<6; i++)
00056         {
00057                 for(j=i+1; j<6; j++)
00058                 {
00059                         NI[i][j][0] = aNI[index];
00060                         NI[i][j][1] = bNI[index];
00061                         NI[i][j][2] = cNI[index];
00062                         index++;
00063                 }
00064         }
00065 
00066 #       ifdef PRINT
00067         
00068         for(i=1; i<6; i++)
00069         {
00070                 for(j=i+1; j<6; j++)
00071                 {
00072                         printf("NI %i%i a:%e ", i, j, NI[i][j][0]);
00073                         printf("%i%i b:%e\n", i, j, NI[i][j][1]);
00074                         
00075                 }
00076         }
00077 #       endif
00078 
00079 
00080         
00081         if(init >= final)
00082         {
00083                 CS = -1;
00084         }
00085 
00086         
00087         else if(init < 1 || init > 5 || final < 1 || final > 5)
00088         {
00089                 CS = -1;
00090         }
00091 
00092         else
00093         {
00094                 temp = MAX2(temp, temp_min); 
00095                 temp = MIN2(temp, temp_max); 
00096                 
00097                 CS = NI[init][final][0]*phycon.te + NI[init][final][1]*phycon.te32 + NI[init][final][2]*phycon.sqrte;
00098         }
00099 
00100         return CS;
00101 }
00102 
00103 
00104 void CoolNitr(void)
00105 {
00106         realnum p2;
00107         double a21, 
00108           a31, 
00109           a32, 
00110           cs, 
00111           cs2s2p, 
00112           cs2s3p, 
00113           cs21, 
00114           cs31, 
00115           cs32, 
00116           p3,
00117           pump_rate;
00118         long int i;
00119 
00120         double a12, 
00121           a13, 
00122           a14, 
00123           a15, 
00124           a23, 
00125           a24, 
00126           a25, 
00127           a34, 
00128           a35, 
00129           a45, 
00130           cs12, 
00131           cs13, 
00132           cs14, 
00133           cs15, 
00134           cs23, 
00135           cs24, 
00136           cs25, 
00137           cs34, 
00138           cs35, 
00139           cs45;
00140 
00141         double pop[5];
00142         static double gAr4[5]={4.,6.,4.,2.,4.};
00143         static double exAr4[4]={19224.464,8.713,9605.74,0.386};
00144 
00145         static long int *ipN1Pump=NULL,
00146                 nN1Pump=0 , lgFirst_N1=true;
00147 
00148         static bool lgFirst_N3=true;
00149         static long int *ipN3Pump=NULL,
00150                 nN3Pump=0;
00151 
00152 
00153 
00154 #       ifdef PRINT
00155         FILE *ofp;
00156         double pop1, pop2,pop3,pop4,pop5;
00157         ofp = fopen("c:\\projects\\cloudy\\trunk\\mydata\\pop.out", "w");
00158         if(ofp == NULL)
00159         {
00160                 printf("Can't open the file\n");
00161                 cdEXIT( EXIT_FAILURE );
00162         }
00163 #       endif
00164 
00165         DEBUG_ENTRY( "CoolNitr()" );
00166 
00167         
00168 
00169 #       if 0
00170         PutCS(1.,&TauLines[ipT671]);
00171         atom_level2(&TauLines[ipT671]);
00172 
00173         PutCS(1.,&TauLines[ipT315]);
00174         atom_level2(&TauLines[ipT315]);
00175 
00176         PutCS(1.,&TauLines[ipT333]);
00177         atom_level2(&TauLines[ipT333]);
00178 
00179         PutCS(1.,&TauLines[ipT324]);
00180         atom_level2(&TauLines[ipT324]);
00181 
00182         PutCS(1.,&TauLines[ipT374g]);
00183         atom_level2(&TauLines[ipT374g]);
00184 
00185         PutCS(1.,&TauLines[ipT374x]);
00186         atom_level2(&TauLines[ipT374x]);
00187 #       endif
00188 
00189         
00190 
00191 
00192 
00193         if( lgFirst_N1 && nWindLine && dense.lgElmtOn[ipNITROGEN] )
00194         {
00195                 lgFirst_N1 = false;
00196                 nN1Pump = 0;
00197                 for( i=0; i<nWindLine; ++i )
00198                 {
00199                         
00200                         if( TauLine2[i].Hi->nelem ==7 && TauLine2[i].Hi->IonStg==1  )
00201                         {
00202                                 ++nN1Pump;
00203                         }
00204                 }
00205                 if( nN1Pump<0 )
00206                         TotalInsanity();
00207                 else if( nN1Pump > 0 )
00208                         
00209                         ipN1Pump = (long *)MALLOC((unsigned)(nN1Pump)*sizeof(long) );
00210                 nN1Pump = 0;
00211                 for( i=0; i<nWindLine; ++i )
00212                 {
00213                         
00214                         if( TauLine2[i].Hi->nelem ==7 && TauLine2[i].Hi->IonStg==1  )
00215                         {
00216 #                               if      0
00217                                 DumpLine( &TauLine2[i] );
00218 #                               endif
00219                                 ipN1Pump[nN1Pump] = i;
00220                                 ++nN1Pump;
00221                         }
00222                 }
00223         }
00224         else
00225                 
00226                 nN1Pump = 0;
00227 
00228         
00229 
00230 
00231         nitro.pump_rate_N1 = 0.;
00232         for( i=0; i<nN1Pump; ++i )
00233         {
00234                 nitro.pump_rate_N1 += TauLine2[ipN1Pump[i]].Emis->pump;
00235 #               if      0
00236                 fprintf(ioQQQ,"DEBUG N %li %.3e %.3e\n",
00237                         i,
00238                         TauLine2[ipN1Pump[i]].WLAng , TauLine2[ipN1Pump[i]].pump );
00239 #               endif
00240         }
00241 
00242         
00243         
00244 
00245 
00246         cs21 = 1.32e-4*phycon.te/(phycon.te10*phycon.te01);
00247         cs31 = 3.60e-5*phycon.te/phycon.te10*phycon.te02;
00248         cs32 = 5.23e-4*phycon.te70*phycon.te10/phycon.te02;
00249 
00250         
00251         
00252 
00253 
00254 
00255 
00256 
00257         
00258 
00261         
00262 
00263 
00264         a21 = 1.28e-5;
00265         a31 = 5.31e-3;
00266         a32 = 6.81e-2;
00267         
00268 
00271         
00272 
00273 
00274         cs12 = xNI_coll_stren(1, 2);
00275         a12 = 7.170e-6;
00276 
00277         cs13 = xNI_coll_stren(1, 3);
00278         a13 = 3.994e-5;
00279 
00280         cs14 = xNI_coll_stren(1, 4);
00281         a14 = 5.397e-3;
00282 
00283         cs15 = xNI_coll_stren(1,5);
00284         a15 = 1.329e-2;
00285 
00286         
00287 
00288         nitro.quench_5200 = (a12+a13) / ((a12+a13) + (cs12 + cs13) * dense.cdsqte );
00289 
00290         
00291 
00292         cs23 = xNI_coll_stren(2, 3);
00293         a23 = 2.478e-8;
00294 
00295         cs24 = xNI_coll_stren(2, 4);
00296         a24 = 3.135e-2;
00297 
00298         cs25 = xNI_coll_stren(2, 5);
00299         a25 = 5.693e-2;
00300 
00301         cs34 = xNI_coll_stren(3, 4);
00302         a34 = 4.92e-2;
00303 
00304         cs35 = xNI_coll_stren(3, 5);
00305         a35 = 2.709e-2;
00306 
00307         cs45 = xNI_coll_stren(4, 5);
00308         a45 = 1e-15;
00309 
00310         atom_pop5(gAr4,exAr4,cs12,cs13,cs14,cs15,cs23,cs24,cs25,cs34,cs35,
00311                   cs45,a12,a13,a14,a15,a23,a24,a25,a34,a35,a45,pop,dense.xIonDense[ipNITROGEN][0]);
00312 
00313 #       ifdef PRINT
00314         pop1 = pop[0]/dense.xIonDense[ipNITROGEN][0];
00315         pop2 = pop[1]/dense.xIonDense[ipNITROGEN][0];
00316         pop3 = pop[2]/dense.xIonDense[ipNITROGEN][0];
00317         pop4 = pop[3]/dense.xIonDense[ipNITROGEN][0];
00318         pop5 = pop[4]/dense.xIonDense[ipNITROGEN][0];
00319         fprintf(ofp, "%lf %lf %lf %lf %lf\n", pop1, pop2, pop3, pop4, pop5);
00320 
00321 #       endif
00322 
00323         nitro.xN5200 = pop[1]*a12*3.818e-12;
00324         nitro.xN5198 = pop[2]*a13*3.821e-12;
00325         nitro.xN3467 = pop[3]*a14*5.729e-12;
00326         nitro.xN3466 = pop[4]*a15*5.729e-12;
00327         nitro.xN10398 = pop[3]*a24*1.910e-12;
00328         nitro.xN10397 = pop[4]*a25*1.910e-12;
00329         nitro.xN10408 = pop[3]*a34*1.908e-12;
00330         nitro.xN10407 = pop[4]*a35*1.908e-12;
00331 
00332         p3 = atom_pop3(4.,10.,6.,cs21,cs31,cs32,a21,a31,a32,2.769e4,1.38e4,
00333           &p2,dense.xIonDense[ipNITROGEN][0],atoms.d5200r,0.,0.);
00334         
00335         atoms.p2nit = p2/SDIV(dense.xIonDense[ipNITROGEN][0]);
00336 
00337         nitro.c5200 = p2*a21*3.83e-12;
00338         CoolAdd("N  1",5200,nitro.c5200);
00339         thermal.dCooldT += nitro.c5200*(2.769e4*thermal.tsq1 + thermal.halfte);
00340 
00341         nitro.c10400 = p3*a32*1.91e-12;
00342         CoolAdd("N  1",10400,nitro.c10400);
00343 
00344         nitro.c3466 = p3*a31*5.74e-12;
00345         CoolAdd("N  1",3466,nitro.c3466);
00346         thermal.dCooldT += (nitro.c10400 + nitro.c3466)*(4.15e4*
00347           thermal.tsq1 + thermal.halfte);
00348 
00349         
00350         PutCS(4.1,&TauLines[ipT1200]);
00351         atom_level2(&TauLines[ipT1200]);
00352 
00353         
00354         PutCS(5.5,&TauLines[ipT1085]);
00355         atom_level2(&TauLines[ipT1085]);
00356 
00357         
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367         a21 = 3.65e-3;
00368         a31 = 0.0316;
00369         a32 = 1.17;
00370         
00371 
00375 #       define USE_LENNON_BURKE 1
00376 #       if( USE_LENNON_BURKE )
00377                 cs21 = 2.64;
00378                 cs31 = 0.293;
00379                 cs32 = 0.834;
00380 #       else
00381                 
00382 
00383                 cs21 = 3.02;
00384                 cs31 = 0.372;
00385                 cs32 = 0.505;
00386 #       endif
00387 
00388         
00389         p3 = atom_pop3(  9.,5.,1.,  cs21, cs31, cs32, a21, a31, a32 ,
00390         
00391                 21955.,24982.,&p2,dense.xIonDense[ipNITROGEN][1],0.,0.,0.);
00392 
00393         nitro.c5755 = p3*a32*3.46e-12;
00394 
00395         nitro.c6584 = p2*a21*3.03e-12;
00396         thermal.dCooldT += nitro.c6584*(2.2e4*thermal.tsq1 - thermal.halfte);
00397         CoolAdd("N  2",5755,nitro.c5755);
00398         CoolAdd("N  2",6584,nitro.c6584);
00399 
00400         
00401 
00402         nitro.xN2_A3_tot = (a31+a32) /(a31+a32 + (cs31+cs32)/1.*dense.cdsqte );
00403         ASSERT( nitro.xN2_A3_tot <= 1. );
00404 
00405         
00406         
00407 #       if( USE_LENNON_BURKE )
00408         cs21 = 0.408;
00409         cs32 = 1.12;
00410         cs31 = 0.272;
00411 #       else
00412         
00413 
00414         cs21 = 0.429;
00415         cs32 = 1.13;
00416         cs31 = 0.265;
00417 #       endif
00418 
00419         PutCS(cs21,&TauLines[ipT205]);
00420         PutCS(cs32,&TauLines[ipT122]);
00421         PutCS(cs31,&TauDummy);
00422         atom_level3(&TauLines[ipT205],&TauLines[ipT122],&TauDummy);
00423 
00424         
00425 
00426 
00427 
00428 
00429 
00430 #       if( USE_LENNON_BURKE )
00431                 cs21 = 1.19;
00432 #       else
00433                 
00434 
00435                 cs21 = 1.15;
00436 #       endif
00437 
00438         PutCS(cs21,&TauLines[ipT2140]);
00439         atom_level2(&TauLines[ipT2140]);
00440 
00441         
00442 
00443         PutCS(7.12,&TauLines[ipT990]);
00444         atom_level2(&TauLines[ipT990]);
00445 
00446         
00447 
00448 
00449 
00450         cs = MIN2(1.90,0.2291*phycon.te10*phycon.te10);
00451         PutCS(cs,&TauLines[ipT57]);
00452 
00453 
00454         
00455         if( lgFirst_N3 && nWindLine && dense.lgElmtOn[ipNITROGEN] )
00456         {
00457                 lgFirst_N3 = false;
00458                 nN3Pump = 0;
00459                 for( i=0; i<nWindLine; ++i )
00460                 {
00461                         
00462                         if( TauLine2[i].Hi->nelem ==7 && TauLine2[i].Hi->IonStg==3  )
00463                         {
00464                                 ++nN3Pump;
00465                         }
00466                 }
00467                 if( nN3Pump<0 )
00468                         TotalInsanity();
00469                 else if( nN3Pump > 0 )
00470                         
00471                         ipN3Pump = (long *)MALLOC((unsigned)(nN3Pump)*sizeof(long) );
00472                 nN3Pump = 0;
00473                 for( i=0; i<nWindLine; ++i )
00474                 {
00475                         
00476                         if( TauLine2[i].Hi->nelem ==7 && TauLine2[i].Hi->IonStg==3  )
00477                         {
00478 #                               if      0
00479                                 DumpLine( &TauLine2[i] );
00480 #                               endif
00481                                 ipN3Pump[nN3Pump] = i;
00482                                 ++nN3Pump;
00483                         }
00484                 }
00485         }
00486         else
00487                 
00488                 nN3Pump = 0;
00489 
00490         
00491         pump_rate = 0.;
00492         for( i=0; i<nN3Pump; ++i )
00493         {
00494                 pump_rate += TauLine2[ipN3Pump[i]].Emis->pump;
00495 #               if      0
00496                 fprintf(ioQQQ,"DEBUG C %li %.3e %.3e\n",
00497                         i,
00498                         TauLine2[ipN3Pump[i]].WLAng , TauLine2[ipN3Pump[i]].pump );
00499 #               endif
00500         }
00501 
00502         
00503         
00504         
00505         AtomSeqBoron(&TauLines[ipT57], 
00506           &TauLines[ipN3_1749], 
00507           &TauLines[ipN3_1747], 
00508           &TauLines[ipN3_1754], 
00509           &TauLines[ipN3_1752], 
00510           &TauLines[ipN3_1751], 
00511           0.201 , 1.088 , 0.668 , 2.044 , pump_rate,"N  3");
00512         
00513 
00514 
00515 
00516 
00517 
00518 
00519         
00520 
00521 
00522 
00523         if( phycon.te > 1.584e4 )
00524         {
00525                 cs = 21.346/(phycon.te10*phycon.te10*phycon.te10*phycon.te02);
00526         }
00527         else
00528         {
00529                 cs = 75.221/(phycon.sqrte/phycon.te03/phycon.te02);
00530         }
00531         
00532         cs = MAX2(0.01,cs);
00533         PutCS(cs,&TauLines[ipT1486]);
00534         AtomSeqBeryllium(.9,.9,3.0,&TauLines[ipT1486],.0115);
00535         embesq.em1486 = (realnum)(atoms.PopLevels[3]*0.0115*1.34e-11);
00536         
00537 
00538         
00539 
00540 
00541         
00542 
00543         cs = MIN2(4.0,1.864*phycon.te03*phycon.te03);
00544         PutCS(cs,&TauLines[ipT765]);
00545         atom_level2(&TauLines[ipT765]);
00546 
00547         
00548 
00549         ligbar(7,&TauLines[ipT1239],&TauLines[ipT209],&cs2s2p,&cs2s3p);
00550         PutCS(cs2s2p,&TauLines[ipT1239]);
00551         PutCS(cs2s2p*0.5,&TauLines[ipT1243]);
00552         PutCS(1.0,&TauDummy);
00553         atom_level3(&TauLines[ipT1243],&TauDummy,&TauLines[ipT1239]);
00554         
00555 
00556         
00557         PutCS(cs2s3p,&TauLines[ipT209]);
00558         atom_level2(&TauLines[ipT209]);
00559         return;
00560 }