cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
conv_ioniz.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 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  /* this is ionization/electron density convergence loop
19  * keep calling ConvBase until lgIonDone is true */
20  for( int i=0; i < LoopLimit; ++i )
21  {
22  /* compute the current ionization, ots rates, secondary ionization rates */
23  if( ConvBase(i) )
24  return 1;
25 
26  if( trace.nTrConvg >= 4 )
27  {
28  /* cooling has not been evaluated yet */
29  fprintf( ioQQQ, " ConvIoniz4 %d heat: %.2e cool: %.2e ",
30  i, thermal.htot , thermal.ctot );
31 
32  /* this is flag saying whether or not ionization/eden has converged */
33  if( conv.lgConvIoniz() )
34  {
35  fprintf( ioQQQ, " ioniz converged\n" );
36  }
37  else
38  {
39  fprintf( ioQQQ, " ioniz no conv: %s old %.4e new %.4e OscilOTS %c\n",
40  conv.chConvIoniz() ,
44  }
45  }
46 
47  if( conv.lgConvIoniz() || lgAbort )
48  break;
49 
50  }
51 
52  if( trace.nTrConvg>=4 )
53  {
54  if (! conv.lgConvIoniz())
55  {
56  fprintf( ioQQQ,
57  " ConvIoniz4>>>>>>>>>>exit without converging after %i tries!!!!\n", LoopLimit);
58  }
59  /* if trace convergence is in operation and we did not converge, give warning */
60  //ConvFail("ioni","");
61  //return 1;
62  }
63 
64  return 0;
65 }
double htot
Definition: thermal.h:169
t_thermal thermal
Definition: thermal.cpp:6
int ConvBase(long loopi)
Definition: conv_base.cpp:188
char TorF(bool l)
Definition: cddefines.h:749
t_conv conv
Definition: conv.cpp:5
double convIonizNewVal() const
Definition: conv.h:120
FILE * ioQQQ
Definition: cddefines.cpp:7
bool lgConvIoniz() const
Definition: conv.h:108
bool lgOscilOTS
Definition: conv.h:186
bool lgSearch
Definition: conv.h:168
t_trace trace
Definition: trace.cpp:5
const char * chConvIoniz() const
Definition: conv.h:112
int nTrConvg
Definition: trace.h:27
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
int ConvIoniz(void)
Definition: conv_ioniz.cpp:11
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
double convIonizOldVal() const
Definition: conv.h:116
bool lgAbort
Definition: cddefines.cpp:10
double ctot
Definition: thermal.h:130