cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rt_tau_inc.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 /*RT_tau_inc increment optical depths once per zone, called after radius_increment */
4 #include "cddefines.h"
5 #include "elementnames.h"
6 #include "taulines.h"
7 #include "iso.h"
8 #include "rfield.h"
9 #include "trace.h"
10 #include "dense.h"
11 #include "prt.h"
12 #include "conv.h"
13 #include "h2.h"
14 #include "hmi.h"
15 #include "opacity.h"
16 #include "cooling.h"
17 #include "thermal.h"
18 #include "radius.h"
19 #include "rt.h"
20 #include "doppvel.h"
21 #include "mole.h"
22 
23 
24 void prt_trans_opc_debug( const char *LineGroup, const TransitionProxy &t )
25 {
26  fprintf( ioQQQ,
27  "%s:\t label= '%s'\t nelem= %d ('%s')\t ion= %2d\t dense= %.4e\t TauCon = %.4e\t TauIn= %.4e\t TauTot= %.4e\n",
28  LineGroup,
29  t.chLabel().c_str(),
30  int((*t.Hi()).nelem()),
31  elementnames.chElementSym[(*t.Hi()).nelem()-1],
32  int((*t.Hi()).IonStg()),
33  dense.xIonDense[(*t.Hi()).nelem()-1][(*t.Hi()).IonStg()-1],
34  t.Emis().TauCon(),
35  t.Emis().TauIn(),
36  t.Emis().TauTot() );
37 }
38 
39 /*RT_tau_inc increment optical depths once per zone, called after radius_increment */
40 void RT_tau_inc(void)
41 {
42  DEBUG_ENTRY( "RT_tau_inc()" );
43 
44  if( trace.lgTrace )
45  {
46  fprintf( ioQQQ, " RT_tau_inc called.\n" );
47  }
48 
49  /* call RT_line_all one last time in this zone, to get fine opacities defined */
52  RT_fine_clear();
54 
55  /* rfield.lgOpacityFine flag set false with no fine opacities command
56  * tests show that always evaluating this changes fast run of
57  * pn_paris from 26.7 sec to 35.1 sec
58  * but must always update fine opacities since used for transmission */
59  if( rfield.lgOpacityFine )
60  {
61  /* increment the fine opacity array */
62  for( long i=0; i<rfield.nfine; ++i )
63  {
65  rfield.fine_opt_depth[i] += tauzone;
66  }
68  }
69 
70  /* this may have updated some escape/destruction rates - force update
71  * to all cooling lines */
73 
74  if( nzone <=1 )
75  {
78  (1. - rfield.ContBoltz[hmi.iphmin-1]/ hmi.hmidep));
79  }
80  else
81  {
84  (1. - rfield.ContBoltz[hmi.iphmin-1]/ hmi.hmidep));
85  }
86 
87  /* prevent maser runaway */
88  rt.dTauMase = 0;
89  rt.mas_species = 0;
90  rt.mas_ion = 0;
91  rt.mas_hi = 0;
92  rt.mas_lo = 0;
93 
94  static vector<realnum> DopplerWidth(LIMELM);
95  for (long nelem=ipHYDROGEN; nelem < LIMELM; ++nelem)
96  {
97  DopplerWidth[nelem] = GetDopplerWidth(dense.AtomicWeight[nelem]);
98  }
99 
100  /* all lines in iso sequences */
101  for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO )
102  {
103  for( long nelem=ipISO; nelem < LIMELM; nelem++ )
104  {
105  if( ! dense.lgElmtOn[ nelem ] )
106  continue;
107 
108  /* this is the parent ion, for HI lines, is 1,
109  * for element He is 1 for He-like (HeI) and 2 for H-like (HeII) */
110  int ion = nelem+1-ipISO;
111  /* do not evaluate in case where trivial parent ion */
112  if( ion <=dense.IonHigh[nelem] && dense.xIonDense[nelem][ion] > dense.density_low_limit )
113  {
114  if( iso_ctrl.lgDielRecom[ipISO] )
115  {
116  // SatelliteLines are indexed by lower level
117  for( long ipLo=0; ipLo < iso_sp[ipISO][nelem].numLevels_local; ipLo++ )
118  {
119  RT_line_one_tauinc(SatelliteLines[ipISO][nelem][ipSatelliteLines[ipISO][nelem][ipLo]], ipISO, nelem, -1, ipLo,
120  DopplerWidth[nelem] );
121  }
122  }
123 
124  for( long ipHi=1; ipHi < iso_sp[ipISO][nelem].numLevels_local; ipHi++ )
125  {
126  for( long ipLo=0; ipLo < ipHi; ipLo++ )
127  {
128  if( iso_sp[ipISO][nelem].trans(ipHi,ipLo).ipCont() <= 0 )
129  continue;
130 
131  /* actually do the work */
132  RT_line_one_tauinc(iso_sp[ipISO][nelem].trans(ipHi,ipLo), ipISO, nelem, ipHi, ipLo,
133  DopplerWidth[nelem] );
134  }
135  }
136  /* these are the extra Lyman lines, use all lines so
137  * totals are correct as attribution may change */
138  for( long ipHi=2; ipHi < iso_ctrl.nLyman[ipISO]; ipHi++ )
139  {
140  TransitionList::iterator tr = ExtraLymanLines[ipISO][nelem].begin()+ipExtraLymanLines[ipISO][nelem][ipHi];
141  (*tr).Emis().PopOpc() = iso_sp[ipISO][nelem].st[0].Pop();
142 
143  /* actually do the work */
144  RT_line_one_tauinc(*tr, -1 ,ipISO, nelem, ipHi,
145  DopplerWidth[nelem] );
146  }
147  }
148  }
149  }
150 
151  /* increment optical depths for all heavy element lines
152  * same routine does wind and static */
153  /* all lines in cooling with g-bar */
154  for( long i=0; i < nWindLine; i++ )
155  {
156  if( ! dense.lgElmtOn[ (*TauLine2[i].Hi()).nelem()-1 ] )
157  continue;
158 
159  /* do not include H-like or He-like in the level two lines since
160  * these are already counted in iso sequences */
161  if( (*TauLine2[i].Hi()).IonStg() < (*TauLine2[i].Hi()).nelem()+1-NISO )
162  {
163  RT_line_one_tauinc(TauLine2[i], -3, -3, -3, i, DopplerWidth[(*TauLine2[i].Hi()).nelem()-1] );
164  }
165  }
166 
167  /* the block of inner shell lines */
168  for( size_t i=0; i < UTALines.size(); i++ )
169  {
170  if( ! dense.lgElmtOn[ (*UTALines[i].Hi()).nelem()-1 ] )
171  continue;
172 
173  /* populations have not been set */
174  UTALines[i].Emis().PopOpc() = dense.xIonDense[(*UTALines[i].Hi()).nelem()-1][(*UTALines[i].Hi()).IonStg()-1];
175  (*UTALines[i].Lo()).Pop() = dense.xIonDense[(*UTALines[i].Hi()).nelem()-1][(*UTALines[i].Hi()).IonStg()-1];
176  (*UTALines[i].Hi()).Pop() = 0.;
177  RT_line_one_tauinc(UTALines[i], -4 , -4 , -4 , i, DopplerWidth[(*UTALines[i].Hi()).nelem()-1] );
178 
179  // prt_trans_opc_debug( "UTA", UTALines[i] );
180  }
181 
182  /* all hyper fine structure lines */
183  for( size_t i=0; i < HFLines.size(); i++ )
184  {
185  if( ! dense.lgElmtOn[ (*HFLines[i].Hi()).nelem()-1 ] )
186  continue;
187 
188  RT_line_one_tauinc(HFLines[i] , -5 , -5 , -5 , i, DopplerWidth[(*HFLines[i].Hi()).nelem()-1] );
189  }
190 
191  /* increment optical depth for the H2 molecule */
192  for( diatom_iter diatom = diatoms.begin(); diatom != diatoms.end(); ++diatom )
193  (*diatom)->H2_RT_tau_inc();
194 
195  /* database Lines*/
196  for( long ipSpecies=0; ipSpecies<nSpecies; ipSpecies++ )
197  {
198  if( dBaseSpecies[ipSpecies].lgActive )
199  {
200  realnum DopplerWidth = GetDopplerWidth( dBaseSpecies[ipSpecies].fmolweight );
201  for (TransitionList::iterator tr=dBaseTrans[ipSpecies].begin();
202  tr != dBaseTrans[ipSpecies].end(); ++tr)
203  {
204  int ipHi = (*tr).ipHi();
205  if (ipHi >= dBaseSpecies[ipSpecies].numLevels_local || (*tr).ipCont() <= 0)
206  continue;
207  int ipLo = (*tr).ipLo();
208 
209  RT_line_one_tauinc( *tr, -10, ipSpecies, ipHi, ipLo, DopplerWidth );
210  }
211  }
212  }
213 
214  if( trace.lgTrace && trace.lgOptcBug )
215  {
216  fprintf( ioQQQ, " RT_tau_inc updated optical depths:\n" );
217  prtmet();
218  }
219 
220  if( trace.lgTrace )
221  fprintf( ioQQQ, " RT_tau_inc returns.\n" );
222 
223  return;
224 }
long int iphmin
Definition: hmi.h:128
realnum * fine_opt_depth
Definition: rfield.h:393
vector< double, allocator_avx< double > > ContBoltz
Definition: rfield.h:124
t_thermal thermal
Definition: thermal.cpp:6
size_t size(void) const
Definition: transition.h:331
void RT_fine_clear()
qList st
Definition: iso.h:482
TransitionList UTALines("UTALines",&AnonStates)
t_opac opac
Definition: opacity.cpp:5
void prt_trans_opc_debug(const char *LineGroup, const TransitionProxy &t)
Definition: rt_tau_inc.cpp:24
multi_arr< int, 3 > ipSatelliteLines
Definition: taulines.cpp:34
t_isoCTRL iso_ctrl
Definition: iso.cpp:9
bool lgFirstSweepThisZone
Definition: conv.h:148
const int NISO
Definition: cddefines.h:311
long int mas_species
Definition: rt.h:208
long int IonHigh[LIMELM+1]
Definition: dense.h:130
realnum & TauTot() const
Definition: emission.h:490
t_conv conv
Definition: conv.cpp:5
bool lgOpacityFine
Definition: rfield.h:404
TransitionList HFLines("HFLines",&AnonStates)
void CoolEvaluate(double *tot)
Definition: cool_eval.cpp:58
FILE * ioQQQ
Definition: cddefines.cpp:7
molezone * findspecieslocal(const char buf[])
void RT_tau_inc(void)
Definition: rt_tau_inc.cpp:40
long int nzone
Definition: cddefines.cpp:14
TransitionList TauLine2("TauLine2",&AnonStates)
long int nSpecies
Definition: taulines.cpp:22
t_dense dense
Definition: global.cpp:15
t_elementnames elementnames
Definition: elementnames.cpp:5
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:11
double xIonDense[LIMELM][LIMELM+1]
Definition: dense.h:135
t_trace trace
Definition: trace.cpp:5
void prtmet(void)
Definition: prt_met.cpp:19
long int nLyman[NISO]
Definition: iso.h:352
bool lgTrace
Definition: trace.h:12
EmissionList::reference Emis() const
Definition: transition.h:447
multi_arr< int, 3 > ipExtraLymanLines
Definition: taulines.cpp:24
bool trans_coef_total_stale
Definition: rfield.h:378
t_rfield rfield
Definition: rfield.cpp:9
bool lgDielRecom[NISO]
Definition: iso.h:385
float realnum
Definition: cddefines.h:124
realnum thmin
Definition: opacity.h:188
vector< diatomics * > diatoms
Definition: h2.cpp:8
qList::iterator Hi() const
Definition: transition.h:435
realnum telec
Definition: opacity.h:188
void RT_line_all(linefunc line_one)
realnum GetDopplerWidth(realnum massAMU)
vector< vector< TransitionList > > SatelliteLines
Definition: taulines.cpp:35
long nWindLine
Definition: cdinit.cpp:19
void RT_line_one_tauinc(const TransitionProxy &t, long int mas_species, long int mas_ion, long int mas_hi, long int mas_lo, realnum DopplerWidth)
t_radius radius
Definition: radius.cpp:5
bool lgElmtOn[LIMELM]
Definition: dense.h:160
realnum * fine_opac_zone
Definition: rfield.h:391
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
Definition: elementnames.h:25
string chLabel() const
Definition: transition.cpp:274
long int mas_lo
Definition: rt.h:208
realnum AtomicWeight[LIMELM]
Definition: dense.h:80
#define ASSERT(exp)
Definition: cddefines.h:613
realnum & TauCon() const
Definition: emission.h:510
const int ipH_LIKE
Definition: iso.h:64
vector< vector< TransitionList > > ExtraLymanLines
Definition: taulines.cpp:25
const int LIMELM
Definition: cddefines.h:308
double hmidep
Definition: hmi.h:42
long nfine
Definition: rfield.h:387
double drad_x_fillfac
Definition: radius.h:77
double den
Definition: mole.h:421
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
long int mas_hi
Definition: rt.h:208
vector< species > dBaseSpecies
Definition: taulines.cpp:15
double eden
Definition: dense.h:201
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
realnum dTauMase
Definition: rt.h:198
bool lgLastSweepThisZone
Definition: conv.h:150
bool lgOptcBug
Definition: trace.h:49
t_hmi hmi
Definition: hmi.cpp:5
vector< TransitionList > dBaseTrans
Definition: taulines.cpp:18
void RT_line_one_fine(const TransitionProxy &t, bool lgShield_this_zone, realnum pestrk, realnum DopplerWidth)
const int ipHYDROGEN
Definition: cddefines.h:349
long int mas_ion
Definition: rt.h:208
long int numLevels_local
Definition: iso.h:529
realnum & TauIn() const
Definition: emission.h:470
EmissionList & Emis()
Definition: transition.h:363
vector< diatomics * >::iterator diatom_iter
Definition: h2.h:13
double ctot
Definition: thermal.h:130
double density_low_limit
Definition: dense.h:208
t_rt rt
Definition: rt.cpp:5