cloudy
trunk
source
age_check.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
/*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
(
findspecieslocal
(
"H2"
)->xFracLim < 1e-2 )
105
{
106
timesc
.
time_H2_Dest_longest
*= -1.;
107
timesc
.
time_H2_Form_longest
*= -1.;
108
}
109
tlong =
MAX2
( tlong ,
timesc
.
time_H2_Dest_longest
);
110
tlong =
MAX2
( tlong ,
timesc
.
time_H2_Form_longest
);
111
112
if
(
findspecieslocal
(
"CO"
)->xFracLim < 1e-2 )
113
{
114
timesc
.
BigCOMoleForm
*= -1.;
115
}
116
tlong =
MAX2
( tlong ,
timesc
.
BigCOMoleForm
);
117
118
/* >>chng 97 jan 03, don't print if zero */
119
if
(
prt
.
lgPrnAges
&&
timesc
.
time_H2_Dest_longest
> 0. )
120
{
121
sprintf( chLine,
" AGE: longest H2 destruction timescale= %.2es."
,
122
timesc
.
time_H2_Dest_longest
);
123
notein
(chLine);
124
}
125
126
if
(
prt
.
lgPrnAges
&&
timesc
.
time_H2_Form_longest
> 0. )
127
{
128
sprintf( chLine,
" AGE: longest H2 formation timescale= %.2es."
,
129
timesc
.
time_H2_Form_longest
);
130
notein
(chLine);
131
}
132
133
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
time_H2_Dest_longest
>
timesc
.
CloudAgeSet
)
134
{
135
sprintf( chLine,
" C-AGE: H2 destruction timescale longer than age, = %.2es"
,
136
timesc
.
time_H2_Dest_longest
);
137
caunin
(chLine);
138
}
139
140
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
time_H2_Form_longest
>
timesc
.
CloudAgeSet
)
141
{
142
sprintf( chLine,
" C-AGE: H2 formation timescale longer than age, = %.2es"
,
143
timesc
.
time_H2_Form_longest
);
144
caunin
(chLine);
145
}
146
147
if
(
prt
.
lgPrnAges
&&
timesc
.
BigCOMoleForm
> 0. )
148
{
149
sprintf( chLine,
" AGE: longest CO formation timescale= %.2es."
,
150
timesc
.
BigCOMoleForm
);
151
notein
(chLine);
152
}
153
154
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
BigCOMoleForm
>
timesc
.
CloudAgeSet
)
155
{
156
sprintf( chLine,
" C-AGE: CO formation timescale longer than age, = %.2es"
,
157
timesc
.
BigCOMoleForm
);
158
caunin
(chLine);
159
}
160
161
/* hydrogen recombination timescale */
162
timesc
.
time_Hrecom_long
= 0.;
163
timesc
.
time_Hrecom_short
= 0.;
164
for
( i=0; i < limit; i++ )
165
{
166
if
(
struc
.
ednstr
[i]>
SMALLFLOAT
)
167
{
168
hold =
struc
.
ednstr
[i]*2.90e-10*pow(
struc
.
testr
[i],(
realnum
)-0.77f);
169
timesc
.
time_Hrecom_long
=
MAX2
(
timesc
.
time_Hrecom_long
, 1./hold);
170
timesc
.
time_Hrecom_short
=
MAX2
(
timesc
.
time_Hrecom_short
, 1./hold);
171
}
172
}
173
174
tlong =
MAX2
(tlong,
timesc
.
time_Hrecom_long
);
175
if
(
prt
.
lgPrnAges
)
176
{
177
sprintf( chLine,
" AGE: longest H recombination timescale= %.2es."
,
178
timesc
.
time_Hrecom_long
);
179
notein
(chLine);
180
}
181
182
if
(
timesc
.
CloudAgeSet
> 0. &&
timesc
.
time_Hrecom_long
>
timesc
.
CloudAgeSet
)
183
{
184
sprintf( chLine,
" C-AGE: Hydrogen recombination timescale longer than age, = %.2es"
,
185
timesc
.
time_Hrecom_long
);
186
caunin
(chLine);
187
}
188
189
/* give age in various units, depending on order of magnitude */
190
if
(
timesc
.
CloudAgeSet
< 0. )
191
{
192
/* CloudAgeSet initially set to -1, if still the case then age not set */
193
if
( tlong < 3600. )
194
{
195
/* less than one day, give only seconds */
196
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s."
,
197
tlong );
198
bangin
(chLine);
199
}
200
201
else
if
( tlong < 8.64e4 )
202
{
203
/* less than one day, give seconds and hours */
204
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e hours."
,
205
tlong, tlong/3600. );
206
bangin
(chLine);
207
}
208
209
else
if
( tlong < 3e7/12. )
210
{
211
/* less than one month, give seconds and days */
212
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e days."
,
213
tlong, tlong/86400. );
214
bangin
(chLine);
215
}
216
217
else
if
( tlong < 3e7 )
218
{
219
/* less than one year, give seconds and months */
220
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e months."
,
221
tlong, (tlong/3.15569e7)*12. );
222
bangin
(chLine);
223
}
224
225
else
226
{
227
/* more than one year, give seconds and years */
228
sprintf( chLine,
" !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e years."
,
229
tlong, tlong/3.15569e7 );
230
bangin
(chLine);
231
}
232
}
233
234
else
235
{
236
/* age set, and passed tests, still say longest */
237
if
( tlong < 3e7 )
238
{
239
/* less than one year, give only seconds */
240
sprintf( chLine,
" AGE: Cloud age was %.2es, Longest timescale was %.2e s."
,
241
timesc
.
CloudAgeSet
, tlong );
242
notein
(chLine);
243
}
244
245
else
246
{
247
/* more than one year, give seconds and years */
248
sprintf( chLine,
" AGE: Cloud age was %.2e s. Longest timescale was %.2e s = %.2e years."
,
249
timesc
.
CloudAgeSet
, tlong, tlong/3.15569e7 );
250
notein
(chLine);
251
}
252
}
253
return
;
254
}
t_timesc::time_H2_Dest_longest
double time_H2_Dest_longest
Definition:
timesc.h:35
t_struc::coolstr
double * coolstr
Definition:
struc.h:78
caunin
void caunin(char *chLine)
Definition:
warnings.cpp:96
findspecieslocal
molezone * findspecieslocal(const char buf[])
Definition:
mole_species.cpp:833
notein
void notein(char *chLine)
Definition:
warnings.cpp:50
t_dense::chDenseLaw
char chDenseLaw[5]
Definition:
dense.h:158
struc.h
dense
t_dense dense
Definition:
dense.cpp:24
t_timesc::BigCOMoleForm
double BigCOMoleForm
Definition:
timesc.h:39
realnum
float realnum
Definition:
cddefines.h:103
t_timesc::time_Hrecom_short
double time_Hrecom_short
Definition:
timesc.h:24
mole.h
t_struc::testr
realnum * testr
Definition:
struc.h:25
t_timesc::time_therm_long
double time_therm_long
Definition:
timesc.h:19
t_timesc::TimeH21cm
double TimeH21cm
Definition:
timesc.h:51
ASSERT
#define ASSERT(exp)
Definition:
cddefines.h:578
t_timesc::time_Hrecom_long
double time_Hrecom_long
Definition:
timesc.h:23
struc
t_struc struc
Definition:
struc.cpp:6
MIN2
#define MIN2
Definition:
cddefines.h:761
t_struc::nzlim
long int nzlim
Definition:
struc.h:19
t_timesc::time_therm_short
double time_therm_short
Definition:
timesc.h:20
nzone
long int nzone
Definition:
cddefines.cpp:14
timesc
t_timesc timesc
Definition:
timesc.cpp:5
dense.h
prt
t_prt prt
Definition:
prt.cpp:10
cddefines.h
t_timesc::CloudAgeSet
realnum CloudAgeSet
Definition:
timesc.h:30
t_timesc::sound
double sound
Definition:
timesc.h:27
hmi.h
MAX2
#define MAX2
Definition:
cddefines.h:782
prt.h
INPUT_LINE_LENGTH
const int INPUT_LINE_LENGTH
Definition:
cddefines.h:254
timesc.h
t_prt::lgPrnAges
bool lgPrnAges
Definition:
prt.h:123
t_struc::DenParticles
realnum * DenParticles
Definition:
struc.h:47
physconst.h
t_struc::ednstr
realnum * ednstr
Definition:
struc.h:30
AgeCheck
void AgeCheck(void)
Definition:
age_check.cpp:14
bangin
void bangin(char *chLine)
Definition:
warnings.cpp:73
t_timesc::time_H2_Form_longest
double time_H2_Form_longest
Definition:
timesc.h:36
BOLTZMANN
const UNUSED double BOLTZMANN
Definition:
physconst.h:97
warnings.h
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition:
cddefines.h:684
SMALLFLOAT
const realnum SMALLFLOAT
Definition:
cpu.h:191
Generated by
1.8.17