Changeset 1838

Show
Ignore:
Timestamp:
03/09/08 16:59:05 (10 months ago)
Author:
rjrw
Message:

Minor changes to resulting from trying to chase down differences on
pdf_leiden_f1 --

ion_solver: allow molecule effects in first iteration,
iso_level: defensive programming for z[][]
mole_eval_balance: move some definitions for sp
mole_co_atom: add SDIV (aka fixit...) to prevent FPE in some circumstances

Location:
branches/newmole/source
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/newmole/source/ion_solver.cpp

    r1835 r1838  
    378378         * matrix is singular */ 
    379379        totsrc = 0.; 
    380         /*>>chng 06 nov 28 only include source from molecules if we have an estimated first  
    381          * solution - first test is that we have called mole at least twice, 
    382          * second test is that we are on a later iteration */ 
    383         if( conv.nTotalIoniz > 1 || iteration > 1 ) 
    384         { 
    385  
    386                 for( i=0; i<ion_range;i++ ) 
    387                 { 
    388                         ion = i+ion_low; 
    389  
    390                         /* these are the external source and sink terms */ 
    391                         /* need negative sign to get positive pops */ 
    392                         source[i] -= mole.source[nelem][ion]; 
    393                         totsrc += mole.source[nelem][ion]; 
    394                         MAT( xmat, i, i ) -= mole.sink[nelem][ion]; 
    395                 } 
     380 
     381        for( i=0; i<ion_range;i++ ) 
     382        { 
     383                ion = i+ion_low; 
     384                 
     385                /* these are the external source and sink terms */ 
     386                /* need negative sign to get positive pops */ 
     387                source[i] -= mole.source[nelem][ion]; 
     388                totsrc += mole.source[nelem][ion]; 
     389                MAT( xmat, i, i ) -= mole.sink[nelem][ion]; 
    396390        } 
    397391 
     
    10301024                fprintf( ioQQQ, "\n" ); 
    10311025 
     1026                /* grain ionization - not total rate but should be dominant process */ 
     1027                fprintf( ioQQQ, " %s ion xfr mol "  ,elementnames.chElementSym[nelem]); 
     1028                for( ion=0; ion < dense.IonHigh[nelem]; ion++ ) 
     1029                { 
     1030                        fprintf( ioQQQ, " %9.2e", mole.xMoleChTrRate[nelem][ion][ion+1] ); 
     1031                } 
     1032                fprintf( ioQQQ, "\n" ); 
     1033 
    10321034                /* charge exchange ionization */ 
    10331035                fprintf( ioQQQ, " %s chr trn ion " ,elementnames.chElementSym[nelem] ); 
     
    10801082                { 
    10811083                        fprintf( ioQQQ, " %9.2e", gv.GrainChTrRate[nelem][ion+1][ion] ); 
     1084                } 
     1085                fprintf( ioQQQ, "\n" ); 
     1086 
     1087                fprintf( ioQQQ, " %s rec xfr mol "  ,elementnames.chElementSym[nelem]); 
     1088                for( ion=0; ion < dense.IonHigh[nelem]; ion++ ) 
     1089                { 
     1090                        fprintf( ioQQQ, " %9.2e", mole.xMoleChTrRate[nelem][ion+1][ion] ); 
    10821091                } 
    10831092                fprintf( ioQQQ, "\n" ); 
  • branches/newmole/source/iso_level.cpp

    r1834 r1838  
    7171        /* now do the 2D array */ 
    7272        z.alloc(numlevels_local,numlevels_local); 
     73        z.zero(); 
    7374 
    7475        /* >>chng 03 may 01, move defn of these two up here, before entering matrix */ 
     
    235236                        /* all process depopulating level and placing into the continuum 
    236237                         * this does NOT include grain charge transfer ionization, added below */ 
    237                         z[level][level] = iso.RateLevel2Cont[ipISO][nelem][level]; 
     238                        z[level][level] += iso.RateLevel2Cont[ipISO][nelem][level]; 
    238239                         
    239240                        if( ipISO == ipHE_LIKE && level == ipHe2s3S ) 
     
    271272 
    272273                                z[ipLo][ipLo] += coll_up + pump ; 
    273                                 z[ipLo][level] = - ( coll_up + pump ); 
     274                                z[ipLo][level] -= coll_up + pump ; 
    274275 
    275276                                double pump_down = pump * 
     
    278279 
    279280                                z[level][level] += RadDecay + pump_down + coll_down; 
    280                                 z[level][ipLo] = - (RadDecay + pump_down + coll_down); 
     281                                z[level][ipLo] -= RadDecay + pump_down + coll_down; 
    281282 
    282283                                if( ipISO == ipHE_LIKE ) 
  • branches/newmole/source/mole_co_atom.cpp

    r1780 r1838  
    333333                        (*Rotate)[j].Emis->ColOvTot = 0.0; 
    334334                else 
    335                         (*Rotate)[j].Emis->ColOvTot = (realnum)(CollRate[j][j+1]/(CollRate[j][j+1]+(*Rotate)[j].Emis->pump) ); 
     335                        (*Rotate)[j].Emis->ColOvTot = (realnum)(CollRate[j][j+1]/SDIV(CollRate[j][j+1]+(*Rotate)[j].Emis->pump) ); 
    336336 
    337337                /* two cases - collisionally excited (usual case) or  
  • branches/newmole/source/mole_eval_balance.cpp

    r1836 r1838  
    9494                 
    9595                for(i=0;i<rate->nreactants;i++) 
    96                 { 
     96                {        
     97                        sp = rate->reactants[i]; 
    9798                        if (rate->rvector[i] == NULL) 
    9899                        { 
    99                                 sp = rate->reactants[i]; 
    100100                                mole.zone[sp->index].snk += rate_deriv[i]; 
    101101                                if (sp == debug_species)  
     
    112112                                for( nelem=0; nelem< LIMELM; ++nelem ) 
    113113                                { 
    114                                         if (rate->reactants[i]->nElem[nelem] != 0) 
     114                                        if (sp->nElem[nelem] != 0) 
    115115                                        { 
    116                                                 mole.xMoleChTrRate[nelem][rate->reactants[i]->charge][rate->rvector[i]->charge] += rate_deriv[i]; 
     116                                                mole.xMoleChTrRate[nelem][sp->charge][rate->rvector[i]->charge] += rate_deriv[i]; 
    117117                                                break; 
    118118                                        } 
     
    123123                for(i=0;i<rate->nproducts;i++) 
    124124                { 
     125                        sp = rate->products[i]; 
    125126                        if (rate->pvector[i] == NULL) 
    126127                        { 
    127                                 sp = rate->products[i]; 
    128128                                mole.zone[sp->index].src += rate_tot; 
    129129                                if (sp == debug_species)