Changeset 2030

Show
Ignore:
Timestamp:
05/07/08 15:16:20 (1 week ago)
Author:
gary
Message:

Nemala's changes to chianti/lambda data base readd

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/source/atmdat_chianti.cpp

    r1925 r2030  
    1818        /* type is set to 0 for non chianti and 1 for chianti*/ 
    1919        long int i,j,nMolLevs,intCollTran,intcollindex,ipLo,ipHi; 
    20         FILE *atmolLevDATA , *atmolTraDATA=NULL,*atmolEleColDATA=NULL
     20        FILE *atmolLevDATA , *atmolTraDATA=NULL,*atmolEleColDATA=NULL,*atmolProColDATA=NULL
    2121        realnum  fstatwt,fenergyK,fenergyWN,fWLAng,fenergy,feinsteina; 
    2222        double fScalingParam,fEnergyDiff,fGF,*xs,*spl,*spl2; 
     
    4040        long int *intNewIndex=NULL,*intOldIndex=NULL; 
    4141        int interror; 
    42         bool lgEneLevOrder; 
     42        bool lgProtonData=false,lgEneLevOrder; 
    4343 
    4444        /*This is to identify where the fields start */ 
     
    9999        if( trace.lgTrace ) 
    100100                fprintf( ioQQQ," moldat_readin opening %s:",chProColFilename); 
     101        /*We will set a flag here to indicate if the proton collision strengths are available */ 
     102        if( ( atmolProColDATA = fopen( chProColFilename , "r" ) ) != NULL ) 
     103        { 
     104                lgProtonData = true; 
     105        } 
     106        else 
     107        { 
     108                lgProtonData = false; 
     109        } 
    101110 
    102111        nMolLevs = 0; 
     
    146155        for( intcollindex = 0; intcollindex<NUM_COLLIDERS; intcollindex++ ) 
    147156        { 
    148                 CollRatesArray[intNS][intcollindex] = (double**)MALLOC((nMolLevs)*sizeof(double*)); 
     157                CollRatesArray[intNS][intcollindex] = NULL; 
     158        } 
     159        /*Allocating space just for the electron*/ 
     160        CollRatesArray[intNS][0] = (double**)MALLOC((nMolLevs)*sizeof(double*)); 
     161        for( ipHi = 0; ipHi<nMolLevs; ipHi++ ) 
     162        { 
     163                CollRatesArray[intNS][0][ipHi] = (double*)MALLOC((unsigned long)(nMolLevs)*sizeof(double)); 
     164                for( ipLo = 0; ipLo<nMolLevs; ipLo++) 
     165                { 
     166                        CollRatesArray[intNS][0][ipHi][ipLo] = 0.0; 
     167                } 
     168        } 
     169        /*Allocating space for the proton*/ 
     170        if(lgProtonData) 
     171        { 
     172                CollRatesArray[intNS][1] = (double**)MALLOC((nMolLevs)*sizeof(double*)); 
    149173                for( ipHi = 0; ipHi<nMolLevs; ipHi++ ) 
    150174                { 
    151                         CollRatesArray[intNS][intcollindex][ipHi] = (double*)MALLOC((unsigned long)(nMolLevs)*sizeof(double)); 
     175                        CollRatesArray[intNS][1][ipHi] = (double*)MALLOC((unsigned long)(nMolLevs)*sizeof(double)); 
    152176                        for( ipLo = 0; ipLo<nMolLevs; ipLo++) 
    153177                        { 
    154                                 CollRatesArray[intNS][intcollindex][ipHi][ipLo] = 0.0; 
    155                         } 
    156                 } 
    157         } 
    158  
     178                                CollRatesArray[intNS][1][ipHi][ipLo] = 0.0; 
     179                        } 
     180                } 
     181        } 
    159182        /*Rewind the energy levels files*/ 
    160183        if( fseek( atmolLevDATA , 0 , SEEK_SET ) != 0 ) 
  • trunk/source/atmdat_lamda.cpp

    r1925 r2030  
    113113        for( intcollindex = 0; intcollindex <NUM_COLLIDERS; intcollindex++ ) 
    114114        { 
    115                 CollRatesArray[intNS][intcollindex] = (double**)MALLOC((unsigned long)(ngMolLevs) * sizeof(double*)); 
    116                 for( ipHi = 0; ipHi<ngMolLevs; ipHi++ ) 
    117                 { 
    118                         CollRatesArray[intNS][intcollindex][ipHi] = (double*)MALLOC((unsigned long)(ngMolLevs) * sizeof(double)); 
    119                         for( ipLo = 0; ipLo<ngMolLevs; ipLo++ ) 
    120                         { 
    121                                 CollRatesArray[intNS][intcollindex][ipHi][ipLo] = 0.0; 
    122                         } 
    123                 } 
    124         } 
     115                CollRatesArray[intNS][intcollindex] = NULL; 
     116        } 
     117 
    125118 
    126119        if(read_whole_line( chLine , (int)sizeof(chLine) , atmolLevDATA ) == NULL ) 
     
    342335                        TotalInsanity(); 
    343336                } 
     337                /*This is where we allocate memory if the collider exists*/ 
     338                /*Needed to take care of the he collisions*/ 
     339                CollRatesArray[intNS][intCollIndex] = (double**)MALLOC((unsigned long)(ngMolLevs) * sizeof(double*)); 
     340                for( ipHi = 0; ipHi<ngMolLevs; ipHi++ ) 
     341                { 
     342                        CollRatesArray[intNS][intCollIndex][ipHi] = (double*)MALLOC((unsigned long)(ngMolLevs) * sizeof(double)); 
     343                        for( ipLo = 0; ipLo<ngMolLevs; ipLo++ ) 
     344                        { 
     345                                CollRatesArray[intNS][intCollIndex][ipHi][ipLo] = 0.0; 
     346                        } 
     347                } 
    344348                if(read_whole_line( chLine , (int)sizeof(chLine)  , atmolLevDATA ) == NULL ) 
    345349                { 
  • trunk/source/nemala2.cpp

    r1947 r2030  
    162162                                        if( lgSpeciesMolecule[i] ) 
    163163                                        { 
    164                                                 /*using the collision rate coefficients directly*/ 
    165                                                 CollRatesArray[i][intCollNo][ipHi][ipLo] =  
    166                                                         LeidenCollRate(i, intCollNo, ipHi, ipLo, phycon.te); 
     164                                                if(CollRatesArray[i][intCollNo]!=NULL) 
     165                                                { 
     166                                                        /*using the collision rate coefficients directly*/ 
     167                                                        CollRatesArray[i][intCollNo][ipHi][ipLo] =  
     168                                                                LeidenCollRate(i, intCollNo, ipHi, ipLo, phycon.te); 
     169                                                } 
    167170                                        } 
    168171                                        /* atom or ion */ 
    169172                                        else 
    170173                                        { 
    171                                                 fupsilon = Chianti_Upsilon(i, intCollNo, ipHi, ipLo, phycon.te); 
    172                                                 /*converting the collision strength to a collision rate coefficient*/ 
    173                                                 CollRatesArray[i][intCollNo][ipHi][ipLo] = ((8.6291e-6)*fupsilon)/(g[ipHi]*phycon.sqrte); 
     174                                                if(CollRatesArray[i][intCollNo]!=NULL) 
     175                                                { 
     176                                                        fupsilon = Chianti_Upsilon(i, intCollNo, ipHi, ipLo, phycon.te); 
     177                                                        /*converting the collision strength to a collision rate coefficient*/ 
     178                                                        /*This formula converting collision strength to collision rate coefficent works fine for the electrons*/ 
     179                                                        /*For any other collider the mass would be different*/ 
     180                                                        CollRatesArray[i][intCollNo][ipHi][ipLo] = ((8.6291e-6)*fupsilon)/(g[ipHi]*phycon.sqrte); 
     181                                                } 
    174182                                        } 
    175183 
    176184                                        /* now get the corresponding excitation rate */ 
    177                                         CollRatesArray[i][intCollNo][ipLo][ipHi] =  
    178                                                 CollRatesArray[i][intCollNo][ipHi][ipLo] * g[ipHi] / g[ipLo] * 
    179                                                 sexp( atmolTrans[i][ipHi][ipLo].EnergyK / phycon.te ); 
     185                                        if(CollRatesArray[i][intCollNo]!=NULL) 
     186                                        { 
     187                                                CollRatesArray[i][intCollNo][ipLo][ipHi] =  
     188                                                        CollRatesArray[i][intCollNo][ipHi][ipLo] * g[ipHi] / g[ipLo] * 
     189                                                        sexp( atmolTrans[i][ipHi][ipLo].EnergyK / phycon.te ); 
     190                                        } 
    180191                                } 
    181192                        } 
     
    221232                                for( intCollNo=0; intCollNo<NUM_COLLIDERS; intCollNo++ ) 
    222233                                { 
    223                                         CollRate[ipHi][ipLo] += CollRatesArray[i][intCollNo][ipHi][ipLo]*fcolldensity[intCollNo]; 
     234                                        if(CollRatesArray[i][intCollNo]!=NULL) 
     235                                        { 
     236                                                CollRate[ipHi][ipLo] += CollRatesArray[i][intCollNo][ipHi][ipLo]*fcolldensity[intCollNo]; 
     237                                        } 
     238                                } 
     239                                /*Correction for Helium*/ 
     240                                /*To include the effects of collision with Helium,the user must multiply the density by 1.14*/ 
     241                                /*pg 5,Schoier et al 2004*/ 
     242                                if(lgSpeciesMolecule[i]) 
     243                                { 
     244                                        /*The collision rate coefficients for helium should not be present and that for molecular hydrogen should be present*/ 
     245                                        if(CollRatesArray[i][3]==NULL && CollRatesArray[i][8]!=NULL ) 
     246                                        { 
     247                                                CollRate[ipHi][ipLo] += 0.7 *CollRatesArray[i][8][ipHi][ipLo]*fcolldensity[3]; 
     248                                        } 
    224249                                } 
    225250                        } 
     
    369394 
    370395                                        /* population of lower level rel to ion, corrected for stim em */ 
     396 
    371397                                        atmolTrans[i][ipHi][ipLo].Emis->PopOpc = 
    372398                                                atmolTrans[i][ipHi][ipLo].Lo->Pop - atmolTrans[i][ipHi][ipLo].Hi->Pop*