cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_plot.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 /*ParsePlot parse the plot command */
4 /*ParsePlotRangeOption parse range from plot command */
5 #include "cddefines.h"
6 #include "plot.h"
7 #include "rfield.h"
8 #include "parser.h"
9 
10 /*ParsePlotRangeOption parse range from plot command, located below */
12 
13 /*ParsePlotRangeContin parse range option for continuum on map command, located below */
15 
16 void ParsePlot(Parser &p )
17 {
18 
19  DEBUG_ENTRY( "ParsePlot()" );
20 
21  /* total number of plots so far */
22  plotCom.nplot += 1;
23 
24  /* plots are turned on */
25  plotCom.lgPlotON = true;
26 
27  /* make sure we have not hit the limit, the dimension of variables in plot.h */
28  if( plotCom.nplot > NDPLOT )
29  {
30  fprintf( ioQQQ,
31  " Too many plots; the limit is%3ld This one ignored.\n",
32  NDPLOT );
34  }
35 
36  if( p.nMatch(" MAP") )
37  {
38  /* option to make plot of heating - cooling map */
39  strcpy( plotCom.chPType[plotCom.nplot-1], " MAP" );
40  }
41 
42  else if( p.nMatch("CONT") )
43  {
44  /* option to make "raw" plot, in internal units */
45  if( p.nMatch(" RAW") )
46  {
47  strcpy( plotCom.chPType[plotCom.nplot-1], "CRAW" );
48  /* option to make diffuse continuum plot */
49  }
50  else if( p.nMatch("DIFF") )
51  {
52  strcpy( plotCom.chPType[plotCom.nplot-1], "DIFF" );
53  /* this is emitted continuum */
54  }
55  else if( p.nMatch("EMIT") )
56  {
57  strcpy( plotCom.chPType[plotCom.nplot-1], "EMIT" );
58  /* this is outward and attenuated continuum */
59  }
60  else if( p.nMatch("OUTW") )
61  {
62  strcpy( plotCom.chPType[plotCom.nplot-1], "OUTW" );
63  /* this is reflected continuum */
64  }
65  else if( p.nMatch("REFL") )
66  {
67  strcpy( plotCom.chPType[plotCom.nplot-1], "REFL" );
68  /* this is continuum in photons */
69  }
70  else if( p.nMatch("PHOT") )
71  {
72  strcpy( plotCom.chPType[plotCom.nplot-1], "CPHT" );
73  }
74  else
75  {
76  strcpy( plotCom.chPType[plotCom.nplot-1], "CONT" );
77  }
78  }
79 
80  else if( p.nMatch("OPAC") )
81  {
82  if( p.nMatch("ABSO") )
83  {
84  /* plot absorption opacity */
85  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAA" );
86  }
87  else if( p.nMatch("SCAT") )
88  {
89  /* plot scattering opacity */
90  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAS" );
91  }
92  else if( p.nMatch("TOTA") )
93  {
94  /* plot total opacity */
95  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
96  }
97  else
98  {
99  /* plot total opacity for default */
100  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
101  }
102  }
103  else
104  {
105  fprintf( ioQQQ, " The second keyword on the PLOT command must be CONTINUUM, _MAP, or OPACITY.\n" );
107  }
108 
109  /* option to turn on trace of plot logic */
110  if( p.nMatch("TRAC") )
111  {
112  plotCom.lgPltTrace[plotCom.nplot-1] = true;
113  }
114  else
115  {
116  plotCom.lgPltTrace[plotCom.nplot-1] = false;
117  }
118 
119  /* option to set min and max x-axis */
120  if( strcmp(plotCom.chPType[plotCom.nplot-1]," MAP") == 0 )
121  {
122  /* this will be map of cooling and heating vs temp */
124  }
125  else
126  {
127  /* continuum map */
129  }
130 
131  return;
132 }
133 
134 /*ParsePlotRangeOption parse range from plot command */
136 {
137  bool
138  lgLogOn;
139  realnum a;
140 
141  DEBUG_ENTRY( "ParsePlotRangeOption()" );
142 
143  /* pltxmn is min for x axis of plot */
145 
146  if( !p.nMatch("RANG") )
147  {
148  /* no lines were enterd, so use default temperature limits */
149  plotCom.pltxmn[plotCom.nplot-1] = 1.;
150  plotCom.pltxmx[plotCom.nplot-1] = 9.;
151  lgLogOn = true;
152  }
153  else if( p.lgEOL() )
154  {
155  /* no lines were enterd, so use default temperature limits */
156  plotCom.pltxmn[plotCom.nplot-1] = 1.;
157  plotCom.pltxmx[plotCom.nplot-1] = 9.;
158  lgLogOn = true;
159  }
160  else
161  {
162  /* number entered, now interprete it */
163  if( plotCom.pltxmn[plotCom.nplot-1] <= 10. )
164  {
165  lgLogOn = true;
166  }
167  else
168  {
169  lgLogOn = false;
170  }
171  /* linear option for temperature */
172  if( p.nMatch("LINE") )
173  lgLogOn = false;
174  /* lower temp was entered, now how about upper temp */
176  if( p.lgEOL() )
177  {
178  if( lgLogOn )
179  {
180  plotCom.pltxmx[plotCom.nplot-1] = 9.;
181  }
182  else
183  {
184  plotCom.pltxmx[plotCom.nplot-1] = 1e9;
185  }
186  }
187  else
188  {
189  /* second number was entered, check for sanity */
191  {
192  fprintf( ioQQQ,
193  " The second (maximum) temperature for the map is%10.2e, but this is less than the first (minimum) temperature,%10.2e\n",
195  fprintf( ioQQQ, " HELP! I am confused!!\n" );
197  }
198  }
199  }
200 
201  /* now force to be log */
202  if( !lgLogOn )
203  {
204  if( plotCom.pltxmx[plotCom.nplot-1] <= 0. || plotCom.pltxmn[plotCom.nplot-1] <=
205  0. )
206  {
207  fprintf( ioQQQ,
208  " Limits for temperature are negative. This is impossible. Sorry.\n" );
210  }
213  }
214 
215  /* check that min is less than max */
217  {
218  fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
220  }
222  {
223  a = plotCom.pltxmx[plotCom.nplot-1];
225  plotCom.pltxmn[plotCom.nplot-1] = a;
226  }
227 
228  return;
229 }
230 
231 /*ParsePlotRangeContin set range for map to parse range option on map command */
233 {
234  bool
235  lgLogOn;
236  realnum a;
237 
238  DEBUG_ENTRY( "ParsePlotRangeContin()" );
239 
241 
242  if( !p.nMatch("RANG") )
243  {
244  /* no numbers on line, just set default limits to energy array */
245  plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm());
247  lgLogOn = true;
248  }
249  else if( p.lgEOL() )
250  {
251  /* no numbers on line, just set default limits to energy array */
252  plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm());
254  lgLogOn = true;
255  }
256  else
257  {
258  /* lower limit entered, now interprete it */
259  if( plotCom.pltxmn[plotCom.nplot-1] < 0. )
260  {
261  lgLogOn = true;
262  }
263  else if( plotCom.pltxmn[plotCom.nplot-1] == 0.0 )
264  {
265  /* option for first number to be zero, lower edge of array */
266  lgLogOn = false;
268  }
269  else
270  {
271  /* a positive number was entered */
272  lgLogOn = false;
273  }
274 
275  /* now look at upper limit */
277  if( p.lgEOL() || plotCom.pltxmx[plotCom.nplot-1] == 0.0 )
278  {
279  /* option for second number to be omitted or zero */
280  if( lgLogOn )
281  {
283  }
284  else
285  {
287  }
288  }
289  }
290 
291  /* now force to be log */
292  if( !lgLogOn )
293  {
296  }
297 
298  /* check that min is less than max */
300  {
301  fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
303  }
305  {
306  a = plotCom.pltxmx[plotCom.nplot-1];
308  plotCom.pltxmn[plotCom.nplot-1] = a;
309  }
310 
311  return;
312 }
realnum pltxmn[NDPLOT]
Definition: plot.h:23
double emm() const
Definition: mesh.h:93
bool nMatch(const char *chKey) const
Definition: parser.h:150
double FFmtRead(void)
Definition: parser.cpp:472
void ParsePlot(Parser &p)
Definition: parse_plot.cpp:16
FILE * ioQQQ
Definition: cddefines.cpp:7
Definition: parser.h:43
STATIC void ParsePlotRangeOption(Parser &p)
Definition: parse_plot.cpp:135
#define STATIC
Definition: cddefines.h:118
t_plotCom plotCom
Definition: plot.cpp:20
t_rfield rfield
Definition: rfield.cpp:9
float realnum
Definition: cddefines.h:124
#define EXIT_FAILURE
Definition: cddefines.h:168
#define cdEXIT(FAIL)
Definition: cddefines.h:482
bool lgPltTrace[NDPLOT]
Definition: plot.h:30
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
STATIC void ParsePlotRangeContin(Parser &p)
Definition: parse_plot.cpp:232
char chPType[NDPLOT][5]
Definition: plot.h:18
double egamry() const
Definition: mesh.h:97
bool lgEOL(void) const
Definition: parser.h:113
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
bool lgPlotON
Definition: plot.h:21
long int nplot
Definition: plot.h:27
realnum pltxmx[NDPLOT]
Definition: plot.h:23
#define NDPLOT
Definition: plot.h:13