cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
prt_lines_general.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 /*lines_general put general information and energetics into line intensity stack */
4 #include "cddefines.h"
5 #include "taulines.h"
6 #include "coolheavy.h"
7 #include "thermal.h"
8 #include "continuum.h"
9 #include "geometry.h"
10 #include "dynamics.h"
11 #include "iso.h"
12 #include "rfield.h"
13 #include "trace.h"
14 #include "ionbal.h"
15 #include "radius.h"
16 #include "lines.h"
17 #include "dense.h"
18 #include "lines_service.h"
19 
20 void lines_general(void)
21 {
22  long int i,
23  nelem,
24  ipnt;
25 
26  double
27  HeatMetal ,
28  ee511;
29 
30  DEBUG_ENTRY( "lines_general()" );
31 
32  if( trace.lgTrace )
33  {
34  fprintf( ioQQQ, " lines_general called\n" );
35  }
36 
37  i = StuffComment( "general properties" );
38  linadd( 0., (realnum)i , "####", 'i',
39  " start of general properties");
40 
41  /* this entry only works correctly if the APERTURE command is not in effect */
42  if( geometry.iEmissPower == 2 )
43  {
44  linadd(continuum.totlsv/radius.dVeffAper,0,"Inci",'i',
45  "total luminosity in incident continuum");
46  /* ipass is flag to indicate whether to only set up line array
47  * (ipass=0) or actually evaluate lines intensities (ipass=1) */
48  if( LineSave.ipass > 0 )
49  {
50  continuum.totlsv = 0.;
51  }
52  }
53 
54  linadd(thermal.htot,0,"TotH",'i',
55  " total heating, all forms, information since individuals added later ");
56 
57  linadd(thermal.ctot,0,"TotC",'i',
58  " total cooling, all forms, information since individuals added later ");
59 
60  linadd(thermal.heating(0,0),0,"BFH1",'h',
61  " hydrogen photoionization heating, ground state only ");
62 
63  linadd(thermal.heating(0,1),0,"BFHx",'h',
64  " net hydrogen photoionization heating less rec cooling, all excited states normally zero, positive if excited states are net heating ");
65 
66  linadd(thermal.heating(0,22),0,"Line",'h',
67  " heating due to induced lines absorption of continuum ");
68  if( thermal.htot > 0. )
69  {
71  {
73  }
74  }
75 
76  linadd(thermal.heating(1,0)+thermal.heating(1,1)+thermal.heating(1,2),0,"BFHe",'h',
77  " total helium photoionization heating, all stages ");
78 
79  HeatMetal = 0.;
80  /* some sums that will be printed in the stack */
81  for( nelem=2; nelem<LIMELM; ++nelem)
82  {
83  /* we now have final solution for this element */
84  for( i=dense.IonLow[nelem]; i < dense.IonHigh[nelem]; i++ )
85  {
86  ASSERT( i < LIMELM );
87  /* total metal photo heating for LINES */
88  HeatMetal += thermal.heating(nelem,i);
89  }
90  }
91 
92  linadd(HeatMetal,0,"TotM",'h',
93  " total heavy element photoionization heating, all stages ");
94 
95  linadd(thermal.heating(0,21),0,"pair",'h',
96  " heating due to pair production ");
97 
98  /* ipass is flag to indicate whether to only set up line array
99  * (ipass=0) or actually evaluate lines intensities (ipass=1) */
100  if( LineSave.ipass > 0 )
101  {
102  /* this will be max local heating due to bound compton */
104  }
105  else
106  {
107  ionbal.CompHeating_Max = 0.;
108  }
109 
110  linadd(ionbal.CompRecoilHeatLocal,0,"Cbnd",'h',
111  " heating due to bound compton scattering ");
112 
113  linadd(rfield.cmheat,0,"ComH",'h',
114  " Compton heating ");
115 
116  linadd(CoolHeavy.tccool,0,"ComC",'c',
117  " total Compton cooling ");
118 
119  /* record max local heating due to advection */
121  /* record max local cooling due to advection */
123 
124  linadd(dynamics.Cool() , 0 , "advC" , 'i',
125  " cooling due to advection " );
126 
127  linadd(dynamics.Heat() , 0 , "advH" , 'i' ,
128  " heating due to advection ");
129 
130  linadd( thermal.char_tran_heat ,0,"CT H",'h',
131  " heating due to charge transfer ");
132 
133  linadd( thermal.char_tran_cool ,0,"CT C",'c',
134  " cooling due to charge transfer ");
135 
136  linadd(thermal.heating(1,6),0,"CR H",'h',
137  " cosmic ray heating ");
138 
139  linadd(thermal.heating(0,20),0,"extH",'h',
140  " extra heat added to this zone, from HEXTRA command ");
141 
142  linadd(CoolHeavy.cextxx,0,"extC",'c',
143  " extra cooling added to this zone, from CEXTRA command ");
144 
145  // 511 keV annihilation line, counts as recombination line since
146  // neither heating nor cooling, but does remove energy
148  PntForLine(2.427e-2,"e-e+",&ipnt);
149  lindst(ee511,(realnum)2.427e-2,"e-e+",ipnt,'r',true,
150  " 511keV annihilation line " );
151 
152  linadd(CoolHeavy.expans,0,"Expn",'c',
153  " expansion cooling, only non-zero for wind ");
154 
155  linadd(iso_sp[ipH_LIKE][ipHYDROGEN].RadRecCool,0,"H FB",'i',
156  " H radiative recombination cooling ");
157 
158  linadd(MAX2(0.,iso_sp[ipH_LIKE][ipHYDROGEN].FreeBnd_net_Cool_Rate),0,"HFBc",'c',
159  " net free-bound cooling ");
160 
161  linadd(MAX2(0.,-iso_sp[ipH_LIKE][ipHYDROGEN].FreeBnd_net_Cool_Rate),0,"HFBh",'h',
162  " net free-bound heating ");
163 
164  linadd(iso_sp[ipH_LIKE][ipHYDROGEN].RecomInducCool_Rate,0,"Hind",'c',
165  " cooling due to induced rec of hydrogen ");
166 
167  linadd(CoolHeavy.cyntrn,0,"Cycn",'c',
168  " cyclotron cooling ");
169 
170  // cooling due to iso-sequence species
171  for( size_t ipISO = ipH_LIKE; ipISO <= size_t(ipHE_LIKE); ipISO++ )
172  {
173  for( size_t nelem = ipISO; nelem < size_t(LIMELM); nelem++ )
174  {
175  string chLabel_base = chIonLbl( nelem+1, nelem+1-ipISO );
176  // label may be too long for linadd
177  size_t nchars = min( NCHLAB-1, chLabel_base.length() );
178  char chLabel_cool[NCHLAB] = { 0 },
179  chLabel_heat[NCHLAB] = { 0 };
180  strncpy( chLabel_cool, chLabel_base.c_str(), NCHLAB-1 );
181  strncpy( chLabel_heat, chLabel_base.c_str(), NCHLAB-1 );
182  if( nchars < NCHLAB-1 )
183  {
184  chLabel_cool[ nchars ] = 'c';
185  chLabel_heat[ nchars ] = 'h';
186  }
187  // this is information, 'i', since individual lines
188  // have been added as cooling or heating
189  linadd(max(0., iso_sp[ipISO][nelem].xLineTotCool),0, chLabel_cool,'c',
190  " net cooling due to iso-seq species");
191  linadd(max(0., -iso_sp[ipISO][nelem].xLineTotCool),0, chLabel_heat,'h',
192  " heating due to iso-seq species");
193  }
194  }
195 
196  // cooling due to database species
197  for( long ipSpecies=0; ipSpecies<nSpecies; ipSpecies++ )
198  {
199  // label may be too long for linadd
200  size_t nchars = min( NCHLAB-1, strlen( dBaseSpecies[ipSpecies].chLabel ) );
201  char chLabel_cool[NCHLAB] = { 0 },
202  chLabel_heat[NCHLAB] = { 0 };
203  strncpy( chLabel_cool, dBaseSpecies[ipSpecies].chLabel, NCHLAB-1 );
204  strncpy( chLabel_heat, dBaseSpecies[ipSpecies].chLabel, NCHLAB-1 );
205  if( nchars < NCHLAB-1 )
206  {
207  chLabel_cool[ nchars ] = 'c';
208  chLabel_heat[ nchars ] = 'h';
209  }
210  // this is information, 'i', since individual lines
211  // have been added as cooling or heating
212  linadd(max(0., dBaseSpecies[ipSpecies].CoolTotal),0, chLabel_cool,'c',
213  " net cooling due to database species");
214  linadd(max(0., -dBaseSpecies[ipSpecies].CoolTotal),0, chLabel_heat,'h',
215  " heating due to database species");
216  }
217 
218  return;
219 }
220 
double htot
Definition: thermal.h:169
t_thermal thermal
Definition: thermal.cpp:6
string chIonLbl(const TransitionProxy &t)
Definition: transition.cpp:233
double Cool()
Definition: dynamics.cpp:2207
const int ipHE_LIKE
Definition: iso.h:65
double expans
Definition: coolheavy.h:18
long int IonHigh[LIMELM+1]
Definition: dense.h:130
void lindst(double xEmiss, realnum wavelength, const char *chLab, long int ipnt, char chInfo, bool lgOutToo, const char *chComment)
long int iEmissPower
Definition: geometry.h:71
t_LineSave LineSave
Definition: lines.cpp:10
double char_tran_heat
Definition: thermal.h:166
t_CoolHeavy CoolHeavy
Definition: coolheavy.cpp:5
double char_tran_cool
Definition: thermal.h:166
FILE * ioQQQ
Definition: cddefines.cpp:7
t_dynamics dynamics
Definition: dynamics.cpp:42
long int nSpecies
Definition: taulines.cpp:22
double tccool
Definition: coolheavy.h:18
void PntForLine(double wavelength, const char *chLabel, long int *ipnt)
t_dense dense
Definition: global.cpp:15
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:11
double CompHeating_Max
Definition: ionbal.h:186
double Heat()
Definition: dynamics.cpp:2193
t_trace trace
Definition: trace.cpp:5
t_ionbal ionbal
Definition: ionbal.cpp:8
t_geometry geometry
Definition: geometry.cpp:5
long int IonLow[LIMELM+1]
Definition: dense.h:129
bool lgTrace
Definition: trace.h:12
LinSv * linadd(double xEmiss, realnum wavelength, const char *chLab, char chInfo, const char *chComment)
t_continuum continuum
Definition: continuum.cpp:6
t_rfield rfield
Definition: rfield.cpp:9
double cextxx
Definition: coolheavy.h:18
realnum HeatLineMax
Definition: thermal.h:181
float realnum
Definition: cddefines.h:124
long max(int a, long b)
Definition: cddefines.h:817
double cmheat
Definition: rfield.h:275
long min(int a, long b)
Definition: cddefines.h:762
sys_float safe_div(sys_float x, sys_float y, sys_float res_0by0)
Definition: cddefines.h:1011
t_radius radius
Definition: radius.cpp:5
void lines_general(void)
double heating(long nelem, long ion)
Definition: thermal.h:186
double CoolMax
Definition: dynamics.h:74
realnum gas_phase[LIMELM]
Definition: dense.h:76
#define ASSERT(exp)
Definition: cddefines.h:613
double CompRecoilHeatLocal
Definition: ionbal.h:156
const int ipH_LIKE
Definition: iso.h:64
const int LIMELM
Definition: cddefines.h:308
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
const int ipHELIUM
Definition: cddefines.h:350
vector< species > dBaseSpecies
Definition: taulines.cpp:15
double totlsv
Definition: continuum.h:71
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
double PairProducPhotoRate[3]
Definition: ionbal.h:145
const int ipHYDROGEN
Definition: cddefines.h:349
double cyntrn
Definition: coolheavy.h:18
double HeatMax
Definition: dynamics.h:74
long int ipass
Definition: lines.h:96
double dVeffAper
Definition: radius.h:93
double ctot
Definition: thermal.h:130
long int StuffComment(const char *chComment)
Definition: prt_final.cpp:1938