cloudy  trunk
 All Data Structures Namespaces 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-2022 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 "prt.h"
6 #include "geometry.h"
7 #include "dense.h"
8 #include "mean.h"
9 #include "elementnames.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 save unit when save 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[LIMELM+1];
29 
30  DEBUG_ENTRY( "PrtMeanIon()" );
31 
32  /* print mean ionization or temperature for the computed model
33  * the ionization means are relative to the total element */
34 
35  const char* type[3] = { "radius", "area", "volume" };
36 
37  for( int d=2; d >= 0; --d )
38  {
39  /* only print spherical 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( geometry.lgGeoPP && d > 0 )
44  continue;
45 
46  /* get means for hydrogen */
47  mean.MeanIon(chType,ipHYDROGEN,d,&n,aa,lgDensity);
48 
49  /* now print hydrogen, special since part of title goes here */
50  fprintf( ioMEAN, "\n Hydrogen " );
51  for( i=0; i < 3; i++ )
52  {
53  fprintf( ioMEAN, "%7.3f", aa[i] );
54  }
55  fprintf(ioMEAN," (H2)");
56  if( chType=='i' && lgDensity )
57  {
58  fprintf( ioMEAN,
59  " Log10 Mean Ionisation (over %s*electron density)\n", type[d] );
60  }
61  else if( chType=='i' )
62  {
63  fprintf( ioMEAN,
64  " Log10 Mean Ionisation (over %s)\n", type[d] );
65  }
66  else if( chType=='t' && lgDensity )
67  {
68  fprintf( ioMEAN,
69  " Log10 Mean Temperature (over %s*electron density)\n", type[d] );
70  }
71  else if( chType=='t' )
72  {
73  fprintf( ioMEAN,
74  " Log10 Mean Temperature (over %s)\n", type[d] );
75  }
76  else
77  {
78  fprintf( ioQQQ, " PrtMeanIon called with insane job: %c\n", chType );
79  TotalInsanity();
80  }
81 
82  /* ionization fractions for remaining elements */
83  for( nelem=ipHELIUM; nelem < LIMELM; nelem++ )
84  {
85  if( dense.lgElmtOn[nelem] )
86  {
87  mean.MeanIon(chType,nelem,d,&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  fprintf( ioMEAN, "\n " );
111  for( i=1; i <= 17; i++ )
112  {
113  fprintf( ioMEAN, "%7ld", i );
114  }
115  fprintf( ioMEAN, "\n" );
116  if( lgPrtLots )
117  {
118  fprintf( ioMEAN, " " );
119  for( i=18; i <= LIMELM; i++ )
120  {
121  fprintf( ioMEAN, "%7ld", i );
122  }
123  fprintf( ioMEAN, "\n" );
124  }
125  }
126  return;
127 }
NORETURN void TotalInsanity(void)
Definition: service.cpp:971
FILE * ioQQQ
Definition: cddefines.cpp:7
void PrtMeanIon(char chType, bool lgDensity, FILE *)
Definition: prt_meanion.cpp:11
#define MIN2(a, b)
Definition: cddefines.h:803
t_dense dense
Definition: global.cpp:15
t_elementnames elementnames
Definition: elementnames.cpp:5
t_geometry geometry
Definition: geometry.cpp:5
t_mean mean
Definition: mean.cpp:16
float realnum
Definition: cddefines.h:124
bool lgGeoPP
Definition: geometry.h:21
bool lgElmtOn[LIMELM]
Definition: dense.h:160
void MeanIon(char chType, long nelem, long dim, long *n, realnum arlog[], bool lgDensity) const
Definition: mean.cpp:151
const int LIMELM
Definition: cddefines.h:308
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
const int ipHELIUM
Definition: cddefines.h:350
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
char chElementName[LIMELM][CHARS_ELEMENT_NAME]
Definition: elementnames.h:17
const int ipHYDROGEN
Definition: cddefines.h:349