cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rfield.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 #include "cddefines.h"
4 #include "rfield.h"
5 
6 #include "opacity.h"
7 #include "continuum.h"
8 
10 
12 {
13  DEBUG_ENTRY( "t_rfield::zero()" );
14  lgHabing = false;
15 
16  /* flag to turn off Lya ots */
17  lgLyaOTS = true;
18  /* HeII rec and Lya ots */
19  lgHeIIOTS = true;
20  lgKillOTSLine = false;
21  lgKillOutLine = false;
22  lgKillOutCont = false;
23 
24  /* DiffPumpOn is unity unless process disabled by setting to 1
25  * with no diffuse line pumping command */
26  DiffPumpOn = 1.;
27 
28  /* >>chng 03 nov 28, add option to not do line transfer */
29  lgDoLineTrans = true;
30 
31  /* flag saying whether to constantly reevaluated opacities -
32  * set false with no opacity reevaluate command */
33  lgOpacityReevaluate = true;
34 
35  /* flag saying whether to constantly reevaluated ionization -
36  * set false with no ionization reevaluate command */
37  lgIonizReevaluate = true;
38  /* this element is default for choosing line width */
40  /* there will be this many resolution elements in one FWHM for this element,
41  * at the lowest temperature to be considered */
43  /* continuum scale factor for case of time varying continuum */
45  /* will fine optical depths be punched? */
46  lgSaveOpacityFine = false;
47 
48  /* first is set true if one of the incident continua needs to have
49  * H-ionizing radiation blocked. Second is set true is it is blocked
50  * with extinguish command - want both true if first is true */
51  lgMustBlockHIon = false;
52  lgBlockHIon = false;
53  strncpy( rfield.chCumuType, "MASS", sizeof(rfield.chCumuType));
54 }
55 
57 {
58  // average opacity transmission coefficient fine to coarse
60  {
61  /* sum over coarse continuum */
62  for( long i=0; i < nflux-1; i++ )
63  {
64  // find transmission coefficient if lower and upper bounds
65  // of coarse continuum is within boundaries of fine continuum
66  // unity is default
67  if( ipnt_coarse_2_fine[i] && ipnt_coarse_2_fine[i+1] )
68  {
69  // first branch is normal case, where fine continuum is finer than
70  // coarse continuum. But, when end temp is very high, fine continuum is
71  // very coarse, so may be just one cell, and following will not pass
73  {
74  trans_coef_total[i] = 0.;
75  for( long j=ipnt_coarse_2_fine[i]; j<ipnt_coarse_2_fine[i+1]; ++j )
77  trans_coef_total[i] /= (ipnt_coarse_2_fine[i+1]-ipnt_coarse_2_fine[i]);
78  }
79  else
80  {
81  // in case where fine is coarser than coarse,
82  // just use first cell
84  }
85  }
86  }
87  trans_coef_total_stale = false;
88  }
89  return trans_coef_total;
90 }
91 
93 {
94  DEBUG_ENTRY( "t_rfield::setTrimming()" );
95 
96  double threshold = 0.;
97  if( rfield.FluxFaint > 0. )
98  {
99  double peak = 0.;
100  for( long i=0; i < rfield.nflux; ++ i )
101  peak = max( peak, rfield.SummedCon[i]*rfield.anu(i)/rfield.widflx(i) );
102  threshold = rfield.FluxFaint * peak;
103  }
104 
105  // search for highest energy cell with positive flux, use 'i < nPositive' in loops
106  nPositive = nflux;
107  while( nPositive > 0 && SummedCon[nPositive-1] <= threshold )
108  --nPositive;
109 }
110 
111 /* report the total flux not including attenuated isotropic continua, if requested */
112 double flux_correct_isotropic( const bool lgSaveIsotr, const int nEmType, const int iflux )
113 {
114  if( iflux < 0 || iflux >= rfield.nflux )
115  return 0.;
116 
117  double this_flux = (double)rfield.flux[ nEmType ][ iflux ];
118  if( nEmType == 0 &&
119  ( ! continuum.lgPrtIsotropicCont || ! lgSaveIsotr ) )
120  {
121  this_flux = (double)( rfield.flux_beam_const[ iflux ]
122  + rfield.flux_beam_time[ iflux ] );
123  }
124 
125  return this_flux;
126 }
127 
128 double flux_correct_isotropic( const int nEmType, const int iflux )
129 {
130  return flux_correct_isotropic( true, nEmType, iflux );
131 }
realnum * fine_opt_depth
Definition: rfield.h:393
bool lgSaveOpacityFine
Definition: rfield.h:406
long int fine_opac_nresolv
Definition: rfield.h:368
bool lgKillOutLine
Definition: rfield.h:417
void setTrimming()
Definition: rfield.cpp:92
double widflx(size_t i) const
Definition: mesh.h:156
t_opac opac
Definition: opacity.cpp:5
realnum ** flux
Definition: rfield.h:68
double * SummedCon
Definition: rfield.h:161
bool lgScatON
Definition: opacity.h:196
bool lgKillOutCont
Definition: rfield.h:420
bool lgIonizReevaluate
Definition: rfield.h:110
sys_float sexp(sys_float x)
Definition: service.cpp:999
bool lgKillOTSLine
Definition: rfield.h:423
realnum time_continuum_scale
Definition: rfield.h:203
double anu(size_t i) const
Definition: mesh.h:120
bool lgHeIIOTS
Definition: rfield.h:414
bool lgHabing
Definition: rfield.h:361
const realnum * getCoarseTransCoef()
Definition: rfield.cpp:56
long int fine_opac_nelem
Definition: rfield.h:365
const int ipIRON
Definition: cddefines.h:374
t_continuum continuum
Definition: continuum.cpp:6
bool trans_coef_total_stale
Definition: rfield.h:378
bool lgLyaOTS
Definition: rfield.h:410
bool lgPrtIsotropicCont
Definition: continuum.h:94
t_rfield rfield
Definition: rfield.cpp:9
float realnum
Definition: cddefines.h:124
long max(int a, long b)
Definition: cddefines.h:817
double FluxFaint
Definition: rfield.h:56
bool lgMustBlockHIon
Definition: rfield.h:92
bool lgDoLineTrans
Definition: rfield.h:99
void zero()
Definition: rfield.cpp:11
bool lgOpacityReevaluate
Definition: rfield.h:103
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
long int * ipnt_coarse_2_fine
Definition: rfield.h:382
realnum * trans_coef_total
Definition: rfield.h:375
realnum DiffPumpOn
Definition: rfield.h:207
realnum * flux_beam_time
Definition: rfield.h:74
realnum * flux_beam_const
Definition: rfield.h:74
char chCumuType[5]
Definition: rfield.h:335
long int nflux
Definition: rfield.h:46
double flux_correct_isotropic(const bool lgSaveIsotr, const int nEmType, const int iflux)
Definition: rfield.cpp:112
bool lgBlockHIon
Definition: rfield.h:96
long int nPositive
Definition: rfield.h:53