cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
prt_met.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 /*prtmet print all line optical depths at end of iteration */
4 #include "cddefines.h"
5 #include "taulines.h"
6 #include "h2.h"
7 #include "iso.h"
8 #include "dense.h"
9 #include "prt.h"
10 #include "trace.h"
11 
12 STATIC void prme(
13  const bool lgReset,
14  const TransitionProxy &t);
15 
16 STATIC void prt_header_cols();
17 
18 /*prtmet print all line optical depths at end of iteration */
19 void prtmet(void)
20 {
21  DEBUG_ENTRY( "prtmet()" );
22 
23  /* default is to not print optical depths, turn on with
24  * print optical depths on command */
25  if( prt.lgPrtTau || (trace.lgTrace && trace.lgOptcBug) )
26  {
27  fprintf( ioQQQ, "\n\n Mean Line Optical Depths\n");
28 
30 
31  /* iso sequences */
32  for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO )
33  {
34  for( long nelem=ipISO; nelem < LIMELM; nelem++ )
35  {
36  if( dense.lgElmtOn[nelem] )
37  {
38  if( (*iso_sp[ipISO][nelem].trans(1,0).Lo()).ColDen() <= 0. )
39  continue;
40 
41  /* print Lyman, Balmer, Paschen, etc sequence optical depths */
42  for( long ipLo=0; ipLo < iso_sp[ipISO][nelem].numLevels_local-1; ipLo++ )
43  {
44  for( long ipHi=ipLo+1; ipHi < iso_sp[ipISO][nelem].numLevels_local; ipHi++ )
45  {
46  prme(false,iso_sp[ipISO][nelem].trans(ipHi,ipLo));
47  }
48  }
49  }
50  }
51  }
52 
53  /* print main lines optical depths */
54  for( long i=0; i < nWindLine; i++ )
55  {
56  if( (*TauLine2[i].Hi()).IonStg() < (*TauLine2[i].Hi()).nelem()+1-NISO )
57  {
58  prme(false,TauLine2[i]);
59  }
60  }
61 
62  for( size_t i=0; i < UTALines.size(); i++ )
63  {
64  prme(false,UTALines[i]);
65  }
66 
67  /* print H2 line optical depths */
68  for( diatom_iter diatom = diatoms.begin(); diatom != diatoms.end(); ++diatom )
69  {
70  for( TransitionList::iterator tr = (*diatom)->trans.begin();
71  tr != (*diatom)->trans.end(); ++tr )
72  {
73  if( (*tr).ipCont() <= 0 )
74  continue;
75  prme( false, *tr );
76  }
77  }
78 
79  for( size_t i=0; i < HFLines.size(); i++ )
80  {
81  prme(false,HFLines[i]);
82  }
83 
84  /* data base lines */
85  for (int ipSpecies=0; ipSpecies < nSpecies; ++ipSpecies)
86  {
87  for( EmissionList::iterator em=dBaseTrans[ipSpecies].Emis().begin();
88  em != dBaseTrans[ipSpecies].Emis().end(); ++em)
89  {
90  prme(false,(*em).Tran());
91  }
92  }
93 
94  fprintf( ioQQQ, "\n");
95  }
96  return;
97 }
98 
100 {
101  string columns = "Species Wavelength Total Single ";
102  size_t nchars = columns.length();
103  size_t header_len = 0;
104 
105  while( header_len < NCOLMAX )
106  {
107  fprintf( ioQQQ, "%s", columns.c_str() );
108  header_len += nchars;
109  if( header_len > NCOLMAX )
110  continue;
111  fprintf( ioQQQ, "%s", prt_linecol.col_gap.c_str() );
112  header_len += prt_linecol.col_gap_len;
113  }
114 
115  fprintf( ioQQQ, "\n");
116 }
117 
118 
119 /* prme - print line optical depth */
121  const bool lgReset,
122  const TransitionProxy &t)
123 {
124  static long int n ;
125 
126  DEBUG_ENTRY( "prme()" );
127 
128  if( lgReset )
129  n = 0;
130 
131  if( t.ipCont() <= 0 )
132  {
133  /* line is not transferred */
134  return;
135  }
136 
137  if( (*t.Lo()).ColDen() <= 0. )
138  return;
139 
140  /* print optical depth if greater than lower limit, or significantly negative
141  * PrtTauFnt is threshold for printing it
142  * */
143  if( t.Emis().TauIn()*SQRTPI > prt.PrtTauFnt || t.Emis().TauIn()*SQRTPI < -1e-5 )
144  {
145  // throw CR after printing NCOLMAX characters
146  const int NOPCMAX = 10;
147  string label = t.chLabel();
148  long len = 2*NOPCMAX + label.size();
149 
150  // Reset n if would overflow
151  if(n+len > NCOLMAX)
152  {
153  n = 0;
154  fprintf( ioQQQ, "\n");
155  }
156  fprintf( ioQQQ, "%s", label.c_str() );
157  /*>> chng 12 jul 25, print mean optical depths, rather than line center */
158  fprintf( ioQQQ, "%*.2e", NOPCMAX, t.Emis().TauIn()*SQRTPI );
159 
160  fprintf( ioQQQ, "%*.2e", NOPCMAX, t.Emis().TauInSpecific()*SQRTPI );
161 
162  // Add wide gap between columns
163  if( n + 2*len + prt_linecol.col_gap_len < NCOLMAX )
164  {
165  fprintf( ioQQQ, "%s", prt_linecol.col_gap.c_str() );
166  len += prt_linecol.col_gap_len;
167  }
168  else
169  {
170  n = NCOLMAX;
171  }
172  n += len;
173  }
174 
175  return;
176 }
STATIC void prme(const bool lgReset, const TransitionProxy &t)
Definition: prt_met.cpp:120
realnum & TauInSpecific() const
Definition: emission.h:480
t_line_col prt_linecol
Definition: prt.cpp:15
bool lgPrtTau
Definition: prt.h:171
const long NCOLMAX
Definition: prt.h:13
size_t size(void) const
Definition: transition.h:331
TransitionList UTALines("UTALines",&AnonStates)
const int NISO
Definition: cddefines.h:311
TransitionList HFLines("HFLines",&AnonStates)
int col_gap_len
Definition: prt.h:329
FILE * ioQQQ
Definition: cddefines.cpp:7
TransitionList TauLine2("TauLine2",&AnonStates)
long int nSpecies
Definition: taulines.cpp:22
t_dense dense
Definition: global.cpp:15
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:11
t_trace trace
Definition: trace.cpp:5
void prtmet(void)
Definition: prt_met.cpp:19
#define STATIC
Definition: cddefines.h:118
bool lgTrace
Definition: trace.h:12
EmissionList::reference Emis() const
Definition: transition.h:447
long & ipCont() const
Definition: transition.h:489
vector< diatomics * > diatoms
Definition: h2.cpp:8
STATIC void prt_header_cols()
Definition: prt_met.cpp:99
long nWindLine
Definition: cdinit.cpp:19
t_prt prt
Definition: prt.cpp:14
bool lgElmtOn[LIMELM]
Definition: dense.h:160
string chLabel() const
Definition: transition.cpp:274
string col_gap
Definition: prt.h:335
realnum PrtTauFnt
Definition: prt.h:182
qList::iterator Lo() const
Definition: transition.h:431
const int ipH_LIKE
Definition: iso.h:64
const int LIMELM
Definition: cddefines.h:308
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
bool lgOptcBug
Definition: trace.h:49
vector< TransitionList > dBaseTrans
Definition: taulines.cpp:18
long int numLevels_local
Definition: iso.h:529
realnum & TauIn() const
Definition: emission.h:470
vector< diatomics * >::iterator diatom_iter
Definition: h2.h:13