cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
h2.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 #include "cddefines.h"
4 #include "h2.h"
5 #include "hmi.h"
6 #include "atmdat.h"
7 
8 vector<diatomics*> diatoms;
9 
10 diatomics h2("h2", 4100., &hmi.H2_total, Yan_H2_CS);
11 diatomics hd("hd", 4100., &hmi.HD_total, Yan_H2_CS);
12 
13 diatomics::diatomics( const string& a, const double& e_star, const double* const abund, double (*fun)(double) ):
14  trans(a, &states), ENERGY_H2_STAR (e_star), dense_total(abund)
15  {
16  DEBUG_ENTRY( "diatomics::diatomics()" );
17  fixit("should probably force path lower and label upper case.");
18  path = a;
19  label = a;
20  {
21  unsigned j;
22  for( j = 0; j < a.size(); ++j )
23  label[j] = toupper( label[j] );
24  shortlabel = label;
25  for( j = a.size(); j < 4; ++j )
26  label += ' ';
27  }
28  /* option to turn off or on gbar collisions of the collision rate,
29  * default is to have it on */
30  /* turn h2.lgColl_gbar on/off with atom h2 gbar on off */
31  lgColl_gbar = true;
32  /* include collision rates that come from real calculations,
33  * off with atom h2 collisions off command */
34  lgColl_deexec_Calc = true;
35  lgColl_dissoc_coll = true;
36  lgEnabled = false;
37  lgEvaluated = false;
38  /* option to turn off H2 - grain collision & deexcitation,
39  * atom h2 grain collision on/off */
41  /* option to scramble collision data */
42  lgH2_NOISE = false;
43  lgH2_NOISECOSMIC = false;
44  /* option to turn off ortho-para collisions, command SPECIES H2 COLLISIONS ORTHO PARA OFF */
46  /* which set of H2 - He collision data to use? default is ORNL data set
47  * also Le Bourlot Meudon set available,
48  * set to ORNL with command
49  * atom H2 He collisions ORNL */
50  lgH2_He_ORNL = true;
51  /* use 1999 or 2007 H2 - H collision set atomic data mole H2 h */
52  lgH2_H_coll_07 = true;
53  /*>>chng 08 feb 27, GS, ORNL or Meudon H2 - H2 collision data
54  * >>chng 09 may 11, make it the default */
55  lgH2_ORH2_ORNL = true;
56  lgH2_PAH2_ORNL = true;
57  /* flag to force using LTE level populations */
58  lgLTE = false;
59  lgREAD_DATA = false;
60  loop_h2_oscil = -1;
61  HeatDiss = 0.;
62  HeatDexc = 0.;
63  HeatDexc_old = 0.;
64  HeatDexc_deriv = 0.;
65  HeatChangeOld = 0.;
66  HeatChange = 0.;
67  photo_heat_soft = 0.;
68  photo_heat_hard = 0.;
74  spon_diss_tot = 0.;
77  Average_A = 0.;
86 
87  /* these remember the largest and smallest factors needed to
88  * renormalize the H2 chemistry */
89  renorm_max = 1.;
90  renorm_min = 1.;
91  /* ortho and para column densities */
92  ortho_colden = 0.;
93  para_colden = 0.;
94  ortho_para_old = 0.;
95  ortho_para_older = 0.;
96  ortho_para_current = 0.;
97  TeUsedBoltz = -1.;
98  TeUsedColl = -1.;
99 
100  /* counters used by H2_itrzn to find number of calls of h2 per zone */
101  nH2_pops = 0;
102  nH2_zone = 0;
104  /* these are used to set trace levels of output by options on atom h2 trace command
105  * first is minimum level of trace, keyword is FINAL */
106  n_trace_final = 1;
107  /* intermediate level of trace, info per iteration, key ITERATION */
108  n_trace_iterations = 2;
109  /* full trace, keyword is FULL */
110  n_trace_full = 3;
111  /* print matrices used in solving X */
112  n_trace_matrix = 4;
113  /* holds options for trace set with atom h2 command */
114  nTRACE = false;
115  /* this is number of electronic levels to include in the print and save output
116  * changed with the PRINT LINE H2 ELECTRONIC and PUNCH H2 commands
117  * by default only include X */
118  nElecLevelOutput = 1;
119  /* the number of electronic quantum states to include.
120  * To do both Lyman and Werner bands want nelec = 3,
121  * default is to do all bands included */
123  nCall_this_zone = 0;
124  /* the number of levels used in the matrix solution
125  * of the level populations - set with atom h2 matrix nlevel,
126  * >>chng 04 oct 05, make default 30 levels
127  * >>chng 04 dec 23, make default 70 levels */
128  nXLevelsMatrix = 70;
129  ndimMalloced = 0;
130 
131  levelAsEval = -1;
132  lgFirst = true;
133  nzone_eval = -1;
134  nzoneEval = -1;
135  iteration_evaluated = -1;
136 
137  /* this is used to establish zone number for evaluation of number of levels in matrix */
138  nzone_nlevel_set = -1;
139  nzoneAsEval = -1;
140  /* this is used to establish zone number for evaluation of number of levels in matrix */
141  nzone_nlevel_set = 0;
142 
143  /* this is the smallest ratio of H2/H where we will bother with the large H2 molecule
144  * this value was chosen so that large mole used at very start of TH85 standard PDR,
145  * NB - this appears in headinfo and must be updated there if changed here */
146  /* >>chng 03 jun 02, from 1e-6 to 1e-8 - in orion veil large H2 turned on half way
147  * across, and Solomon process was very fast since all lines optically thin. correct
148  * result has some shielding, so reset to lower value so that H2 comes on sooner. */
149  H2_to_H_limit = 1e-8;
150  iterationAsEval = -1;
151 
152  strcpy( chH2ColliderLabels[0] , "H0" );
153  strcpy( chH2ColliderLabels[1] , "He" );
154  strcpy( chH2ColliderLabels[2] , "H2 o" );
155  strcpy( chH2ColliderLabels[3] , "H2 p" );
156  strcpy( chH2ColliderLabels[4] , "H+" );
157  }
158 
159 void diatoms_init( void )
160 {
161  DEBUG_ENTRY( "diatoms_init()" );
162 
163  diatoms.clear();
164  diatoms.push_back( &h2 );
165  diatoms.push_back( &hd );
166 
167  // H
168  h2.coll_source[0].magic = 110416;
169  h2.coll_source[0].filename = "coll_rates_H_07.dat";
170  // He
171  h2.coll_source[1].magic = 110416;
172  h2.coll_source[1].filename = "coll_rates_He_ORNL.dat";
173  // H2 ortho
174  h2.coll_source[2].magic = 110416;
175  h2.coll_source[2].filename = "coll_rates_H2ortho_ORNL.dat";
176  // H2 para
177  h2.coll_source[3].magic = 110416;
178  h2.coll_source[3].filename = "coll_rates_H2para_ORNL.dat";
179  // proton
180  h2.coll_source[4].magic = 110416;
181  h2.coll_source[4].filename = "coll_rates_Hp.dat";
182 
183  // H
184  hd.coll_source[0].magic = 110416;
185  hd.coll_source[0].filename = "coll_rates_H_07.dat";
186  // He
187  hd.coll_source[1].magic = 110416;
188  hd.coll_source[1].filename = "coll_rates_He_Flower.dat";
189  // H2 ortho
190  hd.coll_source[2].magic = 110416;
191  hd.coll_source[2].filename = "coll_rates_H2ortho_Flower.dat";
192  // H2 para
193  hd.coll_source[3].magic = 110416;
194  hd.coll_source[3].filename = "coll_rates_H2para_Flower.dat";
195  // proton
196  hd.coll_source[4].magic = 110416;
197  hd.coll_source[4].filename = "coll_rates_Hp.dat";
198 
199  return;
200 }
201 
int nTRACE
Definition: h2_priv.h:406
char chH2ColliderLabels[N_X_COLLIDER][chN_X_COLLIDER]
Definition: h2_priv.h:455
const int N_ELEC
Definition: h2_priv.h:34
double Average_A
Definition: h2_priv.h:303
double renorm_min
Definition: h2_priv.h:343
double TeUsedBoltz
Definition: h2_priv.h:422
double Average_collH2_excit
Definition: h2_priv.h:307
long int n_elec_states
Definition: h2_priv.h:416
double HeatChangeOld
Definition: h2_priv.h:300
double spon_diss_tot
Definition: h2_priv.h:269
bool lgH2_H_coll_07
Definition: h2_priv.h:359
int n_trace_full
Definition: h2_priv.h:409
double ortho_para_older
Definition: h2_priv.h:339
t_coll_source coll_source[N_X_COLLIDER]
Definition: h2_priv.h:323
double HeatDexc_deriv
Definition: h2_priv.h:299
bool lgREAD_DATA
Definition: h2_priv.h:259
double ortho_colden
Definition: h2_priv.h:335
double H2_to_H_limit
Definition: h2_priv.h:401
bool lgEvaluated
Definition: h2_priv.h:317
double rate_grain_op_conserve
Definition: h2_priv.h:280
int nElecLevelOutput
Definition: h2_priv.h:356
double HeatChange
Definition: h2_priv.h:300
double Average_collH2_dissoc_g
Definition: h2_priv.h:312
int n_trace_matrix
Definition: h2_priv.h:409
double Average_collH2_deexcit
Definition: h2_priv.h:305
double Yan_H2_CS(double energy_ryd)
double Solomon_dissoc_rate_g
Definition: h2_priv.h:271
double TeUsedColl
Definition: h2_priv.h:423
long int levelAsEval
Definition: h2_priv.h:564
long int iteration_evaluated
Definition: h2_priv.h:567
char toupper(char c)
Definition: cddefines.h:739
bool lgH2_ortho_para_coll_on
Definition: h2_priv.h:379
double Average_collH2_dissoc_s
Definition: h2_priv.h:313
long int iterationAsEval
Definition: h2_priv.h:507
double HeatDexc_old
Definition: h2_priv.h:298
int n_trace_iterations
Definition: h2_priv.h:409
t_abund abund
Definition: abund.cpp:5
double ortho_para_old
Definition: h2_priv.h:339
bool lgLTE
Definition: h2_priv.h:376
double photodissoc_BigH2_H2s
Definition: h2_priv.h:264
bool lgColl_dissoc_coll
Definition: h2_priv.h:369
string filename
Definition: h2_priv.h:69
long int nzoneAsEval
Definition: h2_priv.h:507
bool lgEnabled
Definition: h2_priv.h:352
long int nzoneEval
Definition: h2_priv.h:395
string label
Definition: h2_priv.h:435
long int nCall_this_zone
Definition: h2_priv.h:348
string path
Definition: h2_priv.h:437
bool lgH2_PAH2_ORNL
Definition: h2_priv.h:387
bool lgH2_NOISE
Definition: h2_priv.h:390
double Average_collH_deexcit
Definition: h2_priv.h:306
bool lgFirst
Definition: h2_priv.h:565
long int ndimMalloced
Definition: h2_priv.h:557
long magic
Definition: h2_priv.h:67
double photodissoc_BigH2_H2g
Definition: h2_priv.h:265
long int nH2_pops
Definition: h2_priv.h:577
double HD_total
Definition: hmi.h:27
long int nXLevelsMatrix
Definition: h2_priv.h:556
bool lgH2_He_ORNL
Definition: h2_priv.h:383
vector< diatomics * > diatoms
Definition: h2.cpp:8
double(* photoion_opacity_fun)(double energy)
Definition: h2_priv.h:81
diatomics h2("h2", 4100.,&hmi.H2_total, Yan_H2_CS)
bool lgColl_deexec_Calc
Definition: h2_priv.h:366
long int loop_h2_oscil
Definition: h2_priv.h:394
double rate_grain_J1_to_J0
Definition: h2_priv.h:281
double HeatDexc
Definition: h2_priv.h:297
double ortho_para_current
Definition: h2_priv.h:339
long int nzone_eval
Definition: h2_priv.h:566
diatomics(const string &a, const double &e_star, const double *const abund, double(*fun)(double))
Definition: h2.cpp:13
double HeatDiss
Definition: h2_priv.h:296
double photo_heat_soft
Definition: h2_priv.h:262
bool lgH2_grain_deexcitation
Definition: h2_priv.h:373
double photo_heat_hard
Definition: h2_priv.h:263
string shortlabel
Definition: h2_priv.h:436
double renorm_max
Definition: h2_priv.h:343
double Average_collH_excit
Definition: h2_priv.h:308
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
double Solomon_dissoc_rate_s
Definition: h2_priv.h:272
bool lgH2_ORH2_ORNL
Definition: h2_priv.h:386
bool lgColl_gbar
Definition: h2_priv.h:363
double H2_total
Definition: hmi.h:25
bool lgH2_NOISECOSMIC
Definition: h2_priv.h:392
diatomics hd("hd", 4100.,&hmi.HD_total, Yan_H2_CS)
double para_colden
Definition: h2_priv.h:335
double Average_collH_dissoc_g
Definition: h2_priv.h:310
long int nzone_nlevel_set
Definition: h2_priv.h:581
double Average_collH_dissoc_s
Definition: h2_priv.h:311
#define fixit(a)
Definition: cddefines.h:417
t_hmi hmi
Definition: hmi.cpp:5
void diatoms_init(void)
Definition: h2.cpp:159
int n_trace_final
Definition: h2_priv.h:409
long int nH2_zone
Definition: h2_priv.h:578