cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
conv.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2017 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 #include "cddefines.h"
4 #include "conv.h"
6 
8 {
9  /* this counts number of times ionize is called by PressureChange, in current zone
10  * these are reset here, so that we count from first zone not search */
11  nPres2Ioniz = 0;
12 
13  /* clear flag indicating the ionization convergence failures
14  * have ever occurred in current zone
15  lgConvIonizThisZone = false; */
16  lgFirstSweepThisZone = false;
17  lgLastSweepThisZone = false;
18  lgLyaMaseCommentDone = false;
19 
20  resetCounters();
21 
22  /* cooling tolerance heating tolerance - allowed error in heating - cooling balance */
23  /*HeatCoolRelErrorAllowed = 0.02f;*/
24  /* >>chng 04 sep 25, change te tolerance from 0.02 to 4x smaller, 0.005, drove instabilities
25  * in chemistry */
26  HeatCoolRelErrorAllowed = 0.005f;
27 
28  /* this is the default allowed relative error in the electron density */
29  EdenErrorAllowed = 1e-2;
30 
31  IonizErrorAllowed = 1e-2;
32 
33  dCmHdT = 0.;
34 
35  LimFail = 20;
36  lgMap = false;
37 
38  /* this counts how many times ionize is called in this model after startr,
39  * and is flag used by ionize to understand it is being called the first time*/
40  nTotalIoniz = 0;
41  /* these are variables to remember the biggest error in the
42  * electron density, and the zone in which it occurred */
43  BigEdenError = 0.;
44  AverEdenError = 0.;
45  BigHeatCoolError = 0.;
46  AverHeatCoolError = 0.;
47  BigPressError = 0.;
48  AverPressError = 0.;
49  strcpy( chSolverEden, "SECA" );
50  strcpy( chSolverTemp, "vWDB" );
51  strcpy( chNotConverged, "none" );
52  strcpy( chConvEden, "none" );
54  /* iterate to convergence flag */
55  lgAutoIt = false;
56  /* convergence criteria */
57  autocv = 0.20f;
58  lgAllTransitions = false;
59  lgConvTemp = true;
60  lgConvPres = true;
61  lgConvEden = true;
62  lgUpdateCouplings = false;
63  /* >>chng 04 jan 25, only set lgConvIoniz true where used in ConvXXX path */
64  /*lgConvIoniz = true;*/
65 
66  /* this is the default allowed relative error in the pressure */
67  PressureErrorAllowed = 0.01f;
68 
70 
71  /* default error in total gas-phase density of each element, including molecules */
73 
74  /* this is abort option set with SET PRESIONIZ command */
75  limPres2Ioniz = 3000;
76 
77  nTeFail = 0;
78  nTotalFailures = 0;
79  nPreFail = 0;
80  failmx = 0.;
81  nIonFail = 0;
82  nPopFail = 0;
83  nNeFail = 0;
84  nGrainFail = 0;
85  dCmHdT = 0.;
86 }
87 
89 {
90  DEBUG_ENTRY( "t_conv::register_()" );
91  for( size_t i=0; i<m_counters.size(); ++i )
92  {
93  if (name == m_labels[i])
94  {
95  fprintf(ioQQQ,"Internal error: convergence counter '%s' already"
96  " registered\n", name.c_str());
98  }
99  }
100  size_t newtype = m_counters.size();
101  m_counters.push_back(0);
102  m_counters_zone.push_back(0);
103  m_labels.push_back(name);
104  return ConvergenceCounter(this, newtype);
105 }
106 
long int nGrainFail
Definition: conv.h:224
long int nTeFail
Definition: conv.h:203
bool lgConvEden
Definition: conv.h:197
Definition: conv.h:75
double MaxFractionalDensityStepPerIteration
Definition: conv.h:272
double EdenErrorAllowed
Definition: conv.h:265
void zero()
Definition: conv.cpp:7
char chConvEden[INPUT_LINE_LENGTH]
Definition: conv.h:85
bool lgFirstSweepThisZone
Definition: conv.h:148
ConvergenceCounter register_(const string name)
Definition: conv.cpp:88
char chNotConverged[INPUT_LINE_LENGTH]
Definition: conv.h:128
bool lgConvPres
Definition: conv.h:194
realnum BigHeatCoolError
Definition: conv.h:176
t_conv conv
Definition: conv.cpp:5
long int nNeFail
Definition: conv.h:212
long int limPres2Ioniz
Definition: conv.h:154
void resetConvIoniz()
Definition: conv.h:93
realnum GasPhaseAbundErrorAllowed
Definition: conv.h:283
realnum AverPressError
Definition: conv.h:181
realnum BigPressError
Definition: conv.h:180
FILE * ioQQQ
Definition: cddefines.cpp:7
realnum AverHeatCoolError
Definition: conv.h:177
bool lgAllTransitions
Definition: conv.h:254
realnum PressureErrorAllowed
Definition: conv.h:270
realnum autocv
Definition: conv.h:260
bool lgLyaMaseCommentDone
Definition: conv.h:170
bool lgMap
Definition: conv.h:233
long int nPres2Ioniz
Definition: conv.h:145
std::vector< long > m_counters_zone
Definition: conv.h:304
#define EXIT_FAILURE
Definition: cddefines.h:168
realnum IonizErrorAllowed
Definition: conv.h:278
double dCmHdT
Definition: conv.h:286
#define cdEXIT(FAIL)
Definition: cddefines.h:484
realnum HeatCoolRelErrorAllowed
Definition: conv.h:276
long int nTotalIoniz
Definition: conv.h:159
std::vector< long > m_counters
Definition: conv.h:303
long int nPreFail
Definition: conv.h:209
long int LimFail
Definition: conv.h:230
bool lgConvTemp
Definition: conv.h:191
void resetCounters()
Definition: conv.h:317
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:729
bool lgAutoIt
Definition: conv.h:251
realnum failmx
Definition: conv.h:206
realnum AverEdenError
Definition: conv.h:173
bool lgUpdateCouplings
Definition: conv.h:257
long int nPopFail
Definition: conv.h:221
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1217
std::vector< string > m_labels
Definition: conv.h:305
long int nIonFail
Definition: conv.h:218
bool lgLastSweepThisZone
Definition: conv.h:150
char chSolverEden[20]
Definition: conv.h:240
realnum BigEdenError
Definition: conv.h:215
char chSolverTemp[20]
Definition: conv.h:244
long int nTotalFailures
Definition: conv.h:200