cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mole_h_step.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*hmole_step do a step in chemical network */
4 /*hmirat compute radiative association rate for H- */
5 /* >> chng 02 nov 7 rjrw, Mole Moreliano:
6  * changes to linearized iterative form */
7 /* from Robin Williams:
8 The process for these kind of problems seems to be pretty uniform:
9 switch printsol on to check which terms in the chemical matrix change,
10 and next to switch on the prints in the matrix assembly which apply to
11 the species involved to find what reactions are involved. It's a bit
12 of a pain grepping down to find the 47th reaction, so I guess some
13 kind of naming scheme for the reactions may come in handy (I'd thought
14 about generating the in and out vectors from a text string, e.g. "H +
15 H => H2";-), but you'd have to verify uniqueness).
16 */
17 /*lint -e778 const express evaluates to 0 */
18 /*lint -e725 expect positive indentation */
19 #include "cddefines.h"
20 #include "physconst.h"
21 #include "iso.h"
22 #include "atmdat.h"
23 #include "grainvar.h"
24 #include "ionbal.h"
25 #include "dense.h"
26 #include "secondaries.h"
27 #include "mole.h"
28 #include "mole_co_priv.h"
29 #include "opacity.h"
30 #include "rfield.h"
31 #include "thermal.h"
32 #include "timesc.h"
33 #include "trace.h"
34 #include "phycon.h"
35 #include "doppvel.h"
36 #include "thirdparty.h"
37 #include "gammas.h"
38 #include "h2.h"
39 #include "dynamics.h"
40 #include "conv.h"
41 #include "radius.h"
42 #include "hextra.h"
43 #include "hmi.h"
44 
45 /* HP cc cannot compile following except in -O1 mode */
46 #if defined(__HP_aCC)
47 # pragma OPT_LEVEL 1
48 #endif
49 
50 #define ABSLIM 1e-12
51 
52 /* Calculate number of elements in an integer vector */
53 #define INTSZ(a) (sizeof(a)/sizeof(int))
54 
55 struct Hmole_rate_s {
56  int index;
61  double rk;
62  struct Hmole_rate_s *next;
63 };
64 typedef struct Hmole_rate_s reaction;
65 
66 /* Generate new element for reaction list */
68  /* reaction index, a number to reference current reaction */
69  int rindex,
70  /* vector of ints that are incoming species, the reactants */
71  int *in,
72  /* number of reactants */
73  int nin,
74  /* same for products */
75  int *out,
76  /* number of products */
77  int nout,
78  /* rate determining species if they are not the same as the reactants,
79  * these are non-null in cases where a part of the chemical network
80  * acts as a catalyst in the reaction
81  * as H2g + H2g -> H2g + H2* or where */
82  int *rate,
83  /* number of these */
84  int nrate)
85 {
86  static reaction *list = NULL, *r;
87  static int poolsize=1, index = 0;
88  int i;
89 
90  /* this routine is called only to initialize structure with information
91  * on the reactants and products - this does not change, so no need
92  * to do this but once. In later cases only the rate coefficients are
93  * updated in hmole_step
94  * in hmole_stop on later call linked list is incremented upon each
95  * reaction, and rate coefficient for current temperature is stored
96  * in r->rk
97  * r is pointer to structure of reaction information including
98  * r->next, which is the next reaction in the linked list */
99  /* fprintf(ioQQQ,"New reaction %d %d %d\n",rindex,nin,nout); */
100 
101  /* default assumption for chemical kinetics,
102  * rate is determined by all incoming species that are in *in
103  * when not null then the rate determining species are not the
104  * same as *in */
105  if(rate == NULL)
106  {
107  rate=in;
108  nrate=nin;
109  }
110 
111  /* space for the linked list "list" */
112  /*lint -e701 shift left of signed quantity */
113  if(list == NULL || index == poolsize)
114  {
115  poolsize <<=1;
116  list = ((reaction *)MALLOC( (size_t)poolsize*sizeof(reaction) ));
117  index = 0;
118  }
119  /*lint +e701 */
120 
121  /* fprintf(ioQQQ,"Getting element %d+1 of %d\n",index,poolsize); */
122  r = list+index;
123  index++;
124  r->next = NULL;
125  r->index = rindex;
126  ASSERT(nin <= MAXREACTANTS && nout <= MAXPRODUCTS && nrate <= MAXREACTANTS);
127 
128  r->nreactants = nin;
129  r->nrates = nrate;
130  r->nproducts = nout;
131 
132  /* incoming reactants */
133  for(i=0; i<r->nreactants; i++)
134  r->reactants[i] = in[i];
135 
136  /* rate determining species */
137  for(i=0; i<r->nrates; i++)
138  r->rate_species[i] = rate[i];
139 
140  /* outgoing products */
141  for(i=0; i<r->nproducts; i++)
142  r->products[i] = out[i];
143 
144  return r;
145 }
146 
147 // icc 10.0 miscompiles this routine with higher optimization
148 #if defined (__ICC) && defined(__amd64)
149 #pragma optimization_level 1
150 #endif
151 
152 /*hmole_step do a step in chemical network */
153 void hmole_step(int *nFixup, double *error)
154 {
155  enum {PRINTSOL = false};
156 
157  int32 ipiv[N_H_MOLEC];
158 
159  long int i,
160  ipConserve,
161  j,
162  limit ,
163  nd,
164  mol;
165 
166  int printsol = PRINTSOL;
167 
168  bool lgNegPop;
169  int iworst;
170  /* >>chng 05 jul 31, from float to double, since very nearly 1 for H - route */
171  double frac_H2star_grains,
172  frac_H2star_hminus;
173  double sum_first_ions;
174 
175  double
176  bhneut,
177  Hneut,
178  c3bod,
179  cionhm,
180  corr,
181  H2star_deexcit,
182  deexc_htwo,
183  deexc_hneut,
184  desh2p,
185  etmp,
186  eh3p_3h,
187  Boltz_fac_H2_H2star,
188  fhneut,
189  gamheh,
190  h1fnd,
191  h1rat,
192  h2pcin,
193  h2phhp,
194  h2pion,
195  H2star_excit ,
196  radath,
197  hmihph2p,
198  h2phmhhh,
199  h2crphh,
200  h2scrphh,
201  h2crphphm,
202  h2scrphphm,
203  h2crphpeh,
204  h2scrphpeh,
205  h2crh2pe,
206  h2crhphe,
207  h2scrhphe,
208  h2scrh2pe,
209  h2pehh,
210  h3ph2ph,
211  hphmhhpe,
212  h2hmhh2e,
213  hehmeheh,
214  hephmhhe,
215  fracneg,
216  fracnegtmp,
217  fracnegfac,
218  sum_H0_Hp,
219  conserve,
220  rate,
221  rk,
222  rated,
223  rate_deriv[MAXREACTANTS],
224  sinkrate[MAXREACTANTS],
225  T_ortho_para_crit ,
226  TStancil;
227 
228 
229  static double
230  gamtwo,
231  h2phet,
232  proton_sum_old,
233  proton_sum_new;
234 
235  static double /*amat[N_H_MOLEC][N_H_MOLEC], */
236  b2pcin,
237  *amat=NULL,
238  *bvec=NULL/*[N_H_MOLEC]*/,
239  *Hmolec_old=NULL/*[N_H_MOLEC]*/,
240  **c=NULL/*[N_H_MOLEC+1][N_H_MOLEC+1]*/,
241  plte;
242  static double oatomic = -1., oion = -1.;
243  /*static long int iter_eval = -2;*/
244 
245  /* if this is still true then must create space for arrays */
246  static bool lgMustMalloc = true;
247 
248  static reaction *rlist = NULL;
249  reaction *r;
250  long int rindex, ratei, ratej;
251 
252  DEBUG_ENTRY( "hmole_step()" );
253 
254  if( lgMustMalloc )
255  {
256  /* on very first call must create space */
257  lgMustMalloc = false;
258 
259  bvec = ((double*)MALLOC( (size_t)N_H_MOLEC*sizeof(double) ));
260  Hmolec_old = ((double*)MALLOC( (size_t)N_H_MOLEC*sizeof(double) ));
261  amat = ((double*)MALLOC( (size_t)(N_H_MOLEC*N_H_MOLEC)*sizeof(double) ));
262  c = ((double**)MALLOC( (size_t)N_H_MOLEC*sizeof(double *) ));
263  for( i=0; i<N_H_MOLEC; ++i )
264  {
265  /* this is the Jacobian array, MALLOC sets it to NaN, first reagents
266  * will be filled in, then Jacobian array set in loop below. Search
267  * for Jacobian array */
268  c[i] = ((double*)MALLOC( (size_t)N_H_MOLEC*sizeof(double) ));
269  }
270  }
271 
272  /* Assume no error for cases with abundances set */
273  *error = 0;
274 
275  /* there are two "no molecules" options, the no co, which turns off everything,
276  * and the no n2, which only turns off the h2. in order to not kill the co
277  * part we still need to compute the hydrogen network here, and then set h2 to
278  * small values */
279  if( hmi.lgNoH2Mole )
280  {
282 
283  /* these are the molecular species */
284  for(mol=0; mol<N_H_MOLEC; ++mol)
285  {
286  hmi.Hmolec[mol] = 0.;
287  }
290  hmi.H2_total = 0.;
291  /* this is where the transition struc expects to find the H2 abundance */
292  dense.xIonDense[LIMELM+2][0] = 0.;
293  hmi.hmihet = 0.;
294  hmi.h2plus_heat = 0.;
295  hmi.H2Opacity = 0.;
296  hmi.hmicol = 0.;
297  hmi.hmidep = 1.;
298  hmi.rh2dis = 0.;
299  hmi.HalphaHmin = 0.;
300 
301  hmi.HeatH2Dish_used = 0.;
302  hmi.HeatH2Dish_BigH2 = 0.;
303  hmi.HeatH2Dish_TH85 = 0.;
304  hmi.HeatH2Dish_BD96 = 0.;
305  hmi.HeatH2Dish_BHT90 = 0.;
306  hmi.HeatH2Dish_ELWERT = 0.;
307 
310  hmi.HeatH2Dexc_used = 0.;
311  hmi.HeatH2Dexc_BigH2 = 0.;
312  hmi.HeatH2Dexc_TH85 = 0.;
313  hmi.HeatH2Dexc_BD96 = 0.;
314  hmi.HeatH2Dexc_BHT90 = 0.;
315  hmi.HeatH2Dexc_ELWERT = 0.;
316 
324  return;
325  }
326 
327  /* option to force H2 abundance, for testing h2 molecules,
328  * hmi.H2_frac_abund_set is fraction in molecules that is set by
329  * set h2 fraction command */
330  if( hmi.H2_frac_abund_set>0.)
331  {
332  for(mol=0;mol<N_H_MOLEC;mol++)
333  {
334  hmi.Hmolec[mol] = 0.;
335  }
336  /* >>chng 03 jul 19, from 0 to SMALLFLOAT, to pass asserts in ConvBase,
337  * problem is that ion range has not been reset for hydrogen */
340  /* put it all in the ground state */
342  hmi.Hmolec[ipMH2s] = 0.;
343 
345  /* first guess at ortho and para densities */
346  h2.ortho_density = 0.75*hmi.H2_total;
347  h2.para_density = 0.25*hmi.H2_total;
348 
349  hmi.hmihet = 0.;
350  hmi.h2plus_heat = 0.;
351  hmi.H2Opacity = 0.;
352  hmi.hmicol = 0.;
353  hmi.HeatH2Dish_TH85 = 0.;
354  hmi.HeatH2Dexc_TH85 = 0.;
356  hmi.hmidep = 1.;
357  hmi.HalphaHmin = 0.;
358 
359  for( nd=0; nd < gv.nBin; nd++ )
360  {
361  gv.bin[nd]->rate_h2_form_grains_used = 0.;
362  }
363  return;
364  }
365 
366  /* update these two to current values of atomic and ionized hydrogen density */
369  /* now copy all of H moles into old array */
370  for(mol=0;mol<N_H_MOLEC;mol++)
371  {
372  Hmolec_old[mol] = hmi.Hmolec[mol];
373  }
374  for(i=0; i<MAXREACTANTS; ++i )
375  {
376  rate_deriv[i] = 0.;
377  sinkrate[i] = 0.;
378  }
379 
380  /* collisional ionization of H-, rate from Janev, Langer et al. */
381  if( phycon.te < 3074. )
382  {
383  cionhm = 1.46e-32*(powi(phycon.te,6))*phycon.sqrte*hmi.exphmi;
384  }
385  else if( phycon.te >= 3074. && phycon.te < 30000. )
386  {
387  cionhm = 5.9e-19*phycon.tesqrd*phycon.sqrte*phycon.te05;
388  }
389  else
390  {
391  cionhm = 3e-7;
392  }
393 
394  /* H2 formation on grains;
395  * rate from
396  * >>refer H2 grain formation Hollenbach, D., & McKee, C.F., 1979, ApJS, 41, 555 eq 3.4 3.8 */
397  if( gv.lgDustOn )
398  {
399 
400 # ifndef IGNORE_QUANTUM_HEATING
401  /* hmole is called before grains, so assure that all the grain stuff is properly initialized */
402  GrainDrive();
403 # endif
404 
405  /* these are rates (s-1) H2 will be deactivated by collisions with grains
406  * will be incremented below
407  * H2 ortho - para conversion on grain surface */
409  /* rate (s-1) v=0, J=1 level goes to 0 */
411 
412  /* loop over all grain species */
413  for( nd=0; nd < gv.nBin; nd++ )
414  {
415 # ifndef IGNORE_QUANTUM_HEATING
416  long k, qnbin;
417  double *qtemp, *qprob;
418  bool lgUseQHeat = gv.lgGrainPhysicsOn && gv.bin[nd]->lgQHeat;
419 # endif
420  /* >>chng 02 feb 15, removed check tedust > 1.01, change in GrainsInit
421  * guarantees that all relevant parameters are initialized, PvH */
422 
423  /* sticking probability, 2H + grain equation 3.7 of
424  * >>refer grain phys Hollenbach, D.J., & McKee, C.F., 1979, ApJS, 41, 555,
425  * fraction of H impacts on grain surface that stick */
426  /* this sticking probability is used for both HM79 and CT02 */
427  double sticking_probability_H = 1./(1. + 0.04*sqrt(gv.bin[nd]->tedust+phycon.te) +
428  0.002*phycon.te + 8e-6*phycon.te*phycon.te);
429 
430 # ifndef IGNORE_QUANTUM_HEATING
431  /* >>chng 04 feb 21, included quantum heating in calculation of formation rate, PvH */
432  if( lgUseQHeat )
433  {
434  qtemp = (double*)MALLOC((size_t)(NQGRID*sizeof(double)));
435  qprob = (double*)MALLOC((size_t)(NQGRID*sizeof(double)));
436 
437  qheat(qtemp,qprob,&qnbin,nd);
438 
439  if( gv.bin[nd]->lgUseQHeat )
440  {
441  ASSERT( qnbin > 0 );
442  }
443  else
444  {
445  qnbin = 1;
446  qprob[0] = 1.;
447  qtemp[0] = gv.bin[nd]->tedust;
448  }
449 
450  gv.bin[nd]->rate_h2_form_grains_HM79 = 0.;
451 
452  for( k=0; k < qnbin; k++ )
453  {
454  /* fraction of impacts that produce H2 before evaporation from grain surface.
455  * this is equation 3.4 of
456  * >>refer grain phys Hollenbach, D.J., & McKee, C.F., 1979, ApJS, 41, 555
457  * 1e4 is ratio of total absorption sites to appropriate sites
458  * 920 is D_H and chosen to get f_a = 0.5 at 100 K.
459  * factor of 0.6252 needed to obtain std ism rate to be 3e-17 at 100 K,
460  * the value deduced by
461  * >>refer H2 grain physics Jura, M., 1974, ApJ, 197, 581 */
462  double conversion_efficiency_HM79 = 1/(1. + 1e4*sexp(920./qtemp[k]));
463  sticking_probability_H = 1./(1. + 0.04*sqrt(qtemp[k]+phycon.te) +
464  0.002*phycon.te + 8e-6*phycon.te*phycon.te);
465 
466  gv.bin[nd]->rate_h2_form_grains_HM79 += qprob[k] * sticking_probability_H *
467  conversion_efficiency_HM79;
468  }
469 
470  /* NB IntArea is total, not projected, area, must div by 4 */
471  /* gv.bin[nd]->rate_h2_form_grains_HM79 has units s^-1 since gv.bin[nd]->cnv_H_pCM3 has units cm-3 */
472  /* cnv_H_pCM3 converts <unit>/H (default depletion) -> <unit>/cm^3 (actual depletion), units are cm-3 */
474  gv.bin[nd]->IntArea/4. * gv.bin[nd]->cnv_H_pCM3;
475 
476  ASSERT( gv.bin[nd]->rate_h2_form_grains_HM79 > 0. );
477  }
478  else
479 # endif
480  {
481  /* fraction of impacts that produce H2 before evaporation from grain surface.
482  * this is equation 3.4 of
483  * >>refer grain phys Hollenbach, D.J., & McKee, C.F., 1979, ApJS, 41, 555
484  * 1e4 is ratio of total absorption sites to appropriate sites
485  * 920 is D_H and chosen to get f_a = 0.5 at 100 K.
486  * factor of 0.6252 needed to obtain std ism rate to be 3e-17 at 100 K,
487  * the value deduced by
488  * >>refer H2 grain physics Jura, M., 1974, ApJ, 197, 581 */
489  double conversion_efficiency_HM79 = 1/(1. + 1e4*sexp(920./gv.bin[nd]->tedust));
490 
491  /* NB IntArea is total area per H for default abundances, not projected area, must div by 4
492  * units s^-1 since gv.bin[nd]->cnv_H_pCM3 has units H cm-3
493  * final units are cm s-1*/
495  /* cnv_H_pCM3 converts <unit>/H (default depletion) -> <unit>/cm^3 (actual depletion), units are cm-3 */
496  gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H * conversion_efficiency_HM79;
497  ASSERT( gv.bin[nd]->rate_h2_form_grains_HM79 > 0. );
498  }
499 
500 # ifndef IGNORE_QUANTUM_HEATING
501  if( lgUseQHeat )
502  {
503  /* H2 formation on grains from
504  * >>refer H2 form Cazaux, S., & Tielens, A.G.G.M., 2002, ApJ, 575, L29 */
505  /* number of monolayers per second - only affects efficiency at very low or high temperatures */
506  double f = 1e-10;
507  /* equation 17
508  double sqrt_term = POW2( 1. + sqrt( (10000.-200.)/(600.-200.) ) );*/
509  double sqrt_term = 35.399494936611667;
510 
511  gv.bin[nd]->rate_h2_form_grains_CT02 = 0.;
512 
513  for( k=0; k < qnbin; k++ )
514  {
515  double beta_alpha = 0.25 * sqrt_term *sexp(200./qtemp[k] );
516  /* equation 16 */
517  double xi = 1./ (1. + 1.3e13*sexp(1.5*1e4/qtemp[k])*sqrt_term/(2.*f) );
518  /* expression for beta comes from just after equation 5 */
519  double beta = 3e12 * sexp( 320. / qtemp[k] );
520  /* recombination efficiency given by their equation 15, they call
521  * this epsilon_H2 */
522  double recombination_efficiency_CT02 = xi / (1. + 0.005*f/2./SDIV(beta) + beta_alpha );
523  sticking_probability_H = 1./(1. + 0.04*sqrt(qtemp[k]+phycon.te) +
524  0.002*phycon.te + 8e-6*phycon.te*phycon.te);
525 
526  /* printf( " k %ld Td %.6e re*sp %.6e\n", k, qtemp[k], recombination_efficiency_CT02* */
527  /* sticking_probability_H ); */
528 
529  gv.bin[nd]->rate_h2_form_grains_CT02 += qprob[k] * sticking_probability_H *
530  recombination_efficiency_CT02;
531  }
532 
533  /* gv.bin[nd]->IntArea integrated grain surface area Int(4pi*a^2), normalized per H, in cm^2/H,
534  * so x/4 is projected area of circle */
535  /* gv.bin[nd]->cnv_H_pCM3 is H density [cm-3] times grain depletion factor */
536  /* gv.bin[nd]->rate_h2_form_grains_CT02 units s-1 */
538  gv.bin[nd]->IntArea/4. * gv.bin[nd]->cnv_H_pCM3;
539 
540  ASSERT( gv.bin[nd]->rate_h2_form_grains_CT02 > 0. );
541 
542  free(qtemp);
543  free(qprob);
544  }
545  else
546 # endif
547  {
548  /* H2 formation on grains from
549  * >>refer H2 form Cazaux, S., & Tielens, A.G.G.M., 2002, ApJ, 575, L29 */
550  /* number of monolayers per second - only affects efficiency at very low or high temperatures */
551  double f = 1e-10;
552  /* equation 17
553  double sqrt_term = POW2( 1. + sqrt( (10000.-200.)/(600.-200.) ) );*/
554  double sqrt_term = 35.399494936611667;
555  double beta_alpha = 0.25 * sqrt_term *sexp(200./gv.bin[nd]->tedust );
556  /* equation 16 */
557  double xi = 1./ (1. + 1.3e13*sexp(1.5*1e4/ gv.bin[nd]->tedust )*sqrt_term/(2.*f) );
558  /* expression for beta comes from just after equation 5 */
559  double beta = 3e12 * sexp( 320. / gv.bin[nd]->tedust );
560  /* recombination efficiency given by their equation 15, they call
561  * this epsilon_H2 */
562  double recombination_efficiency_CT02 = xi / (1. + 0.005*f/2./SDIV(beta) + beta_alpha );
563 
564  /* gv.bin[nd]->IntArea integrated grain surface area Int(4pi*a^2), normalized per H, in cm^2/H,
565  * so x/4 is projected area of circle */
566  /* gv.bin[nd]->cnv_H_pCM3 is H density [cm-3] times grain depletion factor */
567  /* units s-1 */
569  gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H * recombination_efficiency_CT02;
570  ASSERT( gv.bin[nd]->rate_h2_form_grains_CT02 > 0. );
571  }
572 
573 # ifndef IGNORE_QUANTUM_HEATING
574  /* reset sticking probability for code below */
575  sticking_probability_H = 1./(1. + 0.04*sqrt(gv.bin[nd]->tedust+phycon.te) +
576  0.002*phycon.te + 8e-6*phycon.te*phycon.te);
577 # endif
578 
579  /* rate (s-1) all H2 v,J levels go to 0 or 1, preserving nuclear spin */
580  /* ortho to para on grain surfaces, taken from
581  *>refer H2 sticking Le Bourlot, J., 2000, A&A, 360, 656-662
582  * >chng 05 apr 30, GS, hmi.H2_total/dense.gas_phase[ipHYDROGEN] is removed
583  * This is used in h2.c.
584  * NB IntArea is total are per H, not projected area, must div by 4
585  * gv.bin[nd]->cnv_H_pCM3 has units H cm-3 to product with above
586  * is cm2/H H/cm3 or cm-1 or an opacity
587  * multiply by velocity of H2, cm s-1, so product
588  * hmi.rate_grain_h2_op_conserve has units s^-1 */
590  gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H;
591 
592  /* ortho to para on grain surfaces, taken from
593  *>refer H2 sticking Le Bourlot, J., 2000, A&A, 360, 656-662
594  * For all grain temperatures, this process corresponds to high J going to
595  * either 0 or 1 preserving nuclear spin. All ortho go to 1 and para go to 0.
596  * When the dust temperature is below Tcrit all 1 go to 0 and so all J go to 0.
597 
598  * this temperature depends on grain composition, discussion left column of page 657,
599  * this is for a bare grain */
608  /* AveVEl[LIMELM+2] is average speed of H2 molecules
609  * for now assume that sticking probability for H2 on the grain is equal to
610  * that for H
611  * efficiency factor efficiency_opr is vary fast function of t dust -
612  * large at low Td and small at Td > T_ortho_para_crit
613  * start evaluating just above the critical temperature
614  * T_ortho_para_crit this is roughly 24.345 K,GS */
615  T_ortho_para_crit = 2. * hmi.Tad / log( POW2(60. *1.1e11)*hmi.Tad);
616  if( gv.bin[nd]->tedust < T_ortho_para_crit )
617  {
618  double efficiency_opr = sexp(60.*1.1e11*sqrt(hmi.Tad)*sexp(hmi.Tad/gv.bin[nd]->tedust));
619  /* rate (s-1) all v,J levels go to 0, regardless of nuclear spin
620  * see above discussion for how units work out */
622  gv.bin[nd]->cnv_H_pCM3 * sticking_probability_H * efficiency_opr;
623  }
624  }
625  /*fprintf(ioQQQ," H2 grain form rate HM79 %.2e %.2e CT02 %.2e %.2e O-P grn %.2e %.2e\n",
626  gv.bin[nd]->rate_h2_form_grains_HM79 ,
627  gv.bin[nd]->rate_h2_form_grains_HM79 ,
628  gv.bin[nd]->rate_h2_form_grains_CT02 ,
629  gv.bin[nd]->rate_h2_form_grains_CT02 ,
630  hmi.rate_grain_h2_J1_to_J0,
631  hmi.rate_h2_allX_2_J1_grains
632  );*/
633  /* options to turn off grain collision with atom h2 collisions grains off command */
636 
637  }
638  else
639  {
640  /* grains are not enabled, set these to zero */
641  for( nd=0; nd < gv.nBin; nd++ )
642  {
643  gv.bin[nd]->rate_h2_form_grains_CT02 = 0.;
644  gv.bin[nd]->rate_h2_form_grains_HM79 = 0.;
645  }
646  /* rate all H2 goes to either 0 or 1 depending on ortho/para */
648  /* at low temp, rate all H2 goes to J=0 */
650  }
651 
652  /* the H2 catalysis rate on grains that is actually used in calculations
653  * hmi.ScaleJura is scale factor set with set Jura scale command
654  * units are s-1
655  * default is 'C' Cazaux & Tielens */
657  for( nd=0; nd < gv.nBin; nd++ )
658  {
659  if( hmi.chJura == 'C' )
660  {
661  /* use the new rate by
662  * >>refer H2 form Cazaux, S., & Tielens, A.G.G.M., 2002, ApJ, 575, L29
663  * units are s-1*/
667  }
668  else if( hmi.chJura == 'T' )
669  {
670  /* rate from Hollenbach & McKee 1979 */
674  }
675  else if( hmi.chJura == 'S' )
676  {
677  /* H2 formation rate from
678  * >>refer H2 form Sternberg, A. & Neufeld, D.A. 1999, ApJ, 516, 371 */
681  /* this is simple rate from Sternberg & Neufeld 99 */
683  }
684  /*>>chng 07 jan 10, this had been C for constant, and so could never have been triggered.
685  * caught by robin Williams, fixed by nick Abel, error was in sense that any set jura rate
686  * would use Cazaux & Tielens */
687  else if( hmi.chJura == 'F' )
688  {
689  /* command "set H2 rate" - enters log of Jura rate - C for constant,
690  * no dependence on grain properties */
693  }
694  }
696 
697 # ifndef IGNORE_QUANTUM_HEATING
698  printf( " fnzone %.2f H2 rate %.4e\n", fnzone, gv.rate_h2_form_grains_used_total );
699 # endif
700 
701  /* >>chng 03 sep 09, get ratio of excited to ground state H2 */
703  {
704  frac_H2star_grains = hmi.H2star_forms_grains /
706 
707  frac_H2star_hminus = hmi.H2star_forms_hminus /
709 
710  /* option print statement for above */
711  /*printf( "DEBUG H2s frac grain %.3e f(H2g) %.3e ",frac_H2star_grains ,
712  hmi.H2_forms_grains/SDIV(hmi.H2star_forms_grains+hmi.H2_forms_grains) );
713  printf( " H2s frac h- %.3e f(H2g) %.3e\n",frac_H2star_hminus ,
714  hmi.H2_forms_hminus/SDIV(hmi.H2star_forms_hminus+hmi.H2_forms_hminus));*/
715  }
716  else
717  {
718  /* the large H2 molecule was not evaluated, so we can't use exact
719  * branching ratios. These are the distribution fractions for around 500K */
720  /*These depend on temperature and distribution function and the definition of ENERGY_H2_STAR.
721  So reset the values properly*/
722  /* >>chng 05 jul 13, TE, with the new definition of H2s these are both 1 */
723  /* >>chng 05 jul 31, activate above print, rest for current 0.5 ev defn */
724  frac_H2star_grains = 0.9416;
725  frac_H2star_hminus = 1. - 4.938e-6;
726  }
727 
728  /* print rate coefficient */
729  /*fprintf(ioQQQ," total grain h2 form rate %.3e\n",gv.rate_h2_form_grains_used_total);*/
730 
731  /* collisional dissociation, rate from
732  * >>refer H2 collisional dissociation Dove, J.E., and Mandy, M. E., 1986, ApJ, 311, L93.
733  * corr is correction for approach to high density limit
734  * H2 + H => 3H - rate very uncertain */
735  corr = MIN2(6.,14.44-phycon.alogte*3.08);
736 
737  if(corr > 0.)
738  corr = pow(10.,corr*Hmolec_old[ipMH]/(Hmolec_old[ipMH]+1.6e4));
739  else
740  corr = 1.;
741  /* must kill H- when UMIST is in place since they do not consider it */
742  hmi.rh2dis = (realnum)(1.55e-8/phycon.sqrte*sexp(65107./phycon.te)* corr)*co.lgUMISTrates;
743 
744  /* old hminus rate Hollenbach & McKee 1979
745  *>>chng 98 jan 02, from 2.12e4 to 2.123e4 */
746  /*hmi.bh2h2p = 1.8e-12f*phycon.sqrte*phycon.te10/phycon.te01*2.f/16.f;
747  hmi.rh2h2p = 1.8e-12*phycon.sqrte*phycon.te10/phycon.te01*sexp(2.123e4/
748  phycon.te);*/
749 
750  /* forward and back reactions for H2+ + H+ <=> H2+ + H */
751  /*>>chng 02 oct 25, update rate from above (Hollenbach & McKee 1979) to
752  * >>refer H2 form Karpas, Z., Anicich, V., & Huntress, W.T. 1979, J Chem Phys, 70, 2877
753  * following is from this paper.\:
754  We note that the application of detailed balance is only strictly valid for
755  state-to-state reactions, i.e., when the , J level of the reactant and product
756  molecules are known. While typical laboratory conditions are such that = 0 and J
757  is likely to be small for the reactant, the product , J is usually unknown.
758  For example, Krsti (2002) finds that for the reverse of reaction (1), the product
759  H2 is primarily formed into = 4, not = 0. Therefore, estimation of reaction (1)
760  by the application of detailed balance to the measured rate coefficient for the
761  reverse reaction gives the rate coefficient for H2( = 4), which can be as much as
762  an order of magnitude larger than for H2( = 0). Rate coefficients that are estimated
763  by detailed balance are therefore suspect.
764  */
765 
766  /* H2+ + H => H2 + H+ */
767  hmi.bh2h2p = 6.4e-10f;
768 # if 0
769  /* H2 + H+ => H2+ + H
770  * >>chng 04 Feb 24, get back reaction from above */
771  if(hmi.rel_pop_LTE_H2g != 0.)
773  else
774  hmi.rh2h2p = 0;
775 # endif
776  /*>> refer H2 chem Savin, D.W., Krstic, P.S., Haiman, Z., & Stancil, P.C., 2004,
777  *>>refercon ApJL, 606L, 167, astro-ph/0404288 */
778  if(phycon.te<=3.e4 )
779  {
780  /* this is lower bound to their temperature */
781  double teused = MAX2(100., phycon.te );
782  double telog = log(teused);
783  hmi.rh2h2p = sexp(2.123715e4/teused)*(-3.3232183e-7 + 3.3735382e-7*log(teused) -
784  1.4491368e-7*pow(telog,2) +3.4172805e-8*pow(telog,3) -
785  4.781372e-9*pow(telog,4) + 3.9731542e-10*pow(telog,5) -
786  1.8171411e-11*pow(telog,6) +3.5311932e-13*pow(telog,7));
787  /* option to kill process when Leiden hacks are in place */
789  }
790  else
791  hmi.rh2h2p= 0;
792 
793  /* >>chng 05 aug 05 NPA comment The UMIST rate uses a different photorate for H2+. We do it better.
794  Therefore, for this case we use the UMIST rate only when the UMIST hack is set.
795  We cannot actually turn off all H- reactions because to do so would cause the matrix solver
796  to crash. Therefore a couple of reactions still exist, but do not affect the Leiden models */
797 
798  /* H2+ + HNU => H+ + H */
799  gamtwo = GammaK(opac.ih2pnt[0],opac.ih2pnt[1],opac.ih2pof,1.);
800 
801  /* this only occurs when set units rates is entered */
802  if(!co.lgUMISTrates)
803  gamtwo = 5.7e-10*hmi.UV_Cont_rel2_Habing_TH85_face*(realnum)sexp((1.9*rfield.extin_mag_V_point))/1.66f;
804 
805  /*GammaPrt(opac.ih2pnt[0],opac.ih2pnt[1],opac.ih2pof,ioQQQ,gamtwo,0.01);*/
806 
807  h2phet = thermal.HeatNet;
808 
809  /* >> chng 02 nov 15 rjrw: ionization fractions to multiply c[ipHo][*] terms
810  * as b[ipMHo] contains _both_ H0 and H+ */
811  /* sum_H0_Hp = ((double)dense.xIonDense[ipHYDROGEN][0])+((double)dense.xIonDense[ipHYDROGEN][1]); */
812 
813  sum_H0_Hp = Hmolec_old[ipMH]+Hmolec_old[ipMHp];
814 
815  rindex = 0;
816  r = rlist;
817  /* Special case, put null reaction at head of list */
818  if(r == NULL)
819  {
820  int in[]={-1},out[]={-1};
821  r = rlist = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
822  }
823  rindex++;
824 
825  /*-------------------------------------------------------------------- */
826 
827  /* H- H minus hminus balance equations
828  * (IHMI,IPMHO) == processes making H- from Ho =+sign
829  * radiative attachment: HI + NE => H-
830  * H + e -> H- + hnu */
831  /* Use Newton-Raphson step to improve solution, so bvec[] contains reaction rates
832  * and c[][] components of the Jacobian of the rates */
833 
834  /* This block adds a reaction H => H- to the stack if it wasn't
835  * there already.
836  *
837  * >>>> ONLY CHANGE the elements of the in[] and out[] vectors and
838  * the rate constant, keep the rest fixed for all reactions
839  * */
840  if(r->next == NULL) {
841  int in[]={ipMH},out[]={ipMHm};
842  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
843  }
844  r = r->next;
845  rindex++;
846 
847  /* >>chng 05 aug 05, NPA comment: The Leiden comparison does not consider H-. Therefore the UMIST hack
848  is used to turn off H- so that it is never important */
849 
851 
852  /* >>chng 02 oct 29, add these two chemical processes */
853  /* H- + H+ => H2+ + e
854  * equation (H6) from
855  * >>refer H2 chemistry Galli,D., & Palla, F. 1998, A&A, 335, 403-420
856  * hmihph2p = 6.9e-9f*(Tg)^(-0.35) for Tg<=8000
857  * hmihph2p = 6.9e-9f*(Tg)^(-0.9) for Tg>=8000 */
858  /* >>chng 02 nov 07 rjrw, include H+ ion density in rate constant */
859  if(phycon.te <= 7891.)
860  {
861  /*hmihph2p = 6.9e-9*pow(phycon.te , -0.35);*/
862  hmihph2p = 6.9e-9 / (phycon.te30 * phycon.te05);
863  }
864  else
865  {
866  /* >>chng 02 nov 18, had typo for leading coefficient here */
867  /*hmihph2p = 9.6e-7*pow(phycon.te , -0.9);*/
868  hmihph2p = 9.6e-7 / phycon.te90;
869  }
870 
871  if(r->next == NULL) {
872  int in[]={ipMHm,ipMHp},out[]={ipMH2p};
873  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
874  }
875  r = r->next;
876  rindex++;
877 
878  /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.
879  Therefore the UMIST hack is used to turn off H- so that it is never important */
880 
881  hmihph2p = hmihph2p*co.lgUMISTrates;
882  r->rk = hmihph2p;
883 
884  /* >>chng 03 feb 6 */
885  /* H2+ + H- => H2 + H
886  * equation (32) from
887  * >>refer H2+ k Stancil, P.C, & Lepp, S, & Dalgarno, A. 1998,ApJ, 509, 1-10
888  * h2phmh2h = 1.4e-7f*pow(phycon.te/300.0, -0.5) */
889  /* >>chng 03 sep 01, rm the pow function */
890  /*h2phmh2h = 1.4e-7f*pow(phycon.te/300 , -0.5);*/
891  /* the fits in this paper cannot be used below 10K or above 1e4K. Limit
892  * the range of evaluation */
893  TStancil = MIN2(phycon.te, 1e4 );
894  TStancil = MAX2( TStancil , 10. );
895 
897  /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.
898  Therefore the UMIST hack is used to turn off H- so that it is never important */
899 
900  hmi.h2phmh2h = 1.4e-7*co.lgUMISTrates*17.305/phycon.sqrte;
901  if(r->next == NULL) {
902  int in[]={ipMH2p,ipMHm},out[]={ipMH2g,ipMH};
903  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
904  }
905  r = r->next;
906  rindex++;
907  r->rk = hmi.h2phmh2h;
908 
909  /* >>chng 03 feb 7 */
910  /* H2+ + H- => H + H + H
911  * equation (33) from
912  * >>refer H2+ k Stancil, P.C, & Lepp, S, & Dalgarno, A. 1998,ApJ, 509, 1-10
913  * h2phmhhh = 1.4e-7f*pow(phycon.te/300.0, -0.5) */
914  /* >>chng 03 sep 01, rm the pow function */
915  /*h2phmhhh = 1.4e-7f*pow(phycon.te/300 , -0.5);*/
916  h2phmhhh = 1.4e-7f*17.3205/phycon.sqrte;
917  if(r->next == NULL) {
918  int in[]={ipMH2p,ipMHm},out[]={ipMH,ipMH,ipMH};
919  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
920  }
921  r = r->next;
922  rindex++;
923  /* UMIST Leiden does not include H- so must kill H- reactions */
924  r->rk = h2phmhhh*co.lgUMISTrates;
925 
926  /* >>chng 03 sep 30 */
927  /* H+ + H- => H + H+ + e
928  * >>refer H- k Paolo Lenzuni, David F. Chernoff, Edwin E. Salpeter, 1991, ApJS, 76, 759L (table 5)
929  * hphmhhpe = 4.75e-30*pow(phycon.te,3.1); */
930  hphmhhpe = 4.75e-30*pow(phycon.te,3.1);
931  if(r->next == NULL) {
932  int in[]={ipMHp,ipMHm},out[]={ipMH,ipMHp};
933  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
934  }
935  r = r->next;
936  rindex++;
937  /* UMIST Leiden does not include H- so must kill H- reactions */
938  r->rk =hphmhhpe*co.lgUMISTrates;
939 
941  /* >>chng 03 sep 30 */
942  /* H2 + H- => H + H2 + e
943  * >>refer H- k Paolo Lenzuni, David F. Chernoff, Edwin E. Salpeter, 1991, ApJS, 76, 759L (table 5)
944  * h2hmhh2e = 6.74e-17*pow(phycon.te,2)*sexp(19870/phycon.te); */
945  /* UMIST Leiden does not include H- so must kill H- reactions */
946  h2hmhh2e = 6.74e-17*co.lgUMISTrates*phycon.tesqrd*sexp(19870/phycon.te);
947  if(r->next == NULL) {
948  int in[]={ipMH2g,ipMHm},out[]={ipMH,ipMH2g};
949  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
950  }
951  r = r->next;
952  rindex++;
953  r->rk =h2hmhh2e;
954 
955  /* (IHMI,IHMI) = processes destroying H- =-sign
956  * photodissociation, H- + H NU => H + NE */
957 
958  if(r->next == NULL) {
959  int in[]={ipMHm},out[]={ipMH};
960  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
961  }
962  r = r->next;
963  rindex++;
964  r->rk = hmi.HMinus_photo_rate;
965 
966  /* mutual neutralization with heavies, rate from Dalgarno and McCray
967  * all charged ions contribute equally,
968  * H- + A+ => H + A */
969  /* >>chng 04 feb 19, do actual sum of first ions rather than following kludge */
970  /* find the sum of all single ion densities for species heavier than helium */
971  sum_first_ions = 0.;
972  for( i=ipLITHIUM; i < LIMELM; i++ )
973  {
974  sum_first_ions += dense.xIonDense[i][1];
975  }
976 
977  {
978  /* this debug print statement compares H2 formation through grn vs H- */
979  enum {DEBUG_LOC=false};
980  if( DEBUG_LOC && nzone>140 )
981  {
982  fprintf(ioQQQ,"DEBUG sumfirstions\t%.2f\t%.4e\t%.4e\t%.4e",
983  fnzone,phycon.te,
984  sum_first_ions,
985  sum_first_ions/dense.eden);
986  for( i=ipLITHIUM; i < LIMELM; i++ )
987  {
988  if( dense.xIonDense[i][1]/sum_first_ions >0.1 )
989  fprintf(ioQQQ,"\t%li\t%.3e",
990  i,dense.xIonDense[i][1]/sum_first_ions);
991  }
992  fprintf(ioQQQ,"\n");
993  }
994  }
995 
997 
998  if(r->next == NULL) {
999  int in[]={ipMHm},out[]={ipMH};
1000  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1001  }
1002  r = r->next;
1003  rindex++;
1004  r->rk = hmi.hmin_ct_firstions*sum_first_ions*co.lgUMISTrates;
1005 
1006  /* electron collisional ionization of H- */
1007  cionhm *= dense.eden;
1008 
1009  if(r->next == NULL) {
1010  int in[]={ipMHm},out[]={ipMH};
1011  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1012  }
1013  r = r->next;
1014  rindex++;
1015  r->rk = cionhm*co.lgUMISTrates;
1016 
1017  /* inverse process; three body rec */
1018  c3bod = cionhm*(hmi.rel_pop_LTE_Hmin*dense.eden);
1019 
1020  if(r->next == NULL) {
1021  int in[]={ipMH},out[]={ipMHm};
1022  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1023  }
1024  r = r->next;
1025  rindex++;
1026  r->rk = c3bod*co.lgUMISTrates;
1027 
1028  /* form molecular hydrogen from H minus,
1029  * associative detachment: H- + H => H2 + E */
1030  /* make H2 from H-
1031  * associative detachment; H- + H => H2:
1032  * >>referold H2 rates Browne & Dalgarno J PHys B 2, 885 */
1033  /* rate coefficient from
1034  * >>refer H2 form Launay, J.R., Le Dourneuf, M., & Zeippen, C.J.,
1035  * >>refercon 1991, A&A, 252, 842-852*/
1036  /* >>chng 02 oct 17, temp dependent fit to rate, updated reference,
1037  * about 40% larger than before */
1038  {
1039  double y , x;
1040  x = MAX2(10., phycon.te );
1041  x = MIN2(1e4, x );
1042  y=545969508.1323510+x*71239.23653059864;
1043  hmi.assoc_detach = 1./y;
1044  }
1045 
1046  /* >>chng 02 nov 7 rjrw, example case of 2-body process */
1047  /* this one is into ground H2 */
1048  if(r->next == NULL) {
1049  int in[]={ipMH, ipMHm},out[]={ipMH2g};
1050  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1051  }
1052  r = r->next;
1053  rindex++;
1054  r->rk = hmi.assoc_detach*co.lgUMISTrates*(1.-frac_H2star_hminus);
1055 
1056  /* >>chng 03 sep 10, multiply above by correction for excited state,
1057  * add below reaction for population of excited state */
1058  /* this one is into excited H2 */
1059  if(r->next == NULL) {
1060  int in[]={ipMH, ipMHm},out[]={ipMH2s};
1061  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1062  }
1063  r = r->next;
1064  rindex++;
1065  r->rk = hmi.assoc_detach*frac_H2star_hminus*co.lgUMISTrates;
1066 
1067  {
1068  /* this debug print statement compares H2 formation through grn vs H- */
1069  enum {DEBUG_LOC=false};
1070  if( DEBUG_LOC && nzone>140 )
1071  {
1072  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",
1073  fnzone ,
1076  frac_H2star_grains,
1079  frac_H2star_hminus,
1081  );
1082  }
1083  }
1084 
1085  /* convert H2 into H-
1086  * the back reaction, H2(grnd) + e => H- + Ho */
1087  if( hmi.rel_pop_LTE_H2g > 0. )
1088  {
1091  }
1092  else
1093  {
1095  }
1096 
1097  /* convert H2 into H-
1098  * the back reaction, H2(exct) + e => H- + Ho */
1099  if( hmi.rel_pop_LTE_H2s > 0. )
1100  {
1101 
1104  }
1105  else
1106  {
1108  }
1109 
1110  {
1111  /* often the H- route is the most efficient formation mechanism for H2,
1112  * will be through rate called Hmolec_old[ipMH]*hmi.assoc_detach
1113  * this debug print statement is to trace h2 oscillations */
1114  enum {DEBUG_LOC=false};
1115  if( DEBUG_LOC && nzone>140/*&& iteration > 1*/)
1116  {
1117  /* rapid increase in H2 density caused by rapid increase in hmi.rel_pop_LTE_H2g */
1118  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",
1119  /* total forward rate */
1120  fnzone,
1121  phycon.te,
1122  dense.eden,
1123  /* rate H- + H => H2 + E */
1124  hmi.assoc_detach,
1129  /* H0 */
1130  hmi.Hmolec[ipMH],
1131  /* H+ */
1132  hmi.Hmolec[ipMHp],
1133  /* H- */
1134  hmi.Hmolec[ipMHm],
1135  hmi.H2_total,
1139  );
1140  }
1141  }
1142 
1143  /* >>chng 03 sep 11, resolve H2 and H2*, use fraction determined above */
1144  if(r->next == NULL) {
1145  int in[]={ipMH2g},out[]={ipMH,ipMHm};
1146  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1147  }
1148  r = r->next;
1149  rindex++;
1150 
1151  /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.
1152  Therefore the UMIST hack is used to turn off H- so that it is never important */
1153 
1154  /* >>chng 05 oct 03, TE, rearrange to get the correct H2 destruction file */
1155  hmi.assoc_detach_backwards_grnd *= ((1.-frac_H2star_hminus) * co.lgUMISTrates);
1157 
1158  /* >>chng 03 sep 11, resolve H2 and H2*, add new destruction process for H2* */
1159  if(r->next == NULL) {
1160  int in[]={ipMH2s},out[]={ipMH,ipMHm};
1161  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1162  }
1163  r = r->next;
1164  rindex++;
1165  /* >>chng 04 jan 28, had wrong Boltzmann factor for this reaction,
1166  * fixed by Gargi Shaw */
1167 
1168  /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.
1169  Therefore the UMIST hack is used to turn off H- so that it is never important */
1170 
1171  /* >>chng 05 oct 03, TE, rearrange to get the correct H2 destruction file */
1172  hmi.assoc_detach_backwards_exct *= (frac_H2star_hminus * co.lgUMISTrates);
1174 
1175  /*# define Hneut 7e-8*/
1176  /* >>chng 05 sept 12 - NPA. change rate for mutual neutralization of H-
1177  * and H+ to the rate from
1178  * >>refer H- mutual neut Lepp, S., Stancil, P.C. & Dalgarno, A. 2002, J. Phys. B, 35, R57 */
1179  if( phycon.te < 14125. )
1180  {
1181  /* the fit in Lepp et al. explodes at high temperature,
1182  * Te = 14,125 is the temp where the rates reaches its lowest value */
1183  Hneut = 1.4e-7*pow(phycon.te/300,-0.487)*exp(phycon.te/29300);
1184  }
1185  else
1186  {
1187  Hneut = 3.4738192887404660e-008;
1188  }
1189  /* mutual neut, mostly into n=3; rates from Janev et al
1190  * H- + H+ => H + H(n=3) */
1192  fhneut = Hmolec_old[ipMHp]*Hneut; /* dense.xIonDense[ipHYDROGEN][1]*7e-8; */
1193 
1194  if(r->next == NULL) {
1195  int in[]={ipMHm,ipMHp},out[]={ipMH,ipMH};
1196  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1197  }
1198  r = r->next;
1199  rindex++;
1200 
1201  /* >>chng 05 aug 05, NPA comment:The Leiden comparison does not consider H-.
1202  Therefore the UMIST hack is used to turn off H- so that it is never important */
1203 
1204  r->rk = Hneut*co.lgUMISTrates;
1205 
1206  /* back reaction from excited state H */
1207  if( phycon.te > 1000. )
1208  {
1209  /* HBN(3,1) is defined; when <HydTempLimit then set to 1 */
1211  }
1212  else
1213  {
1214  bhneut = 0.;
1215  }
1216 
1217  /* mutual neut, mostly into n=3; rates from Janev et al
1218  * H + H(n=3) => H- + H+ */
1220  /* this is the back reaction, forming H- from Ho */
1221 
1222  if(r->next == NULL) {
1223  int in[]={ipMH,ipMH},out[]={ipMHm,ipMHp}, ratesp[]={ipMH,ipMHp};
1224  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1225  }
1226  r = r->next;
1227  rindex++;
1228  r->rk = bhneut*co.lgUMISTrates;
1229  bhneut *= Hmolec_old[ipMHp];
1230 
1231  /*--------------------------------------------------------------------
1232  *
1233  * molecular hydrogen H2 Htwo balance equation
1234  * (IPMH2,IPMHO)==create H2 from Ho =+ */
1235 
1236  /* H2 formation on grains */
1237  /* >>chng 01 jan 05, remove from matrix part and add hden to hmi.rate_h2_form_grains_used, */
1238  /* the large molecule keeps explicit track of the fraction that goes into
1239  * excited vs ground H2. Use that ratio if H2 turned on, else use an
1240  * estimate of it */
1241  /* The reaction rate is only proportional to one of the ipMH, due to
1242  * surface saturation (?) */
1243 
1244 # define CATALYST true
1245  if( CATALYST )
1246  {
1247  /* this is the method used by the code for most of its history. The grain
1248  * is only a catalytic agent, and so the rate goes as the square of the
1249  * incoming H0 density */
1250  /* This goes to excited H2 */
1251  if(r->next == NULL) {
1252  int in[]={ipMH,ipMH},out[]={ipMH2s},ratesp[]={ipMH};
1253  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1254  }
1255  r = r->next;
1256  rindex++;
1257  r->rk = gv.rate_h2_form_grains_used_total*frac_H2star_grains;
1258 
1259  /* >>chng 03 sep 10, multiply above by correction for excited state,
1260  * add below reaction for population of excited state */
1261 
1262  /* This goes to ground H2 */
1263  if(r->next == NULL) {
1264  int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH};
1265  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1266  }
1267  r = r->next;
1268  rindex++;
1269  r->rk = gv.rate_h2_form_grains_used_total*(1. - frac_H2star_grains);
1270  }
1271 
1272  else
1273  {
1274  /* >>chng 03 nov 25, go to this formalism */
1275  /* the grain is not a true catalyst, but rather a target loaded with H atoms
1276  * ready to react. So the rate is the number of these grains, times their
1277  * cross section, times the number of incident H atoms. The number of grains
1278  * is replaced with the total hydrogen density, which is not in the network
1279  * but is a constant */
1280  /* This goes to excited H2 */
1281  if(r->next == NULL) {
1282  int in[]={ipMH,ipMH},out[]={ipMH2s},ratesp[]={ipMH};
1283  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1284  }
1285  r = r->next;
1286  rindex++;
1287  r->rk = gv.rate_h2_form_grains_used_total*frac_H2star_grains*
1289 
1290  /* >>chng 03 sep 10, multiply above by correction for excited state,
1291  * add below reaction for population of excited state */
1292 
1293  /* This goes to ground H2 */
1294  if(r->next == NULL) {
1295  int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH};
1296  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1297  }
1298  r = r->next;
1299  rindex++;
1300  r->rk = gv.rate_h2_form_grains_used_total*(1. - frac_H2star_grains)*
1302  }
1303 
1304  /* excited atom radiative association,
1305  * H(n=2) + H(n=1) => H2 + hnu
1306  * written as H(n=1)*pop ratio + H(n=1) -> H2 + hnu but ratio of pops is in
1307  * terms of pop to ion, so initial term is
1308  * n(H+) * pop2ion,
1309  * >>refer H2 rates Latter, W.B., & Black, J.H., 1991, Ap.J. 372, 161 */
1310  /* hmi.radasc = ((StatesElem[ipH_LIKE][ipHYDROGEN][ipH2p].Pop + StatesElem[ipH_LIKE][ipHYDROGEN][ipH2s].Pop)*dense.xIonDense[ipHYDROGEN][1])*3e-14; */
1311 
1314  /* >>chng 02 nov 7 rjrw: correct for n^2 behaviour w.r.t. H
1315  >>chng 02 nov 7 rjrw, correct stoichiometry */
1316 
1317  /* Possible that changing to a rate proportional to ipMHp would be more consistent */
1318  if(r->next == NULL) {
1319  int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH,ipMHp};
1320  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1321  }
1322  r = r->next;
1323  rindex++;
1324  r->rk = hmi.radasc*co.lgUMISTrates;
1325  hmi.radasc *= Hmolec_old[ipMHp]; /* why this is reset here? GS*/
1326 
1327  /* photo-destroy H2 */
1328  /* >>chng 00 nov 25 factor of 0.1, assume pump is total, and 10% destroy H2 is 21*/
1329  if(r->next == NULL) {
1330  int in[]={ipMH2g},out[]={ipMH,ipMH};
1331  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1332  }
1333  r = r->next;
1334  rindex++;
1335  /* >>chng 03 mar 07, had factor of 0.1 for branching ratio from H2** to H+H,
1336  * but branching is now already included */
1337  /*r->rk = hmi.H2_Solomon_dissoc_rate_used*0.1;*/
1339 
1340  /* >>chng 03 sep 11, add this process */
1341  /* photo-destroy H2* by Solomon process at same rate as H2ground dissociation,
1342  see above eqn A12 in TH85 */
1343  /* >>chng 00 nov 25 factor of 0.1, assume pump is total, and 10% destroy H2 */
1344  if(r->next == NULL) {
1345  int in[]={ipMH2s},out[]={ipMH,ipMH};
1346  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1347  }
1348  r = r->next;
1349  rindex++;
1350  /* >>chng 03 mar 07, had factor of 0.1 for branching ratio from H2** to H+H,
1351  * but branching is now already included */
1352  /*r->rk = hmi.H2_Solomon_dissoc_rate_used*0.1; is #22*/
1354 
1355  /* H2 + H+ => H3+ HNU
1356  * equation H21 from
1357  * >>refer H2 chemistry Galli,D., & Palla, F. 1998, A&A, 335, 403-420 */
1358  /* >>chng 02 nov 07 rjrw, include H+ ion density in rate constant */
1359 
1360  /* >>chng 05 aug 05, NPA comment. This reaction is not in UMIST, therefore I turned it
1361  off when comparing to the other codes */
1364  hmi.h2hph3p = 1.0e-16f*co.lgUMISTrates;
1365 
1366  if(r->next == NULL) {
1367  int in[]={ipMH2g,ipMHp},out[]={ipMH3p};
1368  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1369  }
1370  r = r->next;
1371  rindex++;
1372  r->rk = hmi.h2hph3p;
1373 
1374  /* collisional dissociation, rate from
1375  * >>refer H2 collisional dissociation Dove, J.E., and Mandy, M. E., 1986, ApJ, 311, L93.
1376  * H_2 + H => 2H + H
1377  * >>chng 02 nov 7 rjrw, correct stoichiometry */
1378 
1379  /* Rate is catalyzed by an additional H */
1380  if(r->next == NULL) {
1381  int in[]={ipMH2g},out[]={ipMH,ipMH},ratesp[]={ipMH,ipMH2g};
1382  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1383  }
1384  r = r->next;
1385  rindex++;
1387  r->rk = hmi.rh2dis;
1388 
1389  /* >>chng 04 apr 21 */
1390  /* 2H + H2 => H2 + H2
1391  * equation (5) from
1392  * >>refer H2 chemistry Palla, F., Salpeter, E.E., & Stahler, S.W., 1983, ApJ,271, 632-641
1393  * bh2h22hh2= 5.5e-29/(8*phycon.te) */
1395  hmi.bh2h22hh2 = 5.5e-29*co.lgUMISTrates/(8.*phycon.te);
1396 
1397  if(r->next == NULL) {
1398  int in[]={ipMH,ipMH,ipMH2g},out[]={ipMH2g,ipMH2g};
1399  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1400  }
1401  r = r->next;
1402  rindex++;
1403  r->rk = hmi.bh2h22hh2;
1404 
1405  /* >>chng 04 apr 21 */
1406  /* H2 + H2 => 2H + H2
1407  * equation (5) from
1408  * >>refer H2 chemistry Palla, F., Salpeter, E.E., & Stahler, S.W., 1983, ApJ,271, 632-641
1409  * h2h22hh2 = bh2h22hh2/hmi.rel_pop_LTE_H2g */
1411  if( hmi.rel_pop_LTE_H2g > 0. )
1412  {
1414  }
1415  else
1416  {
1417  hmi.h2h22hh2 =0.;
1418  }
1419 
1420  if(r->next == NULL) {
1421  int in[]={ipMH2g,ipMH2g},out[]={ipMH,ipMH,ipMH2g};
1422  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1423  }
1424  r = r->next;
1425  rindex++;
1427  r->rk = hmi.h2h22hh2;
1428 
1429  /* back rate, three body recombination, 2H + S => H_2 + S
1430  * >>chng 02 nov 7 rjrw: correct for n^2 behaviour w.r.t. H
1431  * >>chng 02 nov 7 rjrw, correct stoichiometry
1432  * >>chng 02 nov 7 rjrw, correct for n^3 behaviour w.r.t. H !! */
1433  /* hmi.bh2dis = hmi.rh2dis*hmi.rel_pop_LTE_H2g*dense.xIonDense[ipHYDROGEN][0]*dense.xIonDense[ipHYDROGEN][0]; */
1436 
1437  if(r->next == NULL) {
1438  int in[]={ipMH,ipMH},out[]={ipMH2g},ratesp[]={ipMH,ipMH,ipMH};
1439  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
1440  }
1441  r = r->next;
1442  rindex++;
1443  r->rk = hmi.bh2dis;
1444 
1445  hmi.bh2dis = hmi.rh2dis*hmi.rel_pop_LTE_H2g*Hmolec_old[ipMH]*Hmolec_old[ipMH]*co.lgUMISTrates;
1446 
1447  /* H2 + HNU=> H2+ + E
1448  * photoionization by hard photons, crossection=3*HI - in molecular environments this is
1449  * only the highest energy photons that have penetrated the H+ and H0 regions*/
1450  /* following copies from opacity_addtotal line 353 */
1457  /* >>chng 02 jan 16, approximate inclusion of H_2 photoelectric opacity */
1458  /* include H_2 in total photoelectric opacity */
1459  /* set lower and upper limits to this range */
1460  /*hmi.H2_photoionize_rate = iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s];
1461  fprintf(ioQQQ,"DEBUG H2 photo\t%.3e", hmi.H2_photoionize_rate );*/
1463  /* >>chng 05 nov 24, evaluate real photo rate,
1464  * had used H0 rate - photo heating had not been included */
1465  {
1466  static long int nzone_eval = -1, iteration_evaluated=-1;
1467  /* must reevaluate During search phase */
1468  if( ( nzone_eval!=nzone || iteration_evaluated!=iteration ) || !nzone )
1469  {
1470  /* generally not important, do one time per zone */
1473  rfield.nupper,
1476  /* Compton recoil ionization - we include this in the H2 photoionization
1477  * rate but not the heating rate - factor of two since assume 2H
1478  * is same as two H0 at such high energies */
1480 
1481  /* photo heating - this has units s-1 - needs H2 density
1482  * to become vol heat rate */
1485  nzone_eval = nzone;
1486  iteration_evaluated = iteration;
1487  }
1488  }
1489 
1490  /*fprintf(ioQQQ,"\t %.3e\n", hmi.H2_photoionize_rate );*/
1491 
1492  /* cosmic rays predominantly H2 + cr -> H2+ + e, as per table 10 of TH85 */
1493  /* >>chng 00 nov 28, factor of 0.93 from
1494  >>refer cosmic ray ionization rate Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722
1495  * also cosmic rays producing secondary ionization csupra */
1496  /* >>chng 00 nov 28, factor of 0.93 from
1497  >>refer cosmic ray ionization rate Maloney, P.R., Hollenbach, D., & Tielens, A. G. G. M., 1998, ApJ, 466, 561
1498  */
1499  /* >>chng 04jan 26, assume ion(H2) = 2x ion(H), H ion rate of
1500  * 2.5e-17 s-1, as per
1501  * >>refer cosmic ray ionization Williams, J.P., Bergin, E.A., Caselli, P.,
1502  * >>refercon Myers, P.C., & Plume, R. 1998, ApJ, 503, 689
1503  * so H2 secondary ionization rate is 5e-17 s-1 */
1504  if(r->next == NULL) {
1505  int in[]={ipMH2g},out[]={ipMH2p};
1506  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1507  }
1508  r = r->next;
1509  rindex++;
1510  /* >> chng 05 jul 07, TE, rename to get correct h2 destruction file */
1511  /* ratio of H2 to H cr rates from table 10 of tielens & hollenbach 1985 */
1512  /* >> chng 05 aug 05, NPA comment. Our definition of the cosmic ray reaction,
1513  we include the factor hmi.H2_photoionize_rate. The Leiden comparison wanted a constant cosmic
1514  ray rate. Therefore if the UMIST rate is set we use a constant 4.4e-17 ionization
1515  rate. Otherwise we just use what Cloudy naturally does */
1516  if(co.lgUMISTrates)
1517  {
1518  h2crh2pe = hmi.H2_photoionize_rate + secondaries.csupra[ipHYDROGEN][0]*2.02;
1519  }
1520 
1521  else
1522  {
1523  h2crh2pe = 4.4e-17;
1524  }
1525 
1526  r->rk = h2crh2pe;
1527 
1528  /* >>chng 04 apr 22, add H2 + cr -> H+ H + e, TH85 table 10 */
1529  if(r->next == NULL) {
1530  int in[]={ipMH2g},out[]={ipMH,ipMHp};
1531  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1532  }
1533  r = r->next;
1534  rindex++;
1535 
1536  /* >> chng 05 jul 07, TE, rename to get correct h2 destruction file */
1537  /* ratio of H2 to H cr rates from table 10 of tielens & hollenbach 1985 */
1538  /* >> chng 05 aug 05, NPA comment. The Leiden comparison wanted a constant cosmic
1539  ray rate. Therefore if the UMIST rate is set we use a constant 1e-19 ionization
1540  rate. Otherwise we just use what Cloudy naturally does */
1541 
1542  if(co.lgUMISTrates)
1543  {
1544  h2crhphe = secondaries.csupra[ipHYDROGEN][0]*0.0478;
1545  }
1546  else
1547  {
1548  h2crhphe = 1e-19;
1549  }
1550  r->rk = h2crhphe;
1551 
1552  /* >> chng 05 sep 26, TE, include the same reaction for H2s */
1553  /* H2s + CR -> H+ H + e, TH85 table 10 */
1554  if(r->next == NULL) {
1555  int in[]={ipMH2s},out[]={ipMH,ipMHp};
1556  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1557  }
1558  r = r->next;
1559  rindex++;
1560  if(co.lgUMISTrates)
1561  {
1562  h2scrhphe = secondaries.csupra[ipHYDROGEN][0]*0.0478;
1563  }
1564  else
1565  {
1566  h2scrhphe = 1e-19;
1567  }
1568  r->rk = h2scrhphe;
1569 
1570 
1571  /* >> chng 05 jul 07, TE, rename to get correct h2 destruction file */
1572  /* >>chng 05 jul 01,GS */
1573  /* H2s + CRP => H2+ + e;
1574  * Cosmic ray ionization of H2s added*/
1575  if(r->next == NULL) {
1576  int in[]={ipMH2s},out[]={ipMH2p};
1577  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1578  }
1579  r = r->next;
1580  rindex++;
1581 
1582  if( co.lgUMISTrates )
1583  {
1584  /* not using UMIST - do the general case */
1585  h2scrh2pe = hmi.H2_photoionize_rate + secondaries.csupra[ipHYDROGEN][0]*2.02;
1586  }
1587  else
1588  {
1589  /* use UMIST - this is from Sternberg email defining Leiden meeting */
1590  h2scrh2pe = 4.4e-17;
1591  }
1592  r->rk = h2scrh2pe;
1593 
1594  /* >>chng 03 apr 11 */
1595  /* H2 + CRP => H + H; CRP=Cosmic Ray proton
1596  * equation (3643) from
1597  * >>refer H2 k Millar, T.J. et.al, 1997,A&AS, 121, 139
1598  * h2crphh = 1.3e-18f */
1599  if(r->next == NULL) {
1600  int in[]={ipMH2g},out[]={ipMH,ipMH};
1601  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1602  }
1603  r = r->next;
1604  rindex++;
1605 
1606  /* >>chng 05 jun 16, GS, use the rate from big H2 network */
1608  {
1609  h2crphh = hmi.H2_tripletdissoc_H2g;
1610  }
1611  else
1612  {
1613  h2crphh = secondaries.x12tot*3.;
1614  }
1615 
1616  /* co.lgUMISTrates is set false with the set Leiden hack command, which also
1617  * sets their standard cosmic ray rates */
1618  /* >> chng 05 aug 05, NPA comment. The Leiden comparison wanted a constant cosmic
1619  ray rate. Therefore if the UMIST rate is set we use a constant 5e-18 ionization
1620  rate. Otherwise we just use what Cloudy naturally does */
1621  if(!co.lgUMISTrates)
1622  h2crphh = 5e-18;
1623 
1624  r->rk = h2crphh;
1625 
1626  /* >>chng 05 jun 16, GS, use the rate from big H2 network, small network does not have this rate */
1628  {
1629  h2scrphh = hmi.H2_tripletdissoc_H2s;
1630  }
1631  else
1632  {
1633  h2scrphh = secondaries.x12tot*3.;
1634  }
1635 
1636  if(r->next == NULL) {
1637  int in[]={ipMH2s},out[]={ipMH,ipMH};
1638  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1639  }
1640  r = r->next;
1641  rindex++;
1642  r->rk = h2scrphh;
1643 
1644  /* >>chng 03 apr 11 */
1645  /* H2 + CRP => H+ + H_; CRP=Cosmic Ray Proton
1646  * equation (3644) from
1647  * >>refer H2 k Millar, T.J., et.al, 1997,A&AS, 121, 139
1648  * h2crphphm = 3.9e-21 */
1649  /* >> chng 05 aug 05, NPA comment. Turn off H- for the Leiden comparison */
1650  h2crphphm = 3.9e-21 * hextra.cryden_ov_background * co.lgUMISTrates;
1651 
1652  if(r->next == NULL) {
1653  int in[]={ipMH2g},out[]={ipMHp,ipMHm};
1654  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1655  }
1656  r = r->next;
1657  rindex++;
1658 
1659  r->rk = h2crphphm;
1660 
1661  /* >> chng 05 sep 26, TE, include the same reaction for H2s */
1662  /* H2s + CRP => H+ + H_; CRP=Cosmic Ray Proton */
1663  h2scrphphm = 3.9e-21 * hextra.cryden_ov_background * co.lgUMISTrates;
1664 
1665  if(r->next == NULL) {
1666  int in[]={ipMH2s},out[]={ipMHp,ipMHm};
1667  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1668  }
1669  r = r->next;
1670  rindex++;
1671 
1672  r->rk = h2scrphphm;
1673 
1674  /* >>chng 03 apr 11 */
1675  /* H2 + CRP => H+ + H + e; CRP=Cosmic Ray Proton
1676  * equation (3641) from
1677  * >>refer H2 k Millar, T.J., et.al, 1997,A&AS, 121, 139
1678  * h2crphpeh = 2.2e-19f */
1679  /* >> chng 05 aug 05, NPA comment. Amiel Sternberg said to not consider this process
1680  in the benchmark calculations. Therefore, the UMIST rate is used to turn this reaction off */
1681  h2crphpeh = 2.2e-19 * hextra.cryden_ov_background * co.lgUMISTrates;
1682 
1683  if(r->next == NULL) {
1684  int in[]={ipMH2g},out[]={ipMHp,ipMH};
1685  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1686  }
1687  r = r->next;
1688  rindex++;
1689  r->rk = h2crphpeh;
1690 
1691  /* >> chng 05 sep 26, TE, include the same reaction for H2s */
1692  /* H2s + CRP => H+ + H + e; CRP=Cosmic Ray Proton */
1693  h2scrphpeh = 2.2e-19 * hextra.cryden_ov_background * co.lgUMISTrates;
1694 
1695  if(r->next == NULL) {
1696  int in[]={ipMH2s},out[]={ipMHp,ipMH};
1697  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1698  }
1699  r = r->next;
1700  rindex++;
1701  r->rk = h2scrphpeh;
1702 
1703  /*>>chng 05 jul 01, GS, h2s ionization by cosmic ray added*/
1704  /* >>chng 05 jun 29, TE, used in new punch H2 destruction file*/
1705  hmi.CR_reac_H2g = h2crh2pe + h2crhphe + h2crphh + h2crphphm + h2crphpeh;
1706  hmi.CR_reac_H2s = h2scrh2pe + h2scrhphe + h2scrphh + h2scrphphm + h2scrphpeh;
1707 
1708  /* >>chng 03 apr 11 */
1709  /* H3+ + H-=> H2 + H2;
1710  * equation (5,table 9) from
1711  * >>refer H3+ k Maloney et.al, 1996,ApJ, 466, 561
1712  * h3phm2h2 = 1.3e-7f*pow(phycon.te/1000., -0.5) */
1714  /* >> chng 05 aug 05, NPA comment. Turn off H- for the Leiden comparison */
1715  hmi.h3phm2h2 = 1.3e-7 / (phycon.sqrte/31.62278) * co.lgUMISTrates;/*pow(phycon.te/1000., -0.5);*/
1716  if(r->next == NULL) {
1717  int in[]={ipMH3p,ipMHm},out[]={ipMH2g,ipMH2g};
1718  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1719  }
1720  r = r->next;
1721  rindex++;
1722  r->rk = hmi.h3phm2h2;
1723 
1724  /* >>chng 03 sep 30 */
1725  /* H3+ + HNU=> H2+ + H;
1726  * equation (table 5) from
1727  * >>refer H2 dissoc Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722
1728  * h3ph2ph = 7.9e-9*hmi.UV_Cont_rel2_Habing_TH85_depth;*/
1729  /* >>chng 04 jun 13 -- update this rate to match that in the UMIST database */
1730 
1731  /* >> chng 05 aug 05, NPA comment. This is one of the few instances where
1732  I actually updated a rate permanently. Originally this rate was taken from TH85.
1733  I changed this to the UMIST rate. The UMIST database gives the reference for their
1734  rate as van Dishoeck and Black, 1987. Therefore, since it comes from such a regarded
1735  source and after the TH85 paper, I think this is appropriate. The UMIST hack is used
1736  to extinguish the continuum by exp(-a*AV) instead of through our radiative transfer
1737  solution, which is what the other codes in the comparison did. */
1738 
1739  if(co.lgUMISTrates)
1740  {
1741  h3ph2ph = 5.0e-13*hmi.UV_Cont_rel2_Habing_TH85_depth/1.66f;
1742  }
1743  else
1744  {
1745  h3ph2ph = 5.0e-13*hmi.UV_Cont_rel2_Habing_TH85_face*(realnum)sexp((2.3*rfield.extin_mag_V_point))/1.66f;
1746  }
1747 
1748  if(r->next == NULL) {
1749  int in[]={ipMH3p},out[]={ipMH2p,ipMH};
1750  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1751  }
1752  r = r->next;
1753  rindex++;
1754  r->rk =h3ph2ph;
1755 
1756  /* >>chng 03 sep 30 */
1757  /* H3+ + HNU=> H2 + H+;
1758  * equation (table 5) from
1759  * >>refer H2 dissoc Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722
1760  * h3ph2hp = 2.0e-8*hmi.UV_Cont_rel2_Habing_TH85_depth;*/
1761  /* >>chng 04 jun 13 -- update this rate to match that in the UMIST database */
1762  /* >> chng 05 aug 05, NPA comment. This is one of the few instances where
1763  I actually updated a rate permanently. Originally this rate was taken from TH85.
1764  I changed this to the UMIST rate. The UMIST database gives the reference for their
1765  rate as van Dishoeck and Black, 1987. Therefore, since it comes from such a regarded
1766  source and after the TH85 paper, I think this is appropriate. The UMIST hack is used
1767  to extinguish the continuum by exp(-a*AV) instead of through our radiative transfer
1768  solution, which is what the other codes in the comparison did. */
1770  if(co.lgUMISTrates)
1771  {
1773  }
1774  else
1775  {
1777  }
1778 
1779  if(r->next == NULL) {
1780  int in[]={ipMH3p},out[]={ipMH2g,ipMHp};
1781  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1782  }
1783  r = r->next;
1784  rindex++;
1785  r->rk =hmi.h3ph2hp;
1786 
1787  /* >> chng 02 nov 15 rjrw: multiply c[ipMHo][*] terms by ionization fraction
1788  * as b[ipMHo] contains _both_ H0 and H+ */
1789  /* H2* + H+ => H2+ + H */
1790  /* >> chng 05 jul 14, TE,
1791  * to maintain detailed balance with bh2h2p, only consider H2s*/
1792  /* >> chng 05 sept 28, GS,
1793  * H2g + H+ => H2+ + H
1794  * bh2h2p and rh2h2p are not in detailed balance,astro-ph/0404288*/
1795  if(r->next == NULL) {
1796  int in[]={ipMH2g,ipMHp},out[]={ipMH,ipMH2p};
1797  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1798  }
1799  r = r->next;
1800  rindex++;
1801  r->rk = hmi.rh2h2p;
1802 
1803  /* (3,IPMH2P) == destroy H2+ = -sign
1804  * H + H2+ => H+ + H2 */
1805  /* >>chng 02 nov 7 rjrw, remove the destruction rate
1806  * c[ipMHo][ipMHo] += -hmi.bh2h2p*hmi.Hmolec[ipMH2p];
1807  * twice -- reaction changes state of H within single [H0,H+] `species' */
1808 
1809  if(r->next == NULL)
1810  {
1811  /* >> chng 05 jul 13, TE,
1812  * this process populates v=4,no J information assume into J=0 -> H2s not H2g */
1813  int in[]={ipMH,ipMH2p},out[]={ipMHp,ipMH2s};
1814  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1815  }
1816  r = r->next;
1817  rindex++;
1818  r->rk = hmi.bh2h2p;
1819 
1821  /* this rate couples H2+ and H3+, and tends to destabilize the matrix in both highly
1822  * ionized and fully molecular conditions. Setting this to zero had no effect - the th85
1823  * predictions were identical.
1824  *
1825  */
1826  /* H + H3+ => H2 + H2+ */
1828  /* >> chng 05 aug 05, NPA comment. This rate is not in UMIST. Therefore
1829  it is turned off for the Leiden comparison */
1830 
1831  hmi.h3ph2p = HMRATE(2.08e-9,0.,1.88e4)*co.lgUMISTrates;
1832 
1833  if(r->next == NULL)
1834  {
1835  int in[]={ipMH,ipMH3p},out[]={ipMH2g,ipMH2p};
1836  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1837  }
1838  r = r->next;
1839  rindex++;
1840  r->rk = hmi.h3ph2p;
1841 
1842  /* >>chng 03 feb 7 */
1843  /* H3+ + H- => H2 + H + H
1844  * equation (50) from
1845  * >>refer H- k Stancil, P.C, & Lepp, S, & Dalgarno, A. 1998,ApJ, 509, 1-10
1846  * h3phmh2hh = 2.3e-7f*pow(phycon.te/300.0, -0.5) */
1847  /* >> chng 05 aug 05, NPA comment. This rate is not in UMIST. Therefore it
1848  is turned off for the Leiden comparison */
1850  hmi.h3phmh2hh = 2.3e-7f*pow(phycon.te/300 , -0.5)*co.lgUMISTrates;
1851  if(r->next == NULL)
1852  {
1853  int in[]={ipMH3p,ipMHm},out[]={ipMH2g,ipMH,ipMH};
1854  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1855  }
1856  r = r->next;
1857  rindex++;
1858  r->rk = hmi.h3phmh2hh;
1859 
1860  /* H2 + H3+ => H2 + H2+ + H */
1861  /* >> chng 05 aug 05, NPA comment. This rate is not in UMIST. Therefore it
1862  is turned off for the Leiden comparison */
1864  hmi.h3petc = HMRATE(3.41e-11,0.5,7.16e4)*co.lgUMISTrates;
1865 
1866  if(r->next == NULL)
1867  {
1868  int in[]={ipMH2g,ipMH3p},out[]={ipMH2g,ipMH2p,ipMH};
1869  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1870  }
1871  r = r->next;
1872  rindex++;
1873  r->rk = hmi.h3petc;
1874 
1875  /* H2 + H3+ => H2 + H+ + H2 */
1876  /* >> chng 05 aug 05, NPA comment. This rate is not in UMIST. Therefore it
1877  is turned off for the Leiden comparison */
1879  hmi.h32h2 = HMRATE(3.41e-11,0.5,5.04e4)*co.lgUMISTrates;
1880 
1881  if(r->next == NULL) {
1882  int in[]={ipMH2g,ipMH3p},out[]={ipMHp,ipMH2g,ipMH2g};
1883  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1884  }
1885  r = r->next;
1886  rindex++;
1887  r->rk = hmi.h32h2;
1888 
1889  /* e + H3+ => H2 + H */
1890  /* e + H3+ => 3H was supposed to be included in this rate,
1891  * and stoichiometric factor 2* on sink rate seemed wrong */
1892  /* >>chng 03 feb 10, increase rate by factor of 13.6 to agree with
1893  * >>refer H3+ DR McCall, B.J., et al. 2003, Nature, in press (astro-ph 0302106)*/
1894  /* >>chng 03 feb 13, extra 0.2 since 20% of these go to H2 + H, Stancil private comm */
1895  /* >>chng 04 apr 22 , update the next two rates to match that of:
1896  >>refer H3+ k Stancil, P. C., Lepp, S., and Dalgarno, A 509, 1-10;
1897  *>>refercon Table 1, reactions #48 and #49 */
1900  /* >>chng 06 jan 23, Stancil's rate is rescaled by 2.25 to match McCall's rate, GS*/
1901  /* >>chng 07 jan 05, as per GS discussions, USE_MCCALL was commented out,
1902  * turn back on. Should not have been commented out */
1903 # define USE_MCCALL
1904 # ifdef USE_MCCALL
1905 # define FACTOR 2.25
1906 # else
1907 # define FACTOR 1.0
1908 # endif
1909  hmi.eh3_h2h = HMRATE(4.00e-8/FACTOR,-0.5,0.)*dense.eden;
1910 
1911  /* >> chng 05 aug 05, NPA comment. Rate we use and UMIST uses is different. If UMIST
1912  hack is on then we use UMIST, otherwise we use our rate */
1913  if(!co.lgUMISTrates)
1914  hmi.eh3_h2h = HMRATE(2.5e-8,-0.3,0.)*dense.eden;
1915 
1916 
1917  if(r->next == NULL) {
1918  int in[]={ipMH3p},out[]={ipMH,ipMH2g};
1919  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1920  }
1921  r = r->next;
1922  rindex++;
1923  r->rk = hmi.eh3_h2h;
1924 
1925  /* e + H3+ => 3H */
1926  /* >>chng 06 jan 23, Stancil's rate is rescaled by 2.25 to match McCall's rate, GS*/
1927  eh3p_3h = HMRATE(1.6e-7/FACTOR,-0.5,0.)*dense.eden;
1928 # undef FACTOR
1929 # ifdef USE_MCCALL
1930 # undef USE_MCCALL
1931 # endif
1932 
1933  /* >> chng 05 aug 05, NPA comment. Rate we use and UMIST uses is different. If UMIST
1934  hack is on then we use UMIST, otherwise we use our rate */
1935  if(!co.lgUMISTrates)
1936  eh3p_3h = HMRATE(7.5e-8,-0.3,0.)*dense.eden;
1937 
1938  /* >>chng 03 feb 10, increase rate by factor of 13.6 to agree with
1939  * >>refer H3+ DR McCall, B.J., et al. 2003, Nature, in press (astro-ph 0302106)*/
1940  /* >>chng 03 feb 13, extra 0.8 since 80% of these go to 3H, Stancil private comm */
1941 
1942  if(r->next == NULL) {
1943  int in[]={ipMH3p},out[]={ipMH,ipMH,ipMH};
1944  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
1945  }
1946  r = r->next;
1947  rindex++;
1948  r->rk = eh3p_3h;
1949 
1950  if( (trace.lgTrace && trace.lgTr_H2_Mole) )
1951  {
1953  {
1954  fprintf( ioQQQ,
1955  " 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",
1965  );
1966  }
1967  else
1968  {
1969  fprintf( ioQQQ, " Destroy H2: rate=0\n" );
1970  }
1971  }
1972 
1973  /*------------------------------------------------------------------- */
1974 
1975  /* h2plus H2+ balance equations */
1976 
1978  /* >>refer H2+ chemistry Dalgarno, A., & Lepp, S., 1987, in Astrochemistry, eds.
1979  * >>refercon M.S. Vardya & S.P. Tarafar, Reidel, Dordrecht, p 109 */
1980  /* rate = 5e-7 * sqrt(100. / phycon.te); */
1981 
1983  /* >>refer H2+ chemistry Stancil, P.C., 1994, ApJ, 430, 360 */
1984  /* cross section is log10( cs_25) = -1.6547717e6 + 1.8660333e5 ln(nu) - 7.8986431e3*ln(nu)^2
1985  * 148.73693 * ln(nu)^3 - 1.0513032*ln(nu)^4 */
1986 
1987  /* make H2+ from Ho
1988  * H+ + H => H2+ + HNU
1989  * approximation was from Kurucz thesis, not meant for hot gas
1990  * >>chng 02 nov 7 rjrw, stoichiometric factor */
1991  radath = MAX2(0.,2.325*MIN2(5000.,phycon.te)-1375.)*1e-20;
1992 
1993  /* >> chng 05 aug 05, NPA comment. Rate we use and UMIST uses is different. If UMIST
1994  hack is on then we use UMIST, otherwise we use our rate */
1995 
1996  if( !co.lgUMISTrates)
1997  radath = HMRATE(5.3e-19,1.85,0);
1998 
1999  if( r->next == NULL) {
2000  int in[]={ipMH,ipMHp},out[]={ipMH2p};
2001  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2002  }
2003  r = r->next;
2004  /* Printf("O: %ld %g %g\n",rindex,radath*dense.xIonDense[ipHYDROGEN][1]*dense.xIonDense[ipHYDROGEN][0],
2005  radath*dense.xIonDense[ipHYDROGEN][1]); */
2006  rindex++;
2007  r->rk = radath;
2008 
2009  /* H2+ + H+ => H + H+ + H+; Janev et al. 3.2.6 */
2010  /* >>chng 02 nov 7 rjrw, stoichiometric factor */
2011 
2012  /* >> chng 05 aug 05, NPA comment. This reaction is not in UMIST, so turn if off
2013  for the comparison */
2014 
2015  h2pion = 2.4e-27*POW3(phycon.te)*co.lgUMISTrates;
2016 
2017  if(r->next == NULL) {
2018  int in[]={ipMH2p},out[]={ipMH,ipMHp},ratesp[]={ipMHp,ipMH2p};
2019  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
2020  }
2021  r = r->next;
2022  rindex++;
2023  r->rk = h2pion;
2024 
2025  /* H2+ + E => H + H+ + e-; Janev et al. */
2026  /* >>chng 02 nov 7 rjrw, stoichiometric factor */
2027 
2028  /* >> chng 05 aug 05, NPA comment. This reaction is not in UMIST, so turn if off
2029  for the comparison */
2030  h2pcin = 2e-7*sexp(30720./phycon.te)*dense.eden*co.lgUMISTrates;
2031 
2032  if(r->next == NULL) {
2033  int in[]={ipMH2p},out[]={ipMH,ipMHp};
2034  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2035  }
2036  r = r->next;
2037  rindex++;
2038  r->rk = h2pcin;
2039 
2040  /* >>chng 04 jul 06 -- NPA, include H ionization/recombination due
2041  to O-H charge transfer in the molecular solver. */
2042  /* O + H+ => H + O+ */
2043  if( iteration==1 && conv.lgSearch )
2044  {
2045  /* during search for first iteration do not do ct */
2046  oatomic = 0.;
2047  oion = 0.;
2048  }
2049  else
2050  {
2051  /* same zone and iteration, take mean of old and new abund */
2052 # define OLD_FRAC 0.0
2053  oatomic = oatomic*OLD_FRAC + dense.xIonDense[ipOXYGEN][0]*(1.-OLD_FRAC);
2054  oion = oion*OLD_FRAC + dense.xIonDense[ipOXYGEN][1]*(1.-OLD_FRAC);
2055  /* ionbal.lgHO_ct_chem is normally 1 set to 0 with command
2056  * set HO charge transfer ionization, in which case we do H O
2057  * charge transfer in ionization solver */
2058  oatomic *= ionbal.lgHO_ct_chem;
2059  oion *= ionbal.lgHO_ct_chem;
2060  }
2061  /* oatomic = dense.xIonDense[ipOXYGEN][0];
2062  oion = dense.xIonDense[ipOXYGEN][1]; */
2063 
2064  if(r->next == NULL) {
2065  int in[]={ipMHp},out[]={ipMH};
2066  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2067  }
2068 
2069  r = r->next;
2070  rindex++;
2071  /*r->rk = atmdat.HCharExcIonOf[ipOXYGEN][0]*dense.xIonDense[ipOXYGEN][0]; */
2072  r->rk = atmdat.HCharExcIonOf[ipOXYGEN][0]*oatomic;
2073 
2074  /* O+ + H => H+ + O */
2075  if(r->next == NULL) {
2076  int in[]={ipMH},out[]={ipMHp};
2077  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2078  }
2079  r = r->next;
2080  rindex++;
2081  /*r->rk = atmdat.HCharExcRecTo[ipOXYGEN][0]*dense.xIonDense[ipOXYGEN][1]; */
2082  r->rk = atmdat.HCharExcRecTo[ipOXYGEN][0]*oion;
2083 
2084  /* >>chng 03 aug 22 */
2085  /* H2+ + e=> H + H;
2086  * equation (6,table 4) from
2087  * >>refer H2 l Maloney et.al, 1996,ApJ, 466, 561
2088  * h2pehh = 2.8e-8f*pow(phycon.te/1000., -0.37) */
2089  /* >>chng 03 sep 01, rm the pow function */
2090  /*h2pehh = 2.8e-8f*pow(phycon.te/1000., -0.37);*/
2091  h2pehh = 2.8e-8*12.882/(phycon.te30*phycon.te07)*dense.eden;
2092 
2093  /* >> chng 05 aug 05, NPA comment. Rate we use and UMIST uses is different.
2094  If UMIST hack is on then we use UMIST, otherwise we use our rate */
2095 
2096  if(!co.lgUMISTrates)
2097  h2pehh = HMRATE(1.6e-8,-0.43,0);
2098 
2099  if(r->next == NULL) {
2100  int in[]={ipMH2p},out[]={ipMH,ipMH};
2101  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2102  }
2103  r = r->next;
2104  rindex++;
2105  r->rk =h2pehh;
2106 
2107  /* back reaction, H + H+ + e => h2+ + e */
2108  /* >>chng 05 aug 02, rm eden umist terms since now in above
2109  * note on units - this will go into rk as a two-body reaction,
2110  * so we need to multiply by an extra eden before feeding into the matrix
2111  * this is why the eden is left in the h2pcin from above, the
2112  * real back rate coefficient for a three body process would be this
2113  * divided by eden */
2114  b2pcin = h2pcin*hmi.rel_pop_LTE_H2p;
2115  /* this is the hot reaction at high densities */
2116 
2117  if(r->next == NULL) {
2118  int in[]={ipMH,ipMHp},out[]={ipMH2p};
2119  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2120  }
2121  r = r->next;
2122  rindex++;
2123  r->rk = b2pcin;
2124 
2125  /* H2+ + HNU => H+ + H */
2126 
2127  if(r->next == NULL) {
2128  int in[]={ipMH2p},out[]={ipMH,ipMHp};
2129  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2130  }
2131  r = r->next;
2132  rindex++;
2133  r->rk = gamtwo;
2134 
2135  /*>>KEYWORD H2+ photoionization
2136  * photoionization by hard photons, crossection =H0 in high-energy limit
2137  * H2+ + hnu -> H + H+
2138  * one electron system */
2139  if(r->next == NULL) {
2140  int in[]={ipMH2p},out[]={ipMH,ipMHp};
2141  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2142  }
2143  r = r->next;
2144  rindex++;
2145 
2146  /* >> chng 05 aug 05, NPA comment. This reaction is not in UMIST, for the case
2147  * of hard photons. Turn if off for the comparison.
2148  * >>chng 05 nov 27, factor of two had been in front of H photo rate
2149  * by analogy with high-energy limit for H2 - but this is a one-electron
2150  * system so not appropriate
2151  * note that iso.gamnc include bound Compton ionization */
2152  /*r->rk = 2.*iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s]*co.lgUMISTrates;*/
2154 
2155  /* H2 + H2+ => H + H3+ */
2158  hmi.h2ph3p = 1.40e-9*(1. - sexp(9940./phycon.te));
2159 
2160  if(!co.lgUMISTrates)
2161  hmi.h2ph3p = 2.08e-9;
2162 
2163  if(r->next == NULL) {
2164  int in[]={ipMH2g,ipMH2p},out[]={ipMH,ipMH3p};
2165  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2166  }
2167  r = r->next;
2168  rindex++;
2169  r->rk = hmi.h2ph3p;
2170 
2171  /* destroy H2+ via H2+ + H2 => H + H+ + H2 */
2173  /* >> chng 05 aug 05, NPA comment. Rate we use and UMIST uses is different.
2174  If UMIST hack is on then we use UMIST, otherwise we use our rate */
2175 
2176  h2phhp = 2.41e-12*phycon.sqrte*sexp(30720./phycon.te)*co.lgUMISTrates;
2177 
2178  if(r->next == NULL) {
2179  int in[]={ipMH2g,ipMH2p},out[]={ipMH,ipMHp,ipMH2g};
2180  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2181  }
2182  r = r->next;
2183  rindex++;
2184  r->rk = h2phhp;
2185 
2186  /*------------------------------------------------------------------ */
2187 
2188  /* H3+ balance equations*/
2189 
2190  /* photoionization by hard photons, crossection =2*HI (wild guess)
2191  * -- rjrw: where do they go???
2192  * -- H3+ + hv => H2+ + H+ + e, best guess (P. Stancil, priv comm) */
2193 
2194  if(r->next == NULL) {
2195  int in[]={ipMH3p},out[]={ipMH2p,ipMHp};
2196  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2197  }
2198  r = r->next;
2199  rindex++;
2200 
2201  /* >> chng 05 aug 05, NPA comment. This reaction is not in UMIST, for the case
2202  of hard photons. Turn if off for the comparison. */
2204 
2205  /*------------------------------------------------------------------ */
2206 
2207  /* vib excited H2, called H2* balance equations, these closely follow
2208  * >>refer h2 fits Tielens, A.G.G.M., & Hollenbach, D., 1985a, ApJ 291, 722 */
2209  /* population of vib-excited H2, from discussion on pp 736-737 of TH85 */
2210 
2211  /* deexcitation rate from upper level, H2* => H2 */
2212 
2213  /* deexc_hneut is H2* + H0 -> H2g + H
2214  * deexc_htwo is H2* + H2 -> H2g + H2 */
2215  Boltz_fac_H2_H2star = 1.*sexp( 30172./phycon.te);
2217  {
2218  deexc_htwo = hmi.Average_collH2_deexcit;
2219  deexc_hneut = hmi.Average_collH_deexcit;
2220  }
2221  else
2222  {
2223  deexc_htwo = (1.4e-12*phycon.sqrte * sexp( 18100./(phycon.te + 1200.) ))/6.;
2224  deexc_hneut = (1e-12*phycon.sqrte * sexp(1000./phycon.te ))/6.;
2225  }
2226  /* total H2* -> H2g rate, s-1 */
2227  H2star_deexcit = hmi.H2_total*deexc_htwo + hmi.Hmolec[ipMH] * deexc_hneut;
2228 
2229  /* H2g -> H2s */
2231  {
2232  H2star_excit = hmi.Average_collH2_excit *hmi.H2_total +
2234  }
2235  else
2236  {
2237  H2star_excit = Boltz_fac_H2_H2star * H2star_deexcit;
2238  }
2239 
2240  /* depopulate H2_star, 2e-7 is spontaneous deexcitation rate,
2241  * which also appears in lines where intensity of vib lines is entered into line stack */
2242  /* H2* + H2g -> H2g + H2g */
2243 
2244  if(r->next == NULL) {
2245  int in[]={ipMH2s},out[]={ipMH2g};
2246  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2247  }
2248  r = r->next;
2249  rindex++;
2250 
2251  /* >>chng 05 jul 11, TE, rename to use in punch file*/
2252  /* >>chng 05 jul 9, GS, use average A calculated from Big H2 */
2254  {
2256  }
2257  else
2258  {
2259  hmi.h2s_sp_decay = 2e-7;
2260  }
2261  r->rk = hmi.h2s_sp_decay;
2262 
2263 
2264  if(r->next == NULL) {
2265  int in[]={ipMH2s},out[]={ipMH2g},ratesp[]={ipMH2s,ipMH2g};
2266  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
2267  }
2268  r = r->next;
2269  rindex++;
2270  r->rk = deexc_htwo;
2271 
2272  if(r->next == NULL) {
2273  int in[]={ipMH2s},out[]={ipMH2g},ratesp[]={ipMH2s,ipMH};
2274  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
2275  }
2276  r = r->next;
2277  rindex++;
2278  r->rk = deexc_hneut;
2279 
2280  /* collisional excitation of vib from ground,
2281  * H2g + H2g -> H2* + H2g, so H2g acts as catalyst
2282  * stat weight of ground 1, excit 6, as per TH discussion
2283  * this must normally be zero */
2284  /* H2 producing H2_star */
2285  /* >>chng 03 sep 11, had been 6, changed to 1 */
2286  /*Boltz_fac_H2_H2star = 1.*sexp( hmi.H2_BigH2_H2s_av * T1CM / phycon.te);*/
2287  /* total excitation rate to H2*, s-1, NB - this is also used in the cooling - heating
2288  * rate below */
2289  /*H2star_excit = Boltz_fac_H2_H2star * H2star_deexcit;*/
2290 
2291  if(r->next == NULL) {
2292  int in[]={ipMH2g},out[]={ipMH2s},ratesp[]={ipMH2g,ipMH2g};
2293  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
2294  }
2295  r = r->next;
2296  rindex++;
2297  /* >>chng 05 jul 10, GS, use average collisional rate calculated from Big H2 */
2299  {
2301  }
2302  else
2303  {
2304  r->rk = deexc_htwo*Boltz_fac_H2_H2star;
2305  }
2306 
2307  if(r->next == NULL) {
2308  int in[]={ipMH2g},out[]={ipMH2s},ratesp[]={ipMH,ipMH2g};
2309  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),ratesp,INTSZ(ratesp));
2310  }
2311  r = r->next;
2312  rindex++;
2313  /* >>chng 05 jul 10, GS, use average collisional rate calculated from Big H2 */
2315  {
2316  r->rk = hmi.Average_collH_excit;
2317  }
2318  else
2319  {
2320  r->rk = deexc_hneut*Boltz_fac_H2_H2star;
2321  }
2322 
2323  /* >>chng 03 aug 28 */
2324  /* H2* + H => H + H + H
2325  * equation from table 9
2326  * >>refer H2* k Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722*/
2327 
2328  /* hmi.h2sh = HMRATE(9.8e-12,0.5,2.7e4);*/
2329  /* >>chng 05 jul 19, TE, update to UMIST rate */
2330  /* >>chng 05 mar 18, TE, used in new punch H2 destruction file*/
2331  hmi.h2sh = HMRATE(4.67e-7,-1.,5.5e4);
2332 
2333  if(r->next == NULL) {
2334  int in[]={ipMH2s,ipMH},out[]={ipMH,ipMH,ipMH};
2335  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2336  }
2337  r = r->next;
2338  rindex++;
2339  r->rk = hmi.h2sh;
2340 
2341 
2342  /* The following is a general prescription on how to generate chemical rates for H2* from H2. It
2343  is an e-mail from Phillip Stancil received 05 aug 04.
2344  The topic of the e-mail involved the reaction H2 + H2 => H2 + 2H and
2345  getting reaction rates for H2* + H2 -> H2 + 2H and H2* + H2* -> H2/H2* + 2H from the ground state
2346  reaction rate, which has a strong temperature dependence. E-mail inserted by TE, NPA on 05 aug 05 */
2347 
2348  /***********************************************************************************************
2349  Consider that both H2's are in arbitrary v,j levels and after the collision
2350  they are in arbitrary levels with the constraint that at least on of
2351  the H2's been dissociated or both are dissociated, but both cannot be excited to
2352  bound levels (better to use actual data for those cases).
2353 
2354  H2(vj) + H2(v'j') -> H2(v''j'') + H2(v'''j''')
2355 
2356 
2357  Then an approximate rate coefficient would be
2358 
2359  k_vj,v'j'->v''j'',v'''j''' = 10^-11 * exp(-beta/kT)
2360 
2361  where beta = (E_vj - E_v''j'') + (E_v'j' - E_v'''j'''),
2362 
2363  but if beta<0, set beta=0. So that the rate never becomes greater than ~10^-11 cm^3/s.
2364  Here the energies are dissociation energies (i.e., 4.478 eV for vj=00 and 0 for a
2365  dissociation state).
2366 
2367  So, looking at limits, if vj=v'j'=v''j''=00 and v'''j'''=dissociation
2368  state (15,0, say), then we get
2369 
2370  10^-11*exp(-4.478 eV/kT)
2371 
2372  [ H2(0,0) + H2(0,0) -> H2(0,0) + 2H ]
2373 
2374  if vj=v'j'=00 and v''j''=v'''j'''=dissociation, i.e. 4H is the product, then we get
2375 
2376  10^-11*exp(-2*4.478/kT)
2377 
2378  [ H2(0,0) + H2(0,0) -> 2H + 2H]
2379 
2380 
2381  if vj=v'j'=00, v''j'' is an excited bound state, and v'''j''' is
2382  dissociation, the number in parentheses is between 4.478 and 2*4.478
2383  (i.e., dissociation plus excitation)
2384 
2385  [ H2(0,0) + H2(0,0) -> H2*(v,j) + 2H ]
2386 
2387  However, say we have a case where both H2 in the H2* (1.88 eV) level.
2388 
2389  H2* + H2* -> H2(0,0) + 2H
2390 
2391  then beta = (1.88-4.478)+(1.88-0)=-0.718 eV, so take beta=0 to give k=10^-11.
2392 
2393  This argument considers only asymptotic energies.
2394  So, it neglects selection rules (which would be needed if you considered state-to-state
2395  reactions, but not the two-level approximation) and any effect rovibrational overlaps.
2396 
2397  Phillip Stancil
2398 
2399  **************************************************************************************/
2400 
2401 
2402  /* >>chng 03 aug 28 */
2403  /* H2* + H2 => H2 + H + H
2404  * equation from table 9
2405  * >>refer H2* k Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722-746*/
2406 
2407  /* >>chng 05 jul 19, TE, update to UMIST rate */
2408  /* >>chng 05 mar 18, TE, used in new punch H2 destruction file*/
2409  /* hmi.h2sh2g = HMRATE(9.8e-12,0.5,2.7e4);*/
2410  /* hmi.h2sh2g = HMRATE(1e-8,0.,8.41e4); */
2411  /* >>chng 05 aug 05, TE, update to the scheme of Phillip Stancil */
2412  hmi.h2sh2g = HMRATE(1e-11,0.,2.18e4);
2413  if(r->next == NULL) {
2414  int in[]={ipMH2s,ipMH2g},out[]={ipMH2g,ipMH,ipMH};
2415  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2416  }
2417  r = r->next;
2418  rindex++;
2419  /* >>chng 05 jul 20, GS, TE */
2421  {
2423  }
2424 
2425  r->rk = hmi.h2sh2g;
2426 
2427  /* >>chng 03 aug 28 */
2428  /* H2* + H2* => H2 + H + H
2429  * equation from table 9
2430  * >>refer H2* k Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722-746*/
2431  /* >>chng 05 mar 18, TE, used in new punch H2 destruction file*/
2432  /* hmi.h2sh2sh2g2h = HMRATE(9.8e-12,0.5,0.);*/
2433  /* >>chng 05 jul 19, TE, update to UMIST rate */
2434  /* hmi.h2sh2sh2g2h = HMRATE(1e-8,0.,0.); */
2435  /* >>chng 05 aug 05, TE, update to the scheme of Phillip Stancil */
2436  hmi.h2sh2sh2g2h = HMRATE(1e-11,0.,0.);
2437  if(r->next == NULL) {
2438  int in[]={ipMH2s,ipMH2s},out[]={ipMH2g,ipMH,ipMH};
2439  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2440  }
2441  r = r->next;
2442  rindex++;
2443  /* >>chng 05 jul 20, GS, TE */
2445  {
2447  }
2448 
2449  r->rk = hmi.h2sh2sh2g2h;
2450 
2451 
2452  /* >>chng 05 jul 21, TE, GS */
2453  /* H2* + H2* => H2* + H + H */
2454  /* hmi.h2sh2sh2s2h = HMRATE(1e-8,0.,0.);*/
2455  /* >>chng 05 aug 05, TE, update to the scheme of Phillip Stancil */
2456  hmi.h2sh2sh2s2h = HMRATE(1e-11,0.,2.18e4);
2457  if(r->next == NULL) {
2458  int in[]={ipMH2s,ipMH2s},out[]={ipMH2s,ipMH,ipMH};
2459  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2460  }
2461  r = r->next;
2462  rindex++;
2464  {
2466  }
2467 
2468  r->rk = hmi.h2sh2sh2s2h;
2469 
2470 
2471  /* >>03 may 22, hmi.H2_Solomon_dissoc_rate_used is now rate electronic excited states
2472  * decay into X continuum, not the rate that elec excited states are excited.
2473  * assuming that 10% of excitations lead to ionization, this rate, for relax
2474  * into ro-vib excited states, is 10x the Solomon rate */
2475  /* assume that 0.9 of H2 dissociations lead to H2_star,
2476  * H2 + 0.9*hmi.H2_Solomon_dissoc_rate_used => h2_star */
2477  if(r->next == NULL) {
2478  int in[]={ipMH2g},out[]={ipMH2s};
2479  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2480  }
2481  r = r->next;
2482  rindex++;
2483  /* >>chng 03 may 22, see comment just above */
2484  /*r->rk = 0.9*hmi.H2_Solomon_dissoc_rate_used;
2485  r->rk = 10.*hmi.H2_Solomon_dissoc_rate_used;*/
2486  /* >>chng 03 sep 11, use real evaluated rate */
2488 
2489  /* rate of photodissoc of vib-excit H2, A12 of TH85 */
2490  if(r->next == NULL) {
2491  int in[]={ipMH2s},out[]={ipMH,ipMH};
2492  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2493  }
2494  r = r->next;
2495  rindex++;
2497 
2498 
2499  /* >>chng 05 mar 24, TE, include continuum photodissociation from H2g*/
2500  if(r->next == NULL) {
2501  int in[]={ipMH2g},out[]={ipMH,ipMH};
2502  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2503  }
2504  r = r->next;
2505  rindex++;
2507 
2508  /* >>chng 05 oct 04, TE, rename and include in punch H2 destruction
2509  * >>chng 05 sept 30, GS, include collisional dissociation by electron, H2g + e = 2H + e*/
2510  if(r->next == NULL) {
2511  int in[]={ipMH2g},out[]={ipMH,ipMH};
2512  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2513  }
2514  r = r->next;
2515  rindex++;
2516  hmi.h2ge2h = 1e-14*sexp(4.478*EVDEGK/phycon.te)*dense.eden;
2517  r->rk = hmi.h2ge2h;
2518 
2519  /* >>chng 05 oct 04, TE, rename and include in punch H2 destruction
2520  * >>chng 05 sept 30, GS, include collisional dissociation by electron, H2s + e = 2H + e*/
2521  if(r->next == NULL) {
2522  int in[]={ipMH2s},out[]={ipMH,ipMH};
2523  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2524  }
2525  r = r->next;
2526  rindex++;
2527  hmi.h2se2h = 1e-14*sexp(1.978*EVDEGK/phycon.te)*dense.eden;
2528  r->rk = hmi.h2se2h;
2529 
2530  /*---------------------------------------------------------------- */
2531 
2532  /* He H+ formation rates taken from Flower+Roueff, Black */
2533 
2534  /* He+ + H => HeH+
2535  * radiative association from
2536  * >>refer heh+ rate Zygelman, B., and Dalgarno, A. 1990, ApJ 365, 239 */
2537 
2538  if(r->next == NULL) {
2539  int in[]={ipMH},out[]={ipMHeHp};
2540  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2541  }
2542  r = r->next;
2543  rindex++;
2544  r->rk = 1e-15*dense.xIonDense[ipHELIUM][1];
2545 
2546  /* >>chng 03 sep 30 */
2547  /* back reaction of He+ + H=> He + H+ */
2548  /* He + H+=> He+ + H;
2549  * bhephhphe = hephhphe*dense.xIonDense[ipHELIUM][1]*dense.xIonDense[ipHYDROGEN][0]/dense.xIonDense[ipHYDROGEN][1];*/
2550  /*bhephhphe = hephhphe*dense.xIonDense[ipHELIUM][1]*dense.xIonDense[ipHYDROGEN][0]/SDIV(dense.xIonDense[ipHYDROGEN][1]);
2551  if(r->next == NULL) {
2552  int in[]={ipMHp},out[]={ipMH};
2553  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2554  }
2555  r = r->next;
2556  rindex++;
2557  r->rk = bhephhphe;*/
2558 
2559  /* >>chng 03 sep 30 */
2560  /* He + H-=> He + H + e;
2561  * equation (table 5) from
2562  * >>refer H- k Paolo Lenzuni, David F. Chernoff, Edwin E. Salpeter, 1991, ApJS, 76, 759L
2563  * hehmeheh = 4.1e-17*pow(phycon.te,2)*sexp(19870/phycon.te)*dense.xIonDense[ipHELIUM][0];*/
2564  hehmeheh = 4.1e-17*phycon.tesqrd*sexp(19870/phycon.te)*dense.xIonDense[ipHELIUM][0];
2565  if(r->next == NULL) {
2566  int in[]={ipMHm},out[]={ipMH};
2567  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2568  }
2569  r = r->next;
2570  rindex++;
2571  r->rk =hehmeheh;
2572 
2573  /* >>chng 03 sep 30 */
2574  /* He+ + H2=> He + H+ + H;
2575  * equation (table 6) from
2576  * >>refer H2 dissoc Tielens, A.G.G.M., & Hollenbach, D., 1985, ApJ, 291, 722
2577  * heph2hpheh = 1.5e-13*dense.xIonDense[ipHELIUM][1];*/
2578  /*hmi.rheph2hpheh = 1.5e-13f;*/
2579  /* >>chng 04 jun 10 */
2580  /* use the rate for this reaction as defined in UMIST */
2581 
2582  /* >> chng 05 aug 05, NPA comment. This reaction can be an important He+ destruction term
2583  deep in molecular clouds. This reaction is only slightly different from TH85, and has a temperature dependence.
2584  Therefore this rate was switched to UMIST*/
2586  hmi.rheph2hpheh = (realnum)HMRATE(3.7e-14, 0., 35);
2587  if(r->next == NULL) {
2588  int in[]={ipMH2g},out[]={ipMHp,ipMH};
2589  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2590  }
2591  r = r->next;
2592  rindex++;
2594 
2595  /* >>chng 04 jun 10 -- This reaction was not originally included. It is in
2596  * the UMIST database and seems to be an important He+ destruction mechanism */
2597  /* He+ + H2=> He + H2+
2598  * use the rate for this reaction as defined in UMIST */
2600  hmi.heph2heh2p = (realnum)HMRATE(7.2e-15, 0., 0);
2601  if(r->next == NULL) {
2602  int in[]={ipMH2g},out[]={ipMH2p};
2603  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2604  }
2605  r = r->next;
2606  rindex++;
2608 
2609  /* He + H+ => HeH+ */
2610  if(r->next == NULL) {
2611  int in[]={ipMHp},out[]={ipMHeHp};
2612  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2613  }
2614  r = r->next;
2615  rindex++;
2616  r->rk = 1e-20*dense.xIonDense[ipHELIUM][0];
2617 
2618  /* H2+ + HE => HEH+ + H0 */
2619  if(r->next == NULL) {
2620  int in[]={ipMH2p},out[]={ipMH,ipMHeHp};
2621  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2622  }
2623  r = r->next;
2624  rindex++;
2625 
2626  /* >> chng 05 aug 05, NPA comment. Turn off HeH+ for the Leiden comparison. Can't
2627  turn if off completely or else the matrix is unstable. Just make sure that
2628  the abundance never affects the other molecules. */
2629 
2630  r->rk = 3e-10*exp(-6717./phycon.te)*dense.xIonDense[ipHELIUM][0]*co.lgUMISTrates;
2631 
2632  /* photodissociation through 1.6->2.3 continuum */
2633 
2634  /* why is this in a look instead of GammaK?
2635  * to fix must set opacities into stack */
2636  gamheh = 0.;
2637  limit = MIN2(hmi.iheh2-1 , rfield.nflux );
2638  for( i=hmi.iheh1-1; i < limit; i++ )
2639  {
2640  gamheh += rfield.flux[i] + rfield.ConInterOut[i]+ rfield.outlin[i] + rfield.outlin_noplot[i];
2641  }
2642  gamheh *= 4e-18;
2643 
2644  /* hard radiation */
2645  gamheh += 3.*iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s];
2646 
2647  /* recombination, HeH+ + e => He + H */
2648  gamheh += dense.eden*1e-9;
2649 
2650  if(r->next == NULL) {
2651  int in[]={ipMHeHp},out[]={ipMH};
2652  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2653  }
2654  r = r->next;
2655  rindex++;
2656  r->rk = gamheh;
2657 
2658  /* HeH+ + H => H2+ + He */
2659  if(r->next == NULL) {
2660  int in[]={ipMH,ipMHeHp},out[]={ipMH2p};
2661  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2662  }
2663  r = r->next;
2664  rindex++;
2665 
2666  /* >> chng 05 aug 05, NPA comment. Turn off HeH+ for the Leiden comparison. Can't
2667  turn if off completely or else the matrix is unstable. Just make sure that
2668  the abundance never affects the other molecules. */
2669 
2670  r->rk = 1e-10*co.lgUMISTrates;
2671 
2672  /* >>chng 03 sep 30 */
2673  /* HeH+ + H2 => H3+ + He
2674  * equation (He13) from
2675  * >>refer HeH+ k Galli, D., & Palla, F. 1998, A&A,335,403-420
2676  * hehph2h3phe = 1.3e-9;*/
2677  /*UMIST: 1.5e-9*/
2678 
2679  /* >> chng 05 aug 05, NPA comment. Turn off HeH+ for the Leiden comparison. Can't
2680  turn if off completely or else the matrix is unstable. Just make sure that
2681  the abundance never affects the other molecules. */
2684  hmi.hehph2h3phe = 1.3e-9*co.lgUMISTrates;
2685  if(r->next == NULL) {
2686  int in[]={ipMH2g,ipMHeHp},out[]={ipMH3p};
2687  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2688  }
2689  r = r->next;
2690  rindex++;
2691  r->rk = hmi.hehph2h3phe;
2692 
2693  /* >>chng 03 sep 30 */
2694  /* He+ + H- => H + He
2695  * equation (20) from
2696  * >>refer H- k Stancil, P.C., Lepp, S., Dalgarno, A.1998, ApJ,509,1-10
2697  * hephmhhe = 2.32e-7*pow(phycon.te/300,-.52)*sexp(phycon.te/-22400.)*dense.xIonDense[ipHELIUM][1];*/
2698  /* >>chng 03 oct 22, only add for Te < 1e5 - caused exception as T -> inf */
2699  hephmhhe = 2.32e-7*pow(phycon.te/300,-.52)*exp(TStancil/22400.)*dense.xIonDense[ipHELIUM][1];
2700  if(r->next == NULL) {
2701  int in[]={ipMHm},out[]={ipMH};
2702  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2703  }
2704  r = r->next;
2705  rindex++;
2706  r->rk =hephmhhe;
2707 
2708 # define CO_ON true
2709  /*>>chng 06 jul 02, do not include cross terms with co molecules when advection on -
2710  * this causes the H sum to be incorrect by as much as a few percent - no problem is
2711  * co network if not on when dynamics is done */
2712  if( CO_ON && !dynamics.lgAdvection )
2713  {
2714  /* >>chng 04 may 26, NPA add this code */
2715  /* Many reactions in co.c also will create or destroy molecules that are predicted
2716  in hmole. These reactions need to be inserted into this solver to obtain a more
2717  accurate solution. These are the rates for reactions in co.c that create or destroy
2718  species that are predicted in hmole_step.c.*/
2719 
2720  co.H_CH_C_H_H = CO_findrk("H,CH=>C,H,H")*findspecies("CH")->hevmol;
2721  co.H_OH_O_H_H = CO_findrk("H,OH=>O,H,H")*findspecies("OH")->hevmol;
2722  co.H_H2O_OH_H_H = CO_findrk("H,H2O=>OH,H,H")*findspecies("H2O")->hevmol;
2723  co.H_COP_CO_HP = CO_findrk("H,CO+=>CO,H+")*findspecies("CO+")->hevmol;
2724  co.H_CH_C_H2 = CO_findrk("H,CH=>C,H2")*findspecies("CH")->hevmol;
2725  co.H_CHP_CP_H2 = CO_findrk("H,CH+=>C+,H2")*findspecies("CH+")->hevmol;
2726  co.H_CH2_CH_H2 = CO_findrk("H,CH2=>CH,H2")*findspecies("CH2")->hevmol;
2727  co.H_CH3P_CH2P_H2 = CO_findrk("H,CH3+=>CH2+,H2")*findspecies("CH3+")->hevmol;
2728  co.H_OH_O_H2 = CO_findrk("H,OH=>O,H2")*findspecies("OH")->hevmol;
2729  co.H_H2O_OH_H2 = CO_findrk("H,H2O=>OH,H2")*findspecies("H2O")->hevmol;
2730  co.Hminus_HCOP_CO_H2 = CO_findrk("H-,HCO+=>CO,H2")*findspecies("HCO+")->hevmol;
2731  co.Hminus_H3OP_H2O_H2 = CO_findrk("H-,H3O+=>H2O,H2")*findspecies("H3O+")->hevmol;
2732  co.Hminus_H3OP_OH_H2_H = CO_findrk("H-,H3O+=>OH,H2,H")*findspecies("H3O+")->hevmol;
2733  co.HP_CH_CHP_H = CO_findrk("H+,CH=>CH+,H")*findspecies("CH")->hevmol;
2734  co.HP_CH2_CH2P_H = CO_findrk("H+,CH2=>CH2+,H")*findspecies("CH2")->hevmol;
2735  co.HP_H2O_H2OP_H = CO_findrk("H+,H2O=>H2O+,H")*findspecies("H2O")->hevmol;
2736  co.HP_O2_O2P_H = CO_findrk("H+,O2=>O2+,H")*findspecies("O2")->hevmol;
2737  co.HP_OH_OHP_H = CO_findrk("H+,OH=>OH+,H")*findspecies("OH")->hevmol;
2738  co.HP_SiO_SiOP_H = CO_findrk("H+,SiO=>SiO+,H")*findspecies("SiO")->hevmol;
2739  co.HP_CH2_CHP_H2 = CO_findrk("H+,CH2=>CH+,H2")*findspecies("CH2")->hevmol;
2740  co.HP_SiH_SiP_H2 = CO_findrk("H+,SiH=>Si+,H2")*findspecies("SiH")->hevmol;
2741  co.H2_CHP_CH2P_H = CO_findrk("H2,CH+=>CH2+,H")*findspecies("CH+")->hevmol;
2742  co.H2_CH2P_CH3P_H = CO_findrk("H2,CH2+=>CH3+,H")*findspecies("CH2+")->hevmol;
2743  co.H2_OHP_H2OP_H = CO_findrk("H2,OH+=>H2O+,H")*findspecies("OH+")->hevmol;
2744  co.H2_H2OP_H3OP_H = CO_findrk("H2,H2O+=>H3O+,H")*findspecies("H2O+")->hevmol;
2745  co.H2_COP_HCOP_H = CO_findrk("H2,CO+=>HCO+,H")*findspecies("CO+")->hevmol;
2746  co.H2_OP_OHP_H = CO_findrk("H2,O+=>OH+,H")*findspecies("O+")->hevmol;
2747  co.H2_SiOP_SiOHP_H = CO_findrk("H2,SiO+=>SiOH+,H")*findspecies("SiO+")->hevmol;
2748  co.H2_C_CH_H = CO_findrk("H2,C=>CH,H")*findspecies("C")->hevmol;
2749  co.H2_CP_CHP_H = CO_findrk("H2,C+=>CH+,H")*findspecies("C+")->hevmol;
2750  co.H2_CH_CH2_H = CO_findrk("H2,CH=>CH2,H")*findspecies("CH")->hevmol;
2751  co.H2_OH_H2O_H = CO_findrk("H2,OH=>H2O,H")*findspecies("OH")->hevmol;
2752  co.H2_O_OH_H = CO_findrk("H2,O=>OH,H")*findspecies("O")->hevmol;
2753  co.H2_CH_C_H2_H = CO_findrk("H2,CH=>C,H2,H")*findspecies("CH")->hevmol;
2754  co.H2_OH_O_H2_H = CO_findrk("H2,OH=>O,H2,H")*findspecies("OH")->hevmol;
2755  co.H2_H2O_OH_H2_H = CO_findrk("H2,H2O=>OH,H2,H")*findspecies("H2O")->hevmol;
2756  co.H2_O2_O_O_H2 = CO_findrk("H2,O2=>O,O,H2")*findspecies("O2")->hevmol;
2759  co.H2s_H2O_OH_H2_H = CO_findrk("H2*,H2O=>OH,H2,H")*findspecies("H2O")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
2761  co.H2P_C_CHP_H = CO_findrk("H2+,C=>CH+,H")*findspecies("C")->hevmol;
2762  co.H2P_CH_CH2P_H = CO_findrk("H2+,CH=>CH2+,H")*findspecies("CH")->hevmol;
2763  co.H2P_CH2_CH3P_H = CO_findrk("H2+,CH2=>CH3+,H")*findspecies("CH2")->hevmol;
2764  co.H2P_OH_H2OP_H = CO_findrk("H2+,OH=>H2O+,H")*findspecies("OH")->hevmol;
2765  co.H2P_H2O_H3OP_H = CO_findrk("H2+,H2O=>H3O+,H")*findspecies("H2O")->hevmol;
2766  co.H2P_CO_HCOP_H = CO_findrk("H2+,CO=>HCO+,H")*findspecies("CO")->hevmol;
2767  co.H2P_O_OHP_H = CO_findrk("H2+,O=>OH+,H")*findspecies("O")->hevmol;
2768  co.H2P_CH_CHP_H2 = CO_findrk("H2+,CH=>CH+,H2")*findspecies("CH")->hevmol;
2769  co.H2P_CH2_CH2P_H2 = CO_findrk("H2+,CH2=>CH2+,H2")*findspecies("CH2")->hevmol;
2770  co.H2P_CO_COP_H2 = CO_findrk("H2+,CO=>CO+,H2")*findspecies("CO")->hevmol;
2771  co.H2P_H2O_H2OP_H2 = CO_findrk("H2+,H2O=>H2O+,H2")*findspecies("H2O")->hevmol;
2772  co.H2P_O2_O2P_H2 = CO_findrk("H2+,O2=>O2+,H2")*findspecies("O2")->hevmol;
2773  co.H2P_OH_OHP_H2 = CO_findrk("H2+,OH=>OH+,H2")*findspecies("OH")->hevmol;
2774  co.H3P_C_CHP_H2 = CO_findrk("H3+,C=>CH+,H2")*findspecies("C")->hevmol;
2775  co.H3P_CH_CH2P_H2 = CO_findrk("H3+,CH=>CH2+,H2")*findspecies("CH")->hevmol;
2776  co.H3P_CH2_CH3P_H2 = CO_findrk("H3+,CH2=>CH3+,H2")*findspecies("CH2")->hevmol;
2777  co.H3P_OH_H2OP_H2 = CO_findrk("H3+,OH=>H2O+,H2")*findspecies("OH")->hevmol;
2778  co.H3P_H2O_H3OP_H2 = CO_findrk("H3+,H2O=>H3O+,H2")*findspecies("H2O")->hevmol;
2779  co.H3P_CO_HCOP_H2 = CO_findrk("H3+,CO=>HCO+,H2")*findspecies("CO")->hevmol;
2780  co.H3P_O_OHP_H2 = CO_findrk("H3+,O=>OH+,H2")*findspecies("O")->hevmol;
2781  co.H3P_SiH_SiH2P_H2 = CO_findrk("H3+,SiH=>SiH2+,H2")*findspecies("SiH")->hevmol;
2782  co.H3P_SiO_SiOHP_H2 = CO_findrk("H3+,SiO=>SiOH+,H2")*findspecies("SiO")->hevmol;
2788  co.H_CH3_CH2_H2 = CO_findrk("H,CH3=>CH2,H2")*findspecies("CH3")->hevmol;
2789  co.H_CH4P_CH3P_H2 = CO_findrk("H,CH4+=>CH3+,H2")*findspecies("CH4+")->hevmol;
2790  co.H_CH5P_CH4P_H2 = CO_findrk("H,CH5+=>CH4+,H2")*findspecies("CH5+")->hevmol;
2791  co.H2_CH2_CH3_H = CO_findrk("H2,CH2=>CH3,H")*findspecies("CH2")->hevmol;
2792  co.H2_CH3_CH4_H = CO_findrk("H2,CH3=>CH4,H")*findspecies("CH3")->hevmol;
2793  co.H2_CH4P_CH5P_H = CO_findrk("H2,CH4+=>CH5+,H")*findspecies("CH4+")->hevmol;
2794  co.H2s_CH2_CH3_H = CO_findrk("H2*,CH2=>CH3,H")*findspecies("CH2")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
2795  co.H2s_CH3_CH4_H = CO_findrk("H2*,CH3=>CH4,H")*findspecies("CH3")->hevmol*hmi.lgLeiden_Keep_ipMH2s;
2796  co.H2P_CH4_CH3P_H2 = CO_findrk("H2+,CH4=>CH3+,H2,H")*findspecies("CH4")->hevmol;
2797  co.H2P_CH4_CH4P_H2 = CO_findrk("H2+,CH4=>CH4+,H2")*findspecies("CH4")->hevmol;
2798  co.H2P_CH4_CH5P_H = CO_findrk("H2+,CH4=>CH5+,H")*findspecies("CH4")->hevmol;
2799  /* >>chng 05 jul 15, TE, change from findspecies("CH")->hevmol to findspecies("CH3")->hevmol */
2800  co.H3P_CH3_CH4P_H2 = CO_findrk("H3+,CH3=>CH4+,H2")*findspecies("CH3")->hevmol;
2801  co.H3P_CH4_CH5P_H2 = CO_findrk("H3+,CH4=>CH5+,H2")*findspecies("CH4")->hevmol;
2802  co.HP_CH3_CH3P_H = CO_findrk("H+,CH3=>CH3+,H")*findspecies("CH3")->hevmol;
2803  co.HP_CH4_CH3P_H2 = CO_findrk("H+,CH4=>CH3+,H2")*findspecies("CH4")->hevmol;
2804  co.HP_CH4_CH4P_H = CO_findrk("H+,CH4=>CH4+,H")*findspecies("CH4")->hevmol;
2805 
2806 
2807  /* >>chng 04 jul 14 -- NPA. This is the contribution that the heavy element
2808  * network makes to the hydrogen chemistry due to reactions with N and S. */
2809 
2810  co.H2_N_NH_H = CO_findrk("H2,N=>NH,H")*findspecies("N")->hevmol;
2811  co.H2_NH_NH2_H = CO_findrk("H2,NH=>NH2,H")*findspecies("NH")->hevmol;
2812  co.H2_NH2_NH3_H = CO_findrk("H2,NH2=>NH3,H")*findspecies("NH2")->hevmol;
2813  co.H2_CN_HCN_H = CO_findrk("H2,CN=>HCN,H")*findspecies("CN")->hevmol;
2814  co.HP_HNO_NOP_H2 = CO_findrk("H+,HNO=>NO+,H2")*findspecies("HNO")->hevmol;
2815  co.HP_HS_SP_H2 = CO_findrk("H+,HS=>S+,H2")*findspecies("HS")->hevmol;
2816  co.H_HSP_SP_H2 = CO_findrk("H,HS+=>S+,H2")*findspecies("HS+")->hevmol;
2817  co.H2P_N_NHP_H = CO_findrk("H2+,N=>NH+,H")*findspecies("N")->hevmol;
2818  co.H2_NP_NHP_H = CO_findrk("H2,N+=>NH+,H")*findspecies("N+")->hevmol;
2819  co.H2_NHP_N_H3P = CO_findrk("H2,NH+=>N,H3+")*findspecies("NH+")->hevmol;
2820  co.H2P_NH_NH2P_H = CO_findrk("H2+,NH=>NH2+,H")*findspecies("NH")->hevmol;
2821  co.H2_NHP_NH2P_H = CO_findrk("H2,NH+=>NH2+,H")*findspecies("NH+")->hevmol;
2822  co.H2_NH2P_NH3P_H = CO_findrk("H2,NH2+=>NH3+,H")*findspecies("NH2+")->hevmol;
2823  co.H2_NH3P_NH4P_H = CO_findrk("H2,NH3+=>NH4+,H")*findspecies("NH3+")->hevmol;
2824  co.H2P_CN_HCNP_H = CO_findrk("H2+,CN=>HCN+,H")*findspecies("CN")->hevmol;
2825  co.H2_CNP_HCNP_H = CO_findrk("H2,CN+=>HCN+,H")*findspecies("CN+")->hevmol;
2826  co.H2P_NO_HNOP_H = CO_findrk("H2+,NO=>HNO+,H")*findspecies("NO")->hevmol;
2827  co.H2_SP_HSP_H = CO_findrk("H2,S+=>HS+,H")*findspecies("S+")->hevmol;
2828  co.H2_CSP_HCSP_H = CO_findrk("H2,CS+=>HCS+,H")*findspecies("CS+")->hevmol;
2829  co.H3P_NH_NH2P_H2 = CO_findrk("H3+,NH=>NH2+,H2")*findspecies("NH")->hevmol;
2830  co.H3P_NH2_NH3P_H2 = CO_findrk("H3+,NH2=>NH3+,H2")*findspecies("NH2")->hevmol;
2831  co.H3P_NH3_NH4P_H2 = CO_findrk("H3+,NH3=>NH4+,H2")*findspecies("NH3")->hevmol;
2832  co.H3P_CN_HCNP_H2 = CO_findrk("H3+,CN=>HCN+,H2")*findspecies("CN")->hevmol;
2833  co.H3P_NO_HNOP_H2 = CO_findrk("H3+,NO=>HNO+,H2")*findspecies("NO")->hevmol;
2834  co.H3P_S_HSP_H2 = CO_findrk("H3+,S=>HS+,H2")*findspecies("S")->hevmol;
2835  co.H3P_CS_HCSP_H2 = CO_findrk("H3+,CS=>HCS+,H2")*findspecies("CS")->hevmol;
2836  co.H3P_NO2_NOP_OH_H2 = CO_findrk("H3+,NO2=>NO+,OH,H2")*findspecies("NO2")->hevmol;
2837  co.HP_NH_NHP_H = CO_findrk("H+,NH=>NH+,H")*findspecies("NH")->hevmol;
2838  co.HP_NH2_NH2P_H = CO_findrk("H+,NH2=>NH2+,H")*findspecies("NH2")->hevmol;
2839  co.HP_NH3_NH3P_H = CO_findrk("H+,NH3=>NH3+,H")*findspecies("NH3")->hevmol;
2840  co.H_CNP_CN_HP = CO_findrk("H,CN+=>CN,H+")*findspecies("CN+")->hevmol;
2841  co.HP_HCN_HCNP_H = CO_findrk("H+,HCN=>HCN+,H")*findspecies("HCN")->hevmol;
2842  co.H_HCNP_HCN_HP = CO_findrk("H,HCN+=>HCN,H+")*findspecies("HCN+")->hevmol;
2843  co.H_N2P_N2_HP = CO_findrk("H,N2+=>N2,H+")*findspecies("N2+")->hevmol;
2844  co.HP_NO_NOP_H = CO_findrk("H+,NO=>NO+,H")*findspecies("NO")->hevmol;
2845  co.HP_HS_HSP_H = CO_findrk("H+,HS=>HS+,H")*findspecies("HS")->hevmol;
2846  co.HP_SiN_SiNP_H = CO_findrk("H+,SiN=>SiN+,H")*findspecies("SiN")->hevmol;
2847  co.HP_CS_CSP_H = CO_findrk("H+,CS=>CS+,H")*findspecies("CS")->hevmol;
2848  co.HP_NS_NSP_H = CO_findrk("H+,NS=>NS+,H")*findspecies("NS")->hevmol;
2849  co.HP_SO_SOP_H = CO_findrk("H+,SO=>SO+,H")*findspecies("SO")->hevmol;
2850  co.HP_OCS_OCSP_H = CO_findrk("H+,OCS=>OCS+,H")*findspecies("OCS")->hevmol;
2851  co.HP_S2_S2P_H = CO_findrk("H+,S2=>S2+,H")*findspecies("S2")->hevmol;
2852  co.H2P_NH_NHP_H2 = CO_findrk("H2+,NH=>NH+,H2")*findspecies("NH")->hevmol;
2853  co.H2P_NH2_NH2P_H2 = CO_findrk("H2+,NH2=>NH2+,H2")*findspecies("NH2")->hevmol;
2854  co.H2P_NH3_NH3P_H2 = CO_findrk("H2+,NH3=>NH3+,H2")*findspecies("NH3")->hevmol;
2855  co.H2P_CN_CNP_H2 = CO_findrk("H2+,CN=>CN+,H2")*findspecies("CN")->hevmol;
2856  co.H2P_HCN_HCNP_H2 = CO_findrk("H2+,HCN=>HCN+,H2")*findspecies("HCN")->hevmol;
2857  co.H2P_NO_NOP_H2 = CO_findrk("H2+,NO=>NO+,H2")*findspecies("NO")->hevmol;
2858  /*>>chng 05 jul 22, TE, included reaction which contribute to the molecular hydrogen network */
2859  /* that were in mole_co_step, but not in mole_h_step*/
2860  co.HP_C2_C2P_H = CO_findrk("H+,C2=>C2+,H")*findspecies("C2")->hevmol;
2861  co.H2P_C2_C2P_H2 = CO_findrk("H2+,C2=>C2+,H2")*findspecies("C2")->hevmol;
2862  co.Hminus_NH4P_NH3_H2 = CO_findrk("H-,NH4+=>NH3,H2")*findspecies("NH4+")->hevmol;
2863  co.Hminus_NP_N_H = CO_findrk("H-,N+=>N,H")*findspecies("N+")->hevmol;
2864 
2865  /* >> chng 05 jul 15, TE, make the chlorine reactions a member of mole.h */
2866  /* >>chng 05 mar 23 -- NPA. Add Chlorine chemical reactions to hydrogen ionization balance */
2867  /* >>chng 05 jul 21 -- NPA. TE noticed that two reactions that contribute to the molecular hydrogen network,
2868  * and in mole_co_step.c, were not included in h_step. These reactions are now inserted.*/
2869  /* >>chng 05 aug 1 -- NPA. Gargi Shaw noticed that the reaction H2 + S => HS + H was not in the CO network
2870  * This has been changed. This reaction also affects H2 network so must go here also .*/
2871 
2872  co.H2_ClP_HClP_H = CO_findrk("H2,Cl+=>HCl+,H")*findspecies("Cl+")->hevmol;
2873  co.H2_HClP_H2ClP_H = CO_findrk("H2,HCl+=>H2Cl+,H")*findspecies("HCl+")->hevmol;
2874  co.H3P_Cl_HClP_H2 = CO_findrk("H3+,Cl=>HCl+,H2")*findspecies("Cl")->hevmol;
2875  co.H3P_HCl_H2ClP_H2 = CO_findrk("H3+,HCl=>H2Cl+,H2")*findspecies("HCl")->hevmol;
2876  co.HP_HCl_HClP_H = CO_findrk("H+,HCl=>HCl+,H")*findspecies("HCl")->hevmol;
2877  /* >>chng 06 feb 06 rjrw -- was multiplied by HS not S */
2878  co.H2_S_HS_H = CO_findrk("H2,S=>HS,H")*findspecies("S")->hevmol;
2879  /* >>chng 05 sept 14 - NPA, add HNC and HCNH+ to hmole_step */
2880  co.HP_HNC_HCN_HP = CO_findrk("H+,HNC=>HCN,H+")*findspecies("HNC")->hevmol;
2881  co.H_HNC_HCN_H = CO_findrk("H,HNC=>HCN,H")*findspecies("HNC")->hevmol;
2882  /* >>chng 06 feb 06 rjrw -- was duplicated */
2883  /* co.H_HNC_HCN_H = CO_findrk("H,HNC=>HCN,H")*findspecies("HNC")->hevmol; */
2884  co.H2_HCNP_HCNHP_H = CO_findrk("H2,HCN+=>HCNH+,H")*findspecies("HCN+")->hevmol;
2885  /* >>chng 06 Sep 03 rjrw HNC -> HCN in COmole index for consistency */
2886  co.H3P_HCN_HCNHP_H2 = CO_findrk("H3+,HCN=>HCNH+,H2")*findspecies("HCN")->hevmol;
2887  /* >>chng 05 nov 17, TE added following reaction, the same rate as H2g is assumed*/
2888  co.H2s_OP_OHP_H = CO_findrk("H2*,O+=>OH+,H")*findspecies("O+")->hevmol;
2889 
2890 
2891 
2892  /* >>chng 05 dec 01 - NPA. Add reactions of C3, C3+, C2H, C2H+, C3H, C3H+, C2H2,
2893  * C2H2+, and C2H3+ with hydrogen molecules to the overall balance */
2894  co.HP_C2H2_C2H2P_H = CO_findrk("H+,C2H2=>C2H2+,H")*findspecies("C2H2")->hevmol;
2895  co.HP_C2H2_C2HP_H2 = CO_findrk("H+,C2H2=>C2H+,H2")*findspecies("C2H2")->hevmol;
2896  co.HP_C3H_C3HP_H = CO_findrk("H+,C3H=>C3H+,H")*findspecies("C3H")->hevmol;
2897  co.HP_C3H_C3P_H2 = CO_findrk("H+,C3H=>C3+,H2")*findspecies("C3H")->hevmol;
2898  co.H2P_C2H_C2H2P_H = CO_findrk("H2+,C2H=>C2H2+,H")*findspecies("C2H")->hevmol;
2899  co.H2P_C2H2_C2H2P_H2 = CO_findrk("H2+,C2H2=>C2H2+,H2")*findspecies("C2H2")->hevmol;
2900  co.H3P_C2H_C2H2P_H2 = CO_findrk("H3+,C2H=>C2H2+,H2")*findspecies("C2H")->hevmol;
2901  co.H3P_C3_C3HP_H2 = CO_findrk("H3+,C3=>C3H+,H2")*findspecies("C3")->hevmol;
2902  co.H2_C2HP_C2H2P_H = CO_findrk("H2,C2H+=>C2H2+,H")*findspecies("C2H+")->hevmol;
2903  co.H2_C3P_C3HP_H = CO_findrk("H2,C3+=>C3H+,H")*findspecies("C3+")->hevmol;
2904  co.H_C2H3P_C2H2P_H2 = CO_findrk("H,C2H3+=>C2H2+,H2")*findspecies("C2H3+")->hevmol;
2905  co.H3P_C2H2_C2H3P_H2 = CO_findrk("H3+,C2H2=>C2H3+,H2")*findspecies("C2H2")->hevmol;
2906  co.H2P_C2H2_C2H3P_H = CO_findrk("H2+,C2H2=>C2H3+,H")*findspecies("C2H2")->hevmol;
2907  co.HP_C3_C3P_H = CO_findrk("H+,C3=>C3+,H")*findspecies("C3")->hevmol;
2908  co.HP_C2H_C2HP_H = CO_findrk("H+,C2H=>C2H+,H")*findspecies("C2H")->hevmol;
2909  co.H2P_C2_C2HP_H = CO_findrk("H2+,C2=>C2H+,H")*findspecies("C2")->hevmol;
2910  co.H2P_C2H_C2HP_H2 = CO_findrk("H2+,C2H=>C2H+,H2")*findspecies("C2H")->hevmol;
2911  co.H3P_C2_C2HP_H2 = CO_findrk("H3+,C2=>C2H+,H2")*findspecies("C2")->hevmol;
2912  co.H2_C2P_C2HP_H = CO_findrk("H2,C2+=>C2H+,H")*findspecies("C2+")->hevmol;
2913  co.HP_C2H_C2P_H2 = CO_findrk("H+,C2H=>C2+,H2")*findspecies("C2H")->hevmol;
2914  /* >>chng 13 Apr 2006, Add N2H+ to chemistry, which
2915  * should improve modeling of nitrogen chemistry, in
2916  * particular NH and N2 */
2917  co.N2_H3P_N2HP_H2 = CO_findrk("N2,H3+=>N2H+,H2")*findspecies("N2")->hevmol;
2918  if(r->next == NULL)
2919  {
2920  int in[]={ipMH},out[]={ipMH,ipMH};
2921  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2922  }
2923  r = r->next;
2924  rindex++;
2925  r->rk = co.H_CH_C_H_H;
2926 
2927  if(r->next == NULL)
2928  {
2929  int in[]={ipMH},out[]={ipMH,ipMH};
2930  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2931  }
2932  r = r->next;
2933  rindex++;
2934  r->rk =co.H_OH_O_H_H;
2935 
2936  if(r->next == NULL)
2937  {
2938  int in[]={ipMH},out[]={ipMH,ipMH};
2939  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2940  }
2941  r = r->next;
2942  rindex++;
2943  r->rk =co.H_H2O_OH_H_H;
2944 
2945  if(r->next == NULL)
2946  {
2947  int in[]={ipMH},out[]={ipMHp};
2948  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2949  }
2950  r = r->next;
2951  rindex++;
2952  r->rk =co.H_COP_CO_HP;
2953 
2954  if(r->next == NULL)
2955  {
2956  int in[]={ipMH},out[]={ipMH2g};
2957  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2958  }
2959  r = r->next;
2960  rindex++;
2961  r->rk =co.H_CH_C_H2;
2962 
2963  if(r->next == NULL)
2964  {
2965  int in[]={ipMH},out[]={ipMH2g};
2966  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2967  }
2968  r = r->next;
2969  rindex++;
2970  r->rk =co.H_CHP_CP_H2;
2971 
2972  if(r->next == NULL)
2973  {
2974  int in[]={ipMH},out[]={ipMH2g};
2975  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2976  }
2977  r = r->next;
2978  rindex++;
2979  r->rk =co.H_CH2_CH_H2;
2980 
2981  if(r->next == NULL)
2982  {
2983  int in[]={ipMH},out[]={ipMH2g};
2984  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2985  }
2986  r = r->next;
2987  rindex++;
2988  r->rk =co.H_CH3P_CH2P_H2;
2989 
2990  if(r->next == NULL)
2991  {
2992  int in[]={ipMH},out[]={ipMH2g};
2993  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
2994  }
2995  r = r->next;
2996  rindex++;
2997  r->rk =co.H_OH_O_H2;
2998 
2999  if(r->next == NULL)
3000  {
3001  int in[]={ipMH},out[]={ipMH2g};
3002  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3003  }
3004  r = r->next;
3005  rindex++;
3006  r->rk =co.H_H2O_OH_H2;
3007 
3008 
3009  if(r->next == NULL)
3010  {
3011  int in[]={ipMHm},out[]={ipMH2g};
3012  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3013  }
3014  r = r->next;
3015  rindex++;
3016  r->rk =co.Hminus_HCOP_CO_H2;
3017 
3018  if(r->next == NULL)
3019  {
3020  int in[]={ipMHm},out[]={ipMH2g};
3021  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3022  }
3023  r = r->next;
3024  rindex++;
3025  r->rk =co.Hminus_H3OP_H2O_H2;
3026 
3027  if(r->next == NULL)
3028  {
3029  int in[]={ipMHm},out[]={ipMH2g, ipMH};
3030  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3031  }
3032  r = r->next;
3033  rindex++;
3035 
3036  if(r->next == NULL)
3037  {
3038  int in[]={ipMHp},out[]={ipMH};
3039  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3040  }
3041  r = r->next;
3042  rindex++;
3043  r->rk =co.HP_CH_CHP_H;
3044 
3045  if(r->next == NULL)
3046  {
3047  int in[]={ipMHp},out[]={ipMH};
3048  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3049  }
3050  r = r->next;
3051  rindex++;
3052  r->rk =co.HP_CH2_CH2P_H;
3053 
3054  if(r->next == NULL)
3055  {
3056  int in[]={ipMHp},out[]={ipMH};
3057  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3058  }
3059  r = r->next;
3060  rindex++;
3061  r->rk =co.HP_H2O_H2OP_H;
3062 
3063  if(r->next == NULL)
3064  {
3065  int in[]={ipMHp},out[]={ipMH};
3066  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3067  }
3068  r = r->next;
3069  rindex++;
3070  r->rk =co.HP_O2_O2P_H;
3071 
3072  if(r->next == NULL)
3073  {
3074  int in[]={ipMHp},out[]={ipMH};
3075  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3076  }
3077  r = r->next;
3078  rindex++;
3079  r->rk =co.HP_OH_OHP_H;
3080 
3081  if(r->next == NULL)
3082  {
3083  int in[]={ipMHp},out[]={ipMH};
3084  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3085  }
3086  r = r->next;
3087  rindex++;
3088  r->rk =co.HP_SiO_SiOP_H;
3089 
3090  if(r->next == NULL)
3091  {
3092  int in[]={ipMHp},out[]={ipMH2g};
3093  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3094  }
3095  r = r->next;
3096  rindex++;
3097  r->rk =co.HP_CH2_CHP_H2;
3098 
3099  if(r->next == NULL)
3100  {
3101  int in[]={ipMHp},out[]={ipMH2g};
3102  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3103  }
3104  r = r->next;
3105  rindex++;
3106  r->rk =co.HP_SiH_SiP_H2;
3107 
3108  if(r->next == NULL)
3109  {
3110  int in[]={ipMH2g},out[]={ipMH};
3111  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3112  }
3113  r = r->next;
3114  rindex++;
3115  r->rk =co.H2_CHP_CH2P_H;
3116 
3117  if(r->next == NULL)
3118  {
3119  int in[]={ipMH2g},out[]={ipMH};
3120  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3121  }
3122  r = r->next;
3123  rindex++;
3124  r->rk =co.H2_CH2P_CH3P_H;
3125 
3126  if(r->next == NULL)
3127  {
3128  int in[]={ipMH2g},out[]={ipMH};
3129  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3130  }
3131  r = r->next;
3132  rindex++;
3133  r->rk =co.H2_OHP_H2OP_H;
3134 
3135  if(r->next == NULL)
3136  {
3137  int in[]={ipMH2g},out[]={ipMH};
3138  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3139  }
3140  r = r->next;
3141  rindex++;
3142  r->rk =co.H2_H2OP_H3OP_H;
3143 
3144  if(r->next == NULL)
3145  {
3146  int in[]={ipMH2g},out[]={ipMH};
3147  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3148  }
3149  r = r->next;
3150  rindex++;
3151  r->rk =co.H2_COP_HCOP_H;
3152 
3153  if(r->next == NULL)
3154  {
3155  int in[]={ipMH2g},out[]={ipMH};
3156  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3157  }
3158  r = r->next;
3159  rindex++;
3160  r->rk =co.H2_OP_OHP_H;
3161 
3162  if(r->next == NULL)
3163  {
3164  int in[]={ipMH2g},out[]={ipMH};
3165  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3166  }
3167  r = r->next;
3168  rindex++;
3169  r->rk =co.H2_SiOP_SiOHP_H;
3170 
3171  if(r->next == NULL)
3172  {
3173  int in[]={ipMH2g},out[]={ipMH};
3174  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3175  }
3176  r = r->next;
3177  rindex++;
3178  r->rk =co.H2_C_CH_H;
3179 
3180  if(r->next == NULL)
3181  {
3182  int in[]={ipMH2g},out[]={ipMH};
3183  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3184  }
3185  r = r->next;
3186  rindex++;
3187  r->rk =co.H2_CP_CHP_H;
3188 
3189  if(r->next == NULL)
3190  {
3191  int in[]={ipMH2g},out[]={ipMH};
3192  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3193  }
3194  r = r->next;
3195  rindex++;
3196  r->rk =co.H2_CH_CH2_H;
3197 
3198  if(r->next == NULL)
3199  {
3200  int in[]={ipMH2g},out[]={ipMH};
3201  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3202  }
3203  r = r->next;
3204  rindex++;
3205  r->rk =co.H2_OH_H2O_H;
3206 
3207  if(r->next == NULL)
3208  {
3209  int in[]={ipMH2g},out[]={ipMH};
3210  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3211  }
3212  r = r->next;
3213  rindex++;
3214  r->rk =co.H2_O_OH_H;
3215 
3216  if(r->next == NULL)
3217  {
3218  int in[]={ipMH2g},out[]={ipMH2g,ipMH};
3219  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3220  }
3221  r = r->next;
3222  rindex++;
3223  r->rk =co.H2_CH_C_H2_H;
3224 
3225  if(r->next == NULL)
3226  {
3227  int in[]={ipMH2g},out[]={ipMH2g, ipMH};
3228  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3229  }
3230  r = r->next;
3231  rindex++;
3232  r->rk =co.H2_OH_O_H2_H;
3233 
3234  if(r->next == NULL)
3235  {
3236  int in[]={ipMH2g},out[]={ipMH2g, ipMH};
3237  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3238  }
3239  r = r->next;
3240  rindex++;
3241  r->rk =co.H2_H2O_OH_H2_H;
3242 
3243  if(r->next == NULL)
3244  {
3245  int in[]={ipMH2g},out[]={ipMH2g};
3246  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3247  }
3248  r = r->next;
3249  rindex++;
3250  r->rk =co.H2_O2_O_O_H2;
3251 
3252  /* >>chng 05 mar 18, by TE, this was in twice, had little effect since high
3253  * temperature barrier */
3254  /*if(r->next == NULL)
3255  {
3256  int in[]={ipMH2g},out[]={ipMH};
3257  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3258  }
3259  r = r->next;
3260  rindex++;
3261  r->rk =co.H2_C_CH_H;*/
3262 
3263  if(r->next == NULL)
3264  {
3265  int in[]={ipMH2s},out[]={ipMH2g,ipMH};
3266  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3267  }
3268  r = r->next;
3269  rindex++;
3270  r->rk =co.H2s_CH_C_H2_H;
3271 
3272  if(r->next == NULL)
3273  {
3274  int in[]={ipMH2s},out[]={ipMH2g,ipMH};
3275  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3276  }
3277  r = r->next;
3278  rindex++;
3279  r->rk =co.H2s_OH_O_H2_H;
3280 
3281  if(r->next == NULL)
3282  {
3283  int in[]={ipMH2s},out[]={ipMH2g,ipMH};
3284  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3285  }
3286  r = r->next;
3287  rindex++;
3288  r->rk =co.H2s_H2O_OH_H2_H;
3289 
3290  if(r->next == NULL)
3291  {
3292  int in[]={ipMH2s},out[]={ipMH2g};
3293  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3294  }
3295  r = r->next;
3296  rindex++;
3297  r->rk =co.H2s_O2_O_O_H2;
3298 
3299  if(r->next == NULL)
3300  {
3301  int in[]={ipMH2p},out[]={ipMH};
3302  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3303  }
3304  r = r->next;
3305  rindex++;
3306  r->rk =co.H2P_C_CHP_H;
3307 
3308  if(r->next == NULL)
3309  {
3310  int in[]={ipMH2p},out[]={ipMH};
3311  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3312  }
3313  r = r->next;
3314  rindex++;
3315  r->rk =co.H2P_CH_CH2P_H;
3316 
3317  if(r->next == NULL) {
3318  int in[]={ipMH2p},out[]={ipMH};
3319  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3320  }
3321  r = r->next;
3322  rindex++;
3323  r->rk =co.H2P_CH2_CH3P_H;
3324 
3325  if(r->next == NULL) {
3326  int in[]={ipMH2p},out[]={ipMH};
3327  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3328  }
3329  r = r->next;
3330  rindex++;
3331  r->rk =co.H2P_OH_H2OP_H;
3332 
3333  if(r->next == NULL) {
3334  int in[]={ipMH2p},out[]={ipMH};
3335  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3336  }
3337  r = r->next;
3338  rindex++;
3339  r->rk =co.H2P_H2O_H3OP_H;
3340 
3341  if(r->next == NULL) {
3342  int in[]={ipMH2p},out[]={ipMH};
3343  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3344  }
3345  r = r->next;
3346  rindex++;
3347  r->rk =co.H2P_CO_HCOP_H;
3348 
3349  if(r->next == NULL) {
3350  int in[]={ipMH2p},out[]={ipMH};
3351  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3352  }
3353  r = r->next;
3354  rindex++;
3355  r->rk =co.H2P_O_OHP_H;
3356 
3357  if(r->next == NULL) {
3358  int in[]={ipMH2p},out[]={ipMH2g};
3359  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3360  }
3361  r = r->next;
3362  rindex++;
3363  r->rk =co.H2P_CH_CHP_H2;
3364 
3365  if(r->next == NULL) {
3366  int in[]={ipMH2p},out[]={ipMH2g};
3367  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3368  }
3369  r = r->next;
3370  rindex++;
3371  r->rk =co.H2P_CH2_CH2P_H2;
3372 
3373  if(r->next == NULL) {
3374  int in[]={ipMH2p},out[]={ipMH2g};
3375  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3376  }
3377  r = r->next;
3378  rindex++;
3379  r->rk =co.H2P_CO_COP_H2;
3380 
3381  if(r->next == NULL) {
3382  int in[]={ipMH2p},out[]={ipMH2g};
3383  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3384  }
3385  r = r->next;
3386  rindex++;
3387  r->rk =co.H2P_H2O_H2OP_H2;
3388 
3389  if(r->next == NULL) {
3390  int in[]={ipMH2p},out[]={ipMH2g};
3391  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3392  }
3393  r = r->next;
3394  rindex++;
3395  r->rk =co.H2P_O2_O2P_H2;
3396 
3397  if(r->next == NULL) {
3398  int in[]={ipMH2p},out[]={ipMH2g};
3399  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3400  }
3401  r = r->next;
3402  rindex++;
3403  r->rk =co.H2P_OH_OHP_H2;
3404 
3405  if(r->next == NULL) {
3406  int in[]={ipMH3p},out[]={ipMH2g};
3407  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3408  }
3409  r = r->next;
3410  rindex++;
3411  r->rk =co.H3P_C_CHP_H2;
3412 
3413  if(r->next == NULL) {
3414  int in[]={ipMH3p},out[]={ipMH2g};
3415  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3416  }
3417  r = r->next;
3418  rindex++;
3419  r->rk =co.H3P_CH_CH2P_H2;
3420 
3421  if(r->next == NULL) {
3422  int in[]={ipMH3p},out[]={ipMH2g};
3423  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3424  }
3425  r = r->next;
3426  rindex++;
3427  r->rk =co.H3P_CH2_CH3P_H2;
3428 
3429  if(r->next == NULL) {
3430  int in[]={ipMH3p},out[]={ipMH2g};
3431  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3432  }
3433  r = r->next;
3434  rindex++;
3435  r->rk =co.H3P_OH_H2OP_H2;
3436 
3437  if(r->next == NULL) {
3438  int in[]={ipMH3p},out[]={ipMH2g};
3439  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3440  }
3441  r = r->next;
3442  rindex++;
3443  r->rk =co.H3P_H2O_H3OP_H2;
3444 
3445  if(r->next == NULL) {
3446  int in[]={ipMH3p},out[]={ipMH2g};
3447  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3448  }
3449  r = r->next;
3450  rindex++;
3451  r->rk =co.H3P_CO_HCOP_H2;
3452 
3453  if(r->next == NULL)
3454  {
3455  int in[]={ipMH3p},out[]={ipMH2g};
3456  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3457  }
3458  r = r->next;
3459  rindex++;
3460  r->rk =co.H3P_O_OHP_H2;
3461 
3462  if(r->next == NULL)
3463  {
3464  int in[]={ipMH3p},out[]={ipMH2g};
3465  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3466  }
3467  r = r->next;
3468  rindex++;
3469  r->rk =co.H3P_SiH_SiH2P_H2;
3470 
3471  if(r->next == NULL) {
3472  int in[]={ipMH3p},out[]={ipMH2g};
3473  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3474  }
3475  r = r->next;
3476  rindex++;
3477  r->rk =co.H3P_SiO_SiOHP_H2;
3478 
3479  if(r->next == NULL)
3480  {
3481  int in[]={ipMH2s},out[]={ipMH};
3482  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3483  }
3484  r = r->next;
3485  rindex++;
3486  r->rk =co.H2s_CH_CH2_H;
3487 
3488  if(r->next == NULL)
3489  {
3490  int in[]={ipMH2s},out[]={ipMH};
3491  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3492  }
3493  r = r->next;
3494  rindex++;
3495  r->rk =co.H2s_O_OH_H;
3496 
3497  if(r->next == NULL)
3498  {
3499  int in[]={ipMH2s},out[]={ipMH};
3500  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3501  }
3502  r = r->next;
3503  rindex++;
3504  r->rk =co.H2s_OH_H2O_H;
3505 
3506 
3507  if(r->next == NULL)
3508  {
3509  int in[]={ipMH2s},out[]={ipMH};
3510  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3511  }
3512  r = r->next;
3513  rindex++;
3514  r->rk =co.H2s_C_CH_H;
3515 
3516  if(r->next == NULL)
3517  {
3518  int in[]={ipMH2s},out[]={ipMH};
3519  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3520  }
3521  r = r->next;
3522  rindex++;
3523  r->rk =co.H2s_CP_CHP_H;
3524 
3525  if(r->next == NULL)
3526  {
3527  int in[]={ipMH},out[]={ipMH2g};
3528  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3529  }
3530  r = r->next;
3531  rindex++;
3532  r->rk =co.H_CH3_CH2_H2;
3533 
3534  if(r->next == NULL)
3535  {
3536  int in[]={ipMH},out[]={ipMH2g};
3537  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3538  }
3539  r = r->next;
3540  rindex++;
3541  r->rk =co.H_CH4P_CH3P_H2;
3542 
3543  if(r->next == NULL)
3544  {
3545  int in[]={ipMH},out[]={ipMH2g};
3546  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3547  }
3548  r = r->next;
3549  rindex++;
3550  r->rk =co.H_CH5P_CH4P_H2;
3551 
3552  if(r->next == NULL)
3553  {
3554  int in[]={ipMH2g},out[]={ipMH};
3555  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3556  }
3557  r = r->next;
3558  rindex++;
3559  r->rk =co.H2_CH2_CH3_H;
3560 
3561 
3562  if(r->next == NULL)
3563  {
3564  int in[]={ipMH2g},out[]={ipMH};
3565  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3566  }
3567  r = r->next;
3568  rindex++;
3569  r->rk = co.H2_CH3_CH4_H;
3570 
3571  if(r->next == NULL)
3572  {
3573  int in[]={ipMH2g},out[]={ipMH};
3574  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3575  }
3576  r = r->next;
3577  rindex++;
3578  r->rk = co.H2_CH4P_CH5P_H;
3579 
3580  if(r->next == NULL)
3581  {
3582  int in[]={ipMH2s},out[]={ipMH};
3583  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3584  }
3585  r = r->next;
3586  rindex++;
3587  r->rk =co.H2s_CH2_CH3_H;
3588 
3589  if(r->next == NULL)
3590  {
3591  int in[]={ipMH2s},out[]={ipMH};
3592  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3593  }
3594  r = r->next;
3595  rindex++;
3596  r->rk = co.H2s_CH3_CH4_H;
3597 
3598  if(r->next == NULL)
3599  {
3600  int in[]={ipMH2p},out[]={ipMH2g};
3601  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3602  }
3603  r = r->next;
3604  rindex++;
3605  r->rk = co.H2P_CH4_CH3P_H2;
3606 
3607  if(r->next == NULL)
3608  {
3609  int in[]={ipMH2p},out[]={ipMH2g};
3610  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3611  }
3612  r = r->next;
3613  rindex++;
3614  r->rk = co.H2P_CH4_CH4P_H2;
3615 
3616  if(r->next == NULL)
3617  {
3618  int in[]={ipMH2p},out[]={ipMH};
3619  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3620  }
3621  r = r->next;
3622  rindex++;
3623  r->rk = co.H2P_CH4_CH5P_H;
3624 
3625  if(r->next == NULL)
3626  {
3627  int in[]={ipMH3p},out[]={ipMH2g};
3628  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3629  }
3630  r = r->next;
3631  rindex++;
3632  r->rk = co.H3P_CH3_CH4P_H2;
3633 
3634  if(r->next == NULL)
3635  {
3636  int in[]={ipMH3p},out[]={ipMH2g};
3637  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3638  }
3639  r = r->next;
3640  rindex++;
3641  r->rk = co.H3P_CH4_CH5P_H2;
3642 
3643  if(r->next == NULL) {
3644  int in[]={ipMHp},out[]={ipMH2g};
3645  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3646  }
3647  r = r->next;
3648  rindex++;
3649  r->rk = co.HP_CH4_CH3P_H2;
3650 
3651  if(r->next == NULL) {
3652  int in[]={ipMHp},out[]={ipMH};
3653  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3654  }
3655  r = r->next;
3656  rindex++;
3657  r->rk = co.HP_CH4_CH4P_H;
3658 
3659  if(r->next == NULL) {
3660  int in[]={ipMH2g},out[]={ipMH};
3661  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3662  }
3663  r = r->next;
3664  rindex++;
3665  r->rk = co.H2_ClP_HClP_H;
3666 
3667  if(r->next == NULL) {
3668  int in[]={ipMH2g},out[]={ipMH};
3669  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3670  }
3671  r = r->next;
3672  rindex++;
3673  r->rk = co.H2_HClP_H2ClP_H;
3674 
3675  if(r->next == NULL) {
3676  int in[]={ipMH3p},out[]={ipMH2g};
3677  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3678  }
3679  r = r->next;
3680  rindex++;
3681  r->rk = co.H3P_Cl_HClP_H2;
3682 
3683  if(r->next == NULL) {
3684  int in[]={ipMH3p},out[]={ipMH2g};
3685  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3686  }
3687  r = r->next;
3688  rindex++;
3689  r->rk = co.H3P_HCl_H2ClP_H2;
3690 
3691  if(r->next == NULL) {
3692  int in[]={ipMHp},out[]={ipMH};
3693  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3694  }
3695  r = r->next;
3696  rindex++;
3697  r->rk = co.HP_HCl_HClP_H;
3698  /* >>chng 05 aug 02, NA add following reaction */
3699 
3700  if(r->next == NULL) {
3701  int in[]={ipMH2g},out[]={ipMH};
3702  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3703  }
3704  r = r->next;
3705  rindex++;
3706  r->rk = co.H2_S_HS_H;
3707 
3708 
3709  /* The following terms are for the reactions with the rates defined above. The
3710  * actual reaction is self-contained in the rate label. */
3711 
3712  if(r->next == NULL)
3713  {
3714  int in[]={ipMH2g},out[]={ipMH};
3715  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3716  }
3717  r = r->next;
3718  rindex++;
3719  r->rk = co.H2_N_NH_H;
3720 
3721  if(r->next == NULL)
3722  {
3723  int in[]={ipMH2g},out[]={ipMH};
3724  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3725  }
3726  r = r->next;
3727  rindex++;
3728  r->rk = co.H2_NH_NH2_H;
3729 
3730 
3731  if(r->next == NULL)
3732  {
3733  int in[]={ipMH2g},out[]={ipMH};
3734  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3735  }
3736  r = r->next;
3737  rindex++;
3738  r->rk = co.H2_NH2_NH3_H;
3739 
3740  if(r->next == NULL)
3741  {
3742  int in[]={ipMH2g},out[]={ipMH};
3743  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3744  }
3745  r = r->next;
3746  rindex++;
3747  r->rk = co.H2_CN_HCN_H;
3748 
3749  if(r->next == NULL)
3750  {
3751  int in[]={ipMHp},out[]={ipMH2g};
3752  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3753  }
3754  r = r->next;
3755  rindex++;
3756  r->rk = co.HP_HNO_NOP_H2;
3757 
3758  if(r->next == NULL)
3759  {
3760  int in[]={ipMHp},out[]={ipMH2g};
3761  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3762  }
3763  r = r->next;
3764  rindex++;
3765  r->rk = co.HP_HS_SP_H2;
3766 
3767  if(r->next == NULL)
3768  {
3769  int in[]={ipMH},out[]={ipMH2g};
3770  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3771  }
3772  r = r->next;
3773  rindex++;
3774  r->rk = co.H_HSP_SP_H2;
3775 
3776  if(r->next == NULL)
3777  {
3778  int in[]={ipMH2p},out[]={ipMH};
3779  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3780  }
3781  r = r->next;
3782  rindex++;
3783  r->rk = co.H2P_N_NHP_H;
3784 
3785  if(r->next == NULL)
3786  {
3787  int in[]={ipMH2g},out[]={ipMH};
3788  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3789  }
3790  r = r->next;
3791  rindex++;
3792  r->rk = co.H2_NP_NHP_H;
3793 
3794  if(r->next == NULL)
3795  {
3796  int in[]={ipMH2g},out[]={ipMH3p};
3797  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3798  }
3799  r = r->next;
3800  rindex++;
3801  r->rk = co.H2_NHP_N_H3P;
3802 
3803  if(r->next == NULL)
3804  {
3805  int in[]={ipMH2p},out[]={ipMH};
3806  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3807  }
3808  r = r->next;
3809  rindex++;
3810  r->rk = co.H2P_NH_NH2P_H;
3811 
3812 
3813  if(r->next == NULL)
3814  {
3815  int in[]={ipMH2g},out[]={ipMH};
3816  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3817  }
3818  r = r->next;
3819  rindex++;
3820  r->rk = co.H2_NHP_NH2P_H;
3821 
3822  if(r->next == NULL)
3823  {
3824  int in[]={ipMH2g},out[]={ipMH};
3825  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3826  }
3827  r = r->next;
3828  rindex++;
3829  r->rk = co.H2_NH2P_NH3P_H;
3830 
3831  if(r->next == NULL)
3832  {
3833  int in[]={ipMH2g},out[]={ipMH};
3834  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3835  }
3836  r = r->next;
3837  rindex++;
3838  r->rk = co.H2_NH3P_NH4P_H;
3839 
3840  if(r->next == NULL)
3841  {
3842  int in[]={ipMH2p},out[]={ipMH};
3843  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3844  }
3845  r = r->next;
3846  rindex++;
3847  r->rk = co.H2P_CN_HCNP_H;
3848 
3849  if(r->next == NULL)
3850  {
3851  int in[]={ipMH2g},out[]={ipMH};
3852  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3853  }
3854  r = r->next;
3855  rindex++;
3856  r->rk = co.H2_CNP_HCNP_H;
3857 
3858  if(r->next == NULL)
3859  {
3860  int in[]={ipMH2p},out[]={ipMH};
3861  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3862  }
3863  r = r->next;
3864  rindex++;
3865  r->rk = co.H2P_NO_HNOP_H;
3866 
3867  if(r->next == NULL)
3868  {
3869  int in[]={ipMH2g},out[]={ipMH};
3870  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3871  }
3872  r = r->next;
3873  rindex++;
3874  r->rk = co.H2_SP_HSP_H;
3875 
3876  if(r->next == NULL)
3877  {
3878  int in[]={ipMH2g},out[]={ipMH};
3879  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3880  }
3881  r = r->next;
3882  rindex++;
3883  r->rk = co.H2_CSP_HCSP_H;
3884 
3885 
3886  if(r->next == NULL)
3887  {
3888  int in[]={ipMH3p},out[]={ipMH2g};
3889  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3890  }
3891  r = r->next;
3892  rindex++;
3893  r->rk = co.H3P_NH_NH2P_H2;
3894 
3895  if(r->next == NULL)
3896  {
3897  int in[]={ipMH3p},out[]={ipMH2g};
3898  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3899  }
3900  r = r->next;
3901  rindex++;
3902  r->rk = co.H3P_NH2_NH3P_H2;
3903 
3904  if(r->next == NULL)
3905  {
3906  int in[]={ipMH3p},out[]={ipMH2g};
3907  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3908  }
3909  r = r->next;
3910  rindex++;
3911  r->rk = co.H3P_NH3_NH4P_H2;
3912 
3913  if(r->next == NULL)
3914  {
3915  int in[]={ipMH3p},out[]={ipMH2g};
3916  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3917  }
3918  r = r->next;
3919  rindex++;
3920  r->rk = co.H3P_CN_HCNP_H2;
3921 
3922  if(r->next == NULL)
3923  {
3924  int in[]={ipMH3p},out[]={ipMH2g};
3925  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3926  }
3927  r = r->next;
3928  rindex++;
3929  r->rk = co.H3P_NO_HNOP_H2;
3930 
3931  if(r->next == NULL)
3932  {
3933  int in[]={ipMH3p},out[]={ipMH2g};
3934  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3935  }
3936  r = r->next;
3937  rindex++;
3938  r->rk = co.H3P_S_HSP_H2;
3939 
3940  if(r->next == NULL)
3941  {
3942  int in[]={ipMH3p},out[]={ipMH2g};
3943  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3944  }
3945  r = r->next;
3946  rindex++;
3947  r->rk = co.H3P_CS_HCSP_H2;
3948 
3949  if(r->next == NULL)
3950  {
3951  int in[]={ipMH3p},out[]={ipMH2g};
3952  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3953  }
3954  r = r->next;
3955  rindex++;
3956  r->rk = co.H3P_NO2_NOP_OH_H2;
3957 
3958  if(r->next == NULL)
3959  {
3960  int in[]={ipMHp},out[]={ipMH};
3961  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3962  }
3963  r = r->next;
3964  rindex++;
3965  r->rk = co.HP_NH_NHP_H;
3966 
3967  if(r->next == NULL)
3968  {
3969  int in[]={ipMHp},out[]={ipMH};
3970  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3971  }
3972  r = r->next;
3973  rindex++;
3974  r->rk = co.HP_NH2_NH2P_H;
3975 
3976  if(r->next == NULL)
3977  {
3978  int in[]={ipMHp},out[]={ipMH};
3979  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3980  }
3981  r = r->next;
3982  rindex++;
3983  r->rk = co.HP_NH3_NH3P_H;
3984 
3985 
3986  if(r->next == NULL)
3987  {
3988  int in[]={ipMH},out[]={ipMHp};
3989  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3990  }
3991  r = r->next;
3992  rindex++;
3993  r->rk = co.H_CNP_CN_HP;
3994 
3995  if(r->next == NULL)
3996  {
3997  int in[]={ipMHp},out[]={ipMH};
3998  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
3999  }
4000  r = r->next;
4001  rindex++;
4002  r->rk = co.HP_HCN_HCNP_H;
4003 
4004  if(r->next == NULL)
4005  {
4006  int in[]={ipMH},out[]={ipMHp};
4007  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4008  }
4009  r = r->next;
4010  rindex++;
4011  r->rk = co.H_HCNP_HCN_HP;
4012 
4013  if(r->next == NULL)
4014  {
4015  int in[]={ipMH},out[]={ipMHp};
4016  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4017  }
4018  r = r->next;
4019  rindex++;
4020  r->rk = co.H_N2P_N2_HP;
4021 
4022  if(r->next == NULL)
4023  {
4024  int in[]={ipMHp},out[]={ipMH};
4025  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4026  }
4027  r = r->next;
4028  rindex++;
4029  r->rk = co.HP_NO_NOP_H;
4030 
4031  if(r->next == NULL)
4032  {
4033  int in[]={ipMHp},out[]={ipMH};
4034  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4035  }
4036  r = r->next;
4037  rindex++;
4038  r->rk = co.HP_HS_HSP_H;
4039 
4040  if(r->next == NULL)
4041  {
4042  int in[]={ipMHp},out[]={ipMH};
4043  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4044  }
4045  r = r->next;
4046  rindex++;
4047  r->rk = co.HP_SiN_SiNP_H;
4048 
4049  if(r->next == NULL)
4050  {
4051  int in[]={ipMHp},out[]={ipMH};
4052  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4053  }
4054  r = r->next;
4055  rindex++;
4056  r->rk = co.HP_CS_CSP_H;
4057 
4058  if(r->next == NULL)
4059  {
4060  int in[]={ipMHp},out[]={ipMH};
4061  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4062  }
4063  r = r->next;
4064  rindex++;
4065  r->rk = co.HP_NS_NSP_H;
4066 
4067  if(r->next == NULL)
4068  {
4069  int in[]={ipMHp},out[]={ipMH};
4070  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4071  }
4072  r = r->next;
4073  rindex++;
4074  r->rk = co.HP_SO_SOP_H;
4075 
4076 
4077  if(r->next == NULL)
4078  {
4079  int in[]={ipMHp},out[]={ipMH};
4080  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4081  }
4082  r = r->next;
4083  rindex++;
4084  r->rk = co.HP_OCS_OCSP_H;
4085 
4086  if(r->next == NULL)
4087  {
4088  int in[]={ipMHp},out[]={ipMH};
4089  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4090  }
4091  r = r->next;
4092  rindex++;
4093  r->rk = co.HP_S2_S2P_H;
4094 
4095  if(r->next == NULL)
4096  {
4097  int in[]={ipMH2p},out[]={ipMH2g};
4098  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4099  }
4100  r = r->next;
4101  rindex++;
4102  r->rk = co.H2P_NH_NHP_H2;
4103 
4104  if(r->next == NULL)
4105  {
4106  int in[]={ipMH2p},out[]={ipMH2g};
4107  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4108  }
4109  r = r->next;
4110  rindex++;
4111  r->rk = co.H2P_NH2_NH2P_H2;
4112 
4113  if(r->next == NULL)
4114  {
4115  int in[]={ipMH2p},out[]={ipMH2g};
4116  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4117  }
4118  r = r->next;
4119  rindex++;
4120  r->rk = co.H2P_NH3_NH3P_H2;
4121 
4122  if(r->next == NULL)
4123  {
4124  int in[]={ipMH2p},out[]={ipMH2g};
4125  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4126  }
4127  r = r->next;
4128  rindex++;
4129  r->rk = co.H2P_CN_CNP_H2;
4130 
4131  if(r->next == NULL)
4132  {
4133  int in[]={ipMH2p},out[]={ipMH2g};
4134  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4135  }
4136  r = r->next;
4137  rindex++;
4138  r->rk = co.H2P_HCN_HCNP_H2;
4139 
4140  if(r->next == NULL)
4141  {
4142  int in[]={ipMH2p},out[]={ipMH2g};
4143  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4144  }
4145  r = r->next;
4146  rindex++;
4147  r->rk = co.H2P_NO_NOP_H2;
4148 
4149  if(r->next == NULL)
4150  {
4151  int in[]={ipMHp},out[]={ipMH};
4152  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4153  }
4154  r = r->next;
4155  rindex++;
4156  r->rk = co.HP_C2_C2P_H;
4157 
4158 
4159  if(r->next == NULL)
4160  {
4161  int in[]={ipMH2p},out[]={ipMH2g};
4162  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4163  }
4164  r = r->next;
4165  rindex++;
4166  r->rk = co.H2P_C2_C2P_H2;
4167 
4168  if(r->next == NULL)
4169  {
4170  int in[]={ipMHm},out[]={ipMH2g};
4171  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4172  }
4173  r = r->next;
4174  rindex++;
4175  r->rk = co.Hminus_NH4P_NH3_H2;
4176 
4177  if(r->next == NULL)
4178  {
4179  int in[]={ipMHm},out[]={ipMH};
4180  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4181  }
4182  r = r->next;
4183  rindex++;
4184  r->rk = co.Hminus_NP_N_H;
4185 
4186  /* >>chng 05 sept 14 - NPA. Reactions involving HNC or HCNH+ that affect hydrogen chemistry */
4187 
4188  if(r->next == NULL)
4189  {
4190  int in[]={ipMHp},out[]={ipMHp};
4191  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4192  }
4193  r = r->next;
4194  rindex++;
4195  r->rk = co.HP_HNC_HCN_HP;
4196 
4197  if(r->next == NULL)
4198  {
4199  int in[]={ipMH},out[]={ipMH};
4200  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4201  }
4202  r = r->next;
4203  rindex++;
4204  r->rk = co.H_HNC_HCN_H;
4205 
4206  /* >>chng 06 feb 06 rjrw -- was duplicated */
4207  /* if(r->next == NULL)
4208  {
4209  int in[]={ipMH},out[]={ipMH};
4210  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4211  }
4212  r = r->next;
4213  rindex++;
4214  r->rk = co.H_HNC_HCN_H; */
4215 
4216  if(r->next == NULL)
4217  {
4218  int in[]={ipMH2g},out[]={ipMH};
4219  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4220  }
4221  r = r->next;
4222  rindex++;
4223  r->rk = co.H2_HCNP_HCNHP_H;
4224 
4225  if(r->next == NULL)
4226  {
4227  int in[]={ipMH3p},out[]={ipMH2g};
4228  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4229  }
4230  r = r->next;
4231  rindex++;
4232  r->rk = co.H3P_HCN_HCNHP_H2;
4233 
4234  /* >>chng 05 nov 17, TE added following reaction*/
4235  if(r->next == NULL)
4236  {
4237  int in[]={ipMH2s},out[]={ipMH};
4238  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4239  }
4240  r = r->next;
4241  rindex++;
4242  r->rk =co.H2s_OP_OHP_H;
4243 
4244  /* >>chng 05 dec 01 - NPA. Add reactions for some more complex molecules
4245  * into the hydrogen chemistry */
4246  if(r->next == NULL)
4247  {
4248  int in[]={ipMHp},out[]={ipMH};
4249  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4250  }
4251  r = r->next;
4252  rindex++;
4253  r->rk = co.HP_C2H2_C2H2P_H;
4254 
4255  if(r->next == NULL)
4256  {
4257  int in[]={ipMHp},out[]={ipMH2g};
4258  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4259  }
4260  r = r->next;
4261  rindex++;
4262  r->rk = co.HP_C2H2_C2HP_H2;
4263 
4264  if(r->next == NULL)
4265  {
4266  int in[]={ipMHp},out[]={ipMH};
4267  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4268  }
4269  r = r->next;
4270  rindex++;
4271  r->rk = co.HP_C3H_C3HP_H;
4272 
4273  if(r->next == NULL)
4274  {
4275  int in[]={ipMHp},out[]={ipMH2g};
4276  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4277  }
4278  r = r->next;
4279  rindex++;
4280  r->rk =co.HP_C3H_C3P_H2;
4281 
4282  if(r->next == NULL)
4283  {
4284  int in[]={ipMH2p},out[]={ipMH};
4285  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4286  }
4287  r = r->next;
4288  rindex++;
4289  r->rk = co.H2P_C2H_C2H2P_H;
4290 
4291  if(r->next == NULL)
4292  {
4293  int in[]={ipMH2p},out[]={ipMH2g};
4294  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4295  }
4296  r = r->next;
4297  rindex++;
4298  r->rk = co.H2P_C2H2_C2H2P_H2;
4299 
4300  if(r->next == NULL)
4301  {
4302  int in[]={ipMH3p},out[]={ipMH2g};
4303  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4304  }
4305  r = r->next;
4306  rindex++;
4307  r->rk = co.H3P_C2H_C2H2P_H2;
4308 
4309  if(r->next == NULL)
4310  {
4311  int in[]={ipMH3p},out[]={ipMH2g};
4312  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4313  }
4314  r = r->next;
4315  rindex++;
4316  r->rk = co.H3P_C3_C3HP_H2;
4317 
4318  if(r->next == NULL)
4319  {
4320  int in[]={ipMH2g},out[]={ipMH};
4321  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4322  }
4323  r = r->next;
4324  rindex++;
4325  r->rk = co.H2_C2HP_C2H2P_H;
4326 
4327  if(r->next == NULL)
4328  {
4329  int in[]={ipMH2g},out[]={ipMH};
4330  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4331  }
4332  r = r->next;
4333  rindex++;
4334  r->rk = co.H2_C3P_C3HP_H;
4335 
4336  if(r->next == NULL)
4337  {
4338  int in[]={ipMH},out[]={ipMH2g};
4339  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4340  }
4341  r = r->next;
4342  rindex++;
4343  r->rk = co.H_C2H3P_C2H2P_H2;
4344 
4345  if(r->next == NULL)
4346  {
4347  int in[]={ipMH3p},out[]={ipMH2g};
4348  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4349  }
4350  r = r->next;
4351  rindex++;
4352  r->rk = co.H3P_C2H2_C2H3P_H2;
4353 
4354  if(r->next == NULL)
4355  {
4356  int in[]={ipMH2p},out[]={ipMH};
4357  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4358  }
4359  r = r->next;
4360  rindex++;
4361  r->rk = co.H2P_C2H2_C2H3P_H;
4362 
4363  if(r->next == NULL)
4364  {
4365  int in[]={ipMHp},out[]={ipMH};
4366  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4367  }
4368  r = r->next;
4369  rindex++;
4370  r->rk = co.HP_C3_C3P_H;
4371 
4372  if(r->next == NULL)
4373  {
4374  int in[]={ipMH2p},out[]={ipMH};
4375  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4376  }
4377  r = r->next;
4378  rindex++;
4379  r->rk = co.H2P_C2_C2HP_H;
4380 
4381  if(r->next == NULL)
4382  {
4383  int in[]={ipMH2p},out[]={ipMH2g};
4384  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4385  }
4386  r = r->next;
4387  rindex++;
4388  r->rk = co.H2P_C2H_C2HP_H2;
4389 
4390  if(r->next == NULL)
4391  {
4392  int in[]={ipMH3p},out[]={ipMH2g};
4393  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4394  }
4395  r = r->next;
4396  rindex++;
4397  r->rk = co.H3P_C2_C2HP_H2;
4398 
4399  if(r->next == NULL)
4400  {
4401  int in[]={ipMH2g},out[]={ipMH};
4402  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4403  }
4404  r = r->next;
4405  rindex++;
4406  r->rk = co.H2_C2P_C2HP_H;
4407 
4408  if(r->next == NULL)
4409  {
4410  int in[]={ipMHp},out[]={ipMH2g};
4411  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4412  }
4413  r = r->next;
4414  rindex++;
4415  r->rk = co.HP_C2H_C2P_H2;
4416 
4417 
4418  /* >>chng 13 Apr 2006, Add N2H+ to chemistry, which
4419  * should improve modeling of nitrogen chemistry, in
4420  * particular NH and N2 */
4421 
4422  if(r->next == NULL)
4423  {
4424  int in[]={ipMH3p},out[]={ipMH2g};
4425  r->next = newreaction(rindex,in,INTSZ(in),out,INTSZ(out),NULL,0);
4426  }
4427  r = r->next;
4428  rindex++;
4429  r->rk = co.N2_H3P_N2HP_H2;
4430  }
4431  else
4432  {
4433  fixit();/* rm macro set above to hose co chem */
4434  }
4435 
4436  /* >>chng 06 jun 30, these are not used anywhere else and should be removed from co header
4437  * this couples H and CO chem but was unstable. ignore their contribution to H
4438  * chemistry for now - OK because CO moles have little effect on H solution? */
4439 # if 0
4440  /* The following reactions in co.c include a formation or destruction
4441  process, but not both, for one of the molecules in mole_h_step.c.
4442  Because of this, the following rates have to be put into the bvec[i]
4443  part of the matrix. */
4444 
4445  /* Zero out the CO contribution to the sources and sinks in hmole */
4446 
4447 
4448  for(i=0; i<N_H_MOLEC; ++i)
4449  {
4450  co.hydro_source[i] = 0;
4451  co.hydro_sink[i] = 0;
4452  }
4453 
4454  /* C + H3OP = HCOP + H2 */
4455 
4456  co.C_H3OP_HCOP_H2_1 = HMRATE(1.0e-11,0,0)*findspecies("H3O+")->hevmol*findspecies("C")->hevmol;
4458 
4459 
4460  /* C + OH = CO + H */
4461 
4462  co.C_OH_CO_H_1 = HMRATE(1.1e-10,0.5,0)*findspecies("OH")->hevmol*findspecies("C")->hevmol;
4464 
4465  /* CP + OH => CO + HP */
4466 
4467  co.CP_OH_CO_HP_1 = HMRATE(7.7e-10,0,0)*findspecies("OH")->hevmol*findspecies("C+")->hevmol;
4469 
4470  /* CP + H2O => HCOP + H */
4471 
4472  co.CP_H2O_HCOP_H_1 = HMRATE(9.0e-10,0,0)*findspecies("H2O")->hevmol*findspecies("C+")->hevmol;
4474 
4475  /* CP + OH => COP + H */
4476 
4477  co.CP_OH_COP_H_1 = HMRATE(7.7e-10,0,0)*findspecies("OH")->hevmol*findspecies("C+")->hevmol;
4479 
4480  /* O + CH => CO + H */
4481 
4482  co.O_CH_CO_H_1 = HMRATE(6.6e-11,0,0)*findspecies("CH")->hevmol*findspecies("O")->hevmol;
4484 
4485  /* O + CHP => COP + H */
4486 
4487  co.O_CHP_COP_H_1 = HMRATE(3.5e-10,0,0)*findspecies("CH+")->hevmol*findspecies("O")->hevmol;
4489 
4490  /* O + CH2 => CO + H + H */
4491 
4492  co.O_CH2_CO_H_H_1 = HMRATE(1.33e-10,0,0)*findspecies("CH2")->hevmol*findspecies("O")->hevmol;
4494 
4495  /* O + CH2 => CO + H2 */
4496 
4497  co.O_CH2_CO_H2_1 = HMRATE(8.0e-11,0,0)*findspecies("CH2")->hevmol*findspecies("O")->hevmol;
4499 
4500  /* O + CH2P => HCOP + H */
4501 
4502  co.O_CH2P_HCOP_H_1 = HMRATE(7.5e-10,0,0)*findspecies("CH2+")->hevmol*findspecies("O")->hevmol;
4504 
4505  /* O + CH3P => HCOP + H2 */
4506 
4507  co.O_CH3P_HCOP_H2_1 = HMRATE(4.0e-10,0,0)*findspecies("CH3+")->hevmol*findspecies("O")->hevmol;
4509 
4510  /* O + H2OP => O2P + H2 */
4511 
4512  co.O_H2OP_O2P_H2_1 = HMRATE(4.0e-11,0,0)*findspecies("H2O+")->hevmol*findspecies("O")->hevmol;
4514 
4515  /* O + OH => O2 + H */
4516 
4517  co.O_OH_O2_H_1 = HMRATE(4.34e-11,-0.5,30)*findspecies("OH")->hevmol*findspecies("O")->hevmol;
4519 
4520  /* O + OHP => O2P + H */
4521 
4522  co.O_OHP_O2P_H_1 = HMRATE(7.1e-10,0,0)*findspecies("OH+")->hevmol*findspecies("O")->hevmol;
4524 
4525  /* O + SiH => SiO + H */
4526 
4527  co.O_SiH_SiO_H_1 = HMRATE(4.0e-11,0.5,0)*findspecies("SiH")->hevmol*findspecies("O")->hevmol;
4529 
4530  /* O + SiH2P => SiOHP + H */
4531 
4532  co.O_SiH2P_SiOHP_H_1 = HMRATE(6.3e-10,0,0)*findspecies("SiH2+")->hevmol*findspecies("O")->hevmol;
4534 
4535  /* OP + CH => COP + H */
4536 
4537  co.OP_CH_COP_H_1 = HMRATE(3.5e-10,0,0)*findspecies("CH")->hevmol*findspecies("O+")->hevmol;
4539 
4540  /* OP + OH => O2P + H */
4541 
4542  co.OP_OH_O2P_H_1 = HMRATE(3.6e-10,0,0)*findspecies("OH")->hevmol*findspecies("O+")->hevmol;
4544 
4545  /* Si + OH => SiO + H */
4546 
4547  co.Si_OH_SiO_H_1 = HMRATE(2.0e-10,0.5,0)*findspecies("OH")->hevmol*findspecies("Si")->hevmol;
4549 
4550  /* SiP + H2O => SiOHP + H */
4551 
4552  co.SiP_H2O_SiOHP_H_1 = HMRATE(2.3e-10,0,0)*findspecies("H2O")->hevmol*findspecies("Si+")->hevmol;
4554 
4555  /* SiP + OH => SiOP + H */
4556 
4557  co.SiP_OH_SiOP_H_1 = HMRATE(6.3e-10,0,0)*findspecies("OH")->hevmol*findspecies("Si+")->hevmol;
4559 
4560  /* CHP + H2O => HCOP + H2 */
4561 
4562  co.CHP_H2O_HCOP_H2_1 = HMRATE(2.9e-9,0,0)*findspecies("H2O")->hevmol*findspecies("CH+")->hevmol;
4564 
4565  /* CHP + OH => COP + H2 */
4566 
4567  co.CHP_OH_COP_H2_1 = HMRATE(7.5e-10,0,0)*findspecies("OH")->hevmol*findspecies("CH+")->hevmol;
4569 
4570  /* H + C => CH + nu */
4571 
4572  co.H_C_CH_nu = HMRATE(0.00000000000000001,0,0)*dense.xIonDense[ipHYDROGEN][0]*findspecies("C")->hevmol;
4574 
4575  /* H + CP => CHP + nu */
4576 
4577  co.H_CP_CHP_nu = HMRATE(1.7e-17,0,0)*findspecies("C+")->hevmol*dense.xIonDense[ipHYDROGEN][0];
4579 
4580  /* H + OH => H2O + nu */
4581 
4582  co.H_OH_H2O_nu = HMRATE(5.26E-18,-5.22,90)*findspecies("OH")->hevmol*dense.xIonDense[ipHYDROGEN][0];
4584 
4585  /* Hminus + CH => CH2 + e */
4586 
4587  co.Hminus_CH_CH2_e = HMRATE(1.0e-10,0,0)*findspecies("CH")->hevmol*hmi.Hmolec[ipMHm];
4589 
4590  /* Hminus + C => CH + e */
4591 
4592  co.Hminus_C_CH_e = HMRATE(1.0e-9,0,0)*findspecies("C")->hevmol*hmi.Hmolec[ipMHm];
4594 
4595  /* Hminus + OH => H2O + e */
4596 
4597  co.Hminus_OH_H2O_e = HMRATE(1.0e-10,0,0)*findspecies("OH")->hevmol*hmi.Hmolec[ipMHm];
4599 
4600  /* Hminus + O => OH + e */
4601 
4602  co.Hminus_O_OH_e = HMRATE(1.0e-9,0,0)*findspecies("O")->hevmol*hmi.Hmolec[ipMHm];
4604 
4605  /* H2 + C => CH2 + nu */
4606 
4607  co.H2_C_CH2_nu = HMRATE(1.0e-17,0,0)*findspecies("C")->hevmol*hmi.Hmolec[ipMH2g];
4609 
4610  /* H2 + CP => CH2P + nu */
4611 
4612  co.H2_CP_CH2P_nu = HMRATE(4.0e-16,-0.2,0)*findspecies("C+")->hevmol*hmi.Hmolec[ipMH2g];
4614 
4615  /* H2 + SiP => SiH2P + nu */
4616 
4617  co.H2_SiP_SiH2P_nu = HMRATE(3.0e-18,0,0)*findspecies("Si+")->hevmol*hmi.Hmolec[ipMH2g];
4619 
4620  /* H2 + O2 => OH + OH */
4621 
4622  co.H2_O2_OH_OH = HMRATE(3.16e-10,0,21890)*findspecies("O2")->hevmol*hmi.Hmolec[ipMH2g];
4624 
4625  /* HeP + CH => CP + He + H */
4626 
4627  co.HeP_CH_CP_He_H = HMRATE(1.1e-9,0,0)*findspecies("CH")->hevmol*dense.xIonDense[ipHELIUM][1];
4629 
4630  /* HeP + CH2 => CHP + He + H */
4631 
4632  co.HeP_CH2_CHP_He_H = HMRATE(7.5e-10,0,0)*findspecies("CH2")->hevmol*dense.xIonDense[ipHELIUM][1];
4634 
4635  /* HeP + OH => OP + He + H */
4636 
4637  co.HeP_OH_OP_He_H = HMRATE(1.1e-9,0,0)*findspecies("OH")->hevmol*dense.xIonDense[ipHELIUM][1];
4639 
4640  /* HeP + H2O OHP + He + H */
4641 
4642  co.HeP_H2O_OHP_He_H = HMRATE(2.86e-10,0,0)*findspecies("H2O")->hevmol*dense.xIonDense[ipHELIUM][1];
4644 
4645  /* HeP + SiH => SiP + He + H */
4646 
4647  co.HeP_SiH_SiP_He_H = HMRATE(1.8e-9,0,0)*findspecies("SiH")->hevmol*dense.xIonDense[ipHELIUM][1];
4649 
4650  /* HeP + H2O => OH + He + HP */
4651 
4652  co.HeP_H2O_OH_He_HP = HMRATE(2.04e-10,0,0)*findspecies("H2O")->hevmol*dense.xIonDense[ipHELIUM][1];
4654 
4655  /* HeP + CH2 => CP + He + H2 */
4656 
4657  co.HeP_CH2_CP_He_H2 = HMRATE(7.5e-10,0,0)*findspecies("CH2")->hevmol*dense.xIonDense[ipHELIUM][1];
4659 
4660  /* crnu + CH => C + H */
4661 
4662  co.crnu_CH_C_H = findspecies("CH")->hevmol*secondaries.csupra[ipHYDROGEN ][0] * 2. * 756;
4664 
4665  /* crnu + CHP => CP + H */
4666 
4667  co.crnu_CHP_CP_H = findspecies("CH+")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. * 183;
4669 
4670  /* crnu + H2O => OH + H */
4671 
4672  co.crnu_H2O_OH_H = findspecies("H2O")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. * 979;
4674 
4675  /* crnu + OH => O + H */
4676 
4677  co.crnu_OH_O_H = findspecies("OH")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. *522;
4679 
4680  /* crnu + SiH => Si + H */
4681 
4682  co.crnu_SiH_Si_H = findspecies("SiH")->hevmol*secondaries.csupra[ipHYDROGEN][0] * 2. *500;
4684 
4685  /* nu + CH => C + H */
4686 
4689 
4690  /* nu + CHP => CP + H */
4691 
4694 
4695  /* nu + CH2 => CH + H */
4696 
4697  co.nu_CH2_CH_H = HMRATE(7.2e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("CH2")->hevmol;
4699 
4700  /* nu + CH2P => CHP + H */
4701 
4704 
4705  /* nu + CH3P => CH2P + H */
4706 
4709 
4710  /* nu + CH3P => CHP + H2 */
4711 
4714 
4715  /* nu + H2O => OH + H */
4716 
4717  co.nu_H2O_OH_H = HMRATE(5.9e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("H2O")->hevmol;
4719 
4720  /* nu + OH => O + H */
4721 
4722  co.nu_OH_O_H = HMRATE(3.5e-10,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("OH")->hevmol;
4724 
4725  /* nu + OHP => O + HP */
4726 
4727  co.nu_OHP_O_HP = HMRATE(1.0e-12,0,0)*(hmi.UV_Cont_rel2_Habing_TH85_depth/1.66)*findspecies("OH+")->hevmol;
4729 
4730  /* nu + SiH => Si + H */
4731 
4734 
4735  /* e + CHP => C + H */
4736 
4737  co.e_CHP_C_H = HMRATE(1.5e-7,-0.42,0)*dense.eden*findspecies("CH+")->hevmol;
4739 
4740  /* e + CH2P => CH + H */
4741 
4742  co.e_CH2P_CH_H = HMRATE(1.6e-7,-0.6,0)*dense.eden*findspecies("CH2+")->hevmol;
4744 
4745  /* e + CH2P => C + H + H */
4746 
4747  co.e_CH2P_C_H_H = HMRATE(4.03e-7,-0.6,0)*dense.eden*findspecies("CH2+")->hevmol;
4749 
4750  /* e + CH2P => C + H2 */
4751 
4752  co.e_CH2P_C_H2 = HMRATE(7.68e-8,-0.6,0)*dense.eden*findspecies("CH2+")->hevmol;
4754 
4755  /* e + CH3P => C + H2 + H */
4756 
4757  co.e_CH3P_C_H2_H = HMRATE(1.05e-7,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;
4760 
4761  /* e + CH3P => CH2 + H */
4762 
4763  co.e_CH3P_CH2_H = HMRATE(1.4e-7,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;
4765 
4766  /* e + CH3P => CH + H + H */
4767 
4768  co.e_CH3P_CH_H_H = HMRATE(5.6e-8,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;
4770 
4771  /* e + CH3P => CH + H2 */
4772 
4773  co.e_CH3P_CH_H2 = HMRATE(4.9e-8,-0.5,0)*dense.eden*findspecies("CH3+")->hevmol;
4775 
4776  /* e + H2OP => OH + H */
4777 
4778  co.e_H2OP_OH_H = HMRATE(7.92e-8,-0.5,0)*dense.eden*findspecies("H2O+")->hevmol;
4780 
4781  /* e + H2OP => O + H + H */
4782 
4783  co.e_H2OP_O_H_H = HMRATE(2.45e-7,-0.5,0)*dense.eden*findspecies("H2O+")->hevmol;
4785 
4786  /* e + H2OP => O + H2 */
4787 
4788  co.e_H2OP_O_H2 = HMRATE(3.6e-8,-0.5,0)*dense.eden*findspecies("H2O+")->hevmol;
4790 
4791  /* e + H3OP => H2O + H */
4792 
4793  co.e_H3OP_H2O_H = HMRATE(1.08e-7,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;
4795 
4796  /* e + H3OP => OH + H + H */
4797 
4798  co.e_H3OP_OH_H_H = HMRATE(2.58e-7,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;
4800 
4801  /* e + H3OP => OH + H2 */
4802 
4803  co.e_H3OP_OH_H2 = HMRATE(6.45e-8,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;
4805 
4806  /* e + H3OP => O + H2 + H */
4807 
4808  co.e_H3OP_O_H2_H = HMRATE(5.59e-9,-0.5,0)*dense.eden*findspecies("H3O+")->hevmol;
4810 
4811  /* e + HCOP => CO + H */
4812 
4813  co.e_HCOP_CO_H = HMRATE(1.1e-7,-1,0)*dense.eden*findspecies("HCO+")->hevmol;
4815 
4816  /* e + OHP => O + H */
4817 
4818  co.e_OHP_O_H = HMRATE(3.75e-8,-0.5,0)*dense.eden*findspecies("OH+")->hevmol;
4820 
4821  /* e + SiH2P => SiH + H */
4822 
4823  co.e_SiH2P_SiH_H = HMRATE(1.5e-7,-0.5,0)*dense.eden*findspecies("SiH2+")->hevmol;
4825 
4826  /* e + SiH2P => Si + H + H */
4827 
4828  co.e_SiH2P_Si_H_H = HMRATE(2.0e-7,-0.5,0)*dense.eden*findspecies("SiH2+")->hevmol;
4830 
4831  /* e + SiH2P => Si + H2 */
4832 
4833  co.e_SiH2P_Si_H2 = HMRATE(1.5e-7,-0.5,0)*dense.eden*findspecies("SiH2+")->hevmol;
4835 
4836  /* e + SiOHP => SiO + H */
4837 
4838  co.e_SiOHP_SiO_H = HMRATE(1.5e-7,-0.5,0)*dense.eden*findspecies("SiOH+")->hevmol;
4840 
4841  /* H2 + CH => CH3 + nu */
4842 
4843  co.H2_CH_CH3_nu = HMRATE(5.09E-18,-0.71,11.6)*findspecies("H2")->hevmol*findspecies("CH")->hevmol;
4845 
4846  /* H2 + CH3P => CH5P + nu */
4847 
4848  co.H2_CH3P_CH5P_nu = HMRATE(1.3e-15,-1,0)*findspecies("CH3+")->hevmol*hmi.Hmolec[ipMH2g];
4850 
4851  /* H2s + CH => CH3 + nu */
4852 
4855 
4856  /* Hminus + CH2 => CH3 + e */
4857 
4858  co.Hminus_CH2_CH3_e = HMRATE(1.0e-9,0,0)*findspecies("CH2")->hevmol*hmi.Hmolec[ipMHm];
4860 
4861  /* Hminus + CH3 => CH4 + e */
4862 
4863  co.Hminus_CH3_CH4_e = HMRATE(1.0e-9,0,0)*findspecies("CH3")->hevmol*hmi.Hmolec[ipMHm];
4865 
4866  /* nu + CH3 => CH2 + H */
4867 
4870 
4871  /* nu + CH3 => CH + H2 */
4872 
4875 
4876  /* nu + CH4 => CH3 + H */
4877 
4880 
4881  /* nu + CH4 => CH2 + H2 */
4882 
4885 
4886  /* nu + CH4 => CH + H2 */
4887 
4890 
4891  /* crnu + CH3 => CH2 + H */
4892 
4895 
4896  /* crnu + CH3 => CH + H2 */
4897 
4900 
4901  /* crnu + CH4 => CH2 + H2 */
4902 
4905 
4906  /* e + CH5P => CH3 + H2 */
4907 
4908  co.e_CH5P_CH3_H2 = HMRATE(5.5e-7,-0.3,0)*dense.eden*findspecies("CH5+")->hevmol;
4910 
4911  /* e + CH5P => CH4 + H */
4912 
4913  co.e_CH5P_CH4_H = HMRATE(5.5e-7,-0.3,0)*dense.eden*findspecies("CH5+")->hevmol;
4915 
4916  /* e + CH4P => CH3 + H */
4917 
4918  co.e_CH4P_CH3_H = HMRATE(1.75e-7,-0.5,0)*dense.eden*findspecies("CH4+")->hevmol;
4920 
4921  /* e + CH4P => CH2 + H + H */
4922 
4923  co.e_CH4P_CH2_H_H = HMRATE(1.75e-7,-0.5,0)*dense.eden*findspecies("CH4+")->hevmol;
4925 # endif
4926  /******* END OF REACTIONS ********/
4927 # if 0
4928  if( iteration>1 )
4929  {
4930  r = rlist;
4931  i = 0;
4932  while (r->next != NULL)
4933  {
4934  ++i;
4935  r = r->next;
4936  fprintf(ioQQQ,"DEBUG r\t%li\t%.3e\n", i, r->rk);
4937  }
4938  }
4939 # endif
4940 
4941  /* Generate chemical error vector and Jacobian array from reaction list */
4942  for( i=0; i < N_H_MOLEC; i++ )
4943  {
4944  bvec[i] = 0.;
4945  for( j=0; j < N_H_MOLEC; j++ )
4946  {
4947  c[j][i] = 0.;
4948  }
4949  }
4950  /* Subtotal rates for H_0 and H^+ within ipMHo */
4951  for(i=0;i<2;i++)
4952  {
4953  mole.source[ipHYDROGEN][i] = mole.sink[ipHYDROGEN][i] = 0.;
4954  }
4955 
4956  /* reinitialize linked list and move through it */
4957  /* set up Jacobian matrix */
4958  r = rlist;
4959 
4960  /* Comments about this line of code, made by Nick Abel. This section of the code
4961  does the same thing as in co.c, where it decouples products of two densities
4962  that the code is trying to predict. Reactions of the form n(X)*n(Y) cannot be
4963  treated properly in a linear solver otherwise.
4964 
4965  This section of the code starts off with a while
4966  statement that loops over all reactions in the network (hence the r->next variable).
4967  For each reaction, the first thing that is done is to state that for the reaction
4968  of interest, the rate coefficient k is equal to r->rk, which is the stored value from
4969  when the reaction was originally set up above. After this a loop over all reactants is
4970  performed. This is actually a double loop. If the number of reactants is greater than
4971  one, then this code will generate (via the i!=j if statement) two "decoupled" products of
4972  the rate coefficient times the previous solution for the density. This is explained in co.c
4973  and in that code it is just the reaction rates that end in _1 or _2.
4974 
4975  After this loop the variable "rate" is multiplied by the the density that was not multiplied
4976  in the loop. This sets up "rate" to be what co.c calls "bvec" for that reaction. The bvec's
4977  are needed because in the process of "decoupling" a reaction, their is a leftover term of
4978  the form k*n(X)old*n(Y)old which has to go into the solution vector for the matrix equation Ax = b.
4979 
4980  The next two loops set up the bvec so that it goes with the proper species. Also, in the
4981  case of H and H+, these rates are saved so that they can be fed into the main ionization
4982  solver. This allows Cloudy to account for formation and destruction processes
4983  for Hydrogen that are due to reaction with molecules.
4984 
4985  The last for statement inside the while loop takes the rates that were calculated previously
4986  and stores them in the appropriate part of the matrix A. */
4987 
4988  /* rates complete - all reactions have been stored, now fill in the c[][] matrix */
4989  while (r->next != NULL)
4990  {
4991  r = r->next;
4992  /* >>chng 04 feb 05, this was option to cut chemistry short in testing
4993  if(r->index == rindex)
4994  break;*/
4995  rk = r->rk;
4996 
4997  /* if this blows, rk is NaN */
4998  /*ASSERT( rk == rk );*/
4999  ASSERT( !isnan( rk ) );
5000 
5001  /* There's an O(n) algorithm for this -- but it doesn't improve
5002  * things unless nreactants is >= 4...!*/
5003  /* loop over all rate determining species */
5004  for(i=0;i<r->nrates;i++)
5005  {
5006  rate_deriv[i] = rk;
5007  for(j=0;j<r->nrates;j++)
5008  {
5009  /* Hmolec_old was previous abundance,
5010  * rate_deriv[i] is derivative of rates coefficient by species r->rate_species[i] */
5011  if(i!=j)
5012  {
5013  rate_deriv[i] *= Hmolec_old[r->rate_species[j]];
5014  /* if this blows, rate_deriv[i] is NaN */
5015  /*ASSERT( rate_deriv[i] == rate_deriv[i] );*/
5016  ASSERT( !isnan( rate_deriv[i] ) );
5017  }
5018  }
5019  }
5020 
5021  /* this is total rate, rate_deriv times old population */
5022  rate = rate_deriv[0]*Hmolec_old[r->rate_species[0]];
5023 
5024  /* is this blows, rate is NaN */
5025  ASSERT( !isnan( rate ) );
5026 
5027  /* Get sink terms (i.e. rate/abundance) to include in ionization ladders */
5028  for(i=0;i < r->nreactants;i++)
5029  {
5030  int ok = 0;
5031  for(j=0;j < r->nrates && !ok;j++)
5032  {
5033  if(r->rate_species[j] == r->reactants[i])
5034  {
5035  sinkrate[i] = rate_deriv[j];
5036  ok = true;
5037  }
5038  }
5039  if(!ok)
5040  {
5041  /* Odd, the rate didn't depend on one of the species it used
5042  * at all! An alternative way of getting sink rate is
5043  *
5044  * sinkrate[i] = rate/Hmolec_old[r->reactants[i]];
5045  *
5046  * but this uses the possibly zero Hmolec_old, and is prone to underflow of rate.
5047  * */
5048  fprintf(ioQQQ,"A chemical rate in hmole was independent of the species it used\n");
5049  fprintf(ioQQQ,"This probably shouldn't happen (so you shouldn't see this message).\n");
5050  cdEXIT(EXIT_FAILURE);
5051  }
5052  }
5053 
5054  /* if(nzone == 416)
5055  fprintf(ioQQQ,"Adding reaction %d rate %g\n",r->index,rate); */
5056 
5057  /* loop over all reactions, find total consumption rate,
5058  * also keep track of rates that use up H0 or H+ */
5059  for(i=0;i<r->nreactants;i++)
5060  {
5061  ratei = r->reactants[i];
5062  bvec[ratei] -= rate;
5063  /*if((nzone == 421 || nzone == 422) && ratei == ipMHm)
5064  fprintf(ioQQQ,"snk %s %d %g\n",hmi.chLab[ratei],r->index,rate);*/
5065  /* mole.sink[ipHYDROGEN] is how chemical reaction network reacts with ionization
5066  * network, so this keeps track of total rates */
5067  if(ratei == ipMH || ratei == ipMHp)
5068  mole.sink[ipHYDROGEN][ratei] += sinkrate[i];
5069  }
5070 
5071  /* loop over all reactions, find total production rate,
5072  * also keep track of rates that produce H0 or H+ */
5073  for(i=0;i<r->nproducts;i++)
5074  {
5075  ratei = r->products[i];
5076  bvec[ratei] += rate;
5077  /*if((nzone == 421 || nzone == 422) && ratei == ipMHm)
5078  fprintf(ioQQQ,"src %s %d %g\n",hmi.chLab[ratei],r->index,rate); */
5079  if(ratei == ipMH || ratei == ipMHp)
5080  {
5081  mole.source[ipHYDROGEN][ratei] += rate;
5082 
5083  /* confirm mole.source[ipHYDROGEN][ratei] is valid float */
5084  ASSERT( !isnan( mole.source[ipHYDROGEN][ratei] ) );
5085  }
5086  }
5087 
5088  /* The first thing that must be said about the for statements below is that
5089  * it is inside a while statement (starting on line 4151). This while loops over
5090  * all reactions. Each individual reaction is stored with the pointer r->next,
5091  * which goes from 1 to the number of reactions in the hmole_step. Also, for
5092  * each reaction, the code keeps track of the number of products and reactants
5093  * in reaction r->next, what each product or reactant is
5094  * (H2, H2*, H3+, et cetera), and the reaction rate coefficient.
5095  *
5096  * For example, if the first reaction is H2 + H+ => H2+ + H, then:
5097  *
5098  * r->next = 1 (this is the first reaction)
5099  * r->nreactants[i] = 2 (the number of reactants equals two)
5100  * r->nproducts[i] = 2 (the number of products equals two)
5101  * r->nrates = (unless the reactant is repeated, such as H2 + H2 => H2* + H2,
5102  * then r->nrates is always the number of reactants (see line 107)
5103  *
5104  * rate_deriv[j] = reaction rate determined from lines (4161-4173),
5105  * this is the product of the rate coefficient k and the density of
5106  * one of the reactants.
5107  *
5108  * r->rate_species[j], r->reactants[i], and r->products[i] is the species
5109  * corresponding to each product or reactant.
5110  *
5111  *
5112  *
5113  * So H2 + H+ => H2+ + H does the following in the code below.
5114  *
5115  *
5116  * 1) Since nrates = 2, the for loop goes over all reactants, 1 and 2.
5117  * The first reactant considered is 1
5118  * 2) ratej is set equal to H2, and rated is equal to k*[density of H+]
5119  * 3) The second for statement loops over all reactants, and puts
5120  * fills in some matrix elements:
5121  *
5122  * c[ipMH2g][ipMH2g] -= k*[density of H+]
5123  * c[ipMH2g][ipMHp] -=k*[density of H+]
5124  *
5125  * 4) Now the third for statement fills in some more reactions,
5126  * involving the products:
5127  *
5128  * c[ipMH2g][ipMH2p] += k*[density of H+]
5129  * c[ipMH2g][ipMH] += k*[density of H+]
5130  *
5131  * 5) At this state, we go back up to the first for statement,
5132  * and the reactant is changed from 1 to 2 (H+)
5133  * 6) Also ratej is set to H+ and rated is now k*[density of H2]
5134  * 7) Some more matrix elements are filled in:
5135  *
5136  * c[ipMHp][ipMH2g] -= k*[density of H2]
5137  * c[ipMHp][ipMHp] -= k*[density of H2]
5138  *
5139  * c[ipMHp][ipMH2p] += k*[density of H2]
5140  * c[ipMHp][ipMH] += k*[density of H2]
5141  *
5142  * This is the more elegant way of linearizing the series of non-linear
5143  * equations in the molecular network, incorporated by Robin Williams.
5144  * co.c does the same thing more explicitly, but also takes up way too
5145  * much space. */
5146 
5147 
5148  /* fill Jacobian rate matrix */
5149  for(j=0;j<r->nrates;j++)
5150  {
5151  ratej = r->rate_species[j];
5152  rated = rate_deriv[j];
5153  for(i=0;i<r->nreactants;i++)
5154  {
5155  c[ratej][r->reactants[i]] -= rated;
5156  }
5157  for(i=0;i<r->nproducts;i++)
5158  {
5159  c[ratej][r->products[i]] += rated;
5160  }
5161  }
5162  }
5163  /* the c[][] matrix Jacobian array has now been filled with all reagents */
5164 
5165  /* save rate H2 is destroyed units s-1 */
5166  /* >>chng 05 mar 18, TE, add terms -
5167  total destruction rate is: dest_tot = n_H2g/n_H2tot * dest_H2g + n_H2s/n_H2tot * dest_H2s */
5168  /* as reactions that change H2s to H2g and vice versa are not counted destruction processes, the terms c[ipMH2g][ipMH2s] *
5169  and c[ipMH2s][ipMH2g], which have a different sign than [ipMH2g][ipMH2g] and [ipMH2s][ipMH2s], have to be added */
5171  hmi.Hmolec[ipMH2s] * (-c[ipMH2s][ipMH2s]-c[ipMH2s][ipMH2g])) / SDIV(hmi.H2_total);
5172 
5173  {
5174  /* following should be set true to print populations */
5175  enum {DEBUG_LOC=false};
5176  if( DEBUG_LOC )
5177  {
5178  if( DEBUG_LOC && (nzone > 570) )
5179  {
5180  printsol = 1;
5181  fprintf(ioQQQ,"Temperature %g\n",phycon.te);
5182  fprintf(ioQQQ," Net mol ion rate [%g %g] %g\n",mole.source[ipHYDROGEN][1],mole.sink[ipHYDROGEN][1],
5183  mole.source[ipHYDROGEN][1]-mole.sink[ipHYDROGEN][1]*Hmolec_old[ipMHp]);
5184  }
5185  }
5186  }
5187 
5188  /* save total H2P destruction rate for possible later printout:
5189  * NB this must come last */
5190  desh2p = -c[ipMH2p][ipMH2p];
5191 
5192  /* Check that matrix and vector generated in above loops make sense */
5193  /*if(!defined(NDEBUG)) */
5194  /* in std C NDEBUG is a macro set at compile time */
5197 # if 0
5198 /*# if !defined(NDEBUG)*/
5199 # ifndef NDEBUG
5200  {
5201  double total, mtotal;
5202  for(i=0;i<N_H_MOLEC;i++)
5203  {
5204  total = 0.;
5205  for( j=0;j<N_H_MOLEC;j++)
5206  {
5207  total += c[i][j]*hmi.nProton[j];
5208  }
5209  if( fabs(total) > 1e-5*fabs(c[i][i]*hmi.nProton[i]))
5210  {
5211  fprintf(ioQQQ,"PROBLEM Subtotal1 %.2e\n",fabs(total)/fabs(c[i][i]*hmi.nProton[i]));
5212  fprintf(ioQQQ,"Species %li Total %g Diag %g\n",i,total,c[i][i]*hmi.nProton[i]);
5213  }
5214  else if( fabs(total) > 1e-6*fabs(c[i][i]*hmi.nProton[i]) && phycon.te< 1e6 )
5215  {
5216  fprintf(ioQQQ,"NOTE Subtotal1 %.2e Te=%.4e\n",
5217  fabs(total)/fabs(c[i][i]*hmi.nProton[i]),phycon.te);
5218  fprintf(ioQQQ,"Species %li Total %g Diag %g\n",i,total,c[i][i]*hmi.nProton[i]);
5219  }
5220  }
5221  total = mtotal = 0.;
5222  for(j=0;j<N_H_MOLEC;j++)
5223  {
5224  total += bvec[j]*hmi.nProton[j];
5225  mtotal += fabs(bvec[j]*hmi.nProton[j]);
5226  }
5227  if(fabs(total) > 1e-30 && fabs(total) > 1e-10*rtot)
5228  {
5229  fprintf(ioQQQ,"PROBLEM Subtotal2 %.2e\n",fabs(total)/mtotal);
5230  fprintf(ioQQQ,"RHS Total %g cf %g\n",total,mtotal);
5231  }
5232  else if(fabs(total) > 1e-7*mtotal)
5233  {
5234  fprintf(ioQQQ,"WARNING zone %li Hmole RHS conservation error %.2e of %.2e\n",nzone,total,mtotal);
5235  fprintf(ioQQQ,"(may be due to high rate equilibrium reactions)\n");
5236  }
5237  }
5238 # endif
5239 # endif
5240 
5241 
5242 #define MOLMIN 1
5243 #define N_H_MAT (N_H_MOLEC-MOLMIN)
5244  /* Will collapse ipMH and ipMHp into single species, as don't include
5245  * all ionizations and recombinations here */
5246  /* last test - do not include advection if we have overrun the radius scale
5247  * of previous iteration */
5248  /* >>chng 06 mar 17, comment out test on old full depth - keep old solution if overrun scale */
5250  /*&& radius.depth < dynamics.oldFullDepth*/ )
5251  {
5252  /* Don't use conservation form in matrix solution */
5253  ipConserve = -1;
5254  /* Add rate terms for dynamics to equilibrium, makes c[][] non-singular */
5255  for(i=0;i<N_H_MOLEC;i++)
5256  {
5257  c[i][i] -= dynamics.Rate;
5258  bvec[i] -= (Hmolec_old[i]*dynamics.Rate-dynamics.H2_molec[i]);
5259  }
5260 
5261  /* Dynamics implies conservation of advected material */
5262  proton_sum_old = 0.;
5263  for(i=0; i<N_H_MOLEC;i++)
5264  {
5265  proton_sum_old += hmi.nProton[i]*dynamics.H2_molec[i]/dynamics.Rate;
5266  }
5267 
5268  /* bring H+ and H0 together since their ratio is set in H atom solver,
5269  * we determine sum of two here */
5270  for(i=0;i<N_H_MOLEC;i++)
5271  {
5272  c[ipMHp][i] = (Hmolec_old[ipMH]*c[ipMH][i]+Hmolec_old[ipMHp]*c[ipMHp][i])/SDIV(sum_H0_Hp);
5273  c[ipMH][i] = 0.;
5274  }
5275  for(i=1;i<N_H_MOLEC;i++)
5276  {
5277  c[i][ipMHp] += c[i][ipMH];
5278  c[i][ipMH] = 0.;
5279  }
5280  bvec[ipMHp] += bvec[ipMH];
5281  bvec[ipMH] = 0.;
5282  Hmolec_old[ipMHp] += Hmolec_old[ipMH];
5283  Hmolec_old[ipMH] = 0.;
5284  }
5285  else
5286  {
5287  /* usual branch, no advection */
5288  /* bring H+ and H0 together since their ratio is set in H atom solver,
5289  * we determine sum of two here */
5290  for(i=0;i<N_H_MOLEC;i++)
5291  {
5292  /* >>chng 04 feb 04, sum_H0_Hp goes to zero when no ionization,
5293  * add test on SMALLFLOAT */
5294  if( sum_H0_Hp > SMALLFLOAT )
5295  c[ipMHp][i] = (Hmolec_old[ipMH]*c[ipMH][i]+Hmolec_old[ipMHp]*c[ipMHp][i])/sum_H0_Hp;
5296  c[ipMH][i] = 0.;
5297  }
5298  Hmolec_old[ipMHp] += Hmolec_old[ipMH];
5299  bvec[ipMH] = Hmolec_old[ipMH] = 0.;
5300  ipConserve = ipMHp;
5301  /* For Newton-Raphson method, want the change in populations to be zero,
5302  * so the conserved component must also be zero */
5303  bvec[ipConserve] = 0.;
5304 
5305  /* proton_sum_old is the sum of all protons in H-bearing molecules */
5306  proton_sum_old = 0.;
5307  for(i=MOLMIN;i<N_H_MOLEC;i++)
5308  {
5309  c[i][ipConserve] = hmi.nProton[i];
5310  proton_sum_old += hmi.nProton[i]*Hmolec_old[i];
5311  }
5312  }
5313 
5314  {
5315  /* following should be set true to print populations */
5316  enum {DEBUG_LOC=false};
5317  if( DEBUG_LOC )
5318  {
5319  /* these are the raw results */
5320  fprintf( ioQQQ, " HMOLE h2 %.2e h2* %.2e\n" , Hmolec_old[ipMH2g] ,Hmolec_old[ipMH2s] );
5321  }
5322  }
5323 
5324  /*------------------------------------------------------------------ */
5325  if(printsol || (trace.lgTrace && trace.lgTr_H2_Mole ))
5326  {
5327 
5328  /*
5329 
5330  [0][0] [0][1] [0][2] [0][3] [0][4] [0][5]
5331  [1][0] [1][1] [1][2] [1][3] [1][4] [1][5]
5332  [2][0] [2][1] [2][2] [2][3] [2][4] [2][5]
5333  [3][0] [3][1] [3][2] [3][3] [3][4] [3][5]
5334  [4][0] [4][1] [4][2] [4][3] [4][4] [4][5]
5335  [5][0] [5][1] [5][2] [5][3] [5][4] [5][5]
5336 
5337  [ipMHo][ipMHo] [ipMHo][ipMHm] [ipMHo][ipMH2g] [ipMHo][ipMH2p] [ipMHo][ipMH3p] [ipMHo][ipMH2s]
5338  [ipMHm][ipMHo] [ipMHm][ipMHm] [ipMHm][ipMH2g] [ipMHm][ipMH2p] [ipMHm][ipMH3p] [ipMHm][ipMH2s]
5339  [ipMH2g][ipMHo] [ipMH2g][ipMHm] [ipMH2g][ipMH2g] [ipMH2g][ipMH2p] [ipMH2g][ipMH3p] [ipMH2g][ipMH2s]
5340  [ipMH2p][ipMHo] [ipMH2p][ipMHm] [ipMH2p][ipMH2g] [ipMH2p][ipMH2p] [ipMH2p][ipMH3p] [ipMH2p][ipMH2s]
5341  [ipMH3p][ipMHo] [ipMH3p][ipMHm] [ipMH3p][ipMH2g] [ipMH3p][ipMH2p] [ipMH3p][ipMH3p] [ipMH3p][ipMH2s]
5342  [ipMH2s][ipMHo] [ipMH2s][ipMHm] [ipMH2s][ipMH2g] [ipMH2s][ipMH2p] [ipMH2s][ipMH3p] [ipMH2s][ipMH2s]
5343 
5344  */
5345 
5346  fprintf(ioQQQ," MOLE old abundances\t%.2f",fnzone);
5347  for( i=0; i<N_H_MOLEC; i++ )
5348  fprintf(ioQQQ,"\t%.2e", Hmolec_old[i] );
5349  fprintf(ioQQQ,"\n" );
5350 
5351  /* print the full matrix */
5352  fprintf( ioQQQ, " ");
5353  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5354  {
5355  fprintf( ioQQQ, " %s", hmi.chLab[i] );
5356  }
5357  fprintf( ioQQQ, " bvec \n" );
5358 
5359  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5360  {
5361  fprintf( ioQQQ, " MOLE%2ld %s", i-MOLMIN ,hmi.chLab[i] );
5362  for( j=MOLMIN; j < N_H_MOLEC; j++ )
5363  {
5364  fprintf( ioQQQ, "%10.2e", c[j][i] );
5365  }
5366  fprintf( ioQQQ, "%10.2e", bvec[i] );
5367  fprintf( ioQQQ, "\n" );
5368  }
5369  }
5370 
5371  /*fprintf(ioQQQ,"DEBUG %.2e %.2e %.2e %.2e\n",
5372  c[ipMH][ipMH2g] , c[ipMH][ipMH2s],
5373  c[ipMH2g][ipMH] , c[ipMH2s][ipMH]);
5374  fprintf(ioQQQ,"DEBUG %.2e %.2e %.2e %.2e\n\n",
5375  c[ipMHp][ipMH2g] , c[ipMHp][ipMH2s],
5376  c[ipMH2g][ipMHp] , c[ipMH2s][ipMHp]);*/
5377  /* establish local timescale for H2 molecule destruction */
5378  if( -c[ipMH2g][ipMH2g] > SMALLFLOAT )
5379  {
5380  /* units are now seconds */
5382  }
5383  else
5384  {
5386  }
5387 
5388  /* local timescale for H2 formation
5389  * both grains and radiative attachment */
5391  /* this corrects for fact that we the timescale for H2 to form from an atomic gas.
5392  * The rate becomes very small when gas is fully molecular, and ratio of total hydrogen
5393  * to atomic hydrogen corrections for this. */
5396  /* timescale is inverse of this rate */
5398  {
5399  /* units are now seconds */
5401  }
5402  else
5403  {
5405  }
5406 
5407 # ifdef MAT
5408 # undef MAT
5409 # endif
5410 # define MAT(a,I_,J_) (*((a)+(I_)*(N_H_MAT)+(J_)))
5411 
5412  /* copy contents over to 1D array */
5413  for( j=0; j < N_H_MAT; j++ )
5414  {
5415  for( i=0; i < N_H_MAT; i++ )
5416  {
5417  MAT(amat,i,j) = c[i+MOLMIN][j+MOLMIN];
5418  }
5419  }
5420 
5421  if(printsol)
5422  {
5423  double total=0;
5424  fprintf(ioQQQ,"Zone %.2f input:\n",fnzone);
5425  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5426  {
5427  fprintf(ioQQQ,"%15.7g\t",Hmolec_old[i]);
5428  total += hmi.nProton[i]*Hmolec_old[i];
5429  }
5430  fprintf(ioQQQ,"sum = %15.7g\n",total);
5431  }
5432 
5433  int32 merror1 = 0;
5434  int32 merror2 = 0;
5435 
5436  /* now invert the matrix */
5437  getrf_wrapper(N_H_MAT,N_H_MAT,(double*)amat,N_H_MAT,ipiv,&merror1);
5438  getrs_wrapper('N',N_H_MAT,1,(double*)amat,N_H_MAT,ipiv,bvec+MOLMIN,N_H_MAT,&merror2);
5439 
5440  if( merror1 != 0 || merror2 != 0 )
5441  {
5442  fprintf( ioQQQ, "PROBLEM hmole_step: dgetrs finds singular or ill-conditioned matrix\n" );
5443  cdEXIT(EXIT_FAILURE);
5444  }
5445 
5446  if(printsol)
5447  {
5448  double total=0;
5449  fprintf(ioQQQ,"solution:\n");
5450  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5451  {
5452  fprintf(ioQQQ,"%15.7g\t",bvec[i]);
5453  total += hmi.nProton[i]*bvec[i];
5454  }
5455  fprintf(ioQQQ,"sum = %15.7g\n",total);
5456  }
5457 
5458  *error = 0;
5459  /* loop starts from MOLMIN=1 rather than zero since
5460  * H0 and H+ rates have been collapsed into one, since that solution
5461  * comes from H atom solver.
5462  *
5463  * bvec is (old - new) solutions coming into this routine
5464  * loops converts bvec to new density */
5465  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5466  {
5467  /* Smooth the error mode tailoff */
5468  etmp = bvec[i]/(ABSLIM+Hmolec_old[i]);
5469 
5470  if(printsol)
5471  fprintf(ioQQQ,"%15.7g\t",etmp);
5472 
5473  /* square of change in abundance of this species, in this iteration */
5474  *error += etmp*etmp;
5475  /* change bvec from being the difference into being the new value
5476  * bvec is now new density */
5477  bvec[i] = Hmolec_old[i]-bvec[i];
5478  }
5479  /* bvec is now the density */
5480  *error = sqrt(*error)/N_H_MAT;
5481 
5482  if(printsol)
5483  {
5484  double total=0;
5485  fprintf(ioQQQ,"err = %15.7g\n",*error);
5486  /* fprintf(ioQQQ,"derived:\n"); */
5487  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5488  {
5489  fprintf(ioQQQ,"%15.7g\t",bvec[i]);
5490  total += hmi.nProton[i]*bvec[i];
5491  }
5492  fprintf(ioQQQ,"sum = %15.7g\n",total);
5493  }
5494 
5495  proton_sum_new = 0.;
5496  /* check for negative populations and do proton sum */
5497  lgNegPop = false;
5498  fracneg = 0.;
5499  fracnegfac = 0.;
5500  iworst = -1;
5501  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5502  {
5503  if( bvec[i] < 0. )
5504  {
5505  lgNegPop = true;
5506  }
5507  /* largest relative change in solution for neg soln */
5508  fracnegtmp = -bvec[i]/SDIV(Hmolec_old[i]);
5509  /* this can only occur for negative solutions since fracneg starts
5510  * as zero */
5511  if(fracnegtmp > fracneg)
5512  {
5513  fracneg = fracnegtmp;
5514  fracnegfac = (0.5*Hmolec_old[i]-bvec[i])/(Hmolec_old[i]-bvec[i]);
5515  iworst = i;
5516  }
5517  /* sum total number of protons used - hmi.nProton is number of protons in species bvec[i] */
5518  proton_sum_new += hmi.nProton[i] * bvec[i];
5519  }
5520 
5521  /* this is difference between number of protons in hmi.Hmolec upon entry into this routine
5522  * and number of protons we found here */
5523  conserve = (proton_sum_old - proton_sum_new)/SDIV(proton_sum_old);
5524  /* >>chng 06 jun 29, from conserve < 1e-8 to twice FLT_EPSILON - the CO network now includes
5525  * part of the H - the old upstream fraction of H in CO molecules is likely different from
5526  * the current fractions. the CO chem is only solved to a certain error, should not
5527  * demand higher accuracy than this
5528  * the factor 10.*FLT_EPSILON also appears in ion_solver in total H conservation */
5529  /*if( fabs(conserve) > 1e-8 )*/
5530  if( fabs(conserve) > 10.*FLT_EPSILON )
5531  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",
5532  nzone ,
5533  proton_sum_old ,
5534  proton_sum_new ,
5536  conserve ,
5537  dense.gas_phase[ipHYDROGEN]-proton_sum_old,
5538  dense.gas_phase[ipHYDROGEN]-proton_sum_new);
5539 
5540 # if 0
5541  /* NDEBUG is set by the compiler to indicate that a debugging mode
5542  * has not been specified. */
5543 # ifndef NDEBUG
5544  /*if(NDEBUG)*/
5545  {
5546  fprintf( ioQQQ, "Zone %li\n",nzone);
5547  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5548  {
5549  fprintf(ioQQQ," %s %.2e", hmi.chLab[i], Hmolec_old[i]);
5550  }
5551  fprintf( ioQQQ, " =>\n" );
5552  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5553  {
5554  fprintf(ioQQQ," %s %.2e", hmi.chLab[i], bvec[i]);
5555  }
5556  fprintf( ioQQQ, "\n" );
5557  }
5558 # endif
5559 # endif
5560 
5561  if(lgNegPop)
5562  {
5563 # ifndef NDEBUG
5564  /* very common to obtain negative solution on very first try -
5565  * don't print in this case */
5566  if(*nFixup )
5567  {
5568  fprintf( ioQQQ, " PROBLEM hmole_step finds negative H molecule, in zone %.2f.\n",fnzone );
5569  fprintf( ioQQQ, " Worst is species %d -ve by fraction %g.\n",iworst,fracneg );
5570  fprintf( ioQQQ, " The populations follow:\n");
5571  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5572  {
5573  fprintf(ioQQQ," %s %.2e", hmi.chLab[i], bvec[i]);
5574  }
5575  fprintf( ioQQQ, "\n" );
5576  }
5577 # endif
5578 
5579  /* Fix negative abundance -- assume the new solution is better in some ways */
5580  {
5581  double total=0., ntotal=0., ratio;
5582  enum {FIXUPTYPE = 1};
5583 
5584  ++*nFixup;
5585 
5586  if(FIXUPTYPE == 1) {
5587  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5588  {
5589  total += hmi.nProton[i]*bvec[i];
5590  if(bvec[i] < 0)
5591  {
5592  ntotal += hmi.nProton[i]*bvec[i];
5593  bvec[i] = 0.;
5594  }
5595  }
5596  ratio = total/(total-ntotal);
5597  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5598  {
5599  bvec[i] *= ratio;
5600  }
5601  }
5602  else if(FIXUPTYPE == 2)
5603  {
5604  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5605  {
5606  bvec[i] = fracnegfac*Hmolec_old[i]+(1-fracnegfac)*bvec[i];
5607  }
5608  }
5609 
5610 # ifndef NDEBUG
5611  /*if(NDEBUG)*/
5612  /* very common to obtain negative solution on very first try -
5613  * don't print in this case */
5614  if( *nFixup>1 )
5615  {
5616  fprintf(ioQQQ," FIXUP taken %i time%s.\n\n", *nFixup, (*nFixup == 1)?"":"s");
5617  fprintf( ioQQQ, " Initially:\n");
5618  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5619  {
5620  fprintf(ioQQQ," %s %.2e", hmi.chLab[i], Hmolec_old[i]);
5621  }
5622  fprintf( ioQQQ, "\n" );
5623  fprintf( ioQQQ, " Changed to:\n");
5624  for( i=MOLMIN; i < N_H_MOLEC; i++ )
5625  {
5626  fprintf(ioQQQ," %s %.2e", hmi.chLab[i], bvec[i]);
5627  }
5628  fprintf( ioQQQ, "\n" );
5629  }
5630 # endif
5631  }
5632  }
5633 
5634  /* put derived abundances back into appropriate molecular species,
5635  * bvec[ipMHp] is still sum of H0 and H+ from chemistry,
5636  * now split up using ratio found in H atom solver */
5637  h1fnd = bvec[ipMHp];
5638  /* >>chng 04 feb 04, add SMALLFLOAT to protect against fully molecular limit */
5639  h1rat = h1fnd/SDIV(sum_H0_Hp);
5640  /* put back into proper places in solution vector so following loops work
5641  * as expected */
5642  bvec[ipMH] = dense.xIonDense[ipHYDROGEN][0] * h1rat;
5643  bvec[ipMHp] = dense.xIonDense[ipHYDROGEN][1] * h1rat;
5644  /* ASSERT(fabs(bvec[ipMH]+bvec[ipMHp]-h1fnd) < 1e-12 * h1fnd); */
5645 
5646  if(fabs(bvec[ipMH]+bvec[ipMHp]-h1fnd) >= 1e-12 * h1fnd)
5647  {
5648  static bool lgPrint=true;
5649  fprintf(ioQQQ,"PROBLEM h1fnd residual error, bvec[ipMH]=%g [ipMHp}=%g"
5650  " h1fnd=%g h1rat=%g bvec[ipMH]+bvec[ipMHp]-h1fnd=%g\n",
5651  bvec[ipMH],bvec[ipMHp],h1fnd,h1rat,bvec[ipMH]+bvec[ipMHp]-h1fnd);
5652  /* nearly all cases of this problem are due to ZERO H ionization rate - this can't happen if
5653  * cosmic rays are present */
5654  if( lgPrint )
5655  {
5656  fprintf(ioQQQ," This problem is usually caused by little or no sources of ionizaiton.\n");
5657  fprintf(ioQQQ," Is the simulation physically motivated?\n");
5658  if( hextra.cryden==0. && lgPrint )
5659  {
5660  fprintf(ioQQQ,"PROBLEM h1fnd - no cosmic rays are present - is this physical?\n");
5661  fprintf(ioQQQ,"PROBLEM h1fnd - Consider including the COSMIC RAY BACKGROUND command.\n");
5662  }
5663  lgPrint = false;
5664  }
5665  }
5666 
5667  /* copy new solutions over the hmi.Hmolec */
5668  for(mol=0;mol<N_H_MOLEC;mol++)
5669  {
5670  hmi.Hmolec[mol] = (realnum) bvec[mol];
5671  }
5672 
5673  dense.xIonDense[ipHYDROGEN][0] = (realnum) bvec[ipMH];
5674  dense.xIonDense[ipHYDROGEN][1] = (realnum) bvec[ipMHp];
5675 
5676  /* total H2 - all forms */
5678  /* first guess at ortho and para densities */
5679  h2.ortho_density = 0.75*hmi.H2_total;
5680  h2.para_density = 0.25*hmi.H2_total;
5681 
5682  /* NB the first index must be kept parallel with nelem and ionstag in
5683  * H2Lines transition struc,
5684  * since that struc expects to find the abundances here */
5685  /* >>chng 04 feb 19, had been ipMH2g, chng to total */
5686  dense.xIonDense[LIMELM+2][0] = hmi.H2_total;
5687 
5688  /* identify dominant H2 formation process */
5689  {
5690  /* following should be set true to identify H2 formation and destruction processes */
5691  enum {DEBUG_LOC=false};
5692  if( DEBUG_LOC && (nzone>50) )
5693  {
5694  double createsum ,create_from_Hn2 , create_3body_Ho, create_h2p,
5695  create_h3p, create_h3pe, create_grains, create_hminus;
5696  double destroysum, destroy_hm ,destroy_soloman ,destroy_2h ,destroy_hp,
5697  destroy_h,destroy_hp2,destroy_h3p;
5698 
5699  /* H(n=2) + H(n=1) -> H2 */
5700  create_from_Hn2 = hmi.radasc*dense.xIonDense[ipHYDROGEN][0];
5701  /* 3H => H2 + H */
5702  create_3body_Ho = hmi.bh2dis*dense.xIonDense[ipHYDROGEN][0];
5703  /* H2+ + H => H2 + H+ */
5704  create_h2p = hmi.bh2h2p*dense.xIonDense[ipHYDROGEN][0]*Hmolec_old[ipMH2p];
5705  /* H + H3+ => H2 + H2+ */
5706  create_h3p = hmi.h3ph2p*dense.xIonDense[ipHYDROGEN][0]*hmi.Hmolec[ipMH3p];
5707  /* e + H3+ => H2 + H */
5708  create_h3pe = hmi.eh3_h2h*dense.eden * hmi.Hmolec[ipMH3p];
5709  /* from grains */
5710  create_grains = gv.rate_h2_form_grains_used_total;
5711  /* from H- */
5712  create_hminus = Hmolec_old[ipMH]*hmi.assoc_detach*hmi.Hmolec[ipMHm];
5713 
5714  createsum = create_from_Hn2 + create_3body_Ho + create_h2p +
5715  create_h3p + create_h3pe + create_grains + create_hminus;
5716 
5717  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",
5718  fnzone,
5719  createsum,
5720  create_hminus / createsum,
5721  create_from_Hn2 / createsum,
5722  create_3body_Ho / createsum,
5723  create_h2p / createsum,
5724  create_h3p / createsum,
5725  create_h3pe / createsum,
5726  create_grains / createsum );
5727 
5728  /* all h2 molecular hydrogen destruction processes */
5729  /* >>chng 04 jan 28, had wrong Boltzmann factor,
5730  * caught by gargi Shaw */
5732  /*destroy_hm2 = eh2hhm;*/
5733  destroy_soloman = hmi.H2_Solomon_dissoc_rate_used_H2g;
5734  destroy_2h = hmi.eh2hh;
5735  destroy_hp = hmi.h2hph3p*dense.xIonDense[ipHYDROGEN][1];
5736  destroy_h = hmi.rh2dis*dense.xIonDense[ipHYDROGEN][0];
5737  destroy_hp2 = hmi.rh2h2p*dense.xIonDense[ipHYDROGEN][1];
5738  destroy_h3p = hmi.h3petc * hmi.Hmolec[ipMH3p];
5739  destroysum = destroy_hm + /*destroy_hm2 +*/ destroy_soloman + destroy_2h +
5740  destroy_hp+ destroy_h+ destroy_hp2+ destroy_h3p;
5741 
5742  fprintf(ioQQQ,"H2 destroy\t%.3f \t%.2e\tsum\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
5743  fnzone,
5744  destroysum,
5745  destroy_hm / destroysum ,
5746  destroy_soloman / destroysum ,
5747  destroy_2h / destroysum ,
5748  destroy_hp / destroysum ,
5749  destroy_h / destroysum ,
5750  destroy_hp2 / destroysum ,
5751  destroy_h3p / destroysum );
5752 
5753  }
5754  }
5755 
5756  {
5757  /* following should be set true to identify H- formation and destruction processes */
5758  enum {DEBUG_LOC=false};
5759  if( DEBUG_LOC && (nzone>140) )
5760  {
5761  double create_from_Ho,create_3body_Ho,create_batach,destroy_photo,
5762  destroy_coll_heavies,destroy_coll_electrons,destroy_Hattach,destroy_fhneut,
5763  destsum , createsum;
5764 
5765  create_from_Ho = (hmi.hminus_rad_attach + hmi.HMinus_induc_rec_rate);
5766  create_3body_Ho = c3bod;
5767  /* total formation is sum of g and s attachment */
5769  destroy_photo = hmi.HMinus_photo_rate;
5770  destroy_coll_heavies = hmi.hmin_ct_firstions*sum_first_ions;
5771  destroy_coll_electrons = cionhm;
5772  destroy_Hattach = Hmolec_old[ipMH]*hmi.assoc_detach;
5773  destroy_fhneut = fhneut;
5774 
5775  destsum = destroy_photo + destroy_coll_heavies + destroy_coll_electrons +
5776  destroy_Hattach + destroy_fhneut;
5777  fprintf(ioQQQ,"H- destroy zone\t%.2f\tTe\t%.4e\tsum\t%.2e\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n",
5778  fnzone,
5779  phycon.te,
5780  destsum,
5781  destroy_photo/destsum ,
5782  destroy_coll_heavies/destsum,
5783  destroy_coll_electrons/destsum,
5784  destroy_Hattach/destsum,
5785  destroy_fhneut/destsum );
5786 
5787  createsum = create_from_Ho+create_3body_Ho+create_batach;
5788  fprintf(ioQQQ,"H- create\t%.2f\tTe\t%.4e\tsum\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
5789  fnzone,
5790  phycon.te,
5791  createsum,
5792  dense.eden,
5793  create_from_Ho/createsum,
5794  create_3body_Ho/createsum,
5795  create_batach/createsum);
5796  }
5797  }
5798 
5799  /* rate H-alpha is created by H- ct */
5800  hmi.HalphaHmin = (realnum)(fhneut*hmi.Hmolec[ipMHm]);
5801 
5802  /* heating due to H2 dissociation */
5803  if( hmi.lgNoH2Mole )
5804  {
5805  hmi.HeatH2Dish_TH85 = 0.;
5806  hmi.HeatH2Dexc_TH85 = 0.;
5808  }
5809  else
5810  {
5811  /* H2 photodissociation heating, eqn A9 of Tielens & Hollenbach 1985a */
5812  /*hmi.HeatH2Dish_TH85 = (realnum)(1.36e-23*hmi.Hmolec[ipMH2g]*h2esc*hmi.UV_Cont_rel2_Habing_TH85_depth);*/
5813  /* >>chng 04 feb 07, more general to express heating in terms of the assumed
5814  * photo rates - the 0.25 was obtained by inverting A8 & A9 of TH85 to find that
5815  * there are 0.25 eV per dissociative pumping, ie, 10% of total
5816  * this includes both H2g and H2s - TH85 say just ground but they include
5817  * process for both H2 and H2s - as we did above - both must be in
5818  * heating term */
5819  /* >>chng 05 mar 11, TE, old had used H2_Solomon_dissoc_rate_used, which was only
5820  * H2g. in regions where Solomon process is fast, H2s has a large population
5821  * and the heating rate was underestimated. */
5822  /* >>chng 05 jun 23,
5823  * >>chng 05 dec 05, TE, modified to approximate the heating better for the
5824  * new approximation */
5825  /* >>chng 00 nov 25, explicitly break out this heat agent */
5826  /* 2.6 eV of heat per deexcitation, consider difference
5827  * between deexcitation (heat) and excitation (cooling) */
5828  /* >>chng 04 jan 27, code moved here and simplified */
5829  /* >>chng 05 jul 10, GS*/
5830  /* average collisional rate for H2* to H2g calculated from big H2, GS*/
5831 
5832  /* TH85 dissociation heating - this is ALWAYS defined for reference
5833  * may be output for comparison with other rates*/
5834  hmi.HeatH2Dish_TH85 = 0.25 * EN1EV *
5837 
5838  /* TH85 deexcitation heating */
5839  hmi.HeatH2Dexc_TH85 = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12;
5840  /* this is derivative wrt temperature, only if counted as a cooling source */
5842 
5843  if( hmi.chH2_small_model_type == 'H' )
5844  {
5845  /* Burton et al. 1990 */
5846  hmi.HeatH2Dish_BHT90 = 0.25 * EN1EV *
5849 
5850  /* Burton et al. 1990 heating */
5851  hmi.HeatH2Dexc_BHT90 = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12;
5852  /* this is derivative wrt temperature, only if counted as a cooling source */
5854  }
5855  else if( hmi.chH2_small_model_type == 'B')
5856  {
5857  /* Bertoldi & Draine */
5858  hmi.HeatH2Dish_BD96 = 0.25 * EN1EV *
5861  /* Bertoldi & Draine heating, same as TH85 */
5862  hmi.HeatH2Dexc_BD96 = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12;
5863  /* this is derivative wrt temperature, only if counted as a cooling source */
5865  }
5866  else if(hmi.chH2_small_model_type == 'E')
5867  {
5868  /* heating due to dissociation of H2
5869  * >>chng 05 oct 19, TE, define new approximation for the heating due to the destruction of H2
5870  * use this approximation for the specified cloud parameters, otherwise
5871  * use limiting cases for 1 <= G0, G0 >= 1e7, n >= 1e7, n <= 1 */
5872 
5873  double log_density,
5874  f1, f2,f3, f4, f5;
5875  static double log_G0_face = -1;
5876  static double k_f4;
5877 
5878 
5879  /* test for G0
5880  * this is a constant so only do it in zone 0 */
5881  if( !nzone )
5882  {
5884  {
5885  log_G0_face = 0.;
5886  }
5887  else if(hmi.UV_Cont_rel2_Draine_DB96_face >= 1e7)
5888  {
5889  log_G0_face = 7.;
5890  }
5891  else
5892  {
5893  log_G0_face = log10(hmi.UV_Cont_rel2_Draine_DB96_face);
5894  }
5895  /*>>chng 06 oct 24 TE change Go face for spherical geometry*/
5896  log_G0_face /= radius.r1r0sq;
5897  }
5898  /* test for density */
5899  if(dense.gas_phase[ipHYDROGEN] <= 1.)
5900  {
5901  log_density = 0.;
5902  }
5903  else if(dense.gas_phase[ipHYDROGEN] >= 1e7)
5904  {
5905  log_density = 7.;
5906  }
5907  else
5908  {
5909  log_density = log10(dense.gas_phase[ipHYDROGEN]);
5910  }
5911 
5912  f1 = 0.15 * log_density + 0.75;
5913  f2 = -0.5 * log_density + 10.;
5914 
5915  hmi.HeatH2Dish_ELWERT = 0.25 * EN1EV * f1 *
5918  f2 * secondaries.x12tot * EN1EV * hmi.H2_total;
5919 
5920  /*fprintf( ioQQQ, "f1: %.2e, f2: %.2e,heat Solomon: %.2e",f1,f2,hmi.HeatH2Dish_TH85);*/
5921 
5922 
5923  /* heating due to collisional deexcitation within X of H2
5924  * >>chng 05 oct 19, TE, define new approximation for the heating due to the destruction of H2
5925  * use this approximation for the specified cloud parameters, otherwise
5926  * use limiting cases for 1 <= G0, G0 >= 1e7, n >= 1e7, n <= 1 */
5927 
5928  /* set value of k_f4 by testing on value of G0 */
5930  {
5931  log_G0_face = 0.;
5932  }
5933  else if(hmi.UV_Cont_rel2_Draine_DB96_face >= 1e7)
5934  {
5935  log_G0_face = 7.;
5936  }
5937  else
5938  {
5939  log_G0_face = log10(hmi.UV_Cont_rel2_Draine_DB96_face);
5940  }
5941  /* 06 oct 24, TE introduce effects of spherical geometry */
5942  log_G0_face /= radius.r1r0sq;
5943 
5944  /* terms only dependent on G0_face */
5945  k_f4 = -0.25 * log_G0_face + 1.25;
5946 
5947  /* test for density */
5948  if(dense.gas_phase[ipHYDROGEN] <= 1.)
5949  {
5950  log_density = 0.;
5951  f4 = 0.;
5952  }
5953  else if(dense.gas_phase[ipHYDROGEN] >= 1e7)
5954  {
5955  log_density = 7.;
5956  f4 = pow(k_f4,2) * pow( 10. , 2.2211 * log_density - 29.8506);
5957  }
5958  else
5959  {
5960  log_density = log10(dense.gas_phase[ipHYDROGEN]);
5961  f4 = pow(k_f4,2) * pow( 10., 2.2211 * log_density - 29.8506);
5962  }
5963 
5964  f3 = MAX2(0.1, -4.75 * log_density + 24.25);
5965  f5 = MAX2(1.,0.95 * log_density - 1.45) * 0.2 * log_G0_face;
5966 
5967  hmi.HeatH2Dexc_ELWERT = (hmi.Hmolec[ipMH2s]*H2star_deexcit - hmi.Hmolec[ipMH2g]*H2star_excit) * 4.17e-12 * f3 +
5969  f5 * secondaries.x12tot * EN1EV * hmi.H2_total;
5970 
5971  if(log_G0_face == 0.&& dense.gas_phase[ipHYDROGEN] > 1.)
5973 
5974  /* >>chng 06 oct 24, TE introduce effects of spherical geometry */
5975  /*if(radius.depth/radius.rinner >= 1.0) */
5977 
5978  /* this is derivative wrt temperature, only if counted as a cooling source */
5980 
5981  /*fprintf( ioQQQ, "\tf3: %.2e, f4: %.2e, f5: %.2e, heat coll dissoc: %.2e\n",f3,f4,f5,hmi.HeatH2Dexc_TH85);*/
5982  }
5983  /* end Elwert branch for photo rates */
5984  else
5985  TotalInsanity();
5986 
5988  {
5989  deexc_htwo = hmi.Average_collH2_deexcit;
5990  deexc_hneut = hmi.Average_collH_deexcit;
5991  }
5992  else
5993  {
5994  deexc_htwo = (1.4e-12*phycon.sqrte * sexp( 18100./(phycon.te + 1200.) ))/6.;
5995  deexc_hneut = (1e-12*phycon.sqrte * sexp(1000./phycon.te ))/6.;
5996  }
5997 
5998  H2star_deexcit = hmi.H2_total*deexc_htwo + hmi.Hmolec[ipMH] * deexc_hneut;
5999 
6001  {
6003  }
6004  else
6005  {
6006  H2star_excit = Boltz_fac_H2_H2star * H2star_deexcit;
6007  }
6008 
6009  /* Leiden hacks try to turn off H2*, which is all unphysical. do not include heating
6010  * due to H2 deexcitation since H2* is bogus */
6011  /* >>chng 05 aug 12, do not turn off vibrational heating when Leiden hack is in place
6012  * other codes included heating but did not include H2s on chemistry
6013  hmi.HeatH2Dexc_TH85 *= hmi.lgLeiden_Keep_ipMH2s;*/
6014  /*fprintf(ioQQQ,
6015  "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",
6016  fnzone,
6017  hmi.HeatH2Dexc_TH85,
6018  thermal.htot,
6019  hmi.Hmolec[ipMH2s],
6020  H2star_deexcit,
6021  hmi.Hmolec[ipMH2g],
6022  H2star_excit,
6023  Hmolec_old[ipMH2g],
6024  Hmolec_old[ipMH],
6025  phycon.te);*/
6026  }
6027 
6028  {
6029  /* following should be set true to print populations */
6030  enum {DEBUG_LOC=false};
6031  if( DEBUG_LOC )
6032  {
6033  /* these are the raw results */
6034  fprintf( ioQQQ, " HMOLE raw; hi\t%.2e" , dense.xIonDense[ipHYDROGEN][0]);
6035  for( i=0; i < N_H_MOLEC; i++ )
6036  {
6037  fprintf( ioQQQ, "\t%s\t%.2e", hmi.chLab[i], bvec[i] );
6038  }
6039  fprintf( ioQQQ, " \n" );
6040  }
6041  }
6042 
6043  if( trace.lgTrace && trace.lgTr_H2_Mole )
6044  {
6045  /* these are the raw results */
6046  fprintf( ioQQQ, "\n raw; " );
6047  for( i=0; i < N_H_MOLEC; i++ )
6048  {
6049  fprintf( ioQQQ, " %s:%.2e", hmi.chLab[i], bvec[i] );
6050  }
6051  fprintf( ioQQQ, " \n" );
6052  }
6053 
6054  /* >>chng 05 jul 11, TE, each term must have unit cm-3 s-1,
6055  * more terms added */
6067  hmi.eh3_h2h * hmi.Hmolec[ipMH3p] +
6124 
6125  /* option to print rate H2 forms */
6126  /* trace.lgTr_H2_Mole is trace molecules option,
6127  * punch htwo */
6128  if( (trace.lgTrace && trace.lgTr_H2_Mole) )
6129  {
6130 
6131  if( hmi.H2_rate_create > SMALLFLOAT )
6132  {
6133  fprintf( ioQQQ,
6134  " 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",
6143  }
6144  else
6145  {
6146  fprintf( ioQQQ, " Create H2, rate=0\n" );
6147  }
6148  }
6149 
6150  /* this is H2+ */
6151  if( trace.lgTrace && trace.lgTr_H2_Mole )
6152  {
6155  if( rate > 1e-25 )
6156  {
6157  fprintf( ioQQQ, " Create H2+, rate=%10.2e hmi.rh2h2p;%5.3f b2pcin;%5.3f hmi.h3ph2p;%5.3f hmi.h3petc+;%5.3f\n",
6158  rate, hmi.rh2h2p*dense.xIonDense[ipHYDROGEN][1]*hmi.Hmolec[ipMH2g]/rate,
6161  rate );
6162  }
6163  else
6164  {
6165  fprintf( ioQQQ, " Create H2+, rate=0\n" );
6166  }
6167  }
6168 
6169  if( hmi.Hmolec[ipMHm] > 0. && hmi.rel_pop_LTE_Hmin > 0. )
6170  {
6171  hmi.hmidep = (double)hmi.Hmolec[ipMHm]/ SDIV(
6173  }
6174  else
6175  {
6176  hmi.hmidep = 1.;
6177  }
6178 
6179  /* this will be net volume heating rate, photo heat - induc cool */
6181  hmi.h2plus_heat = h2phet*hmi.Hmolec[ipMH2p];
6182 
6183  /* departure coefficient for H2 defined rel to n(1s)**2
6184  * (see Littes and Mihalas Solar Phys 93, 23) */
6185  plte = (double)dense.xIonDense[ipHYDROGEN][0] * hmi.rel_pop_LTE_H2g * (double)dense.xIonDense[ipHYDROGEN][0];
6186  if( plte > 0. )
6187  {
6188  hmi.h2dep = hmi.Hmolec[ipMH2g]/plte;
6189  }
6190  else
6191  {
6192  hmi.h2dep = 1.;
6193  }
6194 
6195  /* departure coefficient of H2+ defined rel to n(1s) n(p)
6196  * sec den was HI before 85.34 */
6197  plte = (double)dense.xIonDense[ipHYDROGEN][0]*hmi.rel_pop_LTE_H2p*(double)dense.xIonDense[ipHYDROGEN][1];
6198  if( plte > 0. )
6199  {
6200  hmi.h2pdep = hmi.Hmolec[ipMH2p]/plte;
6201  }
6202  else
6203  {
6204  hmi.h2pdep = 1.;
6205  }
6206 
6207  /* departure coefficient of H3+ defined rel to N(H2+) N(p) */
6208  if( hmi.rel_pop_LTE_H3p > 0. )
6209  {
6211  }
6212  else
6213  {
6214  hmi.h3pdep = 1.;
6215  }
6216 
6217 
6218  if( trace.lgTrace && trace.lgTr_H2_Mole )
6219  {
6220  fprintf( ioQQQ, " HMOLE, Dep Coef, H-:%10.2e H2:%10.2e H2+:%10.2e\n",
6221  hmi.hmidep, hmi.h2dep, hmi.h2pdep );
6222  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",
6224 
6225  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",
6226  hmi.HMinus_photo_rate, hmi.hmin_ct_firstions*sum_first_ions, cionhm,
6228  fhneut );
6229  fprintf( ioQQQ, " H- heating:%10.3e Ind cooling%10.2e Spon cooling%10.2e\n",
6231  }
6232 
6233  /* identify creation and destruction processes for H2+ */
6234  if( trace.lgTrace && trace.lgTr_H2_Mole )
6235  {
6236  rate = desh2p;
6237  if( rate != 0. )
6238  {
6239  fprintf( ioQQQ,
6240  " 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",
6241  rate, h2pcin*dense.eden/rate, gamtwo/rate, 2.*iso.gamnc[ipH_LIKE][ipHYDROGEN][ipH1s]/
6242  rate, hmi.h2ph3p/rate, h2phhp/rate, h2pion/rate, hmi.bh2h2p*
6243  dense.xIonDense[ipHYDROGEN][0]/rate );
6244 
6245  rate *= hmi.Hmolec[ipMH2p];
6246  if( rate > 0. )
6247  {
6248  fprintf( ioQQQ,
6249  " Create H2+: rate=%.2e HII HI;%.3f Col H2;%.3f HII H2;%.3f HI HI;%.3f\n",
6250  rate,
6251  radath*dense.xIonDense[ipHYDROGEN][1]*dense.xIonDense[ipHYDROGEN][0]/rate,
6252  (hmi.H2_photoionize_rate + secondaries.csupra[ipHYDROGEN][0]*2.02)*hmi.Hmolec[ipMH2g]/rate,
6253  hmi.rh2h2p*dense.xIonDense[ipHYDROGEN][1]*hmi.Hmolec[ipMH2g]/rate,
6254  b2pcin*dense.xIonDense[ipHYDROGEN][0]*dense.xIonDense[ipHYDROGEN][1]*dense.eden/rate );
6255  }
6256  else
6257  {
6258  fprintf( ioQQQ, " Create H2+: rate= is zero\n" );
6259  }
6260  }
6261  }
6262 
6263  {
6264  /* following should be set true to print populations */
6265  enum {DEBUG_LOC=false};
6266  if( DEBUG_LOC )
6267  {
6268  fprintf(ioQQQ,"hmole bugg\t%.3f\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
6269  fnzone,
6272  hmi.Hmolec[ipMH2g] ,
6273  hmi.Hmolec[ipMHm] ,
6274  dense.xIonDense[ipHYDROGEN][1]);
6275  }
6276  }
6277  return;
6278 }
6279 #if defined(__HP_aCC)
6280 #pragma OPTIMIZE OFF
6281 #pragma OPTIMIZE ON
6282 #endif
6283 /*lint +e778 const express eval to 0 */
6284 /*lint +e725 expect positive indentation */

Generated for cloudy by doxygen 1.8.4