cloudy  trunk
 All Data Structures 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-2008 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 "assertresults.h"
8 #include "parse.h"
9 
10 void ParseTest(char *chCard ,
11  long int *nqh,
12  realnum *ar1,
13  bool lgDSet)
14 {
15  char chStuff[INPUT_LINE_LENGTH];
16 
17  DEBUG_ENTRY( "ParseTest()" );
18 
19  /* do a smoke test -
20  * generate test input stream for rapid testing of code */
21 
22  /* optional keyword PRINT will cause all the commands to be printed */
23  int nPrintTest = nMatch("PRIN" , chCard );
24 
25  /* option to turn on the H2 molecule */
26  if( nMatch(" H2 ",chCard) )
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 , "ATOM H2 LIMIT -20 " );
31  if( nPrintTest )
32  fprintf(ioQQQ , "%s\n" , chStuff );
33  ParseAtomH2(chStuff);
34  }
35 
36  /* this is option to also turn on large FeII atom */
37  if( nMatch("FEII",chCard) || nMatch("FE II",chCard) )
38  {
39  sprintf( chStuff , "ATOM FEII " );
40  if( nPrintTest )
41  fprintf(ioQQQ , "%s\n" , chStuff );
42  ParseAtomFeII(chStuff);
43  }
44 
45  /* use largest possible hydrogen atom */
46  if( nMatch("LARG",chCard) )
47  {
48  sprintf( chStuff , "ATOM H-LIKE ELEMENT HYDROGEN LEVELS LIMIT " );
49  if( nPrintTest )
50  fprintf(ioQQQ , "%s\n" , chStuff );
51  ParseAtomISO(ipH_LIKE,chStuff);
52  }
53 
54  if( nMatch("MOLE",chCard) )
55  {
56 # if 0
57  /* hydrogen density */
58  sprintf( chStuff , "TRACE TEMPERATURE CONVERGENCE " );
59  if( nPrintTest )
60  fprintf(ioQQQ , "%s\n" , chStuff );
61  ParseTrace(chStuff);
62 # endif
63 
64  /* hydrogen density */
65  sprintf( chStuff , "HDEN 5 " );
66  if( nPrintTest )
67  fprintf(ioQQQ , "%s\n" , chStuff );
68  ParseHDEN(chStuff);
69 
70  /* make a constant temperature model */
71  sprintf( chStuff , "CONSTANT TEMPER 50K " );
72  if( nPrintTest )
73  fprintf(ioQQQ , "%s\n" , chStuff );
74  ParseConstant(chStuff);
75 
76  /* continuum to include full energy range */
77  sprintf( chStuff , "TABLE ISM " );
78  if( nPrintTest )
79  fprintf(ioQQQ , "%s\n" , chStuff );
80  ParseTable( nqh,chStuff, ar1);
81 
82  /* extinguish this continuum */
83  sprintf( chStuff , "EXTINGUISH 23 " );
84  if( nPrintTest )
85  fprintf(ioQQQ , "%s\n" , chStuff );
86  ParseExtinguish( chStuff );
87 
88  /* stop in second zone, so we do use the zone increment logic */
89  sprintf( chStuff , "STOP ZONE 2 " );
90  if( nPrintTest )
91  fprintf(ioQQQ , "%s\n" , chStuff );
92  ParseStop(chStuff);
93 
94  /* set thickness */
95  sprintf( chStuff , "SET DR 0 " );
96  if( nPrintTest )
97  fprintf(ioQQQ , "%s\n" , chStuff );
98  ParseSet(chStuff);
99 
100  /* do Case B so lyman line pumping of H is not important */
101  sprintf( chStuff , "CASE B " );
102  if( nPrintTest )
103  fprintf(ioQQQ , "%s\n" , chStuff );
104  ParseCaseB(chStuff);
105 
106  /* set cosmic rays */
107  sprintf( chStuff , "COSMIC RAY BACKGROUND " );
108  if( nPrintTest )
109  fprintf(ioQQQ , "%s\n" , chStuff );
110  ParseCosmicRays(chStuff);
111 
112  /* add grains and ism abundances */
113  sprintf( chStuff , "ABUNDANCES ISM " );
114  if( nPrintTest )
115  fprintf(ioQQQ , "%s\n" , chStuff );
116  ParseAbundances(chStuff , lgDSet);
117 
118  /* add grains and ism abundances */
119  sprintf( chStuff , "CONSTANT GRAIN TEMPERATURE 20K " );
120  if( nPrintTest )
121  fprintf(ioQQQ , "%s\n" , chStuff );
122  ParseConstant(chStuff);
123 
124  /* create series of assert commands */
125  sprintf( input.chCARDCAPS , "ASSERT EDEN 0.528 " );
126  if( nPrintTest )
127  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
129 
130  /* create series of assert commands */
131  sprintf( input.chCARDCAPS , "ASSERT MOLECULAR FRACTION H2 -1.193 " );
132  if( nPrintTest )
133  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
135 
136  /* create series of assert commands */
137  sprintf( input.chCARDCAPS , "ASSERT COLUMN CO 1.214 " );
138  if( nPrintTest )
139  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
141 
142  /* create series of assert commands */
143  sprintf( input.chCARDCAPS , "ASSERT EDEN 0.528 " );
144  if( nPrintTest )
145  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
147 
148  /* create series of assert commands */
149  sprintf( input.chCARDCAPS , "ASSERT HYDROGEN 1 TEMPERATURE 50K " );
150  if( nPrintTest )
151  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
153  }
154 
155  else
156  {
157  /* hydrogen density */
158  sprintf( chStuff , "HDEN 4 " );
159  if( nPrintTest )
160  fprintf(ioQQQ , "%s\n" , chStuff );
161  ParseHDEN(chStuff);
162 
163  /* make a constant temperature model */
164  sprintf( chStuff , "CONSTANT TEMPER 4 " );
165  if( nPrintTest )
166  fprintf(ioQQQ , "%s\n" , chStuff );
167  ParseConstant(chStuff);
168 
169  /* continuum to include full energy range */
170  sprintf( chStuff , "TABLE AGN " );
171  if( nPrintTest )
172  fprintf(ioQQQ , "%s\n" , chStuff );
173  ParseTable( nqh,chStuff, ar1);
174 
175  /* set ionization parameter */
176  sprintf( chStuff , "IONIZATION PARAMETER -2 " );
177  if( nPrintTest )
178  fprintf(ioQQQ , "%s\n" , chStuff );
179  ParseIonPar( nqh,chStuff, ar1);
180 
181  /* use old abundances */
182  sprintf( chStuff , "ABUNDANCES OLD SOLAR 84 " );
183  if( nPrintTest )
184  fprintf(ioQQQ , "%s\n" , chStuff );
185  ParseAbundances(chStuff,lgDSet);
186 
187  /* >>chng 02 apr 19, add this */
188  /* set total Lyman continuum depth - this is to prevent caution
189  * that Lyman continuum was thin but expected to be thick */
190  sprintf( chStuff , "STOP LYMAN OPTICAL -4 " );
191  if( nPrintTest )
192  fprintf(ioQQQ , "%s\n" , chStuff );
193  ParseStop(chStuff);
194 
195  /* stop in second zone, so we do use the zone increment logic */
196  sprintf( chStuff , "STOP ZONE 2 " );
197  if( nPrintTest )
198  fprintf(ioQQQ , "%s\n" , chStuff );
199  ParseStop(chStuff);
200 
201  /* set thickness */
202  sprintf( chStuff , "SET DR 0 " );
203  if( nPrintTest )
204  fprintf(ioQQQ , "%s\n" , chStuff );
205  ParseSet(chStuff);
206 
207  /* create series of assert commands */
208  sprintf( input.chCARDCAPS , "ASSERT HYDROGEN 1 IONIZATION -3.040 " );
209  if( nPrintTest )
210  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
212 
213  sprintf( input.chCARDCAPS , "ASSERT HELIUM 2 IONIZATION -1.067 " );
214  if( nPrintTest )
215  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
217 
218  sprintf( input.chCARDCAPS , "ASSERT CARBON 2 IONIZATION -2.301 " );
219  if( nPrintTest )
220  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
222 
223  /*>>chng 06 dec 01, from -0.653 to -0.560. Badnell DR by default */
224  sprintf( input.chCARDCAPS , "ASSERT CARBON 3 IONIZATION -0.560 " );
225  if( nPrintTest )
226  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
228 
229  /*>>chng 06 dec 01, from -0.348 to -0.373. Badnell DR by default */
230  sprintf( input.chCARDCAPS , "ASSERT CARBON 4 IONIZATION -0.373 " );
231  if( nPrintTest )
232  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
234 
235  /*>>chng 06 dec 01, from -0.490 to -0.530. Badnell DR by default */
236  sprintf( input.chCARDCAPS , "ASSERT CARBON 5 IONIZATION -0.530 " );
237  if( nPrintTest )
238  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
240 
241  /*>>chng 06 dec 01, from -0.800 to -0.861. Badnell DR by default */
242  sprintf( input.chCARDCAPS , "ASSERT OXYGEN 3 IONIZATION -0.861 " );
243  if( nPrintTest )
244  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
246 
247  /*>>chng 06 dec 01, from -0.180 to -0.157. Badnell DR by default */
248  sprintf( input.chCARDCAPS , "ASSERT OXYGEN 4 IONIZATION -0.157 " );
249  if( nPrintTest )
250  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
252 
253  /*>>chng 06 dec 01, from -0.770 to -0.808. Badnell DR by default */
254  sprintf( input.chCARDCAPS , "ASSERT OXYGEN 5 IONIZATION -0.808 " );
255  if( nPrintTest )
256  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
258 
259  /* >>chng 02 apr 19, from 0.7258 to 0.946, due to adding Lyman cont depth */
260  /* >>chng 07 oct 22, from 0.946 to 1.108, resolve l-levels of h-like sequence */
261  sprintf( input.chCARDCAPS , "ASSERT LINE \"CA B\" 4861 1.108 " );
262  if( nPrintTest )
263  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
264  /* must have copy of this in chOrgCard, which is used by the routine to get lab */
265  strcpy( input.chOrgCard , input.chCARDCAPS);
267 
268  /* >>chng 02 apr 19, from 2.4603 to 3.25, due to adding Lyman cont depth
269  * >>chng 06 nov 17, asserted value from 3.25 to 3.11, drift over last year */
270  /* >>chng 06 dec 01, from 3.11 to 2.72. Badnell DR by default */
271  /* >>chng 07 oct 22, from 2.72 to 3.18, resolve l-levels of h-like sequence */
272  sprintf( input.chCARDCAPS , "ASSERT LINE \"O 3\" 5007 3.18 " );
273  if( nPrintTest )
274  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
275  /* must have copy of this in chOrgCard, which is used by the routine to get lab */
276  strcpy( input.chOrgCard , input.chCARDCAPS);
278 
279  sprintf( input.chCARDCAPS , "ASSERT HTOT -15.011" );
280  if( nPrintTest )
281  fprintf(ioQQQ , "%s\n" , input.chCARDCAPS );
283  }
284  return;
285 }

Generated for cloudy by doxygen 1.8.1.1