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
conv_ioniz.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
/*ConvIoniz called by ConvEdenIonz, it calls ConvBase until converged */
4
#include "
cddefines.h
"
5
#include "
thermal.h
"
6
#include "
trace.h
"
7
#include "
conv.h
"
8
9
/*ConvIoniz called by ConvEdenIonz, it calls ConvBase until converged
10
* returns 1 if error condition, 0 if ok */
11
int
ConvIoniz
(
void
)
12
{
13
long
int
14
/* the ionization loop counter */
15
loopi ,
16
/* the limit to how many times we will try calling ConvBase before giving up */
17
LoopLimit;
18
19
DEBUG_ENTRY
(
"ConvIoniz()"
);
20
21
/* this routine is called by ConvTempIonz, it calls ConvBase
22
* until it converges */
23
24
if
(
conv
.
lgSearch
)
25
{
26
/* expand limit to number of calls to ConvBase during search phase */
27
LoopLimit = 30;
28
}
29
else
30
{
31
LoopLimit = 20;
32
}
33
34
/* zero the ionization loop counter */
35
loopi = 0;
36
37
/* do not go into the loop with first call to ionization,
38
* since results will be bogus - do it here */
39
if
( !
conv
.
lgSearch
&&
conv
.
nPres2Ioniz
== 0 )
40
{
41
if
(
ConvBase
(loopi) )
42
{
43
return
1;
44
}
45
}
46
47
strcpy(
conv
.
chConvIoniz
,
" NONE!!!!!"
);
48
/* this is ionization/electron density convergence loop
49
* keep calling ConvBase until lgIonDone is true */
50
do
51
{
52
/* compute the current ionization, ots rates, secondary ionization rates */
53
if
(
ConvBase
(loopi) )
54
{
55
56
return
1;
57
}
58
59
if
(
trace
.
nTrConvg
>=4 )
60
{
61
/* cooling has not been evaluated yet */
62
fprintf(
ioQQQ
,
63
" ConvIoniz4%4ld heat:%10.2e cool:%10.2e "
,
64
loopi,
thermal
.
htot
,
thermal
.
ctot
);
65
66
/* this is flag saying whether or not ionization/eden has converged */
67
if
(
conv
.
lgConvIoniz
)
68
{
69
fprintf(
ioQQQ
,
" ioniz converged\n"
);
70
}
71
else
72
{
73
fprintf(
ioQQQ
,
" ioniz no conv:%10.10s old %.4e new %.4e OscilOTS %c\n"
,
74
conv
.
chConvIoniz
,
75
conv
.
BadConvIoniz
[0] ,
76
conv
.
BadConvIoniz
[1] ,
77
TorF
(
conv
.
lgOscilOTS
) );
78
}
79
}
80
81
/* increment ionization loop, and keep going until we converge */
82
++loopi;
83
}
while
( !
conv
.
lgConvIoniz
&& loopi < LoopLimit && !
lgAbort
);
84
85
if
( !
conv
.
lgConvIoniz
)
86
{
87
/* this is a major problem, ConvIoniz did not converge the ionization */
88
++
conv
.
nConvIonizFails
;
89
/* this is flag saying that an ionization convergence problem occurred in this
90
* zone, will be used to help choose next dr
91
>>chng 06 dec 17, never used so removed
92
++conv.lgConvIonizThisZone; */
93
}
94
95
/* if trace convergence is in operation and we did not converge, give warning */
96
if
(
trace
.
nTrConvg
>=4 && !
conv
.
lgConvIoniz
)
97
{
98
fprintf(
ioQQQ
,
99
" ConvIoniz4>>>>>>>>>>exit without converging after %li tries!!!!\n"
,loopi);
100
}
101
# if 0
102
{
103
#include "
grainvar.h
"
104
#include "
dense.h
"
105
#include "
mole.h
"
106
fprintf(
ioQQQ
,
"DEBUG co mol eden\t%.2f\t%e\t%e\t%e\t%e\n"
,
107
fnzone
,
108
dense
.
eden
,
109
gv
.
TotalEden
,
110
co
.
comole_eden
,
111
dense
.
EdenTrue
);
112
}
113
# endif
114
115
return
0;
116
}
Generated for cloudy by
1.8.4