Show
Ignore:
Timestamp:
03/15/08 13:18:03 (10 months ago)
Author:
rjrw
Message:

Tidy & correct H2 rate diagnostics

Files:
1 modified

Legend:

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

    r1846 r1848  
    235235        realnum abundan; 
    236236 
    237         double *b, **c; 
     237        valarray<double> b(mole.num_total);  
     238        double **c; 
    238239        long int i; 
    239240 
    240241        DEBUG_ENTRY( "mole_effects()" ); 
    241242 
    242         b = (double *)MALLOC((size_t)mole.num_total*sizeof(double)); 
    243243        c = (double **)MALLOC((size_t)mole.num_total*sizeof(double *)); 
    244244        c[0] = (double *)MALLOC((size_t)mole.num_total* 
     
    249249        } 
    250250 
    251         mole_eval_balance(mole.num_total,b,c);   
     251        mole_eval_balance(mole.num_total,&b[0],c);       
    252252 
    253253        for (long int nelem=ipHYDROGEN;nelem<LIMELM;nelem++) 
     
    299299 
    300300        /* save rate H2 is destroyed units s-1 */ 
     301 
     302        /* total H2 - all forms */ 
     303        hmi.H2_total = (realnum) findspecies("H2*")->den + findspecies("H2")->den; 
     304        /* first guess at ortho and para densities */ 
     305        h2.ortho_density = 0.75*hmi.H2_total; 
     306        h2.para_density = 0.25*hmi.H2_total; 
     307 
    301308        /* >>chng 05 mar 18, TE, add terms -  
    302309                total destruction rate is: dest_tot = n_H2g/n_H2tot * dest_H2g + n_H2s/n_H2tot * dest_H2s */ 
     
    320327 
    321328        /* establish local timescale for H2 molecule destruction */ 
    322         if(findspecies("H2")->index != -1 && -c[findspecies("H2")->index][findspecies("H2")->index] > SMALLFLOAT ) 
     329        if(hmi.H2_rate_destroy > SMALLFLOAT ) 
    323330        { 
    324331                /* units are now seconds */ 
    325                 timesc.time_H2_Dest_here = -1./c[findspecies("H2")->index][findspecies("H2")->index]; 
     332                timesc.time_H2_Dest_here = 1./hmi.H2_rate_destroy; 
    326333        } 
    327334        else 
     
    331338         
    332339        /* local timescale for H2 formation  
    333          * both grains and radiative attachment */ 
    334         timesc.time_H2_Form_here = (mole_findrk("H,H,grnh=>H2*")+mole_findrk("H,H,grnh=>H2")) *  
    335                 /* this corrects for fact that we the timescale for H2 to form from an atomic gas. 
    336                  * The rate becomes very small when gas is fully molecular, and ratio of total hydrogen 
    337                  * to atomic hydrogen corrections for this. */ 
    338                 dense.gas_phase[ipHYDROGEN]/SDIV(dense.xIonDense[ipHYDROGEN][0]); 
     340         * both grains and radiative attachment  
     341         * >>chng 08 mar 15 rjrw -- ratio formation rate to density of _H2_ so comparable with destruction rate, 
     342         * use full rates not rate coefficients so have correct units */ 
     343        timesc.time_H2_Form_here = (mole_findrate("H,H,grnh=>H2*")+mole_findrate("H,H,grnh=>H2")); 
    339344        /* timescale is inverse of this rate */ 
    340345        if( timesc.time_H2_Form_here > SMALLFLOAT ) 
    341346        { 
    342347                /* units are now seconds */ 
    343                 timesc.time_H2_Form_here = 1./timesc.time_H2_Form_here; 
     348                timesc.time_H2_Form_here =  hmi.H2_total/timesc.time_H2_Form_here; 
    344349        } 
    345350        else 
     
    347352                timesc.time_H2_Form_here = 0.; 
    348353        } 
    349  
    350  
    351         /* total H2 - all forms */ 
    352         hmi.H2_total = (realnum) findspecies("H2*")->den + findspecies("H2")->den; 
    353         /* first guess at ortho and para densities */ 
    354         h2.ortho_density = 0.75*hmi.H2_total; 
    355         h2.para_density = 0.25*hmi.H2_total; 
    356354 
    357355        /* NB the first index must be kept parallel with nelem and ionstag in 
     
    708706        free(c[0]); 
    709707        free(c); 
    710         free(b); 
    711708 
    712709        mole_h_rate_diagnostics();