/home66/gary/public_html/cloudy/c08_branch/source/mole_h_step.cpp

Go to the documentation of this file.
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
00002  * others.  For conditions of distribution and use see copyright notice in license.txt */
00003 /*hmole_step do a step in chemical network */
00004 /*hmirat compute radiative association rate for H- */
00005 /* >> chng 02 nov 7 rjrw, Mole Moreliano:
00006  *   changes to linearized iterative form */
00007 /* from Robin Williams:
00008 The process for these kind of problems seems to be pretty uniform:
00009 switch printsol on to check which terms in the chemical matrix change,
00010 and next to switch on the prints in the matrix assembly which apply to
00011 the species involved to find what reactions are involved.  It's a bit
00012 of a pain grepping down to find the 47th reaction, so I guess some
00013 kind of naming scheme for the reactions may come in handy (I'd thought
00014 about generating the in and out vectors from a text string, e.g. "H +
00015 H => H2";-), but you'd have to verify uniqueness).
00016 */
00017 /*lint -e778 const express evaluates to 0 */
00018 /*lint -e725 expect positive indentation */
00019 #include "cddefines.h"
00020 #include "physconst.h"
00021 #include "iso.h"
00022 #include "atmdat.h"
00023 #include "grainvar.h"
00024 #include "ionbal.h"
00025 #include "dense.h"
00026 #include "secondaries.h"
00027 #include "mole.h"
00028 #include "mole_co_priv.h"
00029 #include "opacity.h"
00030 #include "rfield.h"
00031 #include "thermal.h"
00032 #include "timesc.h"
00033 #include "trace.h"
00034 #include "phycon.h"
00035 #include "doppvel.h"
00036 #include "thirdparty.h"
00037 #include "gammas.h"
00038 #include "h2.h"
00039 #include "dynamics.h"
00040 #include "conv.h"
00041 #include "radius.h"
00042 #include "hextra.h" 
00043 #include "hmi.h"
00044 
00045 /* HP cc cannot compile following except in -O1 mode */
00046 #if defined(__HP_aCC)
00047 #       pragma OPT_LEVEL 1
00048 #endif
00049 
00050 #define ABSLIM  1e-12
00051 
00052 /* Calculate number of elements in an integer vector */
00053 #define INTSZ(a)     (sizeof(a)/sizeof(int))
00054 
00055 struct Hmole_rate_s {
00056         int index;
00057         int nreactants, nrates, nproducts;
00058         int reactants[MAXREACTANTS];
00059         int rate_species[MAXREACTANTS];
00060         int products[MAXPRODUCTS];
00061         double rk; 
00062         struct Hmole_rate_s *next;
00063 };
00064 typedef struct Hmole_rate_s reaction;
00065 
00066 /* Generate new element for reaction list */
00067 reaction *newreaction(
00068         /* reaction index, a number to reference current reaction */
00069         int rindex, 
00070         /* vector of ints that are incoming species, the reactants */
00071         int *in, 
00072         /* number of reactants */
00073         int nin, 
00074         /* same for products */
00075         int *out, 
00076         /* number of products */
00077         int nout, 
00078         /* rate determining species if they are not the same as the reactants,
00079          * these are non-null in cases where a part of the chemical network
00080          * acts as a catalyst in the reaction 
00081          * as H2g + H2g -> H2g + H2* or where */
00082         int *rate, 
00083         /* number of these */
00084         int nrate)
00085 {
00086         static reaction *list = NULL, *r;
00087         static int poolsize=1, index = 0;
00088         int i;
00089 
00090         /* this routine is called only to initialize structure with information
00091          * on the reactants and products - this does not change, so no need
00092          * to do this but once.  In later cases only the rate coefficients are
00093          * updated in hmole_step 
00094          * in hmole_stop on later call linked list is incremented upon each
00095          * reaction, and rate coefficient for current temperature is stored 
00096          * in r->rk 
00097          * r is pointer to structure of reaction information including
00098          * r->next, which is the next reaction in the linked list */
00099         /* fprintf(ioQQQ,"New reaction %d %d %d\n",rindex,nin,nout); */
00100 
00101         /* default assumption for chemical kinetics,
00102          * rate is determined by all incoming species that are in *in 
00103          * when not null then the rate determining species are not the
00104          * same as *in */
00105         if(rate == NULL) 
00106         {
00107                 rate=in;
00108                 nrate=nin;
00109         }
00110 
00111         /* space for the linked list "list" */
00112         /*lint -e701 shift left of signed quantity */
00113         if(list == NULL || index == poolsize) 
00114         {
00115                 poolsize <<=1;
00116                 list = ((reaction *)MALLOC( (size_t)poolsize*sizeof(reaction) ));
00117                 index = 0;
00118         }
00119         /*lint +e701 */
00120 
00121         /* fprintf(ioQQQ,"Getting element %d+1 of %d\n",index,poolsize); */
00122         r = list+index;
00123         index++;
00124         r->next = NULL;
00125         r->index = rindex;
00126         ASSERT(nin <= MAXREACTANTS && nout <= MAXPRODUCTS && nrate <= MAXREACTANTS);
00127 
00128         r->nreactants = nin;
00129         r->nrates =     nrate;
00130         r->nproducts  = nout;
00131 
00132         /* incoming reactants */
00133         for(i=0; i<r->nreactants; i++)
00134                 r->reactants[i] = in[i];
00135 
00136         /* rate determining species */
00137         for(i=0; i<r->nrates; i++)
00138                 r->rate_species[i] = rate[i];
00139 
00140         /* outgoing products */
00141         for(i=0; i<r->nproducts; i++)
00142                 r->products[i] = out[i];
00143 
00144         return r;
00145 }
00146 
00147 // icc 10.0 miscompiles this routine with higher optimization
00148 #if defined (__ICC) && defined(__amd64)
00149 #pragma optimization_level 1
00150 #endif
00151 
00152 /*hmole_step do a step in chemical network */
00153 void hmole_step(int *nFixup, double *error)
00154 {
00155         enum {PRINTSOL = false};
00156 
00157         int32 ipiv[N_H_MOLEC];
00158 
00159         long int i, 
00160           ipConserve, 
00161           j, 
00162           limit ,
00163           nd,
00164           mol;
00165 
00166         int printsol = PRINTSOL;
00167 
00168         bool lgNegPop;
00169         int iworst;
00170         /* >>chng 05 jul 31, from float to double, since very nearly 1 for H - route */
00171         double frac_H2star_grains,
00172                 frac_H2star_hminus; 
00173         double sum_first_ions;
00174 
00175         double 
00176                 bhneut, 
00177                 Hneut,
00178                 c3bod,
00179                 cionhm, 
00180                 corr, 
00181                 H2star_deexcit,
00182                 deexc_htwo,
00183                 deexc_hneut,
00184                 desh2p, 
00185                 etmp,
00186                 eh3p_3h,
00187                 Boltz_fac_H2_H2star,
00188                 fhneut, 
00189                 gamheh, 
00190                 h1fnd, 
00191                 h1rat, 
00192                 h2pcin,  
00193                 h2phhp, 
00194                 h2pion, 
00195                 H2star_excit ,
00196                 radath, 
00197                 hmihph2p,
00198                 h2phmhhh,
00199                 h2crphh,
00200                 h2scrphh,
00201                 h2crphphm,
00202                 h2scrphphm,
00203                 h2crphpeh,
00204                 h2scrphpeh,
00205                 h2crh2pe,
00206                 h2crhphe,
00207                 h2scrhphe,
00208                 h2scrh2pe,
00209                 h2pehh,
00210                 h3ph2ph,
00211                 hphmhhpe,
00212                 h2hmhh2e,
00213                 hehmeheh,
00214                 hephmhhe,
00215                 fracneg,
00216                 fracnegtmp,
00217                 fracnegfac,
00218                 sum_H0_Hp,
00219                 conserve,
00220                 rate,
00221                 rk,
00222                 rated,
00223                 rate_deriv[MAXREACTANTS],
00224                 sinkrate[MAXREACTANTS],
00225                 T_ortho_para_crit ,
00226                 TStancil;
00227 
00228 
00229         static double 
00230           gamtwo, 
00231           h2phet, 
00232           proton_sum_old,
00233           proton_sum_new;
00234 
00235         static double /*amat[N_H_MOLEC][N_H_MOLEC], */
00236           b2pcin, 
00237           *amat=NULL,
00238           *bvec=NULL/*[N_H_MOLEC]*/, 
00239           *Hmolec_old=NULL/*[N_H_MOLEC]*/, 
00240           **c=NULL/*[N_H_MOLEC+1][N_H_MOLEC+1]*/, 
00241           plte;
00242         static double oatomic = -1., oion = -1.;
00243         /*static long int iter_eval = -2;*/
00244 
00245         /* if this is still true then must create space for arrays */
00246         static bool lgMustMalloc = true;
00247 
00248         static reaction *rlist = NULL;
00249         reaction *r;
00250         long int rindex, ratei, ratej;
00251 
00252         DEBUG_ENTRY( "hmole_step()" );
00253 
00254         if( lgMustMalloc )
00255         {
00256                 /* on very first call must create space */
00257                 lgMustMalloc = false;
00258 
00259                 bvec = ((double*)MALLOC( (size_t)N_H_MOLEC*sizeof(double) ));
00260                 Hmolec_old = ((double*)MALLOC( (size_t)N_H_MOLEC*sizeof(double) ));
00261                 amat = ((double*)MALLOC( (size_t)(N_H_MOLEC*N_H_MOLEC)*sizeof(double) ));
00262                 c = ((double**)MALLOC( (size_t)N_H_MOLEC*sizeof(double *) ));
00263                 for( i=0; i<N_H_MOLEC; ++i )
00264                 {
00265                         /* this is the Jacobian array, MALLOC sets it to NaN, first reagents
00266                          * will be filled in, then Jacobian array set in loop below.  Search
00267                          * for Jacobian array */
00268                         c[i] = ((double*)MALLOC( (size_t)N_H_MOLEC*sizeof(double) ));
00269                 }
00270         }
00271 
00272         /* Assume no error for cases with abundances set */
00273         *error = 0;
00274 
00275         /* there are two "no molecules" options, the no co, which turns off everything,
00276          * and the no n2, which only turns off the h2.  in order to not kill the co
00277          * part we still need to compute the hydrogen network here, and then set h2 to
00278          * small values */
00279         if( hmi.lgNoH2Mole )
00280         {
00281                 dense.xMolecules[ipHYDROGEN] = 0.;
00282 
00283                 /* these are the molecular species */
00284                 for(mol=0; mol<N_H_MOLEC; ++mol) 
00285                 {
00286                         hmi.Hmolec[mol] = 0.;
00287                 }
00288                 hmi.Hmolec[ipMH] = dense.xIonDense[ipHYDROGEN][0];
00289                 hmi.Hmolec[ipMHp] = dense.xIonDense[ipHYDROGEN][1];
00290                 hmi.H2_total = 0.;
00291                 /* this is where the transition struc expects to find the H2 abundance */
00292                 dense.xIonDense[LIMELM+2][0] = 0.;
00293                 hmi.hmihet = 0.;
00294                 hmi.h2plus_heat = 0.;
00295                 hmi.H2Opacity = 0.;
00296                 hmi.hmicol = 0.;
00297                 hmi.hmidep = 1.;
00298                 hmi.rh2dis = 0.;
00299                 hmi.HalphaHmin = 0.;
00300 
00301                 hmi.HeatH2Dish_used = 0.; 
00302                 hmi.HeatH2Dish_BigH2 = 0.;
00303                 hmi.HeatH2Dish_TH85 = 0.;
00304                 hmi.HeatH2Dish_BD96 = 0.;
00305                 hmi.HeatH2Dish_BHT90 = 0.;
00306                 hmi.HeatH2Dish_ELWERT = 0.;
00307 
00310                 hmi.HeatH2Dexc_used = 0.;
00311                 hmi.HeatH2Dexc_BigH2 = 0.;
00312                 hmi.HeatH2Dexc_TH85 = 0.;
00313                 hmi.HeatH2Dexc_BD96 = 0.;
00314                 hmi.HeatH2Dexc_BHT90 = 0.;
00315                 hmi.HeatH2Dexc_ELWERT = 0.;
00316 
00318                 hmi.deriv_HeatH2Dexc_used = 0.;
00319                 hmi.deriv_HeatH2Dexc_BigH2 = 0.;
00320                 hmi.deriv_HeatH2Dexc_TH85 = 0.;
00321                 hmi.deriv_HeatH2Dexc_BD96 = 0.;
00322                 hmi.deriv_HeatH2Dexc_BHT90 = 0.;
00323                 hmi.deriv_HeatH2Dexc_ELWERT = 0.;
00324                 return;
00325         }
00326 
00327         /* option to force H2 abundance, for testing h2 molecules,
00328          * hmi.H2_frac_abund_set is fraction in molecules that is set by 
00329          * set h2 fraction command */
00330         if( hmi.H2_frac_abund_set>0.)
00331         {
00332                 for(mol=0;mol<N_H_MOLEC;mol++) 
00333                 {
00334                         hmi.Hmolec[mol] = 0.;
00335                 }
00336                 /* >>chng 03 jul 19, from 0 to SMALLFLOAT, to pass asserts in ConvBase,
00337                  * problem is that ion range has not been reset for hydrogen */
00338                 dense.xIonDense[ipHYDROGEN][0] = dense.xIonDense[ipHYDROGEN][1] = 
00339                         2.f*SMALLFLOAT*dense.gas_phase[ipHYDROGEN];
00340                 /* put it all in the ground state */
00341                 hmi.Hmolec[ipMH2g] = (realnum)(dense.gas_phase[ipHYDROGEN] * hmi.H2_frac_abund_set);
00342                 hmi.Hmolec[ipMH2s] = 0.;
00343 
00344                 hmi.H2_total = hmi.Hmolec[ipMH2g] + hmi.Hmolec[ipMH2s];
00345                 /* first guess at ortho and para densities */
00346                 h2.ortho_density = 0.75*hmi.H2_total;
00347                 h2.para_density = 0.25*hmi.H2_total;
00348 
00349                 hmi.hmihet = 0.;
00350                 hmi.h2plus_heat = 0.;
00351                 hmi.H2Opacity = 0.;
00352                 hmi.hmicol = 0.;
00353                 hmi.HeatH2Dish_TH85 = 0.;
00354                 hmi.HeatH2Dexc_TH85 = 0.;
00355                 hmi.deriv_HeatH2Dexc_TH85 = 0.;
00356                 hmi.hmidep = 1.;
00357                 hmi.HalphaHmin = 0.;
00358 
00359                 for( nd=0; nd < gv.nBin; nd++ )
00360                 {
00361                         gv.bin[nd]->rate_h2_form_grains_used = 0.;
00362                 }
00363                 return;
00364         }
00365 
00366         /* update these two to current values of atomic and ionized hydrogen density */
00367         hmi.Hmolec[ipMH] = dense.xIonDense[ipHYDROGEN][0];
00368         hmi.Hmolec[ipMHp] = dense.xIonDense[ipHYDROGEN][1];
00369         /* now copy all of H moles into old array */
00370         for(mol=0;mol<N_H_MOLEC;mol++) 
00371         {
00372                 Hmolec_old[mol] = hmi.Hmolec[mol];
00373         }
00374         for(i=0; i<MAXREACTANTS; ++i )
00375         {
00376                 rate_deriv[i] = 0.;
00377                 sinkrate[i] = 0.;
00378         }
00379 
00380         /* collisional ionization of H-, rate from Janev, Langer et al. */
00381         if( phycon.te < 3074. )
00382         {
00383                 cionhm = 1.46e-32*(powi(phycon.te,6))*phycon.sqrte*hmi.exphmi;
00384         }
00385         else if( phycon.te >= 3074. && phycon.te < 30000. )
00386         {
00387                 cionhm = 5.9e-19*phycon.tesqrd*phycon.sqrte*phycon.te05;
00388         }
00389         else
00390         {
00391                 cionhm = 3e-7;
00392         }
00393 
00394         /* H2 formation on grains;
00395          * rate from 
00396          * >>refer      H2      grain formation Hollenbach, D., & McKee, C.F., 1979, ApJS, 41, 555 eq 3.4 3.8 */
00397         if( gv.lgDustOn )
00398         {
00399 
00400 #               ifndef IGNORE_QUANTUM_HEATING
00401                 /* hmole is called before grains, so assure that all the grain stuff is properly initialized */
00402                 GrainDrive();
00403 #               endif
00404 
00405                 /* these are rates (s-1) H2 will be deactivated by collisions with grains 
00406                  * will be incremented below 
00407                  * H2 ortho - para conversion on grain surface */
00408                 hmi.rate_grain_h2_op_conserve = 0.;
00409                 /* rate (s-1) v=0, J=1 level goes to 0 */
00410                 hmi.rate_grain_h2_J1_to_J0 = 0.;
00411 
00412                 /* loop over all grain species */
00413                 for( nd=0; nd < gv.nBin; nd++ )
00414                 {
00415 #                       ifndef IGNORE_QUANTUM_HEATING
00416                         long k, qnbin;
00417                         double *qtemp, *qprob;
00418                         bool lgUseQHeat = gv.lgGrainPhysicsOn && gv.bin[nd]->lgQHeat;
00419 #                       endif
00420                         /* >>chng 02 feb 15, removed check tedust > 1.01, change in GrainsInit
00421                          * guarantees that all relevant parameters are initialized, PvH */
00422 
00423                         /* sticking probability, 2H + grain equation 3.7 of
00424                          * >>refer      grain   phys    Hollenbach, D.J., & McKee, C.F., 1979, ApJS, 41, 555,
00425                          * fraction of H impacts on grain surface that stick */
00426                         /* this sticking probability is used for both HM79 and CT02 */
00427                         double sticking_probability_H = 1./(1. + 0.04*sqrt(gv.bin[nd]->tedust+phycon.te) + 
00428                                 0.002*phycon.te + 8e-6*phycon.te*phycon.te);
00429 
00430 #                       ifndef IGNORE_QUANTUM_HEATING
00431                         /* >>chng 04 feb 21, included quantum heating in calculation of formation rate, PvH */
00432                         if( lgUseQHeat )
00433                         {
00434                                 qtemp = (double*)MALLOC((size_t)(NQGRID*sizeof(double)));
00435                                 qprob = (double*)MALLOC((size_t)(NQGRID*sizeof(double)));
00436 
00437                                 qheat(qtemp,qprob,&qnbin,nd);
00438 
00439                                 if( gv.bin[nd]->lgUseQHeat )
00440                                 {
00441                                         ASSERT( qnbin > 0 );
00442                                 }
00443                                 else
00444                                 {
00445                                         qnbin = 1;
00446                                         qprob[0] = 1.;
00447                                         qtemp[0] = gv.bin[nd]->tedust;
00448                                 }
00449 
00450                                 gv.bin[nd]->rate_h2_form_grains_HM79 = 0.;
00451 
00452                                 for( k=0; k < qnbin; k++ )
00453                                 {
00454                                         /* fraction of impacts that produce H2 before evaporation from grain surface.
00455                                          * this is equation 3.4 of
00456                                          * >>refer      grain   phys    Hollenbach, D.J., & McKee, C.F., 1979, ApJS, 41, 555
00457                                          * 1e4 is ratio of total absorption sites to appropriate sites 
00458                                          * 920 is D_H and chosen to get f_a = 0.5 at 100 K.
00459                                          * factor of 0.6252 needed to obtain std ism rate to be 3e-17 at 100 K,
00460                                          * the value deduced by
00461                                          * >>refer      H2      grain physics   Jura, M., 1974, ApJ, 197, 581 */
00462                                         double conversion_efficiency_HM79 = 1/(1. + 1e4*sexp(920./qtemp[k]));
00463                                         sticking_probability_H = 1./(1. + 0.04*sqrt(qtemp[k]+phycon.te) + 
00464                                                                      0.002*phycon.te + 8e-6*phycon.te*phycon.te);
00465 
00466                                         gv.bin[nd]->rate_h2_form_grains_HM79 += qprob[k] * sticking_probability_H *
00467                                                 conversion_efficiency_HM79;
00468                                 }
00469 
00470                                 /* NB IntArea is total, not projected, area, must div by 4 */
00471                                 /* gv.bin[nd]->rate_h2_form_grains_HM79 has units s^-1 since gv.bin[nd]->cnv_H_pCM3 has units cm-3 */
00472                                 /* cnv_H_pCM3 converts <unit>/H (default depletion) -> <unit>/cm^3 (actual depletion), units are cm-3 */
00473                                 gv.bin[nd]->rate_h2_form_grains_HM79 *= 0.5 * DoppVel.AveVel[ipHYDROGEN]*
00474                                         gv.bin[nd]->IntArea/4. * gv.bin[nd]->cnv_H_pCM3;
00475 
00476                                 ASSERT( gv.bin[nd]->rate_h2_form_grains_HM79 > 0. );
00477                         }
00478                         else
00479 #                       endif
00480                         {
00481                                 /* fraction of impacts that produce H2 before evaporation from grain surface.
00482                                 * this is equation 3.4 of
00483                                 * >>refer       grain   phys    Hollenbach, D.J., & McKee, C.F., 1979, ApJS, 41, 555
00484                                 * 1e4 is ratio of total absorption sites to appropriate sites 
00485                                 * 920 is D_H and chosen to get f_a = 0.5 at 100 K.
00486                                 * factor of 0.6252 needed to obtain std ism rate to be 3e-17 at 100 K,
00487                                 * the value deduced by
00488                                 * >>refer       H2      grain physics   Jura, M., 1974, ApJ, 197, 581 */
00489                                 double conversion_efficiency_HM79 = 1/(1. + 1e4*sexp(920./gv.bin[nd]->tedust));
00490 
00491                                 /* NB IntArea is total area per H for default abundances, not projected area, must div by 4 
00492                                  * units s^-1 since gv.bin[nd]->cnv_H_pCM3 has units H cm-3 
00493                                  * final units are cm s-1*/
00494                                 gv.bin[nd]->rate_h2_form_grains_HM79 = 0.5 * DoppVel.AveVel[ipHYDROGEN]* gv.bin[nd]->IntArea/4. * 
00495                                         /* cnv_H_pCM3 converts <unit>/H (default depletion) -> <unit>/cm^3 (actual depletion), units are cm-3 */
00496                                         gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H * conversion_efficiency_HM79;
00497                                 ASSERT( gv.bin[nd]->rate_h2_form_grains_HM79 > 0. );
00498                         }
00499 
00500 #                       ifndef IGNORE_QUANTUM_HEATING
00501                         if( lgUseQHeat )
00502                         {
00503                                 /* H2 formation on grains from 
00504                                  * >>refer      H2      form    Cazaux, S., & Tielens, A.G.G.M., 2002, ApJ, 575, L29 */
00505                                 /* number of monolayers per second - only affects efficiency at very low or high temperatures */
00506                                 double f = 1e-10;
00507                                 /* equation 17 
00508                                 double sqrt_term = POW2( 1. + sqrt( (10000.-200.)/(600.-200.) ) );*/
00509                                 double sqrt_term = 35.399494936611667;
00510 
00511                                 gv.bin[nd]->rate_h2_form_grains_CT02 = 0.;
00512 
00513                                 for( k=0; k < qnbin; k++ )
00514                                 {
00515                                         double beta_alpha = 0.25 * sqrt_term *sexp(200./qtemp[k] );
00516                                         /* equation 16 */
00517                                         double xi =  1./ (1. + 1.3e13*sexp(1.5*1e4/qtemp[k])*sqrt_term/(2.*f) );
00518                                         /* expression for beta comes from just after equation 5 */
00519                                         double beta = 3e12 * sexp( 320. / qtemp[k] );
00520                                         /* recombination efficiency given by their equation 15, they call
00521                                          * this epsilon_H2 */
00522                                         double recombination_efficiency_CT02 = xi / (1. + 0.005*f/2./SDIV(beta) + beta_alpha );
00523                                         sticking_probability_H = 1./(1. + 0.04*sqrt(qtemp[k]+phycon.te) + 
00524                                                                      0.002*phycon.te + 8e-6*phycon.te*phycon.te);
00525 
00526                                         /* printf( " k %ld Td %.6e re*sp %.6e\n", k, qtemp[k], recombination_efficiency_CT02* */
00527                                         /* sticking_probability_H ); */
00528 
00529                                         gv.bin[nd]->rate_h2_form_grains_CT02 += qprob[k] * sticking_probability_H *
00530                                                 recombination_efficiency_CT02;
00531                                 }
00532 
00533                                 /* gv.bin[nd]->IntArea integrated grain surface area Int(4pi*a^2), normalized per H, in cm^2/H,
00534                                  * so x/4 is projected area of circle */
00535                                 /* gv.bin[nd]->cnv_H_pCM3 is H density [cm-3] times grain depletion factor */
00536                                 /* gv.bin[nd]->rate_h2_form_grains_CT02 units s-1 */
00537                                 gv.bin[nd]->rate_h2_form_grains_CT02 *= 0.5 * DoppVel.AveVel[ipHYDROGEN]*
00538                                         gv.bin[nd]->IntArea/4. * gv.bin[nd]->cnv_H_pCM3;
00539 
00540                                 ASSERT( gv.bin[nd]->rate_h2_form_grains_CT02 > 0. );
00541 
00542                                 free(qtemp);
00543                                 free(qprob);
00544                         }
00545                         else
00546 #                       endif
00547                         {
00548                                 /* H2 formation on grains from 
00549                                  * >>refer      H2      form    Cazaux, S., & Tielens, A.G.G.M., 2002, ApJ, 575, L29 */
00550                                 /* number of monolayers per second - only affects efficiency at very low or high temperatures */
00551                                 double f = 1e-10;
00552                                 /* equation 17 
00553                                 double sqrt_term = POW2( 1. + sqrt( (10000.-200.)/(600.-200.) ) );*/
00554                                 double sqrt_term = 35.399494936611667;
00555                                 double beta_alpha = 0.25 * sqrt_term *sexp(200./gv.bin[nd]->tedust );
00556                                 /* equation 16 */
00557                                 double xi =  1./ (1. + 1.3e13*sexp(1.5*1e4/ gv.bin[nd]->tedust )*sqrt_term/(2.*f) );
00558                                 /* expression for beta comes from just after equation 5 */
00559                                 double beta = 3e12 * sexp( 320. / gv.bin[nd]->tedust );
00560                                 /* recombination efficiency given by their equation 15, they call
00561                                  * this epsilon_H2 */
00562                                 double recombination_efficiency_CT02 = xi / (1. + 0.005*f/2./SDIV(beta) + beta_alpha );
00563 
00564                                 /* gv.bin[nd]->IntArea integrated grain surface area Int(4pi*a^2), normalized per H, in cm^2/H,
00565                                  * so x/4 is projected area of circle */
00566                                 /* gv.bin[nd]->cnv_H_pCM3 is H density [cm-3] times grain depletion factor */
00567                                 /* units s-1 */
00568                                 gv.bin[nd]->rate_h2_form_grains_CT02 = 0.5 * DoppVel.AveVel[ipHYDROGEN]* gv.bin[nd]->IntArea/4. * 
00569                                         gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H * recombination_efficiency_CT02;
00570                                 ASSERT( gv.bin[nd]->rate_h2_form_grains_CT02 > 0. );
00571                         }
00572 
00573 #                       ifndef  IGNORE_QUANTUM_HEATING
00574                         /* reset sticking probability for code below */
00575                         sticking_probability_H = 1./(1. + 0.04*sqrt(gv.bin[nd]->tedust+phycon.te) + 
00576                                 0.002*phycon.te + 8e-6*phycon.te*phycon.te);
00577 #                       endif
00578 
00579                         /* rate (s-1) all H2 v,J levels go to 0 or 1, preserving nuclear spin */
00580                         /* ortho to para on grain surfaces, taken from 
00581                          *>refer        H2      sticking        Le Bourlot, J., 2000, A&A, 360, 656-662 
00582                          * >chng 05 apr 30, GS, hmi.H2_total/dense.gas_phase[ipHYDROGEN] is removed
00583                          * This is used in h2.c.
00584                          * NB IntArea is total are per H, not projected area, must div by 4 
00585                          * gv.bin[nd]->cnv_H_pCM3 has units H cm-3 to product with above
00586                          * is cm2/H H/cm3 or cm-1 or an opacity
00587                          * multiply by velocity of H2, cm s-1, so product 
00588                          * hmi.rate_grain_h2_op_conserve has units s^-1  */
00589                         hmi.rate_grain_h2_op_conserve += DoppVel.AveVel[LIMELM+2]* gv.bin[nd]->IntArea/4. *
00590                                 gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H;
00591 
00592                         /* ortho to para on grain surfaces, taken from 
00593                          *>refer        H2      sticking        Le Bourlot, J., 2000, A&A, 360, 656-662 
00594                          * For all grain temperatures, this process corresponds to high J going to
00595                          * either 0 or 1 preserving nuclear spin.  All ortho go to 1 and para go to 0.
00596                          * When the dust temperature is below Tcrit all 1 go to 0 and so all J go to 0.
00597 
00598                          * this temperature depends on grain composition, discussion left column of page 657,
00599                          * this is for a bare grain */
00608                         /* AveVEl[LIMELM+2] is average speed of H2 molecules 
00609                          * for now assume that sticking probability for H2 on the grain is equal to
00610                          * that for H 
00611                          * efficiency factor efficiency_opr is vary fast function of t dust - 
00612                          * large at low Td and small at Td > T_ortho_para_crit
00613                          * start evaluating just above the critical temperature 
00614                          * T_ortho_para_crit this is roughly 24.345 K,GS */
00615                         T_ortho_para_crit = 2. * hmi.Tad / log( POW2(60. *1.1e11)*hmi.Tad); 
00616                         if( gv.bin[nd]->tedust < T_ortho_para_crit )
00617                         {
00618                                 double efficiency_opr = sexp(60.*1.1e11*sqrt(hmi.Tad)*sexp(hmi.Tad/gv.bin[nd]->tedust));
00619                                 /* rate (s-1) all v,J levels go to 0, regardless of nuclear spin
00620                                  * see above discussion for how units work out */
00621                                 hmi.rate_grain_h2_J1_to_J0 += DoppVel.AveVel[LIMELM+2]* gv.bin[nd]->IntArea/4. * 
00622                                         gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H * efficiency_opr;
00623                         }
00624                 }
00625                 /*fprintf(ioQQQ," H2 grain form rate HM79 %.2e  %.2e CT02 %.2e  %.2e O-P grn %.2e %.2e\n", 
00626                         gv.bin[nd]->rate_h2_form_grains_HM79 , 
00627                         gv.bin[nd]->rate_h2_form_grains_HM79 ,
00628                         gv.bin[nd]->rate_h2_form_grains_CT02 , 
00629                         gv.bin[nd]->rate_h2_form_grains_CT02 , 
00630                         hmi.rate_grain_h2_J1_to_J0,
00631                         hmi.rate_h2_allX_2_J1_grains
00632                         );*/
00633                 /* options to turn off grain collision with atom h2 collisions grains off command */
00634                 hmi.rate_grain_h2_op_conserve *= mole.lgH2_grain_deexcitation;
00635                 hmi.rate_grain_h2_J1_to_J0 *= mole.lgH2_grain_deexcitation;
00636 
00637         }
00638         else
00639         {
00640                 /* grains are not enabled, set these to zero */
00641                 for( nd=0; nd < gv.nBin; nd++ )
00642                 {
00643                         gv.bin[nd]->rate_h2_form_grains_CT02 = 0.;
00644                         gv.bin[nd]->rate_h2_form_grains_HM79 = 0.;
00645                 }
00646                 /* rate all H2 goes to either 0 or 1 depending on ortho/para */
00647                 hmi.rate_grain_h2_op_conserve = 0.;
00648                 /* at low temp, rate all H2 goes to J=0 */
00649                 hmi.rate_grain_h2_J1_to_J0 = 0.;
00650         }
00651 
00652         /* the H2 catalysis rate on grains that is actually used in calculations
00653          * hmi.ScaleJura is scale factor set with set Jura scale command 
00654          * units are s-1 
00655          * default is 'C' Cazaux & Tielens */
00656         gv.rate_h2_form_grains_used_total = 0.;
00657         for( nd=0; nd < gv.nBin; nd++ )
00658         {
00659                 if( hmi.chJura == 'C' )
00660                 {
00661                         /* use the new rate by 
00662                          * >>refer      H2      form    Cazaux, S., & Tielens, A.G.G.M., 2002, ApJ, 575, L29 
00663                          * units are s-1*/
00664                         gv.bin[nd]->rate_h2_form_grains_used = 
00665                                 gv.bin[nd]->rate_h2_form_grains_CT02*hmi.ScaleJura;
00666                         gv.rate_h2_form_grains_used_total += gv.bin[nd]->rate_h2_form_grains_used;
00667                 }
00668                 else if( hmi.chJura == 'T' )
00669                 {
00670                         /* rate from Hollenbach & McKee 1979  */
00671                         gv.bin[nd]->rate_h2_form_grains_used = 
00672                                 gv.bin[nd]->rate_h2_form_grains_HM79*hmi.ScaleJura;
00673                         gv.rate_h2_form_grains_used_total += gv.bin[nd]->rate_h2_form_grains_used;
00674                 }
00675                 else if( hmi.chJura == 'S' )
00676                 {
00677                         /* H2 formation rate from 
00678                          * >>refer      H2      form    Sternberg, A. & Neufeld, D.A. 1999, ApJ, 516, 371 */
00679                         gv.bin[nd]->rate_h2_form_grains_used = 
00680                                 3e-18 * phycon.sqrte / gv.nBin * dense.gas_phase[ipHYDROGEN]*hmi.ScaleJura;
00681                         /* this is simple rate from Sternberg & Neufeld 99 */
00682                         gv.rate_h2_form_grains_used_total += gv.bin[nd]->rate_h2_form_grains_used;
00683                 }
00684                 /*>>chng 07 jan 10, this had been C for constant, and so could never have been triggered.
00685                  * caught by robin Williams, fixed by nick Abel, error was in sense that any set jura rate
00686                  * would use Cazaux & Tielens */
00687                 else if( hmi.chJura == 'F' )
00688                 {
00689                         /* command "set H2 rate" - enters log of Jura rate - C for constant,
00690                          * no dependence on grain properties */
00691                         gv.bin[nd]->rate_h2_form_grains_used = hmi.rate_h2_form_grains_set*dense.gas_phase[ipHYDROGEN] / gv.nBin;
00692                         gv.rate_h2_form_grains_used_total += gv.bin[nd]->rate_h2_form_grains_used;
00693                 }
00694         }
00695         ASSERT( gv.rate_h2_form_grains_used_total >= 0. );
00696 
00697 #       ifndef IGNORE_QUANTUM_HEATING
00698         printf( " fnzone %.2f H2 rate %.4e\n", fnzone, gv.rate_h2_form_grains_used_total );
00699 #       endif
00700 
00701         /* >>chng 03 sep 09, get ratio of excited to ground state H2 */
00702         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
00703         {
00704                 frac_H2star_grains = hmi.H2star_forms_grains / 
00705                         SDIV(hmi.H2star_forms_grains+hmi.H2_forms_grains);
00706 
00707                 frac_H2star_hminus = hmi.H2star_forms_hminus / 
00708                         SDIV(hmi.H2star_forms_hminus+hmi.H2_forms_hminus);
00709 
00710                 /* option print statement for above */
00711                 /*printf( "DEBUG H2s frac grain %.3e f(H2g) %.3e ",frac_H2star_grains ,
00712                         hmi.H2_forms_grains/SDIV(hmi.H2star_forms_grains+hmi.H2_forms_grains) );
00713                 printf( " H2s frac h- %.3e f(H2g) %.3e\n",frac_H2star_hminus ,
00714                         hmi.H2_forms_hminus/SDIV(hmi.H2star_forms_hminus+hmi.H2_forms_hminus));*/
00715         }
00716         else
00717         {
00718                 /* the large H2 molecule was not evaluated, so we can't use exact
00719                  * branching ratios.  These are the distribution fractions for around 500K */
00720                 /*These depend on temperature and distribution function and the definition of ENERGY_H2_STAR.
00721                   So reset the values properly*/
00722                 /* >>chng 05 jul 13, TE, with the new definition of H2s these are both 1 */
00723                 /* >>chng 05 jul 31, activate above print, rest for current 0.5 ev defn */
00724                 frac_H2star_grains = 0.9416;
00725                 frac_H2star_hminus = 1. - 4.938e-6;
00726         }
00727 
00728         /* print rate coefficient */
00729         /*fprintf(ioQQQ," total grain h2 form rate %.3e\n",gv.rate_h2_form_grains_used_total);*/
00730 
00731         /* collisional dissociation, rate from 
00732          * >>refer      H2      collisional dissociation        Dove, J.E., and Mandy, M. E., 1986, ApJ, 311, L93.
00733          * corr is correction for approach to high density limit
00734          * H2 + H => 3H - rate very uncertain */
00735         corr = MIN2(6.,14.44-phycon.alogte*3.08);
00736 
00737         if(corr > 0.)
00738                 corr = pow(10.,corr*Hmolec_old[ipMH]/(Hmolec_old[ipMH]+1.6e4));
00739         else
00740                 corr = 1.;
00741         /* must kill H- when UMIST is in place since they do not consider it */
00742         hmi.rh2dis = (realnum)(1.55e-8/phycon.sqrte*sexp(65107./phycon.te)* corr)*co.lgUMISTrates;
00743 
00744         /* old hminus rate Hollenbach & McKee 1979
00745          *>>chng 98 jan 02, from 2.12e4 to 2.123e4 */
00746         /*hmi.bh2h2p = 1.8e-12f*phycon.sqrte*phycon.te10/phycon.te01*2.f/16.f;
00747         hmi.rh2h2p = 1.8e-12*phycon.sqrte*phycon.te10/phycon.te01*sexp(2.123e4/
00748           phycon.te);*/
00749 
00750         /* forward and back reactions for H2+ + H+ <=> H2+ + H */
00751         /*>>chng 02 oct 25, update rate from above (Hollenbach & McKee 1979) to
00752          * >>refer      H2      form    Karpas, Z., Anicich, V., & Huntress, W.T. 1979, J Chem Phys, 70, 2877 
00753          * following is from this paper.\:
00754         We note that the application of detailed balance is only strictly valid for 
00755         state-to-state reactions, i.e., when the , J level of the reactant and product 
00756         molecules are known. While typical laboratory conditions are such that  = 0 and J 
00757         is likely to be small for the reactant, the product , J is usually unknown. 
00758         For example, Krsti (2002) finds that for the reverse of reaction (1), the product 
00759         H2 is primarily formed into  = 4, not  = 0. Therefore, estimation of reaction (1) 
00760         by the application of detailed balance to the measured rate coefficient for the 
00761         reverse reaction gives the rate coefficient for H2( = 4), which can be as much as 
00762         an order of magnitude larger than for H2( = 0). Rate coefficients that are estimated 
00763         by detailed balance are therefore suspect. 
00764         */
00765 
00766         /* H2+ + H => H2 + H+ */
00767         hmi.bh2h2p = 6.4e-10f;
00768 #       if 0
00769         /* H2  +  H+  =>  H2+  +  H
00770          * >>chng 04 Feb 24, get back reaction from above */
00771          if(hmi.rel_pop_LTE_H2g != 0.)
00772                 hmi.rh2h2p = hmi.bh2h2p*hmi.rel_pop_LTE_H2p/hmi.rel_pop_LTE_H2g;
00773          else
00774                 hmi.rh2h2p = 0;
00775 #       endif
00776         /*>> refer      H2      chem    Savin, D.W., Krstic, P.S., Haiman, Z., & Stancil, P.C., 2004,
00777          *>>refercon    ApJL, 606L, 167, astro-ph/0404288 */
00778         if(phycon.te<=3.e4 )
00779         {
00780                 /* this is lower bound to their temperature */
00781                 double teused = MAX2(100., phycon.te );
00782                 double telog = log(teused);
00783                 hmi.rh2h2p = sexp(2.123715e4/teused)*(-3.3232183e-7 + 3.3735382e-7*log(teused) -
00784                         1.4491368e-7*pow(telog,2) +3.4172805e-8*pow(telog,3) -
00785                         4.781372e-9*pow(telog,4) + 3.9731542e-10*pow(telog,5) -
00786                         1.8171411e-11*pow(telog,6) +3.5311932e-13*pow(telog,7));
00787                 /* option to kill process when Leiden hacks are in place */
00788                 hmi.rh2h2p = hmi.rh2h2p*co.lgUMISTrates;
00789         }
00790         else
00791                 hmi.rh2h2p= 0;
00792 
00793         /* >>chng 05 aug 05 NPA comment The UMIST rate uses a different photorate for H2+.  We do it better.  
00794         Therefore, for this case we use the UMIST rate only when the UMIST hack is set.
00795         We cannot actually turn off all H- reactions because to do so would cause the matrix solver 
00796         to crash.  Therefore a couple of reactions still exist, but do not affect the Leiden models */
00797 
00798         /* H2+  +  HNU  =>  H+  + H */
00799         gamtwo = GammaK(opac.ih2pnt[0],opac.ih2pnt[1],opac.ih2pof,1.);
00800 
00801         /* this only occurs when set units rates is entered */
00802         if(!co.lgUMISTrates)
00803                 gamtwo = 5.7e-10*hmi.UV_Cont_rel2_Habing_TH85_face*(realnum)sexp((1.9*rfield.extin_mag_V_point))/1.66f;
00804 
00805         /*GammaPrt(opac.ih2pnt[0],opac.ih2pnt[1],opac.ih2pof,ioQQQ,gamtwo,0.01);*/
00806 
00807         h2phet = thermal.HeatNet;
00808 
00809         /* >> chng 02 nov 15 rjrw: ionization fractions to multiply c[ipHo][*] terms
00810          * as b[ipMHo] contains _both_ H0 and H+ */
00811         /* sum_H0_Hp = ((double)dense.xIonDense[ipHYDROGEN][0])+((double)dense.xIonDense[ipHYDROGEN][1]); */
00812 
00813         sum_H0_Hp = Hmolec_old[ipMH]+Hmolec_old[ipMHp];
00814 
00815         rindex = 0;
00816         r = rlist;
00817         /* Special case, put null reaction at head of list */
00818         if(r == NULL) 
00819         {
00820                 int in[]={-1},out[]={-1};
00821                 r = rlist = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00822         }
00823         rindex++;
00824 
00825         /*-------------------------------------------------------------------- */
00826 
00827         /* H- H minus hminus balance equations
00828          * (IHMI,IPMHO) == processes making H- from Ho =+sign
00829          * radiative attachment: HI + NE => H-
00830          * H + e -> H- + hnu */
00831         /* Use Newton-Raphson step to improve solution, so bvec[] contains reaction rates
00832          * and c[][] components of the Jacobian of the rates */
00833 
00834         /* This block adds a reaction H => H- to the stack if it wasn't
00835          * there already.
00836          *
00837          * >>>> ONLY CHANGE the elements of the in[] and out[] vectors and
00838          * the rate constant, keep the rest fixed for all reactions 
00839          * */
00840         if(r->next == NULL) {
00841                 int in[]={ipMH},out[]={ipMHm};
00842                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00843         }
00844         r = r->next;
00845         rindex++;
00846 
00847         /* >>chng 05 aug 05, NPA comment:  The Leiden comparison does not consider H-.  Therefore the UMIST hack 
00848            is used to turn off H- so that it is never important */
00849 
00850         r->rk = (hmi.hminus_rad_attach + hmi.HMinus_induc_rec_rate)*co.lgUMISTrates;
00851 
00852         /* >>chng 02 oct 29, add these two chemical processes */
00853         /* H- + H+ => H2+ + e
00854          * equation (H6) from 
00855          * >>refer      H2      chemistry       Galli,D., & Palla, F. 1998, A&A, 335, 403-420 
00856          * hmihph2p = 6.9e-9f*(Tg)^(-0.35) for Tg<=8000
00857          * hmihph2p = 6.9e-9f*(Tg)^(-0.9) for Tg>=8000  */
00858         /* >>chng 02 nov 07 rjrw, include H+ ion density in rate constant */
00859         if(phycon.te <= 7891.)
00860         {
00861             /*hmihph2p = 6.9e-9*pow(phycon.te , -0.35);*/
00862             hmihph2p = 6.9e-9 / (phycon.te30 * phycon.te05);
00863         }
00864         else 
00865         {
00866                 /* >>chng 02 nov 18, had typo for leading coefficient here */
00867                 /*hmihph2p = 9.6e-7*pow(phycon.te , -0.9);*/
00868                 hmihph2p = 9.6e-7 / phycon.te90;
00869         }
00870 
00871         if(r->next == NULL) {
00872                 int in[]={ipMHm,ipMHp},out[]={ipMH2p};
00873                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00874         }
00875         r = r->next;
00876         rindex++;
00877 
00878         /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.  
00879         Therefore the UMIST hack is used to turn off H- so that it is never important */
00880 
00881         hmihph2p = hmihph2p*co.lgUMISTrates;
00882         r->rk = hmihph2p;
00883 
00884         /* >>chng 03 feb 6 */
00885         /* H2+ + H- => H2 + H
00886          * equation (32) from
00887          * >>refer      H2+     k       Stancil, P.C, & Lepp, S, & Dalgarno, A. 1998,ApJ, 509, 1-10
00888          * h2phmh2h = 1.4e-7f*pow(phycon.te/300.0, -0.5) */
00889         /* >>chng 03 sep 01, rm the pow function */
00890         /*h2phmh2h = 1.4e-7f*pow(phycon.te/300 , -0.5);*/
00891         /* the fits in this paper cannot be used below 10K or above 1e4K.  Limit
00892          * the range of evaluation */
00893         TStancil = MIN2(phycon.te, 1e4 );
00894         TStancil = MAX2( TStancil , 10. );
00895 
00897         /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.  
00898         Therefore the UMIST hack is used to turn off H- so that it is never important */
00899 
00900         hmi.h2phmh2h = 1.4e-7*co.lgUMISTrates*17.305/phycon.sqrte;
00901         if(r->next == NULL) {
00902                 int in[]={ipMH2p,ipMHm},out[]={ipMH2g,ipMH};
00903                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00904         }
00905         r = r->next;
00906         rindex++;
00907         r->rk = hmi.h2phmh2h;
00908 
00909         /* >>chng 03 feb 7 */
00910         /* H2+ + H- => H + H + H
00911          * equation (33) from
00912          * >>refer      H2+     k       Stancil, P.C, & Lepp, S, & Dalgarno, A. 1998,ApJ, 509, 1-10
00913          * h2phmhhh = 1.4e-7f*pow(phycon.te/300.0, -0.5) */
00914         /* >>chng 03 sep 01, rm the pow function */
00915         /*h2phmhhh = 1.4e-7f*pow(phycon.te/300 , -0.5);*/
00916         h2phmhhh = 1.4e-7f*17.3205/phycon.sqrte;
00917         if(r->next == NULL) {
00918                 int in[]={ipMH2p,ipMHm},out[]={ipMH,ipMH,ipMH};
00919                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00920         }
00921         r = r->next;
00922         rindex++;
00923         /* UMIST Leiden does not include H- so must kill H- reactions */
00924         r->rk = h2phmhhh*co.lgUMISTrates;
00925 
00926         /* >>chng 03 sep 30 */
00927         /* H+ + H- => H + H+ + e
00928          * >>refer      H-      k       Paolo Lenzuni, David F. Chernoff, Edwin E. Salpeter, 1991, ApJS, 76, 759L  (table 5)
00929          * hphmhhpe = 4.75e-30*pow(phycon.te,3.1); */
00930         hphmhhpe = 4.75e-30*pow(phycon.te,3.1);
00931         if(r->next == NULL) {
00932                 int in[]={ipMHp,ipMHm},out[]={ipMH,ipMHp};
00933                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00934         }
00935         r = r->next;
00936         rindex++;
00937         /* UMIST Leiden does not include H- so must kill H- reactions */
00938         r->rk =hphmhhpe*co.lgUMISTrates;
00939 
00941         /* >>chng 03 sep 30 */
00942         /* H2 + H- => H + H2 + e
00943          * >>refer      H-      k       Paolo Lenzuni, David F. Chernoff, Edwin E. Salpeter, 1991, ApJS, 76, 759L (table 5)
00944          * h2hmhh2e = 6.74e-17*pow(phycon.te,2)*sexp(19870/phycon.te); */
00945         /* UMIST Leiden does not include H- so must kill H- reactions */
00946         h2hmhh2e = 6.74e-17*co.lgUMISTrates*phycon.tesqrd*sexp(19870/phycon.te);
00947         if(r->next == NULL) {
00948                 int in[]={ipMH2g,ipMHm},out[]={ipMH,ipMH2g};
00949                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00950         }
00951         r = r->next;
00952         rindex++;
00953         r->rk =h2hmhh2e;
00954 
00955         /* (IHMI,IHMI) = processes destroying H- =-sign
00956          * photodissociation, H- + H NU => H + NE */
00957 
00958         if(r->next == NULL) {
00959                 int in[]={ipMHm},out[]={ipMH};
00960                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
00961         }
00962         r = r->next;
00963         rindex++;
00964         r->rk = hmi.HMinus_photo_rate;
00965 
00966         /* mutual neutralization with heavies, rate from Dalgarno and McCray
00967          * all charged ions contribute equally,
00968          * H- + A+ => H + A */
00969         /* >>chng 04 feb 19, do actual sum of first ions rather than following kludge */
00970         /* find the sum of all single ion densities for species heavier than helium */
00971         sum_first_ions = 0.;
00972         for( i=ipLITHIUM; i < LIMELM; i++ )
00973         {
00974                 sum_first_ions += dense.xIonDense[i][1];
00975         }
00976 
00977         {
00978                 /* this debug print statement compares H2 formation through grn vs H- */
00979                 enum {DEBUG_LOC=false};
00980                 if( DEBUG_LOC && nzone>140 )
00981                 {
00982                         fprintf(ioQQQ,"DEBUG sumfirstions\t%.2f\t%.4e\t%.4e\t%.4e",
00983                                 fnzone,phycon.te,
00984                                 sum_first_ions,
00985                                 sum_first_ions/dense.eden);
00986                         for( i=ipLITHIUM; i < LIMELM; i++ )
00987                         {
00988                                 if( dense.xIonDense[i][1]/sum_first_ions >0.1 )
00989                                         fprintf(ioQQQ,"\t%li\t%.3e",
00990                                         i,dense.xIonDense[i][1]/sum_first_ions);
00991                         }
00992                         fprintf(ioQQQ,"\n");
00993                 }
00994         }
00995 
00996         hmi.hmin_ct_firstions = 4e-6f/(realnum)phycon.sqrte;
00997 
00998         if(r->next == NULL) {
00999                 int in[]={ipMHm},out[]={ipMH};
01000                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01001         }
01002         r = r->next;
01003         rindex++;
01004         r->rk = hmi.hmin_ct_firstions*sum_first_ions*co.lgUMISTrates;
01005 
01006         /* electron collisional ionization of H- */
01007         cionhm *= dense.eden;
01008 
01009         if(r->next == NULL) {
01010                 int in[]={ipMHm},out[]={ipMH};
01011                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01012         }
01013         r = r->next;
01014         rindex++;
01015         r->rk = cionhm*co.lgUMISTrates;
01016 
01017         /* inverse process; three body rec */
01018         c3bod = cionhm*(hmi.rel_pop_LTE_Hmin*dense.eden);
01019 
01020         if(r->next == NULL) {
01021                 int in[]={ipMH},out[]={ipMHm};
01022                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01023         }
01024         r = r->next;
01025         rindex++;
01026         r->rk = c3bod*co.lgUMISTrates;
01027 
01028         /* form molecular hydrogen from H minus,
01029          * associative detachment:  H- + H => H2 + E */
01030         /* make H2 from H- 
01031          * associative detachment; H- + H => H2: 
01032          * >>referold   H2      rates   Browne & Dalgarno J PHys B 2, 885 */
01033         /* rate coefficient from 
01034          * >>refer      H2      form    Launay, J.R., Le Dourneuf, M., & Zeippen, C.J., 
01035          * >>refercon   1991, A&A, 252, 842-852*/
01036         /* >>chng 02 oct 17, temp dependent fit to rate, updated reference,
01037          * about 40% larger than before */
01038         {
01039                 double y , x;
01040                 x = MAX2(10., phycon.te );
01041                 x = MIN2(1e4, x );
01042                 y=545969508.1323510+x*71239.23653059864;
01043                 hmi.assoc_detach = 1./y;
01044         }
01045 
01046         /* >>chng 02 nov 7 rjrw, example case of 2-body process */
01047         /* this one is into ground H2 */
01048         if(r->next == NULL) {
01049                 int in[]={ipMH, ipMHm},out[]={ipMH2g};
01050                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01051         }
01052         r = r->next;
01053         rindex++;
01054         r->rk = hmi.assoc_detach*co.lgUMISTrates*(1.-frac_H2star_hminus);
01055 
01056         /* >>chng 03 sep 10, multiply above by correction for excited state,
01057          * add below reaction for population of excited state */
01058         /* this one is into excited H2 */
01059         if(r->next == NULL) {
01060                 int in[]={ipMH, ipMHm},out[]={ipMH2s};
01061                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01062         }
01063         r = r->next;
01064         rindex++;
01065         r->rk = hmi.assoc_detach*frac_H2star_hminus*co.lgUMISTrates;
01066 
01067         {
01068                 /* this debug print statement compares H2 formation through grn vs H- */
01069                 enum {DEBUG_LOC=false};
01070                 if( DEBUG_LOC && nzone>140 )
01071                 {
01072                         fprintf(ioQQQ," debuggggrn grn\t%.2f\t%.3e\t%.3e\tfrac\t%.3e\tH-\t%.3e\t%.3e\tfrac\t%.3e\t%.3e\t%.3e\t%.3e\n",
01073                                 fnzone ,
01074                                 gv.rate_h2_form_grains_used_total , 
01075                                 hmi.H2_forms_grains+hmi.H2star_forms_grains ,
01076                                 frac_H2star_grains,
01077                                 hmi.assoc_detach*dense.xIonDense[ipHYDROGEN][0]*hmi.Hmolec[ipMHm],
01078                                 hmi.H2star_forms_hminus+hmi.H2_forms_hminus,
01079                                 frac_H2star_hminus,
01080                                 hmi.assoc_detach,dense.xIonDense[ipHYDROGEN][0],hmi.Hmolec[ipMHm]
01081                                 );
01082                 }
01083         }
01084 
01085         /* convert H2 into H- 
01086          * the back reaction, H2(grnd) + e => H- + Ho */
01087         if( hmi.rel_pop_LTE_H2g > 0. )
01088         { 
01089                 hmi.assoc_detach_backwards_grnd = hmi.assoc_detach*hmi.rel_pop_LTE_Hmin/hmi.rel_pop_LTE_H2g*
01090                         dense.eden*co.lgUMISTrates;
01091         }
01092         else
01093         {
01094                 hmi.assoc_detach_backwards_grnd = 0.;
01095         }
01096 
01097         /* convert H2 into H- 
01098          * the back reaction, H2(exct) + e => H- + Ho */
01099         if( hmi.rel_pop_LTE_H2s > 0. )
01100         { 
01101 
01102                 hmi.assoc_detach_backwards_exct = hmi.assoc_detach*hmi.rel_pop_LTE_Hmin/hmi.rel_pop_LTE_H2s*
01103                         dense.eden*co.lgUMISTrates; 
01104         }
01105         else
01106         {
01107                 hmi.assoc_detach_backwards_exct = 0.;
01108         }
01109 
01110         {
01111                 /* often the H- route is the most efficient formation mechanism for H2,
01112                  * will be through rate called Hmolec_old[ipMH]*hmi.assoc_detach
01113                  * this debug print statement is to trace h2 oscillations */
01114                 enum {DEBUG_LOC=false};
01115                 if( DEBUG_LOC && nzone>140/*&& iteration > 1*/)
01116                 {
01117                         /* rapid increase in H2 density caused by rapid increase in hmi.rel_pop_LTE_H2g */
01118                         fprintf(ioQQQ,"hmi.assoc_detach_backwards_grnd\t%.2f\t%.5e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\n", 
01119                                 /* total forward rate */
01120                                 fnzone,
01121                                 phycon.te, 
01122                                 dense.eden,
01123                                 /* rate H- + H => H2 + E */
01124                                 hmi.assoc_detach,
01125                                 hmi.assoc_detach_backwards_grnd, 
01126                                 hmi.assoc_detach_backwards_exct, 
01127                                 hmi.hminus_rad_attach,
01128                                 hmi.HMinus_induc_rec_rate,
01129                                 /* H0 */
01130                                 hmi.Hmolec[ipMH],
01131                                 /* H+ */
01132                                 hmi.Hmolec[ipMHp],
01133                                 /* H- */
01134                                 hmi.Hmolec[ipMHm],
01135                                 hmi.H2_total,
01136                                 hmi.rel_pop_LTE_Hmin,
01137                                 hmi.rel_pop_LTE_H2g,
01138                                 hmi.rel_pop_LTE_H2s
01139                                 );
01140                 }
01141         }
01142 
01143         /* >>chng 03 sep 11, resolve H2 and H2*, use fraction determined above */
01144         if(r->next == NULL) {
01145                 int in[]={ipMH2g},out[]={ipMH,ipMHm};
01146                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01147         }
01148         r = r->next;
01149         rindex++;
01150 
01151         /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.  
01152         Therefore the UMIST hack is used to turn off H- so that it is never important */
01153 
01154         /* >>chng 05 oct 03, TE, rearrange to get the correct H2 destruction file */ 
01155         hmi.assoc_detach_backwards_grnd *= ((1.-frac_H2star_hminus) * co.lgUMISTrates);
01156         r->rk = hmi.assoc_detach_backwards_grnd;
01157 
01158         /* >>chng 03 sep 11, resolve H2 and H2*, add new destruction process for H2* */
01159         if(r->next == NULL) {
01160                 int in[]={ipMH2s},out[]={ipMH,ipMHm};
01161                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01162         }
01163         r = r->next;
01164         rindex++;
01165         /* >>chng 04 jan 28, had wrong Boltzmann factor for this reaction,
01166          * fixed by Gargi Shaw */
01167 
01168         /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.  
01169         Therefore the UMIST hack is used to turn off H- so that it is never important */
01170 
01171         /* >>chng 05 oct 03, TE, rearrange to get the correct H2 destruction file */ 
01172         hmi.assoc_detach_backwards_exct *= (frac_H2star_hminus * co.lgUMISTrates);
01173         r->rk = hmi.assoc_detach_backwards_exct;
01174 
01175         /*#     define Hneut 7e-8*/
01176         /* >>chng 05 sept 12 - NPA.  change rate for mutual neutralization of H-
01177          * and H+ to the rate from 
01178          * >>refer H-   mutual neut     Lepp, S., Stancil, P.C. & Dalgarno, A. 2002, J. Phys. B, 35, R57 */
01179         if( phycon.te < 14125. )
01180         {
01181                 /* the fit in Lepp et al. explodes at high temperature,
01182                  * Te = 14,125 is the temp where the rates reaches its lowest value */
01183                 Hneut = 1.4e-7*pow(phycon.te/300,-0.487)*exp(phycon.te/29300);
01184         }
01185         else
01186         {
01187                 Hneut = 3.4738192887404660e-008;
01188         }
01189         /* mutual neut, mostly into n=3; rates from Janev et al
01190          * H- + H+ => H + H(n=3) */
01192         fhneut = Hmolec_old[ipMHp]*Hneut; /* dense.xIonDense[ipHYDROGEN][1]*7e-8; */
01193 
01194         if(r->next == NULL) {
01195                 int in[]={ipMHm,ipMHp},out[]={ipMH,ipMH};
01196                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01197         }
01198         r = r->next;
01199         rindex++;
01200 
01201         /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.  
01202         Therefore the UMIST hack is used to turn off H- so that it is never important */
01203 
01204         r->rk = Hneut*co.lgUMISTrates;
01205 
01206         /* back reaction from excited state H */
01207         if( phycon.te > 1000. )
01208         {
01209                 /* HBN(3,1) is defined; when <HydTempLimit then set to 1 */
01210                 bhneut = (Hneut*hmi.rel_pop_LTE_Hmin*dense.eden)*iso.DepartCoef[ipH_LIKE][ipHYDROGEN][3];
01211         }
01212         else
01213         {
01214                 bhneut = 0.;
01215         }
01216 
01217         /* mutual neut, mostly into n=3; rates from Janev et al
01218          * H + H(n=3) => H- + H+ */
01220         /* this is the back reaction, forming H- from Ho */
01221 
01222         if(r->next == NULL) {
01223                 int in[]={ipMH,ipMH},out[]={ipMHm,ipMHp}, ratesp[]={ipMH,ipMHp};
01224                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01225         }
01226         r = r->next;
01227         rindex++;
01228         r->rk = bhneut*co.lgUMISTrates; 
01229         bhneut *= Hmolec_old[ipMHp];
01230 
01231         /*--------------------------------------------------------------------
01232          *
01233          * molecular hydrogen H2 Htwo balance equation
01234          * (IPMH2,IPMHO)==create H2 from Ho =+ */
01235 
01236         /* H2 formation on grains */
01237         /* >>chng 01 jan 05, remove from matrix part and add hden to hmi.rate_h2_form_grains_used, */
01238         /* the large molecule keeps explicit track of the fraction that goes into 
01239          * excited vs ground H2.  Use that ratio if H2 turned on, else use an
01240          * estimate of it */
01241         /* The reaction rate is only proportional to one of the ipMH, due to
01242          * surface saturation (?) */
01243 
01244 #       define  CATALYST        true
01245         if( CATALYST )
01246         {
01247                 /* this is the method used by the code for most of its history.  The grain
01248                  * is only a catalytic agent, and so the rate goes as the square of the
01249                  * incoming H0 density */
01250                 /* This goes to excited H2 */
01251                 if(r->next == NULL) {
01252                         int in[]={ipMH,ipMH},out[]={ipMH2s},ratesp[]={ipMH};
01253                         r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01254                 }
01255                 r = r->next;
01256                 rindex++;
01257                 r->rk = gv.rate_h2_form_grains_used_total*frac_H2star_grains;
01258 
01259                 /* >>chng 03 sep 10, multiply above by correction for excited state,
01260                 * add below reaction for population of excited state */
01261 
01262                 /* This goes to ground H2 */
01263                 if(r->next == NULL) {
01264                         int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH};
01265                         r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01266                 }
01267                 r = r->next;
01268                 rindex++;
01269                 r->rk = gv.rate_h2_form_grains_used_total*(1. - frac_H2star_grains);
01270         }
01271 
01272         else
01273         {
01274                 /* >>chng 03 nov 25, go to this formalism */
01275                 /* the grain is not a true catalyst, but rather a target loaded with H atoms
01276                  * ready to react.  So the rate is the number of these grains, times their
01277                  * cross section, times the number of incident H atoms.  The number of grains
01278                  * is replaced with the total hydrogen density, which is not in the network
01279                  * but is a constant */
01280                 /* This goes to excited H2 */
01281                 if(r->next == NULL) {
01282                         int in[]={ipMH,ipMH},out[]={ipMH2s},ratesp[]={ipMH};
01283                         r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01284                 }
01285                 r = r->next;
01286                 rindex++;
01287                 r->rk = gv.rate_h2_form_grains_used_total*frac_H2star_grains*
01288                         dense.gas_phase[ipHYDROGEN]/SDIV(dense.xIonDense[ipHYDROGEN][0]);
01289 
01290                 /* >>chng 03 sep 10, multiply above by correction for excited state,
01291                 * add below reaction for population of excited state */
01292 
01293                 /* This goes to ground H2 */
01294                 if(r->next == NULL) {
01295                         int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH};
01296                         r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01297                 }
01298                 r = r->next;
01299                 rindex++;
01300                 r->rk = gv.rate_h2_form_grains_used_total*(1. - frac_H2star_grains)*
01301                         dense.gas_phase[ipHYDROGEN]/SDIV(dense.xIonDense[ipHYDROGEN][0]);
01302         }
01303 
01304         /* excited atom radiative association,
01305          * H(n=2) + H(n=1) => H2 + hnu
01306          * written as H(n=1)*pop ratio + H(n=1) -> H2 + hnu but ratio of pops is in
01307          * terms of pop to ion, so initial term is
01308          * n(H+) * pop2ion, 
01309          * >>refer      H2      rates   Latter, W.B., & Black, J.H., 1991, Ap.J. 372, 161 */
01310         /* hmi.radasc = ((StatesElem[ipH_LIKE][ipHYDROGEN][ipH2p].Pop + StatesElem[ipH_LIKE][ipHYDROGEN][ipH2s].Pop)*dense.xIonDense[ipHYDROGEN][1])*3e-14; */
01311 
01313         hmi.radasc = ((StatesElem[ipH_LIKE][ipHYDROGEN][ipH2p].Pop + StatesElem[ipH_LIKE][ipHYDROGEN][ipH2s].Pop))*3e-14;
01314         /* >>chng 02 nov 7 rjrw: correct for n^2 behaviour w.r.t. H 
01315            >>chng 02 nov 7 rjrw, correct stoichiometry */
01316 
01317         /* Possible that changing to a rate proportional to ipMHp would be more consistent */
01318         if(r->next == NULL) {
01319                 int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH,ipMHp};
01320                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01321         }
01322         r = r->next;
01323         rindex++;
01324         r->rk = hmi.radasc*co.lgUMISTrates;  
01325         hmi.radasc *= Hmolec_old[ipMHp]; /* why this is reset here? GS*/
01326 
01327         /* photo-destroy H2 */
01328         /* >>chng 00 nov 25 factor of 0.1, assume pump is total, and 10% destroy H2 is 21*/
01329         if(r->next == NULL) {
01330                 int in[]={ipMH2g},out[]={ipMH,ipMH};
01331                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01332         }
01333         r = r->next;
01334         rindex++;
01335         /* >>chng 03 mar 07, had factor of 0.1 for branching ratio from H2** to H+H, 
01336          * but branching is now already included */
01337         /*r->rk = hmi.H2_Solomon_dissoc_rate_used*0.1;*/
01338         r->rk = hmi.H2_Solomon_dissoc_rate_used_H2g;
01339 
01340         /* >>chng 03 sep 11, add this process */
01341         /* photo-destroy H2* by Solomon process at same rate as H2ground dissociation,
01342                 see above eqn A12 in TH85 */
01343         /* >>chng 00 nov 25 factor of 0.1, assume pump is total, and 10% destroy H2 */
01344         if(r->next == NULL) {
01345                 int in[]={ipMH2s},out[]={ipMH,ipMH};
01346                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01347         }
01348         r = r->next;
01349         rindex++;
01350         /* >>chng 03 mar 07, had factor of 0.1 for branching ratio from H2** to H+H, 
01351          * but branching is now already included */
01352         /*r->rk = hmi.H2_Solomon_dissoc_rate_used*0.1; is #22*/
01353         r->rk = hmi.H2_Solomon_dissoc_rate_used_H2s;
01354 
01355         /* H2 + H+ => H3+ HNU
01356          * equation H21 from 
01357          * >>refer      H2      chemistry       Galli,D., & Palla, F. 1998, A&A, 335, 403-420 */
01358         /* >>chng 02 nov 07 rjrw, include H+ ion density in rate constant */
01359 
01360         /* >>chng 05 aug 05, NPA comment.  This reaction is not in UMIST, therefore I turned it 
01361            off when comparing to the other codes */
01364         hmi.h2hph3p = 1.0e-16f*co.lgUMISTrates;
01365 
01366         if(r->next == NULL) {
01367                 int in[]={ipMH2g,ipMHp},out[]={ipMH3p};
01368                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01369         }
01370         r = r->next;
01371         rindex++;
01372         r->rk = hmi.h2hph3p;
01373 
01374         /* collisional dissociation, rate from 
01375          * >>refer      H2      collisional dissociation        Dove, J.E., and Mandy, M. E., 1986, ApJ, 311, L93.
01376          * H_2 + H => 2H + H     
01377          * >>chng 02 nov 7 rjrw, correct stoichiometry */
01378 
01379         /* Rate is catalyzed by an additional H */
01380         if(r->next == NULL) {
01381                 int in[]={ipMH2g},out[]={ipMH,ipMH},ratesp[]={ipMH,ipMH2g};
01382                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01383         }
01384         r = r->next;
01385         rindex++;
01386         hmi.rh2dis *= co.lgUMISTrates;
01387         r->rk = hmi.rh2dis;
01388 
01389         /* >>chng 04 apr 21 */
01390         /* 2H + H2 => H2 + H2
01391          * equation (5) from 
01392          * >>refer      H2      chemistry Palla, F., Salpeter, E.E., & Stahler, S.W., 1983, ApJ,271, 632-641
01393          * bh2h22hh2= 5.5e-29/(8*phycon.te) */
01395         hmi.bh2h22hh2 = 5.5e-29*co.lgUMISTrates/(8.*phycon.te);
01396 
01397         if(r->next == NULL) {
01398                 int in[]={ipMH,ipMH,ipMH2g},out[]={ipMH2g,ipMH2g};
01399                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01400         }
01401         r = r->next;
01402         rindex++;
01403         r->rk = hmi.bh2h22hh2;
01404 
01405         /* >>chng 04 apr 21 */
01406         /* H2 + H2 => 2H + H2
01407          * equation (5) from 
01408          * >>refer      H2      chemistry Palla, F., Salpeter, E.E., & Stahler, S.W., 1983, ApJ,271, 632-641
01409          * h2h22hh2 = bh2h22hh2/hmi.rel_pop_LTE_H2g */
01411         if( hmi.rel_pop_LTE_H2g > 0. )
01412         {
01413                 hmi.h2h22hh2 = hmi.bh2h22hh2/hmi.rel_pop_LTE_H2g;
01414         }
01415         else
01416         {
01417                 hmi.h2h22hh2 =0.;
01418         }
01419 
01420         if(r->next == NULL) {
01421                 int in[]={ipMH2g,ipMH2g},out[]={ipMH,ipMH,ipMH2g};
01422                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01423         }
01424         r = r->next;
01425         rindex++;
01426         hmi.h2h22hh2 *= co.lgUMISTrates;
01427         r->rk = hmi.h2h22hh2;
01428 
01429         /* back rate, three body recombination, 2H + S => H_2 + S        
01430          * >>chng 02 nov 7 rjrw: correct for n^2 behaviour w.r.t. H 
01431          * >>chng 02 nov 7 rjrw, correct stoichiometry 
01432          * >>chng 02 nov 7 rjrw, correct for n^3 behaviour w.r.t. H !! */
01433         /* hmi.bh2dis = hmi.rh2dis*hmi.rel_pop_LTE_H2g*dense.xIonDense[ipHYDROGEN][0]*dense.xIonDense[ipHYDROGEN][0]; */
01435         hmi.bh2dis = hmi.rh2dis*hmi.rel_pop_LTE_H2g*co.lgUMISTrates;    
01436 
01437         if(r->next == NULL) {
01438                 int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH,ipMH,ipMH};
01439                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
01440         }
01441         r = r->next;
01442         rindex++;
01443         r->rk = hmi.bh2dis;
01444 
01445         hmi.bh2dis = hmi.rh2dis*hmi.rel_pop_LTE_H2g*Hmolec_old[ipMH]*Hmolec_old[ipMH]*co.lgUMISTrates;
01446 
01447         /* H2 + HNU=>  H2+ + E
01448          * photoionization by hard photons, crossection=3*HI - in molecular environments this is
01449          * only the highest energy photons that have penetrated the H+ and H0 regions*/
01450         /* following copies from opacity_addtotal line 353 */
01457         /* >>chng 02 jan 16, approximate inclusion of H_2 photoelectric opacity */
01458         /* include H_2 in total photoelectric opacity */
01459         /* set lower and upper limits to this range */
01460         /*hmi.H2_photoionize_rate = iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s];
01461         fprintf(ioQQQ,"DEBUG H2 photo\t%.3e", hmi.H2_photoionize_rate );*/
01463         /* >>chng 05 nov 24, evaluate real photo rate,
01464          * had used H0 rate - photo heating had not been included */
01465         {
01466                 static long int nzone_eval = -1, iteration_evaluated=-1;
01467                 /* must reevaluate During search phase */
01468                 if( ( nzone_eval!=nzone || iteration_evaluated!=iteration ) || !nzone )
01469                 {
01470                         /* generally not important, do one time per zone */
01471                         hmi.H2_photoionize_rate = 
01472                                 GammaK(opac.ipH2_photo_thresh , 
01473                                 rfield.nupper,
01474                                 opac.ipH2_photo_opac_offset,1.)*
01475                                 ionbal.lgPhotoIoniz_On +
01476                                 /* Compton recoil ionization - we include this in the H2 photoionization
01477                                  * rate but not the heating rate - factor of two since assume 2H
01478                                  * is same as two H0 at such high energies */
01479                                  2.*ionbal.CompRecoilIonRate[ipHYDROGEN][0];
01480 
01481                         /* photo heating - this has units s-1 - needs H2 density
01482                          * to become vol heat rate */
01483                         hmi.H2_photo_heat_soft = thermal.HeatLowEnr * ionbal.lgPhotoIoniz_On;
01484                         hmi.H2_photo_heat_hard = thermal.HeatHiEnr * ionbal.lgPhotoIoniz_On;
01485                         nzone_eval = nzone;
01486                         iteration_evaluated = iteration;
01487                 }
01488         }
01489 
01490         /*fprintf(ioQQQ,"\t %.3e\n", hmi.H2_photoionize_rate );*/
01491 
01492         /* cosmic rays predominantly H2 + cr -> H2+ + e, as per table 10 of TH85 */
01493         /* >>chng 00 nov 28, factor of 0.93 from
01494          >>refer        cosmic ray      ionization rate Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722
01495          * also cosmic rays producing secondary ionization csupra */
01496         /* >>chng 00 nov 28, factor of 0.93 from
01497          >>refer        cosmic ray      ionization rate Maloney, P.R., Hollenbach, D., & Tielens, A. G. G. M., 1998, ApJ, 466, 561
01498          */
01499         /* >>chng 04jan 26, assume ion(H2) = 2x ion(H), H ion rate of
01500          * 2.5e-17 s-1, as per
01501          * >>refer      cosmic ray      ionization      Williams, J.P., Bergin, E.A., Caselli, P., 
01502          * >>refercon   Myers, P.C., & Plume, R. 1998, ApJ, 503, 689 
01503          * so H2 secondary ionization rate is 5e-17 s-1 */
01504         if(r->next == NULL) {
01505                 int in[]={ipMH2g},out[]={ipMH2p};
01506                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01507         }
01508         r = r->next;
01509         rindex++;
01510         /* >> chng 05 jul 07, TE, rename to get correct h2 destruction file */
01511         /* ratio of H2 to H cr rates from table 10 of tielens & hollenbach 1985 */
01512         /* >> chng 05 aug 05, NPA comment.  Our definition of the cosmic ray reaction, 
01513            we include the factor hmi.H2_photoionize_rate.  The Leiden comparison wanted a constant cosmic 
01514            ray rate.  Therefore if the UMIST rate is set we use a constant 4.4e-17 ionization
01515            rate.  Otherwise we just use what Cloudy naturally does */
01516         if(co.lgUMISTrates)
01517         {
01518                 h2crh2pe = hmi.H2_photoionize_rate + secondaries.csupra[ipHYDROGEN][0]*2.02;
01519         }
01520 
01521         else
01522         {
01523                 h2crh2pe = 4.4e-17;
01524         }
01525 
01526         r->rk = h2crh2pe;
01527 
01528         /* >>chng 04 apr 22, add H2 + cr -> H+ H + e, TH85 table 10 */
01529         if(r->next == NULL) {
01530                 int in[]={ipMH2g},out[]={ipMH,ipMHp};
01531                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01532         }
01533         r = r->next;
01534         rindex++;
01535 
01536         /* >> chng 05 jul 07, TE, rename to get correct h2 destruction file */
01537         /* ratio of H2 to H cr rates from table 10 of tielens & hollenbach 1985 */
01538         /* >> chng 05 aug 05, NPA comment.  The Leiden comparison wanted a constant cosmic 
01539            ray rate.  Therefore if the UMIST rate is set we use a constant 1e-19 ionization
01540            rate.  Otherwise we just use what Cloudy naturally does */
01541 
01542         if(co.lgUMISTrates)
01543         {
01544                 h2crhphe = secondaries.csupra[ipHYDROGEN][0]*0.0478;
01545         }
01546         else
01547         {
01548                 h2crhphe =  1e-19;
01549         }
01550         r->rk = h2crhphe;
01551 
01552         /* >> chng 05 sep 26, TE, include the same reaction for H2s */
01553         /* H2s + CR -> H+ H + e, TH85 table 10 */
01554         if(r->next == NULL) {
01555                 int in[]={ipMH2s},out[]={ipMH,ipMHp};
01556                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01557         }
01558         r = r->next;
01559         rindex++;
01560         if(co.lgUMISTrates)
01561         {
01562                 h2scrhphe = secondaries.csupra[ipHYDROGEN][0]*0.0478;
01563         }
01564         else
01565         {
01566                 h2scrhphe =  1e-19;
01567         }
01568         r->rk = h2scrhphe;
01569 
01570 
01571         /* >> chng 05 jul 07, TE, rename to get correct h2 destruction file */
01572         /* >>chng 05 jul 01,GS */
01573         /* H2s + CRP => H2+ + e; 
01574          * Cosmic ray ionization of H2s added*/
01575         if(r->next == NULL) {
01576                 int in[]={ipMH2s},out[]={ipMH2p};
01577                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01578         }
01579         r = r->next;
01580         rindex++;
01581 
01582         if( co.lgUMISTrates )
01583         {
01584                 /* not using UMIST - do the general case */
01585                 h2scrh2pe = hmi.H2_photoionize_rate + secondaries.csupra[ipHYDROGEN][0]*2.02;
01586         }
01587         else
01588         {
01589                 /* use UMIST - this is from Sternberg email defining Leiden meeting */
01590                 h2scrh2pe = 4.4e-17;
01591         }
01592         r->rk = h2scrh2pe;
01593 
01594         /* >>chng 03 apr 11 */
01595         /* H2 + CRP => H + H; CRP=Cosmic Ray proton 
01596          * equation (3643) from
01597          * >>refer      H2      k       Millar, T.J. et.al, 1997,A&AS, 121, 139
01598          * h2crphh = 1.3e-18f */ 
01599         if(r->next == NULL) {
01600                 int in[]={ipMH2g},out[]={ipMH,ipMH};
01601                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01602         }
01603         r = r->next;
01604         rindex++;
01605 
01606         /* >>chng 05 jun 16, GS, use the rate from big H2 network */
01607         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
01608         {
01609                 h2crphh = hmi.H2_tripletdissoc_H2g;
01610         }
01611         else
01612         {
01613                 h2crphh = secondaries.x12tot*3.;
01614         }
01615 
01616         /* co.lgUMISTrates is set false with the set Leiden hack command, which also
01617          * sets their standard cosmic ray rates */
01618         /* >> chng 05 aug 05, NPA comment.  The Leiden comparison wanted a constant cosmic 
01619            ray rate.  Therefore if the UMIST rate is set we use a constant 5e-18 ionization
01620            rate.  Otherwise we just use what Cloudy naturally does */
01621         if(!co.lgUMISTrates)
01622                  h2crphh = 5e-18;
01623 
01624         r->rk = h2crphh;
01625 
01626         /* >>chng 05 jun 16, GS, use the rate from big H2 network, small network does not have this rate */
01627         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
01628         {
01629                 h2scrphh = hmi.H2_tripletdissoc_H2s;
01630         }
01631         else
01632         {
01633                 h2scrphh = secondaries.x12tot*3.;
01634         }
01635 
01636         if(r->next == NULL) {
01637                 int in[]={ipMH2s},out[]={ipMH,ipMH};
01638                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01639         }
01640         r = r->next;
01641         rindex++;
01642         r->rk = h2scrphh;
01643 
01644         /* >>chng 03 apr 11 */
01645         /* H2 + CRP => H+ + H_; CRP=Cosmic Ray Proton
01646          * equation (3644) from
01647          * >>refer      H2      k       Millar, T.J., et.al, 1997,A&AS, 121, 139
01648          * h2crphphm = 3.9e-21 */
01649         /* >> chng 05 aug 05, NPA comment.  Turn off H- for the Leiden comparison */
01650          h2crphphm = 3.9e-21 * hextra.cryden_ov_background * co.lgUMISTrates;
01651 
01652         if(r->next == NULL) {
01653                 int in[]={ipMH2g},out[]={ipMHp,ipMHm};
01654                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01655         }
01656         r = r->next;
01657         rindex++;
01658 
01659         r->rk = h2crphphm;
01660 
01661         /* >> chng 05 sep 26, TE, include the same reaction for H2s */
01662         /* H2s + CRP => H+ + H_; CRP=Cosmic Ray Proton */
01663          h2scrphphm = 3.9e-21 * hextra.cryden_ov_background * co.lgUMISTrates;
01664 
01665         if(r->next == NULL) {
01666                 int in[]={ipMH2s},out[]={ipMHp,ipMHm};
01667                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01668         }
01669         r = r->next;
01670         rindex++;
01671 
01672         r->rk = h2scrphphm;
01673 
01674         /* >>chng 03 apr 11 */
01675         /* H2 + CRP => H+ + H + e; CRP=Cosmic Ray Proton
01676          * equation (3641) from
01677          * >>refer      H2      k       Millar, T.J., et.al, 1997,A&AS, 121, 139
01678          * h2crphpeh = 2.2e-19f */ 
01679         /* >> chng 05 aug 05, NPA comment.  Amiel Sternberg said to not consider this process
01680               in the benchmark calculations.  Therefore, the UMIST rate is used to turn this reaction off */
01681          h2crphpeh = 2.2e-19 * hextra.cryden_ov_background * co.lgUMISTrates;
01682 
01683         if(r->next == NULL) {
01684                 int in[]={ipMH2g},out[]={ipMHp,ipMH};
01685                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01686         }
01687         r = r->next;
01688         rindex++;
01689         r->rk = h2crphpeh;
01690 
01691         /* >> chng 05 sep 26, TE, include the same reaction for H2s */
01692         /* H2s + CRP => H+ + H + e; CRP=Cosmic Ray Proton */
01693          h2scrphpeh = 2.2e-19 * hextra.cryden_ov_background * co.lgUMISTrates;
01694 
01695         if(r->next == NULL) {
01696                 int in[]={ipMH2s},out[]={ipMHp,ipMH};
01697                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01698         }
01699         r = r->next;
01700         rindex++;
01701         r->rk = h2scrphpeh;
01702 
01703         /*>>chng 05 jul 01, GS, h2s ionization by cosmic ray added*/
01704         /* >>chng 05 jun 29, TE, used in new punch H2 destruction file*/
01705         hmi.CR_reac_H2g = h2crh2pe + h2crhphe + h2crphh + h2crphphm + h2crphpeh;
01706         hmi.CR_reac_H2s = h2scrh2pe + h2scrhphe + h2scrphh + h2scrphphm + h2scrphpeh;
01707 
01708         /* >>chng 03 apr 11 */
01709         /* H3+ + H-=> H2 + H2; 
01710          * equation (5,table 9) from
01711          * >>refer      H3+     k       Maloney et.al, 1996,ApJ, 466, 561
01712          * h3phm2h2 = 1.3e-7f*pow(phycon.te/1000., -0.5) */ 
01714         /* >> chng 05 aug 05, NPA comment.  Turn off H- for the Leiden comparison */
01715         hmi.h3phm2h2 = 1.3e-7 / (phycon.sqrte/31.62278) * co.lgUMISTrates;/*pow(phycon.te/1000., -0.5);*/
01716         if(r->next == NULL) {
01717                 int in[]={ipMH3p,ipMHm},out[]={ipMH2g,ipMH2g};
01718                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01719         }
01720         r = r->next;
01721         rindex++;
01722         r->rk = hmi.h3phm2h2;
01723 
01724         /* >>chng 03 sep 30 */
01725         /* H3+ + HNU=> H2+ + H; 
01726          * equation (table 5) from
01727          * >>refer      H2      dissoc  Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722  
01728          * h3ph2ph = 7.9e-9*hmi.UV_Cont_rel2_Habing_TH85_depth;*/
01729         /* >>chng 04 jun 13 --  update this rate to match that in the UMIST database */
01730 
01731         /* >> chng 05 aug 05, NPA comment.  This is one of the few instances where 
01732         I actually updated a rate permanently.  Originally this rate was taken from TH85.  
01733         I changed this to the UMIST rate.  The UMIST database gives the reference for their 
01734         rate as van Dishoeck and Black, 1987.  Therefore, since it comes from such a regarded 
01735         source and after the TH85 paper, I think this is appropriate.  The UMIST hack is used 
01736         to extinguish the continuum by exp(-a*AV) instead of through our radiative transfer 
01737         solution, which is what the other codes in the comparison did. */
01738 
01739         if(co.lgUMISTrates)
01740         {
01741                 h3ph2ph = 5.0e-13*hmi.UV_Cont_rel2_Habing_TH85_depth/1.66f;
01742         }
01743         else
01744         {
01745                 h3ph2ph = 5.0e-13*hmi.UV_Cont_rel2_Habing_TH85_face*(realnum)sexp((2.3*rfield.extin_mag_V_point))/1.66f;
01746         }
01747 
01748         if(r->next == NULL) {
01749                 int in[]={ipMH3p},out[]={ipMH2p,ipMH};
01750                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01751         }
01752         r = r->next;
01753         rindex++;
01754         r->rk =h3ph2ph;
01755 
01756         /* >>chng 03 sep 30 */
01757         /* H3+ + HNU=> H2 + H+; 
01758          * equation (table 5) from
01759          * >>refer      H2      dissoc  Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722  
01760          * h3ph2hp = 2.0e-8*hmi.UV_Cont_rel2_Habing_TH85_depth;*/
01761         /* >>chng 04 jun 13 --  update this rate to match that in the UMIST database */ 
01762         /* >> chng 05 aug 05, NPA comment.  This is one of the few instances where 
01763         I actually updated a rate permanently.  Originally this rate was taken from TH85.  
01764         I changed this to the UMIST rate.  The UMIST database gives the reference for their 
01765         rate as van Dishoeck and Black, 1987.  Therefore, since it comes from such a regarded 
01766         source and after the TH85 paper, I think this is appropriate.  The UMIST hack is used 
01767         to extinguish the continuum by exp(-a*AV) instead of through our radiative transfer 
01768         solution, which is what the other codes in the comparison did. */
01770         if(co.lgUMISTrates)
01771         {
01772                 hmi.h3ph2hp = 5.0e-13*hmi.UV_Cont_rel2_Habing_TH85_depth/1.66f;
01773         }
01774         else
01775         {
01776                 hmi.h3ph2hp = 5.0e-13*hmi.UV_Cont_rel2_Habing_TH85_face*sexp((1.8*rfield.extin_mag_V_point))/1.66;
01777         }
01778 
01779         if(r->next == NULL) {
01780                 int in[]={ipMH3p},out[]={ipMH2g,ipMHp};
01781                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01782         }
01783         r = r->next;
01784         rindex++;
01785         r->rk =hmi.h3ph2hp;
01786 
01787         /* >> chng 02 nov 15 rjrw: multiply c[ipMHo][*] terms by ionization fraction
01788          * as b[ipMHo] contains _both_ H0 and H+ */
01789         /* H2*  +  H+  =>  H2+  +  H */
01790         /* >> chng 05 jul 14, TE, 
01791          * to maintain detailed balance with bh2h2p, only consider H2s*/
01792         /* >> chng 05 sept 28, GS, 
01793          * H2g  +  H+  =>  H2+  +  H 
01794          *  bh2h2p and rh2h2p are not in detailed balance,astro-ph/0404288*/
01795         if(r->next == NULL) {
01796                 int in[]={ipMH2g,ipMHp},out[]={ipMH,ipMH2p};
01797                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01798         }
01799         r = r->next;
01800         rindex++;
01801         r->rk = hmi.rh2h2p;
01802 
01803         /* (3,IPMH2P) == destroy H2+ = -sign
01804          * H + H2+ => H+ + H2 */
01805         /* >>chng 02 nov 7 rjrw, remove the destruction rate 
01806          *       c[ipMHo][ipMHo] += -hmi.bh2h2p*hmi.Hmolec[ipMH2p]; 
01807          * twice -- reaction changes state of H within single [H0,H+] `species' */
01808 
01809         if(r->next == NULL) 
01810         {
01811         /* >> chng 05 jul 13, TE, 
01812          * this process populates v=4,no J information assume into J=0 -> H2s not H2g */
01813                 int in[]={ipMH,ipMH2p},out[]={ipMHp,ipMH2s};
01814                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01815         }
01816         r = r->next;
01817         rindex++;
01818         r->rk = hmi.bh2h2p;
01819 
01821         /* this rate couples H2+ and H3+, and tends to destabilize the matrix in both highly
01822          * ionized and fully molecular conditions.  Setting this to zero had no effect - the th85
01823          * predictions were identical.  
01824          *
01825          */
01826         /* H + H3+ => H2 + H2+ */
01828         /* >> chng 05 aug 05, NPA comment.  This rate is not in UMIST.  Therefore 
01829               it is turned off for the Leiden comparison */
01830 
01831         hmi.h3ph2p = HMRATE(2.08e-9,0.,1.88e4)*co.lgUMISTrates;
01832 
01833         if(r->next == NULL) 
01834         {
01835                 int in[]={ipMH,ipMH3p},out[]={ipMH2g,ipMH2p};
01836                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01837         }
01838         r = r->next;
01839         rindex++;
01840         r->rk = hmi.h3ph2p;
01841 
01842         /* >>chng 03 feb 7 */
01843                 /* H3+ + H- => H2 + H + H
01844          * equation (50) from
01845          * >>refer      H-      k       Stancil, P.C, & Lepp, S, & Dalgarno, A. 1998,ApJ, 509, 1-10
01846          * h3phmh2hh = 2.3e-7f*pow(phycon.te/300.0, -0.5) */
01847         /* >> chng 05 aug 05, NPA comment.  This rate is not in UMIST.  Therefore it 
01848            is turned off for the Leiden comparison */
01850         hmi.h3phmh2hh = 2.3e-7f*pow(phycon.te/300 , -0.5)*co.lgUMISTrates;
01851         if(r->next == NULL) 
01852         {
01853                 int in[]={ipMH3p,ipMHm},out[]={ipMH2g,ipMH,ipMH};
01854                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01855         }
01856         r = r->next;
01857         rindex++;
01858         r->rk = hmi.h3phmh2hh;
01859 
01860         /* H2 + H3+ => H2 + H2+ + H */
01861         /* >> chng 05 aug 05, NPA comment.  This rate is not in UMIST.  Therefore it 
01862         is turned off for the Leiden comparison */
01864         hmi.h3petc = HMRATE(3.41e-11,0.5,7.16e4)*co.lgUMISTrates;
01865 
01866         if(r->next == NULL) 
01867         {
01868                 int in[]={ipMH2g,ipMH3p},out[]={ipMH2g,ipMH2p,ipMH};
01869                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01870         }
01871         r = r->next;
01872         rindex++;
01873         r->rk = hmi.h3petc;
01874 
01875         /* H2 + H3+ => H2 + H+ + H2 */
01876         /* >> chng 05 aug 05, NPA comment.  This rate is not in UMIST.  Therefore it 
01877         is turned off for the Leiden comparison */
01879         hmi.h32h2 = HMRATE(3.41e-11,0.5,5.04e4)*co.lgUMISTrates;
01880 
01881         if(r->next == NULL) {
01882                 int in[]={ipMH2g,ipMH3p},out[]={ipMHp,ipMH2g,ipMH2g};
01883                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01884         }
01885         r = r->next;
01886         rindex++;
01887         r->rk = hmi.h32h2;
01888 
01889         /* e + H3+ => H2 + H */
01890         /* e + H3+ => 3H was supposed to be included in this rate, 
01891          * and stoichiometric factor 2* on sink rate seemed wrong */
01892         /* >>chng 03 feb 10, increase rate by factor of 13.6 to agree with
01893          * >>refer      H3+     DR      McCall, B.J., et al. 2003, Nature, in press (astro-ph 0302106)*/
01894         /* >>chng 03 feb 13, extra 0.2 since 20% of these go to H2 + H, Stancil private comm */
01895         /* >>chng 04 apr 22 , update the next two rates to match that of:
01896            >>refer      H3+     k       Stancil, P. C., Lepp, S., and Dalgarno, A 509, 1-10;
01897            *>>refercon  Table 1, reactions #48 and #49 */
01900         /* >>chng 06 jan 23, Stancil's rate is rescaled by 2.25 to match McCall's rate, GS*/
01901         /* >>chng 07 jan 05, as per GS discussions, USE_MCCALL was commented out,
01902          * turn back on.  Should not have been commented out */
01903 #       define USE_MCCALL
01904 #       ifdef USE_MCCALL
01905 #       define  FACTOR  2.25
01906 #       else
01907 #       define  FACTOR  1.0
01908 #       endif
01909         hmi.eh3_h2h = HMRATE(4.00e-8/FACTOR,-0.5,0.)*dense.eden;
01910 
01911         /* >> chng 05 aug 05, NPA comment.  Rate we use and UMIST uses is different.  If UMIST 
01912            hack is on then we use UMIST, otherwise we use our rate   */
01913         if(!co.lgUMISTrates)
01914                 hmi.eh3_h2h = HMRATE(2.5e-8,-0.3,0.)*dense.eden;
01915 
01916 
01917         if(r->next == NULL) {
01918                 int in[]={ipMH3p},out[]={ipMH,ipMH2g};
01919                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01920         }
01921         r = r->next;
01922         rindex++;
01923         r->rk = hmi.eh3_h2h;
01924 
01925         /* e + H3+ => 3H */
01926         /* >>chng 06 jan 23, Stancil's rate is rescaled by 2.25 to match McCall's rate, GS*/
01927         eh3p_3h = HMRATE(1.6e-7/FACTOR,-0.5,0.)*dense.eden;
01928 #       undef FACTOR
01929 #       ifdef USE_MCCALL
01930 #       undef USE_MCCALL
01931 #       endif
01932 
01933                 /* >> chng 05 aug 05, NPA comment.  Rate we use and UMIST uses is different.  If UMIST 
01934            hack is on then we use UMIST, otherwise we use our rate   */
01935         if(!co.lgUMISTrates)
01936                 eh3p_3h = HMRATE(7.5e-8,-0.3,0.)*dense.eden;
01937 
01938         /* >>chng 03 feb 10, increase rate by factor of 13.6 to agree with
01939          * >>refer      H3+     DR      McCall, B.J., et al. 2003, Nature, in press (astro-ph 0302106)*/
01940         /* >>chng 03 feb 13, extra 0.8 since 80% of these go to 3H, Stancil private comm */
01941 
01942         if(r->next == NULL) {
01943                 int in[]={ipMH3p},out[]={ipMH,ipMH,ipMH};
01944                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
01945         }
01946         r = r->next;
01947         rindex++;
01948         r->rk = eh3p_3h;
01949 
01950         if( (trace.lgTrace && trace.lgTr_H2_Mole) )
01951         {
01952                 if( hmi.H2_rate_destroy > SMALLFLOAT )
01953                 {
01954                         fprintf( ioQQQ, 
01955                           " H2 destroy rate=%.2e DIS;%.3f bat;%.3f h2dis;%.3f hmi.H2_photoionize_rate;%.3f h2h2p;%.3f E-h;%.3f hmi.h2hph3p;%.3f sec;%.3f\n", 
01956                           hmi.H2_rate_destroy, 
01957                           hmi.H2_Solomon_dissoc_rate_used_H2g / hmi.H2_rate_destroy, 
01958                           hmi.assoc_detach_backwards_grnd / hmi.H2_rate_destroy, 
01959                           hmi.rh2dis*dense.xIonDense[ipHYDROGEN][0] / hmi.H2_rate_destroy, 
01960                           hmi.H2_photoionize_rate / hmi.H2_rate_destroy, 
01961                           hmi.rh2h2p*dense.xIonDense[ipHYDROGEN][1] / hmi.H2_rate_destroy, 
01962                           hmi.eh2hh /hmi.H2_rate_destroy, 
01963                           hmi.h2hph3p / hmi.H2_rate_destroy ,
01964                           secondaries.csupra[ipHYDROGEN][0]*2.02 / hmi.H2_rate_destroy
01965                           );
01966                 }
01967                 else
01968                 {
01969                         fprintf( ioQQQ, " Destroy H2: rate=0\n" );
01970                 }
01971         }
01972 
01973         /*------------------------------------------------------------------- */
01974 
01975         /* h2plus H2+ balance equations */
01976 
01978         /* >>refer      H2+     chemistry       Dalgarno, A., & Lepp, S., 1987, in Astrochemistry, eds. 
01979          * >>refercon   M.S. Vardya & S.P. Tarafar, Reidel, Dordrecht, p 109 */
01980         /* rate = 5e-7 * sqrt(100. / phycon.te); */
01981 
01983         /* >>refer      H2+     chemistry       Stancil, P.C., 1994, ApJ, 430, 360 */
01984         /* cross section is log10( cs_25) = -1.6547717e6 + 1.8660333e5 ln(nu) - 7.8986431e3*ln(nu)^2
01985          * 148.73693 * ln(nu)^3 - 1.0513032*ln(nu)^4 */
01986 
01987         /* make H2+ from Ho
01988          * H+  + H  =>  H2+ + HNU
01989          * approximation was from Kurucz thesis, not meant for hot gas 
01990          * >>chng 02 nov 7 rjrw, stoichiometric factor */
01991         radath = MAX2(0.,2.325*MIN2(5000.,phycon.te)-1375.)*1e-20;
01992 
01993         /* >> chng 05 aug 05, NPA comment.  Rate we use and UMIST uses is different.  If UMIST 
01994            hack is on then we use UMIST, otherwise we use our rate   */
01995 
01996         if( !co.lgUMISTrates)
01997                 radath = HMRATE(5.3e-19,1.85,0);
01998 
01999         if( r->next == NULL) {
02000                 int in[]={ipMH,ipMHp},out[]={ipMH2p};
02001                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02002         }
02003         r = r->next;
02004         /* Printf("O: %ld %g %g\n",rindex,radath*dense.xIonDense[ipHYDROGEN][1]*dense.xIonDense[ipHYDROGEN][0],
02005                  radath*dense.xIonDense[ipHYDROGEN][1]); */
02006         rindex++;
02007         r->rk = radath;
02008 
02009         /* H2+  +  H+  => H + H+ + H+; Janev et al. 3.2.6 */
02010         /* >>chng 02 nov 7 rjrw, stoichiometric factor */
02011 
02012         /* >> chng 05 aug 05, NPA comment.  This reaction is not in UMIST, so turn if off 
02013            for the comparison */
02014 
02015         h2pion = 2.4e-27*POW3(phycon.te)*co.lgUMISTrates;
02016 
02017         if(r->next == NULL) {
02018                 int in[]={ipMH2p},out[]={ipMH,ipMHp},ratesp[]={ipMHp,ipMH2p};
02019                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
02020         }
02021         r = r->next;
02022         rindex++;
02023         r->rk = h2pion;
02024 
02025         /* H2+  +  E  => H + H+ + e-; Janev et al. */
02026         /* >>chng 02 nov 7 rjrw, stoichiometric factor */
02027 
02028         /* >> chng 05 aug 05, NPA comment.  This reaction is not in UMIST, so turn if off 
02029          for the comparison */
02030         h2pcin = 2e-7*sexp(30720./phycon.te)*dense.eden*co.lgUMISTrates;
02031 
02032         if(r->next == NULL) {
02033                 int in[]={ipMH2p},out[]={ipMH,ipMHp};
02034                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02035         }
02036         r = r->next;
02037         rindex++;
02038         r->rk = h2pcin;
02039 
02040         /* >>chng 04 jul 06 -- NPA, include H ionization/recombination due
02041         to O-H charge transfer in the molecular solver.  */
02042         /* O + H+ => H + O+ */
02043         if( iteration==1 && conv.lgSearch )
02044         {
02045                 /* during search for first iteration do not do ct */
02046                 oatomic = 0.;
02047                 oion = 0.; 
02048         }
02049         else
02050         {
02051                 /* same zone and iteration, take mean of old and new abund */
02052 #               define OLD_FRAC 0.0
02053                 oatomic = oatomic*OLD_FRAC + dense.xIonDense[ipOXYGEN][0]*(1.-OLD_FRAC); 
02054                 oion = oion*OLD_FRAC + dense.xIonDense[ipOXYGEN][1]*(1.-OLD_FRAC); 
02055                 /* ionbal.lgHO_ct_chem is normally 1 set to 0 with command
02056                  * set HO charge transfer ionization, in which case we do H O
02057                  * charge transfer in ionization solver */
02058                 oatomic *= ionbal.lgHO_ct_chem;
02059                 oion *= ionbal.lgHO_ct_chem;
02060         }
02061         /*      oatomic = dense.xIonDense[ipOXYGEN][0];
02062                 oion = dense.xIonDense[ipOXYGEN][1]; */
02063 
02064         if(r->next == NULL) {
02065                 int in[]={ipMHp},out[]={ipMH};
02066                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02067         }
02068 
02069         r = r->next;
02070         rindex++;
02071         /*r->rk = atmdat.HCharExcIonOf[ipOXYGEN][0]*dense.xIonDense[ipOXYGEN][0]; */
02072         r->rk = atmdat.HCharExcIonOf[ipOXYGEN][0]*oatomic; 
02073 
02074         /* O+ + H => H+ + O */
02075         if(r->next == NULL) {
02076                 int in[]={ipMH},out[]={ipMHp};
02077                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02078         }
02079         r = r->next;
02080         rindex++;
02081         /*r->rk = atmdat.HCharExcRecTo[ipOXYGEN][0]*dense.xIonDense[ipOXYGEN][1]; */
02082         r->rk = atmdat.HCharExcRecTo[ipOXYGEN][0]*oion; 
02083 
02084         /* >>chng 03 aug 22 */
02085         /* H2+ + e=> H + H; 
02086          * equation (6,table 4) from
02087          * >>refer      H2      l       Maloney et.al, 1996,ApJ, 466, 561
02088          * h2pehh = 2.8e-8f*pow(phycon.te/1000., -0.37) */
02089         /* >>chng 03 sep 01, rm the pow function */
02090         /*h2pehh = 2.8e-8f*pow(phycon.te/1000., -0.37);*/
02091         h2pehh = 2.8e-8*12.882/(phycon.te30*phycon.te07)*dense.eden;
02092 
02093         /* >> chng 05 aug 05, NPA comment.  Rate we use and UMIST uses is different.  
02094            If UMIST hack is on then we use UMIST, otherwise we use our rate */
02095 
02096         if(!co.lgUMISTrates)
02097                 h2pehh = HMRATE(1.6e-8,-0.43,0);
02098 
02099         if(r->next == NULL) {
02100                 int in[]={ipMH2p},out[]={ipMH,ipMH};
02101                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02102         }
02103         r = r->next;
02104         rindex++;
02105         r->rk =h2pehh;
02106 
02107         /* back reaction, H + H+ + e => h2+ + e */
02108         /* >>chng 05 aug 02, rm eden umist terms since now in above 
02109          * note on units - this will go into rk as a two-body reaction,
02110          * so we need to multiply by an extra eden before feeding into the matrix
02111          * this is why the eden is left in the h2pcin from above, the 
02112          * real back rate coefficient for a three body process would be this
02113          * divided by eden */
02114         b2pcin = h2pcin*hmi.rel_pop_LTE_H2p;
02115         /* this is the hot reaction at high densities */
02116 
02117         if(r->next == NULL) {
02118                 int in[]={ipMH,ipMHp},out[]={ipMH2p};
02119                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02120         }
02121         r = r->next;
02122         rindex++;
02123         r->rk = b2pcin;
02124 
02125         /* H2+  +  HNU  =>  H+  + H */
02126 
02127         if(r->next == NULL) {
02128                 int in[]={ipMH2p},out[]={ipMH,ipMHp};
02129                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02130         }
02131         r = r->next;
02132         rindex++;
02133         r->rk = gamtwo;
02134 
02135         /*>>KEYWORD     H2+ photoionization
02136          * photoionization by hard photons, crossection =H0 in high-energy limit 
02137          * H2+ + hnu -> H + H+ 
02138          * one electron system */
02139         if(r->next == NULL) {
02140                 int in[]={ipMH2p},out[]={ipMH,ipMHp};
02141                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02142         }
02143         r = r->next;
02144         rindex++;
02145 
02146         /* >> chng 05 aug 05, NPA comment.  This reaction is not in UMIST, for the case 
02147          * of hard photons.  Turn if off for the comparison. 
02148          * >>chng 05 nov 27, factor of two had been in front of H photo rate 
02149          * by analogy with high-energy limit for H2 - but this is a one-electron
02150          * system so not appropriate 
02151          * note that iso.gamnc include bound Compton ionization */
02152         /*r->rk = 2.*iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s]*co.lgUMISTrates;*/
02153         r->rk = iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s]*co.lgUMISTrates;
02154 
02155         /* H2 + H2+ => H + H3+ */
02158         hmi.h2ph3p = 1.40e-9*(1. - sexp(9940./phycon.te));
02159 
02160         if(!co.lgUMISTrates)
02161                 hmi.h2ph3p = 2.08e-9;
02162 
02163         if(r->next == NULL) {
02164                 int in[]={ipMH2g,ipMH2p},out[]={ipMH,ipMH3p};
02165                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02166         }
02167         r = r->next;
02168         rindex++;
02169         r->rk = hmi.h2ph3p;
02170 
02171         /* destroy H2+ via H2+ + H2 => H + H+ + H2 */
02173         /* >> chng 05 aug 05, NPA comment.  Rate we use and UMIST uses is different.  
02174            If UMIST hack is on then we use UMIST, otherwise we use our rate */
02175 
02176         h2phhp = 2.41e-12*phycon.sqrte*sexp(30720./phycon.te)*co.lgUMISTrates;
02177 
02178         if(r->next == NULL) {
02179                 int in[]={ipMH2g,ipMH2p},out[]={ipMH,ipMHp,ipMH2g};
02180                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02181         }
02182         r = r->next;
02183         rindex++;
02184         r->rk = h2phhp;
02185 
02186         /*------------------------------------------------------------------ */
02187 
02188         /* H3+ balance equations*/
02189 
02190         /* photoionization by hard photons, crossection =2*HI (wild guess)
02191          * -- rjrw: where do they go??? 
02192          * -- H3+ + hv => H2+ + H+ + e, best guess (P. Stancil, priv comm) */
02193 
02194         if(r->next == NULL) {
02195                 int in[]={ipMH3p},out[]={ipMH2p,ipMHp};
02196                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02197         }
02198         r = r->next;
02199         rindex++;
02200 
02201         /* >> chng 05 aug 05, NPA comment.  This reaction is not in UMIST, for the case 
02202            of hard photons.  Turn if off for the comparison. */
02203         r->rk = 2.*iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s]*co.lgUMISTrates;
02204 
02205         /*------------------------------------------------------------------ */
02206 
02207         /* vib excited H2, called H2* balance equations, these closely follow
02208          * >>refer      h2      fits    Tielens, A.G.G.M., & Hollenbach, D., 1985a, ApJ 291, 722 */
02209         /* population of vib-excited H2, from discussion on pp 736-737 of TH85 */
02210 
02211         /* deexcitation rate from upper level, H2* => H2 */
02212 
02213         /* deexc_hneut is H2* + H0 -> H2g + H 
02214          * deexc_htwo  is H2* + H2 -> H2g + H2 */
02215         Boltz_fac_H2_H2star = 1.*sexp( 30172./phycon.te);
02216         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02217         {
02218                 deexc_htwo = hmi.Average_collH2_deexcit;
02219                 deexc_hneut = hmi.Average_collH_deexcit;
02220         }
02221         else
02222         {
02223                 deexc_htwo = (1.4e-12*phycon.sqrte * sexp( 18100./(phycon.te + 1200.) ))/6.;
02224                 deexc_hneut =  (1e-12*phycon.sqrte * sexp(1000./phycon.te ))/6.;
02225         }
02226         /* total H2* -> H2g rate, s-1 */
02227         H2star_deexcit = hmi.H2_total*deexc_htwo + hmi.Hmolec[ipMH] * deexc_hneut;
02228 
02229         /* H2g -> H2s */
02230         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02231         {
02232                 H2star_excit = hmi.Average_collH2_excit *hmi.H2_total + 
02233                         hmi.Average_collH_excit*hmi.Hmolec[ipMH];
02234         }
02235         else
02236         {
02237                 H2star_excit = Boltz_fac_H2_H2star * H2star_deexcit;
02238         }
02239 
02240         /* depopulate H2_star, 2e-7 is spontaneous deexcitation rate,
02241          * which also appears in lines where intensity of vib lines is entered into line stack */
02242         /* H2* + H2g -> H2g + H2g */
02243 
02244         if(r->next == NULL) {
02245                 int in[]={ipMH2s},out[]={ipMH2g};
02246                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02247         }
02248         r = r->next;
02249         rindex++;
02250 
02251         /* >>chng 05 jul 11, TE, rename to use in punch file*/
02252         /* >>chng 05 jul 9, GS, use average A calculated from Big H2 */
02253         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02254         {
02255                 hmi.h2s_sp_decay = hmi.Average_A;
02256         }
02257         else
02258         {
02259                 hmi.h2s_sp_decay = 2e-7;
02260         }
02261         r->rk = hmi.h2s_sp_decay;
02262 
02263 
02264         if(r->next == NULL) {
02265                 int in[]={ipMH2s},out[]={ipMH2g},ratesp[]={ipMH2s,ipMH2g};
02266                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
02267         }
02268         r = r->next;
02269         rindex++;
02270         r->rk = deexc_htwo;
02271 
02272         if(r->next == NULL) {
02273                 int in[]={ipMH2s},out[]={ipMH2g},ratesp[]={ipMH2s,ipMH};
02274                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
02275         }
02276         r = r->next;
02277         rindex++;
02278         r->rk = deexc_hneut;
02279 
02280         /* collisional excitation of vib from ground, 
02281          * H2g + H2g -> H2* + H2g, so H2g acts as catalyst
02282          * stat weight of ground 1, excit 6, as per TH discussion
02283          * this must normally be zero */
02284         /* H2 producing H2_star */
02285         /* >>chng 03 sep 11, had been 6, changed to 1 */
02286         /*Boltz_fac_H2_H2star = 1.*sexp( hmi.H2_BigH2_H2s_av * T1CM / phycon.te);*/
02287         /* total excitation rate to H2*, s-1, NB - this is also used in the cooling - heating
02288          * rate below */
02289         /*H2star_excit = Boltz_fac_H2_H2star * H2star_deexcit;*/
02290 
02291         if(r->next == NULL) {
02292                 int in[]={ipMH2g},out[]={ipMH2s},ratesp[]={ipMH2g,ipMH2g};
02293                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
02294         }
02295         r = r->next;
02296         rindex++;
02297         /* >>chng 05 jul 10, GS, use average collisional rate calculated from Big H2 */
02298         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02299         {
02300                 r->rk = hmi.Average_collH2_excit;
02301         }
02302         else
02303         {
02304                 r->rk = deexc_htwo*Boltz_fac_H2_H2star;
02305         }
02306 
02307         if(r->next == NULL) {
02308                 int in[]={ipMH2g},out[]={ipMH2s},ratesp[]={ipMH,ipMH2g};
02309                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
02310         }
02311         r = r->next;
02312         rindex++;
02313         /* >>chng 05 jul 10, GS, use average collisional rate calculated from Big H2 */
02314         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02315         {
02316                 r->rk = hmi.Average_collH_excit;
02317         }
02318         else
02319         {
02320                 r->rk = deexc_hneut*Boltz_fac_H2_H2star;
02321         }
02322 
02323         /* >>chng 03 aug 28 */
02324         /* H2* + H => H + H + H
02325          * equation  from table 9
02326          * >>refer      H2*     k       Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722*/
02327 
02328         /*      hmi.h2sh = HMRATE(9.8e-12,0.5,2.7e4);*/
02329         /* >>chng 05 jul 19, TE, update to UMIST rate */
02330         /* >>chng 05 mar 18, TE, used in new punch H2 destruction file*/
02331         hmi.h2sh = HMRATE(4.67e-7,-1.,5.5e4);
02332 
02333         if(r->next == NULL) {
02334                 int in[]={ipMH2s,ipMH},out[]={ipMH,ipMH,ipMH};
02335                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02336         }
02337         r = r->next;
02338         rindex++;
02339         r->rk = hmi.h2sh;
02340 
02341 
02342         /*  The following is a general prescription on how to generate chemical rates for H2* from H2.  It
02343             is an e-mail from Phillip Stancil received 05 aug 04.  
02344                 The topic of the e-mail involved the reaction H2 + H2 => H2 + 2H and 
02345                 getting reaction rates for H2* + H2 -> H2 + 2H and H2* + H2* -> H2/H2* + 2H from the ground state
02346                 reaction rate, which has a strong temperature dependence.  E-mail inserted by TE, NPA on 05 aug 05 */
02347 
02348         /***********************************************************************************************
02349                 Consider that both H2's are in arbitrary v,j levels and after the collision
02350                 they are in arbitrary levels with the constraint that at least on of  
02351                 the H2's been dissociated or both are dissociated, but both cannot be excited to 
02352                 bound levels (better to use actual data for those cases).
02353 
02354                 H2(vj) + H2(v'j') -> H2(v''j'') + H2(v'''j''')
02355 
02356 
02357                 Then an approximate rate coefficient would be
02358 
02359                 k_vj,v'j'->v''j'',v'''j''' = 10^-11 * exp(-beta/kT)
02360 
02361                 where beta = (E_vj - E_v''j'') + (E_v'j' - E_v'''j'''),
02362 
02363                 but if beta<0, set beta=0. So that the rate never becomes greater than ~10^-11 cm^3/s.
02364                 Here the energies are dissociation energies (i.e., 4.478 eV for vj=00  and 0 for a
02365                 dissociation state).
02366 
02367                 So, looking at limits, if vj=v'j'=v''j''=00 and v'''j'''=dissociation  
02368                 state (15,0, say), then we get
02369 
02370                 10^-11*exp(-4.478 eV/kT)
02371 
02372                 [ H2(0,0) + H2(0,0) -> H2(0,0) + 2H  ]
02373 
02374                 if vj=v'j'=00 and v''j''=v'''j'''=dissociation, i.e. 4H is the product, then we get
02375 
02376                 10^-11*exp(-2*4.478/kT)
02377 
02378                 [ H2(0,0) + H2(0,0) -> 2H + 2H]
02379 
02380 
02381                 if vj=v'j'=00, v''j'' is an excited bound state, and v'''j''' is  
02382                 dissociation, the number in parentheses is between 4.478 and 2*4.478 
02383                 (i.e., dissociation plus excitation)
02384 
02385                 [ H2(0,0) + H2(0,0) -> H2*(v,j) + 2H ]
02386 
02387                 However, say we have a case where both H2 in the H2* (1.88 eV) level.
02388 
02389                 H2* + H2* -> H2(0,0) + 2H
02390 
02391                 then beta = (1.88-4.478)+(1.88-0)=-0.718 eV, so take beta=0 to give k=10^-11.
02392 
02393                 This argument considers only asymptotic energies.
02394                 So, it neglects selection rules (which would be needed if you considered state-to-state
02395                 reactions, but not the two-level approximation) and any effect rovibrational overlaps.
02396 
02397                 Phillip Stancil
02398 
02399         **************************************************************************************/
02400 
02401 
02402         /* >>chng 03 aug 28 */
02403         /* H2* + H2 => H2 + H + H
02404          * equation from table 9
02405          * >>refer      H2*     k       Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722-746*/
02406 
02407         /* >>chng 05 jul 19, TE, update to UMIST rate */
02408         /* >>chng 05 mar 18, TE, used in new punch H2 destruction file*/
02409         /*      hmi.h2sh2g = HMRATE(9.8e-12,0.5,2.7e4);*/
02410         /* hmi.h2sh2g = HMRATE(1e-8,0.,8.41e4); */
02411         /* >>chng 05 aug 05, TE, update to the scheme of Phillip Stancil */
02412         hmi.h2sh2g = HMRATE(1e-11,0.,2.18e4);
02413         if(r->next == NULL) {
02414                 int in[]={ipMH2s,ipMH2g},out[]={ipMH2g,ipMH,ipMH};
02415                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02416         }
02417         r = r->next;
02418         rindex++;
02419         /* >>chng 05 jul 20, GS, TE */
02420         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02421         {
02422                 hmi.h2sh2g = hmi.Average_collH2s_dissoc; 
02423         }
02424 
02425         r->rk = hmi.h2sh2g;
02426 
02427         /* >>chng 03 aug 28 */
02428         /* H2* + H2* => H2 + H + H
02429          * equation from table 9
02430          * >>refer      H2*     k       Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722-746*/
02431         /* >>chng 05 mar 18, TE, used in new punch H2 destruction file*/
02432         /*      hmi.h2sh2sh2g2h = HMRATE(9.8e-12,0.5,0.);*/
02433         /* >>chng 05 jul 19, TE, update to UMIST rate */
02434         /* hmi.h2sh2sh2g2h = HMRATE(1e-8,0.,0.); */
02435         /* >>chng 05 aug 05, TE, update to the scheme of Phillip Stancil */
02436         hmi.h2sh2sh2g2h = HMRATE(1e-11,0.,0.);
02437         if(r->next == NULL) {
02438                 int in[]={ipMH2s,ipMH2s},out[]={ipMH2g,ipMH,ipMH};
02439                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02440         }
02441         r = r->next;
02442         rindex++;
02443         /* >>chng 05 jul 20, GS, TE */
02444         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02445         {
02446                 hmi.h2sh2sh2g2h = hmi.Average_collH2s_dissoc;
02447         }
02448 
02449         r->rk = hmi.h2sh2sh2g2h;
02450 
02451 
02452         /* >>chng 05 jul 21, TE, GS */
02453         /* H2* + H2* => H2* + H + H */
02454         /* hmi.h2sh2sh2s2h = HMRATE(1e-8,0.,0.);*/
02455         /* >>chng 05 aug 05, TE, update to the scheme of Phillip Stancil */
02456         hmi.h2sh2sh2s2h = HMRATE(1e-11,0.,2.18e4);
02457         if(r->next == NULL) {
02458                 int in[]={ipMH2s,ipMH2s},out[]={ipMH2s,ipMH,ipMH};
02459                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02460         }
02461         r = r->next;
02462         rindex++;
02463         if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
02464         {
02465                 hmi.h2sh2sh2s2h = hmi.Average_collH2s_dissoc;
02466         }
02467 
02468         r->rk = hmi.h2sh2sh2s2h;
02469 
02470 
02471         /* >>03 may 22, hmi.H2_Solomon_dissoc_rate_used is now rate electronic excited states
02472          * decay into X continuum, not the rate that elec excited states are excited.
02473          * assuming that 10% of excitations lead to ionization, this rate, for relax
02474          * into ro-vib excited states, is 10x the Solomon rate */
02475         /* assume that 0.9 of H2 dissociations lead to H2_star,
02476          * H2 + 0.9*hmi.H2_Solomon_dissoc_rate_used => h2_star */
02477         if(r->next == NULL) {
02478                 int in[]={ipMH2g},out[]={ipMH2s};
02479                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02480         }
02481         r = r->next;
02482         rindex++;
02483         /* >>chng 03 may 22, see comment just above */
02484         /*r->rk = 0.9*hmi.H2_Solomon_dissoc_rate_used;
02485         r->rk = 10.*hmi.H2_Solomon_dissoc_rate_used;*/
02486         /* >>chng 03 sep 11, use real evaluated rate */
02487         r->rk = hmi.H2_H2g_to_H2s_rate_used;
02488 
02489         /* rate of photodissoc of vib-excit H2, A12 of TH85 */
02490         if(r->next == NULL) {
02491                 int in[]={ipMH2s},out[]={ipMH,ipMH};
02492                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02493         }
02494         r = r->next;
02495         rindex++;
02496         r->rk = hmi.H2_photodissoc_used_H2s;
02497 
02498 
02499         /* >>chng 05 mar 24, TE, include continuum photodissociation from H2g*/
02500         if(r->next == NULL) {
02501                 int in[]={ipMH2g},out[]={ipMH,ipMH};
02502                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02503         }
02504         r = r->next;
02505         rindex++;
02506         r->rk = hmi.H2_photodissoc_used_H2g;
02507 
02508         /* >>chng 05 oct 04, TE, rename and include in punch H2 destruction
02509          * >>chng 05 sept 30, GS, include collisional dissociation by electron, H2g + e = 2H + e*/
02510         if(r->next == NULL) {
02511                 int in[]={ipMH2g},out[]={ipMH,ipMH};
02512                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02513         }
02514         r = r->next;
02515         rindex++;
02516         hmi.h2ge2h = 1e-14*sexp(4.478*EVDEGK/phycon.te)*dense.eden;
02517         r->rk = hmi.h2ge2h;
02518 
02519         /* >>chng 05 oct 04, TE, rename and include in punch H2 destruction
02520          * >>chng 05 sept 30, GS, include collisional dissociation by electron, H2s + e = 2H + e*/      
02521         if(r->next == NULL) {
02522                 int in[]={ipMH2s},out[]={ipMH,ipMH};
02523                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02524         }
02525         r = r->next;
02526         rindex++;
02527         hmi.h2se2h = 1e-14*sexp(1.978*EVDEGK/phycon.te)*dense.eden;
02528         r->rk = hmi.h2se2h;
02529 
02530         /*---------------------------------------------------------------- */
02531 
02532         /* He H+ formation rates taken from Flower+Roueff, Black */
02533 
02534         /* He+ + H => HeH+
02535          * radiative association from 
02536          * >>refer      heh+    rate    Zygelman, B., and Dalgarno, A. 1990, ApJ 365, 239 */
02537 
02538         if(r->next == NULL) {
02539                 int in[]={ipMH},out[]={ipMHeHp};
02540                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02541         }
02542         r = r->next;
02543         rindex++;
02544         r->rk = 1e-15*dense.xIonDense[ipHELIUM][1];
02545 
02546         /* >>chng 03 sep 30 */
02547         /* back reaction of He+ + H=> He + H+   */
02548         /* He + H+=> He+ + H;   
02549          * bhephhphe = hephhphe*dense.xIonDense[ipHELIUM][1]*dense.xIonDense[ipHYDROGEN][0]/dense.xIonDense[ipHYDROGEN][1];*/
02550         /*bhephhphe = hephhphe*dense.xIonDense[ipHELIUM][1]*dense.xIonDense[ipHYDROGEN][0]/SDIV(dense.xIonDense[ipHYDROGEN][1]);
02551         if(r->next == NULL) {
02552                 int in[]={ipMHp},out[]={ipMH};
02553                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02554         }
02555         r = r->next;
02556         rindex++;
02557         r->rk = bhephhphe;*/
02558 
02559         /* >>chng 03 sep 30 */
02560         /* He + H-=> He + H + e; 
02561          * equation (table 5) from
02562          * >>refer      H-      k       Paolo Lenzuni, David F. Chernoff, Edwin E. Salpeter, 1991, ApJS, 76, 759L  
02563          * hehmeheh = 4.1e-17*pow(phycon.te,2)*sexp(19870/phycon.te)*dense.xIonDense[ipHELIUM][0];*/
02564         hehmeheh = 4.1e-17*phycon.tesqrd*sexp(19870/phycon.te)*dense.xIonDense[ipHELIUM][0];
02565         if(r->next == NULL) {
02566                 int in[]={ipMHm},out[]={ipMH};
02567                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02568         }
02569         r = r->next;
02570         rindex++;
02571         r->rk =hehmeheh;
02572 
02573         /* >>chng 03 sep 30 */
02574         /* He+ + H2=> He + H+ + H; 
02575          * equation (table 6) from
02576          * >>refer      H2      dissoc  Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722  
02577          * heph2hpheh = 1.5e-13*dense.xIonDense[ipHELIUM][1];*/
02578         /*hmi.rheph2hpheh = 1.5e-13f;*/
02579         /* >>chng 04 jun 10 */
02580         /* use the rate for this reaction as defined in UMIST */
02581 
02582         /* >> chng 05 aug 05, NPA comment.  This reaction can be an important He+ destruction term 
02583            deep in molecular clouds.  This reaction is only slightly different from TH85, and has a temperature dependence.
02584            Therefore this rate was switched to UMIST*/
02586         hmi.rheph2hpheh = (realnum)HMRATE(3.7e-14, 0., 35);
02587         if(r->next == NULL) {
02588                 int in[]={ipMH2g},out[]={ipMHp,ipMH};
02589                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02590         }
02591         r = r->next;
02592         rindex++;
02593         r->rk = hmi.rheph2hpheh*dense.xIonDense[ipHELIUM][1];
02594 
02595         /* >>chng 04 jun 10 -- This reaction was not originally included.  It is in
02596          * the UMIST database and seems to be an important He+ destruction mechanism */
02597         /* He+ + H2=> He + H2+  
02598          * use the rate for this reaction as defined in UMIST */
02600         hmi.heph2heh2p = (realnum)HMRATE(7.2e-15, 0., 0);
02601         if(r->next == NULL) {
02602                 int in[]={ipMH2g},out[]={ipMH2p};
02603                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02604         }
02605         r = r->next;
02606         rindex++;
02607         r->rk = hmi.heph2heh2p*dense.xIonDense[ipHELIUM][1];
02608 
02609         /* He + H+ => HeH+ */   
02610         if(r->next == NULL) {
02611                 int in[]={ipMHp},out[]={ipMHeHp};
02612                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02613         }
02614         r = r->next;
02615         rindex++;
02616         r->rk = 1e-20*dense.xIonDense[ipHELIUM][0];
02617 
02618         /* H2+ + HE => HEH+ + H0 */
02619         if(r->next == NULL) {
02620                 int in[]={ipMH2p},out[]={ipMH,ipMHeHp};
02621                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02622         }
02623         r = r->next;
02624         rindex++;
02625 
02626         /* >> chng 05 aug 05, NPA comment.  Turn off HeH+ for the Leiden comparison.  Can't
02627            turn if off completely or else the matrix is unstable.  Just make sure that 
02628            the abundance never affects the other molecules. */
02629 
02630         r->rk = 3e-10*exp(-6717./phycon.te)*dense.xIonDense[ipHELIUM][0]*co.lgUMISTrates;
02631 
02632         /* photodissociation through 1.6->2.3 continuum */
02633 
02634         /* why is this in a look instead of GammaK?
02635          * to fix must set opacities into stack */
02636         gamheh = 0.;
02637         limit = MIN2(hmi.iheh2-1 , rfield.nflux );
02638         for( i=hmi.iheh1-1; i < limit; i++ )
02639         {
02640                 gamheh += rfield.flux[i] + rfield.ConInterOut[i]+ rfield.outlin[i] + rfield.outlin_noplot[i];
02641         }
02642         gamheh *= 4e-18;
02643 
02644         /* hard radiation */
02645         gamheh += 3.*iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s];
02646 
02647         /* recombination, HeH+  +  e => He + H */
02648         gamheh += dense.eden*1e-9;
02649 
02650         if(r->next == NULL) {
02651                 int in[]={ipMHeHp},out[]={ipMH};
02652                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02653         }
02654         r = r->next;
02655         rindex++;
02656         r->rk = gamheh;
02657 
02658         /* HeH+  +  H => H2+  + He */
02659         if(r->next == NULL) {
02660                 int in[]={ipMH,ipMHeHp},out[]={ipMH2p};
02661                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02662         }
02663         r = r->next;
02664         rindex++;
02665 
02666         /* >> chng 05 aug 05, NPA comment.  Turn off HeH+ for the Leiden comparison.  Can't
02667            turn if off completely or else the matrix is unstable.  Just make sure that 
02668            the abundance never affects the other molecules. */
02669 
02670         r->rk = 1e-10*co.lgUMISTrates;
02671 
02672         /* >>chng 03 sep 30 */
02673         /* HeH+  +  H2 => H3+  + He 
02674          * equation (He13) from
02675          * >>refer      HeH+    k       Galli, D., & Palla, F. 1998, A&A,335,403-420 
02676          * hehph2h3phe = 1.3e-9;*/
02677         /*UMIST: 1.5e-9*/
02678 
02679         /* >> chng 05 aug 05, NPA comment.  Turn off HeH+ for the Leiden comparison.  Can't
02680            turn if off completely or else the matrix is unstable.  Just make sure that 
02681            the abundance never affects the other molecules. */
02684         hmi.hehph2h3phe = 1.3e-9*co.lgUMISTrates;
02685         if(r->next == NULL) {
02686                 int in[]={ipMH2g,ipMHeHp},out[]={ipMH3p};
02687                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02688         }
02689         r = r->next;
02690         rindex++;
02691         r->rk = hmi.hehph2h3phe;
02692 
02693         /* >>chng 03 sep 30 */
02694         /* He+  +  H- => H  + He 
02695          * equation (20) from
02696          * >>refer      H-      k       Stancil, P.C., Lepp, S., Dalgarno, A.1998, ApJ,509,1-10
02697          * hephmhhe = 2.32e-7*pow(phycon.te/300,-.52)*sexp(phycon.te/-22400.)*dense.xIonDense[ipHELIUM][1];*/
02698         /* >>chng 03 oct 22, only add for Te < 1e5 - caused exception as T -> inf */
02699         hephmhhe = 2.32e-7*pow(phycon.te/300,-.52)*exp(TStancil/22400.)*dense.xIonDense[ipHELIUM][1];
02700         if(r->next == NULL) {
02701                 int in[]={ipMHm},out[]={ipMH};
02702                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02703         }
02704         r = r->next;
02705         rindex++;
02706         r->rk =hephmhhe;
02707 
02708 #       define CO_ON    true
02709         /*>>chng 06 jul 02, do not include cross terms with co molecules when advection on -
02710          * this causes the H sum to be incorrect by as much as a few percent - no problem is
02711          * co network if not on when dynamics is done */
02712         if( CO_ON && !dynamics.lgAdvection )
02713         {
02714         /* >>chng 04 may 26, NPA add this code */
02715         /* Many reactions in co.c also will create or destroy molecules that are predicted 
02716            in hmole.  These reactions need to be inserted into this solver to obtain a more
02717            accurate solution. These are the rates for reactions in co.c that create or destroy
02718            species that are predicted in hmole_step.c.*/
02719 
02720         co.H_CH_C_H_H                           = CO_findrk("H,CH=>C,H,H")*findspecies("CH")->hevmol;
02721         co.H_OH_O_H_H                           = CO_findrk("H,OH=>O,H,H")*findspecies("OH")->hevmol;
02722         co.H_H2O_OH_H_H                         = CO_findrk("H,H2O=>OH,H,H")*findspecies("H2O")->hevmol;
02723         co.H_COP_CO_HP                          = CO_findrk("H,CO+=>CO,H+")*findspecies("CO+")->hevmol;
02724         co.H_CH_C_H2                            = CO_findrk("H,CH=>C,H2")*findspecies("CH")->hevmol;
02725         co.H_CHP_CP_H2                          = CO_findrk("H,CH+=>C+,H2")*findspecies("CH+")->hevmol;
02726         co.H_CH2_CH_H2                          = CO_findrk("H,CH2=>CH,H2")*findspecies("CH2")->hevmol;
02727         co.H_CH3P_CH2P_H2                       = CO_findrk("H,CH3+=>CH2+,H2")*findspecies("CH3+")->hevmol;
02728         co.H_OH_O_H2                            = CO_findrk("H,OH=>O,H2")*findspecies("OH")->hevmol;
02729         co.H_H2O_OH_H2                          = CO_findrk("H,H2O=>OH,H2")*findspecies("H2O")->hevmol;
02730         co.Hminus_HCOP_CO_H2        = CO_findrk("H-,HCO+=>CO,H2")*findspecies("HCO+")->hevmol;
02731         co.Hminus_H3OP_H2O_H2       = CO_findrk("H-,H3O+=>H2O,H2")*findspecies("H3O+")->hevmol;
02732         co.Hminus_H3OP_OH_H2_H      = CO_findrk("H-,H3O+=>OH,H2,H")*findspecies("H3O+")->hevmol;
02733         co.HP_CH_CHP_H                      = CO_findrk("H+,CH=>CH+,H")*findspecies("CH")->hevmol;
02734         co.HP_CH2_CH2P_H                    = CO_findrk("H+,CH2=>CH2+,H")*findspecies("CH2")->hevmol;
02735         co.HP_H2O_H2OP_H                    = CO_findrk("H+,H2O=>H2O+,H")*findspecies("H2O")->hevmol;
02736         co.HP_O2_O2P_H                      = CO_findrk("H+,O2=>O2+,H")*findspecies("O2")->hevmol;
02737         co.HP_OH_OHP_H                      = CO_findrk("H+,OH=>OH+,H")*findspecies("OH")->hevmol;
02738         co.HP_SiO_SiOP_H                    = CO_findrk("H+,SiO=>SiO+,H")*findspecies("SiO")->hevmol;
02739         co.HP_CH2_CHP_H2                    = CO_findrk("H+,CH2=>CH+,H2")*findspecies("CH2")->hevmol;
02740         co.HP_SiH_SiP_H2                    = CO_findrk("H+,SiH=>Si+,H2")*findspecies("SiH")->hevmol;
02741         co.H2_CHP_CH2P_H                    = CO_findrk("H2,CH+=>CH2+,H")*findspecies("CH+")->hevmol;
02742         co.H2_CH2P_CH3P_H                   = CO_findrk("H2,CH2+=>CH3+,H")*findspecies("CH2+")->hevmol;
02743         co.H2_OHP_H2OP_H                    = CO_findrk("H2,OH+=>H2O+,H")*findspecies("OH+")->hevmol;
02744         co.H2_H2OP_H3OP_H                   = CO_findrk("H2,H2O+=>H3O+,H")*findspecies("H2O+")->hevmol;
02745         co.H2_COP_HCOP_H                    = CO_findrk("H2,CO+=>HCO+,H")*findspecies("CO+")->hevmol;
02746         co.H2_OP_OHP_H                      = CO_findrk("H2,O+=>OH+,H")*findspecies("O+")->hevmol;
02747         co.H2_SiOP_SiOHP_H                  = CO_findrk("H2,SiO+=>SiOH+,H")*findspecies("SiO+")->hevmol;
02748         co.H2_C_CH_H                            = CO_findrk("H2,C=>CH,H")*findspecies("C")->hevmol;
02749         co.H2_CP_CHP_H                          = CO_findrk("H2,C+=>CH+,H")*findspecies("C+")->hevmol;
02750         co.H2_CH_CH2_H                          = CO_findrk("H2,CH=>CH2,H")*findspecies("CH")->hevmol;
02751         co.H2_OH_H2O_H                          = CO_findrk("H2,OH=>H2O,H")*findspecies("OH")->hevmol;
02752         co.H2_O_OH_H                            = CO_findrk("H2,O=>OH,H")*findspecies("O")->hevmol;
02753         co.H2_CH_C_H2_H                         = CO_findrk("H2,CH=>C,H2,H")*findspecies("CH")->hevmol;
02754         co.H2_OH_O_H2_H                         = CO_findrk("H2,OH=>O,H2,H")*findspecies("OH")->hevmol;
02755         co.H2_H2O_OH_H2_H                       = CO_findrk("H2,H2O=>OH,H2,H")*findspecies("H2O")->hevmol;
02756         co.H2_O2_O_O_H2                         = CO_findrk("H2,O2=>O,O,H2")*findspecies("O2")->hevmol;
02757         co.H2s_CH_C_H2_H                        = CO_findrk("H2*,CH=>C,H2,H")*findspecies("CH")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02758         co.H2s_OH_O_H2_H                        = CO_findrk("H2*,OH=>O,H2,H")*findspecies("OH")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02759         co.H2s_H2O_OH_H2_H                      = CO_findrk("H2*,H2O=>OH,H2,H")*findspecies("H2O")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02760         co.H2s_O2_O_O_H2                        = CO_findrk("H2*,O2=>O,O,H2")*findspecies("O2")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02761         co.H2P_C_CHP_H                          = CO_findrk("H2+,C=>CH+,H")*findspecies("C")->hevmol;
02762         co.H2P_CH_CH2P_H                        = CO_findrk("H2+,CH=>CH2+,H")*findspecies("CH")->hevmol;
02763         co.H2P_CH2_CH3P_H                       = CO_findrk("H2+,CH2=>CH3+,H")*findspecies("CH2")->hevmol;
02764         co.H2P_OH_H2OP_H                        = CO_findrk("H2+,OH=>H2O+,H")*findspecies("OH")->hevmol;
02765         co.H2P_H2O_H3OP_H                       = CO_findrk("H2+,H2O=>H3O+,H")*findspecies("H2O")->hevmol;
02766         co.H2P_CO_HCOP_H                        = CO_findrk("H2+,CO=>HCO+,H")*findspecies("CO")->hevmol;
02767         co.H2P_O_OHP_H                          = CO_findrk("H2+,O=>OH+,H")*findspecies("O")->hevmol;
02768         co.H2P_CH_CHP_H2                        = CO_findrk("H2+,CH=>CH+,H2")*findspecies("CH")->hevmol;
02769         co.H2P_CH2_CH2P_H2                      = CO_findrk("H2+,CH2=>CH2+,H2")*findspecies("CH2")->hevmol;
02770         co.H2P_CO_COP_H2                        = CO_findrk("H2+,CO=>CO+,H2")*findspecies("CO")->hevmol;
02771         co.H2P_H2O_H2OP_H2                      = CO_findrk("H2+,H2O=>H2O+,H2")*findspecies("H2O")->hevmol;
02772         co.H2P_O2_O2P_H2                        = CO_findrk("H2+,O2=>O2+,H2")*findspecies("O2")->hevmol;
02773         co.H2P_OH_OHP_H2                        = CO_findrk("H2+,OH=>OH+,H2")*findspecies("OH")->hevmol;
02774         co.H3P_C_CHP_H2                         = CO_findrk("H3+,C=>CH+,H2")*findspecies("C")->hevmol;
02775         co.H3P_CH_CH2P_H2                       = CO_findrk("H3+,CH=>CH2+,H2")*findspecies("CH")->hevmol;
02776         co.H3P_CH2_CH3P_H2                      = CO_findrk("H3+,CH2=>CH3+,H2")*findspecies("CH2")->hevmol;
02777         co.H3P_OH_H2OP_H2                       = CO_findrk("H3+,OH=>H2O+,H2")*findspecies("OH")->hevmol;
02778         co.H3P_H2O_H3OP_H2                      = CO_findrk("H3+,H2O=>H3O+,H2")*findspecies("H2O")->hevmol;
02779         co.H3P_CO_HCOP_H2                       = CO_findrk("H3+,CO=>HCO+,H2")*findspecies("CO")->hevmol;
02780         co.H3P_O_OHP_H2                         = CO_findrk("H3+,O=>OH+,H2")*findspecies("O")->hevmol;
02781         co.H3P_SiH_SiH2P_H2                     = CO_findrk("H3+,SiH=>SiH2+,H2")*findspecies("SiH")->hevmol;
02782         co.H3P_SiO_SiOHP_H2                     = CO_findrk("H3+,SiO=>SiOH+,H2")*findspecies("SiO")->hevmol;
02783         co.H2s_CH_CH2_H                         = CO_findrk("H2*,CH=>CH2,H")*findspecies("CH")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02784         co.H2s_O_OH_H                           = CO_findrk("H2*,O=>OH,H")*findspecies("O")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02785         co.H2s_OH_H2O_H                         = CO_findrk("H2*,OH=>H2O,H")*findspecies("OH")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02786         co.H2s_C_CH_H                           = CO_findrk("H2*,C=>CH,H")*findspecies("C")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02787         co.H2s_CP_CHP_H                         = CO_findrk("H2*,C+=>CH+,H")*findspecies("C+")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02788         co.H_CH3_CH2_H2                         = CO_findrk("H,CH3=>CH2,H2")*findspecies("CH3")->hevmol;
02789         co.H_CH4P_CH3P_H2                       = CO_findrk("H,CH4+=>CH3+,H2")*findspecies("CH4+")->hevmol;
02790         co.H_CH5P_CH4P_H2                       = CO_findrk("H,CH5+=>CH4+,H2")*findspecies("CH5+")->hevmol;
02791         co.H2_CH2_CH3_H                         = CO_findrk("H2,CH2=>CH3,H")*findspecies("CH2")->hevmol;
02792         co.H2_CH3_CH4_H                         = CO_findrk("H2,CH3=>CH4,H")*findspecies("CH3")->hevmol;
02793         co.H2_CH4P_CH5P_H                       = CO_findrk("H2,CH4+=>CH5+,H")*findspecies("CH4+")->hevmol;
02794         co.H2s_CH2_CH3_H                        = CO_findrk("H2*,CH2=>CH3,H")*findspecies("CH2")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02795         co.H2s_CH3_CH4_H                        = CO_findrk("H2*,CH3=>CH4,H")*findspecies("CH3")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
02796         co.H2P_CH4_CH3P_H2                      = CO_findrk("H2+,CH4=>CH3+,H2,H")*findspecies("CH4")->hevmol;
02797         co.H2P_CH4_CH4P_H2                      = CO_findrk("H2+,CH4=>CH4+,H2")*findspecies("CH4")->hevmol;
02798         co.H2P_CH4_CH5P_H                       = CO_findrk("H2+,CH4=>CH5+,H")*findspecies("CH4")->hevmol;
02799         /* >>chng 05 jul 15, TE, change from findspecies("CH")->hevmol to findspecies("CH3")->hevmol */
02800         co.H3P_CH3_CH4P_H2                      = CO_findrk("H3+,CH3=>CH4+,H2")*findspecies("CH3")->hevmol;
02801         co.H3P_CH4_CH5P_H2                      = CO_findrk("H3+,CH4=>CH5+,H2")*findspecies("CH4")->hevmol;
02802         co.HP_CH3_CH3P_H                        = CO_findrk("H+,CH3=>CH3+,H")*findspecies("CH3")->hevmol;
02803         co.HP_CH4_CH3P_H2                       = CO_findrk("H+,CH4=>CH3+,H2")*findspecies("CH4")->hevmol;
02804         co.HP_CH4_CH4P_H                        = CO_findrk("H+,CH4=>CH4+,H")*findspecies("CH4")->hevmol;
02805 
02806 
02807         /*  >>chng 04 jul 14 -- NPA. This is the contribution that the heavy element 
02808          *  network makes to the hydrogen chemistry due to reactions with N and S. */
02809 
02810         co.H2_N_NH_H           = CO_findrk("H2,N=>NH,H")*findspecies("N")->hevmol;
02811         co.H2_NH_NH2_H         = CO_findrk("H2,NH=>NH2,H")*findspecies("NH")->hevmol;
02812         co.H2_NH2_NH3_H        = CO_findrk("H2,NH2=>NH3,H")*findspecies("NH2")->hevmol;
02813         co.H2_CN_HCN_H         = CO_findrk("H2,CN=>HCN,H")*findspecies("CN")->hevmol;
02814         co.HP_HNO_NOP_H2       = CO_findrk("H+,HNO=>NO+,H2")*findspecies("HNO")->hevmol;
02815         co.HP_HS_SP_H2         = CO_findrk("H+,HS=>S+,H2")*findspecies("HS")->hevmol;
02816         co.H_HSP_SP_H2         = CO_findrk("H,HS+=>S+,H2")*findspecies("HS+")->hevmol;
02817         co.H2P_N_NHP_H         = CO_findrk("H2+,N=>NH+,H")*findspecies("N")->hevmol;
02818         co.H2_NP_NHP_H         = CO_findrk("H2,N+=>NH+,H")*findspecies("N+")->hevmol;
02819         co.H2_NHP_N_H3P        = CO_findrk("H2,NH+=>N,H3+")*findspecies("NH+")->hevmol;
02820         co.H2P_NH_NH2P_H       = CO_findrk("H2+,NH=>NH2+,H")*findspecies("NH")->hevmol;
02821         co.H2_NHP_NH2P_H       = CO_findrk("H2,NH+=>NH2+,H")*findspecies("NH+")->hevmol;
02822         co.H2_NH2P_NH3P_H      = CO_findrk("H2,NH2+=>NH3+,H")*findspecies("NH2+")->hevmol;
02823         co.H2_NH3P_NH4P_H      = CO_findrk("H2,NH3+=>NH4+,H")*findspecies("NH3+")->hevmol;
02824         co.H2P_CN_HCNP_H       = CO_findrk("H2+,CN=>HCN+,H")*findspecies("CN")->hevmol;
02825         co.H2_CNP_HCNP_H       = CO_findrk("H2,CN+=>HCN+,H")*findspecies("CN+")->hevmol;
02826         co.H2P_NO_HNOP_H       = CO_findrk("H2+,NO=>HNO+,H")*findspecies("NO")->hevmol;
02827         co.H2_SP_HSP_H         = CO_findrk("H2,S+=>HS+,H")*findspecies("S+")->hevmol;
02828         co.H2_CSP_HCSP_H       = CO_findrk("H2,CS+=>HCS+,H")*findspecies("CS+")->hevmol;
02829         co.H3P_NH_NH2P_H2      = CO_findrk("H3+,NH=>NH2+,H2")*findspecies("NH")->hevmol;
02830         co.H3P_NH2_NH3P_H2     = CO_findrk("H3+,NH2=>NH3+,H2")*findspecies("NH2")->hevmol;
02831         co.H3P_NH3_NH4P_H2     = CO_findrk("H3+,NH3=>NH4+,H2")*findspecies("NH3")->hevmol;
02832         co.H3P_CN_HCNP_H2      = CO_findrk("H3+,CN=>HCN+,H2")*findspecies("CN")->hevmol;
02833         co.H3P_NO_HNOP_H2      = CO_findrk("H3+,NO=>HNO+,H2")*findspecies("NO")->hevmol;
02834         co.H3P_S_HSP_H2        = CO_findrk("H3+,S=>HS+,H2")*findspecies("S")->hevmol;
02835         co.H3P_CS_HCSP_H2      = CO_findrk("H3+,CS=>HCS+,H2")*findspecies("CS")->hevmol;
02836         co.H3P_NO2_NOP_OH_H2   = CO_findrk("H3+,NO2=>NO+,OH,H2")*findspecies("NO2")->hevmol;
02837         co.HP_NH_NHP_H         = CO_findrk("H+,NH=>NH+,H")*findspecies("NH")->hevmol;
02838         co.HP_NH2_NH2P_H       = CO_findrk("H+,NH2=>NH2+,H")*findspecies("NH2")->hevmol;
02839         co.HP_NH3_NH3P_H       = CO_findrk("H+,NH3=>NH3+,H")*findspecies("NH3")->hevmol;
02840         co.H_CNP_CN_HP         = CO_findrk("H,CN+=>CN,H+")*findspecies("CN+")->hevmol;
02841         co.HP_HCN_HCNP_H       = CO_findrk("H+,HCN=>HCN+,H")*findspecies("HCN")->hevmol;
02842         co.H_HCNP_HCN_HP       = CO_findrk("H,HCN+=>HCN,H+")*findspecies("HCN+")->hevmol;
02843         co.H_N2P_N2_HP         = CO_findrk("H,N2+=>N2,H+")*findspecies("N2+")->hevmol;
02844         co.HP_NO_NOP_H         = CO_findrk("H+,NO=>NO+,H")*findspecies("NO")->hevmol;
02845         co.HP_HS_HSP_H         = CO_findrk("H+,HS=>HS+,H")*findspecies("HS")->hevmol;
02846         co.HP_SiN_SiNP_H       = CO_findrk("H+,SiN=>SiN+,H")*findspecies("SiN")->hevmol;
02847         co.HP_CS_CSP_H         = CO_findrk("H+,CS=>CS+,H")*findspecies("CS")->hevmol;
02848         co.HP_NS_NSP_H         = CO_findrk("H+,NS=>NS+,H")*findspecies("NS")->hevmol;
02849         co.HP_SO_SOP_H         = CO_findrk("H+,SO=>SO+,H")*findspecies("SO")->hevmol;
02850         co.HP_OCS_OCSP_H       = CO_findrk("H+,OCS=>OCS+,H")*findspecies("OCS")->hevmol;
02851         co.HP_S2_S2P_H         = CO_findrk("H+,S2=>S2+,H")*findspecies("S2")->hevmol;
02852         co.H2P_NH_NHP_H2       = CO_findrk("H2+,NH=>NH+,H2")*findspecies("NH")->hevmol;
02853         co.H2P_NH2_NH2P_H2     = CO_findrk("H2+,NH2=>NH2+,H2")*findspecies("NH2")->hevmol;
02854         co.H2P_NH3_NH3P_H2     = CO_findrk("H2+,NH3=>NH3+,H2")*findspecies("NH3")->hevmol;
02855         co.H2P_CN_CNP_H2       = CO_findrk("H2+,CN=>CN+,H2")*findspecies("CN")->hevmol;
02856         co.H2P_HCN_HCNP_H2     = CO_findrk("H2+,HCN=>HCN+,H2")*findspecies("HCN")->hevmol;
02857         co.H2P_NO_NOP_H2       = CO_findrk("H2+,NO=>NO+,H2")*findspecies("NO")->hevmol;
02858         /*>>chng 05 jul 22, TE, included reaction which contribute to the molecular hydrogen network */
02859         /* that were in mole_co_step, but not in mole_h_step*/
02860         co.HP_C2_C2P_H             = CO_findrk("H+,C2=>C2+,H")*findspecies("C2")->hevmol;
02861         co.H2P_C2_C2P_H2           = CO_findrk("H2+,C2=>C2+,H2")*findspecies("C2")->hevmol;     
02862         co.Hminus_NH4P_NH3_H2  = CO_findrk("H-,NH4+=>NH3,H2")*findspecies("NH4+")->hevmol;
02863         co.Hminus_NP_N_H       = CO_findrk("H-,N+=>N,H")*findspecies("N+")->hevmol;
02864 
02865         /* >> chng 05 jul 15, TE, make the chlorine reactions a member of mole.h */
02866         /* >>chng 05 mar 23 -- NPA. Add Chlorine chemical reactions to hydrogen ionization balance */
02867         /* >>chng 05 jul 21 -- NPA. TE noticed that two reactions that contribute to the molecular hydrogen network,
02868          * and in mole_co_step.c, were not included in h_step.  These reactions are now inserted.*/
02869         /* >>chng 05 aug 1 -- NPA. Gargi Shaw noticed that the reaction H2 + S => HS + H was not in the CO network
02870          * This has been changed.  This reaction also affects H2 network so must go here also .*/
02871 
02872         co.H2_ClP_HClP_H = CO_findrk("H2,Cl+=>HCl+,H")*findspecies("Cl+")->hevmol;
02873         co.H2_HClP_H2ClP_H = CO_findrk("H2,HCl+=>H2Cl+,H")*findspecies("HCl+")->hevmol;
02874         co.H3P_Cl_HClP_H2 = CO_findrk("H3+,Cl=>HCl+,H2")*findspecies("Cl")->hevmol;
02875         co.H3P_HCl_H2ClP_H2 = CO_findrk("H3+,HCl=>H2Cl+,H2")*findspecies("HCl")->hevmol;
02876         co.HP_HCl_HClP_H = CO_findrk("H+,HCl=>HCl+,H")*findspecies("HCl")->hevmol;
02877         /* >>chng 06 feb 06 rjrw -- was multiplied by HS not S */       
02878         co.H2_S_HS_H = CO_findrk("H2,S=>HS,H")*findspecies("S")->hevmol;
02879         /* >>chng 05 sept 14 - NPA, add HNC and HCNH+ to hmole_step */
02880         co.HP_HNC_HCN_HP = CO_findrk("H+,HNC=>HCN,H+")*findspecies("HNC")->hevmol;
02881         co.H_HNC_HCN_H = CO_findrk("H,HNC=>HCN,H")*findspecies("HNC")->hevmol;
02882         /* >>chng 06 feb 06 rjrw -- was duplicated */
02883         /* co.H_HNC_HCN_H = CO_findrk("H,HNC=>HCN,H")*findspecies("HNC")->hevmol; */
02884         co.H2_HCNP_HCNHP_H = CO_findrk("H2,HCN+=>HCNH+,H")*findspecies("HCN+")->hevmol;
02885         /* >>chng 06 Sep 03 rjrw HNC -> HCN in COmole index for consistency */
02886         co.H3P_HCN_HCNHP_H2 = CO_findrk("H3+,HCN=>HCNH+,H2")*findspecies("HCN")->hevmol;
02887         /* >>chng 05 nov 17, TE added following reaction, the same rate as H2g is assumed*/
02888         co.H2s_OP_OHP_H = CO_findrk("H2*,O+=>OH+,H")*findspecies("O+")->hevmol;
02889 
02890 
02891 
02892         /* >>chng 05 dec 01 - NPA.  Add reactions of C3, C3+, C2H, C2H+, C3H, C3H+, C2H2,
02893          * C2H2+, and C2H3+ with hydrogen molecules to the overall balance */
02894         co.HP_C2H2_C2H2P_H = CO_findrk("H+,C2H2=>C2H2+,H")*findspecies("C2H2")->hevmol;
02895         co.HP_C2H2_C2HP_H2 = CO_findrk("H+,C2H2=>C2H+,H2")*findspecies("C2H2")->hevmol;
02896         co.HP_C3H_C3HP_H = CO_findrk("H+,C3H=>C3H+,H")*findspecies("C3H")->hevmol;
02897         co.HP_C3H_C3P_H2 = CO_findrk("H+,C3H=>C3+,H2")*findspecies("C3H")->hevmol;
02898         co.H2P_C2H_C2H2P_H = CO_findrk("H2+,C2H=>C2H2+,H")*findspecies("C2H")->hevmol;
02899         co.H2P_C2H2_C2H2P_H2 = CO_findrk("H2+,C2H2=>C2H2+,H2")*findspecies("C2H2")->hevmol;
02900         co.H3P_C2H_C2H2P_H2 = CO_findrk("H3+,C2H=>C2H2+,H2")*findspecies("C2H")->hevmol;
02901         co.H3P_C3_C3HP_H2 = CO_findrk("H3+,C3=>C3H+,H2")*findspecies("C3")->hevmol;
02902         co.H2_C2HP_C2H2P_H = CO_findrk("H2,C2H+=>C2H2+,H")*findspecies("C2H+")->hevmol;
02903         co.H2_C3P_C3HP_H = CO_findrk("H2,C3+=>C3H+,H")*findspecies("C3+")->hevmol;
02904         co.H_C2H3P_C2H2P_H2 = CO_findrk("H,C2H3+=>C2H2+,H2")*findspecies("C2H3+")->hevmol;
02905         co.H3P_C2H2_C2H3P_H2 = CO_findrk("H3+,C2H2=>C2H3+,H2")*findspecies("C2H2")->hevmol;
02906         co.H2P_C2H2_C2H3P_H = CO_findrk("H2+,C2H2=>C2H3+,H")*findspecies("C2H2")->hevmol;
02907         co.HP_C3_C3P_H = CO_findrk("H+,C3=>C3+,H")*findspecies("C3")->hevmol;
02908         co.HP_C2H_C2HP_H = CO_findrk("H+,C2H=>C2H+,H")*findspecies("C2H")->hevmol;
02909         co.H2P_C2_C2HP_H = CO_findrk("H2+,C2=>C2H+,H")*findspecies("C2")->hevmol;
02910         co.H2P_C2H_C2HP_H2 = CO_findrk("H2+,C2H=>C2H+,H2")*findspecies("C2H")->hevmol;
02911         co.H3P_C2_C2HP_H2 = CO_findrk("H3+,C2=>C2H+,H2")*findspecies("C2")->hevmol;
02912         co.H2_C2P_C2HP_H = CO_findrk("H2,C2+=>C2H+,H")*findspecies("C2+")->hevmol;
02913         co.HP_C2H_C2P_H2 = CO_findrk("H+,C2H=>C2+,H2")*findspecies("C2H")->hevmol;
02914         /* >>chng 13 Apr 2006, Add N2H+ to chemistry, which 
02915          * should improve modeling of nitrogen chemistry, in 
02916          * particular NH and N2 */
02917         co.N2_H3P_N2HP_H2 = CO_findrk("N2,H3+=>N2H+,H2")*findspecies("N2")->hevmol;
02918         if(r->next == NULL) 
02919         {
02920                 int in[]={ipMH},out[]={ipMH,ipMH};
02921                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02922         }
02923         r = r->next;
02924         rindex++;
02925         r->rk = co.H_CH_C_H_H;
02926 
02927         if(r->next == NULL)
02928         {
02929                 int in[]={ipMH},out[]={ipMH,ipMH};
02930                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02931         }
02932         r = r->next;
02933         rindex++;
02934         r->rk =co.H_OH_O_H_H;
02935 
02936         if(r->next == NULL)
02937         {
02938                 int in[]={ipMH},out[]={ipMH,ipMH};
02939                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02940         }
02941         r = r->next;
02942         rindex++;
02943         r->rk =co.H_H2O_OH_H_H;
02944 
02945         if(r->next == NULL)
02946         {
02947                 int in[]={ipMH},out[]={ipMHp};
02948                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02949         }
02950         r = r->next;
02951         rindex++;
02952         r->rk =co.H_COP_CO_HP;
02953 
02954         if(r->next == NULL)
02955         {
02956                 int in[]={ipMH},out[]={ipMH2g};
02957                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02958         }
02959         r = r->next;
02960         rindex++;
02961         r->rk =co.H_CH_C_H2;
02962 
02963         if(r->next == NULL)
02964         {
02965                 int in[]={ipMH},out[]={ipMH2g};
02966                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02967         }
02968         r = r->next;
02969         rindex++;
02970         r->rk =co.H_CHP_CP_H2;
02971 
02972         if(r->next == NULL) 
02973         {
02974                 int in[]={ipMH},out[]={ipMH2g};
02975                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02976         }
02977         r = r->next;
02978         rindex++;
02979         r->rk =co.H_CH2_CH_H2;
02980 
02981         if(r->next == NULL) 
02982         {
02983                 int in[]={ipMH},out[]={ipMH2g};
02984                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02985         }
02986         r = r->next;
02987         rindex++;
02988         r->rk =co.H_CH3P_CH2P_H2;
02989 
02990         if(r->next == NULL)
02991         {
02992                 int in[]={ipMH},out[]={ipMH2g};
02993                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
02994         }
02995         r = r->next;
02996         rindex++;
02997         r->rk =co.H_OH_O_H2;
02998 
02999         if(r->next == NULL) 
03000         {
03001                 int in[]={ipMH},out[]={ipMH2g};
03002                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03003         }
03004         r = r->next;
03005         rindex++;
03006         r->rk =co.H_H2O_OH_H2;
03007 
03008 
03009         if(r->next == NULL) 
03010         {
03011                 int in[]={ipMHm},out[]={ipMH2g};
03012                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03013         }
03014         r = r->next;
03015         rindex++;
03016         r->rk =co.Hminus_HCOP_CO_H2;
03017 
03018         if(r->next == NULL) 
03019         {
03020                 int in[]={ipMHm},out[]={ipMH2g};
03021                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03022         }
03023         r = r->next;
03024         rindex++;
03025         r->rk =co.Hminus_H3OP_H2O_H2;
03026 
03027         if(r->next == NULL)
03028         {
03029                 int in[]={ipMHm},out[]={ipMH2g, ipMH};
03030                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03031         }
03032         r = r->next;
03033         rindex++;
03034         r->rk =co.Hminus_H3OP_OH_H2_H;
03035 
03036         if(r->next == NULL)
03037         {
03038                 int in[]={ipMHp},out[]={ipMH};
03039                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03040         }
03041         r = r->next;
03042         rindex++;
03043         r->rk =co.HP_CH_CHP_H;
03044 
03045         if(r->next == NULL)
03046         {
03047                 int in[]={ipMHp},out[]={ipMH};
03048                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03049         }
03050         r = r->next;
03051         rindex++;
03052         r->rk =co.HP_CH2_CH2P_H;
03053 
03054         if(r->next == NULL)
03055         {
03056                 int in[]={ipMHp},out[]={ipMH};
03057                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03058         }
03059         r = r->next;
03060         rindex++;
03061         r->rk =co.HP_H2O_H2OP_H;
03062 
03063         if(r->next == NULL)
03064         {
03065                 int in[]={ipMHp},out[]={ipMH};
03066                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03067         }
03068         r = r->next;
03069         rindex++;
03070         r->rk =co.HP_O2_O2P_H;
03071 
03072         if(r->next == NULL)
03073         {
03074                 int in[]={ipMHp},out[]={ipMH};
03075                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03076         }
03077         r = r->next;
03078         rindex++;
03079         r->rk =co.HP_OH_OHP_H;
03080 
03081         if(r->next == NULL)
03082         {
03083                 int in[]={ipMHp},out[]={ipMH};
03084                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03085         }
03086         r = r->next;
03087         rindex++;
03088         r->rk =co.HP_SiO_SiOP_H;
03089 
03090         if(r->next == NULL) 
03091         {
03092                 int in[]={ipMHp},out[]={ipMH2g};
03093                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03094         }
03095         r = r->next;
03096         rindex++;
03097         r->rk =co.HP_CH2_CHP_H2;
03098 
03099         if(r->next == NULL) 
03100         {
03101                 int in[]={ipMHp},out[]={ipMH2g};
03102                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03103         }
03104         r = r->next;
03105         rindex++;
03106         r->rk =co.HP_SiH_SiP_H2;
03107 
03108         if(r->next == NULL) 
03109         {
03110                 int in[]={ipMH2g},out[]={ipMH};
03111                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03112         }
03113         r = r->next;
03114         rindex++;
03115         r->rk =co.H2_CHP_CH2P_H;
03116 
03117         if(r->next == NULL)
03118         {
03119                 int in[]={ipMH2g},out[]={ipMH};
03120                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03121         }
03122         r = r->next;
03123         rindex++;
03124         r->rk =co.H2_CH2P_CH3P_H;
03125 
03126         if(r->next == NULL)
03127         {
03128                 int in[]={ipMH2g},out[]={ipMH};
03129                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03130         }
03131         r = r->next;
03132         rindex++;
03133         r->rk =co.H2_OHP_H2OP_H;
03134 
03135         if(r->next == NULL) 
03136         {
03137                 int in[]={ipMH2g},out[]={ipMH};
03138                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03139         }
03140         r = r->next;
03141         rindex++;
03142         r->rk =co.H2_H2OP_H3OP_H;
03143 
03144         if(r->next == NULL)
03145         {
03146                 int in[]={ipMH2g},out[]={ipMH};
03147                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03148         }
03149         r = r->next;
03150         rindex++;
03151         r->rk =co.H2_COP_HCOP_H;
03152 
03153         if(r->next == NULL)
03154         {
03155                 int in[]={ipMH2g},out[]={ipMH};
03156                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03157         }
03158         r = r->next;
03159         rindex++;
03160         r->rk =co.H2_OP_OHP_H;
03161 
03162         if(r->next == NULL)
03163         {
03164                 int in[]={ipMH2g},out[]={ipMH};
03165                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03166         }
03167         r = r->next;
03168         rindex++;
03169         r->rk =co.H2_SiOP_SiOHP_H;
03170 
03171         if(r->next == NULL) 
03172         {
03173                 int in[]={ipMH2g},out[]={ipMH};
03174                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03175         }
03176         r = r->next;
03177         rindex++;
03178         r->rk =co.H2_C_CH_H;
03179 
03180         if(r->next == NULL) 
03181         {
03182                 int in[]={ipMH2g},out[]={ipMH};
03183                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03184         }
03185         r = r->next;
03186         rindex++;
03187         r->rk =co.H2_CP_CHP_H;
03188 
03189         if(r->next == NULL) 
03190         {
03191                 int in[]={ipMH2g},out[]={ipMH};
03192                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03193         }
03194         r = r->next;
03195         rindex++;
03196         r->rk =co.H2_CH_CH2_H;
03197 
03198         if(r->next == NULL)
03199         {
03200                 int in[]={ipMH2g},out[]={ipMH};
03201                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03202         }
03203         r = r->next;
03204         rindex++;
03205         r->rk =co.H2_OH_H2O_H;
03206 
03207         if(r->next == NULL)
03208         {
03209                 int in[]={ipMH2g},out[]={ipMH};
03210                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03211         }
03212         r = r->next;
03213         rindex++;
03214         r->rk =co.H2_O_OH_H;
03215 
03216         if(r->next == NULL)
03217         {
03218                 int in[]={ipMH2g},out[]={ipMH2g,ipMH};
03219                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03220         }
03221         r = r->next;
03222         rindex++;
03223         r->rk =co.H2_CH_C_H2_H;
03224 
03225         if(r->next == NULL) 
03226         {
03227                 int in[]={ipMH2g},out[]={ipMH2g, ipMH};
03228                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03229         }
03230         r = r->next;
03231         rindex++;
03232         r->rk =co.H2_OH_O_H2_H;
03233 
03234         if(r->next == NULL)
03235         {
03236                 int in[]={ipMH2g},out[]={ipMH2g, ipMH};
03237                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03238         }
03239         r = r->next;
03240         rindex++;
03241         r->rk =co.H2_H2O_OH_H2_H;
03242 
03243         if(r->next == NULL) 
03244         {
03245                 int in[]={ipMH2g},out[]={ipMH2g};
03246                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03247         }
03248         r = r->next;
03249         rindex++;
03250         r->rk =co.H2_O2_O_O_H2;
03251 
03252         /* >>chng 05 mar 18, by TE, this was in twice, had little effect since high
03253          * temperature barrier */
03254         /*if(r->next == NULL)
03255         {
03256                 int in[]={ipMH2g},out[]={ipMH};
03257                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03258         }
03259         r = r->next;
03260         rindex++;
03261         r->rk =co.H2_C_CH_H;*/
03262 
03263         if(r->next == NULL) 
03264         {
03265                 int in[]={ipMH2s},out[]={ipMH2g,ipMH};
03266                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03267         }
03268         r = r->next;
03269         rindex++;
03270         r->rk =co.H2s_CH_C_H2_H;
03271 
03272         if(r->next == NULL) 
03273         {
03274                 int in[]={ipMH2s},out[]={ipMH2g,ipMH};
03275                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03276         }
03277         r = r->next;
03278         rindex++;
03279         r->rk =co.H2s_OH_O_H2_H;
03280 
03281         if(r->next == NULL)
03282         {
03283                 int in[]={ipMH2s},out[]={ipMH2g,ipMH};
03284                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03285         }
03286         r = r->next;
03287         rindex++;
03288         r->rk =co.H2s_H2O_OH_H2_H;
03289 
03290         if(r->next == NULL) 
03291         {
03292                 int in[]={ipMH2s},out[]={ipMH2g};
03293                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03294         }
03295         r = r->next;
03296         rindex++;
03297         r->rk =co.H2s_O2_O_O_H2;
03298 
03299         if(r->next == NULL)
03300         {
03301                 int in[]={ipMH2p},out[]={ipMH};
03302                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03303         }
03304         r = r->next;
03305         rindex++;
03306         r->rk =co.H2P_C_CHP_H;
03307 
03308         if(r->next == NULL) 
03309         {
03310                 int in[]={ipMH2p},out[]={ipMH};
03311                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03312         }
03313         r = r->next;
03314         rindex++;
03315         r->rk =co.H2P_CH_CH2P_H;
03316 
03317         if(r->next == NULL) {
03318                 int in[]={ipMH2p},out[]={ipMH};
03319                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03320         }
03321         r = r->next;
03322         rindex++;
03323         r->rk =co.H2P_CH2_CH3P_H;
03324 
03325         if(r->next == NULL) {
03326                 int in[]={ipMH2p},out[]={ipMH};
03327                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03328         }
03329         r = r->next;
03330         rindex++;
03331         r->rk =co.H2P_OH_H2OP_H;
03332 
03333         if(r->next == NULL) {
03334                 int in[]={ipMH2p},out[]={ipMH};
03335                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03336         }
03337         r = r->next;
03338         rindex++;
03339         r->rk =co.H2P_H2O_H3OP_H;
03340 
03341         if(r->next == NULL) {
03342                 int in[]={ipMH2p},out[]={ipMH};
03343                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03344         }
03345         r = r->next;
03346         rindex++;
03347         r->rk =co.H2P_CO_HCOP_H;
03348 
03349         if(r->next == NULL) {
03350                 int in[]={ipMH2p},out[]={ipMH};
03351                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03352         }
03353         r = r->next;
03354         rindex++;
03355         r->rk =co.H2P_O_OHP_H;
03356 
03357         if(r->next == NULL) {
03358                 int in[]={ipMH2p},out[]={ipMH2g};
03359                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03360         }
03361         r = r->next;
03362         rindex++;
03363         r->rk =co.H2P_CH_CHP_H2;
03364 
03365         if(r->next == NULL) {
03366                 int in[]={ipMH2p},out[]={ipMH2g};
03367                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03368         }
03369         r = r->next;
03370         rindex++;
03371         r->rk =co.H2P_CH2_CH2P_H2;
03372 
03373         if(r->next == NULL) {
03374                 int in[]={ipMH2p},out[]={ipMH2g};
03375                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03376         }
03377         r = r->next;
03378         rindex++;
03379         r->rk =co.H2P_CO_COP_H2;
03380 
03381         if(r->next == NULL) {
03382                 int in[]={ipMH2p},out[]={ipMH2g};
03383                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03384         }
03385         r = r->next;
03386         rindex++;
03387         r->rk =co.H2P_H2O_H2OP_H2;
03388 
03389         if(r->next == NULL) {
03390                 int in[]={ipMH2p},out[]={ipMH2g};
03391                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03392         }
03393         r = r->next;
03394         rindex++;
03395         r->rk =co.H2P_O2_O2P_H2;
03396 
03397         if(r->next == NULL) {
03398                 int in[]={ipMH2p},out[]={ipMH2g};
03399                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03400         }
03401         r = r->next;
03402         rindex++;
03403         r->rk =co.H2P_OH_OHP_H2;
03404 
03405         if(r->next == NULL) {
03406                 int in[]={ipMH3p},out[]={ipMH2g};
03407                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03408         }
03409         r = r->next;
03410         rindex++;
03411         r->rk =co.H3P_C_CHP_H2;
03412 
03413         if(r->next == NULL) {
03414                 int in[]={ipMH3p},out[]={ipMH2g};
03415                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03416         }
03417         r = r->next;
03418         rindex++;
03419         r->rk =co.H3P_CH_CH2P_H2;
03420 
03421         if(r->next == NULL) {
03422                 int in[]={ipMH3p},out[]={ipMH2g};
03423                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03424         }
03425         r = r->next;
03426         rindex++;
03427         r->rk =co.H3P_CH2_CH3P_H2;
03428 
03429         if(r->next == NULL) {
03430                 int in[]={ipMH3p},out[]={ipMH2g};
03431                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03432         }
03433         r = r->next;
03434         rindex++;
03435         r->rk =co.H3P_OH_H2OP_H2;
03436 
03437         if(r->next == NULL) {
03438                 int in[]={ipMH3p},out[]={ipMH2g};
03439                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03440         }
03441         r = r->next;
03442         rindex++;
03443         r->rk =co.H3P_H2O_H3OP_H2;
03444 
03445         if(r->next == NULL) {
03446                 int in[]={ipMH3p},out[]={ipMH2g};
03447                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03448         }
03449         r = r->next;
03450         rindex++;
03451         r->rk =co.H3P_CO_HCOP_H2;
03452 
03453         if(r->next == NULL) 
03454         {
03455                 int in[]={ipMH3p},out[]={ipMH2g};
03456                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03457         }
03458         r = r->next;
03459         rindex++;
03460         r->rk =co.H3P_O_OHP_H2;
03461 
03462         if(r->next == NULL)
03463         {
03464                 int in[]={ipMH3p},out[]={ipMH2g};
03465                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03466         }
03467         r = r->next;
03468         rindex++;
03469         r->rk =co.H3P_SiH_SiH2P_H2;
03470 
03471         if(r->next == NULL) {
03472                 int in[]={ipMH3p},out[]={ipMH2g};
03473                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03474         }
03475         r = r->next;
03476         rindex++;
03477         r->rk =co.H3P_SiO_SiOHP_H2;
03478 
03479         if(r->next == NULL) 
03480         {
03481                 int in[]={ipMH2s},out[]={ipMH};
03482                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03483         }
03484         r = r->next;
03485         rindex++;
03486         r->rk =co.H2s_CH_CH2_H;
03487 
03488         if(r->next == NULL)
03489         {
03490                 int in[]={ipMH2s},out[]={ipMH};
03491                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03492         }
03493         r = r->next;
03494         rindex++;
03495         r->rk =co.H2s_O_OH_H;
03496 
03497         if(r->next == NULL) 
03498         {
03499                 int in[]={ipMH2s},out[]={ipMH};
03500                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03501         }
03502         r = r->next;
03503         rindex++;
03504         r->rk =co.H2s_OH_H2O_H;
03505 
03506 
03507         if(r->next == NULL) 
03508         {
03509                 int in[]={ipMH2s},out[]={ipMH};
03510                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03511         }
03512         r = r->next;
03513         rindex++;
03514         r->rk =co.H2s_C_CH_H;
03515 
03516         if(r->next == NULL)
03517         {
03518                 int in[]={ipMH2s},out[]={ipMH};
03519                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03520         }
03521         r = r->next;
03522         rindex++;
03523         r->rk =co.H2s_CP_CHP_H;
03524 
03525         if(r->next == NULL) 
03526         {
03527                 int in[]={ipMH},out[]={ipMH2g};
03528                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03529         }
03530         r = r->next;
03531         rindex++;
03532         r->rk =co.H_CH3_CH2_H2;
03533 
03534         if(r->next == NULL) 
03535         {
03536                 int in[]={ipMH},out[]={ipMH2g};
03537                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03538         }
03539         r = r->next;
03540         rindex++;
03541         r->rk =co.H_CH4P_CH3P_H2;
03542 
03543         if(r->next == NULL)
03544         {
03545                 int in[]={ipMH},out[]={ipMH2g};
03546                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03547         }
03548         r = r->next;
03549         rindex++;
03550         r->rk =co.H_CH5P_CH4P_H2;
03551 
03552         if(r->next == NULL)
03553         {
03554                 int in[]={ipMH2g},out[]={ipMH};
03555                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03556         }
03557         r = r->next;
03558         rindex++;
03559         r->rk =co.H2_CH2_CH3_H;
03560 
03561 
03562         if(r->next == NULL)
03563         {
03564                 int in[]={ipMH2g},out[]={ipMH};
03565                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03566         }
03567         r = r->next;
03568         rindex++;
03569         r->rk = co.H2_CH3_CH4_H;
03570 
03571         if(r->next == NULL)
03572         {
03573                 int in[]={ipMH2g},out[]={ipMH};
03574                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03575         }
03576         r = r->next;
03577         rindex++;
03578         r->rk = co.H2_CH4P_CH5P_H;
03579 
03580         if(r->next == NULL)
03581         {
03582                 int in[]={ipMH2s},out[]={ipMH};
03583                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03584         }
03585         r = r->next;
03586         rindex++;
03587         r->rk =co.H2s_CH2_CH3_H;
03588 
03589         if(r->next == NULL) 
03590         {
03591                 int in[]={ipMH2s},out[]={ipMH};
03592                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03593         }
03594         r = r->next;
03595         rindex++;
03596         r->rk = co.H2s_CH3_CH4_H;
03597 
03598         if(r->next == NULL) 
03599         {
03600                 int in[]={ipMH2p},out[]={ipMH2g};
03601                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03602         }
03603         r = r->next;
03604         rindex++;
03605         r->rk = co.H2P_CH4_CH3P_H2;
03606 
03607         if(r->next == NULL) 
03608         {
03609                 int in[]={ipMH2p},out[]={ipMH2g};
03610                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03611         }
03612         r = r->next;
03613         rindex++;
03614         r->rk = co.H2P_CH4_CH4P_H2;
03615 
03616         if(r->next == NULL)
03617         {
03618                 int in[]={ipMH2p},out[]={ipMH};
03619                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03620         }
03621         r = r->next;
03622         rindex++;
03623         r->rk = co.H2P_CH4_CH5P_H;
03624 
03625         if(r->next == NULL)
03626         {
03627                 int in[]={ipMH3p},out[]={ipMH2g};
03628                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03629         }
03630         r = r->next;
03631         rindex++;
03632         r->rk = co.H3P_CH3_CH4P_H2;
03633 
03634         if(r->next == NULL) 
03635         {
03636                 int in[]={ipMH3p},out[]={ipMH2g};
03637                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03638         }
03639         r = r->next;
03640         rindex++;
03641         r->rk = co.H3P_CH4_CH5P_H2;
03642 
03643         if(r->next == NULL) {
03644                 int in[]={ipMHp},out[]={ipMH2g};
03645                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03646         }
03647         r = r->next;
03648         rindex++;
03649         r->rk = co.HP_CH4_CH3P_H2;
03650 
03651         if(r->next == NULL) {
03652                 int in[]={ipMHp},out[]={ipMH};
03653                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03654         }
03655         r = r->next;
03656         rindex++;
03657         r->rk = co.HP_CH4_CH4P_H;
03658 
03659         if(r->next == NULL) {
03660                 int in[]={ipMH2g},out[]={ipMH};
03661                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03662         }
03663         r = r->next;
03664         rindex++;
03665         r->rk = co.H2_ClP_HClP_H;
03666 
03667         if(r->next == NULL) {
03668                 int in[]={ipMH2g},out[]={ipMH};
03669                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03670         }
03671         r = r->next;
03672         rindex++;
03673         r->rk = co.H2_HClP_H2ClP_H;
03674 
03675         if(r->next == NULL) {
03676                 int in[]={ipMH3p},out[]={ipMH2g};
03677                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03678         }
03679         r = r->next;
03680         rindex++;
03681         r->rk = co.H3P_Cl_HClP_H2;
03682 
03683         if(r->next == NULL) {
03684                 int in[]={ipMH3p},out[]={ipMH2g};
03685                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03686         }
03687         r = r->next;
03688         rindex++;
03689         r->rk = co.H3P_HCl_H2ClP_H2;
03690 
03691         if(r->next == NULL) {
03692                 int in[]={ipMHp},out[]={ipMH};
03693                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03694         }
03695         r = r->next;
03696         rindex++;
03697         r->rk = co.HP_HCl_HClP_H;
03698         /* >>chng 05 aug 02, NA add following reaction */
03699 
03700         if(r->next == NULL) {
03701                 int in[]={ipMH2g},out[]={ipMH};
03702                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03703         }
03704         r = r->next;
03705         rindex++;
03706         r->rk = co.H2_S_HS_H;
03707 
03708 
03709         /* The following terms are for the reactions with the rates defined above.  The 
03710          * actual reaction is self-contained in the rate label. */
03711 
03712         if(r->next == NULL)
03713         {
03714                 int in[]={ipMH2g},out[]={ipMH};
03715                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03716         }
03717         r = r->next;
03718         rindex++;
03719         r->rk = co.H2_N_NH_H;
03720 
03721         if(r->next == NULL)
03722         {
03723                 int in[]={ipMH2g},out[]={ipMH};
03724                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03725         }
03726         r = r->next;
03727         rindex++;
03728         r->rk = co.H2_NH_NH2_H;
03729 
03730 
03731         if(r->next == NULL)
03732         {
03733                 int in[]={ipMH2g},out[]={ipMH};
03734                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03735         }
03736         r = r->next;
03737         rindex++;
03738         r->rk = co.H2_NH2_NH3_H;
03739 
03740         if(r->next == NULL)
03741         {
03742                 int in[]={ipMH2g},out[]={ipMH};
03743                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03744         }
03745         r = r->next;
03746         rindex++;
03747         r->rk = co.H2_CN_HCN_H;
03748 
03749         if(r->next == NULL)
03750         {
03751                 int in[]={ipMHp},out[]={ipMH2g};
03752                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03753         }
03754         r = r->next;
03755         rindex++;
03756         r->rk = co.HP_HNO_NOP_H2;
03757 
03758         if(r->next == NULL)
03759         {
03760                 int in[]={ipMHp},out[]={ipMH2g};
03761                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03762         }
03763         r = r->next;
03764         rindex++;
03765         r->rk = co.HP_HS_SP_H2;
03766 
03767         if(r->next == NULL)
03768         {
03769                 int in[]={ipMH},out[]={ipMH2g};
03770                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03771         }
03772         r = r->next;
03773         rindex++;
03774         r->rk = co.H_HSP_SP_H2;
03775 
03776         if(r->next == NULL)
03777         {
03778                 int in[]={ipMH2p},out[]={ipMH};
03779                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03780         }
03781         r = r->next;
03782         rindex++;
03783         r->rk = co.H2P_N_NHP_H;
03784 
03785         if(r->next == NULL)
03786         {
03787                 int in[]={ipMH2g},out[]={ipMH};
03788                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03789         }
03790         r = r->next;
03791         rindex++;
03792         r->rk = co.H2_NP_NHP_H;
03793 
03794         if(r->next == NULL)
03795         {
03796                 int in[]={ipMH2g},out[]={ipMH3p};
03797                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03798         }
03799         r = r->next;
03800         rindex++;
03801         r->rk = co.H2_NHP_N_H3P;
03802 
03803         if(r->next == NULL)
03804         {
03805                 int in[]={ipMH2p},out[]={ipMH};
03806                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03807         }
03808         r = r->next;
03809         rindex++;
03810         r->rk = co.H2P_NH_NH2P_H;
03811 
03812 
03813         if(r->next == NULL)
03814         {
03815                 int in[]={ipMH2g},out[]={ipMH};
03816                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03817         }
03818         r = r->next;
03819         rindex++;
03820         r->rk = co.H2_NHP_NH2P_H;
03821 
03822         if(r->next == NULL)
03823         {
03824                 int in[]={ipMH2g},out[]={ipMH};
03825                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03826         }
03827         r = r->next;
03828         rindex++;
03829         r->rk = co.H2_NH2P_NH3P_H;
03830 
03831         if(r->next == NULL)
03832         {
03833                 int in[]={ipMH2g},out[]={ipMH};
03834                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03835         }
03836         r = r->next;
03837         rindex++;
03838         r->rk = co.H2_NH3P_NH4P_H;
03839 
03840         if(r->next == NULL)
03841         {
03842                 int in[]={ipMH2p},out[]={ipMH};
03843                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03844         }
03845         r = r->next;
03846         rindex++;
03847         r->rk = co.H2P_CN_HCNP_H;
03848 
03849         if(r->next == NULL)
03850         {
03851                 int in[]={ipMH2g},out[]={ipMH};
03852                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03853         }
03854         r = r->next;
03855         rindex++;
03856         r->rk = co.H2_CNP_HCNP_H;
03857 
03858         if(r->next == NULL)
03859         {
03860                 int in[]={ipMH2p},out[]={ipMH};
03861                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03862         }
03863         r = r->next;
03864         rindex++;
03865         r->rk = co.H2P_NO_HNOP_H;
03866 
03867         if(r->next == NULL)
03868         {
03869                 int in[]={ipMH2g},out[]={ipMH};
03870                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03871         }
03872         r = r->next;
03873         rindex++;
03874         r->rk = co.H2_SP_HSP_H;
03875 
03876         if(r->next == NULL)
03877         {
03878                 int in[]={ipMH2g},out[]={ipMH};
03879                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03880         }
03881         r = r->next;
03882         rindex++;
03883         r->rk = co.H2_CSP_HCSP_H;
03884 
03885 
03886         if(r->next == NULL)
03887         {
03888                 int in[]={ipMH3p},out[]={ipMH2g};
03889                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03890         }
03891         r = r->next;
03892         rindex++;
03893         r->rk = co.H3P_NH_NH2P_H2;
03894 
03895         if(r->next == NULL)
03896         {
03897                 int in[]={ipMH3p},out[]={ipMH2g};
03898                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03899         }
03900         r = r->next;
03901         rindex++;
03902         r->rk = co.H3P_NH2_NH3P_H2;
03903 
03904         if(r->next == NULL)
03905         {
03906                 int in[]={ipMH3p},out[]={ipMH2g};
03907                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03908         }
03909         r = r->next;
03910         rindex++;
03911         r->rk = co.H3P_NH3_NH4P_H2;
03912 
03913         if(r->next == NULL)
03914         {
03915                 int in[]={ipMH3p},out[]={ipMH2g};
03916                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03917         }
03918         r = r->next;
03919         rindex++;
03920         r->rk = co.H3P_CN_HCNP_H2;
03921 
03922         if(r->next == NULL)
03923         {
03924                 int in[]={ipMH3p},out[]={ipMH2g};
03925                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03926         }
03927         r = r->next;
03928         rindex++;
03929         r->rk = co.H3P_NO_HNOP_H2;
03930 
03931         if(r->next == NULL)
03932         {
03933                 int in[]={ipMH3p},out[]={ipMH2g};
03934                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03935         }
03936         r = r->next;
03937         rindex++;
03938         r->rk = co.H3P_S_HSP_H2;
03939 
03940         if(r->next == NULL)
03941         {
03942                 int in[]={ipMH3p},out[]={ipMH2g};
03943                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03944         }
03945         r = r->next;
03946         rindex++;
03947         r->rk = co.H3P_CS_HCSP_H2;
03948 
03949         if(r->next == NULL)
03950         {
03951                 int in[]={ipMH3p},out[]={ipMH2g};
03952                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03953         }
03954         r = r->next;
03955         rindex++;
03956         r->rk = co.H3P_NO2_NOP_OH_H2;
03957 
03958         if(r->next == NULL)
03959         {
03960                 int in[]={ipMHp},out[]={ipMH};
03961                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03962         }
03963         r = r->next;
03964         rindex++;
03965         r->rk = co.HP_NH_NHP_H;
03966 
03967         if(r->next == NULL)
03968         {
03969                 int in[]={ipMHp},out[]={ipMH};
03970                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03971         }
03972         r = r->next;
03973         rindex++;
03974         r->rk = co.HP_NH2_NH2P_H;
03975 
03976         if(r->next == NULL)
03977         {
03978                 int in[]={ipMHp},out[]={ipMH};
03979                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03980         }
03981         r = r->next;
03982         rindex++;
03983         r->rk = co.HP_NH3_NH3P_H;
03984 
03985 
03986         if(r->next == NULL)
03987         {
03988                 int in[]={ipMH},out[]={ipMHp};
03989                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03990         }
03991         r = r->next;
03992         rindex++;
03993         r->rk = co.H_CNP_CN_HP;
03994 
03995         if(r->next == NULL)
03996         {
03997                 int in[]={ipMHp},out[]={ipMH};
03998                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
03999         }
04000         r = r->next;
04001         rindex++;
04002         r->rk = co.HP_HCN_HCNP_H;
04003 
04004         if(r->next == NULL)
04005         {
04006                 int in[]={ipMH},out[]={ipMHp};
04007                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04008         }
04009         r = r->next;
04010         rindex++;
04011         r->rk = co.H_HCNP_HCN_HP;
04012 
04013         if(r->next == NULL)
04014         {
04015                 int in[]={ipMH},out[]={ipMHp};
04016                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04017         }
04018         r = r->next;
04019         rindex++;
04020         r->rk = co.H_N2P_N2_HP;
04021 
04022         if(r->next == NULL)
04023         {
04024                 int in[]={ipMHp},out[]={ipMH};
04025                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04026         }
04027         r = r->next;
04028         rindex++;
04029         r->rk = co.HP_NO_NOP_H;
04030 
04031         if(r->next == NULL)
04032         {
04033                 int in[]={ipMHp},out[]={ipMH};
04034                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04035         }
04036         r = r->next;
04037         rindex++;
04038         r->rk = co.HP_HS_HSP_H;
04039 
04040         if(r->next == NULL)
04041         {
04042                 int in[]={ipMHp},out[]={ipMH};
04043                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04044         }
04045         r = r->next;
04046         rindex++;
04047         r->rk = co.HP_SiN_SiNP_H;
04048 
04049         if(r->next == NULL)
04050         {
04051                 int in[]={ipMHp},out[]={ipMH};
04052                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04053         }
04054         r = r->next;
04055         rindex++;
04056         r->rk = co.HP_CS_CSP_H;
04057 
04058         if(r->next == NULL)
04059         {
04060                 int in[]={ipMHp},out[]={ipMH};
04061                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04062         }
04063         r = r->next;
04064         rindex++;
04065         r->rk = co.HP_NS_NSP_H;
04066 
04067         if(r->next == NULL)
04068         {
04069                 int in[]={ipMHp},out[]={ipMH};
04070                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04071         }
04072         r = r->next;
04073         rindex++;
04074         r->rk = co.HP_SO_SOP_H;
04075 
04076 
04077         if(r->next == NULL)
04078         {
04079                 int in[]={ipMHp},out[]={ipMH};
04080                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04081         }
04082         r = r->next;
04083         rindex++;
04084         r->rk = co.HP_OCS_OCSP_H;
04085 
04086         if(r->next == NULL)
04087         {
04088                 int in[]={ipMHp},out[]={ipMH};
04089                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04090         }
04091         r = r->next;
04092         rindex++;
04093         r->rk = co.HP_S2_S2P_H;
04094 
04095         if(r->next == NULL)
04096         {
04097                 int in[]={ipMH2p},out[]={ipMH2g};
04098                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04099         }
04100         r = r->next;
04101         rindex++;
04102         r->rk = co.H2P_NH_NHP_H2;
04103 
04104         if(r->next == NULL)
04105         {
04106                 int in[]={ipMH2p},out[]={ipMH2g};
04107                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04108         }
04109         r = r->next;
04110         rindex++;
04111         r->rk = co.H2P_NH2_NH2P_H2;
04112 
04113         if(r->next == NULL)
04114         {
04115                 int in[]={ipMH2p},out[]={ipMH2g};
04116                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04117         }
04118         r = r->next;
04119         rindex++;
04120         r->rk = co.H2P_NH3_NH3P_H2;
04121 
04122         if(r->next == NULL)
04123         {
04124                 int in[]={ipMH2p},out[]={ipMH2g};
04125                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04126         }
04127         r = r->next;
04128         rindex++;
04129         r->rk = co.H2P_CN_CNP_H2;
04130 
04131         if(r->next == NULL)
04132         {
04133                 int in[]={ipMH2p},out[]={ipMH2g};
04134                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04135         }
04136         r = r->next;
04137         rindex++;
04138         r->rk = co.H2P_HCN_HCNP_H2;
04139 
04140         if(r->next == NULL)
04141         {
04142                 int in[]={ipMH2p},out[]={ipMH2g};
04143                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04144         }
04145         r = r->next;
04146         rindex++;
04147         r->rk = co.H2P_NO_NOP_H2;
04148 
04149         if(r->next == NULL)
04150         {
04151                 int in[]={ipMHp},out[]={ipMH};
04152                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04153         }
04154         r = r->next;
04155         rindex++;
04156         r->rk = co.HP_C2_C2P_H;
04157 
04158 
04159         if(r->next == NULL)
04160         {
04161                 int in[]={ipMH2p},out[]={ipMH2g};
04162                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04163         }
04164         r = r->next;
04165         rindex++;
04166         r->rk = co.H2P_C2_C2P_H2;
04167 
04168         if(r->next == NULL)
04169         {
04170                 int in[]={ipMHm},out[]={ipMH2g};
04171                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04172         }
04173         r = r->next;
04174         rindex++;
04175         r->rk = co.Hminus_NH4P_NH3_H2;
04176 
04177         if(r->next == NULL)
04178         {
04179                 int in[]={ipMHm},out[]={ipMH};
04180                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04181         }
04182         r = r->next;
04183         rindex++;
04184         r->rk = co.Hminus_NP_N_H;
04185 
04186         /* >>chng 05 sept 14 - NPA.  Reactions involving HNC or HCNH+ that affect hydrogen chemistry */
04187 
04188         if(r->next == NULL)
04189         {
04190                 int in[]={ipMHp},out[]={ipMHp};
04191                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04192         }
04193         r = r->next;
04194         rindex++;
04195         r->rk = co.HP_HNC_HCN_HP;
04196 
04197         if(r->next == NULL)
04198         {
04199                 int in[]={ipMH},out[]={ipMH};
04200                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04201         }
04202         r = r->next;
04203         rindex++;
04204         r->rk = co.H_HNC_HCN_H;
04205 
04206         /* >>chng 06 feb 06 rjrw -- was duplicated */
04207         /* if(r->next == NULL)
04208         {
04209                 int in[]={ipMH},out[]={ipMH};
04210                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04211         }
04212         r = r->next;
04213         rindex++;
04214         r->rk = co.H_HNC_HCN_H; */
04215 
04216         if(r->next == NULL)
04217         {
04218                 int in[]={ipMH2g},out[]={ipMH};
04219                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04220         }
04221         r = r->next;
04222         rindex++;
04223         r->rk = co.H2_HCNP_HCNHP_H;
04224 
04225         if(r->next == NULL)
04226         {
04227                 int in[]={ipMH3p},out[]={ipMH2g};
04228                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04229         }
04230         r = r->next;
04231         rindex++;
04232         r->rk = co.H3P_HCN_HCNHP_H2;
04233 
04234         /* >>chng 05 nov 17, TE  added following reaction*/
04235         if(r->next == NULL)
04236         {
04237                 int in[]={ipMH2s},out[]={ipMH};
04238                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04239         }
04240         r = r->next;
04241         rindex++;
04242         r->rk =co.H2s_OP_OHP_H;
04243 
04244         /* >>chng 05 dec 01 - NPA.  Add reactions for some more complex molecules
04245          * into the hydrogen chemistry */
04246         if(r->next == NULL)
04247         {
04248                 int in[]={ipMHp},out[]={ipMH};
04249                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04250         }
04251         r = r->next;
04252         rindex++;
04253         r->rk = co.HP_C2H2_C2H2P_H;
04254 
04255         if(r->next == NULL)
04256         {
04257                 int in[]={ipMHp},out[]={ipMH2g};
04258                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04259         }
04260         r = r->next;
04261         rindex++;
04262         r->rk = co.HP_C2H2_C2HP_H2;
04263 
04264         if(r->next == NULL)
04265         {
04266                 int in[]={ipMHp},out[]={ipMH};
04267                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04268         }
04269         r = r->next;
04270         rindex++;
04271         r->rk = co.HP_C3H_C3HP_H;
04272 
04273         if(r->next == NULL)
04274         {
04275                 int in[]={ipMHp},out[]={ipMH2g};
04276                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04277         }
04278         r = r->next;
04279         rindex++;
04280         r->rk =co.HP_C3H_C3P_H2;
04281 
04282         if(r->next == NULL)
04283         {
04284                 int in[]={ipMH2p},out[]={ipMH};
04285                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04286         }
04287         r = r->next;
04288         rindex++;
04289         r->rk = co.H2P_C2H_C2H2P_H;
04290 
04291         if(r->next == NULL)
04292         {
04293                 int in[]={ipMH2p},out[]={ipMH2g};
04294                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04295         }
04296         r = r->next;
04297         rindex++;
04298         r->rk = co.H2P_C2H2_C2H2P_H2;
04299 
04300         if(r->next == NULL)
04301         {
04302                 int in[]={ipMH3p},out[]={ipMH2g};
04303                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04304         }
04305         r = r->next;
04306         rindex++;
04307         r->rk = co.H3P_C2H_C2H2P_H2;
04308 
04309         if(r->next == NULL)
04310         {
04311                 int in[]={ipMH3p},out[]={ipMH2g};
04312                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04313         }
04314         r = r->next;
04315         rindex++;
04316         r->rk = co.H3P_C3_C3HP_H2;
04317 
04318         if(r->next == NULL)
04319         {
04320                 int in[]={ipMH2g},out[]={ipMH};
04321                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04322         }
04323         r = r->next;
04324         rindex++;
04325         r->rk = co.H2_C2HP_C2H2P_H;
04326 
04327         if(r->next == NULL)
04328         {
04329                 int in[]={ipMH2g},out[]={ipMH};
04330                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04331         }
04332         r = r->next;
04333         rindex++;
04334         r->rk = co.H2_C3P_C3HP_H;
04335 
04336         if(r->next == NULL)
04337         {
04338                 int in[]={ipMH},out[]={ipMH2g};
04339                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04340         }
04341         r = r->next;
04342         rindex++;
04343         r->rk = co.H_C2H3P_C2H2P_H2;
04344 
04345         if(r->next == NULL)
04346         {
04347                 int in[]={ipMH3p},out[]={ipMH2g};
04348                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04349         }
04350         r = r->next;
04351         rindex++;
04352         r->rk = co.H3P_C2H2_C2H3P_H2;
04353 
04354         if(r->next == NULL)
04355         {
04356                 int in[]={ipMH2p},out[]={ipMH};
04357                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04358         }
04359         r = r->next;
04360         rindex++;
04361         r->rk = co.H2P_C2H2_C2H3P_H;
04362 
04363         if(r->next == NULL)
04364         {
04365                 int in[]={ipMHp},out[]={ipMH};
04366                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04367         }
04368         r = r->next;
04369         rindex++;
04370         r->rk = co.HP_C3_C3P_H;
04371 
04372         if(r->next == NULL)
04373         {
04374                 int in[]={ipMH2p},out[]={ipMH};
04375                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04376         }
04377         r = r->next;
04378         rindex++;
04379         r->rk = co.H2P_C2_C2HP_H;
04380 
04381         if(r->next == NULL)
04382         {
04383                 int in[]={ipMH2p},out[]={ipMH2g};
04384                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04385         }
04386         r = r->next;
04387         rindex++;
04388         r->rk = co.H2P_C2H_C2HP_H2;
04389 
04390         if(r->next == NULL)
04391         {
04392                 int in[]={ipMH3p},out[]={ipMH2g};
04393                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04394         }
04395         r = r->next;
04396         rindex++;
04397         r->rk = co.H3P_C2_C2HP_H2;
04398 
04399         if(r->next == NULL)
04400         {
04401                 int in[]={ipMH2g},out[]={ipMH};
04402                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04403         }
04404         r = r->next;
04405         rindex++;
04406         r->rk = co.H2_C2P_C2HP_H;
04407 
04408         if(r->next == NULL)
04409         {
04410                 int in[]={ipMHp},out[]={ipMH2g};
04411                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04412         }
04413         r = r->next;
04414         rindex++;
04415         r->rk = co.HP_C2H_C2P_H2;
04416 
04417 
04418         /* >>chng 13 Apr 2006, Add N2H+ to chemistry, which 
04419          * should improve modeling of nitrogen chemistry, in 
04420          * particular NH and N2 */
04421 
04422         if(r->next == NULL)
04423         {
04424                 int in[]={ipMH3p},out[]={ipMH2g};
04425                 r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
04426         }
04427         r = r->next;
04428         rindex++;
04429         r->rk = co.N2_H3P_N2HP_H2;
04430         }
04431         else
04432         {
04433                 fixit();/* rm macro set above to hose co chem */
04434         }
04435 
04436         /* >>chng 06 jun 30, these are not used anywhere else and should be removed from co header
04437          * this couples H and CO chem but was unstable.  ignore their contribution to H
04438          * chemistry for now - OK because CO moles have little effect on H solution? */
04439 #       if 0
04440         /*  The following reactions in co.c include a formation or destruction
04441             process, but not both, for one of the molecules in mole_h_step.c.
04442                 Because of this, the following rates have to be put into the bvec[i]
04443                 part of the matrix. */
04444 
04445         /* Zero out the CO contribution to the sources and sinks in hmole */
04446 
04447 
04448         for(i=0; i<N_H_MOLEC; ++i)
04449         {
04450                 co.hydro_source[i] = 0;
04451                 co.hydro_sink[i] = 0;
04452         }
04453 
04454         /* C + H3OP =  HCOP + H2 */   
04455 
04456         co.C_H3OP_HCOP_H2_1 =  HMRATE(1.0e-11,0,0)*findspecies("H3O+")->hevmol*findspecies("C")->hevmol;
04457         co.hydro_source[ipMH2g] += (realnum)co.C_H3OP_HCOP_H2_1;
04458 
04459 
04460         /* C + OH =  CO + H  */  
04461 
04462         co.C_OH_CO_H_1 = HMRATE(1.1e-10,0.5,0)*findspecies("OH")->hevmol*findspecies("C")->hevmol;
04463         co.hydro_source[ipMH] += (realnum)co.C_OH_CO_H_1;
04464 
04465         /* CP + OH =>  CO + HP */   
04466 
04467         co.CP_OH_CO_HP_1 = HMRATE(7.7e-10,0,0)*findspecies("OH")->hevmol*findspecies("C+")->hevmol;
04468         co.hydro_source[ipMHp] += (realnum)co.CP_OH_CO_HP_1;
04469 
04470         /* CP + H2O =>  HCOP + H  */  
04471 
04472         co.CP_H2O_HCOP_H_1 = HMRATE(9.0e-10,0,0)*findspecies("H2O")->hevmol*findspecies("C+")->hevmol;
04473         co.hydro_source[ipMH] += (realnum)co.CP_H2O_HCOP_H_1;
04474 
04475         /* CP + OH =>  COP + H  */  
04476 
04477         co.CP_OH_COP_H_1 = HMRATE(7.7e-10,0,0)*findspecies("OH")->hevmol*findspecies("C+")->hevmol;
04478         co.hydro_source[ipMH] += (realnum)co.CP_OH_COP_H_1;
04479 
04480         /* O + CH =>  CO + H  */  
04481 
04482         co.O_CH_CO_H_1 = HMRATE(6.6e-11,0,0)*findspecies("CH")->hevmol*findspecies("O")->hevmol;
04483         co.hydro_source[ipMH] += (realnum)co.O_CH_CO_H_1;
04484 
04485         /* O + CHP =>  COP + H  */  
04486 
04487         co.O_CHP_COP_H_1 = HMRATE(3.5e-10,0,0)*findspecies("CH+")->hevmol*findspecies("O")->hevmol;
04488         co.hydro_source[ipMH] += (realnum)co.O_CHP_COP_H_1;
04489 
04490         /* O + CH2 =>  CO + H + H  */  
04491 
04492         co.O_CH2_CO_H_H_1 = HMRATE(1.33e-10,0,0)*findspecies("CH2")->hevmol*findspecies("O")->hevmol;
04493         co.hydro_source[ipMH] += (realnum)co.O_CH2_CO_H_H_1;
04494 
04495         /* O + CH2 =>  CO + H2 */  
04496 
04497         co.O_CH2_CO_H2_1 = HMRATE(8.0e-11,0,0)*findspecies("CH2")->hevmol*findspecies("O")->hevmol;
04498         co.hydro_source[ipMH2g] += (realnum)co.O_CH2_CO_H2_1;
04499 
04500         /* O + CH2P =>  HCOP + H  */  
04501 
04502         co.O_CH2P_HCOP_H_1 = HMRATE(7.5e-10,0,0)*findspecies("CH2+")->hevmol*findspecies("O")->hevmol;
04503         co.hydro_source[ipMH] += (realnum)co.O_CH2P_HCOP_H_1;
04504 
04505         /* O + CH3P =>  HCOP + H2  */   
04506 
04507         co.O_CH3P_HCOP_H2_1     = HMRATE(4.0e-10,0,0)*findspecies("CH3+")->hevmol*findspecies("O")->hevmol;
04508         co.hydro_source[ipMH2g] += (realnum)co.O_CH3P_HCOP_H2_1;
04509 
04510         /* O + H2OP =>  O2P + H2  */   
04511 
04512         co.O_H2OP_O2P_H2_1 = HMRATE(4.0e-11,0,0)*findspecies("H2O+")->hevmol*findspecies("O")->hevmol;
04513         co.hydro_source[ipMH2g] += (realnum)co.O_H2OP_O2P_H2_1;
04514 
04515         /* O + OH =>  O2 + H  */  
04516 
04517         co.O_OH_O2_H_1 = HMRATE(4.34e-11,-0.5,30)*findspecies("OH")->hevmol*findspecies("O")->hevmol;
04518         co.hydro_source[ipMH] += (realnum)co.O_OH_O2_H_1;
04519 
04520         /* O + OHP =>  O2P + H  */  
04521 
04522         co.O_OHP_O2P_H_1 = HMRATE(7.1e-10,0,0)*findspecies("OH+")->hevmol*findspecies("O")->hevmol;
04523         co.hydro_source[ipMH] += (realnum)co.O_OHP_O2P_H_1;
04524 
04525         /* O + SiH =>  SiO + H  */  
04526 
04527         co.O_SiH_SiO_H_1 = HMRATE(4.0e-11,0.5,0)*findspecies("SiH")->hevmol*findspecies("O")->hevmol;
04528         co.hydro_source[ipMH] += (realnum)co.O_SiH_SiO_H_1;
04529 
04530         /* O + SiH2P =>  SiOHP + H  */  
04531 
04532         co.O_SiH2P_SiOHP_H_1 = HMRATE(6.3e-10,0,0)*findspecies("SiH2+")->hevmol*findspecies("O")->hevmol;       
04533         co.hydro_source[ipMH] += (realnum)co.O_SiH2P_SiOHP_H_1;
04534 
04535         /* OP + CH =>  COP + H  */  
04536 
04537         co.OP_CH_COP_H_1 = HMRATE(3.5e-10,0,0)*findspecies("CH")->hevmol*findspecies("O+")->hevmol;
04538         co.hydro_source[ipMH] += (realnum)co.OP_CH_COP_H_1;
04539 
04540         /* OP + OH =>  O2P + H  */  
04541 
04542         co.OP_OH_O2P_H_1 = HMRATE(3.6e-10,0,0)*findspecies("OH")->hevmol*findspecies("O+")->hevmol;
04543         co.hydro_source[ipMH] += (realnum)co.OP_OH_O2P_H_1;
04544 
04545         /* Si + OH =>  SiO + H  */  
04546 
04547         co.Si_OH_SiO_H_1 = HMRATE(2.0e-10,0.5,0)*findspecies("OH")->hevmol*findspecies("Si")->hevmol;
04548         co.hydro_source[ipMH] += (realnum)co.Si_OH_SiO_H_1;
04549 
04550         /* SiP + H2O =>  SiOHP + H  */  
04551 
04552         co.SiP_H2O_SiOHP_H_1 = HMRATE(2.3e-10,0,0)*findspecies("H2O")->hevmol*findspecies("Si+")->hevmol;                       
04553         co.hydro_source[ipMH] += (realnum)co.SiP_H2O_SiOHP_H_1;
04554 
04555         /* SiP + OH =>  SiOP + H  */  
04556 
04557         co.SiP_OH_SiOP_H_1 = HMRATE(6.3e-10,0,0)*findspecies("OH")->hevmol*findspecies("Si+")->hevmol;          
04558         co.hydro_source[ipMH] += (realnum)co.SiP_OH_SiOP_H_1;
04559 
04560         /* CHP + H2O =>  HCOP +  H2  */   
04561 
04562         co.CHP_H2O_HCOP_H2_1 = HMRATE(2.9e-9,0,0)*findspecies("H2O")->hevmol*findspecies("CH+")->hevmol;                        
04563         co.hydro_source[ipMH2g] += (realnum)co.CHP_H2O_HCOP_H2_1;
04564 
04565         /* CHP + OH =>  COP + H2  */   
04566 
04567         co.CHP_OH_COP_H2_1 = HMRATE(7.5e-10,0,0)*findspecies("OH")->hevmol*findspecies("CH+")->hevmol;          
04568         co.hydro_source[ipMH2g] += (realnum)co.CHP_OH_COP_H2_1;
04569 
04570         /* H + C =>  CH + nu  */
04571 
04572         co.H_C_CH_nu = HMRATE(0.00000000000000001,0,0)*dense.xIonDense[ipHYDROGEN][0]*findspecies("C")->hevmol;
04573         co.hydro_sink[ipMH] += (realnum)co.H_C_CH_nu;
04574 
04575         /* H + CP =>  CHP + nu  */
04576 
04577         co.H_CP_CHP_nu = HMRATE(1.7e-17,0,0)*findspecies("C+")->hevmol*dense.xIonDense[ipHYDROGEN][0];  
04578         co.hydro_sink[ipMH] += (realnum)co.H_CP_CHP_nu;
04579 
04580         /* H + OH =>  H2O + nu  */
04581 
04582         co.H_OH_H2O_nu = HMRATE(5.26E-18,-5.22,90)*findspecies("OH")->hevmol*dense.xIonDense[ipHYDROGEN][0];    
04583         co.hydro_sink[ipMH] += (realnum)co.H_OH_H2O_nu;
04584 
04585         /* Hminus + CH =>  CH2 + e  */
04586 
04587         co.Hminus_CH_CH2_e = HMRATE(1.0e-10,0,0)*findspecies("CH")->hevmol*hmi.Hmolec[ipMHm];           
04588         co.hydro_sink[ipMHm] += (realnum)co.Hminus_CH_CH2_e;
04589 
04590         /* Hminus + C =>  CH + e  */
04591 
04592         co.Hminus_C_CH_e = HMRATE(1.0e-9,0,0)*findspecies("C")->hevmol*hmi.Hmolec[ipMHm];       
04593         co.hydro_sink[ipMHm] += (realnum)co.Hminus_C_CH_e;
04594 
04595         /* Hminus + OH =>  H2O + e  */
04596 
04597         co.Hminus_OH_H2O_e = HMRATE(1.0e-10,0,0)*findspecies("OH")->hevmol*hmi.Hmolec[ipMHm];                   
04598         co.hydro_sink[ipMHm] += (realnum)co.Hminus_OH_H2O_e;
04599 
04600         /* Hminus + O =>  OH + e  */
04601 
04602         co.Hminus_O_OH_e = HMRATE(1.0e-9,0,0)*findspecies("O")->hevmol*hmi.Hmolec[ipMHm];                               
04603         co.hydro_sink[ipMHm] += (realnum)co.Hminus_O_OH_e;
04604 
04605         /* H2 + C =>  CH2 + nu  */
04606 
04607         co.H2_C_CH2_nu = HMRATE(1.0e-17,0,0)*findspecies("C")->hevmol*hmi.Hmolec[ipMH2g];               
04608         co.hydro_sink[ipMH2g] += (realnum)co.H2_C_CH2_nu;
04609 
04610         /* H2 + CP =>  CH2P + nu  */
04611 
04612         co.H2_CP_CH2P_nu = HMRATE(4.0e-16,-0.2,0)*findspecies("C+")->hevmol*hmi.Hmolec[ipMH2g];                 
04613         co.hydro_sink[ipMH2g] += (realnum)co.H2_CP_CH2P_nu;
04614 
04615         /* H2 + SiP =>  SiH2P + nu  */
04616 
04617         co.H2_SiP_SiH2P_nu = HMRATE(3.0e-18,0,0)*findspecies("Si+")->hevmol*hmi.Hmolec[ipMH2g]; 
04618         co.hydro_sink[ipMH2g] += (realnum)co.H2_SiP_SiH2P_nu;
04619 
04620         /* H2 + O2 =>  OH + OH */
04621 
04622         co.H2_O2_OH_OH = HMRATE(3.16e-10,0,21890)*findspecies("O2")->hevmol*hmi.Hmolec[ipMH2g];
04623         co.hydro_sink[ipMH2g] += (realnum)co.H2_O2_OH_OH;
04624 
04625         /* HeP + CH =>  CP + He + H  */
04626 
04627         co.HeP_CH_CP_He_H = HMRATE(1.1e-9,0,0)*findspecies("CH")->hevmol*dense.xIonDense[ipHELIUM][1];  
04628         co.hydro_source[ipMH] += (realnum)co.HeP_CH_CP_He_H;
04629 
04630         /* HeP + CH2 =>  CHP + He + H  */
04631 
04632         co.HeP_CH2_CHP_He_H = HMRATE(7.5e-10,0,0)*findspecies("CH2")->hevmol*dense.xIonDense[ipHELIUM][1];      
04633         co.hydro_source[ipMH] += (realnum)co.HeP_CH2_CHP_He_H;
04634 
04635         /* HeP + OH =>  OP + He + H  */
04636 
04637         co.HeP_OH_OP_He_H = HMRATE(1.1e-9,0,0)*findspecies("OH")->hevmol*dense.xIonDense[ipHELIUM][1];  
04638         co.hydro_source[ipMH] += (realnum)co.HeP_OH_OP_He_H;
04639 
04640         /* HeP + H2O  OHP + He + H  */
04641 
04642         co.HeP_H2O_OHP_He_H = HMRATE(2.86e-10,0,0)*findspecies("H2O")->hevmol*dense.xIonDense[ipHELIUM][1];     
04643         co.hydro_source[ipMH] += (realnum)co.HeP_H2O_OHP_He_H;
04644 
04645         /* HeP + SiH =>  SiP + He + H  */
04646 
04647         co.HeP_SiH_SiP_He_H = HMRATE(1.8e-9,0,0)*findspecies("SiH")->hevmol*dense.xIonDense[ipHELIUM][1];       
04648         co.hydro_source[ipMH] += (realnum)co.HeP_SiH_SiP_He_H;
04649 
04650         /* HeP + H2O =>  OH + He + HP */
04651 
04652         co.HeP_H2O_OH_He_HP = HMRATE(2.04e-10,0,0)*findspecies("H2O")->hevmol*dense.xIonDense[ipHELIUM][1];     
04653         co.hydro_source[ipMHp] += (realnum)co.HeP_H2O_OH_He_HP;
04654 
04655         /* HeP + CH2 =>  CP + He + H2  */
04656 
04657         co.HeP_CH2_CP_He_H2 = HMRATE(7.5e-10,0,0)*findspecies("CH2")->hevmol*dense.xIonDense[ipHELIUM][1];      
04658         co.hydro_source[ipMH2g] += (realnum)co.HeP_CH2_CP_He_H2;
04659 
04660         /* crnu + CH =>  C + H  */
04661 
04662         co.crnu_CH_C_H = findspecies("CH")->hevmol*secondaries.csupra[ipHYDROGEN ][0] * 2. * 756;
04663         co.hydro_source[ipMH] += (realnum)co.crnu_CH_C_H;
04664 
04665         /* crnu + CHP =>  CP + H  */
04666 
04667         co.crnu_CHP_CP_H = findspecies("CH+")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. * 183;     
04668         co.hydro_source[ipMH] += (realnum)co.crnu_CHP_CP_H;
04669 
04670         /* crnu + H2O =>  OH + H  */
04671 
04672         co.crnu_H2O_OH_H = findspecies("H2O")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. * 979;     
04673         co.hydro_source[ipMH] += (realnum)co.crnu_H2O_OH_H;
04674 
04675         /* crnu + OH =>  O + H  */
04676 
04677         co.crnu_OH_O_H = findspecies("OH")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. *522;
04678         co.hydro_source[ipMH] += (realnum)co.crnu_OH_O_H;
04679 
04680         /* crnu + SiH =>  Si + H  */
04681 
04682         co.crnu_SiH_Si_H = findspecies("SiH")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. *500;      
04683         co.hydro_source[ipMH] += (realnum)co.crnu_SiH_Si_H;
04684 
04685         /* nu + CH =>  C + H  */
04686 
04687         co.nu_CH_C_H = HMRATE(8.6e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH")->hevmol;
04688         co.hydro_source[ipMH] += (realnum)co.nu_CH_C_H;
04689 
04690         /* nu + CHP =>  CP + H  */
04691 
04692         co.nu_CHP_CP_H = HMRATE(2.5e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH+")->hevmol;
04693         co.hydro_source[ipMH] += (realnum)co.nu_CHP_CP_H;
04694 
04695         /* nu + CH2 =>  CH + H  */
04696 
04697         co.nu_CH2_CH_H = HMRATE(7.2e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH2")->hevmol;      
04698         co.hydro_source[ipMH] += (realnum)co.nu_CH2_CH_H;
04699 
04700         /* nu + CH2P =>  CHP + H  */
04701 
04702         co.nu_CH2P_CHP_H = HMRATE(1.7e-9,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH2+")->hevmol;            
04703         co.hydro_source[ipMH] += (realnum)co.nu_CH2P_CHP_H;
04704 
04705         /* nu + CH3P =>  CH2P + H  */
04706 
04707         co.nu_CH3P_CH2P_H = HMRATE(1.0e-9,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH3+")->hevmol;           
04708         co.hydro_source[ipMH] += (realnum)co.nu_CH3P_CH2P_H;
04709 
04710         /* nu + CH3P =>  CHP + H2  */
04711 
04712         co.nu_CH3P_CHP_H2 = HMRATE(1.0e-9,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH3+")->hevmol;                   
04713         co.hydro_source[ipMH2g] += (realnum)co.nu_CH3P_CHP_H2;
04714 
04715         /* nu + H2O =>  OH + H  */
04716 
04717         co.nu_H2O_OH_H = HMRATE(5.9e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("H2O")->hevmol;              
04718         co.hydro_source[ipMH] += (realnum)co.nu_H2O_OH_H;
04719 
04720         /* nu + OH =>  O + H  */
04721 
04722         co.nu_OH_O_H = HMRATE(3.5e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("OH")->hevmol;                 
04723         co.hydro_source[ipMH] += (realnum)co.nu_OH_O_H;
04724 
04725         /* nu + OHP =>  O + HP */
04726 
04727         co.nu_OHP_O_HP = HMRATE(1.0e-12,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("OH+")->hevmol;              
04728         co.hydro_source[ipMHp] += (realnum)co.nu_OHP_O_HP;
04729 
04730         /* nu + SiH =>  Si + H  */
04731 
04732         co.nu_SiH_Si_H = HMRATE(2.8e-9,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("SiH")->hevmol;       
04733         co.hydro_source[ipMH] += (realnum)co.nu_SiH_Si_H;
04734 
04735         /* e + CHP =>  C + H  */
04736 
04737         co.e_CHP_C_H = HMRATE(1.5e-7,-0.42,0)*dense.eden*findspecies("CH+")->hevmol;    
04738         co.hydro_source[ipMH] += (realnum)co.e_CHP_C_H;
04739 
04740         /* e + CH2P =>  CH + H  */
04741 
04742         co.e_CH2P_CH_H = HMRATE(1.6e-7,-0.6,0)*dense.eden*findspecies("CH2+")->hevmol;  
04743         co.hydro_source[ipMH] += (realnum)co.e_CH2P_CH_H;
04744 
04745         /* e + CH2P =>  C + H + H  */
04746 
04747         co.e_CH2P_C_H_H = HMRATE(4.03e-7,-0.6,0)*dense.eden*findspecies("CH2+")->hevmol;        
04748         co.hydro_source[ipMH] += (realnum)co.e_CH2P_C_H_H;
04749 
04750         /* e + CH2P =>  C + H2  */
04751 
04752         co.e_CH2P_C_H2 = HMRATE(7.68e-8,-0.6,0)*dense.eden*findspecies("CH2+")->hevmol; 
04753         co.hydro_source[ipMH2g] += (realnum)co.e_CH2P_C_H2;
04754 
04755         /* e + CH3P =>  C + H2 + H  */
04756 
04757         co.e_CH3P_C_H2_H = HMRATE(1.05e-7,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;               
04758         co.hydro_source[ipMH] += (realnum)co.e_CH3P_C_H2_H;
04759         co.hydro_source[ipMH2g] += (realnum)co.e_CH3P_C_H2_H;
04760 
04761         /* e + CH3P =>  CH2 + H  */
04762 
04763         co.e_CH3P_CH2_H = HMRATE(1.4e-7,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;
04764         co.hydro_source[ipMH] += (realnum)co.e_CH3P_CH2_H;
04765 
04766         /* e + CH3P =>  CH + H + H  */
04767 
04768         co.e_CH3P_CH_H_H = HMRATE(5.6e-8,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;        
04769         co.hydro_source[ipMH] += (realnum)co.e_CH3P_CH_H_H;
04770 
04771         /* e + CH3P =>  CH + H2  */
04772 
04773         co.e_CH3P_CH_H2 = HMRATE(4.9e-8,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;
04774         co.hydro_source[ipMH2g] += (realnum)co.e_CH3P_CH_H2;
04775 
04776         /* e + H2OP =>  OH + H  */
04777 
04778         co.e_H2OP_OH_H = HMRATE(7.92e-8,-0.5,0)*dense.eden*findspecies("H2O+")->hevmol;
04779         co.hydro_source[ipMH] += (realnum)co.e_H2OP_OH_H;
04780 
04781         /* e + H2OP =>  O + H + H  */
04782 
04783         co.e_H2OP_O_H_H = HMRATE(2.45e-7,-0.5,0)*dense.eden*findspecies("H2O+")->hevmol;
04784         co.hydro_source[ipMH] += (realnum)co.e_H2OP_O_H_H;
04785 
04786         /* e + H2OP =>  O + H2  */
04787 
04788         co.e_H2OP_O_H2 = HMRATE(3.6e-8,-0.5,0)*dense.eden*findspecies("H2O+")->hevmol;
04789         co.hydro_source[ipMH2g] += (realnum)co.e_H2OP_O_H2;
04790 
04791         /* e + H3OP =>  H2O + H  */
04792 
04793         co.e_H3OP_H2O_H = HMRATE(1.08e-7,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;
04794         co.hydro_source[ipMH] += (realnum)co.e_H3OP_H2O_H;
04795 
04796         /* e + H3OP =>  OH + H + H  */
04797 
04798         co.e_H3OP_OH_H_H = HMRATE(2.58e-7,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;       
04799         co.hydro_source[ipMH] += (realnum)co.e_H3OP_OH_H_H;
04800 
04801         /* e + H3OP =>  OH + H2  */
04802 
04803         co.e_H3OP_OH_H2 = HMRATE(6.45e-8,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;
04804         co.hydro_source[ipMH2g] += (realnum)co.e_H3OP_OH_H2;
04805 
04806         /* e + H3OP =>  O + H2 + H  */
04807 
04808         co.e_H3OP_O_H2_H = HMRATE(5.59e-9,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;       
04809         co.hydro_source[ipMH] += (realnum)co.e_H3OP_O_H2_H;
04810 
04811         /* e + HCOP =>  CO + H  */
04812 
04813         co.e_HCOP_CO_H = HMRATE(1.1e-7,-1,0)*dense.eden*findspecies("HCO+")->hevmol;
04814         co.hydro_source[ipMH] += (realnum)co.e_HCOP_CO_H;
04815 
04816         /* e + OHP =>  O + H  */
04817 
04818         co.e_OHP_O_H = HMRATE(3.75e-8,-0.5,0)*dense.eden*findspecies("OH+")->hevmol;
04819         co.hydro_source[ipMH] += (realnum)co.e_OHP_O_H;
04820 
04821         /* e + SiH2P =>  SiH + H  */
04822 
04823         co.e_SiH2P_SiH_H = HMRATE(1.5e-7,-0.5,0)*dense.eden*findspecies("SiH2+")->hevmol;       
04824         co.hydro_source[ipMH] += (realnum)co.e_SiH2P_SiH_H;
04825 
04826         /* e + SiH2P =>  Si + H + H  */
04827 
04828         co.e_SiH2P_Si_H_H = HMRATE(2.0e-7,-0.5,0)*dense.eden*findspecies("SiH2+")->hevmol;      
04829         co.hydro_source[ipMH] += (realnum)co.e_SiH2P_Si_H_H;
04830 
04831         /* e + SiH2P =>  Si + H2  */
04832 
04833         co.e_SiH2P_Si_H2 = HMRATE(1.5e-7,-0.5,0)*dense.eden*findspecies("SiH2+")->hevmol;       
04834         co.hydro_source[ipMH2g] += (realnum)co.e_SiH2P_Si_H2;
04835 
04836         /* e + SiOHP =>  SiO + H  */
04837 
04838         co.e_SiOHP_SiO_H = HMRATE(1.5e-7,-0.5,0)*dense.eden*findspecies("SiOH+")->hevmol;       
04839         co.hydro_source[ipMH] += (realnum)co.e_SiOHP_SiO_H;
04840 
04841         /* H2 + CH =>  CH3 + nu  */
04842 
04843         co.H2_CH_CH3_nu = HMRATE(5.09E-18,-0.71,11.6)*findspecies("H2")->hevmol*findspecies("CH")->hevmol;
04844         co.hydro_sink[ipMH2g] += (realnum)co.H2_CH_CH3_nu;
04845 
04846         /* H2 + CH3P =>  CH5P + nu  */
04847 
04848         co.H2_CH3P_CH5P_nu = HMRATE(1.3e-15,-1,0)*findspecies("CH3+")->hevmol*hmi.Hmolec[ipMH2g];       
04849         co.hydro_sink[ipMH2g] += (realnum)co.H2_CH3P_CH5P_nu;
04850 
04851         /* H2s + CH =>  CH3 + nu  */
04852 
04853         co.H2s_CH_CH3_nu = HMRATE(5.09E-18,-0.71,0)*findspecies("CH")->hevmol*hmi.Hmolec[ipMH2s]*hmi.lgLeiden_Keep_ipMH2s;      
04854         co.hydro_sink[ipMH2s] += (realnum)co.H2s_CH_CH3_nu;
04855 
04856         /* Hminus + CH2 =>  CH3 + e  */
04857 
04858         co.Hminus_CH2_CH3_e     = HMRATE(1.0e-9,0,0)*findspecies("CH2")->hevmol*hmi.Hmolec[ipMHm];      
04859         co.hydro_sink[ipMHm] += (realnum)co.Hminus_CH2_CH3_e;
04860 
04861         /* Hminus + CH3 =>  CH4 + e  */
04862 
04863         co.Hminus_CH3_CH4_e     = HMRATE(1.0e-9,0,0)*findspecies("CH3")->hevmol*hmi.Hmolec[ipMHm];      
04864         co.hydro_sink[ipMHm] += (realnum)co.Hminus_CH3_CH4_e;
04865 
04866         /* nu + CH3 =>  CH2 + H  */
04867 
04868         co.nu_CH3_CH2_H = HMRATE(2.5e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH3")->hevmol;
04869         co.hydro_source[ipMH] += (realnum)co.nu_CH3_CH2_H;
04870 
04871         /* nu + CH3 =>  CH + H2  */
04872 
04873         co.nu_CH3_CH_H2 = HMRATE(2.5e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH3")->hevmol;
04874         co.hydro_source[ipMH2g] += (realnum)co.nu_CH3_CH_H2;
04875 
04876         /* nu + CH4 =>  CH3 + H  */
04877 
04878         co.nu_CH4_CH3_H = HMRATE(2.2e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH4")->hevmol;
04879         co.hydro_source[ipMH] += (realnum)co.nu_CH4_CH3_H;
04880 
04881         /* nu + CH4 =>  CH2 + H2  */
04882 
04883         co.nu_CH4_CH2_H2 = HMRATE(9.8e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH4")->hevmol;    
04884         co.hydro_source[ipMH2g] += (realnum)co.nu_CH4_CH2_H2;
04885 
04886         /* nu + CH4 =>  CH + H2  */
04887 
04888         co.nu_CH4_CH_H2 = HMRATE(2.2e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH4")->hevmol;
04889         co.hydro_source[ipMH2g] += (realnum)co.nu_CH4_CH_H2;
04890 
04891         /* crnu + CH3 =>  CH2 + H  */
04892 
04893         co.crnu_CH3_CH2_H = findspecies("CH3")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2.*500;      
04894         co.hydro_source[ipMH] += (realnum)co.crnu_CH3_CH2_H;
04895 
04896         /* crnu + CH3 =>  CH + H2  */
04897 
04898         co.crnu_CH3_CH_H2 = findspecies("CH3")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2.*500;      
04899         co.hydro_source[ipMH2g] += (realnum)co.crnu_CH3_CH_H2;
04900 
04901         /* crnu + CH4 =>  CH2 + H2  */
04902 
04903         co.crnu_CH4_CH2_H2 = findspecies("CH4")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2.*2272;    
04904         co.hydro_source[ipMH2g] += (realnum)co.crnu_CH4_CH2_H2;
04905 
04906         /* e + CH5P =>  CH3 + H2  */
04907 
04908         co.e_CH5P_CH3_H2 = HMRATE(5.5e-7,-0.3,0)*dense.eden*findspecies("CH5+")->hevmol;        
04909         co.hydro_source[ipMH2g] += (realnum)co.e_CH5P_CH3_H2;
04910 
04911         /* e + CH5P =>  CH4 + H  */
04912 
04913         co.e_CH5P_CH4_H = HMRATE(5.5e-7,-0.3,0)*dense.eden*findspecies("CH5+")->hevmol;
04914         co.hydro_source[ipMH] += (realnum)co.e_CH5P_CH4_H;
04915 
04916         /* e + CH4P =>  CH3 + H  */
04917 
04918         co.e_CH4P_CH3_H = HMRATE(1.75e-7,-0.5,0)*dense.eden*findspecies("CH4+")->hevmol;
04919         co.hydro_source[ipMH] += (realnum)co.e_CH4P_CH3_H;
04920 
04921         /* e + CH4P =>  CH2 + H + H  */
04922 
04923         co.e_CH4P_CH2_H_H = HMRATE(1.75e-7,-0.5,0)*dense.eden*findspecies("CH4+")->hevmol;      
04924         co.hydro_source[ipMH] += (realnum)co.e_CH4P_CH2_H_H;
04925 #       endif
04926         /******* END OF REACTIONS ********/
04927 #       if 0
04928         if( iteration>1 )
04929         {
04930                 r = rlist;
04931                 i = 0;
04932                 while (r->next != NULL)
04933                 {
04934                         ++i;
04935                         r = r->next;
04936                         fprintf(ioQQQ,"DEBUG r\t%li\t%.3e\n", i, r->rk);
04937                 }
04938         }
04939 #       endif
04940 
04941         /* Generate chemical error vector and Jacobian array from reaction list */
04942         for( i=0; i < N_H_MOLEC; i++ )
04943         {
04944                 bvec[i] = 0.;
04945                 for( j=0; j < N_H_MOLEC; j++ )
04946                 {
04947                         c[j][i] = 0.;
04948                 }
04949         }
04950         /* Subtotal rates for H_0 and H^+ within ipMHo */
04951         for(i=0;i<2;i++) 
04952         {
04953                 mole.source[ipHYDROGEN][i] = mole.sink[ipHYDROGEN][i] = 0.;
04954         }
04955 
04956         /* reinitialize linked list and move through it */
04957         /* set up Jacobian matrix */
04958         r = rlist;
04959 
04960         /*  Comments about this line of code, made by Nick Abel.  This section of the code
04961                 does the same thing as in co.c, where it decouples products of two densities
04962                 that the code is trying to predict. Reactions of the form n(X)*n(Y) cannot be 
04963                 treated properly in a linear solver otherwise.
04964 
04965                 This section of the code starts off with a while
04966                 statement that loops over all reactions in the network (hence the r->next variable).
04967                 For each reaction, the first thing that is done is to state that for the reaction
04968                 of interest, the rate coefficient k is equal to r->rk, which is the stored value from
04969                 when the reaction was originally set up above.  After this a loop over all reactants is 
04970                 performed.  This is actually a double loop.  If the number of reactants is greater than 
04971                 one, then this code will generate (via the i!=j if statement) two "decoupled" products of 
04972                 the rate coefficient times the previous solution for the density.  This is explained in co.c 
04973                 and in that code it is just the reaction rates that end in _1 or _2. 
04974 
04975                 After this loop the     variable "rate" is multiplied by the the density that was not multiplied
04976                 in the loop.  This sets up "rate" to be what co.c calls "bvec" for that reaction. The bvec's 
04977                 are needed because in the process of "decoupling" a reaction, their is a leftover term of
04978                 the form k*n(X)old*n(Y)old which has to go into the solution vector for the matrix equation Ax = b.
04979 
04980                 The next two loops set up the bvec so that it goes with the proper species.  Also, in the
04981                 case of H and H+, these rates are saved so that they can be fed into the main ionization 
04982                 solver.  This allows Cloudy to account for formation and destruction processes
04983                 for Hydrogen that are due to reaction with molecules.  
04984 
04985                 The last for statement inside the while loop takes the rates that were calculated previously 
04986                 and stores them in the appropriate part of the matrix A. */
04987 
04988         /* rates complete - all reactions have been stored, now fill in the c[][] matrix */
04989         while (r->next != NULL)
04990         {
04991                 r = r->next;
04992                 /* >>chng 04 feb 05, this was option to cut chemistry short in testing
04993                 if(r->index == rindex)
04994                         break;*/
04995                 rk = r->rk;
04996 
04997                 /* if this blows, rk is NaN */
04998                 /*ASSERT( rk == rk );*/
04999                 ASSERT( !isnan( rk ) );
05000 
05001                 /* There's an O(n) algorithm for this -- but it doesn't improve
05002                  * things unless nreactants is >= 4...!*/
05003                 /* loop over all rate determining species */
05004                 for(i=0;i<r->nrates;i++)
05005                 {
05006                         rate_deriv[i] = rk;
05007                         for(j=0;j<r->nrates;j++)
05008                         {
05009                                 /* Hmolec_old was previous abundance,
05010                                  * rate_deriv[i] is derivative of rates coefficient by species r->rate_species[i] */
05011                                 if(i!=j)
05012                                 {
05013                                         rate_deriv[i] *= Hmolec_old[r->rate_species[j]];
05014                                         /* if this blows, rate_deriv[i] is NaN */
05015                                         /*ASSERT( rate_deriv[i] == rate_deriv[i] );*/
05016                                         ASSERT( !isnan( rate_deriv[i] ) );
05017                                 }
05018                         }
05019                 }
05020 
05021                 /* this is total rate, rate_deriv times old population */
05022                 rate = rate_deriv[0]*Hmolec_old[r->rate_species[0]];
05023 
05024                 /* is this blows, rate is NaN */
05025                 ASSERT( !isnan( rate ) );
05026 
05027                 /* Get sink terms (i.e. rate/abundance) to include in ionization ladders */
05028                 for(i=0;i < r->nreactants;i++)
05029                 {
05030                         int ok = 0;
05031                         for(j=0;j < r->nrates && !ok;j++)
05032                         {
05033                                 if(r->rate_species[j] == r->reactants[i]) 
05034                                 {
05035                                         sinkrate[i] = rate_deriv[j];
05036                                         ok = true;
05037                                 }
05038                         }
05039                         if(!ok) 
05040                         {
05041                                 /* Odd, the rate didn't depend on one of the species it used
05042                                  * at all!  An alternative way of getting sink rate is
05043                                  *
05044                                  * sinkrate[i] = rate/Hmolec_old[r->reactants[i]]; 
05045                                  *
05046                                  * but this uses the possibly zero Hmolec_old, and is prone to underflow of rate.
05047                                  * */
05048                                 fprintf(ioQQQ,"A chemical rate in hmole was independent of the species it used\n");
05049                                 fprintf(ioQQQ,"This probably shouldn't happen (so you shouldn't see this message).\n");
05050                                 cdEXIT(EXIT_FAILURE);
05051                         }
05052                 }
05053 
05054                 /* if(nzone == 416)
05055                          fprintf(ioQQQ,"Adding reaction %d rate %g\n",r->index,rate); */
05056 
05057                 /* loop over all reactions, find total consumption rate,
05058                  * also keep track of rates that use up H0 or H+ */
05059                 for(i=0;i<r->nreactants;i++)
05060                 {
05061                         ratei = r->reactants[i];
05062                         bvec[ratei] -= rate;
05063                         /*if((nzone == 421 || nzone == 422) && ratei == ipMHm)
05064                                         fprintf(ioQQQ,"snk %s %d %g\n",hmi.chLab[ratei],r->index,rate);*/
05065                         /* mole.sink[ipHYDROGEN] is how chemical reaction network reacts with ionization
05066                          * network, so this keeps track of total rates */
05067                         if(ratei == ipMH || ratei == ipMHp)
05068                                 mole.sink[ipHYDROGEN][ratei] += sinkrate[i];
05069                 }
05070 
05071                 /* loop over all reactions, find total production rate,
05072                  * also keep track of rates that produce H0 or H+ */
05073                 for(i=0;i<r->nproducts;i++)
05074                 {
05075                         ratei = r->products[i];
05076                         bvec[ratei] += rate;
05077                         /*if((nzone == 421 || nzone == 422) && ratei == ipMHm)
05078                                         fprintf(ioQQQ,"src %s %d %g\n",hmi.chLab[ratei],r->index,rate); */
05079                         if(ratei == ipMH || ratei == ipMHp)
05080                         {
05081                                 mole.source[ipHYDROGEN][ratei] += rate;
05082 
05083                                 /* confirm mole.source[ipHYDROGEN][ratei] is valid float */
05084                                 ASSERT( !isnan( mole.source[ipHYDROGEN][ratei] ) );
05085                         }
05086                 }
05087 
05088                 /* The first thing that must be said about the for statements below is that 
05089                  * it is inside a while statement (starting on line 4151).  This while loops over
05090                  * all reactions. Each individual reaction is stored with the pointer r->next,
05091                  * which goes from 1 to the number of reactions in the hmole_step.  Also, for
05092                  * each reaction, the code keeps track of the number of products and reactants
05093                  * in reaction r->next, what each product or reactant is 
05094                  * (H2, H2*, H3+, et cetera), and the reaction rate coefficient.
05095                  *
05096                  *      For example, if the first reaction is H2 + H+ => H2+ + H, then:          
05097                  *
05098                  *      r->next = 1 (this is the first reaction)
05099                  *      r->nreactants[i] = 2 (the number of reactants equals two)
05100                  *      r->nproducts[i] = 2  (the number of products equals two)
05101                  *      r->nrates =  (unless the reactant is repeated, such as H2 + H2 => H2* + H2, 
05102                  *                  then r->nrates is always the number of reactants (see line 107)
05103                  *
05104                  *      rate_deriv[j] = reaction rate determined from lines (4161-4173), 
05105                  *                              this is the product of the rate coefficient k and the density of
05106                  *                              one of the reactants.
05107                  *
05108                  *      r->rate_species[j], r->reactants[i], and r->products[i] is the species
05109                  *                              corresponding to each product or reactant.
05110                  *
05111                  *
05112                  *
05113                  *      So H2 + H+ => H2+ + H does the following in the code below.
05114                  *
05115                  *
05116                  *      1)  Since nrates = 2, the for loop goes over all reactants, 1 and 2. 
05117                  *              The first reactant considered is 1
05118                  *      2)  ratej is set equal to H2, and rated is equal to k*[density of H+]
05119                  *      3)  The second for statement  loops over all reactants, and puts
05120                  *              fills in some matrix elements:
05121                  *
05122                  *              c[ipMH2g][ipMH2g] -= k*[density of H+]
05123                  *              c[ipMH2g][ipMHp] -=k*[density of H+]
05124                  *
05125                  *      4)  Now the third for statement fills in some more reactions,
05126                  *              involving the products:
05127                  *
05128                  *              c[ipMH2g][ipMH2p] += k*[density of H+]
05129                  *              c[ipMH2g][ipMH] += k*[density of H+]
05130                  *
05131                  *      5)  At this state, we go back up to the first for statement,
05132                  *              and the reactant is changed from 1 to 2 (H+)
05133                  *      6)  Also ratej is set to H+ and rated is now k*[density of H2]
05134                  *      7)  Some more matrix elements are filled in:
05135                  *
05136                  *              c[ipMHp][ipMH2g] -= k*[density of H2]
05137                  *              c[ipMHp][ipMHp] -= k*[density of H2]
05138                  *
05139                  *              c[ipMHp][ipMH2p] += k*[density of H2]
05140                  *              c[ipMHp][ipMH] += k*[density of H2]
05141                  *
05142                  *              This is the more elegant way of linearizing the series of non-linear
05143                  *              equations in the molecular network, incorporated by Robin Williams.
05144                  *              co.c does the same thing more explicitly, but also takes up way too 
05145                  *              much space. */
05146 
05147 
05148                 /* fill Jacobian rate matrix */
05149                 for(j=0;j<r->nrates;j++)
05150                 {
05151                         ratej = r->rate_species[j];
05152                         rated = rate_deriv[j];
05153                         for(i=0;i<r->nreactants;i++)
05154                         {
05155                                 c[ratej][r->reactants[i]] -= rated;
05156                         }
05157                         for(i=0;i<r->nproducts;i++)
05158                         {
05159                                 c[ratej][r->products[i]] += rated;
05160                         }
05161                 }
05162         }
05163         /* the c[][] matrix Jacobian array has now been filled with all reagents */
05164 
05165         /* save rate H2 is destroyed units s-1 */
05166         /* >>chng 05 mar 18, TE, add terms - 
05167                 total destruction rate is: dest_tot = n_H2g/n_H2tot * dest_H2g + n_H2s/n_H2tot * dest_H2s */
05168         /* as reactions that change H2s to H2g and vice versa are not counted destruction processes, the terms c[ipMH2g][ipMH2s] *
05169            and c[ipMH2s][ipMH2g], which have a different sign than [ipMH2g][ipMH2g] and [ipMH2s][ipMH2s], have to be added      */
05170         hmi.H2_rate_destroy = (hmi.Hmolec[ipMH2g] * (-c[ipMH2g][ipMH2g]-c[ipMH2g][ipMH2s]) +
05171                                                         hmi.Hmolec[ipMH2s] * (-c[ipMH2s][ipMH2s]-c[ipMH2s][ipMH2g])) / SDIV(hmi.H2_total);
05172 
05173         {
05174                 /* following should be set true to print populations */
05175                 enum {DEBUG_LOC=false};
05176                 if( DEBUG_LOC )
05177                 {
05178                         if( DEBUG_LOC && (nzone > 570) ) 
05179                         {
05180                                 printsol = 1;
05181                                 fprintf(ioQQQ,"Temperature %g\n",phycon.te);
05182                                 fprintf(ioQQQ," Net mol ion rate [%g %g] %g\n",mole.source[ipHYDROGEN][1],mole.sink[ipHYDROGEN][1],
05183                                                                 mole.source[ipHYDROGEN][1]-mole.sink[ipHYDROGEN][1]*Hmolec_old[ipMHp]);
05184                         }
05185                 }
05186         }
05187 
05188         /* save total H2P destruction rate for possible later printout:
05189          * NB this must come last */
05190         desh2p = -c[ipMH2p][ipMH2p]; 
05191 
05192         /* Check that matrix and vector generated in above loops make sense */
05193         /*if(!defined(NDEBUG))  */
05194         /* in std C NDEBUG is a macro set at compile time */
05197 #       if 0
05198 /*#     if !defined(NDEBUG)*/
05199 #       ifndef NDEBUG
05200         {
05201                 double total, mtotal;
05202                 for(i=0;i<N_H_MOLEC;i++) 
05203                 {
05204                         total = 0.;
05205                         for( j=0;j<N_H_MOLEC;j++) 
05206                         {
05207                                 total += c[i][j]*hmi.nProton[j];
05208                         }
05209                         if( fabs(total) > 1e-5*fabs(c[i][i]*hmi.nProton[i])) 
05210                         {
05211                                 fprintf(ioQQQ,"PROBLEM Subtotal1 %.2e\n",fabs(total)/fabs(c[i][i]*hmi.nProton[i]));
05212                                 fprintf(ioQQQ,"Species %li Total %g Diag %g\n",i,total,c[i][i]*hmi.nProton[i]);
05213                         }
05214                         else if( fabs(total) > 1e-6*fabs(c[i][i]*hmi.nProton[i]) && phycon.te< 1e6 ) 
05215                         {
05216                                 fprintf(ioQQQ,"NOTE Subtotal1 %.2e Te=%.4e\n",
05217                                         fabs(total)/fabs(c[i][i]*hmi.nProton[i]),phycon.te);
05218                                 fprintf(ioQQQ,"Species %li Total %g Diag %g\n",i,total,c[i][i]*hmi.nProton[i]);
05219                         }
05220                 }
05221                 total = mtotal = 0.;
05222                 for(j=0;j<N_H_MOLEC;j++) 
05223                 { 
05224                         total += bvec[j]*hmi.nProton[j]; 
05225                         mtotal += fabs(bvec[j]*hmi.nProton[j]); 
05226                 }
05227                 if(fabs(total) > 1e-30 && fabs(total) > 1e-10*rtot) 
05228                 { 
05229                         fprintf(ioQQQ,"PROBLEM Subtotal2 %.2e\n",fabs(total)/mtotal);
05230                         fprintf(ioQQQ,"RHS Total %g cf %g\n",total,mtotal);
05231                 } 
05232                 else if(fabs(total) > 1e-7*mtotal)  
05233                 {
05234                         fprintf(ioQQQ,"WARNING zone %li Hmole RHS conservation error %.2e of %.2e\n",nzone,total,mtotal);
05235                         fprintf(ioQQQ,"(may be due to high rate equilibrium reactions)\n");
05236                 }
05237         }
05238 #               endif
05239 #       endif
05240 
05241 
05242 #define MOLMIN  1
05243 #define N_H_MAT (N_H_MOLEC-MOLMIN)
05244         /* Will collapse ipMH and ipMHp into single species, as don't include
05245          * all ionizations and recombinations here */
05246         /* last test - do not include advection if we have overrun the radius scale 
05247          * of previous iteration */
05248         /* >>chng 06 mar 17, comment out test on old full depth - keep old solution if overrun scale */
05249         if( iteration >= dynamics.n_initial_relax+1  && dynamics.lgAdvection 
05250                 /*&& radius.depth < dynamics.oldFullDepth*/ ) 
05251         {
05252                 /* Don't use conservation form in matrix solution */
05253                 ipConserve = -1; 
05254                 /* Add rate terms for dynamics to equilibrium, makes c[][] non-singular */
05255                 for(i=0;i<N_H_MOLEC;i++) 
05256                 {
05257                         c[i][i] -= dynamics.Rate;
05258                         bvec[i] -= (Hmolec_old[i]*dynamics.Rate-dynamics.H2_molec[i]);
05259                 }
05260 
05261                 /* Dynamics implies conservation of advected material */
05262                 proton_sum_old = 0.;
05263                 for(i=0; i<N_H_MOLEC;i++)
05264                 {
05265                         proton_sum_old += hmi.nProton[i]*dynamics.H2_molec[i]/dynamics.Rate;
05266                 }
05267 
05268                 /* bring H+ and H0 together since their ratio is set in H atom solver,
05269                  * we determine sum of two here */
05270                 for(i=0;i<N_H_MOLEC;i++) 
05271                 {
05272                         c[ipMHp][i] = (Hmolec_old[ipMH]*c[ipMH][i]+Hmolec_old[ipMHp]*c[ipMHp][i])/SDIV(sum_H0_Hp);
05273                         c[ipMH][i] = 0.;
05274                 }
05275                 for(i=1;i<N_H_MOLEC;i++) 
05276                 {
05277                         c[i][ipMHp] += c[i][ipMH];
05278                         c[i][ipMH] = 0.;
05279                 }
05280                 bvec[ipMHp] += bvec[ipMH];
05281                 bvec[ipMH] = 0.;
05282                 Hmolec_old[ipMHp] += Hmolec_old[ipMH];
05283                 Hmolec_old[ipMH] = 0.;
05284         }
05285         else
05286         {
05287                 /* usual branch, no advection */
05288                 /* bring H+ and H0 together since their ratio is set in H atom solver,
05289                  * we determine sum of two here */
05290                 for(i=0;i<N_H_MOLEC;i++) 
05291                 {
05292                         /* >>chng 04 feb 04, sum_H0_Hp goes to zero when no ionization,
05293                          * add test on SMALLFLOAT */
05294                         if( sum_H0_Hp > SMALLFLOAT )
05295                                 c[ipMHp][i] = (Hmolec_old[ipMH]*c[ipMH][i]+Hmolec_old[ipMHp]*c[ipMHp][i])/sum_H0_Hp;
05296                         c[ipMH][i] = 0.;
05297                 }
05298                 Hmolec_old[ipMHp] += Hmolec_old[ipMH];
05299                 bvec[ipMH] = Hmolec_old[ipMH] = 0.;
05300                 ipConserve = ipMHp;
05301                 /* For Newton-Raphson method, want the change in populations to be zero,
05302                  * so the conserved component must also be zero */
05303                 bvec[ipConserve] = 0.;
05304 
05305                 /* proton_sum_old is the sum of all protons in H-bearing molecules */
05306                 proton_sum_old = 0.;
05307                 for(i=MOLMIN;i<N_H_MOLEC;i++) 
05308                 {
05309                         c[i][ipConserve] = hmi.nProton[i];
05310                         proton_sum_old += hmi.nProton[i]*Hmolec_old[i];
05311                 }
05312         }
05313 
05314         {
05315                 /* following should be set true to print populations */
05316                 enum {DEBUG_LOC=false};
05317                 if( DEBUG_LOC )
05318                 {
05319                         /* these are the raw results */
05320                         fprintf( ioQQQ, " HMOLE h2 %.2e h2* %.2e\n" , Hmolec_old[ipMH2g] ,Hmolec_old[ipMH2s] );
05321                 }
05322         }
05323 
05324         /*------------------------------------------------------------------ */
05325         if(printsol || (trace.lgTrace && trace.lgTr_H2_Mole ))
05326         {
05327 
05328                 /*
05329 
05330                 [0][0]  [0][1]  [0][2]  [0][3]  [0][4]  [0][5]
05331                 [1][0]  [1][1]  [1][2]  [1][3]  [1][4]  [1][5]
05332                 [2][0]  [2][1]  [2][2]  [2][3]  [2][4]  [2][5]
05333                 [3][0]  [3][1]  [3][2]  [3][3]  [3][4]  [3][5]
05334                 [4][0]  [4][1]  [4][2]  [4][3]  [4][4]  [4][5]
05335                 [5][0]  [5][1]  [5][2]  [5][3]  [5][4]  [5][5]
05336 
05337                 [ipMHo][ipMHo]  [ipMHo][ipMHm]  [ipMHo][ipMH2g]  [ipMHo][ipMH2p]  [ipMHo][ipMH3p]  [ipMHo][ipMH2s]
05338                 [ipMHm][ipMHo] [ipMHm][ipMHm] [ipMHm][ipMH2g] [ipMHm][ipMH2p] [ipMHm][ipMH3p] [ipMHm][ipMH2s]
05339                 [ipMH2g][ipMHo]  [ipMH2g][ipMHm]  [ipMH2g][ipMH2g]  [ipMH2g][ipMH2p]  [ipMH2g][ipMH3p]  [ipMH2g][ipMH2s]
05340                 [ipMH2p][ipMHo] [ipMH2p][ipMHm] [ipMH2p][ipMH2g] [ipMH2p][ipMH2p] [ipMH2p][ipMH3p] [ipMH2p][ipMH2s]
05341                 [ipMH3p][ipMHo] [ipMH3p][ipMHm] [ipMH3p][ipMH2g] [ipMH3p][ipMH2p] [ipMH3p][ipMH3p] [ipMH3p][ipMH2s]
05342                 [ipMH2s][ipMHo] [ipMH2s][ipMHm] [ipMH2s][ipMH2g] [ipMH2s][ipMH2p] [ipMH2s][ipMH3p]  [ipMH2s][ipMH2s]
05343 
05344                 */
05345 
05346                 fprintf(ioQQQ,"       MOLE old abundances\t%.2f",fnzone);
05347                 for( i=0; i<N_H_MOLEC; i++ )
05348                         fprintf(ioQQQ,"\t%.2e", Hmolec_old[i] );
05349                 fprintf(ioQQQ,"\n" );
05350 
05351                 /* print the full matrix */
05352                 fprintf( ioQQQ, "                ");
05353                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05354                 {
05355                         fprintf( ioQQQ, "      %s", hmi.chLab[i] );
05356                 }
05357                 fprintf( ioQQQ, "   bvec \n" );
05358 
05359                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05360                 {
05361                         fprintf( ioQQQ, "       MOLE%2ld %s", i-MOLMIN ,hmi.chLab[i] );
05362                         for( j=MOLMIN; j < N_H_MOLEC; j++ )
05363                         {
05364                                 fprintf( ioQQQ, "%10.2e", c[j][i] );
05365                         }
05366                         fprintf( ioQQQ, "%10.2e", bvec[i] );
05367                         fprintf( ioQQQ, "\n" );
05368                 }
05369         }
05370 
05371         /*fprintf(ioQQQ,"DEBUG %.2e %.2e %.2e %.2e\n", 
05372                 c[ipMH][ipMH2g] , c[ipMH][ipMH2s],
05373                 c[ipMH2g][ipMH] , c[ipMH2s][ipMH]);
05374         fprintf(ioQQQ,"DEBUG %.2e %.2e %.2e %.2e\n\n", 
05375                 c[ipMHp][ipMH2g] , c[ipMHp][ipMH2s],
05376                 c[ipMH2g][ipMHp] , c[ipMH2s][ipMHp]);*/
05377         /* establish local timescale for H2 molecule destruction */
05378         if( -c[ipMH2g][ipMH2g] > SMALLFLOAT )
05379         {
05380                 /* units are now seconds */
05381                 timesc.time_H2_Dest_here = -1./c[ipMH2g][ipMH2g];
05382         }
05383         else
05384         {
05385                 timesc.time_H2_Dest_here = 0.;
05386         }
05387 
05388         /* local timescale for H2 formation 
05389          * both grains and radiative attachment */
05390         timesc.time_H2_Form_here = gv.rate_h2_form_grains_used_total * 
05391                 /* this corrects for fact that we the timescale for H2 to form from an atomic gas.
05392                  * The rate becomes very small when gas is fully molecular, and ratio of total hydrogen
05393                  * to atomic hydrogen corrections for this. */
05394                 dense.gas_phase[ipHYDROGEN]/SDIV(dense.xIonDense[ipHYDROGEN][0]) + 
05395                 hmi.hminus_rad_attach;
05396         /* timescale is inverse of this rate */
05397         if( timesc.time_H2_Form_here > SMALLFLOAT )
05398         {
05399                 /* units are now seconds */
05400                 timesc.time_H2_Form_here = 1./timesc.time_H2_Form_here;
05401         }
05402         else
05403         {
05404                 timesc.time_H2_Form_here = 0.;
05405         }
05406 
05407 #       ifdef MAT
05408 #               undef MAT
05409 #       endif
05410 #       define MAT(a,I_,J_)     (*((a)+(I_)*(N_H_MAT)+(J_)))
05411 
05412         /* copy contents over to 1D array */
05413         for( j=0; j < N_H_MAT; j++ )
05414         {
05415                 for( i=0; i < N_H_MAT; i++ )
05416                 {
05417                         MAT(amat,i,j) = c[i+MOLMIN][j+MOLMIN];
05418                 }
05419         }
05420 
05421         if(printsol)
05422         {
05423                 double total=0;
05424                 fprintf(ioQQQ,"Zone %.2f input:\n",fnzone);
05425                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05426                 {
05427                                 fprintf(ioQQQ,"%15.7g\t",Hmolec_old[i]);
05428                                 total += hmi.nProton[i]*Hmolec_old[i];
05429                 }
05430                 fprintf(ioQQQ,"sum = %15.7g\n",total);
05431         }
05432 
05433         int32 merror1 = 0;
05434         int32 merror2 = 0;
05435 
05436         /* now invert the matrix */
05437         getrf_wrapper(N_H_MAT,N_H_MAT,(double*)amat,N_H_MAT,ipiv,&merror1);
05438         getrs_wrapper('N',N_H_MAT,1,(double*)amat,N_H_MAT,ipiv,bvec+MOLMIN,N_H_MAT,&merror2);
05439 
05440         if( merror1 != 0 || merror2 != 0 )
05441         {
05442                 fprintf( ioQQQ, "PROBLEM hmole_step: dgetrs finds singular or ill-conditioned matrix\n" );
05443                 cdEXIT(EXIT_FAILURE);
05444         }
05445 
05446         if(printsol)
05447         {
05448                 double total=0;
05449                 fprintf(ioQQQ,"solution:\n");
05450                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05451                 {
05452                         fprintf(ioQQQ,"%15.7g\t",bvec[i]);
05453                         total += hmi.nProton[i]*bvec[i];
05454                 }
05455                 fprintf(ioQQQ,"sum = %15.7g\n",total);
05456         }
05457 
05458         *error = 0;
05459         /* loop starts from MOLMIN=1 rather than zero since
05460          * H0 and H+ rates have been collapsed into one, since that solution
05461          * comes from H atom solver.  
05462          *
05463          * bvec is (old - new) solutions coming into this routine
05464          * loops converts bvec to new density */
05465         for( i=MOLMIN; i < N_H_MOLEC; i++ )
05466         {
05467                 /* Smooth the error mode tailoff */
05468                 etmp = bvec[i]/(ABSLIM+Hmolec_old[i]);
05469 
05470                 if(printsol)
05471                         fprintf(ioQQQ,"%15.7g\t",etmp);
05472 
05473                 /* square of change in abundance of this species, in this iteration */
05474                 *error += etmp*etmp;
05475                 /* change bvec from being the difference into being the new value
05476                  * bvec is now new density */
05477                 bvec[i] = Hmolec_old[i]-bvec[i];
05478         }
05479         /* bvec is now the density */
05480         *error = sqrt(*error)/N_H_MAT;
05481 
05482         if(printsol)
05483         {
05484                 double total=0;
05485                 fprintf(ioQQQ,"err = %15.7g\n",*error);
05486                 /* fprintf(ioQQQ,"derived:\n"); */
05487                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05488                 {
05489                                 fprintf(ioQQQ,"%15.7g\t",bvec[i]);
05490                                 total += hmi.nProton[i]*bvec[i];
05491                 }
05492                 fprintf(ioQQQ,"sum = %15.7g\n",total);
05493         }
05494 
05495         proton_sum_new = 0.;
05496         /* check for negative populations and do proton sum */
05497         lgNegPop = false;
05498         fracneg = 0.;
05499         fracnegfac = 0.;
05500         iworst = -1;
05501         for( i=MOLMIN; i < N_H_MOLEC; i++ )
05502         {
05503                 if( bvec[i] < 0. ) 
05504                 {
05505                         lgNegPop = true;
05506                 }
05507                 /* largest relative change in solution for neg soln */
05508                 fracnegtmp = -bvec[i]/SDIV(Hmolec_old[i]);
05509                 /* this can only occur for negative solutions since fracneg starts
05510                  * as zero */
05511                 if(fracnegtmp > fracneg) 
05512                 {
05513                         fracneg = fracnegtmp;
05514                         fracnegfac = (0.5*Hmolec_old[i]-bvec[i])/(Hmolec_old[i]-bvec[i]);
05515                         iworst = i;
05516                 }
05517                 /* sum total number of protons used - hmi.nProton is number of protons in species bvec[i] */
05518                 proton_sum_new += hmi.nProton[i] * bvec[i];
05519         }
05520 
05521         /* this is difference between number of protons in hmi.Hmolec upon entry into this routine
05522          * and number of protons we found here */
05523         conserve = (proton_sum_old - proton_sum_new)/SDIV(proton_sum_old);
05524         /* >>chng 06 jun 29, from conserve < 1e-8 to twice FLT_EPSILON - the CO network now includes
05525          * part of the H - the old upstream fraction of H in CO molecules is likely different from
05526          * the current fractions.  the CO chem is only solved to a certain error, should not
05527          * demand higher accuracy than this 
05528          * the factor 10.*FLT_EPSILON also appears in ion_solver in total H conservation */
05529         /*if( fabs(conserve) > 1e-8 )*/
05530         if( fabs(conserve) > 10.*FLT_EPSILON )
05531                 fprintf(ioQQQ,"PROBLEM hmoleee zn %li proton_sum_old %.8e, proton_sum_new %.8e n(H) %.8e (old-new)/old %.3e nH-old %.3e nH-new %.3e\n", 
05532                 nzone , 
05533                 proton_sum_old , 
05534                 proton_sum_new , 
05535                 dense.gas_phase[ipHYDROGEN] , 
05536                 conserve ,
05537                 dense.gas_phase[ipHYDROGEN]-proton_sum_old,
05538                 dense.gas_phase[ipHYDROGEN]-proton_sum_new);
05539 
05540 #       if 0
05541         /* NDEBUG is set by the compiler to indicate that a debugging mode
05542          * has not been specified.  */
05543 #       ifndef NDEBUG
05544         /*if(NDEBUG)*/
05545         {
05546                 fprintf( ioQQQ, "Zone %li\n",nzone);
05547                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05548                 {
05549                         fprintf(ioQQQ," %s %.2e", hmi.chLab[i], Hmolec_old[i]);
05550                 }
05551                 fprintf( ioQQQ, " =>\n" );
05552                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05553                 {
05554                         fprintf(ioQQQ," %s %.2e", hmi.chLab[i], bvec[i]);
05555                 }
05556                 fprintf( ioQQQ, "\n" );
05557         }
05558 #       endif
05559 #       endif
05560 
05561         if(lgNegPop)
05562         {
05563 #               ifndef NDEBUG
05564                 /* very common to obtain negative solution on very first try - 
05565                  * don't print in this case */
05566                 if(*nFixup )
05567                 {
05568                         fprintf( ioQQQ, " PROBLEM  hmole_step finds negative H molecule, in zone %.2f.\n",fnzone );
05569                         fprintf( ioQQQ, " Worst is species %d -ve by fraction %g.\n",iworst,fracneg );
05570                         fprintf( ioQQQ, " The populations follow:\n");
05571                         for( i=MOLMIN; i < N_H_MOLEC; i++ )
05572                         {
05573                                 fprintf(ioQQQ," %s %.2e", hmi.chLab[i], bvec[i]);
05574                         }
05575                         fprintf( ioQQQ, "\n" );
05576                 }
05577 #               endif
05578 
05579                 /* Fix negative abundance -- assume the new solution is better in some ways */
05580                 {
05581                         double total=0., ntotal=0., ratio;
05582                         enum {FIXUPTYPE = 1};
05583 
05584                         ++*nFixup;
05585 
05586                         if(FIXUPTYPE == 1) {
05587                                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05588                                 {
05589                                         total += hmi.nProton[i]*bvec[i];
05590                                         if(bvec[i] < 0) 
05591                                         {
05592                                                 ntotal += hmi.nProton[i]*bvec[i];
05593                                                 bvec[i] = 0.;
05594                                         }
05595                                 }
05596                                 ratio = total/(total-ntotal);
05597                                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05598                                 {
05599                                         bvec[i] *= ratio;
05600                                 }
05601                         }
05602                         else if(FIXUPTYPE == 2) 
05603                         {
05604                                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05605                                 {
05606                                         bvec[i] = fracnegfac*Hmolec_old[i]+(1-fracnegfac)*bvec[i];
05607                                 }
05608                         }
05609 
05610 #                       ifndef NDEBUG
05611                         /*if(NDEBUG)*/
05612                         /* very common to obtain negative solution on very first try - 
05613                          * don't print in this case */
05614                         if( *nFixup>1 )
05615                         {
05616                                 fprintf(ioQQQ," FIXUP taken %i time%s.\n\n", *nFixup, (*nFixup == 1)?"":"s");
05617                                 fprintf( ioQQQ, " Initially:\n");
05618                                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05619                                 {
05620                                         fprintf(ioQQQ," %s %.2e", hmi.chLab[i], Hmolec_old[i]);
05621                                 }
05622                                 fprintf( ioQQQ, "\n" );
05623                                 fprintf( ioQQQ, " Changed to:\n");
05624                                 for( i=MOLMIN; i < N_H_MOLEC; i++ )
05625                                 {
05626                                         fprintf(ioQQQ," %s %.2e", hmi.chLab[i], bvec[i]);
05627                                 }
05628                                 fprintf( ioQQQ, "\n" );
05629                         }
05630 #                       endif
05631                 }
05632         }
05633 
05634         /* put derived abundances back into appropriate molecular species,
05635          * bvec[ipMHp] is still sum of H0 and H+ from chemistry,
05636          * now split up using ratio found in H atom solver */
05637         h1fnd = bvec[ipMHp];
05638         /* >>chng 04 feb 04, add SMALLFLOAT to protect against fully molecular limit */
05639         h1rat = h1fnd/SDIV(sum_H0_Hp);
05640         /* put back into proper places in solution vector so following loops work
05641          * as expected */
05642         bvec[ipMH] = dense.xIonDense[ipHYDROGEN][0] * h1rat;
05643         bvec[ipMHp] = dense.xIonDense[ipHYDROGEN][1] * h1rat;
05644         /* ASSERT(fabs(bvec[ipMH]+bvec[ipMHp]-h1fnd) < 1e-12 * h1fnd); */
05645 
05646         if(fabs(bvec[ipMH]+bvec[ipMHp]-h1fnd) >= 1e-12 * h1fnd) 
05647         {
05648                 static bool lgPrint=true;
05649                 fprintf(ioQQQ,"PROBLEM h1fnd residual error, bvec[ipMH]=%g [ipMHp}=%g" 
05650                         " h1fnd=%g h1rat=%g bvec[ipMH]+bvec[ipMHp]-h1fnd=%g\n",
05651                         bvec[ipMH],bvec[ipMHp],h1fnd,h1rat,bvec[ipMH]+bvec[ipMHp]-h1fnd);
05652                 /* nearly all cases of this problem are due to ZERO H ionization rate - this can't happen if
05653                  * cosmic rays are present */
05654                 if( lgPrint )
05655                 {
05656                         fprintf(ioQQQ," This problem is usually caused by little or no sources of ionizaiton.\n");
05657                         fprintf(ioQQQ," Is the simulation physically motivated?\n");
05658                         if( hextra.cryden==0. && lgPrint )
05659                         {
05660                                 fprintf(ioQQQ,"PROBLEM h1fnd - no cosmic rays are present - is this physical?\n");
05661                                 fprintf(ioQQQ,"PROBLEM h1fnd - Consider including the COSMIC RAY BACKGROUND command.\n");
05662                         }
05663                         lgPrint = false;
05664                 }
05665         }
05666 
05667         /* copy new solutions over the hmi.Hmolec */
05668         for(mol=0;mol<N_H_MOLEC;mol++)
05669         {
05670                 hmi.Hmolec[mol] = (realnum) bvec[mol];
05671         }
05672 
05673         dense.xIonDense[ipHYDROGEN][0] = (realnum) bvec[ipMH];
05674         dense.xIonDense[ipHYDROGEN][1] = (realnum) bvec[ipMHp];
05675 
05676         /* total H2 - all forms */
05677         hmi.H2_total = hmi.Hmolec[ipMH2s] + hmi.Hmolec[ipMH2g];
05678         /* first guess at ortho and para densities */
05679         h2.ortho_density = 0.75*hmi.H2_total;
05680         h2.para_density = 0.25*hmi.H2_total;
05681 
05682         /* NB the first index must be kept parallel with nelem and ionstag in
05683          * H2Lines transition struc,
05684          * since that struc expects to find the abundances here */
05685         /* >>chng 04 feb 19, had been ipMH2g, chng to total */
05686         dense.xIonDense[LIMELM+2][0] = hmi.H2_total;
05687 
05688         /* identify dominant H2 formation process */
05689         {
05690                 /* following should be set true to identify H2 formation and destruction processes */
05691                 enum {DEBUG_LOC=false};
05692                 if( DEBUG_LOC && (nzone>50) )
05693                 {
05694                         double createsum ,create_from_Hn2 , create_3body_Ho, create_h2p, 
05695                                 create_h3p, create_h3pe, create_grains, create_hminus;
05696                         double destroysum, destroy_hm ,destroy_soloman ,destroy_2h ,destroy_hp,
05697                                 destroy_h,destroy_hp2,destroy_h3p;
05698 
05699                         /* H(n=2) + H(n=1) -> H2 */
05700                         create_from_Hn2 = hmi.radasc*dense.xIonDense[ipHYDROGEN][0];
05701                         /* 3H => H2 + H */
05702                         create_3body_Ho = hmi.bh2dis*dense.xIonDense[ipHYDROGEN][0];
05703                         /* H2+ + H => H2 + H+ */
05704                         create_h2p = hmi.bh2h2p*dense.xIonDense[ipHYDROGEN][0]*Hmolec_old[ipMH2p];
05705                         /* H + H3+ => H2 + H2+ */
05706                         create_h3p = hmi.h3ph2p*dense.xIonDense[ipHYDROGEN][0]*hmi.Hmolec[ipMH3p];
05707                         /* e + H3+ => H2 + H */
05708                         create_h3pe = hmi.eh3_h2h*dense.eden * hmi.Hmolec[ipMH3p];
05709                         /* from grains */
05710                         create_grains = gv.rate_h2_form_grains_used_total;
05711                         /* from H- */
05712                         create_hminus = Hmolec_old[ipMH]*hmi.assoc_detach*hmi.Hmolec[ipMHm];
05713 
05714                         createsum = create_from_Hn2 + create_3body_Ho + create_h2p +
05715                                 create_h3p + create_h3pe + create_grains + create_hminus;
05716 
05717                         fprintf(ioQQQ,"H2 create zone\t%.2f \tsum\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
05718                                 fnzone,
05719                                 createsum,
05720                                 create_hminus   / createsum,
05721                                 create_from_Hn2 / createsum,
05722                                 create_3body_Ho / createsum,
05723                                 create_h2p      / createsum,
05724                                 create_h3p      / createsum,
05725                                 create_h3pe     / createsum,
05726                                 create_grains   / createsum     );
05727 
05728                         /* all h2 molecular hydrogen destruction processes */
05729                         /* >>chng 04 jan 28, had wrong Boltzmann factor,
05730                          * caught by gargi Shaw */
05731                         destroy_hm = hmi.assoc_detach_backwards_grnd+hmi.assoc_detach_backwards_exct;
05732                         /*destroy_hm2 = eh2hhm;*/
05733                         destroy_soloman = hmi.H2_Solomon_dissoc_rate_used_H2g;
05734                         destroy_2h = hmi.eh2hh;
05735                         destroy_hp = hmi.h2hph3p*dense.xIonDense[ipHYDROGEN][1];
05736                         destroy_h = hmi.rh2dis*dense.xIonDense[ipHYDROGEN][0];
05737                         destroy_hp2 = hmi.rh2h2p*dense.xIonDense[ipHYDROGEN][1];
05738                         destroy_h3p = hmi.h3petc * hmi.Hmolec[ipMH3p];
05739                         destroysum = destroy_hm + /*destroy_hm2 +*/ destroy_soloman + destroy_2h + 
05740                                 destroy_hp+ destroy_h+ destroy_hp2+ destroy_h3p;
05741 
05742                         fprintf(ioQQQ,"H2 destroy\t%.3f \t%.2e\tsum\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
05743                                 fnzone,
05744                                 destroysum,
05745                                 destroy_hm / destroysum ,
05746                                 destroy_soloman / destroysum ,
05747                                 destroy_2h / destroysum ,
05748                                 destroy_hp / destroysum ,
05749                                 destroy_h / destroysum ,
05750                                 destroy_hp2 / destroysum ,
05751                                 destroy_h3p / destroysum );
05752 
05753                 }
05754         }
05755 
05756         {
05757                 /* following should be set true to identify H- formation and destruction processes */
05758                 enum {DEBUG_LOC=false};
05759                 if( DEBUG_LOC && (nzone>140) )
05760                 {
05761                         double create_from_Ho,create_3body_Ho,create_batach,destroy_photo,
05762                                 destroy_coll_heavies,destroy_coll_electrons,destroy_Hattach,destroy_fhneut,
05763                                 destsum , createsum;
05764 
05765                         create_from_Ho = (hmi.hminus_rad_attach + hmi.HMinus_induc_rec_rate);
05766                         create_3body_Ho = c3bod;
05767                         /* total formation is sum of g and s attachment */
05768                         create_batach = hmi.assoc_detach_backwards_grnd + hmi.assoc_detach_backwards_exct;
05769                         destroy_photo = hmi.HMinus_photo_rate;
05770                         destroy_coll_heavies = hmi.hmin_ct_firstions*sum_first_ions;
05771                         destroy_coll_electrons = cionhm;
05772                         destroy_Hattach = Hmolec_old[ipMH]*hmi.assoc_detach;
05773                         destroy_fhneut = fhneut;
05774 
05775                         destsum = destroy_photo + destroy_coll_heavies + destroy_coll_electrons + 
05776                                 destroy_Hattach + destroy_fhneut;
05777                         fprintf(ioQQQ,"H- destroy zone\t%.2f\tTe\t%.4e\tsum\t%.2e\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", 
05778                                 fnzone,
05779                                 phycon.te,
05780                                 destsum,
05781                                 destroy_photo/destsum , 
05782                                 destroy_coll_heavies/destsum,
05783                                 destroy_coll_electrons/destsum, 
05784                                 destroy_Hattach/destsum,
05785                                 destroy_fhneut/destsum );
05786 
05787                         createsum = create_from_Ho+create_3body_Ho+create_batach;
05788                         fprintf(ioQQQ,"H- create\t%.2f\tTe\t%.4e\tsum\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
05789                                 fnzone,
05790                                 phycon.te,
05791                                 createsum,
05792                                 dense.eden,
05793                                 create_from_Ho/createsum,
05794                                 create_3body_Ho/createsum,
05795                                 create_batach/createsum);
05796                 }
05797         }
05798 
05799         /* rate H-alpha is created by H- ct */
05800         hmi.HalphaHmin = (realnum)(fhneut*hmi.Hmolec[ipMHm]);
05801 
05802         /* heating due to H2 dissociation */
05803         if( hmi.lgNoH2Mole )
05804         {
05805                 hmi.HeatH2Dish_TH85 = 0.;
05806                 hmi.HeatH2Dexc_TH85 = 0.;
05807                 hmi.deriv_HeatH2Dexc_TH85 = 0.;
05808         }
05809         else
05810         {
05811                 /* H2 photodissociation heating, eqn A9 of Tielens & Hollenbach 1985a */
05812                 /*hmi.HeatH2Dish_TH85 = (realnum)(1.36e-23*hmi.Hmolec[ipMH2g]*h2esc*hmi.UV_Cont_rel2_Habing_TH85_depth);*/
05813                 /* >>chng 04 feb 07, more general to express heating in terms of the assumed
05814                  * photo rates - the 0.25 was obtained by inverting A8 & A9 of TH85 to find that
05815                  * there are 0.25 eV per dissociative pumping, ie, 10% of total 
05816                  * this includes both H2g and H2s - TH85 say just ground but they include
05817                  * process for both H2 and H2s - as we did above - both must be in
05818                  * heating term */
05819                 /* >>chng 05 mar 11, TE, old had used H2_Solomon_dissoc_rate_used, which was only
05820                  * H2g.  in regions where Solomon process is fast, H2s has a large population
05821                  * and the heating rate was underestimated. */
05822                 /* >>chng 05 jun 23, 
05823                  * >>chng 05 dec 05, TE, modified to approximate the heating better for the
05824                  * new approximation */
05825                 /* >>chng 00 nov 25, explicitly break out this heat agent */
05826                 /* 2.6 eV of heat per deexcitation, consider difference
05827                 * between deexcitation (heat) and excitation (cooling) */
05828                 /* >>chng 04 jan 27, code moved here and simplified */
05829                 /* >>chng 05 jul 10, GS*/ 
05830                 /*  average collisional rate for H2* to H2g calculated from big H2, GS*/
05831 
05832                 /* TH85 dissociation heating - this is ALWAYS defined for reference
05833                  * may be output for comparison with other rates*/
05834                 hmi.HeatH2Dish_TH85 = 0.25 * EN1EV *
05835                         (hmi.H2_Solomon_dissoc_rate_used_H2g * hmi.Hmolec[ipMH2g] +
05836                          hmi.H2_Solomon_dissoc_rate_used_H2s * hmi.Hmolec[ipMH2s]);
05837 
05838                 /* TH85 deexcitation heating */
05839                 hmi.HeatH2Dexc_TH85 = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12;
05840                 /* this is derivative wrt temperature, only if counted as a cooling source */
05841                 hmi.deriv_HeatH2Dexc_TH85 = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_TH85)* ( 30172. * thermal.tsq1 - thermal.halfte ) );
05842 
05843                 if( hmi.chH2_small_model_type == 'H' )
05844                 {
05845                         /* Burton et al. 1990 */
05846                         hmi.HeatH2Dish_BHT90 = 0.25 * EN1EV *
05847                                 (hmi.H2_Solomon_dissoc_rate_used_H2g * hmi.Hmolec[ipMH2g] +
05848                                 hmi.H2_Solomon_dissoc_rate_used_H2s * hmi.Hmolec[ipMH2s]);
05849 
05850                         /* Burton et al. 1990 heating */
05851                         hmi.HeatH2Dexc_BHT90 = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12;
05852                         /* this is derivative wrt temperature, only if counted as a cooling source */
05853                         hmi.deriv_HeatH2Dexc_BHT90 = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_BHT90)* ( 30172. * thermal.tsq1 - thermal.halfte ) );
05854                 }
05855                 else if( hmi.chH2_small_model_type == 'B')
05856                 {
05857                         /* Bertoldi & Draine */
05858                         hmi.HeatH2Dish_BD96 = 0.25 * EN1EV *
05859                                 (hmi.H2_Solomon_dissoc_rate_used_H2g * hmi.Hmolec[ipMH2g] +
05860                                 hmi.H2_Solomon_dissoc_rate_used_H2s * hmi.Hmolec[ipMH2s]);
05861                         /* Bertoldi & Draine heating, same as TH85 */
05862                         hmi.HeatH2Dexc_BD96 = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12;
05863                         /* this is derivative wrt temperature, only if counted as a cooling source */
05864                         hmi.deriv_HeatH2Dexc_BD96 = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_BD96)* ( 30172. * thermal.tsq1 - thermal.halfte ) );
05865                 }
05866                 else if(hmi.chH2_small_model_type == 'E')
05867                 {
05868                         /* heating due to dissociation of H2
05869                          * >>chng 05 oct 19, TE, define new approximation for the heating due to the destruction of H2
05870                          *      use this approximation for the specified cloud parameters, otherwise
05871                          * use limiting cases for 1 <= G0, G0 >= 1e7, n >= 1e7, n <= 1 */
05872 
05873                         double log_density, 
05874                                         f1, f2,f3, f4, f5;
05875                         static double log_G0_face = -1;
05876                         static double k_f4;
05877 
05878 
05879                         /* test for G0 
05880                          * this is a constant so only do it in zone 0 */
05881                         if( !nzone )
05882                         {
05883                                 if(hmi.UV_Cont_rel2_Draine_DB96_face <= 1.) 
05884                                 { 
05885                                         log_G0_face = 0.;
05886                                 }
05887                                 else if(hmi.UV_Cont_rel2_Draine_DB96_face >= 1e7) 
05888                                 { 
05889                                         log_G0_face = 7.;
05890                                 }
05891                                 else 
05892                                 { 
05893                                         log_G0_face = log10(hmi.UV_Cont_rel2_Draine_DB96_face); 
05894                                 }
05895                                 /*>>chng 06 oct 24 TE change Go face for spherical geometry*/
05896                                 log_G0_face /= radius.r1r0sq;
05897                         }
05898                         /* test for density */
05899                         if(dense.gas_phase[ipHYDROGEN] <= 1.) 
05900                         { 
05901                                 log_density = 0.; 
05902                         }
05903                         else if(dense.gas_phase[ipHYDROGEN] >= 1e7) 
05904                         { 
05905                                 log_density = 7.; 
05906                         }
05907                         else 
05908                         { 
05909                                 log_density = log10(dense.gas_phase[ipHYDROGEN]); 
05910                         }
05911 
05912                         f1 = 0.15 * log_density + 0.75;
05913                         f2 = -0.5 * log_density + 10.;
05914 
05915                         hmi.HeatH2Dish_ELWERT = 0.25 * EN1EV *  f1 * 
05916                                 (hmi.H2_Solomon_dissoc_rate_used_H2g * hmi.Hmolec[ipMH2g] +
05917                                  hmi.H2_Solomon_dissoc_rate_used_H2s * hmi.Hmolec[ipMH2s] ) + 
05918                                 f2 * secondaries.x12tot * EN1EV * hmi.H2_total;
05919 
05920                         /*fprintf( ioQQQ, "f1: %.2e, f2: %.2e,heat Solomon: %.2e",f1,f2,hmi.HeatH2Dish_TH85);*/
05921 
05922 
05923                         /* heating due to collisional deexcitation within X of H2
05924                         * >>chng 05 oct 19, TE, define new approximation for the heating due to the destruction of H2
05925                         *       use this approximation for the specified cloud parameters, otherwise
05926                         * use limiting cases for 1 <= G0, G0 >= 1e7, n >= 1e7, n <= 1 */
05927 
05928                         /* set value of k_f4 by testing on value of G0 */
05929                         if(hmi.UV_Cont_rel2_Draine_DB96_face <= 1.) 
05930                         { 
05931                                 log_G0_face = 0.;
05932                         }
05933                         else if(hmi.UV_Cont_rel2_Draine_DB96_face >= 1e7) 
05934                         { 
05935                                 log_G0_face = 7.;
05936                         }
05937                         else 
05938                         { 
05939                                 log_G0_face = log10(hmi.UV_Cont_rel2_Draine_DB96_face); 
05940                         }
05941                         /* 06 oct 24, TE introduce effects of spherical geometry */
05942                         log_G0_face /= radius.r1r0sq;
05943 
05944                         /* terms only dependent on G0_face */
05945                         k_f4 = -0.25 * log_G0_face + 1.25;
05946 
05947                         /* test for density */
05948                         if(dense.gas_phase[ipHYDROGEN] <= 1.) 
05949                         { 
05950                                 log_density = 0.; 
05951                                 f4 = 0.; 
05952                         }
05953                         else if(dense.gas_phase[ipHYDROGEN] >= 1e7) 
05954                         { 
05955                                 log_density = 7.; 
05956                                 f4 = pow(k_f4,2) * pow( 10. , 2.2211 * log_density - 29.8506);
05957                         }
05958                         else 
05959                         { 
05960                                 log_density = log10(dense.gas_phase[ipHYDROGEN]); 
05961                                 f4 = pow(k_f4,2) * pow( 10., 2.2211 * log_density - 29.8506);
05962                         }
05963 
05964                         f3 = MAX2(0.1, -4.75 * log_density + 24.25);
05965                         f5 = MAX2(1.,0.95 * log_density - 1.45) * 0.2 * log_G0_face;
05966 
05967                         hmi.HeatH2Dexc_ELWERT = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12 * f3 + 
05968                                 f4 * (hmi.Hmolec[ipMH]/dense.gas_phase[ipHYDROGEN]) +
05969                                 f5 * secondaries.x12tot * EN1EV * hmi.H2_total;
05970 
05971                         if(log_G0_face == 0.&& dense.gas_phase[ipHYDROGEN] > 1.) 
05972                                 hmi.HeatH2Dexc_ELWERT *= 0.001 / dense.gas_phase[ipHYDROGEN];
05973 
05974                         /* >>chng 06 oct 24, TE introduce effects of spherical geometry */
05975                         /*if(radius.depth/radius.rinner >= 1.0) */
05976                         hmi.HeatH2Dexc_ELWERT /= POW2(radius.r1r0sq);
05977 
05978                         /* this is derivative wrt temperature, only if counted as a cooling source */
05979                         hmi.deriv_HeatH2Dexc_ELWERT = (realnum)(MAX2(0.,-hmi.HeatH2Dexc_ELWERT)* ( 30172. * thermal.tsq1 - thermal.halfte ) );
05980 
05981                         /*fprintf( ioQQQ, "\tf3: %.2e, f4: %.2e, f5: %.2e, heat coll dissoc: %.2e\n",f3,f4,f5,hmi.HeatH2Dexc_TH85);*/
05982                 }
05983                 /* end Elwert branch for photo rates */
05984                 else
05985                         TotalInsanity();
05986 
05987                 if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
05988                 {
05989                                 deexc_htwo = hmi.Average_collH2_deexcit;
05990                                 deexc_hneut = hmi.Average_collH_deexcit;
05991                 }
05992                 else
05993                 {
05994                         deexc_htwo = (1.4e-12*phycon.sqrte * sexp( 18100./(phycon.te + 1200.) ))/6.;
05995                         deexc_hneut =  (1e-12*phycon.sqrte * sexp(1000./phycon.te ))/6.;
05996                 }
05997 
05998                 H2star_deexcit = hmi.H2_total*deexc_htwo + hmi.Hmolec[ipMH] * deexc_hneut;
05999 
06000                 if( h2.lgH2ON  && hmi.lgBigH2_evaluated && hmi.lgH2_Chemistry_BigH2 )
06001                 {
06002                         H2star_excit = hmi.Average_collH2_excit *hmi.H2_total + hmi.Average_collH_excit*hmi.Hmolec[ipMH];
06003                 }
06004                 else
06005                 {
06006                         H2star_excit = Boltz_fac_H2_H2star * H2star_deexcit;
06007                 }
06008 
06009                 /* Leiden hacks try to turn off H2*, which is all unphysical.  do not include heating
06010                  * due to H2 deexcitation since H2* is bogus */
06011                 /* >>chng 05 aug 12, do not turn off vibrational heating when Leiden hack is in place
06012                  * other codes included heating but did not include H2s on chemistry 
06013                 hmi.HeatH2Dexc_TH85 *= hmi.lgLeiden_Keep_ipMH2s;*/
06014                 /*fprintf(ioQQQ,
06015                         "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",
06016                         fnzone,
06017                         hmi.HeatH2Dexc_TH85,
06018                         thermal.htot,
06019                         hmi.Hmolec[ipMH2s],
06020                         H2star_deexcit, 
06021                         hmi.Hmolec[ipMH2g],
06022                         H2star_excit,
06023                         Hmolec_old[ipMH2g],
06024                         Hmolec_old[ipMH],
06025                         phycon.te);*/
06026         }
06027 
06028         {
06029                 /* following should be set true to print populations */
06030                 enum {DEBUG_LOC=false};
06031                 if( DEBUG_LOC )
06032                 {
06033                         /* these are the raw results */
06034                         fprintf( ioQQQ, " HMOLE raw; hi\t%.2e" , dense.xIonDense[ipHYDROGEN][0]);
06035                         for( i=0; i < N_H_MOLEC; i++ )
06036                         {
06037                                 fprintf( ioQQQ, "\t%s\t%.2e", hmi.chLab[i], bvec[i] );
06038                         }
06039                         fprintf( ioQQQ, " \n" );
06040                 }
06041         }
06042 
06043         if( trace.lgTrace && trace.lgTr_H2_Mole )
06044         {
06045                 /* these are the raw results */
06046                 fprintf( ioQQQ, "\n raw; " );
06047                 for( i=0; i < N_H_MOLEC; i++ )
06048                 {
06049                         fprintf( ioQQQ, " %s:%.2e", hmi.chLab[i], bvec[i] );
06050                 }
06051                 fprintf( ioQQQ, " \n" );
06052         }
06053 
06054         /* >>chng 05 jul 11, TE, each term must have unit cm-3 s-1,
06055          * more terms added */
06056         hmi.H2_rate_create = gv.rate_h2_form_grains_used_total  * dense.xIonDense[ipHYDROGEN][0] + 
06057                 hmi.assoc_detach * hmi.Hmolec[ipMH] * hmi.Hmolec[ipMHm] +
06058                 hmi.bh2dis * dense.xIonDense[ipHYDROGEN][0] + 
06059                 hmi.bh2h2p * dense.xIonDense[ipHYDROGEN][0] * hmi.Hmolec[ipMH2p] + 
06060                 hmi.radasc * dense.xIonDense[ipHYDROGEN][0] + 
06061                 hmi.h3ph2p * dense.xIonDense[ipHYDROGEN][0] * hmi.Hmolec[ipMH3p] + 
06062                 hmi.h2phmh2h * hmi.Hmolec[ipMH2p] * hmi.Hmolec[ipMHm] +
06063                 hmi.bh2h22hh2 * 2 * dense.xIonDense[ipHYDROGEN][0] * hmi.Hmolec[ipMH2g] +
06064                 hmi.h3phmh2hh * hmi.Hmolec[ipMH3p] * hmi.Hmolec[ipMHm] +
06065                 hmi.h3phm2h2 * hmi.Hmolec[ipMH3p] * hmi.Hmolec[ipMHm] +
06066                 hmi.h32h2 * hmi.Hmolec[ipMH2p] * hmi.Hmolec[ipMH3p] +
06067                 hmi.eh3_h2h * hmi.Hmolec[ipMH3p] +
06068                 hmi.h3ph2hp * hmi.Hmolec[ipMH3p]+
06069                 co.H_CH_C_H2 * dense.xIonDense[ipHYDROGEN][0] +
06070                 co.H_CHP_CP_H2 * dense.xIonDense[ipHYDROGEN][0] +
06071                 co.H_CH2_CH_H2 * dense.xIonDense[ipHYDROGEN][0] +
06072                 co.H_CH3P_CH2P_H2 * dense.xIonDense[ipHYDROGEN][0] +
06073                 co.H_OH_O_H2 * dense.xIonDense[ipHYDROGEN][0] +
06074                 co.Hminus_HCOP_CO_H2 * hmi.Hmolec[ipMHm] +
06075                 co.Hminus_H3OP_H2O_H2 * hmi.Hmolec[ipMHm] +
06076                 co.Hminus_H3OP_OH_H2_H * hmi.Hmolec[ipMHm] +
06077                 co.HP_CH2_CHP_H2 * hmi.Hmolec[ipMHp] +
06078                 co.HP_SiH_SiP_H2 * hmi.Hmolec[ipMHp] +
06079                 co.H2P_CH_CHP_H2 * hmi.Hmolec[ipMH2p] + 
06080                 co.H2P_CH2_CH2P_H2 * hmi.Hmolec[ipMH2p] + 
06081                 co.H2P_CO_COP_H2 * hmi.Hmolec[ipMH2p] + 
06082                 co.H2P_H2O_H2OP_H2 * hmi.Hmolec[ipMH2p] + 
06083                 co.H2P_O2_O2P_H2 * hmi.Hmolec[ipMH2p] + 
06084                 co.H2P_OH_OHP_H2 * hmi.Hmolec[ipMH2p] + 
06085                 co.H3P_C_CHP_H2 * hmi.Hmolec[ipMH3p] + 
06086                 co.H3P_CH_CH2P_H2 * hmi.Hmolec[ipMH3p] + 
06087                 co.H3P_CH2_CH3P_H2 * hmi.Hmolec[ipMH3p] + 
06088                 co.H3P_OH_H2OP_H2 * hmi.Hmolec[ipMH3p] + 
06089                 co.H3P_H2O_H3OP_H2 * hmi.Hmolec[ipMH3p] + 
06090                 co.H3P_CO_HCOP_H2 * hmi.Hmolec[ipMH3p] + 
06091                 co.H3P_O_OHP_H2 * hmi.Hmolec[ipMH3p] + 
06092                 co.H3P_SiH_SiH2P_H2 * hmi.Hmolec[ipMH3p] + 
06093                 co.H3P_SiO_SiOHP_H2     * hmi.Hmolec[ipMH3p] +
06094                 co.H_CH3_CH2_H2 * dense.xIonDense[ipHYDROGEN][0] +
06095                 co.H_CH4P_CH3P_H2 * dense.xIonDense[ipHYDROGEN][0] +
06096                 co.H_CH5P_CH4P_H2 * dense.xIonDense[ipHYDROGEN][0] +
06097                 co.H2P_CH4_CH3P_H2 * hmi.Hmolec[ipMH2p] + 
06098                 co.H2P_CH4_CH4P_H2 * hmi.Hmolec[ipMH2p] + 
06099                 co.H3P_CH3_CH4P_H2 * hmi.Hmolec[ipMH3p] + 
06100                 co.H3P_CH4_CH5P_H2 * hmi.Hmolec[ipMH3p] + 
06101                 co.HP_CH4_CH3P_H2 * hmi.Hmolec[ipMHp] + 
06102                 co.HP_HNO_NOP_H2 * hmi.Hmolec[ipMHp] +
06103                 co.HP_HS_SP_H2 * hmi.Hmolec[ipMHp] +
06104                 co.H_HSP_SP_H2 * dense.xIonDense[ipHYDROGEN][0] +
06105                 co.H3P_NH_NH2P_H2 * hmi.Hmolec[ipMH3p] + 
06106                 co.H3P_NH2_NH3P_H2 * hmi.Hmolec[ipMH3p] + 
06107                 co.H3P_NH3_NH4P_H2 * hmi.Hmolec[ipMH3p] + 
06108                 co.H3P_CN_HCNP_H2 * hmi.Hmolec[ipMH3p] + 
06109                 co.H3P_NO_HNOP_H2 * hmi.Hmolec[ipMH3p] + 
06110                 co.H3P_S_HSP_H2 * hmi.Hmolec[ipMH3p] + 
06111                 co.H3P_CS_HCSP_H2 * hmi.Hmolec[ipMH3p] + 
06112                 co.H3P_NO2_NOP_OH_H2 * hmi.Hmolec[ipMH3p] + 
06113                 co.H2P_NH_NHP_H2 * hmi.Hmolec[ipMH2p] + 
06114                 co.H2P_NH2_NH2P_H2 * hmi.Hmolec[ipMH2p] + 
06115                 co.H2P_NH3_NH3P_H2 * hmi.Hmolec[ipMH2p] + 
06116                 co.H2P_CN_CNP_H2 * hmi.Hmolec[ipMH2p] + 
06117                 co.H2P_HCN_HCNP_H2 * hmi.Hmolec[ipMH2p] + 
06118                 co.H2P_NO_NOP_H2 * hmi.Hmolec[ipMH2p] +
06119                 co.H3P_Cl_HClP_H2 * hmi.Hmolec[ipMH3p]+
06120                 co.H3P_HCl_H2ClP_H2 * hmi.Hmolec[ipMH3p]+
06121                 co.H2P_C2_C2P_H2 * hmi.Hmolec[ipMH2p]+  
06122                 co.Hminus_NH4P_NH3_H2 * hmi.Hmolec[ipMHm]+
06123                 co.H3P_HCN_HCNHP_H2 * hmi.Hmolec[ipMH3p];
06124 
06125         /* option to print rate H2 forms */
06126         /* trace.lgTr_H2_Mole is trace molecules option,
06127          * punch htwo */
06128         if( (trace.lgTrace && trace.lgTr_H2_Mole) )
06129         {
06130 
06131                 if( hmi.H2_rate_create > SMALLFLOAT )
06132                 {
06133                         fprintf( ioQQQ, 
06134                                 " Create H2, rate=%10.2e grain;%5.3f hmin;%5.3f bhedis;%5.3f h2+;%5.3f hmi.radasc:%5.3f hmi.h3ph2p:%5.3f hmi.h3petc:%5.3f\n", 
06135                           hmi.H2_rate_create, 
06136                           gv.rate_h2_form_grains_used_total/hmi.H2_rate_create, 
06137                           hmi.assoc_detach * hmi.Hmolec[ipMH] * hmi.Hmolec[ipMHm] /hmi.H2_rate_create, 
06138                           hmi.bh2dis * dense.xIonDense[ipHYDROGEN][0]/hmi.H2_rate_create, 
06139                           hmi.bh2h2p*dense.xIonDense[ipHYDROGEN][0]*hmi.Hmolec[ipMH2p]/hmi.H2_rate_create, 
06140                           hmi.radasc*dense.xIonDense[ipHYDROGEN][0]/hmi.H2_rate_create, 
06141                           hmi.h3ph2p*hmi.Hmolec[ipMH3p]/hmi.H2_rate_create, 
06142                           hmi.h3petc*hmi.Hmolec[ipMH3p]/hmi.H2_rate_create );
06143                 }
06144                 else
06145                 {
06146                         fprintf( ioQQQ, " Create H2, rate=0\n" );
06147                 }
06148         }
06149 
06150         /* this is H2+ */
06151         if( trace.lgTrace && trace.lgTr_H2_Mole )
06152         {
06153                 rate = hmi.rh2h2p*hmi.Hmolec[ipMH2g]*dense.xIonDense[ipHYDROGEN][1] + b2pcin*dense.xIonDense[ipHYDROGEN][1]*dense.eden*dense.xIonDense[ipHYDROGEN][0] + 
06154                   hmi.h3ph2p*hmi.Hmolec[ipMH3p] + hmi.h3petc*hmi.Hmolec[ipMH3p];
06155                 if( rate > 1e-25 )
06156                 {
06157                         fprintf( ioQQQ, " Create H2+, rate=%10.2e hmi.rh2h2p;%5.3f b2pcin;%5.3f hmi.h3ph2p;%5.3f hmi.h3petc+;%5.3f\n", 
06158                           rate, hmi.rh2h2p*dense.xIonDense[ipHYDROGEN][1]*hmi.Hmolec[ipMH2g]/rate, 
06159                                 b2pcin*dense.xIonDense[ipHYDROGEN][1]*dense.xIonDense[ipHYDROGEN][1]*
06160                           dense.eden/rate, hmi.h3ph2p*hmi.Hmolec[ipMH3p]/rate, hmi.h3petc*hmi.Hmolec[ipMH3p]/
06161                           rate );
06162                 }
06163                 else
06164                 {
06165                         fprintf( ioQQQ, " Create H2+, rate=0\n" );
06166                 }
06167         }
06168 
06169         if( hmi.Hmolec[ipMHm] > 0. && hmi.rel_pop_LTE_Hmin > 0. )
06170         {
06171                 hmi.hmidep = (double)hmi.Hmolec[ipMHm]/ SDIV( 
06172                         ((double)dense.xIonDense[ipHYDROGEN][0]*dense.eden*hmi.rel_pop_LTE_Hmin));
06173         }
06174         else
06175         {
06176                 hmi.hmidep = 1.;
06177         }
06178 
06179         /* this will be net volume heating rate, photo heat - induc cool */
06180         hmi.hmihet = hmi.HMinus_photo_heat*hmi.Hmolec[ipMHm] - hmi.HMinus_induc_rec_cooling;
06181         hmi.h2plus_heat = h2phet*hmi.Hmolec[ipMH2p];
06182 
06183         /* departure coefficient for H2 defined rel to n(1s)**2
06184          * (see Littes and Mihalas Solar Phys 93, 23) */
06185         plte = (double)dense.xIonDense[ipHYDROGEN][0] * hmi.rel_pop_LTE_H2g * (double)dense.xIonDense[ipHYDROGEN][0];
06186         if( plte > 0. )
06187         {
06188                 hmi.h2dep = hmi.Hmolec[ipMH2g]/plte;
06189         }
06190         else
06191         {
06192                 hmi.h2dep = 1.;
06193         }
06194 
06195         /* departure coefficient of H2+ defined rel to n(1s) n(p)
06196          * sec den was HI before 85.34 */
06197         plte = (double)dense.xIonDense[ipHYDROGEN][0]*hmi.rel_pop_LTE_H2p*(double)dense.xIonDense[ipHYDROGEN][1];
06198         if( plte > 0. )
06199         {
06200                 hmi.h2pdep = hmi.Hmolec[ipMH2p]/plte;
06201         }
06202         else
06203         {
06204                 hmi.h2pdep = 1.;
06205         }
06206 
06207         /* departure coefficient of H3+ defined rel to N(H2+) N(p) */
06208         if( hmi.rel_pop_LTE_H3p > 0. )
06209         {
06210                 hmi.h3pdep = hmi.Hmolec[ipMH3p]/hmi.rel_pop_LTE_H3p;
06211         }
06212         else
06213         {
06214                 hmi.h3pdep = 1.;
06215         }
06216 
06217 
06218         if( trace.lgTrace && trace.lgTr_H2_Mole )
06219         {
06220                 fprintf( ioQQQ, " HMOLE, Dep Coef, H-:%10.2e H2:%10.2e H2+:%10.2e\n", 
06221                   hmi.hmidep, hmi.h2dep, hmi.h2pdep );
06222                 fprintf( ioQQQ, "     H- creat: Rad atch%10.3e Induc%10.3e bHneut%10.2e 3bod%10.2e b=>H2%10.2e N(H-);%10.2e b(H-);%10.2e\n", 
06223                   hmi.hminus_rad_attach, hmi.HMinus_induc_rec_rate, bhneut, c3bod, hmi.assoc_detach_backwards_grnd, hmi.Hmolec[ipMHm], hmi.hmidep );
06224 
06225                 fprintf( ioQQQ, "     H- destr: Photo;%10.3e mut neut%10.2e e- coll ion%10.2e =>H2%10.2e x-ray%10.2e p+H-%10.2e\n", 
06226                   hmi.HMinus_photo_rate, hmi.hmin_ct_firstions*sum_first_ions, cionhm, 
06227                   Hmolec_old[ipMH]*hmi.assoc_detach, iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s], 
06228                   fhneut );
06229                 fprintf( ioQQQ, "     H- heating:%10.3e Ind cooling%10.2e Spon cooling%10.2e\n", 
06230                   hmi.hmihet, hmi.HMinus_induc_rec_cooling, hmi.hmicol );
06231         }
06232 
06233         /* identify creation and destruction processes for H2+ */
06234         if( trace.lgTrace && trace.lgTr_H2_Mole )
06235         {
06236                 rate = desh2p;
06237                 if( rate != 0. )
06238                 {
06239                         fprintf( ioQQQ, 
06240                                 " Destroy H2+: rate=%10.2e e-;%5.3f phot;%5.3f hard gam;%5.3f H2col;%5.3f h2phhp;%5.3f pion;%5.3f bh2h2p:%5.3f\n", 
06241                           rate, h2pcin*dense.eden/rate, gamtwo/rate, 2.*iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s]/
06242                           rate, hmi.h2ph3p/rate, h2phhp/rate, h2pion/rate, hmi.bh2h2p*
06243                           dense.xIonDense[ipHYDROGEN][0]/rate );
06244 
06245                         rate *= hmi.Hmolec[ipMH2p];
06246                         if( rate > 0. )
06247                         {
06248                                 fprintf( ioQQQ, 
06249                                         " Create  H2+: rate=%.2e HII HI;%.3f Col H2;%.3f HII H2;%.3f HI HI;%.3f\n", 
06250                                   rate, 
06251                                   radath*dense.xIonDense[ipHYDROGEN][1]*dense.xIonDense[ipHYDROGEN][0]/rate, 
06252                                   (hmi.H2_photoionize_rate + secondaries.csupra[ipHYDROGEN][0]*2.02)*hmi.Hmolec[ipMH2g]/rate, 
06253                                   hmi.rh2h2p*dense.xIonDense[ipHYDROGEN][1]*hmi.Hmolec[ipMH2g]/rate, 
06254                                   b2pcin*dense.xIonDense[ipHYDROGEN][0]*dense.xIonDense[ipHYDROGEN][1]*dense.eden/rate );
06255                         }
06256                         else
06257                         {
06258                                 fprintf( ioQQQ, " Create  H2+: rate= is zero\n" );
06259                         }
06260                 }
06261         }
06262 
06263         {
06264                 /* following should be set true to print populations */
06265                 enum {DEBUG_LOC=false};
06266                 if( DEBUG_LOC )
06267                 {
06268                         fprintf(ioQQQ,"hmole bugg\t%.3f\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
06269                                 fnzone,
06270                                 iso.gamnc[ipH_LIKE][ipHYDROGEN][0],
06271                                 hmi.HMinus_photo_rate,
06272                                 hmi.Hmolec[ipMH2g] , 
06273                                 hmi.Hmolec[ipMHm] ,
06274                                 dense.xIonDense[ipHYDROGEN][1]);
06275                 }
06276         }
06277         return;
06278 }
06279 #if defined(__HP_aCC)
06280 #pragma OPTIMIZE OFF
06281 #pragma OPTIMIZE ON
06282 #endif
06283 /*lint +e778 const express eval to 0 */
06284 /*lint +e725 expect positive indentation */

Generated on Mon Feb 16 12:01:19 2009 for cloudy by  doxygen 1.4.7