cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
prt_columns.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 /*PrtColumns print column densities of all elements */
4 #include "cddefines.h"
5 #include "cddrive.h"
6 #include "dense.h"
7 #include "elementnames.h"
8 #include "h2.h"
9 #include "taulines.h"
10 #include "molcol.h"
11 #include "generic_state.h"
12 #include "prt.h"
13 
15  /* this is stream used for io, is stdout when called by final,
16  * is save unit when save output generated */
17  FILE *ioMEAN )
18 {
19  DEBUG_ENTRY( "PrtColumns()" );
20 
21  /* print molecular element column densities */
22  molcol("PRIN" , ioMEAN);
23 
24  fprintf( ioMEAN, "\n" );
25 
26  fprintf( ioMEAN, "\n " );
27  for( long i=1; i <= 17; i++ )
28  {
29  fprintf( ioMEAN, "%7ld", i );
30  }
31  fprintf( ioMEAN, "\n\n" );
32 
33  /* ionization column densities */
34  for( long nelem=0; nelem < LIMELM; nelem++ )
35  {
36  if( dense.lgElmtOn[nelem] )
37  {
38  bool lgDONE = false;
39 
40  fprintf( ioMEAN, " %10.10s", elementnames.chElementName[nelem] );
41 
42  long i = 1;
43  while( !lgDONE )
44  {
45  double aa;
46  if( cdColm(
47  /* return value is zero if all ok, 1 if errors happened */
48  /* 4-char + eol string that is first
49  * 4 char of element name as spelled by cloudy */
51 
52  /* integer stage of ionization, 1 for atom, 0 for CO or H2 */
53  i,
54 
55  /* the theoretical column density derived by the code */
56  &aa ) )
57  TotalInsanity();
58 
59  if( aa == 0. )
60  {
61  aa = -30.;
62  }
63  else if( aa > 0. )
64  {
65  aa = log10(aa);
66  }
67 
68  if( i == 18 )
69  {
70  fprintf( ioMEAN, "\n" );
71  }
72  fprintf( ioMEAN, "%7.3f", aa );
73 
74  /* increment counter and check if at upper limit */
75  ++i;
76  /* MAX2 is to include H2 in H array */
77  if( i > MAX2(3,nelem+2) )
78  lgDONE = true;
79 
80  /* print title for this info if we are done with hydrogen */
81  if( nelem==ipHYDROGEN && lgDONE )
82  fprintf(ioMEAN," (H2) Log10 Column density (cm^-2)");
83  }
84 
85  fprintf( ioMEAN, "\n" );
86  }
87  }
88 
89  /* only print excited state column densities if level2 lines are included
90  * since they populated the upper level by UV pumping. This process
91  * is not included if level2 lines are not considered, by introducing
92  * the "no level2" command */
93  if( nWindLine>0 )
94  {
95  const int nEXCIT_COL = 12;
96  // use strings instead of char[][] to avoid bogus errors with PGCC bounds checking
97  string strExcit_Col[nEXCIT_COL]={
98  "He[2]","C+[2]","C[1]","C[2]","C[3]","O[1]","O[2]","O[3]","Si+[1]","C+2[2]","C+2[3]","C+2[4]"};
99  /* print excited level column densities */
100  fprintf(ioMEAN," Exc state ");
101  long int nprt = 12;
102  for(long i=0; i<nEXCIT_COL; ++i )
103  {
104  ASSERT( strExcit_Col[i].size() <= NCHLAB-1 );
105  vector<genericState> v = matchGeneric(strExcit_Col[i].c_str(),false);
106  ASSERT ( v.size() <= 1 );
107  genericState gs= v.size() == 1 ? v[0] : genericState();
108 
109  if( nprt > 120 )
110  {
111  fprintf(ioMEAN,"\n ");
112  nprt = 12;
113  }
114  fprintf(ioMEAN," %*.*s%7.3f",
115  NCHLAB-1,NCHLAB-1,strExcit_Col[i].c_str(),
116  log10(SDIV(column(gs)) ));
117  nprt += 10+(NCHLAB-1);
118  }
119  fprintf(ioMEAN,"\n");
120  }
121 
122  /* print column densities for H2 */
123  h2.H2_Prt_column_density(ioMEAN);
124 
125  fprintf(ioMEAN,"\n");
126 }
NORETURN void TotalInsanity(void)
Definition: service.cpp:971
void H2_Prt_column_density(FILE *ioMEAN)
Definition: mole_h2_io.cpp:368
vector< genericState > matchGeneric(const char *chLabel, bool lgValidate)
t_dense dense
Definition: global.cpp:15
t_elementnames elementnames
Definition: elementnames.cpp:5
diatomics h2("h2", 4100.,&hmi.H2_total, Yan_H2_CS)
double column(const genericState &gs)
void PrtColumns(FILE *ioMEAN)
Definition: prt_columns.cpp:14
long nWindLine
Definition: cdinit.cpp:19
void molcol(const char *chLabel, FILE *ioMEAN)
Definition: molcol.cpp:11
char chElementNameShort[LIMELM][CHARS_ELEMENT_NAME_SHORT]
Definition: elementnames.h:21
bool lgElmtOn[LIMELM]
Definition: dense.h:160
#define ASSERT(exp)
Definition: cddefines.h:613
const int LIMELM
Definition: cddefines.h:308
int cdColm(const char *chLabel, long int ion, double *theocl)
Definition: cddrive.cpp:592
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
const int NCHLAB
Definition: cddefines.h:304
#define MAX2(a, b)
Definition: cddefines.h:824
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
sys_float SDIV(sys_float x)
Definition: cddefines.h:1002
char chElementName[LIMELM][CHARS_ELEMENT_NAME]
Definition: elementnames.h:17
const int ipHYDROGEN
Definition: cddefines.h:349