cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
prt_meanion.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 /*PrtMeanIon print mean ionization fractions or temperatures for all elements */
4 #include "cddefines.h"
5 #include "geometry.h"
6 #include "dense.h"
7 #include "mean.h"
8 #include "elementnames.h"
9 #include "prt.h"
10 
12  /* this is either 't' or 'i', for mean ionization or temperature */
13  char chType ,
14  /* true include density, false do not */
15  bool lgDensity ,
16  /* this is stream used for io, is stdout when called by final,
17  * is punch unit when punch output generated */
18  FILE *ioMEAN )
19 {
20  long int i,
21  limit,
22  n,
23  nelem;
24  /* >>chng 04 dec 31, had been static, not possible to ever set false if
25  * ever true, rm static */
26  bool lgPrtLots=false;
27 
28  realnum aa[64];
29 
30  DEBUG_ENTRY( "PrtMeanIon()" );
31 
32  /* print mean ionization or temperature?? */
33  /* chType must be i for ionization, or t for temperature */
34  ASSERT( chType == 'i' || chType == 't' );
35 
36  /* print mean ionization or temperature for the computed model
37  * the means are relative to the total atoms and ions and does not include molecules or grains */
38 
39  /* only print sphereical if not plane parallel */
40  /* >>>chng 99 may 01, test included one for sphere being set,
41  * so no printout when not set. now print even when sphere not
42  * set but geo is not plane parallel */
43  if( /*sphere.lgSphere &&*/ (!geometry.lgGeoPP) )
44  {
45 
46  /* get means for hydrogen and helium, MeanIonVolume is in mean.c */
47  MeanIonVolume(chType,ipHYDROGEN,&n,aa,lgDensity);
48  /*MeanIonVolume(chType,2,&n,c ,lgDensity);*/
49 
50  /* now print hydrogen, special since part of title goes here */
51  fprintf( ioMEAN, "\n Hydrogen " );
52  for( i=0; i < 3; i++ )
53  {
54  fprintf( ioMEAN, "%7.3f", aa[i] );
55  }
56  fprintf(ioMEAN," (H2)");
57  if( chType=='i' && lgDensity )
58  {
59  fprintf( ioMEAN,
60  " Log10 Mean Ionisation (over volume*electron density)\n" );
61  }
62  else if( chType=='i' )
63  {
64  fprintf( ioMEAN,
65  " Log10 Mean Ionisation (over volume)\n" );
66  }
67  else if( chType=='t' && lgDensity )
68  {
69  fprintf( ioMEAN,
70  " Log10 Mean Temperature (over volume*electron density)\n" );
71  }
72  else if( chType=='t' )
73  {
74  fprintf( ioMEAN,
75  " Log10 Mean Temperature (over volume)\n" );
76  }
77  else
78  {
79  fprintf(ioQQQ,"PrtMeanIon called with insane job\n");
80  }
81 
82  /* ionization fractions for remaining elements */
83  for( nelem=ipHELIUM; nelem < LIMELM; nelem++ )
84  {
85  if( dense.lgElmtOn[nelem] )
86  {
87  MeanIonVolume(chType,nelem,&n,aa,lgDensity);
88  limit = MIN2(17,n);
89  fprintf( ioMEAN, " %10.10s", elementnames.chElementName[nelem] );
90 
91  for( i=0; i < limit; i++ )
92  {
93  fprintf( ioMEAN, "%7.3f", aa[i] );
94  }
95  fprintf( ioMEAN, "\n" );
96 
97  if( n > 17 )
98  {
99  lgPrtLots = true;
100  fprintf( ioMEAN, " " );
101  for( i=17; i < n; i++ )
102  {
103  fprintf( ioMEAN, "%7.3f", aa[i] );
104  }
105  fprintf( ioMEAN, "\n" );
106  }
107  }
108  }
109  }
110 
111  fprintf( ioMEAN, "\n " );
112  for( i=1; i <= 17; i++ )
113  {
114  fprintf( ioMEAN, "%7ld", i );
115  }
116  fprintf( ioMEAN, "\n" );
117  if( lgPrtLots )
118  {
119  fprintf( ioMEAN, " " );
120  for( i=18; i <= LIMELM; i++ )
121  {
122  fprintf( ioMEAN, "%7ld", i );
123  }
124  fprintf( ioMEAN, "\n" );
125  }
126 
127  /* get hydrogen ionization fractions */
128  MeanIonRadius(chType,ipHYDROGEN,&n,aa,lgDensity);
129 
130  /* get helium ionization fractions
131  MeanIonRadius(chType,ipHELIUM,&n,c,lgDensity);*/
132 
133  fprintf( ioMEAN, "\n Hydrogen " );
134 
135  for( i=0; i < 3; i++ )
136  {
137  /* print hydrogen fractions */
138  fprintf( ioMEAN, "%7.3f", aa[i] );
139  }
140  fprintf(ioMEAN," (H2)");
141  if( chType=='i' && lgDensity )
142  {
143  fprintf( ioMEAN,
144  " Log10 Mean Ionisation (over radius*electron density)\n" );
145  }
146  else if( chType=='i' )
147  {
148  fprintf( ioMEAN,
149  " Log10 Mean Ionisation (over radius)\n" );
150  }
151  else if( chType=='t' && lgDensity )
152  {
153  fprintf( ioMEAN,
154  " Log10 Mean Temperature (over radius*electron density)\n" );
155  }
156  else if( chType=='t' )
157  {
158  fprintf( ioMEAN,
159  " Log10 Mean Temperature (over radius)\n" );
160  }
161  else
162  {
163  fprintf(ioQQQ,"PrtMeanIon called with insane job\n");
164  }
165 
166  /* now the remaining elements, he on up */
167  for( nelem=ipHELIUM; nelem < LIMELM; nelem++ )
168  {
169  if( dense.lgElmtOn[nelem] )
170  {
171  MeanIonRadius(chType,nelem,&n,aa,lgDensity);
172  limit = MIN2(17,n);
173  fprintf( ioMEAN, " %10.10s",
174  elementnames.chElementName[nelem] );
175  for( i=0; i < limit; i++ )
176  {
177  fprintf( ioMEAN, "%7.3f", aa[i] );
178  }
179  fprintf( ioMEAN, "\n" );
180 
181  if( n > 17 )
182  {
183  lgPrtLots = true;
184  fprintf( ioMEAN, " " );
185 
186  for( i=17; i < n; i++ )
187  {
188  fprintf( ioMEAN, "%7.3f", aa[i] );
189  }
190  fprintf( ioMEAN, "\n" );
191  }
192  }
193  }
194  return;
195 }

Generated for cloudy by doxygen 1.8.3.1