cloudy  trunk
parse_test.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 /*ParseTest parse the test command */
4 #include "cddefines.h"
5 #include "atomfeii.h"
6 #include "input.h"
7 #include "iso.h"
8 #include "monitor_results.h"
9 #include "parser.h"
10 
11 void ParseTest(Parser &p)
12 {
13  char chStuff[INPUT_LINE_LENGTH];
14 
15  DEBUG_ENTRY( "ParseTest()" );
16 
17  /* do a smoke test -
18  * generate test input stream for rapid testing of code */
19 
20  /* optional keyword PRINT will cause all the commands to be printed */
21  int nPrintTest = p.nMatch("PRIN" );
22 
23  bool lgH2 = p.nMatch(" H2 ");
24  bool lgFeII = p.nMatch("FEII") || p.nMatch("FE II");
25  bool lgLARG = p.nMatch("LARG");
26  bool lgMOLE = p.nMatch("MOLE");
27 
28  /* option to turn on the H2 molecule */
29  if( lgH2 )
30  {
31  /* this will both enable the molecule and also set the threshold for actually
32  * computing it to a very low value, so that it is actually used in ionized gas */
33  sprintf( chStuff , "ATOM H2 LIMIT -20 " );
34  if( nPrintTest )
35  fprintf(ioQQQ , "%s\n" , chStuff );
36  p.setline(chStuff);
37  p.set_point(4);
38  ParseAtomH2(p);
39  }
40 
41  /* this is option to also turn on large FeII atom */
42  if( lgFeII )
43  {
44  sprintf( chStuff , "ATOM FEII " );
45  if( nPrintTest )
46  fprintf(ioQQQ , "%s\n" , chStuff );
47  p.setline(chStuff);
48  p.set_point(4);
49  ParseAtomFeII(p);
50  }
51 
52  /* use largest possible hydrogen atom */
53  if( lgLARG )
54  {
55  sprintf( chStuff , "ATOM H-LIKE ELEMENT HYDROGEN LEVELS LARGER " );
56  if( nPrintTest )
57  fprintf(ioQQQ , "%s\n" , chStuff );
58  p.setline(chStuff);
59  p.set_point(4);
61  }
62 
63  if( lgMOLE )
64  {
65 # if 0
66  {
67  /* hydrogen density */
68  sprintf( chStuff , "TRACE TEMPERATURE CONVERGENCE " );
69  if( nPrintTest )
70  fprintf(ioQQQ , "%s\n" , chStuff );
71  p.setline(chStuff);
72  p.set_point(4);
73  ParseTrace(chStuff);
74  }
75 # endif
76 
77  {
78  /* hydrogen density */
79  sprintf( chStuff , "HDEN 5 " );
80  if( nPrintTest )
81  fprintf(ioQQQ , "%s\n" , chStuff );
82  p.setline(chStuff);
83  p.set_point(4);
84  ParseHDEN(p);
85  }
86 
87  {
88  /* make a constant temperature model */
89  sprintf( chStuff , "CONSTANT TEMPER 50K " );
90  if( nPrintTest )
91  fprintf(ioQQQ , "%s\n" , chStuff );
92  p.setline(chStuff);
93  p.set_point(4);
94  ParseConstant(p);
95  }
96 
97  {
98  /* continuum to include full energy range */
99  sprintf( chStuff , "TABLE ISM " );
100  if( nPrintTest )
101  fprintf(ioQQQ , "%s\n" , chStuff );
102  p.setline(chStuff);
103  p.set_point(4);
104  ParseTable( p);
105  }
106 
107  {
108  /* extinguish this continuum */
109  sprintf( chStuff , "EXTINGUISH 23 " );
110  if( nPrintTest )
111  fprintf(ioQQQ , "%s\n" , chStuff );
112  p.setline(chStuff);
113  p.set_point(4);
114  ParseExtinguish( p );
115  }
116 
117  {
118  /* stop in second zone, so we do use the zone increment logic */
119  sprintf( chStuff , "STOP ZONE 2 " );
120  if( nPrintTest )
121  fprintf(ioQQQ , "%s\n" , chStuff );
122  p.setline(chStuff);
123  p.set_point(4);
124  ParseStop(p);
125  }
126 
127  {
128  /* set thickness */
129  sprintf( chStuff , "SET DR 0 " );
130  if( nPrintTest )
131  fprintf(ioQQQ , "%s\n" , chStuff );
132  p.setline(chStuff);
133  p.set_point(4);
134  ParseSet(p);
135  }
136 
137  {
138  /* do Case B so lyman line pumping of H is not important */
139  sprintf( chStuff , "CASE B " );
140  if( nPrintTest )
141  fprintf(ioQQQ , "%s\n" , chStuff );
142  p.setline(chStuff);
143  p.set_point(4);
144  ParseCaseB( p );
145  }
146 
147  {
148  /* set cosmic rays */
149  //>>chng 12 apr 09, this uses old Williams CR backbround for continuity
150  sprintf( chStuff , "COSMIC RAY BACKGROUND linear 0.1266 " );
151  if( nPrintTest )
152  fprintf(ioQQQ , "%s\n" , chStuff );
153  p.setline(chStuff);
154  p.set_point(4);
155  ParseCosmicRays( p );
156  }
157 
158  {
159  /* add grains and ism abundances */
160  sprintf( chStuff , "ABUNDANCES ISM " );
161  if( nPrintTest )
162  fprintf(ioQQQ , "%s\n" , chStuff );
163  p.setline(chStuff);
164  p.set_point(4);
165  ParseAbundances( p );
166  }
167 
168  {
169  /* add grains and ism abundances */
170  sprintf( chStuff , "CONSTANT GRAIN TEMPERATURE 20K " );
171  if( nPrintTest )
172  fprintf(ioQQQ , "%s\n" , chStuff );
173  p.setline(chStuff);
174  p.set_point(4);
175  ParseConstant( p );
176  }
177 
178  /* create series of monitor commands */
179  sprintf( chStuff , "MONITOR EDEN 0.625 " );
180  if( nPrintTest )
181  fprintf(ioQQQ , "%s\n" , chStuff );
182  p.setline(chStuff);
184 
185  /* create series of monitor commands */
186  sprintf( chStuff , "MONITOR MOLECULAR FRACTION H2 -1.528 " );
187  if( nPrintTest )
188  fprintf(ioQQQ , "%s\n" , chStuff );
189  p.setline(chStuff);
191 
192  /* create series of monitor commands */
193  sprintf( chStuff , "MONITOR COLUMN CO 0.987 " );
194  if( nPrintTest )
195  fprintf(ioQQQ , "%s\n" , chStuff );
196  p.setline(chStuff);
198 
199  /* create series of monitor commands */
200  sprintf( chStuff , "MONITOR EDEN 0.625 " );
201  if( nPrintTest )
202  fprintf(ioQQQ , "%s\n" , chStuff );
203  p.setline(chStuff);
205 
206  /* create series of monitor commands */
207  sprintf( chStuff , "MONITOR HYDROGEN 1 TEMPERATURE 50K " );
208  if( nPrintTest )
209  fprintf(ioQQQ , "%s\n" , chStuff );
210  p.setline(chStuff);
212  }
213 
214  else
215  {
216  {
217  /* hydrogen density */
218  sprintf( chStuff , "HDEN 4 " );
219  if( nPrintTest )
220  fprintf(ioQQQ , "%s\n" , chStuff );
221  p.setline(chStuff);
222  p.set_point(4);
223  ParseHDEN( p );
224  }
225 
226  {
227  /* make a constant temperature model */
228  sprintf( chStuff , "CONSTANT TEMPER 4 " );
229  if( nPrintTest )
230  fprintf(ioQQQ , "%s\n" , chStuff );
231  p.setline(chStuff);
232  p.set_point(4);
233  ParseConstant( p );
234  }
235 
236  {
237  /* continuum to include full energy range */
238  sprintf( chStuff , "TABLE AGN " );
239  if( nPrintTest )
240  fprintf(ioQQQ , "%s\n" , chStuff );
241  p.setline(chStuff);
242  p.set_point(4);
243  ParseTable( p);
244  }
245 
246  {
247  /* set ionization parameter */
248  sprintf( chStuff , "IONIZATION PARAMETER -2 " );
249  if( nPrintTest )
250  fprintf(ioQQQ , "%s\n" , chStuff );
251  p.setline(chStuff);
252  p.set_point(4);
253  ParseIonParI( p);
254  }
255 
256  {
257  /* use old abundances */
258  sprintf( chStuff , "ABUNDANCES OLD SOLAR 84 " );
259  if( nPrintTest )
260  fprintf(ioQQQ , "%s\n" , chStuff );
261  p.setline(chStuff);
262  p.set_point(4);
263  ParseAbundances(p);
264  }
265 
266  {
267  /* >>chng 02 apr 19, add this */
268  /* set total Lyman continuum depth - this is to prevent caution
269  * that Lyman continuum was thin but expected to be thick */
270  sprintf( chStuff , "STOP LYMAN OPTICAL -4 " );
271  if( nPrintTest )
272  fprintf(ioQQQ , "%s\n" , chStuff );
273  p.setline(chStuff);
274  p.set_point(4);
275  ParseStop(p);
276  }
277 
278  {
279  /* stop in second zone, so we do use the zone increment logic */
280  sprintf( chStuff , "STOP ZONE 2 " );
281  if( nPrintTest )
282  fprintf(ioQQQ , "%s\n" , chStuff );
283  p.setline(chStuff);
284  p.set_point(4);
285  ParseStop(p);
286  }
287 
288  {
289  /* set thickness */
290  sprintf( chStuff , "SET DR 0 " );
291  if( nPrintTest )
292  fprintf(ioQQQ , "%s\n" , chStuff );
293  p.setline(chStuff);
294  p.set_point(4);
295  ParseSet(p);
296  }
297 
298  /* create series of monitor commands */
299  sprintf( chStuff , "MONITOR HYDROGEN 1 IONIZATION -3.052 " );
300  if( nPrintTest )
301  fprintf(ioQQQ , "%s\n" , chStuff );
302  p.setline(chStuff);
304 
305  sprintf( chStuff , "MONITOR HELIUM 2 IONIZATION -1.076 " );
306  if( nPrintTest )
307  fprintf(ioQQQ , "%s\n" , chStuff );
308  p.setline(chStuff);
310 
311  /*>>chng 13 feb 01, from -2.377 to -2.319. undo r6703 DR suppression */
312  /*>>chng 13 apr 13, from -2.319 to -2.359, redo DR suppression */
313  sprintf( chStuff , "MONITOR CARBON 2 IONIZATION -2.359 " );
314  if( nPrintTest )
315  fprintf(ioQQQ , "%s\n" , chStuff );
316  p.setline(chStuff);
318 
319  /*>>chng 06 dec 01, from -0.653 to -0.560. Badnell DR by default */
320  /*>>chng 13 feb 01, from -0.596 to -0.565. undo r6703 DR suppression */
321  /*>>chng 13 apr 13, from -0.565 to -0.586, redo DR suppression */
322  sprintf( chStuff , "MONITOR CARBON 3 IONIZATION -0.586 " );
323  if( nPrintTest )
324  fprintf(ioQQQ , "%s\n" , chStuff );
325  p.setline(chStuff);
327 
328  /*>>chng 06 dec 01, from -0.348 to -0.373. Badnell DR by default */
329  sprintf( chStuff , "MONITOR CARBON 4 IONIZATION -0.361 " );
330  if( nPrintTest )
331  fprintf(ioQQQ , "%s\n" , chStuff );
332  p.setline(chStuff);
334 
335  /*>>chng 06 dec 01, from -0.490 to -0.530. Badnell DR by default */
336  sprintf( chStuff , "MONITOR CARBON 5 IONIZATION -0.514 " );
337  if( nPrintTest )
338  fprintf(ioQQQ , "%s\n" , chStuff );
339  p.setline(chStuff);
341 
342  /*>>chng 06 dec 01, from -0.800 to -0.861. Badnell DR by default */
343  /*>>chng 11 jul 12, from -0.861 to -0.935, DR coll suppression */
344  /*>>chng 13 feb 01, from -0.935 to -0.863. undo r6703 DR suppression */
345  /*>>chng 13 apr 13, from -0.863 to -0.894, redo DR suppression */
346  sprintf( chStuff , "MONITOR OXYGEN 3 IONIZATION -0.894 " );
347  if( nPrintTest )
348  fprintf(ioQQQ , "%s\n" , chStuff );
349  p.setline(chStuff);
351 
352  /*>>chng 06 dec 01, from -0.180 to -0.157. Badnell DR by default */
353  sprintf( chStuff , "MONITOR OXYGEN 4 IONIZATION -0.148 " );
354  if( nPrintTest )
355  fprintf(ioQQQ , "%s\n" , chStuff );
356  p.setline(chStuff);
358 
359  /*>>chng 06 dec 01, from -0.770 to -0.808. Badnell DR by default */
360  /*>>chng 13 feb 01, from -0.790 to -0.807. undo r6703 DR suppression */
361  /*>>chng 13 mar 13, from -0.807 to -0.798. undo DR suppression */
362  sprintf( chStuff , "MONITOR OXYGEN 5 IONIZATION -0.798 " );
363  if( nPrintTest )
364  fprintf(ioQQQ , "%s\n" , chStuff );
365  p.setline(chStuff);
367 
368  /* >>chng 02 apr 19, from 0.7258 to 0.946, due to adding Lyman cont depth */
369  /* >>chng 07 oct 22, from 0.946 to 1.108, resolve l-levels of h-like sequence */
370  sprintf( chStuff , "MONITOR LINE \"CA B\" 4861.36 1.108 " );
371  if( nPrintTest )
372  fprintf(ioQQQ , "%s\n" , chStuff );
373  /* must have copy of this in chOrgCard, which is used by the routine to get lab */
374  p.setline(chStuff);
376 
377  /* >>chng 02 apr 19, from 2.4603 to 3.25, due to adding Lyman cont depth
378  * >>chng 06 nov 17, asserted value from 3.25 to 3.11, drift over last year */
379  /* >>chng 06 dec 01, from 3.11 to 2.72. Badnell DR by default */
380  /* >>chng 07 oct 22, from 2.72 to 3.18, resolve l-levels of h-like sequence */
381  /* >>chng 11 jul 12, from 3.18 to 2.695, DR coll suppression */
382  /* >>chng 13 feb 01, from 2.695 to 3.189. undo r6703 DR suppression */
383  /* >>chng 13 apr 13, from 3.189 to 2.961, redo DR suppression */
384  sprintf( chStuff , "MONITOR LINE \"O 3\" 5007 2.961 " );
385  if( nPrintTest )
386  fprintf(ioQQQ , "%s\n" , chStuff );
387  /* must have copy of this in chOrgCard, which is used by the routine to get lab */
388  p.setline(chStuff);
390 
391  sprintf( chStuff , "MONITOR HTOT -15.019" );
392  if( nPrintTest )
393  fprintf(ioQQQ , "%s\n" , chStuff );
394  p.setline(chStuff);
396  }
397 
398  return;
399 }
Parser::nMatch
bool nMatch(const char *chKey) const
Definition: parser.h:135
ParseTable
void ParseTable(Parser &p)
Definition: parse_table.cpp:340
ParseCosmicRays
void ParseCosmicRays(Parser &p)
Definition: parse_cosmic_rays.cpp:13
ParseHDEN
void ParseHDEN(Parser &p)
Definition: parse_hden.cpp:11
ioQQQ
FILE * ioQQQ
Definition: cddefines.cpp:7
ParseSet
void ParseSet(Parser &p)
Definition: parse_set.cpp:44
ParseStop
void ParseStop(Parser &p)
Definition: parse_stop.cpp:17
ParseTest
void ParseTest(Parser &p)
Definition: parse_test.cpp:11
ParseAtomH2
void ParseAtomH2(Parser &p)
Definition: parse_atom_h2.cpp:13
iso.h
ParseExtinguish
void ParseExtinguish(Parser &p)
Definition: parse_extinguish.cpp:9
ParseAtomISO
void ParseAtomISO(long ipISO, Parser &p)
Definition: parse_atom_iso.cpp:17
Parser
Definition: parser.h:31
ParseIonParI
void ParseIonParI(Parser &p)
Definition: parse_ionpar.cpp:11
cddefines.h
ParseCaseB
void ParseCaseB(Parser &p)
Definition: parse_caseb.cpp:9
INPUT_LINE_LENGTH
const int INPUT_LINE_LENGTH
Definition: cddefines.h:254
Parser::setline
void setline(const char *const card)
Definition: parser.h:69
parser.h
ParseAbundances
void ParseAbundances(Parser &p)
Definition: parse_abundances.cpp:14
Parser::set_point
void set_point(long int ipnt)
Definition: parser.h:77
ParseTrace
void ParseTrace(Parser &p)
Definition: parse_trace.cpp:11
ParseAtomFeII
void ParseAtomFeII(Parser &p)
Definition: atom_feii.cpp:2619
ParseMonitorResults
void ParseMonitorResults(Parser &p)
Definition: monitor_results.cpp:104
monitor_results.h
input.h
atomfeii.h
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:684
ipH_LIKE
const int ipH_LIKE
Definition: iso.h:62
ParseConstant
void ParseConstant(Parser &p)
Definition: parse_constant.cpp:15