cloudy  trunk
prt_lines_general.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2013 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 "hydrogenic.h"
8 #include "dense.h"
9 #include "thermal.h"
10 #include "continuum.h"
11 #include "geometry.h"
12 #include "dynamics.h"
13 #include "rt.h"
14 #include "iso.h"
15 #include "rfield.h"
16 #include "trace.h"
17 #include "ionbal.h"
18 #include "lines_service.h"
19 #include "radius.h"
20 #include "lines.h"
21 
22 void lines_general(void)
23 {
24  long int i,
25  ipHi,
26  ipLo,
27  nelem,
28  ipnt;
29 
30  double
31  hbetac,
32  HeatMetal ,
33  ee511,
34  hlalph;
35 
36  DEBUG_ENTRY( "lines_general()" );
37 
38  if( trace.lgTrace )
39  {
40  fprintf( ioQQQ, " lines_general called\n" );
41  }
42 
43  i = StuffComment( "general properties" );
44  linadd( 0., (realnum)i , "####", 'i',
45  " start of general properties");
46 
47  /* total H-beta from multi-level atom */
48  nelem = ipHYDROGEN;
49  ipLo = ipH2p;
50 
51  // this can be changed with the atom levels command but must be at
52  // least 3
53  ASSERT( iso_sp[ipH_LIKE][nelem].n_HighestResolved_max >=3 );
54 
55  if( iso_sp[ipH_LIKE][nelem].n_HighestResolved_max >= 4 )
56  {
57  ipHi = ipH4p;
58  hbetac =
59  (iso_sp[ipH_LIKE][nelem].trans(ipH4p,ipH2s).Emis().Aul() *
60  (iso_sp[ipH_LIKE][nelem].trans(ipH4p,ipH2s).Emis().Pesc() +
61  iso_sp[ipH_LIKE][nelem].trans(ipH4p,ipH2s).Emis().Pelec_esc() ) *
62  iso_sp[ipH_LIKE][nelem].st[ipH4p].Pop() +
63  iso_sp[ipH_LIKE][nelem].trans(ipH4s,ipH2p).Emis().Aul() *
64  (iso_sp[ipH_LIKE][nelem].trans(ipH4s,ipH2p).Emis().Pesc() +
65  iso_sp[ipH_LIKE][nelem].trans(ipH4s,ipH2p).Emis().Pelec_esc() ) *
66  iso_sp[ipH_LIKE][nelem].st[ipH4s].Pop() +
67  iso_sp[ipH_LIKE][nelem].trans(ipH4d,ipH2p).Emis().Aul() *
68  (iso_sp[ipH_LIKE][nelem].trans(ipH4d,ipH2p).Emis().Pesc() +
69  iso_sp[ipH_LIKE][nelem].trans(ipH4d,ipH2p).Emis().Pelec_esc() ) *
70  iso_sp[ipH_LIKE][nelem].st[ipH4d].Pop()) *
71  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).EnergyErg();
72  }
73  else
74  {
75  // atom levels command does not allow < 3
76  ASSERT( iso_sp[ipH_LIKE][nelem].n_HighestResolved_max == 3 );
77  ipHi = 6;
78  hbetac =
79  (iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).Emis().Aul() *
80  (iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).Emis().Pesc() +
81  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).Emis().Pelec_esc() ) +
82  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2p).Emis().Aul() *
83  (iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2p).Emis().Pesc() +
84  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2p).Emis().Pelec_esc() ) ) *
85  iso_sp[ipH_LIKE][nelem].st[ipHi].Pop() *
86  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).EnergyErg();
87  }
88 
89  /* these lines added to outlin in metdif - following must be false
90  * this passes array index for line energy in continuum mesh - in rest
91  * of code this is set by a previous call to PntForLine, this index
92  * is on the f not c scale */
93  rt.fracin = iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).Emis().FracInwd();
94  lindst(hbetac,iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).WLAng(),"TOTL",
95  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).ipCont(),'t',false,
96  " H I Balmer beta predicted by model atom " );
97  rt.fracin = 0.5;
98 
99  if( iso_sp[ipH_LIKE][nelem].n_HighestResolved_max < 4 )
100  {
101  // we need to have something for Hb "H 1" and "Inwd"
102  lindst(hbetac,iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).WLAng(),"H 1",
103  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).ipCont(),'t',false,
104  " H I Balmer beta predicted by model atom " );
105  // we need to have something for Hb "H 1" and "Inwd"
106  lindst(hbetac/2.,iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).WLAng(),"Inwd",
107  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipH2s).ipCont(),'t',false,
108  " H I Balmer beta predicted by model atom " );
109  }
110 
111  /* total Ly-a from multi-level atom */
112  ipHi = ipH2p;
113  ipLo = ipH1s;
114  hlalph =
115  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).Emis().Aul()*
116  iso_sp[ipH_LIKE][nelem].st[ipHi].Pop()*
117  (iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).Emis().Pesc() +
118  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).Emis().Pelec_esc() )*
119  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).EnergyErg();
120 
121  rt.fracin = iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).Emis().FracInwd();
122  lindst(hlalph,iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).WLAng(),"TOTL",
123  iso_sp[ipH_LIKE][nelem].trans(ipHi,ipLo).ipCont(),'t',false ,
124  " H I Lya predicted from model atom ");
125  rt.fracin = 0.5;
126 
127  /* this entry only works correctly if the APERTURE command is not in effect */
128  if( geometry.iEmissPower == 2 )
129  {
130  linadd(continuum.totlsv/radius.dVeffAper,0,"Inci",'i',
131  "total luminosity in incident continuum");
132  /* ipass is flag to indicate whether to only set up line array
133  * (ipass=0) or actually evaluate lines intensities (ipass=1) */
134  if( LineSave.ipass > 0 )
135  {
136  continuum.totlsv = 0.;
137  }
138  }
139 
140  linadd(thermal.htot,0,"TotH",'i',
141  " total heating, all forms, information since individuals added later ");
142 
143  linadd(thermal.ctot,0,"TotC",'i',
144  " total cooling, all forms, information since individuals added later ");
145 
146  linadd(thermal.heating[0][0],0,"BFH1",'h',
147  " hydrogen photoionization heating, ground state only ");
148 
149  linadd(thermal.heating[0][1],0,"BFHx",'h',
150  " net hydrogen photoionization heating less rec cooling, all excited states normally zero, positive if excited states are net heating ");
151 
152  linadd(thermal.heating[0][22],0,"Line",'h',
153  " heating due to induced lines absorption of continuum ");
154  if( thermal.htot > 0. )
155  {
157  {
159  }
160  }
161 
162  linadd(thermal.heating[1][0]+thermal.heating[1][1]+thermal.heating[1][2],0,"BFHe",'h',
163  " total helium photoionization heating, all stages ");
164 
165  HeatMetal = 0.;
166  /* some sums that will be printed in the stack */
167  for( nelem=2; nelem<LIMELM; ++nelem)
168  {
169  /* we now have final solution for this element */
170  for( i=dense.IonLow[nelem]; i < dense.IonHigh[nelem]; i++ )
171  {
172  ASSERT( i < LIMELM );
173  /* total metal photo heating for LINES */
174  HeatMetal += thermal.heating[nelem][i];
175  }
176  }
177 
178  linadd(HeatMetal,0,"TotM",'h',
179  " total heavy element photoionization heating, all stages ");
180 
181  linadd(thermal.heating[0][21],0,"pair",'h',
182  " heating due to pair production ");
183 
184  /* ipass is flag to indicate whether to only set up line array
185  * (ipass=0) or actually evaluate lines intensities (ipass=1) */
186  if( LineSave.ipass > 0 )
187  {
188  /* this will be max local heating due to bound compton */
190  }
191  else
192  {
193  ionbal.CompHeating_Max = 0.;
194  }
195 
196  linadd(ionbal.CompRecoilHeatLocal,0,"Cbnd",'h',
197  " heating due to bound compton scattering ");
198 
199  linadd(rfield.cmheat,0,"ComH",'h',
200  " Compton heating ");
201 
202  linadd(CoolHeavy.tccool,0,"ComC",'c',
203  " total Compton cooling ");
204 
205  /* record max local heating due to advection */
207  /* record max local cooling due to advection */
209 
210  linadd(dynamics.Cool() , 0 , "advC" , 'i',
211  " cooling due to advection " );
212 
213  linadd(dynamics.Heat() , 0 , "advH" , 'i' ,
214  " heating due to advection ");
215 
216  linadd( thermal.char_tran_heat ,0,"CT H",'h',
217  " heating due to charge transfer ");
218 
219  linadd( thermal.char_tran_cool ,0,"CT C",'c',
220  " cooling due to charge transfer ");
221 
222  linadd(thermal.heating[1][6],0,"CR H",'h',
223  " cosmic ray heating ");
224 
225  linadd(thermal.heating[0][20],0,"extH",'h',
226  " extra heat added to this zone, from HEXTRA command ");
227 
228  linadd(CoolHeavy.cextxx,0,"extC",'c',
229  " extra cooling added to this zone, from CEXTRA command ");
230 
231  // 511 keV annihilation line, counts as recombination line since
232  // neither heating nor cooling, but does remove energy
234  PntForLine(2.427e-2,"e-e+",&ipnt);
235  lindst(ee511,(realnum)2.427e-2,"e-e+",ipnt,'r',true,
236  " 511keV annihilation line " );
237 
238  linadd(CoolHeavy.expans,0,"Expn",'c',
239  " expansion cooling, only non-zero for wind ");
240 
241  linadd(iso_sp[ipH_LIKE][ipHYDROGEN].RadRecCool,0,"H FB",'i',
242  " H radiative recombination cooling ");
243 
244  linadd(MAX2(0.,iso_sp[ipH_LIKE][ipHYDROGEN].FreeBnd_net_Cool_Rate),0,"HFBc",'c',
245  " net free-bound cooling ");
246 
247  linadd(MAX2(0.,-iso_sp[ipH_LIKE][ipHYDROGEN].FreeBnd_net_Cool_Rate),0,"HFBh",'h',
248  " net free-bound heating ");
249 
250  linadd(iso_sp[ipH_LIKE][ipHYDROGEN].RecomInducCool_Rate,0,"Hind",'c',
251  " cooling due to induced rec of hydrogen ");
252 
253  linadd(CoolHeavy.cyntrn,0,"Cycn",'c',
254  " cyclotron cooling ");
255 
256  // cooling due to database species
257  for( long ipSpecies=0; ipSpecies<nSpecies; ipSpecies++ )
258  {
259  // label may be too long for linadd
260  char chLabel[5];
261  strncpy( chLabel, dBaseStates[ipSpecies][0].chLabel(), 4 );
262  chLabel[4] = '\0';
263  // this is information, 'i', since individual lines
264  // have been added as cooling or heating
265  linadd(dBaseSpecies[ipSpecies].CoolTotal,0, chLabel,'i',
266  " net cooling due to database species");
267  }
268 
269  return;
270 }
271 
thermal.h
t_dynamics::Heat
double Heat()
Definition: dynamics.cpp:2173
TransitionProxy::EnergyErg
realnum EnergyErg() const
Definition: transition.h:78
t_CoolHeavy::cextxx
double cextxx
Definition: coolheavy.h:74
lines.h
PntForLine
void PntForLine(double wavelength, const char *chLabel, long int *ipnt)
Definition: lines_service.cpp:583
t_ionbal::PairProducPhotoRate
double PairProducPhotoRate[3]
Definition: ionbal.h:141
dense
t_dense dense
Definition: dense.cpp:24
rfield
t_rfield rfield
Definition: rfield.cpp:8
ioQQQ
FILE * ioQQQ
Definition: cddefines.cpp:7
geometry.h
t_ionbal::CompHeating_Max
double CompHeating_Max
Definition: ionbal.h:190
t_dynamics::CoolMax
double CoolMax
Definition: dynamics.h:68
lines_general
void lines_general(void)
Definition: prt_lines_general.cpp:22
realnum
float realnum
Definition: cddefines.h:103
t_radius::dVeffAper
double dVeffAper
Definition: radius.h:87
rfield.h
t_CoolHeavy::tccool
double tccool
Definition: coolheavy.h:72
t_thermal::char_tran_heat
double char_tran_heat
Definition: thermal.h:146
trace.h
t_dense::gas_phase
realnum gas_phase[LIMELM]
Definition: dense.h:71
lines_service.h
dynamics.h
ASSERT
#define ASSERT(exp)
Definition: cddefines.h:578
t_rt::fracin
realnum fracin
Definition: rt.h:239
iso.h
t_thermal::HeatLineMax
realnum HeatLineMax
Definition: thermal.h:164
ipHYDROGEN
const int ipHYDROGEN
Definition: cddefines.h:305
t_thermal::ctot
double ctot
Definition: thermal.h:112
lindst
void lindst(double xInten, realnum wavelength, const char *chLab, long int ipnt, char chInfo, bool lgOutToo, const char *chComment)
Definition: lines_service.cpp:468
ipH4p
const int ipH4p
Definition: iso.h:34
ipH4d
const int ipH4d
Definition: iso.h:35
LineSave
t_LineSave LineSave
Definition: lines.cpp:5
radius
t_radius radius
Definition: radius.cpp:5
t_thermal::char_tran_cool
double char_tran_cool
Definition: thermal.h:146
TransitionProxy::Emis
EmissionList::reference Emis() const
Definition: transition.h:408
linadd
void linadd(double xInten, realnum wavelength, const char *chLab, char chInfo, const char *chComment)
Definition: lines_service.cpp:316
dense.h
coolheavy.h
trace
t_trace trace
Definition: trace.cpp:5
cddefines.h
ipH2s
const int ipH2s
Definition: iso.h:28
t_LineSave::ipass
long int ipass
Definition: lines.h:75
thermal
t_thermal thermal
Definition: thermal.cpp:5
t_thermal::heating
double heating[LIMELM][LIMELM]
Definition: thermal.h:158
radius.h
t_ionbal::CompRecoilHeatLocal
double CompRecoilHeatLocal
Definition: ionbal.h:152
MAX2
#define MAX2
Definition: cddefines.h:782
ionbal
t_ionbal ionbal
Definition: ionbal.cpp:5
LIMELM
const int LIMELM
Definition: cddefines.h:258
t_rfield::cmheat
double cmheat
Definition: rfield.h:292
t_geometry::iEmissPower
long int iEmissPower
Definition: geometry.h:61
t_dense::IonLow
long int IonLow[LIMELM+1]
Definition: dense.h:119
t_iso_sp::st
qList st
Definition: iso.h:453
t_dynamics::HeatMax
double HeatMax
Definition: dynamics.h:68
t_dense::IonHigh
long int IonHigh[LIMELM+1]
Definition: dense.h:120
hydrogenic.h
EmissionProxy::Pelec_esc
realnum & Pelec_esc() const
Definition: emission.h:533
t_thermal::htot
double htot
Definition: thermal.h:149
ipH2p
const int ipH2p
Definition: iso.h:29
rt.h
ionbal.h
EmissionProxy::Pesc
realnum & Pesc() const
Definition: emission.h:523
dynamics
t_dynamics dynamics
Definition: dynamics.cpp:44
dBaseSpecies
species * dBaseSpecies
Definition: taulines.cpp:14
rt
t_rt rt
Definition: rt.cpp:5
ipHELIUM
const int ipHELIUM
Definition: cddefines.h:306
t_CoolHeavy::cyntrn
double cyntrn
Definition: coolheavy.h:98
t_iso_sp::trans
TransitionProxy trans(const long ipHi, const long ipLo)
Definition: iso.h:444
taulines.h
CoolHeavy
t_CoolHeavy CoolHeavy
Definition: coolheavy.cpp:5
StuffComment
long int StuffComment(const char *chComment)
Definition: prt_final.cpp:1932
ipH4s
const int ipH4s
Definition: iso.h:33
t_continuum::totlsv
double totlsv
Definition: continuum.h:98
geometry
t_geometry geometry
Definition: geometry.cpp:5
dBaseStates
vector< qList > dBaseStates
Definition: taulines.cpp:15
ipH1s
const int ipH1s
Definition: iso.h:27
continuum
t_continuum continuum
Definition: continuum.cpp:5
iso_sp
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:8
continuum.h
t_CoolHeavy::expans
double expans
Definition: coolheavy.h:73
nSpecies
long int nSpecies
Definition: taulines.cpp:21
EmissionProxy::Aul
realnum & Aul() const
Definition: emission.h:613
EmissionProxy::FracInwd
realnum & FracInwd() const
Definition: emission.h:463
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:684
ipH_LIKE
const int ipH_LIKE
Definition: iso.h:62
t_dynamics::Cool
double Cool()
Definition: dynamics.cpp:2187
t_trace::lgTrace
bool lgTrace
Definition: trace.h:12