cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_atom_h2.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 /*ParseAtomH2 parse information from the atom command line */
4 #include "cddefines.h"
5 #include "hmi.h"
6 #include "mole.h"
7 #include "h2.h"
8 #include "h2_priv.h"
9 #include "parse.h"
10 #include "thirdparty.h"
11 
12 /*ParseAtomH2 parse information from the atom command line */
13 void ParseAtomH2(char *chCard )
14 {
15  bool lgEOL;
16  long int i , j;
17 
18  DEBUG_ENTRY( "ParseAtomH2()" );
19 
20  /* this command has a 2 in the H2 label - must not parse the two by
21  * accident. Get the first number off the line image, and confirm that
22  * it is a 2 */
23  i = 5;
24  j = (long int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
25  if( j != 2 )
26  {
27  fprintf( ioQQQ, " Something is wrong with the order of the numbers on this line.\n" );
28  fprintf( ioQQQ, " The first number I encounter should be a 2.\n Sorry.\n" );
29  cdEXIT(EXIT_FAILURE);
30  }
31 
32  /* the mere calling of this routine turns the large H2 molecule on */
33  h2.lgH2ON = true;
34 
35  if( nMatch("LEVE",chCard) )
36  {
37  /* number of electronic levels */
38 
39  /* lgH2_READ_DATA is false at start of calculation, set true when
40  * space allocated for the H lines. Once done we must ignore all
41  * future changes in the number of levels */
42  if( !lgH2_READ_DATA )
43  {
44  mole.n_h2_elec_states = (long int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
45  if( lgEOL )
46  {
47  if( nMatch("LARG",chCard) )
48  {
49  /* LARGE is option to use the most number of electronic levels */
51  }
52  else
53  {
54  NoNumb(chCard);
55  }
56  }
57 
58  /* do not allow fewer than 3 - that includes Lyman & Werner bands */
59  if( mole.n_h2_elec_states < 3 )
60  {
61  fprintf( ioQQQ, " This would be too few electronic levels - resetting to 3.\n" );
63  }
64  /* N_H2_ELEC is in h2.h and is the greatest number of elec lev possible */
65  else if( mole.n_h2_elec_states > N_H2_ELEC )
66  {
67  fprintf( ioQQQ,
68  " This would be too many levels, the limit is %i.\n" ,
69  N_H2_ELEC);
70  cdEXIT(EXIT_FAILURE);
71  }
72  }
73  }
74 
75  else if( nMatch("LIMI",chCard) )
76  {
77  /* the limit to the H2 / Htot ratio -
78  * if smaller than this, do not compute large H2 mole */
79  mole.H2_to_H_limit = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
80  if( lgEOL )
81  {
82  /* did not find a number, either mistake or key " off" */
83  if( nMatch( " OFF" , chCard ) )
84  {
85  /* turn off limit */
86  mole.H2_to_H_limit = -1.;
87  }
88  else
89  {
90  fprintf( ioQQQ," The limit must appear on this line.\n");
91  NoNumb( chCard );
92  }
93  }
94  else
95  {
96  /* got a number, check if negative and so a log */
97  /* a number <= 0 is the log of the ratio */
98  if( mole.H2_to_H_limit <= 0. )
100  }
101  }
102  else if( nMatch("GBAR",chCard ) )
103  {
104  /* option to either use, or not use, gbar approximation for low X
105  * levels with no collision data - by default it is on */
106  if( nMatch(" OFF",chCard ) )
107  {
108  mole.lgColl_gbar = false;
109  }
110  else if( nMatch(" ON ",chCard ) )
111  {
112  mole.lgColl_gbar = true;
113  }
114  else
115  {
116  fprintf( ioQQQ,
117  " The gbar approximation must be off (\" OFF\") or on (\" ON \").\n");
118  cdEXIT(EXIT_FAILURE);
119  }
120  }
121  /* option to turn collisional effects off or on */
122  else if( nMatch("COLL",chCard ) )
123  {
124  /* option to turn collisional dissociation off or on */
125  if( nMatch("DISS",chCard ) )
126  {
127  /* option to turn collisions off */
128  if( nMatch(" ON ",chCard ) )
129  {
130  /* this is the default, leave collisions off */
131  mole.lgColl_dissoc_coll = true;
132  }
133  else
134  {
135  /* default (and only reason for this command) is to turn off collisions */
136  mole.lgColl_dissoc_coll = false;
137  }
138  }
139  /* option to turn collisional dissociation off or on
140  * >>chng 06 mar 01, had been simply if - so all collisions were turned off
141  * when dissociation collisions turned off -
142  * due to bucket else at end */
143  else if( nMatch("ORTH",chCard ) && nMatch("PARA",chCard ) )
144  {
145  /* option to turn ortho - para collisions with particles off */
146  if( nMatch(" ON ",chCard ) )
147  {
148  /* this is the default, leave collisions off */
150  }
151  else
152  {
153  /* default (and only reason for this command) is to turn off
154  * ortho-para collisions */
156  }
157  }
158 
159  /* option to turn collisional effects off or on */
160  else if( nMatch("GRAI",chCard ) )
161  {
162  /* option to turn collisions off */
163  if( nMatch(" ON",chCard ) )
164  {
165  /* this is the default, leave collisions off */
167  }
168  else
169  {
170  /* default (and only reason for this command) is to turn off collisions */
172  }
173  }
174  else if( nMatch(" HE ",chCard ) )
175  {
176  /* atom H2 He collisions ORNL (the default), Le BOURlot, and OFF
177  * which data set for He collisions,
178  * Teck Lee et al. ApJ to be submitted */
179  if( nMatch(" NEW",chCard ) || nMatch("ORNL",chCard ) )
180  {
181  /* use the new coefficients */
182  mole.lgH2_He_ORNL = true;
183  }
184  else if( nMatch(" OLD",chCard ) || nMatch("BOUR",chCard ) )
185  {
186  /* use the coefficients from
187  *>>refer H2 collision Le Bourlot, J., Pineau des Forets,
188  *>>refercon G., & Flower, D.R. 1999, MNRAS, 305, 802*/
189  mole.lgH2_He_ORNL = false;
190  }
191  else
192  {
193  fprintf( ioQQQ,
194  " I did not find a keyword on this ATOM H2 HE command - I know about the keys ORNL and Le BOURlot\n");
195  cdEXIT(EXIT_FAILURE);
196  }
197  }
198  else
199  {
200  /* option to turn all collisions off */
201  if( nMatch(" ON ",chCard ) )
202  {
203  /* this is the default, leave collisions on */
204  mole.lgColl_deexec_Calc = true;
205  }
206  else
207  {
208  /* default (and only reason for this command) is to turn off collisions */
209  mole.lgColl_deexec_Calc = false;
210  }
211  }
212  }
213 
214  /* set number of levels in matrix, but not trace matrix option */
215  else if( nMatch("MATR",chCard ) && !nMatch("TRAC",chCard ) )
216  {
217  /* matrix option sets the number of levels that will
218  * be included in the matrix solution */
219  nXLevelsMatrix = (long)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
220  if( nMatch(" ALL",chCard) )
221  {
222  /* " all" means do all of X, but space has not yet been allocated,
223  * so we do know know how many levels are within X - set special
224  * flag that will be used then this is known */
225  /*nXLevelsMatrix = nLevels_per_elec[0];*/
226  nXLevelsMatrix = -1;
227  }
228  else if( lgEOL && !(nMatch(" OFF",chCard) || nMatch("NONE",chCard) ) )
229  {
230  /* this branch hit eol but OFF or NONE is not on line - this is a mistake */
231  fprintf( ioQQQ,
232  " The total number of levels used in the matrix solver must be entered, or keywords ALL or NONE entered.\n Sorry.\n");
233  cdEXIT(EXIT_FAILURE);
234  }
235  /* cannot check less than total number of levels within x since not yet set
236  * We do not certify that matrix limits are greater than 1 -
237  * zero or <0 limits just turns if off, as did the off option */
238  }
239  else if( nMatch(" LTE",chCard ) )
240  {
241  /* LTE option causes code to assume LTE for level populations */
242  mole.lgH2_LTE = true;
243  }
244 
245  else if( nMatch("TRAC",chCard ) )
246  {
247  /* these are used to set trace levels of output
248  mole.nH2_trace_final = 1;
249  mole.nH2_trace_iterations = 2;
250  mole.nH2_trace_full = 3;
251  mole.nH2_trace_matrix = 4*/
252 
253  /* turns on trace printout - there are multiple levels */
254  if( nMatch("FINA",chCard ) )
255  {
256  /* FINAL gives only final information when solver exits */
258  }
259  else if( nMatch("ITER",chCard ) )
260  {
261  /* follow iterations within each call */
263  }
264  else if( nMatch("FULL",chCard ) )
265  {
266  /* full details of solution - this is also the default*/
268  }
269  else if( nMatch("MATR",chCard ) )
270  {
271  /* print the matrices used for X */
273  }
274  else
275  {
276  /* full details of solution is also the default*/
278  }
279  }
280  else if( nMatch("NOIS",chCard ) )
281  {
282  unsigned int iseed;
283  /* check on effects of uncertainties in collision rates */
284  mole.lgH2_NOISE = true;
285  mole.lgH2_NOISECOSMIC = true;
286 
287  /* optional mean - default is 0 */
288  mole.xMeanNoise = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
289  if( lgEOL )
290  mole.xMeanNoise = 0.;
291 
292  /* this is the standard deviation for the mole, with default */
293  mole.xSTDNoise = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
294  if( lgEOL )
295  mole.xSTDNoise = 0.5;
296 
297  /* this may be a seed for the random number generator. if no seed is
298  * set then use system time, and always get different sequence */
299  iseed = (unsigned int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
300  /* returned 0 if eol hit */
301  if( iseed > 0 )
302  {
303  /* user set seed */
304  init_genrand( iseed );
305  }
306  else
307  {
308  init_genrand( (unsigned)time( NULL ) );
309  }
310  }
311 
312  else if( nMatch("THER",chCard ) )
313  {
314  /* change the treatment of the heating - cooling effects of H2,
315  * options are simple (use TH85 expressions) and full (use large molecule)*/
316  if( nMatch("SIMP",chCard ) )
317  {
318  hmi.lgH2_Thermal_BigH2 = false;
319  }
320  else if( nMatch("FULL",chCard ) )
321  {
322  /* this is the default - use big atom */
323  hmi.lgH2_Thermal_BigH2 = true;
324  }
325  }
326 
327  else if( nMatch("CHEM",chCard ) )
328  {
329  /* atom h2 chemistry simple command
330  * change the treatment of the chemistry - formation and destruction,
331  * options are simple (use TH85 expressions) and full (use large molecule)*/
332  if( nMatch("SIMP",chCard ) )
333  {
334  hmi.lgH2_Chemistry_BigH2 = false;
335  }
336  else if( nMatch("FULL",chCard ) )
337  {
338  /* this is the default - use big atom */
339  hmi.lgH2_Chemistry_BigH2 = true;
340  }
341  }
342 
343  /* there is no final branch - if we do not find a keyword, simply
344  * turn on the H2 molecule */
345  return;
346 }

Generated for cloudy by doxygen 1.8.1.1