Show
Ignore:
Timestamp:
12/17/07 17:55:05 (11 months ago)
Author:
rjrw
Message:

Refactor testing of whether the network holds the species density to
allow for Cgrn species.

Location:
branches/newmole/source
Files:
6 modified

Legend:

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

    r1686 r1691  
    950950                                 Old_molecules[ipUpstream][mol]/Old_density[ipUpstream])* 
    951951                                frac_next; 
    952                         /* Atoms and positive ions are already counted in UpstreamElem */ 
    953                         if(COmole[mol]->n_nuclei != 1 || COmole[mol]->charge < 0)  
     952                        /* Externally represented species are already counted in UpstreamElem */ 
     953                        if(COmole[mol]->location == NULL) 
    954954                        { 
    955955                                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
     
    983983                { 
    984984                        Upstream_molecules[mol] = Old_molecules[ipUpstream][mol]/Old_density[ipUpstream]; 
    985                         if(COmole[mol]->n_nuclei > 1 || COmole[mol]->charge < 0) 
     985                        if(COmole[mol]->location == NULL) 
    986986                        { 
    987987                                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
  • branches/newmole/source/heat_sum.cpp

    r1686 r1691  
    118118        for( i=0; i < mole.num_calc; i++ ) 
    119119        { 
    120                 if(COmole[i]->n_nuclei > 1 || COmole[i]->charge < 0) 
     120                if(COmole[i]->location == NULL) 
    121121                        AtomicCollidDensity += COmole[i]->hevmol; 
    122122        } 
  • branches/newmole/source/mole_newton_step.cpp

    r1690 r1691  
    554554                        b[i] -= COmole[i]->hevmol*dynamics.Rate; 
    555555 
    556                         if (COmole[i]->n_nuclei != 1 || COmole[i]->charge < 0) 
     556                        if (COmole[i]->n_nuclei != 1 || COmole[i]->charge < 0 || ! COmole[i]->lgGas_Phase) 
    557557                        { 
    558558                                b[i] += dynamics.molecules[i]*dynamics.Rate; 
  • branches/newmole/source/mole_species.cpp

    r1690 r1691  
    585585        for (i=0;i<mole.num_total;i++)  
    586586        { 
    587                 if(COmole[i]->location)  
    588                 { 
     587                if(COmole[i]->location != NULL)  
    589588                        COmole[i]->hevmol = *(COmole[i]->location); 
    590                 } 
    591589        } 
    592590} 
     
    606604        { 
    607605                if (COmole[i]->location == NULL) 
    608                 { 
    609606                        mole.elec += COmole[i]->hevmol*COmole[i]->charge; 
    610                 } 
    611607        } 
    612608 
     
    687683        for (i=0;i<mole.num_calc;++i)  
    688684        { 
    689                 if (COmole[i]->n_nuclei == 1 && COmole[i]->charge >= 0) 
    690                         continue; 
    691                 for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
    692                 { 
    693                         total[nelem] += COmole[i]->hevmol*COmole[i]->nElem[nelem]; 
     685                if (COmole[i]->location == NULL) 
     686                { 
     687                        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
     688                        { 
     689                                total[nelem] += COmole[i]->hevmol*COmole[i]->nElem[nelem]; 
     690                        } 
    694691                } 
    695692        } 
     
    705702        for (i=0;i<mole.num_calc;++i)  
    706703        { 
    707                 if (COmole[i]->n_nuclei == 1 && COmole[i]->charge >= 0) 
    708                         continue; 
    709                 total += (realnum) COmole[i]->hevmol; 
     704                if (COmole[i]->location == NULL) 
     705                        total += (realnum) COmole[i]->hevmol; 
    710706        } 
    711707        return total; 
     
    721717        for (i=0;i<mole.num_calc;++i)  
    722718        { 
    723                 if (COmole[i]->lgGas_Phase && (COmole[i]->n_nuclei != 1 || COmole[i]->charge < 0) ) 
     719                if (COmole[i]->lgGas_Phase && COmole[i]->location == NULL ) 
    724720                        total += (realnum) COmole[i]->hevmol; 
    725721        } 
     
    745741        for (i=0,j=0;i<mole.num_calc;i++)  
    746742        { 
    747                 if (COmole[i]->n_nuclei != 1 || COmole[i]->charge <= 0)  
     743                if (COmole[i]->n_nuclei != 1 || COmole[i]->charge <= 0 || ! COmole[i]->lgGas_Phase) 
    748744                { 
    749745                        /* Compound molecules and negative ions are represented individually */ 
  • branches/newmole/source/prt_comment.cpp

    r1687 r1691  
    23162316        lgLots_of_moles = false; 
    23172317        lgLotsSolids = false; 
    2318         /* largest fraction in any heavy element molecule */ 
     2318        /* largest fraction in any molecule */ 
    23192319        for( i=0; i<mole.num_calc; ++i ) 
    23202320        { 
    2321                 if( COmole[i]->n_nuclei == 1 && COmole[i]->charge >= 0) 
    2322                         continue; 
    2323  
    2324                 if( COmole[i]->xMoleFracMax > 0.1 ) 
    2325                 { 
    2326                         sprintf( chLine, "  !The fraction of %s in %s reached %.1f%% at some point in the cloud.",  
    2327                                 elementnames.chElementSym[COmole[i]->xMoleFracMaxElem], 
    2328                                 COmole[i]->label, 
    2329                                 COmole[i]->xMoleFracMax*100. ); 
    2330                         bangin(chLine); 
    2331                         lgLots_of_moles = true; 
    2332                         /* check whether molecules are on grains */ 
    2333                         if( !COmole[i]->lgGas_Phase ) 
    2334                                 lgLotsSolids = true; 
    2335                 } 
    2336                 else if( COmole[i]->xMoleFracMax>0.01 ) 
    2337                 { 
    2338                         sprintf( chLine, "   The fraction of %s in %s reached %.2f%% at some point in the cloud.",  
    2339                                 elementnames.chElementSym[COmole[i]->xMoleFracMaxElem], 
    2340                                 COmole[i]->label, 
    2341                                 COmole[i]->xMoleFracMax*100. ); 
    2342                         notein(chLine); 
    2343                         lgLots_of_moles = true; 
    2344                         /* check whether molecules are on grains */ 
    2345                         if( !COmole[i]->lgGas_Phase ) 
    2346                                 lgLotsSolids = true; 
    2347                 } 
    2348                 else if( COmole[i]->xMoleFracMax > 1e-3 ) 
    2349                 { 
    2350                         sprintf( chLine, "   The fraction of %s in %s reached %.3f%% at some point in the cloud.",  
    2351                                 elementnames.chElementSym[COmole[i]->xMoleFracMaxElem], 
    2352                                 COmole[i]->label, 
    2353                                 COmole[i]->xMoleFracMax*100. ); 
    2354                         notein(chLine); 
    2355                         /* check whether molecules are on grains */ 
    2356                         if( !COmole[i]->lgGas_Phase ) 
    2357                                 lgLotsSolids = true; 
     2321                if( COmole[i]->location == NULL ) 
     2322                { 
     2323                        if( COmole[i]->xMoleFracMax > 0.1 ) 
     2324                        { 
     2325                                sprintf( chLine, "  !The fraction of %s in %s reached %.1f%% at some point in the cloud.",  
     2326                                                                 elementnames.chElementSym[COmole[i]->xMoleFracMaxElem], 
     2327                                                                 COmole[i]->label, 
     2328                                                                 COmole[i]->xMoleFracMax*100. ); 
     2329                                bangin(chLine); 
     2330                                lgLots_of_moles = true; 
     2331                                /* check whether molecules are on grains */ 
     2332                                if( !COmole[i]->lgGas_Phase ) 
     2333                                        lgLotsSolids = true; 
     2334                        } 
     2335                        else if( COmole[i]->xMoleFracMax>0.01 ) 
     2336                        { 
     2337                                sprintf( chLine, "   The fraction of %s in %s reached %.2f%% at some point in the cloud.",  
     2338                                                                 elementnames.chElementSym[COmole[i]->xMoleFracMaxElem], 
     2339                                                                 COmole[i]->label, 
     2340                                                                 COmole[i]->xMoleFracMax*100. ); 
     2341                                notein(chLine); 
     2342                                lgLots_of_moles = true; 
     2343                                /* check whether molecules are on grains */ 
     2344                                if( !COmole[i]->lgGas_Phase ) 
     2345                                        lgLotsSolids = true; 
     2346                        } 
     2347                        else if( COmole[i]->xMoleFracMax > 1e-3 ) 
     2348                        { 
     2349                                sprintf( chLine, "   The fraction of %s in %s reached %.3f%% at some point in the cloud.",  
     2350                                                                 elementnames.chElementSym[COmole[i]->xMoleFracMaxElem], 
     2351                                                                 COmole[i]->label, 
     2352                                                                 COmole[i]->xMoleFracMax*100. ); 
     2353                                notein(chLine); 
     2354                                /* check whether molecules are on grains */ 
     2355                                if( !COmole[i]->lgGas_Phase ) 
     2356                                        lgLotsSolids = true; 
     2357                        } 
    23582358                } 
    23592359        } 
  • branches/newmole/source/radius_next.cpp

    r1687 r1691  
    885885                                abund1, 
    886886                                abund_limit; 
    887                         if( COmole[i]->n_nuclei <= 1 && COmole[i]->charge >= 0) 
    888                                 continue; 
    889                         /* >>chng 03 sep 21, add CO logic */ 
    890                         /* >>chng 04 mar 30, generalize to any molecule at all */ 
    891                         /* >>chng 04 mar 31 lower limit to abund had been 0.01, change 
    892                          * to 0.001 to pick up approach to molecular fronts */ 
    893                         abund = 0.; 
    894                         for (nelem=ipHYDROGEN;nelem < LIMELM; nelem++)  
    895                         { 
    896                                 if (dense.lgElmtOn[nelem]) 
     887                        if( COmole[i]->location == NULL) 
     888                        { 
     889                                /* >>chng 03 sep 21, add CO logic */ 
     890                                /* >>chng 04 mar 30, generalize to any molecule at all */ 
     891                                /* >>chng 04 mar 31 lower limit to abund had been 0.01, change 
     892                                 * to 0.001 to pick up approach to molecular fronts */ 
     893                                abund = 0.; 
     894                                for (nelem=ipHYDROGEN;nelem < LIMELM; nelem++)  
    897895                                { 
    898                                         abund1 = (realnum)COmole[i]->hevmol*COmole[i]->nElem[nelem]/SDIV(dense.gas_phase[nelem]); 
    899                                         if (abund1 > abund) 
     896                                        if (dense.lgElmtOn[nelem]) 
    900897                                        { 
    901                                                 abund = abund1; 
     898                                                abund1 = (realnum)COmole[i]->hevmol*COmole[i]->nElem[nelem]/SDIV(dense.gas_phase[nelem]); 
     899                                                if (abund1 > abund) 
     900                                                { 
     901                                                        abund = abund1; 
     902                                                } 
    902903                                        } 
    903904                                } 
    904                         } 
    905                         /* is this an ice?  need special logic for ice since density increases 
    906                          * exponentially when grain temp falls below sublimation temperature  
    907                          * >>chng 05 dec 06 - detect changes for smaller abundances for ices 
    908                          * due to large changes in ice abundances */ 
    909                         if( COmole[i]->lgGas_Phase ) 
    910                         { 
    911                                 abund_limit = 1e-3f; 
    912                         } 
    913                         else 
    914                         { 
    915                                 /* this is an ice - track its abundance at lower values so that 
    916                                  * we resolve the sublimation transition region */ 
    917                                 abund_limit = 1e-5f; 
    918                         } 
    919  
    920                         if( abund > abund_limit ) 
    921                         { 
    922                                 double drmole_one, relative_change, relative_change_denom; 
    923                                 /* >>chng 05 dec 08, use smaller abundance for the denominator since just taking 
    924                                  * current abundance will overlook case where current density is vastly large 
    925                                  * than old density */ 
    926                                 if( struc.molecules[i][nzone-3]>SMALLFLOAT ) 
     905                                /* is this an ice?  need special logic for ice since density increases 
     906                                 * exponentially when grain temp falls below sublimation temperature  
     907                                 * >>chng 05 dec 06 - detect changes for smaller abundances for ices 
     908                                 * due to large changes in ice abundances */ 
     909                                if( COmole[i]->lgGas_Phase ) 
    927910                                { 
    928                                         relative_change_denom = MIN2( COmole[i]->hevmol , struc.molecules[i][nzone-3] ); 
     911                                        abund_limit = 1e-3f; 
    929912                                } 
    930913                                else 
    931914                                { 
    932                                         relative_change_denom = COmole[i]->hevmol; 
     915                                        /* this is an ice - track its abundance at lower values so that 
     916                                         * we resolve the sublimation transition region */ 
     917                                        abund_limit = 1e-5f; 
    933918                                } 
    934                                 /* the relative change in the abundance */ 
    935                                 relative_change =  
    936                                         /*fabs( COmole[i]->hevmol - struc.CO_molec[i][nzone-3] ) / COmole[i]->hevmol;*/ 
    937                                         /* >>chng 05 dec 08, use smaller abundance */ 
    938                                         fabs( COmole[i]->hevmol - struc.molecules[i][nzone-3] ) / relative_change_denom; 
    939                                 /* >>chng 03 jun 16, change from 0.05 to 0.1, fine resolution of H2/H exposed 
    940                                  * small numerical oscillations in Solomon process */ 
    941                                 /* >>chng 04 jun 02, from 0.1 back to 0.05, more extensive CO etc network 
    942                                  * caused oscillations in SiO abundance and Si Si+ density. */ 
    943                                 /* >>chng 04 aug 03, from 0.05 to 0.035, leiden pdr model v2 had major 
    944                                  * jump in eden */ 
    945                                 /* >>chng 04 oct 18, from 0.035 back to 0.05, leiden pdr v2 actually due to having 
    946                                  * PAHs in fully molecular limit (??), this caused cool flow pdr grid to trip on 
    947                                  * too small dr */ 
    948                                 relative_change = SDIV(relative_change); 
    949                                 /*>>chng 05 dec 08, relative_change must be less than one - with 
    950                                  * revised logic above can be bigger than one */ 
    951                                 if( relative_change > 1. ) 
    952                                         relative_change = 1./relative_change; 
    953                                 /*drmole_one = radius.drad*MAX2(0.2,0.035/relative_change );*/ 
    954                                 /* >>chng 05 aug 23, thermal front allowed dr to become much too small 
    955                                  * chng from 0.02 to .6 */ 
    956                                 /*drmole_one = radius.drad*MAX2(0.2,0.05/relative_change );*/ 
    957                                 drmole_one = radius.drad*MAX2(0.6,0.05/relative_change ); 
    958                                 /* final dr will be the smallest we encounter */ 
    959                                 if( drmole_one < dr_mole_abund ) 
     919                                 
     920                                if( abund > abund_limit ) 
    960921                                { 
    961                                         /* this is the dr used to set next dr - keep track of which moe was changing */ 
    962                                         dr_mole_abund = drmole_one; 
    963                                         mole_dr_change = i; 
    964                                         dCO_abund = relative_change; 
     922                                        double drmole_one, relative_change, relative_change_denom; 
     923                                        /* >>chng 05 dec 08, use smaller abundance for the denominator since just taking 
     924                                         * current abundance will overlook case where current density is vastly large 
     925                                         * than old density */ 
     926                                        if( struc.molecules[i][nzone-3]>SMALLFLOAT ) 
     927                                        { 
     928                                                relative_change_denom = MIN2( COmole[i]->hevmol , struc.molecules[i][nzone-3] ); 
     929                                        } 
     930                                        else 
     931                                        { 
     932                                                relative_change_denom = COmole[i]->hevmol; 
     933                                        } 
     934                                        /* the relative change in the abundance */ 
     935                                        relative_change =  
     936                                                /*fabs( COmole[i]->hevmol - struc.CO_molec[i][nzone-3] ) / COmole[i]->hevmol;*/ 
     937                                                /* >>chng 05 dec 08, use smaller abundance */ 
     938                                                fabs( COmole[i]->hevmol - struc.molecules[i][nzone-3] ) / relative_change_denom; 
     939                                        /* >>chng 03 jun 16, change from 0.05 to 0.1, fine resolution of H2/H exposed 
     940                                         * small numerical oscillations in Solomon process */ 
     941                                        /* >>chng 04 jun 02, from 0.1 back to 0.05, more extensive CO etc network 
     942                                         * caused oscillations in SiO abundance and Si Si+ density. */ 
     943                                        /* >>chng 04 aug 03, from 0.05 to 0.035, leiden pdr model v2 had major 
     944                                         * jump in eden */ 
     945                                        /* >>chng 04 oct 18, from 0.035 back to 0.05, leiden pdr v2 actually due to having 
     946                                         * PAHs in fully molecular limit (??), this caused cool flow pdr grid to trip on 
     947                                         * too small dr */ 
     948                                        relative_change = SDIV(relative_change); 
     949                                        /*>>chng 05 dec 08, relative_change must be less than one - with 
     950                                         * revised logic above can be bigger than one */ 
     951                                        if( relative_change > 1. ) 
     952                                                relative_change = 1./relative_change; 
     953                                        /*drmole_one = radius.drad*MAX2(0.2,0.035/relative_change );*/ 
     954                                        /* >>chng 05 aug 23, thermal front allowed dr to become much too small 
     955                                         * chng from 0.02 to .6 */ 
     956                                        /*drmole_one = radius.drad*MAX2(0.2,0.05/relative_change );*/ 
     957                                        drmole_one = radius.drad*MAX2(0.6,0.05/relative_change ); 
     958                                        /* final dr will be the smallest we encounter */ 
     959                                        if( drmole_one < dr_mole_abund ) 
     960                                        { 
     961                                                /* this is the dr used to set next dr - keep track of which moe was changing */ 
     962                                                dr_mole_abund = drmole_one; 
     963                                                mole_dr_change = i; 
     964                                                dCO_abund = relative_change; 
     965                                        } 
    965966                                } 
    966967                        }