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