cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion_collis.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*ion_collis fill in collisional ionization rates, and resulting cooling */
4 #include "cddefines.h"
5 #include "phycon.h"
6 #include "rfield.h"
7 #include "heavy.h"
8 #include "atmdat_adfa.h"
9 #include "ionbal.h"
10 #include "dense.h"
11 
13  /* element number on c scale, H is 0 */
14  long int nelem )
15 {
16  long int ion,
17  limit;
18  double DimaRate, crate;
19 
20  DEBUG_ENTRY( "ion_collis()" );
21 
22  /* compute collisional ionization rate */
23 
24  /* CollidRate[nelem][ion][0] is collisional ionization rate, s-1
25  * CollidRate[nelem][ion][1] is collisional ionization cooling, erg/s
26  */
27 
28  /* zero out rates below lowest ionization stage we will consider */
29  for( ion=0; ion < (dense.IonLow[nelem] - 1); ion++ )
30  {
31  ionbal.CollIonRate_Ground[nelem][ion][0] = 0.;
32  ionbal.CollIonRate_Ground[nelem][ion][1] = 0.;
33  }
34 
35  /* chng logic changed to be precisely same as ion_solver */
36  /* >>chng 02 nov 08, change 2 to NISO */
37  /*limit = MIN2(nelem-2,dense.IonHigh[nelem]-1);*/
38  limit = MIN2(nelem-NISO,dense.IonHigh[nelem]-1);
39  ASSERT( limit < LIMELM );
40 
41  for( ion=dense.IonLow[nelem]; ion <= limit; ion++ )
42  {
43  //Get the rate coefficients using either Dima or Hybrid
44  DimaRate = t_ADfA::Inst().coll_ion_wrapper( nelem, ion , phycon.te );
45 
46  crate = DimaRate*dense.EdenHCorr;
47 
48  /* total collisional ionization rate
49  * with only thermal suprathermal electrons */
50  ionbal.CollIonRate_Ground[nelem][ion][0] = crate;
51 
52  /* cooling due to collisional ionization, which only includes thermal */
53  ionbal.CollIonRate_Ground[nelem][ion][1] = (crate*
54  rfield.anu(Heavy.ipHeavy[nelem][ion]-1)* EN1RYD);
55  }
56 
57  for( ion=dense.IonHigh[nelem]; ion <= nelem; ion++ )
58  {
59  ionbal.CollIonRate_Ground[nelem][ion][0] = 0.;
60  ionbal.CollIonRate_Ground[nelem][ion][1] = 0.;
61  }
62 
63  /* check not rates are negative - in release mode this loop will optimize out */
64  for( ion=0; ion <= nelem; ion++ )
65  {
66  /* there can be no negative rates */
67  ASSERT( ionbal.CollIonRate_Ground[nelem][ion][0] >= 0. );
68  }
69  return;
70 }
double EdenHCorr
Definition: dense.h:227
t_Heavy Heavy
Definition: heavy.cpp:5
const int NISO
Definition: cddefines.h:311
long int IonHigh[LIMELM+1]
Definition: dense.h:130
t_phycon phycon
Definition: phycon.cpp:6
double coll_ion_wrapper(long int z, long int n, double t)
#define MIN2(a, b)
Definition: cddefines.h:803
double anu(size_t i) const
Definition: mesh.h:120
t_dense dense
Definition: global.cpp:15
static t_ADfA & Inst()
Definition: cddefines.h:209
t_ionbal ionbal
Definition: ionbal.cpp:8
long int IonLow[LIMELM+1]
Definition: dense.h:129
t_rfield rfield
Definition: rfield.cpp:9
void ion_collis(long int nelem)
Definition: ion_collis.cpp:12
double *** CollIonRate_Ground
Definition: ionbal.h:121
#define ASSERT(exp)
Definition: cddefines.h:613
const int LIMELM
Definition: cddefines.h:308
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
double te
Definition: phycon.h:21
long int ipHeavy[LIMELM][LIMELM]
Definition: heavy.h:11