cloudy
trunk
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
source
age_check.cpp
Go to the documentation of this file.
1
/* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2
* others. For conditions of distribution and use see copyright notice in license.txt */
3
/*AgeCheck check various timescales after calculation complete to confirm time steady OK */
4
#include "
cddefines.h
"
5
#include "
physconst.h
"
6
#include "
prt.h
"
7
#include "
hmi.h
"
8
#include "
mole.h
"
9
#include "
struc.h
"
10
#include "
warnings.h
"
11
#include "
dense.h
"
12
#include "
timesc.h
"
13
14
void
AgeCheck
(
void
)
15
{
16
char
chLine[
INPUT_LINE_LENGTH
];
17
long
int
i,
18
limit;
19
double
hold,
20
tlong,
21
tsound;
22
23
DEBUG_ENTRY
(
"AgeCheck()"
);
24
25
/* cloud age of zero means that age command turned off
26
* negative cloud age means was not set */
27
28
/* remember longest timescale */
29
tlong = 0.;
30
31
/* thermal equilibrium timescale */
32
timesc
.
time_therm_long
= 0.;
33
timesc
.
time_therm_short
= 0.;
34
limit =
MAX2
(1,
nzone
-1);
35
ASSERT
( limit <
struc
.
nzlim
);
36
37
/* NZLIM is the size of the struc vectors - should be dynamic
38
limit = MIN2( limit , NZLIM-1 );*/
39
40
for
( i=0; i < limit; i++ )
41
{
42
timesc
.
time_therm_long
=
43
MAX2
(
timesc
.
time_therm_long
,
44
struc
.
DenParticles
[i]*
BOLTZMANN
*1.5*
struc
.
testr
[i]/
struc
.
coolstr
[i]);
45
timesc
.
time_therm_short
=
46
MIN2
(
timesc
.
time_therm_short
,
47
struc
.
DenParticles
[i]*
BOLTZMANN
*1.5*
struc
.
testr
[i]/
struc
.
coolstr
[i]);
48
/*>>chng 99 feb 01, had div by heating, changed to cooling so constant
49
* temperature models are more realistic */
50
}
51
52
tlong =
MAX2
(tlong,
timesc
.
time_therm_long
);
53
if
(
prt
.
lgPrnAges
)
54
{
55
sprintf( chLine,
" AGE: longest thermal timescale= %.2es."
,
56
timesc
.
time_therm_long
);
57
notein
(chLine);
58
}
59
60
tlong =
MAX2
(tlong,
timesc
.
TimeH21cm
);
61
if
(
prt
.
lgPrnAges
)
62
{
63
sprintf( chLine,
" AGE: 21 cm equilibrium timescale= %.2es."
,
64
timesc
.
TimeH21cm
);
65
notein
(chLine);
66
}
67
68
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
time_therm_long
>
timesc
.
CloudAgeSet
)
69
{
70
sprintf( chLine,
" C-AGE: Thermal equilibrium timescale, %.2es, longer than age"
,
71
timesc
.
time_therm_long
);
72
caunin
(chLine);
73
}
74
75
/* check soundt travel time if constant pressure */
76
if
( strcmp(
dense
.
chDenseLaw
,
"CPRE"
) == 0 )
77
{
78
tsound =
timesc
.
sound
;
79
if
(
prt
.
lgPrnAges
)
80
{
81
sprintf( chLine,
" AGE: sound travel time= %.2es."
,
82
tsound );
83
notein
(chLine);
84
}
85
86
if
(
timesc
.
CloudAgeSet
> 0. && tsound >
timesc
.
CloudAgeSet
)
87
{
88
sprintf( chLine,
" C-AGE: Sound travel time longer than age in constant pressure model = %.2es"
,
89
timesc
.
time_therm_long
);
90
caunin
(chLine);
91
}
92
}
93
94
else
95
{
96
/* do not check if not constant pressure */
97
tsound = 0.;
98
}
99
tlong =
MAX2
(tlong,tsound);
100
101
/* molecule formation timescale */
102
/* >>chng 04 sep 17, - if species are negligible will set to negative number
103
* to retain value but not include in timescales */
104
if
(
hmi
.
BiggestH2
<1e-2 )
105
{
106
timesc
.
time_H2_Dest_longest
*= -1.;
107
timesc
.
time_H2_Form_longest
*= -1.;
108
}
109
if
(
findspecies
(
"CO"
)->xMoleFracMax < 1e-2 )
110
{
111
timesc
.
BigCOMoleForm
*= -1.;
112
}
113
tlong =
MAX2
( tlong ,
timesc
.
time_H2_Dest_longest
);
114
tlong =
MAX2
( tlong ,
timesc
.
time_H2_Form_longest
);
115
tlong =
MAX2
( tlong ,
timesc
.
BigCOMoleForm
);
116
117
/* >>chng 97 jan 03, don't print if zero */
118
if
(
prt
.
lgPrnAges
&&
timesc
.
time_H2_Dest_longest
> 0. )
119
{
120
sprintf( chLine,
" AGE: longest H2 destruction timescale= %.2es."
,
121
timesc
.
time_H2_Dest_longest
);
122
notein
(chLine);
123
}
124
125
if
(
prt
.
lgPrnAges
&&
timesc
.
time_H2_Form_longest
> 0. )
126
{
127
sprintf( chLine,
" AGE: longest H2 formation timescale= %.2es."
,
128
timesc
.
time_H2_Form_longest
);
129
notein
(chLine);
130
}
131
132
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
time_H2_Dest_longest
>
timesc
.
CloudAgeSet
)
133
{
134
sprintf( chLine,
" C-AGE: H2 destruction timescale longer than age, = %.2es"
,
135
timesc
.
time_H2_Dest_longest
);
136
caunin
(chLine);
137
}
138
139
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
time_H2_Form_longest
>
timesc
.
CloudAgeSet
)
140
{
141
sprintf( chLine,
" C-AGE: H2 formation timescale longer than age, = %.2es"
,
142
timesc
.
time_H2_Form_longest
);
143
caunin
(chLine);
144
}
145
146
if
(
prt
.
lgPrnAges
&&
timesc
.
BigCOMoleForm
> 0. )
147
{
148
sprintf( chLine,
" AGE: longest CO formation timescale= %.2es."
,
149
timesc
.
BigCOMoleForm
);
150
notein
(chLine);
151
}
152
153
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
BigCOMoleForm
>
timesc
.
CloudAgeSet
)
154
{
155
sprintf( chLine,
" C-AGE: CO formation timescale longer than age, = %.2es"
,
156
timesc
.
BigCOMoleForm
);
157
caunin
(chLine);
158
}
159
160
/* hydrogen recombination timescale */
161
timesc
.
time_Hrecom_long
= 0.;
162
timesc
.
time_Hrecom_short
= 0.;
163
for
( i=0; i < limit; i++ )
164
{
165
hold =
struc
.
ednstr
[i]*2.90e-10*pow(
struc
.
testr
[i],(
realnum
)-0.77f);
166
timesc
.
time_Hrecom_long
=
MAX2
(
timesc
.
time_Hrecom_long
, 1./hold);
167
timesc
.
time_Hrecom_short
=
MAX2
(
timesc
.
time_Hrecom_short
, 1./hold);
168
}
169
170
tlong =
MAX2
(tlong,
timesc
.
time_Hrecom_long
);
171
if
(
prt
.
lgPrnAges
)
172
{
173
sprintf( chLine,
" AGE: longest H recombination timescale= %.2es."
,
174
timesc
.
time_Hrecom_long
);
175
notein
(chLine);
176
}
177
178
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
time_Hrecom_long
>
timesc
.
CloudAgeSet
)
179
{
180
sprintf( chLine,
" C-AGE: Hydrogen recombination timescale longer than age, = %.2es"
,
181
timesc
.
time_Hrecom_long
);
182
caunin
(chLine);
183
}
184
185
/* give age in various units, depending on order of magnitude */
186
if
(
timesc
.
CloudAgeSet
< 0. )
187
{
188
/* CloudAgeSet initially set to -1, if still the case then age not set */
189
if
( tlong < 3600. )
190
{
191
/* less than one day, give only seconds */
192
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s."
,
193
tlong );
194
bangin
(chLine);
195
}
196
197
else
if
( tlong < 8.64e4 )
198
{
199
/* less than one day, give seconds and hours */
200
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e hours."
,
201
tlong, tlong/3600. );
202
bangin
(chLine);
203
}
204
205
else
if
( tlong < 3e7/12. )
206
{
207
/* less than one month, give seconds and days */
208
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e days."
,
209
tlong, tlong/86400. );
210
bangin
(chLine);
211
}
212
213
else
if
( tlong < 3e7 )
214
{
215
/* less than one year, give seconds and months */
216
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e months."
,
217
tlong, (tlong/3.15569e7)*12. );
218
bangin
(chLine);
219
}
220
221
else
222
{
223
/* more than one year, give seconds and years */
224
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e years."
,
225
tlong, tlong/3.15569e7 );
226
bangin
(chLine);
227
}
228
}
229
230
else
231
{
232
/* age set, and passed tests, still say longest */
233
if
( tlong < 3e7 )
234
{
235
/* less than one year, give only seconds */
236
sprintf( chLine,
" AGE: Cloud age was %.2es, Longest timescale was %.2e s."
,
237
timesc
.
CloudAgeSet
, tlong );
238
notein
(chLine);
239
}
240
241
else
242
{
243
/* more than one year, give seconds and years */
244
sprintf( chLine,
" AGE: Cloud age was %.2e s. Longest timescale was %.2e s = %.2e years."
,
245
timesc
.
CloudAgeSet
, tlong, tlong/3.15569e7 );
246
notein
(chLine);
247
}
248
}
249
return
;
250
}
Generated for cloudy by
1.8.4