cloudy
trunk
Loading...
Searching...
No Matches
source
conv_ioniz.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
/*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
/* this routine is called by ConvEdenIoniz, it calls ConvBase
10
* until it converges or overruns the loop limit */
11
int
ConvIoniz
()
12
{
13
DEBUG_ENTRY
(
"ConvIoniz()"
);
14
15
/* expand limit to number of calls to ConvBase during search phase */
16
int
LoopLimit =
conv
.lgSearch ? 20 : 10;
17
18
/* do not go into the loop with first call to ionization,
19
* since results will be bogus - do it here */
20
if
( !
conv
.lgSearch &&
conv
.nPres2Ioniz == 0 )
21
{
22
if
(
ConvBase
(0) )
23
return
1;
24
}
25
26
conv
.resetConvIoniz();
27
/* this is ionization/electron density convergence loop
28
* keep calling ConvBase until lgIonDone is true */
29
for
(
int
i=0; i < LoopLimit; ++i )
30
{
31
/* compute the current ionization, ots rates, secondary ionization rates */
32
if
(
ConvBase
(i) )
33
return
1;
34
35
if
(
trace
.nTrConvg >= 4 )
36
{
37
/* cooling has not been evaluated yet */
38
fprintf(
ioQQQ
,
" ConvIoniz4 %d heat: %.2e cool: %.2e "
,
39
i,
thermal
.htot ,
thermal
.ctot );
40
41
/* this is flag saying whether or not ionization/eden has converged */
42
if
(
conv
.lgConvIoniz() )
43
{
44
fprintf(
ioQQQ
,
" ioniz converged\n"
);
45
}
46
else
47
{
48
fprintf(
ioQQQ
,
" ioniz no conv: %s old %.4e new %.4e OscilOTS %c\n"
,
49
conv
.chConvIoniz() ,
50
conv
.convIonizOldVal() ,
51
conv
.convIonizNewVal() ,
52
TorF
(
conv
.lgOscilOTS));
53
}
54
}
55
56
if
(
conv
.lgConvIoniz() ||
lgAbort
)
57
break
;
58
59
}
60
61
if
(
trace
.nTrConvg>=4 )
62
{
63
if
(!
conv
.lgConvIoniz())
64
{
65
fprintf(
ioQQQ
,
66
" ConvIoniz4>>>>>>>>>>exit without converging after %i tries!!!!\n"
, LoopLimit);
67
}
68
/* if trace convergence is in operation and we did not converge, give warning */
69
//ConvFail("ioni","");
70
//return 1;
71
}
72
73
return
0;
74
}
ioQQQ
FILE * ioQQQ
Definition
cddefines.cpp:7
lgAbort
bool lgAbort
Definition
cddefines.cpp:10
cddefines.h
TorF
char TorF(bool l)
Definition
cddefines.h:710
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition
cddefines.h:684
conv
t_conv conv
Definition
conv.cpp:5
conv.h
ConvBase
int ConvBase(long loopi)
Definition
conv_base.cpp:163
ConvIoniz
int ConvIoniz()
Definition
conv_ioniz.cpp:11
thermal
t_thermal thermal
Definition
thermal.cpp:5
thermal.h
trace
t_trace trace
Definition
trace.cpp:5
trace.h
Generated by
1.14.0