cloudy trunk
Loading...
Searching...
No Matches
ion_collis.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/*ion_collis fill in collisional ionization rates, and resulting cooling */
4#include "cddefines.h"
5#include "physconst.h"
6#include "phycon.h"
7#include "rfield.h"
8#include "heavy.h"
9#include "dense.h"
10#include "atmdat.h"
11#include "ionbal.h"
12
14 /* element number on c scale, H is 0 */
15 long int nelem )
16{
17 long int ion,
18 limit;
19 double DimaRate, crate;
20
21 DEBUG_ENTRY( "ion_collis()" );
22
23 /* compute collisional ionization rate */
24
25 /* CollidRate[nelem][ion][0] is collisional ionization rate, s-1
26 * CollidRate[nelem][ion][1] is collisional ionization cooling, erg/s
27 */
28
29 /* zero out rates below lowest ionization stage we will consider */
30 for( ion=0; ion < (dense.IonLow[nelem] - 1); ion++ )
31 {
32 ionbal.CollIonRate_Ground[nelem][ion][0] = 0.;
33 ionbal.CollIonRate_Ground[nelem][ion][1] = 0.;
34 }
35
36 /* chng logic changed to be precisely same as ion_solver */
37 /* >>chng 02 nov 08, change 2 to NISO */
38 /*limit = MIN2(nelem-2,dense.IonHigh[nelem]-1);*/
39 limit = MIN2(nelem-NISO,dense.IonHigh[nelem]-1);
40 ASSERT( limit < LIMELM );
41
42 for( ion=dense.IonLow[nelem]; ion <= limit; ion++ )
43 {
44 //Get the rate coefficients using either Dima or Hybrid
45 DimaRate = t_ADfA::Inst().coll_ion_wrapper( nelem, ion , phycon.te );
46
47 crate = DimaRate*dense.EdenHCorr;
48
49 /* total collisional ionization rate
50 * with only thermal suprathermal electrons */
51 ionbal.CollIonRate_Ground[nelem][ion][0] = crate;
52
53 /* cooling due to collisional ionization, which only includes thermal */
54 ionbal.CollIonRate_Ground[nelem][ion][1] = (crate*
55 rfield.anu[Heavy.ipHeavy[nelem][ion]-1]* EN1RYD);
56 }
57
58 for( ion=dense.IonHigh[nelem]; ion <= nelem; ion++ )
59 {
60 ionbal.CollIonRate_Ground[nelem][ion][0] = 0.;
61 ionbal.CollIonRate_Ground[nelem][ion][1] = 0.;
62 }
63
64 /* check not rates are negative - in release mode this loop will optimize out */
65 for( ion=0; ion <= nelem; ion++ )
66 {
67 /* there can be no negative rates */
68 ASSERT( ionbal.CollIonRate_Ground[nelem][ion][0] >= 0. );
69 }
70 return;
71}
#define ASSERT(exp)
Definition cddefines.h:578
#define MIN2
Definition cddefines.h:761
const int LIMELM
Definition cddefines.h:258
const int NISO
Definition cddefines.h:261
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
static t_ADfA & Inst()
Definition cddefines.h:175
double coll_ion_wrapper(long int z, long int n, double t)
t_dense dense
Definition dense.cpp:24
t_Heavy Heavy
Definition heavy.cpp:5
void ion_collis(long int nelem)
t_ionbal ionbal
Definition ionbal.cpp:5
t_phycon phycon
Definition phycon.cpp:6
UNUSED const double EN1RYD
Definition physconst.h:179
t_rfield rfield
Definition rfield.cpp:8