Show
Ignore:
Timestamp:
12/22/07 09:53:10 (11 months ago)
Author:
rjrw
Message:

Revise coding of grain photoevaporation rates.

Switch back error scaling in mole_newton_step to get more decks working.

Location:
branches/newmole/source
Files:
6 modified

Legend:

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

    r1706 r1714  
    6868                if (abund_total < -10.0*FLT_EPSILON*dense.gas_phase[nelem]) 
    6969                { 
     70                        double sum; 
    7071                        fprintf(stdout," DISASTER ion_solver: Bad density %li %g %g %g\n",nelem,dense.gas_phase[nelem],dense.xMolecules[nelem], 
    7172                                                        dense.gas_phase[nelem]-dense.xMolecules[nelem]); 
     73                        sum = 0; 
     74                        fprintf(stdout," Levels:"); 
     75                        for (ion=dense.IonLow[nelem]; ion<=dense.IonHigh[nelem]; ++ion ) 
     76                        { 
     77                                fprintf(stdout," %ld %g;",ion,dense.xIonDense[nelem][ion]); 
     78                                sum += dense.xIonDense[nelem][ion]; 
     79                        } 
     80                        fprintf(stdout," tot=%g\n",sum); 
    7281                        puts( "[Stop in ion_solver]" ); 
    7382                        cdEXIT(EXIT_FAILURE); 
  • branches/newmole/source/mole.h

    r1688 r1714  
    107107        int num_total, num_calc, num_compacted; 
    108108         
    109         realnum eden_f, grain_area; 
     109        realnum eden_f, grain_area, grain_avg_area; 
    110110 
    111111        /** total charge in molecules */ 
  • branches/newmole/source/mole_newton_step.cpp

    r1712 r1714  
    2626 
    2727#define ABSLIM  1e-12 
     28#define ERRLIM  1e-12 
    2829#define SMALLABUND 1e-24 
    2930#       ifdef MAT 
     
    291292                { 
    292293                        /* Smooth the error mode tailoff */ 
    293                         etmp = b[groupspecies[i]->index]; 
    294                         //((ABSLIM+b0vec[i])*(-c[groupspecies[i]->index][groupspecies[i]->index])); 
     294                        etmp = b[groupspecies[i]->index]/ 
     295                                ((ERRLIM+fabs(b0vec[i]))*(ERRLIM+fabs(c[groupspecies[i]->index][groupspecies[i]->index]))); 
    295296                        etmp *= etmp; 
    296297                        if (etmp > emax) 
     
    477478                                        iworst = i; 
    478479                                } 
    479                                 if (b0vec[i] > SMALLABUND) // || b2vec[i] < -SMALLABUND) 
     480                                if (b0vec[i] > SMALLABUND || b2vec[i] < -SMALLABUND) 
    480481                                        ++*nBad; 
    481482                        } 
     
    488489                updateMolecules( b2vec, fion );          
    489490        } 
     491        //fprintf(ioQQQ,"Final fstep %g\n",fstep); 
    490492 
    491493        *error = (realnum) MIN2(error0,1e30); 
  • branches/newmole/source/mole_reactions.cpp

    r1708 r1714  
    990990         * The following treatment uses their equation 3 */ 
    991991 
    992         double grain_area; 
    993         int nd; 
    994  
    995992        DEBUG_ENTRY("grn_photo()"); 
    996993 
    997         grain_area = 0.; 
    998         for( nd=0; nd < gv.nBin; nd++ ) 
    999         { 
    1000                 grain_area += gv.bin[nd]->AvArea; 
    1001         } 
    1002  
    1003         /* This is the number of molecules removed from the grain per incident photon 
    1004          * use same value of 1e-4 as used in Bergin */ 
    1005  
    1006         return grain_area* hmi.UV_Cont_rel2_Draine_DB96_depth; 
     994        /* This is the number of molecules removed from the grain per 
     995         * incident photon use same value of 1e-4 as used in Bergin, include 
     996         * conversion to radiation field units to get the dimensions right 
     997         * (cf the d'Hendercourt reference in Bergin et al) */ 
     998 
     999        fixit(); // Should this be 4* (i.e. the total not the cs area)?  Depends on definition of radiation field. 
     1000        return mole.grain_avg_area * hmi.UV_Cont_rel2_Draine_DB96_depth *(1.232e7f * 1.71f); 
    10071001} 
    10081002 
  • branches/newmole/source/mole_species.cpp

    r1712 r1714  
    212212                sp = newspecies("H2Ogrn",MOLECULE,MOLE_ACTIVE,NULL,1.00e-15, -238.9f); 
    213213                sp = newspecies("OHgrn ",MOLECULE,MOLE_ACTIVE,NULL,1.00e-15, 38.4f); 
    214                 if (0) 
     214                if (1) 
    215215                { 
    216216                        sp = newspecies("Cgrn  ",MOLECULE,MOLE_ACTIVE,NULL,1.00e-15, 711.2f); 
     
    596596        int i; 
    597597        int nd; 
    598         double den_times_area; 
     598        double den_times_area, dengrains; 
    599599 
    600600        DEBUG_ENTRY("mole_update_species_cache()"); 
     
    611611        /* >>chng 06 feb 28, turn off this rate when no grain molecules */ 
    612612        /* >>chng 06 dec 05 rjrw: do this in newreact rather than rate */ 
    613         den_times_area = 0.0; 
    614         for( nd=0; nd < gv.nBin; nd++ ) 
    615         { 
    616                 /* >>chng 06 mar 04, update expression for projected grain surface area, PvH */ 
    617                 den_times_area += gv.bin[nd]->IntArea/4.*gv.bin[nd]->cnv_H_pCM3; 
    618         } 
    619  
    620         mole.grain_area = den_times_area; 
     613        if(gv.lgDustOn) 
     614        { 
     615                den_times_area = dengrains = 0.0; 
     616                for( nd=0; nd < gv.nBin; nd++ ) 
     617                { 
     618                        /* >>chng 06 mar 04, update expression for projected grain surface area, PvH */ 
     619                        den_times_area += gv.bin[nd]->IntArea/4.*gv.bin[nd]->cnv_H_pCM3; 
     620                        dengrains += gv.bin[nd]->cnv_GR_pCM3; 
     621                } 
     622                 
     623                mole.grain_area = den_times_area; 
     624                mole.grain_avg_area = den_times_area/dengrains; 
     625        } 
     626        else 
     627        { 
     628                mole.grain_area = mole.grain_avg_area = 0.0; 
     629        } 
    621630 
    622631        for (i=0;i<mole.num_total;i++)  
  • branches/newmole/source/punch_do.cpp

    r1701 r1714  
    25302530                                        for(i=0; i<mole.num_calc; ++i ) 
    25312531                                        { 
    2532                                                 fprintf( punch.ipPnunit[ipPun], "\t%-4.4s", COmole[i]->label ); 
     2532                                                fprintf( punch.ipPnunit[ipPun], "\t%-7.7s", COmole[i]->label ); 
    25332533                                        } 
    25342534                                        fprintf ( punch.ipPnunit[ipPun], "\n");