cloudy  trunk
init_sim_postparse.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 /*InitSimPostparse initialization at start of simulation,
4  * called from cloudy after parser,
5  * called one time per sim in grid
6  * not called for every iteration */
7 #include "cddefines.h"
8 #include "dense.h"
9 #include "deuterium.h"
10 #include "struc.h"
11 #include "rfield.h"
12 #include "elementnames.h"
13 #include "atoms.h"
14 #include "physconst.h"
15 #include "iterations.h"
16 #include "pressure.h"
17 #include "mole.h"
18 #include "trace.h"
19 #include "radius.h"
20 #include "thermal.h"
21 #include "heavy.h"
22 #include "wind.h"
23 #include "init.h"
24 #include "iso.h"
25 #include "h2.h"
26 #include "co.h"
27 #include "monitor_results.h"
28 #include "taulines.h"
29 
30 /*InitSimPostparse initialization after parser,
31  * called one time for each simulation in a grid,
32  * only before first iteration
33  * sets initial or zeros values before start of a simulation */
34 void InitSimPostparse( void )
35 {
36  DEBUG_ENTRY( "InitSimPostparse()" );
37  static double one=1.0;
38 
40 
41  thermal.thist = 0.;
42  thermal.tlowst = 1e20f;
43  thermal.nUnstable = 0;
44  thermal.lgUnstable = false;
45 
46  colliders.init();
47 
48  mole_global.init();
49  mole_global.zero();
50 
51  for( long nelem=ipHYDROGEN; nelem<LIMELM; ++nelem )
52  {
53  for( long ion=0; ion<nelem+2; ++ion )
54  mole.set_location( nelem, ion, &(dense.xIonDense[nelem][ion]) );
55  }
56 
57  findspecieslocal("e-")->location = &(dense.eden);
59  findspecieslocal("PHOTON")->location = &one;
60  findspecieslocal("CRPHOT")->location = &one;
61  findspecieslocal("CRP")->location = &one;
62  if( deut.lgElmtOn )
63  {
65  findspecieslocal("D+")->location = &(deut.xIonDense[1]);
66  }
67 
68  /* >> chng 06 Nov 24 rjrw: Move reaction definitions here so they can be controlled by parsed commands */
70 
71  //mole_cmp_num_in_out_reactions();
72 
73  for( diatom_iter diatom = diatoms.begin(); diatom != diatoms.end(); ++diatom )
74  (*diatom)->H2_Reset();
75 
76  /* zero out diffuse Lya emission */
77  for( long nelem=ipHYDROGEN; nelem<LIMELM; ++nelem )
78  for( long ion=0; ion<=nelem; ++ion )
79  Heavy.xLyaHeavy[nelem][ion] = 0;
80 
81  /* convert STOP RADIUS command to STOP THICKNESS command now that inner radius is known */
82  if( radius.StopRadius[0] > 0. )
83  {
84  for( long j=0; j < iterations.iter_malloc; j++ )
85  {
86  if( radius.StopRadius[j] > radius.Radius )
88  else
89  {
90  fprintf( ioQQQ, " PROBLEM stopping radius is <= inner radius. Bailing out.\n" );
92  }
93  }
94  }
95 
96  /* this term applies centrifugal acceleration if DISK option on wind command */
97  wind.DiskRadius = 0;
98  if( wind.lgDisk )
100 
101  iterations.lgLastIt = false;
102 
104 
105  rfield.lgUSphON = false;
106 
107  /* where cloud is optically thick to brems */
109  rfield.EnergyBremsThin = 0.;
110  rfield.comtot = 0.;
111  rfield.cmcool = 0.;
112  rfield.cinrat = 0.;
117  rfield.EnerGammaRay = 7676.;
118 
119  for( vector<TransitionList>::iterator it = AllTransitions.begin(); it != AllTransitions.end(); ++it )
120  {
121  for( TransitionList::iterator tr = it->begin(); tr != it->end(); ++tr )
122  {
123  tr->Emis().TauTrack().clear();
124  }
125  }
126 
127  /* usually computed in pressure_change, but not called before first zone */
129  (1.-wind.DiskRadius/radius.Radius) );
130  if( trace.lgTrace && trace.lgWind )
131  {
132  fprintf(ioQQQ," InitSimPostparse sets AccelGravity %.3e lgDisk?%c\n",
133  wind.AccelGravity ,
134  TorF(wind.lgDisk) );
135  }
136 
137  /* pressure related variables */
138  pressure.PresInteg = 0.;
140  pressure.pinzon = 0.;
141 
142  /* update iso sequence level information */
143  for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO )
144  {
145  for( long nelem=ipISO; nelem < LIMELM; ++nelem )
146  {
147  iso_sp[ipISO][nelem].Reset();
148  /* these elements that are turned off */
149  if( nelem>ipHELIUM && !dense.lgElmtOn[nelem] )
150  {
151  iso_sp[ipISO][nelem].numLevels_max = 0;
152  iso_sp[ipISO][nelem].nCollapsed_max = 0;
153  iso_sp[ipISO][nelem].n_HighestResolved_max = 0;
154 
155  iso_sp[ipISO][nelem].numLevels_local = 0;
156  iso_sp[ipISO][nelem].nCollapsed_local = 0;
157  iso_sp[ipISO][nelem].n_HighestResolved_local = 0;
158  }
159  else
160  {
161  iso_update_num_levels( ipISO, nelem );
162  /* must always have at least one collapsed level, unless compiling recomb data file. */
163  ASSERT( iso_sp[ipISO][nelem].nCollapsed_max > 0 || iso_ctrl.lgCompileRecomb[ipISO] );
164  }
165  }
166  }
167 
169  {
170  fprintf(ioQQQ,"\n\n Number of levels in ions treated by iso sequences.\n");
171  fprintf(ioQQQ," ISO Element hi-n(l-resolved) #(l-resolved) n(collapsed)\n");
172  /* option to print number of levels for each element */
173  for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO )
174  {
175  for( long nelem=ipISO; nelem<LIMELM; ++nelem )
176  {
177  /* print number of levels */
178  fprintf(ioQQQ," %s %s %4li %4li %4li \n",
179  iso_ctrl.chISO[ipISO] ,
180  elementnames.chElementSym[nelem],
181  iso_sp[ipISO][nelem].n_HighestResolved_max,
182  iso_sp[ipISO][nelem].numLevels_max-iso_sp[ipISO][nelem].nCollapsed_max,
183  iso_sp[ipISO][nelem].nCollapsed_max);
184  }
185  }
186  }
187  atoms.p2nit = 0.;
188  atoms.d5200r = 0.;
189 
192 
193  return;
194 }
thermal.h
findspecieslocal
molezone * findspecieslocal(const char buf[])
Definition: mole_species.cpp:833
TorF
char TorF(bool l)
Definition: cddefines.h:710
t_dense::eden
double eden
Definition: dense.h:190
t_rfield::extin_mag_B_point
double extin_mag_B_point
Definition: rfield.h:277
colliders
ColliderList colliders
Definition: collision.cpp:57
struc.h
dense
t_dense dense
Definition: dense.cpp:24
elementnames.h
t_iso_sp::n_HighestResolved_max
long int n_HighestResolved_max
Definition: iso.h:505
t_radius::StopRadius
double * StopRadius
Definition: radius.h:58
atoms.h
rfield
t_rfield rfield
Definition: rfield.cpp:8
t_deuterium::lgElmtOn
bool lgElmtOn
Definition: deuterium.h:19
ioQQQ
FILE * ioQQQ
Definition: cddefines.cpp:7
elementnames
t_elementnames elementnames
Definition: elementnames.cpp:5
Wind::comass
realnum comass
Definition: wind.h:14
t_pressure::pinzon
realnum pinzon
Definition: pressure.h:110
AllTransitions
vector< TransitionList > AllTransitions
Definition: taulines.cpp:8
diatom_iter
vector< diatomics * >::iterator diatom_iter
Definition: h2.h:13
t_isoCTRL::chISO
const char * chISO[NISO]
Definition: iso.h:330
realnum
float realnum
Definition: cddefines.h:103
iterations
t_iterations iterations
Definition: iterations.cpp:5
rfield.h
SOLAR_MASS
const UNUSED double SOLAR_MASS
Definition: physconst.h:71
t_struc::nzonePreviousIteration
long int nzonePreviousIteration
Definition: struc.h:22
mole.h
Wind::DiskRadius
double DiskRadius
Definition: wind.h:78
t_thermal::thist
realnum thist
Definition: thermal.h:56
t_mole_global::zero
void zero(void)
Definition: mole.cpp:36
t_mole_local::grain_area
double grain_area
Definition: mole.h:387
t_dense::lgElmtOn
bool lgElmtOn[LIMELM]
Definition: dense.h:146
diatoms
vector< diatomics * > diatoms
Definition: h2.cpp:8
t_iso_sp::numLevels_local
long int numLevels_local
Definition: iso.h:498
trace.h
t_mole_global::init
void init(void)
Definition: mole.cpp:11
ProxyIterator
Definition: proxy_iterator.h:58
Wind::lgDisk
bool lgDisk
Definition: wind.h:74
t_isoCTRL::lgPrintNumberOfLevels
bool lgPrintNumberOfLevels
Definition: iso.h:328
Heavy
t_Heavy Heavy
Definition: heavy.cpp:5
ASSERT
#define ASSERT(exp)
Definition: cddefines.h:578
t_monitorresults::nSumErrorCaseMonitor
long int nSumErrorCaseMonitor
Definition: monitor_results.h:32
struc
t_struc struc
Definition: struc.cpp:6
iso.h
t_rfield::extin_mag_V_point
double extin_mag_V_point
Definition: rfield.h:277
ipHYDROGEN
const int ipHYDROGEN
Definition: cddefines.h:305
wind
Wind wind
Definition: wind.cpp:5
t_pressure::PresIntegElecThin
realnum PresIntegElecThin
Definition: pressure.h:115
POW2
#define POW2
Definition: cddefines.h:929
mole_create_react
void mole_create_react(void)
Definition: mole_reactions.cpp:1665
t_thermal::nUnstable
long int nUnstable
Definition: thermal.h:52
t_rfield::cinrat
double cinrat
Definition: rfield.h:294
t_mole_local::set_location
void set_location(long nelem, long ion, double *dense)
Definition: mole_species.cpp:1018
t_monitorresults::SumErrorCaseMonitor
double SumErrorCaseMonitor
Definition: monitor_results.h:31
radius
t_radius radius
Definition: radius.cpp:5
t_atoms::d5200r
realnum d5200r
Definition: atoms.h:242
t_iso_sp::nCollapsed_local
long int nCollapsed_local
Definition: iso.h:488
EXIT_FAILURE
#define EXIT_FAILURE
Definition: cddefines.h:140
t_thermal::tlowst
realnum tlowst
Definition: thermal.h:57
t_isoCTRL::lgCompileRecomb
bool lgCompileRecomb[NISO]
Definition: iso.h:380
dense.h
init.h
mole
t_mole_local mole
Definition: mole.cpp:7
trace
t_trace trace
Definition: trace.cpp:5
cddefines.h
atoms
t_atoms atoms
Definition: atoms.cpp:5
t_rfield::cmcool
double cmcool
Definition: rfield.h:293
t_iso_sp::numLevels_max
long int numLevels_max
Definition: iso.h:493
t_radius::Radius
double Radius
Definition: radius.h:25
thermal
t_thermal thermal
Definition: thermal.cpp:5
iso_update_num_levels
void iso_update_num_levels(long ipISO, long nelem)
Definition: iso_create.cpp:1488
t_elementnames::chElementSym
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
Definition: elementnames.h:25
Wind::AccelGravity
realnum AccelGravity
Definition: wind.h:49
radius.h
deut
t_deuterium deut
Definition: deuterium.cpp:8
heavy.h
t_atoms::p2nit
realnum p2nit
Definition: atoms.h:242
pressure.h
LIMELM
const int LIMELM
Definition: cddefines.h:258
ColliderList::init
void init()
Definition: collision.cpp:44
rfield_opac_zero
void rfield_opac_zero(long lo, long ihi)
Definition: cont_createmesh.cpp:802
cdEXIT
#define cdEXIT(FAIL)
Definition: cddefines.h:434
t_deuterium::xIonDense
double xIonDense[2]
Definition: deuterium.h:21
t_iso_sp::nCollapsed_max
long int nCollapsed_max
Definition: iso.h:487
co.h
t_rfield::nupper
long int nupper
Definition: rfield.h:46
t_dense::xIonDense
double xIonDense[LIMELM][LIMELM+1]
Definition: dense.h:125
molezone::location
double * location
Definition: mole.h:349
t_rfield::extin_mag_V_extended
double extin_mag_V_extended
Definition: rfield.h:281
t_iterations::lgLastIt
bool lgLastIt
Definition: iterations.h:36
wind.h
t_iso_sp::Reset
void Reset()
Definition: iso.h:568
t_radius::StopThickness
double * StopThickness
Definition: radius.h:55
physconst.h
InitSimPostparse
void InitSimPostparse(void)
Definition: init_sim_postparse.cpp:34
t_rfield::lgUSphON
bool lgUSphON
Definition: rfield.h:370
iso_ctrl
t_isoCTRL iso_ctrl
Definition: iso.cpp:6
ipHELIUM
const int ipHELIUM
Definition: cddefines.h:306
t_rfield::EnergyBremsThin
realnum EnergyBremsThin
Definition: rfield.h:246
taulines.h
t_trace::lgWind
bool lgWind
Definition: trace.h:109
pressure
t_pressure pressure
Definition: pressure.cpp:5
t_iso_sp::n_HighestResolved_local
long int n_HighestResolved_local
Definition: iso.h:507
t_rfield::comtot
double comtot
Definition: rfield.h:291
iterations.h
iso_sp
t_iso_sp iso_sp[NISO][LIMELM]
Definition: iso.cpp:8
GRAV_CONST
const UNUSED double GRAV_CONST
Definition: physconst.h:109
t_iterations::iter_malloc
long int iter_malloc
Definition: iterations.h:29
h2.h
t_rfield::extin_mag_B_extended
double extin_mag_B_extended
Definition: rfield.h:281
NISO
const int NISO
Definition: cddefines.h:261
monitor_results.h
t_Heavy::xLyaHeavy
realnum xLyaHeavy[LIMELM][LIMELM]
Definition: heavy.h:21
mole_global
t_mole_global mole_global
Definition: mole.cpp:6
t_thermal::lgUnstable
bool lgUnstable
Definition: thermal.h:53
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:684
t_rfield::ipEnergyBremsThin
long int ipEnergyBremsThin
Definition: rfield.h:245
ipH_LIKE
const int ipH_LIKE
Definition: iso.h:62
MonitorResults
t_monitorresults MonitorResults
Definition: monitor_results.cpp:38
t_pressure::PresInteg
realnum PresInteg
Definition: pressure.h:109
t_trace::lgTrace
bool lgTrace
Definition: trace.h:12
t_rfield::EnerGammaRay
realnum EnerGammaRay
Definition: rfield.h:465
deuterium.h