Show
Ignore:
Timestamp:
12/10/07 10:00:15 (12 months ago)
Author:
rjrw
Message:

Remove some leftover code which over-wrote H- FB rate output.

Move mole_effects to mole_co_drive, a more logical home for it.

Location:
branches/newmole/source
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/newmole/source/mole.h

    r1654 r1656  
    247247                                                                                                 bool lgHeader, bool lgData, double depth); 
    248248 
    249 extern void mole_effects(void); 
    250  
    251249extern void total_molecule_elems(realnum total[LIMELM]); 
    252250 
  • branches/newmole/source/mole_co_drive.cpp

    r1652 r1656  
    77#include "hmi.h" 
    88#include "conv.h" 
     9#include "gammas.h" 
     10#include "mole_co_atom.h" 
     11#include "opacity.h" 
    912#include "phycon.h" 
     13#include "physconst.h" 
     14#include "radius.h" 
     15#include "secondaries.h" 
     16#include "timesc.h" 
    1017#include "trace.h" 
    1118#include "thermal.h" 
     
    3340STATIC void MolecSetup ( 
    3441        char *chReason ); 
     42STATIC void mole_effects(void); 
    3543 
    3644static void CO_null_results(void); 
     
    401409        return; 
    402410} 
     411STATIC void mole_effects() 
     412{ 
     413        double  
     414                h2phet, 
     415                plte; 
     416        realnum abundan; 
     417 
     418        double *b, **c; 
     419        long int i; 
     420 
     421        DEBUG_ENTRY( "mole_effects()" ); 
     422 
     423        b = (double *)MALLOC((size_t)mole.num_total*sizeof(double)); 
     424        c = (double **)MALLOC((size_t)mole.num_total*sizeof(double *)); 
     425        c[0] = (double *)MALLOC((size_t)mole.num_total* 
     426                                                                                                        mole.num_total*sizeof(double)); 
     427        for(i=1;i<mole.num_total;i++) 
     428        { 
     429                c[i] = c[i-1]+mole.num_total; 
     430        } 
     431 
     432        mole_eval_balance(mole.num_total,b,c);   
     433 
     434        co.CODissHeat = (realnum)(CO_findrate("PHOTON,CO=>C,O")*1e-12); 
     435 
     436        thermal.heating[0][9] = co.CODissHeat; 
     437 
     438        /* the real multi-level model molecule */ 
     439        abundan = (realnum) findspecies("CO")->hevmol; 
     440        /* IonStg and nelem were set to 2, 0 in makelevlines */ 
     441        ASSERT( C12O16Rotate[0].Hi->IonStg < LIMELM+2 ); 
     442        ASSERT( C12O16Rotate[0].Hi->nelem-1 < LIMELM+2 ); 
     443        dense.xIonDense[ C12O16Rotate[0].Hi->nelem-1][C12O16Rotate[0].Hi->IonStg-1] = abundan; 
     444 
     445        CO_PopsEmisCool(&C12O16Rotate, nCORotate,abundan , "12CO", 
     446                &CoolHeavy.C12O16Rot,&CoolHeavy.dC12O16Rot ); 
     447        /*if( nzone>400 ) 
     448                fprintf(ioQQQ,"DEBUG co cool\t%.2f\t%.4e\t%li\t%.4e\t%.4e\n", 
     449                        fnzone,CoolHeavy.C12O16Rot,nCORotate,abundan,phycon.te );*/ 
     450 
     451        abundan = (realnum) findspecies("CO")->hevmol/co.C12_C13_isotope_ratio; 
     452        /* IonStg and nelem were set to 3, 0 in makelevlines */ 
     453        ASSERT( C13O16Rotate[0].Hi->IonStg < LIMELM+2 ); 
     454        ASSERT( C13O16Rotate[0].Hi->nelem-1 < LIMELM+2 ); 
     455        dense.xIonDense[ C13O16Rotate[0].Hi->nelem-1][C13O16Rotate[0].Hi->IonStg-1] = abundan; 
     456 
     457        CO_PopsEmisCool(&C13O16Rotate, nCORotate,abundan ,"13CO", 
     458                &CoolHeavy.C13O16Rot,&CoolHeavy.dC13O16Rot ); 
     459 
     460        /* save rate H2 is destroyed units s-1 */ 
     461        /* >>chng 05 mar 18, TE, add terms -  
     462                total destruction rate is: dest_tot = n_H2g/n_H2tot * dest_H2g + n_H2s/n_H2tot * dest_H2s */ 
     463        /* as reactions that change H2s to H2g and vice versa are not counted destruction processes, the terms c[ipMH2g][ipMH2s] * 
     464           and c[ipMH2s][ipMH2g], which have a different sign than [ipMH2g][ipMH2g] and [ipMH2s][ipMH2s], have to be added      */ 
     465        { 
     466                int ipMH2, ipMH2s; 
     467                ipMH2 = findspecies("H2")->index; 
     468                ipMH2s = findspecies("H2*")->index; 
     469                hmi.H2_rate_destroy = 0; 
     470                if (ipMH2 != -1) 
     471                        hmi.H2_rate_destroy += -findspecies("H2")->hevmol * c[ipMH2][ipMH2]; 
     472                if (ipMH2s != -1) 
     473                        hmi.H2_rate_destroy += -findspecies("H2*")->hevmol * c[ipMH2s][ipMH2s]; 
     474                if (ipMH2 != -1 && ipMH2s != -1)  
     475                        hmi.H2_rate_destroy +=  
     476                                - findspecies("H2")->hevmol * c[ipMH2][ipMH2s] 
     477                                - findspecies("H2*")->hevmol * c[ipMH2s][ipMH2]; 
     478                hmi.H2_rate_destroy /= SDIV(hmi.H2_total); 
     479        } 
     480 
     481        /* establish local timescale for H2 molecule destruction */ 
     482        if(findspecies("H2")->index != -1 && -c[findspecies("H2")->index][findspecies("H2")->index] > SMALLFLOAT ) 
     483        { 
     484                /* units are now seconds */ 
     485                timesc.time_H2_Dest_here = -1./c[findspecies("H2")->index][findspecies("H2")->index]; 
     486        } 
     487        else 
     488        { 
     489                timesc.time_H2_Dest_here = 0.; 
     490        } 
     491         
     492        /* local timescale for H2 formation  
     493         * both grains and radiative attachment */ 
     494        timesc.time_H2_Form_here = (CO_findrk("H,H,grnh=>H2*")+CO_findrk("H,H,grnh=>H2")) *  
     495                /* this corrects for fact that we the timescale for H2 to form from an atomic gas. 
     496                 * The rate becomes very small when gas is fully molecular, and ratio of total hydrogen 
     497                 * to atomic hydrogen corrections for this. */ 
     498                dense.gas_phase[ipHYDROGEN]/SDIV(dense.xIonDense[ipHYDROGEN][0]); 
     499        /* timescale is inverse of this rate */ 
     500        if( timesc.time_H2_Form_here > SMALLFLOAT ) 
     501        { 
     502                /* units are now seconds */ 
     503                timesc.time_H2_Form_here = 1./timesc.time_H2_Form_here; 
     504        } 
     505        else 
     506        { 
     507                timesc.time_H2_Form_here = 0.; 
     508        } 
     509 
     510 
     511        /* total H2 - all forms */ 
     512        hmi.H2_total = (realnum) findspecies("H2*")->hevmol + findspecies("H2")->hevmol; 
     513        /* first guess at ortho and para densities */ 
     514        h2.ortho_density = 0.75*hmi.H2_total; 
     515        h2.para_density = 0.25*hmi.H2_total; 
     516 
     517        /* NB the first index must be kept parallel with nelem and ionstag in 
     518         * H2Lines EmLine struc, 
     519         * since that struc expects to find the abundances here */ 
     520        /* >>chng 04 feb 19, had been ipMH2g, chng to total */ 
     521        dense.xIonDense[LIMELM+2][0] = hmi.H2_total; 
     522 
     523 
     524        /* heating due to H2 dissociation */ 
     525 
     526        /* H2 photodissociation heating, eqn A9 of Tielens & Hollenbach 1985a */ 
     527        /*hmi.HeatH2Dish_TH85 = (float)(1.36e-23*findspecies("H2")->hevmol*h2esc*hmi.UV_Cont_rel2_Habing_TH85_depth);*/ 
     528        /* >>chng 04 feb 07, more general to express heating in terms of the assumed 
     529         * photo rates - the 0.25 was obtained by inverting A8 & A9 of TH85 to find that 
     530         * there are 0.25 eV per dissociative pumping, ie, 10% of total  
     531         * this includes both H2g and H2s - TH85 say just ground but they include 
     532         * process for both H2 and H2s - as we did above - both must be in 
     533         * heating term */ 
     534        /* >>chng 05 mar 11, TE, old had used H2_Solomon_dissoc_rate_used, which was only 
     535         * H2g.  in regions where Solomon process is fast, H2s has a large population 
     536         * and the heating rate was underestimated. */ 
     537        /* >>chng 05 jun 23,  
     538         * >>chng 05 dec 05, TE, modified to approximate the heating better for the 
     539         * new approximation */ 
     540        /* >>chng 00 nov 25, explicitly break out this heat agent */ 
     541        /* 2.6 eV of heat per deexcitation, consider difference 
     542         * between deexcitation (heat) and excitation (cooling) */ 
     543        /* >>chng 04 jan 27, code moved here and simplified */ 
     544        /* >>chng 05 jul 10, GS*/  
     545        /*  average collisional rate for H2* to H2g calculated from big H2, GS*/ 
     546         
     547        /* TH85 dissociation heating - this is ALWAYS defined for reference 
     548         * may be output for comparison with other rates*/ 
     549        hmi.HeatH2Dish_TH85 = 0.25 * EN1EV * 
     550                (hmi.H2_Solomon_dissoc_rate_used_H2g * findspecies("H2")->hevmol + 
     551                 hmi.H2_Solomon_dissoc_rate_used_H2s * findspecies("H2*")->hevmol); 
     552         
     553        /* TH85 deexcitation heating */ 
     554        hmi.HeatH2Dexc_TH85 = ((CO_findrate("H2*,H2=>H2,H2") + CO_findrate("H2*,H=>H2,H")) 
     555                                                                                                 - (CO_findrate("H2,H2=>H2*,H2") + CO_findrate("H2,H=>H2*,H"))) * 4.17e-12; 
     556        /* this is derivative wrt temperature, only if counted as a cooling source */ 
     557        hmi.deriv_HeatH2Dexc_TH85 = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_TH85)* ( 30172. * thermal.tsq1 - thermal.halfte ) ); 
     558         
     559        if( hmi.chH2_small_model_type == 'H' ) 
     560        { 
     561                /* Burton et al. 1990 */ 
     562                hmi.HeatH2Dish_BHT90 = 0.25 * EN1EV * 
     563                        (hmi.H2_Solomon_dissoc_rate_used_H2g * findspecies("H2")->hevmol + 
     564                         hmi.H2_Solomon_dissoc_rate_used_H2s * findspecies("H2*")->hevmol); 
     565                 
     566                /* Burton et al. 1990 heating */ 
     567                hmi.HeatH2Dexc_BHT90 = ((CO_findrate("H2*,H2=>H2,H2") + CO_findrate("H2*,H=>H2,H"))  
     568                                                                                                                - (CO_findrate("H2,H2=>H2*,H2") + CO_findrate("H2,H=>H2*,H"))) * 4.17e-12; 
     569                /* this is derivative wrt temperature, only if counted as a cooling source */ 
     570                hmi.deriv_HeatH2Dexc_BHT90 = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_BHT90)* ( 30172. * thermal.tsq1 - thermal.halfte ) ); 
     571        } 
     572        else if( hmi.chH2_small_model_type == 'B') 
     573        { 
     574                /* Bertoldi & Draine */ 
     575                hmi.HeatH2Dish_BD96 = 0.25 * EN1EV * 
     576                        (hmi.H2_Solomon_dissoc_rate_used_H2g * findspecies("H2")->hevmol + 
     577                         hmi.H2_Solomon_dissoc_rate_used_H2s * findspecies("H2*")->hevmol); 
     578                /* Bertoldi & Draine heating, same as TH85 */ 
     579                hmi.HeatH2Dexc_BD96 = ((CO_findrate("H2*,H2=>H2,H2") + CO_findrate("H2*,H=>H2,H")) 
     580                                                                                                         - (CO_findrate("H2,H2=>H2*,H2") + CO_findrate("H2,H=>H2*,H"))) * 4.17e-12; 
     581                /* this is derivative wrt temperature, only if counted as a cooling source */ 
     582                hmi.deriv_HeatH2Dexc_BD96 = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_BD96)* ( 30172. * thermal.tsq1 - thermal.halfte ) ); 
     583        } 
     584        else if(hmi.chH2_small_model_type == 'E') 
     585        { 
     586                /* heating due to dissociation of H2 
     587                 * >>chng 05 oct 19, TE, define new approximation for the heating due to the destruction of H2 
     588                 *      use this approximation for the specified cloud parameters, otherwise 
     589                 * use limiting cases for 1 <= G0, G0 >= 1e7, n >= 1e7, n <= 1 */ 
     590                 
     591                double log_density,  
     592                        f1, f2,f3, f4, f5; 
     593                static double log_G0_face = -1; 
     594                static double k_f4; 
     595                 
     596                 
     597                /* test for G0  
     598                 * this is a constant so only do it in zone 0 */ 
     599                if( !nzone ) 
     600                { 
     601                        if(hmi.UV_Cont_rel2_Draine_DB96_face <= 1.)  
     602                        {  
     603                                log_G0_face = 0.; 
     604                        } 
     605                        else if(hmi.UV_Cont_rel2_Draine_DB96_face >= 1e7)  
     606                        {  
     607                                log_G0_face = 7.; 
     608                        } 
     609                        else  
     610                        {  
     611                                log_G0_face = log10(hmi.UV_Cont_rel2_Draine_DB96_face);  
     612                        } 
     613                        /*>>chng 06 oct 24 TE change Go face for spherical geometry*/ 
     614                        log_G0_face /= radius.r1r0sq; 
     615                } 
     616 
     617                /* test for density */ 
     618                if(dense.gas_phase[ipHYDROGEN] <= 1.)  
     619                {  
     620                        log_density = 0.;  
     621                } 
     622                else if(dense.gas_phase[ipHYDROGEN] >= 1e7)  
     623                {  
     624                        log_density = 7.;  
     625                } 
     626                else  
     627                {  
     628                        log_density = log10(dense.gas_phase[ipHYDROGEN]);  
     629                } 
     630                 
     631                f1 = 0.15 * log_density + 0.75; 
     632                f2 = -0.5 * log_density + 10.; 
     633                 
     634                hmi.HeatH2Dish_ELWERT = 0.25 * EN1EV *  f1 *  
     635                        (hmi.H2_Solomon_dissoc_rate_used_H2g * findspecies("H2")->hevmol + 
     636                         hmi.H2_Solomon_dissoc_rate_used_H2s * findspecies("H2*")->hevmol ) +  
     637                        f2 * secondaries.x12tot * EN1EV * hmi.H2_total; 
     638                 
     639                /*fprintf( ioQQQ, "f1: %.2e, f2: %.2e,heat Solomon: %.2e",f1,f2,hmi.HeatH2Dish_TH85);*/ 
     640                 
     641                 
     642                /* heating due to collisional deexcitation within X of H2 
     643                 * >>chng 05 oct 19, TE, define new approximation for the heating due to the destruction of H2 
     644                 *      use this approximation for the specified cloud parameters, otherwise 
     645                 * use limiting cases for 1 <= G0, G0 >= 1e7, n >= 1e7, n <= 1 */ 
     646                 
     647                /* set value of k_f4 by testing on value of G0 */ 
     648                if(hmi.UV_Cont_rel2_Draine_DB96_face <= 1.)  
     649                {  
     650                        log_G0_face = 0.; 
     651                } 
     652                else if(hmi.UV_Cont_rel2_Draine_DB96_face >= 1e7)  
     653                {  
     654                        log_G0_face = 7.; 
     655                } 
     656                else  
     657                {  
     658                        log_G0_face = log10(hmi.UV_Cont_rel2_Draine_DB96_face);  
     659                } 
     660                /* 06 oct 24, TE introduce effects of spherical geometry */ 
     661                log_G0_face /= radius.r1r0sq; 
     662                 
     663                /* terms only dependent on G0_face */ 
     664                k_f4 = -0.25 * log_G0_face + 1.25; 
     665 
     666                /* test for density */ 
     667                if(dense.gas_phase[ipHYDROGEN] <= 1.)  
     668                {  
     669                        log_density = 0.;  
     670                        f4 = 0.;  
     671                } 
     672                else if(dense.gas_phase[ipHYDROGEN] >= 1e7)  
     673                {  
     674                        log_density = 7.;  
     675                        f4 = pow(k_f4,2) * pow( 10. , 2.2211 * log_density - 29.8506); 
     676                } 
     677                else  
     678                {  
     679                        log_density = log10(dense.gas_phase[ipHYDROGEN]);  
     680                        f4 = pow(k_f4,2) * pow( 10., 2.2211 * log_density - 29.8506); 
     681                } 
     682                 
     683                f3 = MAX2(0.1, -4.75 * log_density + 24.25); 
     684                f5 = MAX2(1.,0.95 * log_density - 1.45) * 0.2 * log_G0_face; 
     685                 
     686                hmi.HeatH2Dexc_ELWERT = ((CO_findrate("H2*,H2=>H2,H2") + CO_findrate("H2*,H=>H2,H")) 
     687                                                                                                                 - (CO_findrate("H2,H2=>H2*,H2") + CO_findrate("H2,H=>H2*,H"))) * 4.17e-12 * f3 +  
     688                        f4 * (COmole[element_list[ipHYDROGEN]->ipMl[0]]->hevmol/dense.gas_phase[ipHYDROGEN]) + 
     689                        f5 * secondaries.x12tot * EN1EV * hmi.H2_total; 
     690                 
     691                if(log_G0_face == 0.&& dense.gas_phase[ipHYDROGEN] > 1.)  
     692                        hmi.HeatH2Dexc_ELWERT *= 0.001 / dense.gas_phase[ipHYDROGEN]; 
     693                 
     694                /* >>chng 06 oct 24, TE introduce effects of spherical geometry */ 
     695                /*if(radius.depth/radius.rinner >= 1.0) */ 
     696                hmi.HeatH2Dexc_ELWERT /= POW2(radius.r1r0sq); 
     697                 
     698                /* this is derivative wrt temperature, only if counted as a cooling source */ 
     699                hmi.deriv_HeatH2Dexc_ELWERT = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_ELWERT)* ( 30172. * thermal.tsq1 - thermal.halfte ) ); 
     700                 
     701                /*fprintf( ioQQQ, "\tf3: %.2e, f4: %.2e, f5: %.2e, heat coll dissoc: %.2e\n",f3,f4,f5,hmi.HeatH2Dexc_TH85);*/ 
     702        } 
     703        /* end Elwert branch for photo rates */ 
     704        else 
     705                TotalInsanity(); 
     706         
     707        /* if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 ) 
     708                 { 
     709                 deexc_htwo = hmi.Average_collH2; 
     710                 deexc_hneut = hmi.Average_collH; 
     711                 } 
     712                 else 
     713                 { 
     714                 deexc_htwo = (1.4e-12*phycon.sqrte * sexp( 18100./(phycon.te + 1200.) ))/6.; 
     715                 deexc_hneut =  (1e-12*phycon.sqrte * sexp(1000./phycon.te ))/6.; 
     716                 } */ 
     717         
     718        /* Leiden hacks try to turn off H2*, which is all unphysical.  do not include heating 
     719         * due to H2 deexcitation since H2* is bogus */ 
     720        /* >>chng 05 aug 12, do not turn off vibrational heating when Leiden hack is in place 
     721         * other codes included heating but did not include H2s on chemistry  
     722         hmi.HeatH2Dexc_TH85 *= hmi.lgLeiden_Keep_ipMH2s;*/ 
     723        /*fprintf(ioQQQ, 
     724                "DEBUG hmole H2 deex heating:\t%.2f\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n", 
     725                fnzone, 
     726                hmi.HeatH2Dexc_TH85, 
     727                thermal.htot, 
     728                findspecies("H2*")->hevmol, 
     729                H2star_deexcit,  
     730                findspecies("H2")->hevmol, 
     731                H2star_excit, 
     732                Hmolec_old[ipMH2g], 
     733                Hmolec_old[ipMH], 
     734                phycon.te);*/ 
     735         
     736        /* >>chng 05 jul 11, TE, each term must have unit cm-3 s-1, 
     737         * more terms added */ 
     738        hmi.H2_rate_create =  
     739                CO_findrate("H,H,grnh=>H2*")+ 
     740                CO_findrate("H,H,grnh=>H2") +  
     741                CO_findrate("H,H-=>H2,e-")+ 
     742                CO_findrate("H,H-=>H2*,e-") + 
     743                CO_findrate("H,H,H=>H2,H") +  
     744                CO_findrate("H,H2+=>H+,H2*") +  
     745                CO_findrate("H,H=>H2") +  
     746                CO_findrate("H,H3+=>H2,H2+") +  
     747                CO_findrate("H2+,H-=>H2,H") + 
     748                CO_findrate("H,H,H2=>H2,H2") +  
     749                CO_findrate("H3+,H-=>H2,H,H") + 
     750                CO_findrate("H3+,H-=>H2,H2") + 
     751                CO_findrate("H2,H3+=>H+,H2,H2") + 
     752                CO_findrate("e-,H3+=>H2,H") + 
     753                CO_findrate("H3+,PHOTON=>H2,H+") + 
     754                CO_findrate("H,CH=>C,H2") + 
     755                CO_findrate("H,CH+=>C+,H2") + 
     756                CO_findrate("H,CH2=>CH,H2") + 
     757                CO_findrate("H,CH3+=>CH2+,H2") + 
     758                CO_findrate("H,OH=>O,H2") + 
     759                CO_findrate("H-,HCO+=>CO,H2") + 
     760                CO_findrate("H-,H3O+=>H2O,H2") + 
     761                CO_findrate("H-,H3O+=>OH,H2,H") + 
     762                CO_findrate("H+,CH2=>CH+,H2") + 
     763                CO_findrate("H+,SiH=>Si+,H2") + 
     764                CO_findrate("H2+,CH=>CH+,H2") +  
     765                CO_findrate("H2+,CH2=>CH2+,H2") +  
     766                CO_findrate("H2+,CO=>CO+,H2") +  
     767                CO_findrate("H2+,H2O=>H2O+,H2") +  
     768                CO_findrate("H2+,O2=>O2+,H2") +  
     769                CO_findrate("H2+,OH=>OH+,H2") +  
     770                CO_findrate("H3+,C=>CH+,H2") +  
     771                CO_findrate("H3+,CH=>CH2+,H2") +  
     772                CO_findrate("H3+,CH2=>CH3+,H2") +  
     773                CO_findrate("H3+,OH=>H2O+,H2") +  
     774                CO_findrate("H3+,H2O=>H3O+,H2") +  
     775                CO_findrate("H3+,CO=>HCO+,H2") +  
     776                CO_findrate("H3+,O=>OH+,H2") +  
     777                CO_findrate("H3+,SiH=>SiH2+,H2") +  
     778                CO_findrate("H3+,SiO=>SiOH+,H2") + 
     779                CO_findrate("H,CH3=>CH2,H2") + 
     780                CO_findrate("H,CH4+=>CH3+,H2") + 
     781                CO_findrate("H,CH5+=>CH4+,H2") + 
     782                CO_findrate("H2+,CH4=>CH3+,H2,H") +  
     783                CO_findrate("H2+,CH4=>CH4+,H2") +  
     784                CO_findrate("H3+,CH3=>CH4+,H2") +  
     785                CO_findrate("H3+,CH4=>CH5+,H2") +  
     786                CO_findrate("H+,CH4=>CH3+,H2") +         
     787                CO_findrate("H+,HNO=>NO+,H2") + 
     788                CO_findrate("H+,HS=>S+,H2") + 
     789                CO_findrate("H,HS+=>S+,H2") + 
     790                CO_findrate("H3+,NH=>NH2+,H2") +  
     791                CO_findrate("H3+,NH2=>NH3+,H2") +  
     792                CO_findrate("H3+,NH3=>NH4+,H2") +  
     793                CO_findrate("H3+,CN=>HCN+,H2") +  
     794                CO_findrate("H3+,NO=>HNO+,H2") +  
     795                CO_findrate("H3+,S=>HS+,H2") +  
     796                CO_findrate("H3+,CS=>HCS+,H2") +  
     797                CO_findrate("H3+,NO2=>NO+,OH,H2") +  
     798                CO_findrate("H2+,NH=>NH+,H2") +  
     799                CO_findrate("H2+,NH2=>NH2+,H2") +  
     800                CO_findrate("H2+,NH3=>NH3+,H2") +  
     801                CO_findrate("H2+,CN=>CN+,H2") +  
     802                CO_findrate("H2+,HCN=>HCN+,H2") +  
     803                CO_findrate("H2+,NO=>NO+,H2") + 
     804                CO_findrate("H3+,Cl=>HCl+,H2")+ 
     805                CO_findrate("H3+,HCl=>H2Cl+,H2")+ 
     806                CO_findrate("H2+,C2=>C2+,H2")+   
     807                CO_findrate("H-,NH4+=>NH3,H2")+ 
     808                CO_findrate("H3+,HCN=>HCNH+,H2"); 
     809 
     810        /*>>chng 05 jul 01, GS, h2s ionization by cosmic ray added*/ 
     811        /* >>chng 05 jun 29, TE, used in new punch H2 destruction file*/ 
     812        hmi.CR_reac_H2g = CO_findrk("H2,CRPHOT=>H2+,e-") + CO_findrk("H2,CRPHOT=>H,H+,e-")  
     813                + CO_findrk("H2,CRPHOT=>H,H") + CO_findrk("H2,CRPHOT=>H+,H-") + CO_findrk("H2,CRPHOT=>H+,H,e-"); 
     814        hmi.CR_reac_H2s = CO_findrk("H2*,CRPHOT=>H2+,e-") + CO_findrk("H2*,CRPHOT=>H,H+,e-") + 
     815                CO_findrk("H2*,CRPHOT=>H,H") + CO_findrk("H2*,CRPHOT=>H+,H-") + CO_findrk("H2*,CRPHOT=>H+,H,e-"); 
     816 
     817        if( findspecies("H-")->hevmol > 0. && hmi.rel_pop_LTE_Hmin > 0. ) 
     818        { 
     819                hmi.hmidep = (double)findspecies("H-")->hevmol/ SDIV(  
     820                        ((double)dense.xIonDense[ipHYDROGEN][0]*dense.eden*hmi.rel_pop_LTE_Hmin)); 
     821        } 
     822        else 
     823        { 
     824                hmi.hmidep = 1.; 
     825        } 
     826 
     827        /* this will be net volume heating rate, photo heat - induc cool */ 
     828        hmi.hmihet = hmi.HMinus_photo_heat*findspecies("H-")->hevmol - hmi.HMinus_induc_rec_cooling; 
     829 
     830        /* H2+  +  HNU  =>  H+  + H */ 
     831        h2phet = GammaK(opac.ih2pnt[0],opac.ih2pnt[1],opac.ih2pof,1.); /* Now used entirely for side-effect.  Yuk */ 
     832        hmi.h2plus_heat = thermal.HeatNet*findspecies("H2+")->hevmol; 
     833 
     834        /* departure coefficient for H2 defined rel to n(1s)**2 
     835         * (see Littes and Mihalas Solar Phys 93, 23) */ 
     836        plte = (double)dense.xIonDense[ipHYDROGEN][0] * hmi.rel_pop_LTE_H2g * (double)dense.xIonDense[ipHYDROGEN][0]; 
     837        if( plte > 0. ) 
     838        { 
     839                hmi.h2dep = findspecies("H2")->hevmol/plte; 
     840        } 
     841        else 
     842        { 
     843                hmi.h2dep = 1.; 
     844        } 
     845 
     846        /* departure coefficient of H2+ defined rel to n(1s) n(p) 
     847         * sec den was HI before 85.34 */ 
     848        plte = (double)dense.xIonDense[ipHYDROGEN][0]*hmi.rel_pop_LTE_H2p*(double)dense.xIonDense[ipHYDROGEN][1]; 
     849        if( plte > 0. ) 
     850        { 
     851                hmi.h2pdep = findspecies("H2+")->hevmol/plte; 
     852        } 
     853        else 
     854        { 
     855                hmi.h2pdep = 1.; 
     856        } 
     857 
     858        /* departure coefficient of H3+ defined rel to N(H2+) N(p) */ 
     859        if( hmi.rel_pop_LTE_H3p > 0. ) 
     860        { 
     861                hmi.h3pdep = findspecies("H3+")->hevmol/hmi.rel_pop_LTE_H3p; 
     862        } 
     863        else 
     864        { 
     865                hmi.h3pdep = 1.; 
     866        } 
     867 
     868        free(c[0]); 
     869        free(c); 
     870        free(b); 
     871        return; 
     872} 
  • branches/newmole/source/mole_newton_step.cpp

    r1653 r1656  
    1414#include "ionbal.h" 
    1515#include "dense.h" 
     16#include "gammas.h" 
     17#include "opacity.h" 
    1618#include "secondaries.h" 
    1719#include "mole.h" 
    1820#include "mole_priv.h" 
    19 #include "opacity.h" 
    2021#include "rfield.h" 
    2122#include "thermal.h" 
    22 #include "timesc.h" 
    2323#include "trace.h" 
    2424#include "phycon.h" 
    2525#include "doppvel.h" 
    2626#include "thirdparty.h" 
    27 #include "gammas.h" 
    2827#include "h2.h" 
    2928#include "dynamics.h" 
    3029#include "conv.h" 
    31 #include "radius.h" 
    3230#include "hextra.h"  
    3331#include "hmi.h" 
    3432#include "taulines.h" 
    3533#include "coolheavy.h" 
    36 #include "mole_co_atom.h" 
    3734 
    3835/* HP cc cannot compile following except in -O1 mode */ 
     
    631628 
    632629        CO_return_cached_species(); 
    633  
    634         hmi.H2_total = 0.; 
    635         /* this is where the transition struc expects to find the H2 abundance */ 
    636         dense.xIonDense[LIMELM+2][0] = 0.; 
    637         hmi.hmihet = 0.; 
    638         hmi.h2plus_heat = 0.; 
    639         hmi.H2Opacity = 0.; 
    640         hmi.hmicol = 0.; 
    641         hmi.hmidep = 1.; 
    642  
    643         if (0)  
    644         { 
    645                 fprintf(stdout,"SILICON %ld snk %g %g\n",nzone,mole.sink[ipSILICON][0],mole.sink[ipSILICON][1]); 
    646                 fprintf(stdout,"SILICON src %g %g\n",mole.source[ipSILICON][0],mole.source[ipSILICON][1]); 
    647  
    648                 fprintf(stdout,"HYDROGEN snk %g %g\n",mole.sink[ipHYDROGEN][0],mole.sink[ipHYDROGEN][1]); 
    649                 fprintf(stdout,"HYDROGEN src %g %g\n",mole.source[ipHYDROGEN][0],mole.source[ipHYDROGEN][1]); 
    650                 fprintf(stdout,"CARBON snk %g %g\n",mole.sink[ipCARBON][0],mole.sink[ipCARBON][1]); 
    651                 fprintf(stdout,"CARBON src %g %g\n",mole.source[ipCARBON][0],mole.source[ipCARBON][1]); 
    652                 fprintf(stdout,"NEON snk %g %g\n",mole.sink[ipNEON][0],mole.sink[ipNEON][1]); 
    653                 fprintf(stdout,"NEON src %g %g\n",mole.source[ipNEON][0],mole.source[ipNEON][1]); 
    654                 fprintf(stdout,"NEON dense %g %g\n",findspecies("Ne")->hevmol,findspecies("Ne+")->hevmol); 
    655         } 
    656630         
    657631        return; 
    658632} 
    659633 
    660 void mole_effects() 
    661 { 
    662         double  
    663                 h2phet, 
    664                 plte; 
    665         realnum abundan; 
    666  
    667         double *b, **c; 
    668         long int i; 
    669  
    670         DEBUG_ENTRY( "mole_effects()" ); 
    671  
    672         b = (double *)MALLOC((size_t)mole.num_total*sizeof(double)); 
    673         c = (double **)MALLOC((size_t)mole.num_total*sizeof(double *)); 
    674         c[0] = (double *)MALLOC((size_t)mole.num_total* 
    675                                                                                                         mole.num_total*sizeof(double)); 
    676         for(i=1;i<mole.num_total;i++) 
    677         { 
    678                 c[i] = c[i-1]+mole.num_total; 
    679         } 
    680  
    681         mole_eval_balance(mole.num_total,b,c);   
    682  
    683         co.CODissHeat = (realnum)(CO_findrate("PHOTON,CO=>C,O")*1e-12); 
    684  
    685         thermal.heating[0][9] = co.CODissHeat; 
    686  
    687         /* the real multi-level model molecule */ 
    688         abundan = (realnum) findspecies("CO")->hevmol; 
    689         /* IonStg and nelem were set to 2, 0 in makelevlines */ 
    690         ASSERT( C12O16Rotate[0].Hi->IonStg < LIMELM+2 ); 
    691         ASSERT( C12O16Rotate[0].Hi->nelem-1 < LIMELM+2 ); 
    692         dense.xIonDense[ C12O16Rotate[0].Hi->nelem-1][C12O16Rotate[0].Hi->IonStg-1] = abundan; 
    693  
    694         CO_PopsEmisCool(&C12O16Rotate, nCORotate,abundan , "12CO", 
    695                 &CoolHeavy.C12O16Rot,&CoolHeavy.dC12O16Rot ); 
    696         /*if( nzone>400 ) 
    697                 fprintf(ioQQQ,"DEBUG co cool\t%.2f\t%.4e\t%li\t%.4e\t%.4e\n", 
    698                         fnzone,CoolHeavy.C12O16Rot,nCORotate,abundan,phycon.te );*/ 
    699  
    700         abundan = (realnum) findspecies("CO")->hevmol/co.C12_C13_isotope_ratio; 
    701         /* IonStg and nelem were set to 3, 0 in makelevlines */ 
    702         ASSERT( C13O16Rotate[0].Hi->IonStg < LIMELM+2 ); 
    703         ASSERT( C13O16Rotate[0].Hi->nelem-1 < LIMELM+2 ); 
    704         dense.xIonDense[ C13O16Rotate[0].Hi->nelem-1][C13O16Rotate[0].Hi->IonStg-1] = abundan; 
    705  
    706         CO_PopsEmisCool(&C13O16Rotate, nCORotate,abundan ,"13CO", 
    707                 &CoolHeavy.C13O16Rot,&CoolHeavy.dC13O16Rot ); 
    708  
    709         /* save rate H2 is destroyed units s-1 */ 
    710         /* >>chng 05 mar 18, TE, add terms -  
    711                 total destruction rate is: dest_tot = n_H2g/n_H2tot * dest_H2g + n_H2s/n_H2tot * dest_H2s */ 
    712         /* as reactions that change H2s to H2g and vice versa are not counted destruction processes, the terms c[ipMH2g][ipMH2s] * 
    713            and c[ipMH2s][ipMH2g], which have a different sign than [ipMH2g][ipMH2g] and [ipMH2s][ipMH2s], have to be added      */ 
    714         { 
    715                 int ipMH2, ipMH2s; 
    716                 ipMH2 = findspecies("H2")->index; 
    717                 ipMH2s = findspecies("H2*")->index; 
    718                 hmi.H2_rate_destroy = 0; 
    719                 if (ipMH2 != -1) 
    720                         hmi.H2_rate_destroy += -findspecies("H2")->hevmol * c[ipMH2][ipMH2]; 
    721                 if (ipMH2s != -1) 
    722                         hmi.H2_rate_destroy += -findspecies("H2*")->hevmol * c[ipMH2s][ipMH2s]; 
    723                 if (ipMH2 != -1 && ipMH2s != -1)  
    724                         hmi.H2_rate_destroy +=  
    725                                 - findspecies("H2")->hevmol * c[ipMH2][ipMH2s] 
    726                                 - findspecies("H2*")->hevmol * c[ipMH2s][ipMH2]; 
    727                 hmi.H2_rate_destroy /= SDIV(hmi.H2_total); 
    728         } 
    729  
    730         /* establish local timescale for H2 molecule destruction */ 
    731         if(findspecies("H2")->index != -1 && -c[findspecies("H2")->index][findspecies("H2")->index] > SMALLFLOAT ) 
    732         { 
    733                 /* units are now seconds */ 
    734                 timesc.time_H2_Dest_here = -1./c[findspecies("H2")->index][findspecies("H2")->index]; 
    735         } 
    736         else 
    737         { 
    738                 timesc.time_H2_Dest_here = 0.; 
    739