cloudy
trunk
Loading...
Searching...
No Matches
source
init_coreload.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
/*InitCoreload one time initialization of core load, called from cdDrive, this sets
4
* minimum set of values needed for the code to start - called after
5
* input lines have been read in and checked for VARY or GRID - so
6
* known whether single or multiple sims will be run */
7
#include "
cddefines.h
"
8
#include "
optimize.h
"
9
#include "
parse.h
"
10
#include "
struc.h
"
11
#include "
input.h
"
12
#include "
dense.h
"
13
#include "
hcmap.h
"
14
#include "
h2.h
"
15
#include "
version.h
"
16
#include "
h2.h
"
17
#include "
hextra.h
"
18
#include "
heavy.h
"
19
#include "
grid.h
"
20
#include "
ionbal.h
"
21
#include "
iso.h
"
22
#include "
taulines.h
"
23
#include "
cosmology.h
"
24
#include "
physconst.h
"
25
#include "
broke.h
"
26
#include "
rfield.h
"
27
28
// //////////////////////////////////////////////////////////////////////////
29
//
30
//
31
// NB DO NOT ADD VARIABLES TO THIS FILE! THE GOAL IS TO REMOVE THIS FILE
32
// initialization of variables done one time per coreload should be done in
33
// a constructor for the data
34
//
35
//
36
// //////////////////////////////////////////////////////////////////////////
37
38
/*InitCoreload one time initialization of core load, called from cdDrive, this sets
39
* minimum set of values needed for the code to start - called after
40
* input lines have been read in and checked for VARY or GRID - so
41
* known whether single or multiple sims will be run */
42
void
InitCoreload
(
void
)
43
{
44
static
int
nCalled=0;
45
long
int
nelem;
46
47
DEBUG_ENTRY
(
"InitCoreload()"
);
48
49
/* return if already called */
50
if
( nCalled )
51
return
;
52
53
++nCalled;
54
55
rfield
.
lgMeshSetUp
=
false
;
56
57
hcmap
.
lgMapOK
=
true
;
58
hcmap
.
lgMapDone
=
false
;
59
60
// subdirectory delimiter character
61
# ifdef _WIN32
62
strcpy(
input
.
chDelimiter
,
"\\"
);
63
# else
64
strcpy(
input
.
chDelimiter
,
"/"
);
65
# endif
66
67
/* will be reset to positive number when map actually done */
68
hcmap
.
nMapAlloc
= 0;
69
hcmap
.
nmap
= 0;
70
hcmap
.
lgMapBeingDone
=
false
;
71
72
/* name of output file from optimization run */
73
strncpy(
chOptimFileName
,
"optimal.in"
,
sizeof
(
chOptimFileName
) );
74
75
/* number of electrons in valence shell that can Compton recoil ionize */
76
long
int
nCom[
LIMELM
] =
77
{
78
1 , 2 ,
/* K 1s shell */
79
1 , 2 ,
/* L 2s shell */
80
1 , 2 , 3 , 4 , 5 , 6 ,
/* L 2p shell */
81
1 , 2 ,
/* M 3s shell */
82
1 , 2 , 3 , 4 , 5 , 6 ,
/* M 3p shell */
83
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ,
/* M 3d shell */
84
1 , 2 ,
/* N 4s shell */
85
1 , 2
/* N 4p shell */
86
};
87
88
for
( nelem=
ipHYDROGEN
; nelem<
LIMELM
; ++nelem )
89
{
90
ionbal
.
nCompRecoilElec
[nelem] = nCom[nelem];
91
}
92
93
/* list of shells, 1 to 7 */
94
strcpy(
Heavy
.
chShell
[0],
"1s"
);
95
strcpy(
Heavy
.
chShell
[1],
"2s"
);
96
strcpy(
Heavy
.
chShell
[2],
"2p"
);
97
strcpy(
Heavy
.
chShell
[3],
"3s"
);
98
strcpy(
Heavy
.
chShell
[4],
"3p"
);
99
strcpy(
Heavy
.
chShell
[5],
"3d"
);
100
strcpy(
Heavy
.
chShell
[6],
"4s"
);
101
102
/* variables for H-like sequence */
103
/* default number of levels for hydrogen iso sequence */
104
for
( nelem=
ipHYDROGEN
; nelem <
LIMELM
; ++nelem )
105
{
106
iso_sp
[
ipH_LIKE
][nelem].
n_HighestResolved_max
= 5;
107
iso_sp
[
ipH_LIKE
][nelem].
nCollapsed_max
= 2;
108
}
109
110
iso_sp
[
ipH_LIKE
][
ipHYDROGEN
].
n_HighestResolved_max
= 10;
111
iso_sp
[
ipH_LIKE
][
ipHELIUM
].
n_HighestResolved_max
= 10;
112
113
iso_sp
[
ipH_LIKE
][
ipHYDROGEN
].
nCollapsed_max
= 15;
114
iso_sp
[
ipH_LIKE
][
ipHELIUM
].
nCollapsed_max
= 15;
115
116
/* variables for He-like sequence */
117
/* "he-like" hydrogen (H-) is treated elsewhere */
118
iso_sp
[
ipHE_LIKE
][
ipHYDROGEN
].
n_HighestResolved_max
= -LONG_MAX;
119
iso_sp
[
ipHE_LIKE
][
ipHYDROGEN
].
numLevels_max
= -LONG_MAX;
120
iso_sp
[
ipHE_LIKE
][
ipHYDROGEN
].
nCollapsed_max
= -LONG_MAX;
121
122
for
( nelem=
ipHELIUM
; nelem <
LIMELM
; ++nelem )
123
{
124
/* put at least three resolved and 1 collapsed in every element for he-like */
125
iso_sp
[
ipHE_LIKE
][nelem].
n_HighestResolved_max
= 3;
126
iso_sp
[
ipHE_LIKE
][nelem].
nCollapsed_max
= 1;
127
}
128
129
iso_sp
[
ipHE_LIKE
][
ipHELIUM
].
n_HighestResolved_max
= 6;
130
iso_sp
[
ipHE_LIKE
][
ipHELIUM
].
nCollapsed_max
= 20;
131
132
/* And n=5 for these because they are most abundant */
133
iso_sp
[
ipHE_LIKE
][
ipCARBON
].
n_HighestResolved_max
= 5;
134
iso_sp
[
ipHE_LIKE
][
ipNITROGEN
].
n_HighestResolved_max
= 5;
135
iso_sp
[
ipHE_LIKE
][
ipOXYGEN
].
n_HighestResolved_max
= 5;
136
iso_sp
[
ipHE_LIKE
][
ipNEON
].
n_HighestResolved_max
= 5;
137
iso_sp
[
ipHE_LIKE
][
ipSILICON
].
n_HighestResolved_max
= 5;
138
iso_sp
[
ipHE_LIKE
][
ipMAGNESIUM
].
n_HighestResolved_max
= 5;
139
iso_sp
[
ipHE_LIKE
][
ipSULPHUR
].
n_HighestResolved_max
= 5;
140
iso_sp
[
ipHE_LIKE
][
ipIRON
].
n_HighestResolved_max
= 5;
141
/* also set this, for exercising any possible issues with biggest charge models */
142
iso_sp
[
ipHE_LIKE
][
LIMELM
-1].
n_HighestResolved_max
= 5;
143
144
iso_ctrl
.
chISO
[
ipH_LIKE
] =
"H-like "
;
145
iso_ctrl
.
chISO
[
ipHE_LIKE
] =
"He-like"
;
146
147
max_num_levels
= 0;
148
for
(
long
ipISO =
ipH_LIKE
; ipISO <
NISO
; ipISO++ )
149
{
150
for
( nelem=ipISO; nelem <
LIMELM
; nelem++ )
151
{
152
/* set this to LONG_MAX, reduce to actual number later,
153
* then verify number of levels is not increased after initial coreload */
154
iso_sp
[ipISO][nelem].
numLevels_malloc
= LONG_MAX;
155
iso_update_num_levels
( ipISO, nelem );
156
}
157
}
158
159
lgStatesAdded
=
false
;
160
lgLinesAdded
=
false
;
161
162
/* turn element on if this is first call to this routine,
163
* but do not reset otherwise since would clobber how elements were set up */
164
for
( nelem=0; nelem <
LIMELM
; nelem++ )
165
{
166
/* never turn on element if turned off on first iteration */
167
dense
.
lgElmtOn
[nelem] =
true
;
168
169
/* option to set ionization with element ioniz cmnd,
170
* default (false) is to solve for ionization */
171
dense
.
lgSetIoniz
[nelem] =
false
;
172
173
// are we using Chianti for this ion?
174
for
(
int
ion=0; ion<=nelem+1; ++ion )
175
{
176
dense
.
lgIonChiantiOn
[nelem][ion] =
false
;
177
dense
.
lgIonStoutOn
[nelem][ion] =
false
;
178
dense
.
maxWN
[nelem][ion] = 0.;
179
}
180
}
181
182
/* smallest density to permit in any ion - if smaller then set to zero */
183
dense
.
density_low_limit
=
SMALLFLOAT
* 1e3;
184
dense
.
density_low_limit
=
MAX2
(
dense
.
density_low_limit
, 1e-50 );
185
186
/* default cosmic ray background */
187
/* >>chng 99 jun 24, slight change to value
188
* quoted by
189
* >>refer cosmic ray ionization rate McKee, C.M., 1999, astro-ph 9901370
190
* this will produce a total
191
* secondary ionization rate of 2.5e-17 s^-1, as tested in
192
* test suite cosmicray.in. If each ionization produces 2.4 eV of heat,
193
* the background heating rate should be 9.6e-29 * n*/
194
/* >>chng 04 jan 26, update cosmic ray ionization rate for H0 to
195
* >>refer cosmic ray ionization Williams, J.P., Bergin, E.A., Caselli, P.,
196
* >>refercon Myers, P.C., & Plume, R. 1998, ApJ, 503, 689,
197
* H0 ionization rate of 2.5e-17 s-1 and a H2 ionization rate twice this
198
* >>chng 04 mar 15, comment said 2.5e-17 which is correct, but code produce 8e-17,
199
* fix back to correct value
200
*/
201
/* NB - the rate is derived from the density. these two are related by the secondary
202
* ionization efficiency problem. background_rate is only here to provide the relationship
203
* for predominantly neutral gas. the background_density is the real rate.
204
hextra.background_density = 1.99e-9f;*/
205
/* >>chng 05 apr 16, to get proper ionization rate in ism_set_cr_rate, where
206
* H is forced to be fully atomic, no molecules, density from 1.99 to 2.15 */
207
/* >>chng 02 apr 05, update to
208
* >>refer cosmic ray ionization Indriolo, N., Geballe, T., Oka, T., & McCall, B.J. 2007, ApJ, 671, 1736
209
*/
210
hextra
.
background_density
= 2.15e-9f*7.9f;
211
hextra
.
background_rate
= 2.5e-17f*7.9f;
212
213
/* initialization for save files - must call after input commands have
214
* been scanned for grid and vary options. So known if grid or single run
215
* default save is different for these */
216
grid
.
lgGridDone
=
false
;
217
grid
.
lgStrictRepeat
=
false
;
218
219
/* these are energy range... if not changed with command, 0. says just use energy limits of mesh */
220
grid
.
LoEnergy_keV
= 0.;
221
grid
.
HiEnergy_keV
= 0.;
222
grid
.
ipLoEnergy
= 0;
223
grid
.
ipHiEnergy
= 0;
224
grid
.
seqNum
= 0;
225
226
for
(
long
i=0; i <
LIMPAR
; ++i )
227
optimize
.
lgOptimizeAsLinear
[i] =
false
;
228
229
/* limit on ionization we check for zoning and prtcomment */
230
struc
.
dr_ionfrac_limit
= 1e-3f;
231
232
SaveFilesInit
();
233
234
diatoms_init
();
235
236
/* initialize cosmological information */
237
cosmology
.
redshift_current
= 0.f;
238
cosmology
.
redshift_start
= 0.f;
239
cosmology
.
redshift_step
= 0.f;
240
cosmology
.
omega_baryon
= 0.04592f;
241
cosmology
.
omega_rad
= 8.23e-5f;
242
cosmology
.
omega_lambda
= 0.7299177f;
243
cosmology
.
omega_matter
= 0.27f;
244
cosmology
.
omega_k
= 0.f;
245
/* the Hubble parameter in 100 km/s/Mpc */
246
cosmology
.
h
= 0.71f;
247
/* the Hubble parameter in km/s/Mpc */
248
cosmology
.
H_0
= 100.f*
cosmology
.
h
;
249
cosmology
.
lgDo
=
false
;
250
251
// the code is ok at startup; only init here so that code remains broken
252
// in a grid if any single model announces broken
253
broke
.
lgBroke
=
false
;
254
broke
.
lgFixit
=
false
;
255
broke
.
lgCheckit
=
false
;
256
257
return
;
258
}
broke
t_broke broke
Definition:
broke.cpp:5
broke.h
cddefines.h
ipSILICON
const int ipSILICON
Definition:
cddefines.h:318
ipNITROGEN
const int ipNITROGEN
Definition:
cddefines.h:311
ipIRON
const int ipIRON
Definition:
cddefines.h:330
ipCARBON
const int ipCARBON
Definition:
cddefines.h:310
ipOXYGEN
const int ipOXYGEN
Definition:
cddefines.h:312
LIMELM
const int LIMELM
Definition:
cddefines.h:258
ipMAGNESIUM
const int ipMAGNESIUM
Definition:
cddefines.h:316
NISO
const int NISO
Definition:
cddefines.h:261
ipHELIUM
const int ipHELIUM
Definition:
cddefines.h:306
MAX2
#define MAX2
Definition:
cddefines.h:782
ipSULPHUR
const int ipSULPHUR
Definition:
cddefines.h:320
ipHYDROGEN
const int ipHYDROGEN
Definition:
cddefines.h:305
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition:
cddefines.h:684
ipNEON
const int ipNEON
Definition:
cddefines.h:314
t_ionbal::nCompRecoilElec
long int nCompRecoilElec[LIMELM]
Definition:
ionbal.h:188
t_iso_sp::numLevels_max
long int numLevels_max
Definition:
iso.h:493
t_iso_sp::numLevels_malloc
long int numLevels_malloc
Definition:
iso.h:502
t_iso_sp::n_HighestResolved_max
long int n_HighestResolved_max
Definition:
iso.h:505
t_iso_sp::nCollapsed_max
long int nCollapsed_max
Definition:
iso.h:487
t_isoCTRL::chISO
const char * chISO[NISO]
Definition:
iso.h:330
cosmology
t_cosmology cosmology
Definition:
cosmology.cpp:11
cosmology.h
SMALLFLOAT
const realnum SMALLFLOAT
Definition:
cpu.h:191
dense
t_dense dense
Definition:
dense.cpp:24
dense.h
grid
t_grid grid
Definition:
grid.cpp:5
grid.h
diatoms_init
void diatoms_init(void)
Definition:
h2.cpp:13
h2.h
hcmap
t_hcmap hcmap
Definition:
hcmap.cpp:21
hcmap.h
Heavy
t_Heavy Heavy
Definition:
heavy.cpp:5
heavy.h
hextra
t_hextra hextra
Definition:
hextra.cpp:5
hextra.h
InitCoreload
void InitCoreload(void)
Definition:
init_coreload.cpp:42
input
t_input input
Definition:
input.cpp:12
input.h
ionbal
t_ionbal ionbal
Definition:
ionbal.cpp:5
ionbal.h
iso_sp
t_iso_sp iso_sp[NISO][LIMELM]
Definition:
iso.cpp:8
max_num_levels
long int max_num_levels
Definition:
iso.cpp:10
iso_ctrl
t_isoCTRL iso_ctrl
Definition:
iso.cpp:6
iso.h
iso_update_num_levels
void iso_update_num_levels(long ipISO, long nelem)
Definition:
iso_create.cpp:1488
ipHE_LIKE
const int ipHE_LIKE
Definition:
iso.h:63
ipH_LIKE
const int ipH_LIKE
Definition:
iso.h:62
chOptimFileName
char chOptimFileName[INPUT_LINE_LENGTH]
Definition:
optimize.cpp:6
optimize
t_optimize optimize
Definition:
optimize.cpp:5
optimize.h
LIMPAR
const long LIMPAR
Definition:
optimize.h:61
parse.h
SaveFilesInit
void SaveFilesInit(void)
Definition:
parse_save.cpp:2687
physconst.h
rfield
t_rfield rfield
Definition:
rfield.cpp:8
rfield.h
struc
t_struc struc
Definition:
struc.cpp:6
struc.h
t_Heavy::chShell
char chShell[7][3]
Definition:
heavy.h:31
t_broke::lgCheckit
bool lgCheckit
Definition:
broke.h:18
t_broke::lgBroke
bool lgBroke
Definition:
broke.h:12
t_broke::lgFixit
bool lgFixit
Definition:
broke.h:15
t_cosmology::omega_rad
realnum omega_rad
Definition:
cosmology.h:32
t_cosmology::H_0
realnum H_0
Definition:
cosmology.h:39
t_cosmology::omega_matter
realnum omega_matter
Definition:
cosmology.h:34
t_cosmology::redshift_current
realnum redshift_current
Definition:
cosmology.h:26
t_cosmology::omega_lambda
realnum omega_lambda
Definition:
cosmology.h:33
t_cosmology::lgDo
bool lgDo
Definition:
cosmology.h:44
t_cosmology::redshift_start
realnum redshift_start
Definition:
cosmology.h:27
t_cosmology::h
realnum h
Definition:
cosmology.h:38
t_cosmology::omega_baryon
realnum omega_baryon
Definition:
cosmology.h:31
t_cosmology::omega_k
realnum omega_k
Definition:
cosmology.h:35
t_cosmology::redshift_step
realnum redshift_step
Definition:
cosmology.h:28
t_dense::density_low_limit
double density_low_limit
Definition:
dense.h:197
t_dense::lgElmtOn
bool lgElmtOn[LIMELM]
Definition:
dense.h:146
t_dense::lgSetIoniz
bool lgSetIoniz[LIMELM]
Definition:
dense.h:149
t_dense::maxWN
double maxWN[LIMELM][LIMELM+1]
Definition:
dense.h:134
t_dense::lgIonStoutOn
bool lgIonStoutOn[LIMELM][LIMELM+1]
Definition:
dense.h:131
t_dense::lgIonChiantiOn
bool lgIonChiantiOn[LIMELM][LIMELM+1]
Definition:
dense.h:128
t_grid::HiEnergy_keV
realnum HiEnergy_keV
Definition:
grid.h:59
t_grid::ipLoEnergy
long ipLoEnergy
Definition:
grid.h:58
t_grid::ipHiEnergy
long ipHiEnergy
Definition:
grid.h:58
t_grid::LoEnergy_keV
realnum LoEnergy_keV
Definition:
grid.h:59
t_grid::seqNum
long seqNum
Definition:
grid.h:62
t_grid::lgGridDone
bool lgGridDone
Definition:
grid.h:41
t_grid::lgStrictRepeat
bool lgStrictRepeat
Definition:
grid.h:42
t_hcmap::nMapAlloc
long int nMapAlloc
Definition:
hcmap.h:53
t_hcmap::lgMapDone
bool lgMapDone
Definition:
hcmap.h:36
t_hcmap::lgMapBeingDone
bool lgMapBeingDone
Definition:
hcmap.h:33
t_hcmap::lgMapOK
bool lgMapOK
Definition:
hcmap.h:30
t_hcmap::nmap
long int nmap
Definition:
hcmap.h:39
t_hextra::background_rate
realnum background_rate
Definition:
hextra.h:29
t_hextra::background_density
realnum background_density
Definition:
hextra.h:28
t_input::chDelimiter
char chDelimiter[3]
Definition:
input.h:42
t_optimize::lgOptimizeAsLinear
bool lgOptimizeAsLinear[LIMPAR]
Definition:
optimize.h:180
t_rfield::lgMeshSetUp
bool lgMeshSetUp
Definition:
rfield.h:131
t_struc::dr_ionfrac_limit
realnum dr_ionfrac_limit
Definition:
struc.h:84
lgStatesAdded
bool lgStatesAdded
Definition:
taulines.cpp:10
lgLinesAdded
bool lgLinesAdded
Definition:
taulines.cpp:11
taulines.h
version.h
Generated by
1.9.5