cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cool_eval.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*CoolEvaluate main routine to call others, to evaluate total cooling */
4 #include "cddefines.h"
5 #include "physconst.h"
6 #include "hydrogenic.h"
7 #include "taulines.h"
8 #include "wind.h"
9 #include "coolheavy.h"
10 #include "radius.h"
11 #include "conv.h"
12 #include "h2.h"
13 #include "rt.h"
14 #include "doppvel.h"
15 #include "opacity.h"
16 #include "ionbal.h"
17 #include "dense.h"
18 #include "trace.h"
19 #include "dynamics.h"
20 #include "rfield.h"
21 #include "grainvar.h"
22 #include "atmdat.h"
23 #include "atoms.h"
24 #include "called.h"
25 #include "mole.h"
26 #include "hmi.h"
27 #include "numderiv.h"
28 #include "magnetic.h"
29 #include "phycon.h"
30 #include "lines_service.h"
31 #include "hyperfine.h"
32 #include "iso.h"
33 #include "thermal.h"
34 #include "cooling.h"
35 #include "pressure.h"
36 /*fndneg search cooling array to find negative values */
37 STATIC void fndneg(void);
38 /*fndstr search cooling stack to find strongest values */
39 STATIC void fndstr(double tot,
40  double dc);
41 
42 /* set true to debug derivative of heating and cooling */
43 static const bool PRT_DERIV = false;
44 
45 void CoolEvaluate(double *tot)
46 {
47  static long int nhit = 0,
48  nzSave=0;
49 
50  static double TeEvalCS = 0., TeEvalCS_21cm=0.;
51  static double TeUsedBrems=-1.f;
52  static int nzoneUsedBrems=-1;
53 
54  static double electron_rate_21cm,
55  atomic_rate_21cm,
56  proton_rate_21cm;
57 
58  double
59  cs ,
60  deriv,
61  factor,
62  qn,
63  rothi=-SMALLFLOAT,
64  rotlow=-SMALLFLOAT,
65  x;
66 
67  static double oltcool=0.,
68  oldtemp=0.;
69 
70  long int coolnum, coolcal;
71 
72  DEBUG_ENTRY( "CoolEvaluate()" );
73 
74  /* returns tot, the total cooling,
75  * and dc, the derivative of the cooling */
76 
77  /* routine atom_level2( t10 )
78  * routine atom_level3( abund , t10,t21,t20)
79  * tsq1 = 1. / (te**2)
80  * POPEXC( O12,g1,g2,A21,excit,abund); result already*a21
81  * POP3(G1,G2,G3,O12,O13,O23,A21,A31,A32,E12,E23,P2,ABUND,GAM2)
82  * AtomSeqBeryllium(cs23,cs24,cs34,tarray,a41)
83  * FIVEL( G(1-5) , ex(wn,1-5), cs12,cs13,14,15,23,24,25,34,35,45,
84  * A21,31,41,51,32,42,52,43,53,54, pop(1-5), abund) */
85 
86  if( trace.lgTrace )
87  fprintf( ioQQQ, " COOLR TE:%.4e zone %li %li Cool:%.4e Heat:%.4e eden:%.4e edenTrue:%.4e\n",
88  phycon.te,
91 
92  /* must call TempChange since ionization has changed, there are some
93  * terms that affect collision rates (H0 term in electron collision) */
94  TempChange(phycon.te , false);
95 
96  /* now zero out the cooling stack */
97  CoolZero();
98  if( PRT_DERIV )
99  fprintf(ioQQQ,"DEBUG dCdT 0 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
100  if( gv.lgGrainPhysicsOn )
101  {
102  /* grain heating and cooling */
103  /* grain recombination cooling, evaluated elsewhere
104  * can either heat or cool the gas, do cooling here */
105  CoolAdd("dust",0,MAX2(0.,gv.GasCoolColl));
106 
107  /* grain cooling proportional to temperature ^3/2 */
108  thermal.dCooldT += MAX2(0.,gv.GasCoolColl)*3./(2.*phycon.te);
109 
110  /* these are the various heat agents from grains */
111  /* options to force gas heating or cooling by grains to zero - for tests only ! */
112  if( gv.lgDustOn() && gv.lgDHetOn )
113  {
114  /* rate dust heats gas by photoelectric effect */
115  thermal.heating[0][13] = gv.GasHeatPhotoEl;
116 
117  /* if grains hotter than gas then collisions with gas act
118  * to heat the gas, add this in here
119  * a symmetric statement appears in COOLR, where cooling is added on */
120  thermal.heating[0][14] = MAX2(0.,-gv.GasCoolColl);
121 
122  /* this is gas heating due to thermionic emissions */
123  thermal.heating[0][25] = gv.GasHeatTherm;
124  }
125  else
126  {
127  thermal.heating[0][13] = 0.;
128  thermal.heating[0][14] = 0.;
129  thermal.heating[0][25] = 0.;
130  }
131  }
132  else if( gv.lgBakesPAH_heat )
133  {
134  /* >>chng 06 jul 21, option to include Bakes PAH hack with grain physics off,
135  * needed to test dynamics models */
136  thermal.heating[0][13] = gv.GasHeatPhotoEl;
137  }
138 
139  if( PRT_DERIV )
140  fprintf(ioQQQ,"DEBUG dCdT 1 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
141 
142  /* molecular molecules molecule cooling */
143  if( mole_global.lgNoMole )
144  {
145  /* this branch - do not include molecules */
146  hmi.hmicol = 0.;
148  /* line cooling within simple H2 molecule - zero when big used */
149  CoolHeavy.h2line = 0.;
150  /* H + H+ => H2+ cooling */
151  CoolHeavy.H2PlsCool = 0.;
152  CoolHeavy.HD = 0.;
153 
154  /* thermal.heating[0][8] is heating due to collisions within X of H2 */
155  thermal.heating[0][8] = 0.;
156  /* thermal.heating[0][15] is H minus heating*/
157  thermal.heating[0][15] = 0.;
158  /* thermal.heating[0][16] is H2+ heating */
159  thermal.heating[0][16] = 0.;
160  hmi.HeatH2Dish_used = 0.;
161  hmi.HeatH2Dexc_used = 0.;
163  }
164 
165  else
166  {
167  /* save various molecular heating/cooling agent */
168  thermal.heating[0][15] = hmi.hmihet;
169  thermal.heating[0][16] = hmi.h2plus_heat;
170  /* now get heating from H2 molecule, either simple or from big one */
172  {
173  if( h2.lgEvaluated )
174  {
175  /* these are explicitly from big H2 molecule,
176  * first is heating due to radiative pump of excited states, followed by
177  * radiative decay into continuum of X, followed by dissociation of molecule
178  * with kinetic energy, typically 0.25 - 0.5 eV per event */
181  if (0)
182  fprintf(ioQQQ,"DEBUG big %.2f\t%.5e\t%.2e\t%.2e\t%.2e\n",
185  /* negative sign because right term is really deriv of heating,
186  * but will be used below as deriv of cooling */
188  }
189  else
190  {
191  hmi.HeatH2Dish_used = 0;
192  hmi.HeatH2Dexc_used = 0;
194  }
195  }
196 
197  else if( hmi.chH2_small_model_type == 'T' )
198  {
199  /* TH85 dissociation heating */
200  /* these come from approximations in TH85, see comments above */
204  }
205  else if( hmi.chH2_small_model_type == 'H' )
206  {
207  /* Burton et al. 1990 */
211  }
212  else if( hmi.chH2_small_model_type == 'B')
213  {
214  /* Bertoldi & Draine */
218  }
219  else if(hmi.chH2_small_model_type == 'E')
220  {
221  /* this is the default when small H2 used */
225  }
226  else
227  TotalInsanity();
228 
229  /* heating due to photodissociation heating */
231 
232  /* heating due to continuum photodissociation */
233  thermal.heating[0][28] = 0.;
234  for( diatom_iter diatom = diatoms.begin(); diatom != diatoms.end(); ++diatom )
235  {
236  if( (*diatom)->lgEnabled && mole_global.lgStancil )
237  thermal.heating[0][28] += (*diatom)->Cont_Diss_Heat_Rate();
238  }
239 
240  /* heating (usually cooling in big H2) due to collisions within X */
241  /* add to heating is net heating is positive */
242  thermal.heating[0][8] = MAX2(0.,hmi.HeatH2Dexc_used);
243 
244  /* add to cooling if net heating is negative */
245  CoolAdd("H2cX",0,MAX2(0.,-hmi.HeatH2Dexc_used));
246  /*fprintf(ioQQQ,"DEBUG coolh2\t%.2f\t%.4e\t%.4e\t%.4e\t%.4e\t%.4e\n",
247  fnzone, phycon.te, dense.eden, hmi.H2_total, thermal.ctot, -hmi.HeatH2Dexc_used );*/
248  /* add to net derivative */
249  /*thermal.dCooldT += MAX2(0.,-hmi.HeatH2Dexc_used)* ( 30172. * thermal.tsq1 - thermal.halfte );*/
250  /* >>chng 04 jan 25, check sign to prevent cooling from entering here,
251  * also enter neg sign since going into cooling stack (bug), in heatsum
252  * same term adds to deriv of heating */
253  if( hmi.HeatH2Dexc_used < 0. )
255 
256  /* H + H+ => H2+ cooling */
257  CoolHeavy.H2PlsCool = (realnum)(MAX2((2.325*phycon.te-1875.)*1e-20,0.)*
259 
260  if( h2.lgEnabled )
261  {
262  /* this is simplified approximation to H2 rotation cooling,
263  * big molecule goes this far better */
264  CoolHeavy.h2line = 0.;
265  }
266  else
267  {
268  /* rate for rotation lines from
269  * >>refer h2 cool Lepp, S., & Shull, J.M. 1983, ApJ, 270, 578 */
270  x = phycon.alogte - 4.;
271  if( phycon.te > 1087. )
272  {
273  rothi = 3.90e-19*sexp(6118./phycon.te);
274  }
275  else
276  {
277  rothi = pow(10.,-19.24 + 0.474*x - 1.247*x*x);
278  }
279 
280  /* low density rotation cooling */
281  /*&qn = pow(MAX2(findspecieslocal("H2")->den,1e-37),0.77) + 1.2*pow(MAX2(dense.xIonDense[ipHYDROGEN][0],1e-37),0.77);*/
282  qn = pow(MAX2(hmi.H2_total,1e-37),0.77) + 1.2*pow(MAX2(dense.xIonDense[ipHYDROGEN][0],1e-37),0.77);
283  /* these are equations 11 from LS83 */
284  if( phycon.te > 4031. )
285  {
286  rotlow = 1.38e-22*sexp(9243./phycon.te)*qn;
287  }
288  else
289  {
290  rotlow = pow(10.,-22.90 - 0.553*x - 1.148*x*x)*qn;
291  }
292 
293  CoolHeavy.h2line = 0.;
294  if( rotlow > 0. )
295  CoolHeavy.h2line += hmi.H2_total*rothi/(1. + rothi/rotlow);
296  /* \todo 1 add this from LS83 or (better yet) update to another form. See Galli & Palla 1998, A5-7. */
297  //if( viblow > 0. )
298  // CoolHeavy.h2line += hmi.H2_total*vibhi/(1. + vibhi/viblow);
299  }
300 
301  {
302  enum {DEBUG_LOC=false};
303  if( DEBUG_LOC && nzone>187&& iteration > 1)
304  {
305  fprintf(ioQQQ,"h2coolbug\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\t%.2e\n",
306  phycon.te,
307  CoolHeavy.h2line,
308  hmi.H2_total,
309  findspecieslocal("H-")->den,
311  rothi,
312  rotlow );
313  }
314  }
315 
316  if( hd.lgEnabled )
317  {
318  CoolHeavy.HD = 0.;
319  }
320  else
321  {
322  /* >>chng 02 mar 07, add DH cooling using rates (eqn 6) from
323  * >>refer HD cooling Puy, D., Grenacher, L, & Jetzer, P., 1999, A&A, 345, 723 */
324  factor = sexp(128.6/phycon.te);
325  CoolHeavy.HD = 2.66e-21 * hydro.D2H_ratio * POW2((double)hmi.H2_total) * phycon.sqrte *
326  factor/(1416.+phycon.sqrte*hmi.H2_total * (1. + 3.*factor));
327  }
328  }
329 
330  fixit(); // test and enable this by default
331 #if 0
332  double chemical_heating = mole.chem_heat();
333  thermal.heating[0][29] = MAX2(0.,chemical_heating);
334  /* add to cooling if net heating is negative */
335  CoolAdd("Chem",0,MAX2(0.,-chemical_heating));
336 #endif
337 
338  /* cooling due to charge transfer ionization / recombination */
339  CoolAdd("CT C" , 0. , thermal.char_tran_cool );
340 
341  /* H- FB; H + e -> H- + hnu */
342  /* H- FF is in with H ff */
343  CoolAdd("H-fb",0,hmi.hmicol);
344 
345  /* >>chng 96 nov 15, fac of 2 in deriv to help convergence in very dense
346  * models where H- is important, this takes change in eden into
347  * partial account */
349  if( PRT_DERIV )
350  fprintf(ioQQQ,"DEBUG dCdT 2 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
351 
352  CoolAdd("H2ln",0,CoolHeavy.h2line);
353  /* >>chng 00 oct 21, added coef of 3.5, sign had been wrong */
354  /*thermal.dCooldT += CoolHeavy.h2line*phycon.teinv;*/
355  /* >>chng 03 mar 17, change 3.5 to 15 as per behavior in primal.in */
356  /*thermal.dCooldT += 3.5*CoolHeavy.h2line*phycon.teinv;*/
357  /* >>chng 03 may 18, from 15 to 30 as per behavior in primal.in - overshoots happen */
358  /*thermal.dCooldT += 15.*CoolHeavy.h2line*phycon.teinv;*/
359  /*>>chng 03 oct 03, from 30 to 3, no more overshoots in primalin */
360  /*thermal.dCooldT += 30.*CoolHeavy.h2line*phycon.teinv;*/
362 
363  {
364  /* problems with H2 cooling */
365  enum {DEBUG_LOC=false};
366  if( DEBUG_LOC /*&& nzone>300 && iteration > 1*/)
367  {
368  fprintf(ioQQQ,"CoolEvaluate debuggg\t%.2f\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\n",
369  fnzone,
370  phycon.te,
371  hmi.H2_total ,
373  findspecieslocal("H-")->den ,
374  dense.eden);
375  }
376  }
377 
378  CoolAdd("HDro",0,CoolHeavy.HD);
380 
381  CoolAdd("H2+ ",0,CoolHeavy.H2PlsCool);
383 
384  /* heating due to three-body, will be incremented in iso_cool*/
385  thermal.heating[0][3] = 0.;
386  /* heating due to hydrogen lines */
387  thermal.heating[0][23] = 0.;
388  /* heating due to photoionization of all excited states of hydrogen species */
389  thermal.heating[0][1] = 0.;
390 
391  /* isoelectronic species cooling, mainly lines, and level ionization */
392  for( long int ipISO=ipH_LIKE; ipISO<NISO; ++ipISO )
393  {
394  for( long int nelem=ipISO; nelem < LIMELM; nelem++ )
395  {
396  /* must always call iso_cool since we must zero those variables
397  * that would have been set had the species been present */
398  iso_cool( ipISO , nelem );
399  }
400  }
401 
402  /* >>chng 02 jun 18, don't reevaluate needlessly */
403  /* >>chng 03 nov 28, even faster - special logic for when ff is pretty
404  * negligible - eval of ff is pretty slow */
405  /* >>chng 04 feb 19, must not test on temp not changing, since ionization
406  * can change at constant temperature
407  * >>chng 04 sep 14, above introduced bug since brems never reevaluated
408  * now test is zone or temp has changed */
410  conv.lgSearch ||
411  !fp_equal(phycon.te,TeUsedBrems) ||
412  nzone != nzoneUsedBrems )
413  {
414  double BremsThisEnergy;
415  /*double OpacityThisIon;*/
416  long int limit;
417  /* free-free free free brems emission for all ions */
418 
419  TeUsedBrems = phycon.te;
420  nzoneUsedBrems = nzone;
421  /* highest frequency where we have non-zero Boltzmann factors */
422  limit = MIN2( rfield.ipMaxBolt , rfield.nflux );
423 
425  CoolHeavy.brems_cool_h = 0.;
429 
430  {
431  double bhfac, bhMinusfac;
432  realnum sumion[LIMELM+1];
433  long int ion_lo , ion_hi;
434 
436  ASSERT(limit < rfield.nupper);
437 
438  /* ipEnergyBremsThin is index to energy where gas becomes optically thin to brems,
439  * so this loop is over optically thin frequencies
440  * do not include optically thick part as net emission since self absorbed */
441 
442  /* do hydrogen first, before main loop since want to break out as separate
443  * coolant, and what to add on H- brems */
444  CoolHeavy.brems_cool_h = 0.;
446  /* this is all done in opacity_addtotal - why do here too? */
447  for( long int i=rfield.ipEnergyBremsThin; i < limit; i++ )
448  {
449  long int ion = 1;
450 
451  /* in all following CoolHeavy.lgFreeOn is flag set with 'no free-free' to
452  * turn off brems heating and cooling */
453  BremsThisEnergy = rfield.gff[ion][i]*rfield.widflx[i]*rfield.ContBoltz[i];
454  /*ASSERT( BremsThisEnergy >= 0. );*/
455  CoolHeavy.brems_cool_h += BremsThisEnergy;
456 
457  /* for case of hydrogen, add H- brems - OpacStack contains the ratio
458  * of the H- to H brems cross section - multiply by this and H(1s) population */
459  CoolHeavy.brems_cool_hminus += BremsThisEnergy * opac.OpacStack[i-1+opac.iphmra];
460  }
462  bhMinusfac = iso_sp[ipH_LIKE][ipHYDROGEN].st[ipH1s].Pop()*CoolHeavy.lgFreeOn* dense.eden*1.032e-11/phycon.sqrte*EN1RYD;
463  CoolHeavy.brems_cool_h *= bhfac;
464  CoolHeavy.brems_cool_hminus *= bhMinusfac;
465 
466  /* now do helium, both He+ and He++ */
468  for( long int i=rfield.ipEnergyBremsThin; i < limit; i++ )
469  {
470  long int nelem = ipHELIUM;
471  /* eff. charge is ion, so first rfield.gff argument must be "ion". */
472  BremsThisEnergy =
473  (dense.xIonDense[nelem][1]*rfield.gff[1][i] + 4.*dense.xIonDense[nelem][2]*rfield.gff[2][i])*
475  CoolHeavy.brems_cool_he += BremsThisEnergy;
476  }
479 
480  /* >>chng 05 jul 13, rewrite this for speed */
481  /* gaunt factors depend only on photon energy and ion charge, so do
482  * sum of ions here before entering into loop over photon energy */
483  sumion[0] = 0.;
484  for( long int ion=1; ion<=LIMELM; ++ion )
485  {
486  sumion[ion] = 0.;
487  for( long int nelem=ipLITHIUM; nelem < LIMELM; ++nelem )
488  {
489  if( dense.lgElmtOn[nelem] && ion<=nelem+1 )
490  {
491  sumion[ion] += dense.xIonDense[nelem][ion];
492  }
493  }
494  /* now include the charge, density, and temperature */
495  sumion[ion] *= POW2((realnum)ion);
496  }
497 
498  /* add molecular ions */
499  for( long ipMol = 0; ipMol<mole_global.num_calc; ipMol++ )
500  {
501  ASSERT( (mole_global.list[ipMol]->n_nuclei() != 1) ==
502  (!mole_global.list[ipMol]->isMonatomic()));
503 
504  if( !mole_global.list[ipMol]->isMonatomic() &&
505  mole_global.list[ipMol]->parentLabel.empty() &&
506  mole_global.list[ipMol]->charge > 0 &&
507  mole_global.list[ipMol]->label != "H2+" &&
508  mole_global.list[ipMol]->label != "H3+" )
509  {
510  ASSERT( mole_global.list[ipMol]->charge < LIMELM+1 );
511  sumion[mole_global.list[ipMol]->charge] += (realnum)mole.species[ipMol].den * POW2((realnum)mole_global.list[ipMol]->charge);
512  }
513  }
514 
515  /* now find lowest and highest ion we need to consider - following loop is over
516  * full continuum and eats time
517  * >>chng 05 oct 19, bounds check had been on ion, rather than ion_lo and ion_hi, so
518  * array bounds were exceeded */
519  ion_lo = 1;
520  while( sumion[ion_lo]==0 && ion_lo<LIMELM-1 )
521  ++ion_lo;
522  ion_hi = LIMELM;
523  while( sumion[ion_hi]==0 && ion_hi>0 )
524  --ion_hi;
525 
526  /* heavy elements */
529  for( long int i=rfield.ipEnergyBremsThin; i < limit; i++ )
530  {
531  BremsThisEnergy = 0.;
532  for(long int ion=ion_lo; ion<=ion_hi; ++ion )
533  BremsThisEnergy += sumion[ion]*rfield.gff[ion][i];
534 
535  CoolHeavy.brems_cool_metals += BremsThisEnergy*rfield.widflx[i]*rfield.ContBoltz[i];
536  /* the total heating due to bremsstrahlung */
538  }
541 
542  {
543  enum {DEBUG_LOC=false};
544  if( DEBUG_LOC && nzone>60 /*&& iteration > 1*/)
545  {
546  double sumfield = 0., sumtot=0., sum1=0., sum2=0.;
547  for( long int i=rfield.ipEnergyBremsThin; i<limit; i++ )
548  {
549  sumtot += opac.FreeFreeOpacity[i]*rfield.flux[0][i]*rfield.anu[i];
550  sumfield += rfield.flux[0][i]*rfield.anu[i];
551  sum1 += opac.FreeFreeOpacity[i]*rfield.flux[0][i]*rfield.anu[i];
552  sum2 += opac.FreeFreeOpacity[i]*rfield.flux[0][i];
553  }
554  fprintf(ioQQQ,"DEBUG brems heat\t%.2f\t%.3e\t%.3e\t%.3e\t%e\t%.3e\t%.3e\n",
555  fnzone,
557  sumtot/SDIV(sumfield) ,
558  sum1/SDIV(sum2),
559  phycon.te ,
560  rfield.gff[1][1218],
561  opac.FreeFreeOpacity[1218]);
562  }
563  }
564  }
565  }
566 
567  /* these two terms are both large, nearly canceling, near lte */
574  /*fprintf(ioQQQ,"DEBUG brems\t%.2f\t%.4e\t%.4e\t%.4e\t%.4e\t%.4e\t%.4e\t%.4e\n",
575  fnzone,
576  phycon.te,
577  CoolHeavy.brems_cool_net,
578  CoolHeavy.brems_cool_h ,
579  CoolHeavy.brems_cool_he ,
580  CoolHeavy.brems_cool_hminus,
581  CoolHeavy.brems_cool_metals ,
582  CoolHeavy.brems_heat_total);*/
583 
584  /* net free free brems cooling, count as cooling if positive */
585  CoolAdd( "FF c" , 0, MAX2(0.,CoolHeavy.brems_cool_net) );
586 
587  /* now stuff into heating array if negative */
589 
590  /* >>chng 96 oct 30, from HFFNet to just FreeFreeCool,
591  * since HeatSum picks up CoolHeavy.brems_heat_total */
593  if( PRT_DERIV )
594  fprintf(ioQQQ,"DEBUG dCdT 3 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
595 
596  /* >>chng 02 jun 21, net cooling already includes this */
597  /* end of brems cooling */
598 
599  /* heavy element recombination cooling, do not count hydrogenic since
600  * already done above, also helium singlets have been done */
601  /* >>chng 02 jul 21, put in charge dependent rec term */
602  CoolHeavy.heavfb = 0.;
603  for( long int nelem=ipLITHIUM; nelem < LIMELM; nelem++ )
604  {
605  if( dense.lgElmtOn[nelem] )
606  {
607  /* note that detailed iso seq atoms are done in iso_cool */
608  long limit_lo = MAX2( 1 , dense.IonLow[nelem] );
609  long limit_hi = MIN2( nelem-NISO+1, dense.IonHigh[nelem] );
610  for( long int ion=limit_lo; ion<=limit_hi; ++ion )
611  {
612  /* factor of 0.9 is roughly correct for nebular conditions, see
613  * >>refer H rec cooling LaMothe, J., & Ferland, G.J., 2001, PASP, 113, 165 */
614  /* note that ionbal.RR_rate_coef_used is the rate coef, cm3 s-1, needs eden */
615  /* >>chng 02 nov 07, move rec arrays around, this now has ONLY rad rec,
616  * previously had included grain rec and three body */
617  /* recombination cooling for iso-seq atoms are done in iso_cool */
618  double one = dense.xIonDense[nelem][ion] * ionbal.RR_rate_coef_used[nelem][ion-1]*
620  /*fprintf(ioQQQ,"debugggfb\t%li\t%li\t%.3e\t%.3e\t%.3e\n", nelem, ion, one,
621  dense.xIonDense[nelem][ion] , ionbal.RR_rate_coef_used[nelem][ion]);*/
622  CoolHeavy.heavfb += one;
623  }
624  }
625  }
626 
627  /*fprintf(ioQQQ,"debuggg hvFB\t%i\t%.2f\t%.2e\t%.2e\n",iteration, fnzone,CoolHeavy.heavfb, dense.eden);*/
628 
629  CoolAdd("hvFB",0,CoolHeavy.heavfb);
631  if( PRT_DERIV )
632  fprintf(ioQQQ,"DEBUG dCdT 4 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
633 
634  /* electron-electron brems, approx form from
635  * >>refer ee brems Stepney and Guilbert, MNRAS 204, 1269 (1983)
636  * ok for T<10**9 */
637  CoolHeavy.eebrm = POW2(dense.eden*phycon.te*1.84e-21);
638 
639  /* >>chng 97 mar 12, added deriv */
641  CoolAdd("eeff",0,CoolHeavy.eebrm);
642 
643  /* add advective heating and cooling */
644  /* this is cooling due to loss of matter from this region */
645  CoolAdd("adve",0,dynamics.Cool() );
646  /* >>chng02 dec 04, rm factor of 8 in front of dCooldT */
648  /* local heating due to matter moving into this location */
649  thermal.heating[1][5] = dynamics.Heat();
651 
652  /* total Compton cooling */
654  CoolAdd("Comp",0,CoolHeavy.tccool);
656 
657  /* option for "extra" cooling, expressed as power-law in temperature, these
658  * are set with the CEXTRA command */
659  if( thermal.lgCExtraOn )
660  {
661  CoolHeavy.cextxx =
662  (realnum)(thermal.CoolExtra*pow(phycon.te/1e4,(double)thermal.cextpw));
663  }
664  else
665  {
666  CoolHeavy.cextxx = 0.;
667  }
668  CoolAdd("Extr",0,CoolHeavy.cextxx);
669 
670  realnum dDensityDT;
671 
672  /* cooling due to wind expansion, only for winds expansion cooling */
673  if( wind.lgBallistic() )
674  {
675  dDensityDT = -(realnum)(wind.AccelTotalOutward/wind.windv + 2.*wind.windv/
676  radius.Radius);
677  CoolHeavy.expans = -2.5*pressure.PresGasCurr*dDensityDT;
678  }
679  else if( dynamics.lgTimeDependentStatic &&
681  {
682  realnum dens = scalingDensity();
683  dDensityDT =
686  // pdV work term
687  CoolHeavy.expans = -pressure.PresGasCurr*dDensityDT;
688  }
689  else
690  {
691  dDensityDT = 0.;
692  CoolHeavy.expans = 0.;
693  }
694  CoolAdd("Expn",0,CoolHeavy.expans);
696 
697  /* cyclotron cooling */
698  /* coef is 4/3 /8pi /c * vtherm(elec) */
700  CoolAdd("Cycl",0,CoolHeavy.cyntrn);
702 
703  /* heavy element collisional ionization
704  * derivative should be zero since increased coll ion rate
705  * decreases neutral fraction by proportional amount */
706  CoolAdd("Hvin",0,CoolHeavy.colmet);
707 
708  /* evaluate H 21 cm spin changing collisions */
709  coolnum = thermal.ncltot;
710  if( !fp_equal(phycon.te,TeEvalCS_21cm) )
711  {
712  {
713  /* this prints table of rates at points given in original data paper */
714  enum {DEBUG_LOC=false};
715  if( DEBUG_LOC )
716  {
717 # define N21CM_TE 16
718  int n;
719  double teval[N21CM_TE]={2.,5.,10.,20.,50.,100.,200.,500.,1000.,
720  2000.,3000.,5000.,7000.,10000.,15000.,20000.};
721  for( n = 0; n<N21CM_TE; ++n )
722  {
723  fprintf(
724  ioQQQ,"DEBUG 21 cm deex Te=\t%.2e\tH0=\t%.2e\tp=\t%.2e\te=\t%.2e\n",
725  teval[n],
726  H21cm_H_atom( teval[n] ),
727  H21cm_proton( teval[n] ),
728  H21cm_electron( teval[n] ) );
729  }
731 # undef N21CM_TE
732  }
733  }
734  /*only evaluate T dependent part when Te changes, but update
735  * density part below since densities may constantly change */
736  atomic_rate_21cm = H21cm_H_atom( phycon.te );
737  proton_rate_21cm = H21cm_proton( phycon.te );
738  electron_rate_21cm = H21cm_electron( phycon.te );
739  TeEvalCS_21cm = phycon.te;
740  }
741  /* H 21 cm emission/population,
742  * cs will be sum of e cs and H cs converted from rate */
743  cs = (electron_rate_21cm * dense.eden +
744  atomic_rate_21cm * dense.xIonDense[ipHYDROGEN][0] +
745  proton_rate_21cm * dense.xIonDense[ipHYDROGEN][1] ) *
746  3./ dense.cdsqte;
747  PutCS( cs , HFLines[0] );
748 
749  /* fine structure lines */
750  if( !fp_equal(phycon.te,TeEvalCS) )
751  {
752  /* H 21 cm done above, now loop over remaining lines to get collision strengths */
753  for( long int i=1; i < nHFLines; i++ )
754  {
755  cs = HyperfineCS( i );
756  /* now generate the collision strength and put into the line array */
757  PutCS( cs , HFLines[i] );
758  }
759  TeEvalCS = phycon.te;
760  }
761 
762  /* do level pops for H 21 cm which is a special case since Lya pumping in included */
763  RT_line_one( HFLines[0], true,0.f, GetDopplerWidth(dense.AtomicWeight[(*HFLines[0].Hi()).nelem()-1]) );
764  H21_cm_pops();
765  if( PRT_DERIV )
766  fprintf(ioQQQ,"DEBUG dCdT 5 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
767 
768  /* find total cooling due to hyperfine structure lines */
769  hyperfine.cooling_total = HFLines[0].Coll().cool();
770 
771  /* now do level pops for all except 21 cm */
772  for( long int i=1; i < nHFLines; i++ )
773  {
774  /* remember current gas-phase abundance of this isotope */
775  realnum save = dense.xIonDense[(*HFLines[i].Hi()).nelem()-1][(*HFLines[i].Hi()).IonStg()-1];
776 
777  /* bail if no abundance */
778  if( save<=0. )
779  continue;
780 
781  RT_line_one( HFLines[i], true,0.f, GetDopplerWidth(dense.AtomicWeight[(*HFLines[i].Hi()).nelem()-1]) );
782 
783  /* set gas-phase abundance to total times isotope ratio */
784  dense.xIonDense[(*HFLines[i].Hi()).nelem()-1][(*HFLines[i].Hi()).IonStg()-1] *=
786 
787  /* use the collision strength generated above and find pops and cooling */
788  atom_level2( HFLines[i] );
789 
790  /* put the correct gas-phase abundance back in the array */
791  dense.xIonDense[(*HFLines[i].Hi()).nelem()-1][(*HFLines[i].Hi()).IonStg()-1] = save;
792 
793  /* find total cooling due to hyperfine structure lines */
794  hyperfine.cooling_total += HFLines[i].Coll().cool();
795  }
796  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
798 
799  if( PRT_DERIV )
800  fprintf(ioQQQ,"DEBUG dCdT 6 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
801 
802  double xIonDenseSave[LIMELM][LIMELM+1];
804  {
805  for( int nelem=0; nelem < LIMELM; nelem++ )
806  {
807  for( int ion=0; ion<=nelem+1; ++ion )
808  {
809  xIonDenseSave[nelem][ion] = dense.xIonDense[nelem][ion];
810  // zero abundance of species if we are using Chianti for this ion
811  if( dense.lgIonChiantiOn[nelem][ion] || dense.lgIonStoutOn[nelem][ion] )
812  dense.xIonDense[nelem][ion] = 0.;
813  }
814  }
815  }
816 
817  /* Carbon cooling */
818  coolnum = thermal.ncltot;
819  CoolCarb();
820  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
822  if( PRT_DERIV )
823  fprintf(ioQQQ,"DEBUG dCdT C %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
824 
825  /* Nitrogen cooling */
826  coolnum = thermal.ncltot;
827  CoolNitr();
828  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
830  if( PRT_DERIV )
831  fprintf(ioQQQ,"DEBUG dCdT N %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
832 
833  /* Oxygen cooling */
834  coolnum = thermal.ncltot;
835  CoolOxyg();
836  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
838  if( PRT_DERIV )
839  fprintf(ioQQQ,"DEBUG dCdT 7 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
840 
841  /* Neon cooling */
842  coolnum = thermal.ncltot;
843  CoolNeon();
844  if( PRT_DERIV )
845  fprintf(ioQQQ,"DEBUG dCdT Ne %.3e dHdT %.3e\n",thermal.dCooldT
846  , thermal.dHeatdT);
847  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
849 
850  /* Magnesium cooling */
851  coolnum = thermal.ncltot;
852  CoolMagn();
853  if( PRT_DERIV )
854  fprintf(ioQQQ,"DEBUG dCdT 8 %.3e dHdT %.3e\n",thermal.dCooldT
855  , thermal.dHeatdT);
856  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
858 
859  /* Sodium cooling */
860  coolnum = thermal.ncltot;
861  CoolSodi();
862  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
864  if( PRT_DERIV )
865  fprintf(ioQQQ,"DEBUG dCdT Na %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
866 
867  /* Aluminum cooling */
868  coolnum = thermal.ncltot;
869  CoolAlum();
870  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
872  if( PRT_DERIV )
873  fprintf(ioQQQ,"DEBUG dCdT Al %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
874 
875  /* Silicon cooling */
876  coolnum = thermal.ncltot;
877  CoolSili();
878  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
880  if( PRT_DERIV )
881  fprintf(ioQQQ,"DEBUG dCdT 9 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
882 
883  /* Phosphorus */
884  coolnum = thermal.ncltot;
885  CoolPhos();
886  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
888 
889  /* Sulphur cooling */
890  coolnum = thermal.ncltot;
891  CoolSulf();
892  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
894 
895  /* Chlorine cooling */
896  coolnum = thermal.ncltot;
897  CoolChlo();
898  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
900 
901  /* Argon cooling */
902  coolnum = thermal.ncltot;
903  CoolArgo();
904  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
906  if( PRT_DERIV )
907  fprintf(ioQQQ,"DEBUG dCdT 10 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
908 
909  /* Potasium cooling */
910  coolnum = thermal.ncltot;
911  CoolPota();
912  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
914 
915  /* Calcium cooling */
916  coolnum = thermal.ncltot;
917  CoolCalc();
918  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
920 
921  /* Scandium cooling */
922  coolnum = thermal.ncltot;
923  CoolScan();
924  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
926 
927  /* Chromium cooling */
928  coolnum = thermal.ncltot;
929  CoolChro();
930  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
932 
933 
934  /* Iron cooling */
935  coolnum = thermal.ncltot;
936  CoolIron();
937  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
939  if( PRT_DERIV )
940  fprintf(ioQQQ,"DEBUG dCdT 12 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
941 
942  /* Cobalt cooling */
943  coolnum = thermal.ncltot;
944  CoolCoba();
945  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
947 
948  /* Nickel cooling */
949  coolnum = thermal.ncltot;
950  CoolNick();
951  for( coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
953 
954  coolnum = thermal.ncltot;
955 
956  // reset abundances to original values, may have been set zero to protect against old cloudy lines
958  {
959  // this clause, first reset abundances set to zero when Chianti included
960  for( int nelem=0; nelem < LIMELM; nelem++ )
961  {
962  for( int ion=0; ion<=nelem+1; ++ion )
963  {
964  dense.xIonDense[nelem][ion] = xIonDenseSave[nelem][ion];
965  }
966  }
967  }
968 
969  /* opacity project lines Dima Verner added with g-bar approximation */
970  CoolDima();
971 
972  for( int coolcal = coolnum; coolcal < thermal.ncltot; coolcal++ )
973  thermal.dima += thermal.cooling[coolcal];
974 
975  /* do external database lines */
976  dBase_solve();
977 
978  /* Print number of levels for each species */
979  {
980  enum {DEBUG_LOC=false};
981  if( DEBUG_LOC )
982  {
983  static bool lgMustPrintHeader=true;
984  if( lgMustPrintHeader )
985  {
986  lgMustPrintHeader = false;
987  printf("DEBUG Levels\t%s",dBaseSpecies[0].chLabel );
988  for( long ipSpecies=1; ipSpecies<nSpecies; ipSpecies++ )
989  {
990  printf("\t%s",dBaseSpecies[ipSpecies].chLabel );
991  }
992  printf("\n" );
993  printf("DEBUG Max\t%li" ,dBaseSpecies[0].numLevels_max );
994  for( long ipSpecies=1; ipSpecies<nSpecies; ipSpecies++ )
995  {
996  printf( "\t%li" ,dBaseSpecies[ipSpecies].numLevels_max );
997  }
998  printf("\n");
999  }
1000  printf("DEBUG Local\t%li" ,dBaseSpecies[0].numLevels_local );
1001  for( long ipSpecies=1; ipSpecies<nSpecies; ipSpecies++ )
1002  {
1003  printf("\t%li" ,dBaseSpecies[ipSpecies].numLevels_local );
1004  }
1005  printf("\n");
1006  }
1007  }
1008 
1009  /* now add up all the coolants */
1010  CoolSum(tot);
1011  if( PRT_DERIV )
1012  fprintf(ioQQQ,"DEBUG dCdT 14 %.3e dHdT %.3e\n",thermal.dCooldT , thermal.dHeatdT);
1013 
1014  /* negative cooling */
1015  if( *tot <= 0. )
1016  {
1017  fprintf( ioQQQ, " COOLR; cooling is <=0, this is impossible.\n" );
1018  ShowMe();
1020  }
1021 
1022  /* bad derivative */
1023  if( thermal.dCooldT == 0. )
1024  {
1025  fprintf( ioQQQ, " COOLR; cooling slope <=0, this is impossible.\n" );
1026  if( *tot > 0. && dense.gas_phase[ipHYDROGEN] < 1e-4 )
1027  {
1028  fprintf( ioQQQ, " Probably due to very low density.\n" );
1029  }
1030  ShowMe();
1032  }
1033 
1034  if( trace.lgTrace )
1035  {
1036  fndstr(*tot,thermal.dCooldT);
1037  }
1038 
1039  /* lgTSetOn true for constant temperature model */
1040  if( (((((!thermal.lgTemperatureConstant) && *tot < 0.) && called.lgTalk) &&
1041  !conv.lgSearch) && thermal.lgCNegChk) && nzone > 0 )
1042  {
1043  fprintf( ioQQQ,
1044  " NOTE Negative cooling, zone %4ld, =%10.2e coola=%10.2e CHION=%10.2e Te=%10.2e\n",
1045  nzone,
1046  *tot,
1047  iso_sp[ipH_LIKE][ipHYDROGEN].cLya_cool,
1048  iso_sp[ipH_LIKE][ipHYDROGEN].coll_ion,
1049  phycon.te );
1050  fndneg();
1051  }
1052 
1053  /* possibility of getting empirical cooling derivative
1054  * normally false, set true with 'set numerical derivatives' command */
1055  if( NumDeriv.lgNumDeriv )
1056  {
1057  if( ((nzone > 2 && nzone == nzSave) && ! fp_equal( oldtemp, phycon.te )) && nhit > 4 )
1058  {
1059  /* hnit is number of tries on this zone - use to stop numerical problems
1060  * do not evaluate numerical deriv until well into solution */
1061  deriv = (oltcool - *tot)/(oldtemp - phycon.te);
1062  thermal.dCooldT = deriv;
1063  }
1064  else
1065  {
1066  deriv = thermal.dCooldT;
1067  }
1068  if( nzone != nzSave )
1069  nhit = 0;
1070 
1071  nzSave = nzone;
1072  nhit += 1;
1073  oltcool = *tot;
1074  oldtemp = phycon.te;
1075  }
1076  return;
1077 }
1078 
1079 /* */
1080 #ifdef EPS
1081 # undef EPS
1082 #endif
1083 #define EPS 0.01
1084 
1085 /*fndneg search cooling array to find negative values */
1086 STATIC void fndneg(void)
1087 {
1088  long int i;
1089  double trig;
1090 
1091  DEBUG_ENTRY( "fndneg()" );
1092 
1093  trig = fabs(thermal.htot*EPS);
1094  for( i=0; i < thermal.ncltot; i++ )
1095  {
1096  if( thermal.cooling[i] < 0. && fabs(thermal.cooling[i]) > trig )
1097  {
1098  fprintf( ioQQQ, " negative line=%s %.2f fraction of heating=%.3f\n",
1100  thermal.htot );
1101  }
1102 
1103  if( thermal.heatnt[i] > trig )
1104  {
1105  fprintf( ioQQQ, " heating line=%s %.2f fraction of heating=%.3f\n",
1107  thermal.htot );
1108  }
1109  }
1110  return;
1111 }
1112 
1113 /*fndstr search cooling stack to find strongest values */
1114 STATIC void fndstr(double tot,
1115  double dc)
1116 {
1117  char chStrngLab[NCOLNT_LAB_LEN+1];
1118  long int i;
1119  realnum wl;
1120  double str,
1121  strong;
1122 
1123  DEBUG_ENTRY( "fndstr()" );
1124 
1125  strong = 0.;
1126  wl = -FLT_MAX;
1127  for( i=0; i < thermal.ncltot; i++ )
1128  {
1129  if( fabs(thermal.cooling[i]) > strong )
1130  {
1131  /* this is the wavelength of the coolant, 0 for a continuum*/
1132  wl = thermal.collam[i];
1133  /* make sure labels are all valid*/
1134  /*>>chng 06 jun 06, bug fix, assert length was ==4, should be <=NCOLNT_LAB_LEN */
1135  ASSERT( strlen( thermal.chClntLab[i] ) <= NCOLNT_LAB_LEN );
1136  strcpy( chStrngLab, thermal.chClntLab[i] );
1137  strong = fabs(thermal.cooling[i]);
1138  }
1139  }
1140 
1141  str = strong;
1142 
1143  fprintf( ioQQQ,
1144  " fndstr cool: TE=%10.4e Ne=%10.4e C=%10.3e dC/dT=%10.2e ABS(%s %.1f)=%.2e nz=%ld\n",
1145  phycon.te, dense.eden, tot, dc, chStrngLab
1146  , wl, str, nzone );
1147 
1148  /* option for extensive printout of lines */
1149  if( trace.lgCoolTr )
1150  {
1151  realnum ratio;
1152 
1153  /* flag all significant coolants, first zero out the array */
1154  coolpr(ioQQQ,(char*)thermal.chClntLab[0],1,0.,"ZERO");
1155 
1156  /* push all coolants onto the stack */
1157  for( i=0; i < thermal.ncltot; i++ )
1158  {
1159  /* usually positive, although can be neg for coolants that heats,
1160  * only do positive here */
1161  ratio = (realnum)(thermal.cooling[i]/thermal.ctot);
1162  if( ratio >= EPS )
1163  {
1164  /*>>chng 99 jan 27, only cal when ratio is significant */
1165  coolpr(ioQQQ,(char*)thermal.chClntLab[i],thermal.collam[i], ratio,"DOIT");
1166  }
1167  }
1168 
1169  /* complete the printout for positive coolants */
1170  coolpr(ioQQQ,"DONE",1,0.,"DONE");
1171 
1172  /* now do cooling that was counted as a heat source if significant */
1173  if( thermal.heating[0][22]/thermal.ctot > 0.05 )
1174  {
1175  fprintf( ioQQQ,
1176  " All coolant heat greater than%6.2f%% of the total will be printed.\n",
1177  EPS*100. );
1178 
1179  coolpr(ioQQQ,"ZERO",1,0.,"ZERO");
1180  for( i=0; i < thermal.ncltot; i++ )
1181  {
1182  ratio = (realnum)(thermal.heatnt[i]/thermal.ctot);
1183  if( fabs(ratio) >=EPS )
1184  {
1185  coolpr(ioQQQ,(char*)thermal.chClntLab[i],thermal.collam[i],
1186  ratio,"DOIT");
1187  }
1188  }
1189  coolpr(ioQQQ,"DONE",1,0.,"DONE");
1190  }
1191  }
1192  return;
1193 }
void CoolAdd(const char *chLabel, realnum lambda, double cool)
Definition: cool_etc.cpp:13
#define MIN2
Definition: cddefines.h:765
double cdsqte
Definition: dense.h:235
realnum ** gff
Definition: rfield.h:227
void CoolNitr(void)
Definition: cool_nitr.cpp:119
t_mole_global mole_global
Definition: mole.cpp:6
double hmicol
Definition: hmi.h:24
bool lgBakesPAH_heat
Definition: grainvar.h:475
bool lgStancil
Definition: mole.h:289
double Radius
Definition: radius.h:22
realnum * widflx
Definition: rfield.h:65
char chClntLab[NCOLNT][NCOLNT_LAB_LEN+1]
Definition: thermal.h:92
t_atmdat atmdat
Definition: atmdat.cpp:6
double HMinus_photo_rate
Definition: hmi.h:42
void CoolNeon(void)
Definition: cool_neon.cpp:17
t_thermal thermal
Definition: thermal.cpp:5
const int ipMAGNESIUM
Definition: cddefines.h:320
void CoolChro(void)
Definition: cool_chro.cpp:14
double * OpacStack
Definition: opacity.h:151
void coolpr(FILE *io, const char *chLabel, realnum lambda, double ratio, const char *chJOB)
Definition: cool_pr.cpp:9
qList st
Definition: iso.h:453
double Cool()
Definition: dynamics.cpp:2182
void CoolAlum(void)
Definition: cool_alum.cpp:15
double hmihet
Definition: hmi.h:24
long int ipEnergyBremsThin
Definition: rfield.h:245
NORETURN void TotalInsanity(void)
Definition: service.cpp:886
realnum CoolExtra
Definition: thermal.h:132
t_opac opac
Definition: opacity.cpp:5
int num_calc
Definition: mole.h:314
realnum ** flux
Definition: rfield.h:86
double expans
Definition: coolheavy.h:9
#define N21CM_TE
void CoolChlo(void)
Definition: cool_chlo.cpp:14
const int ipARGON
Definition: cddefines.h:326
t_hyperfine hyperfine
Definition: hyperfine.cpp:5
double cooling_total
Definition: hyperfine.h:53
bool lgStoutOn
Definition: atmdat.h:241
const realnum SMALLFLOAT
Definition: cpu.h:178
const int NISO
Definition: cddefines.h:265
double H21cm_H_atom(double temp)
double GasCoolColl
Definition: grainvar.h:544
double HeatH2Dish_BD96
Definition: hmi.h:129
double HeatDexc_deriv
Definition: h2_priv.h:289
const int ipOXYGEN
Definition: cddefines.h:316
const int ipCHLORINE
Definition: cddefines.h:325
#define MAX2
Definition: cddefines.h:786
double ctot
Definition: thermal.h:110
t_magnetic magnetic
Definition: magnetic.cpp:17
long int ipMaxBolt
Definition: rfield.h:249
bool lgTimeDependentStatic
Definition: dynamics.h:96
bool lgCExtraOn
Definition: thermal.h:131
void RT_line_one(const TransitionProxy &t, bool lgShield_this_zone, realnum pestrk, realnum DopplerWidth)
t_conv conv
Definition: conv.cpp:5
void CoolCarb(void)
Definition: cool_carb.cpp:22
double char_tran_cool
Definition: thermal.h:146
TransitionList HFLines("HFLines",&AnonStates)
bool lgEvaluated
Definition: h2_priv.h:307
double brems_cool_he
Definition: coolheavy.h:117
t_phycon phycon
Definition: phycon.cpp:6
void CoolEvaluate(double *tot)
Definition: cool_eval.cpp:45
t_dense dense
Definition: dense.cpp:24
void CoolOxyg(void)
Definition: cool_oxyg.cpp:24
sys_float sexp(sys_float x)
Definition: service.cpp:914
t_CoolHeavy CoolHeavy
Definition: coolheavy.cpp:5
const int ipCOBALT
Definition: cddefines.h:335
double pressure
Definition: magnetic.h:33
static const bool PRT_DERIV
Definition: cool_eval.cpp:43
FILE * ioQQQ
Definition: cddefines.cpp:7
molezone * findspecieslocal(const char buf[])
double h2plus_heat
Definition: hmi.h:39
long int nzone
Definition: cddefines.cpp:14
double HeatH2Dexc_used
Definition: hmi.h:129
double HeatH2Dish_TH85
Definition: hmi.h:129
bool lgTalk
Definition: called.h:12
t_dynamics dynamics
Definition: dynamics.cpp:44
const int ipNICKEL
Definition: cddefines.h:336
double eebrm
Definition: coolheavy.h:9
long int nSpecies
Definition: taulines.cpp:21
void TempChange(double TempNew, bool lgForceUpdate)
Definition: temp_change.cpp:51
realnum deriv_HeatH2Dexc_ELWERT
Definition: hmi.h:145
double tccool
Definition: coolheavy.h:9
#define EPS
Definition: cool_eval.cpp:1083
const int ipSULPHUR
Definition: cddefines.h:324
double xIonDense[LIMELM][LIMELM+1]
Definition: dense.h:125
void CoolPota(void)
Definition: cool_pota.cpp:11
bool lgNumDeriv
Definition: numderiv.h:9
double brems_cool_net
Definition: coolheavy.h:117
long int iphmra
Definition: opacity.h:210
void CoolIron(void)
Definition: cool_iron.cpp:494
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:8
double Heat()
Definition: dynamics.cpp:2168
long int nupper
Definition: rfield.h:46
double heatnt[NCOLNT]
Definition: thermal.h:88
Wind wind
Definition: wind.cpp:5
realnum deriv_HeatH2Dexc_TH85
Definition: hmi.h:145
double H21cm_proton(double temp)
void CoolSum(double *total)
Definition: cool_etc.cpp:76
bool lgTemperatureConstant
Definition: thermal.h:32
long int iteration
Definition: cddefines.cpp:16
double heating[LIMELM][LIMELM]
Definition: thermal.h:158
bool lgSearch
Definition: conv.h:175
t_trace trace
Definition: trace.cpp:5
bool fp_equal(sys_float x, sys_float y, int n=3)
Definition: cddefines.h:816
realnum collam[NCOLNT]
Definition: thermal.h:87
double H21cm_electron(double temp)
bool lgBallistic(void) const
Definition: wind.h:31
realnum H2PlsCool
Definition: coolheavy.h:139
double dima
Definition: thermal.h:98
t_ionbal ionbal
Definition: ionbal.cpp:5
bool lgIonChiantiOn[LIMELM][LIMELM+1]
Definition: dense.h:128
double chem_heat(void) const
const int ipIRON
Definition: cddefines.h:334
void CoolZero(void)
Definition: cool_etc.cpp:50
double cooling[NCOLNT]
Definition: thermal.h:88
double dHeatdT
Definition: thermal.h:149
void CoolDima(void)
Definition: cool_dima.cpp:25
#define POW2
Definition: cddefines.h:933
void iso_cool(long ipISO, long nelem)
void PutCS(double cs, const TransitionProxy &t)
Definition: transition.cpp:317
STATIC void fndneg(void)
Definition: cool_eval.cpp:1086
const int ipH1s
Definition: iso.h:27
double HeatH2Dish_used
Definition: hmi.h:129
long int nPres2Ioniz
Definition: conv.h:152
double GasHeatTherm
Definition: grainvar.h:544
bool lgChiantiOn
Definition: atmdat.h:231
#define STATIC
Definition: cddefines.h:101
bool lgTrace
Definition: trace.h:12
realnum deriv_HeatH2Dexc_BD96
Definition: hmi.h:145
long int ncltot
Definition: thermal.h:90
bool lgEnabled
Definition: h2_priv.h:342
const int ipSCANDIUM
Definition: cddefines.h:329
double brems_cool_h
Definition: coolheavy.h:117
double teinv
Definition: phycon.h:23
t_mole_local mole
Definition: mole.cpp:7
double cmcool
Definition: rfield.h:291
t_pressure pressure
Definition: pressure.cpp:5
t_rfield rfield
Definition: rfield.cpp:8
void dBase_solve(void)
Definition: species2.cpp:33
double HyperfineCS(long i)
long int IonHigh[LIMELM+1]
Definition: dense.h:120
double cextxx
Definition: coolheavy.h:9
double timestep
Definition: dynamics.h:181
void CoolSili(void)
Definition: cool_sili.cpp:16
float realnum
Definition: cddefines.h:107
valarray< class molezone > species
Definition: mole.h:355
double dHeatdT
Definition: dynamics.h:63
#define EXIT_FAILURE
Definition: cddefines.h:144
realnum AccelTotalOutward
Definition: wind.h:52
realnum cextpw
Definition: thermal.h:132
const int ipPHOSPHORUS
Definition: cddefines.h:323
void CoolScan(void)
Definition: cool_scan.cpp:12
vector< diatomics * > diatoms
Definition: h2.cpp:8
realnum AtomicWeight[LIMELM]
Definition: dense.h:75
bool lgElmtOn[LIMELM]
Definition: dense.h:146
t_hydro hydro
Definition: hydrogenic.cpp:5
#define cdEXIT(FAIL)
Definition: cddefines.h:438
const int ipNEON
Definition: cddefines.h:318
const int ipCHROMIUM
Definition: cddefines.h:332
double brems_heat_total
Definition: coolheavy.h:117
double * ContBoltz
Definition: rfield.h:145
bool lgGrainPhysicsOn
Definition: grainvar.h:475
diatomics h2("h2", 4100.,&hmi.H2_total, Yan_H2_CS)
realnum GetDopplerWidth(realnum massAMU)
double HeatH2Dexc_TH85
Definition: hmi.h:129
double HeatH2Dexc_BHT90
Definition: hmi.h:129
double PresGasCurr
Definition: pressure.h:86
species * dBaseSpecies
Definition: taulines.cpp:14
const double EN1RYD
Definition: physconst.h:179
bool lgCoolTr
Definition: trace.h:112
realnum HeatCoolRelErrorAllowed
Definition: conv.h:278
double heavfb
Definition: coolheavy.h:9
static bool lgMustPrintHeader
Definition: save_line.cpp:287
t_radius radius
Definition: radius.cpp:5
double brems_cool_hminus
Definition: coolheavy.h:117
void CoolArgo(void)
Definition: cool_argo.cpp:15
bool lgCNegChk
Definition: thermal.h:102
void CoolCalc(void)
Definition: cool_calc.cpp:19
double GasHeatPhotoEl
Definition: grainvar.h:544
double HeatDexc
Definition: h2_priv.h:287
realnum gas_phase[LIMELM]
Definition: dense.h:71
const int ipSILICON
Definition: cddefines.h:322
double HeatH2Dish_ELWERT
Definition: hmi.h:129
double brems_cool_metals
Definition: coolheavy.h:117
long int IonLow[LIMELM+1]
Definition: dense.h:119
#define ASSERT(exp)
Definition: cddefines.h:582
void CoolPhos(void)
Definition: cool_phos.cpp:13
double HeatDiss
Definition: h2_priv.h:286
double * anu
Definition: rfield.h:58
bool lgIonStoutOn[LIMELM][LIMELM+1]
Definition: dense.h:131
double HeatH2Dish_BHT90
Definition: hmi.h:129
const int ipALUMINIUM
Definition: cddefines.h:321
const int ipCALCIUM
Definition: cddefines.h:328
const int ipNITROGEN
Definition: cddefines.h:315
double htot
Definition: thermal.h:149
bool lgDHetOn
Definition: grainvar.h:485
char chH2_small_model_type
Definition: hmi.h:168
realnum deriv_HeatH2Dexc_BHT90
Definition: hmi.h:145
const int ipH_LIKE
Definition: iso.h:62
const int LIMELM
Definition: cddefines.h:262
t_NumDeriv NumDeriv
Definition: numderiv.cpp:5
double den
Definition: mole.h:396
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:688
realnum scalingDensity(void)
Definition: dense.cpp:378
const int ipHELIUM
Definition: cddefines.h:310
double * FreeFreeOpacity
Definition: opacity.h:117
bool lgH2_Thermal_BigH2
Definition: hmi.h:160
void atom_level2(const TransitionProxy &t)
Definition: atom_level2.cpp:17
double dCooldT()
Definition: dynamics.cpp:2197
double H2_total
Definition: hmi.h:16
#define NCOLNT_LAB_LEN
Definition: thermal.h:91
diatomics hd("hd", 4100.,&hmi.HD_total, Yan_H2_CS)
double eden
Definition: dense.h:190
double EdenTrue
Definition: dense.h:221
void CoolNick(void)
Definition: cool_nick.cpp:12
double HeatH2Dexc_ELWERT
Definition: hmi.h:129
long int nHFLines
Definition: taulines.cpp:31
MoleculeList list
Definition: mole.h:317
realnum deriv_HeatH2Dexc_used
Definition: hmi.h:145
const double BOLTZMANN
Definition: physconst.h:97
void CoolSodi(void)
Definition: cool_sodi.cpp:13
sys_float SDIV(sys_float x)
Definition: cddefines.h:956
double alogte
Definition: phycon.h:82
void CoolSulf(void)
Definition: cool_sulf.cpp:20
long int n_initial_relax
Definition: dynamics.h:126
double dCooldT
Definition: thermal.h:119
const int ipCARBON
Definition: cddefines.h:314
void CoolMagn(void)
Definition: cool_magn.cpp:14
double halfte
Definition: thermal.h:122
realnum Upstream_density
Definition: dynamics.h:169
double sqrte
Definition: phycon.h:48
STATIC void fndstr(double tot, double dc)
Definition: cool_eval.cpp:1114
GrainVar gv
Definition: grainvar.cpp:5
t_hmi hmi
Definition: hmi.cpp:5
double fnzone
Definition: cddefines.cpp:15
void ShowMe(void)
Definition: service.cpp:181
t_save save
Definition: save.cpp:5
double te
Definition: phycon.h:11
bool lgNoMole
Definition: mole.h:277
double D2H_ratio
Definition: hydrogenic.h:98
double h2line
Definition: coolheavy.h:9
bool lgDustOn() const
Definition: grainvar.h:471
const int ipHYDROGEN
Definition: cddefines.h:309
void fixit(void)
Definition: service.cpp:991
double elementcool[LIMELM+1]
Definition: thermal.h:95
bool lgFreeOn
Definition: coolheavy.h:116
long int nflux
Definition: rfield.h:43
const int ipLITHIUM
Definition: cddefines.h:311
double cyntrn
Definition: coolheavy.h:9
double HD
Definition: coolheavy.h:9
void H21_cm_pops(void)
const int ipPOTASSIUM
Definition: cddefines.h:327
realnum windv
Definition: wind.h:18
double HeatH2Dexc_BD96
Definition: hmi.h:129
t_called called
Definition: called.cpp:5
vector< diatomics * >::iterator diatom_iter
Definition: h2.h:13
const int ipSODIUM
Definition: cddefines.h:319
void CoolCoba(void)
Definition: cool_coba.cpp:10
double ** RR_rate_coef_used
Definition: ionbal.h:212
const double PI8
Definition: physconst.h:38
realnum * HFLabundance
Definition: hyperfine.h:44
double colmet
Definition: coolheavy.h:9