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-2022 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 
19  resetCounters();
20 
21  /* cooling tolerance heating tolerance - allowed error in heating - cooling balance */
22  /*HeatCoolRelErrorAllowed = 0.02f;*/
23  /* >>chng 04 sep 25, change te tolerance from 0.02 to 4x smaller, 0.005, drove instabilities
24  * in chemistry */
25  HeatCoolRelErrorAllowed = 0.005f;
26 
27  /* this is the default allowed relative error in the electron density */
28  EdenErrorAllowed = 1e-2;
29 
30  IonizErrorAllowed = 1e-2;
31 
32  dCmHdT = 0.;
33 
34  LimFail = 20;
35  lgMap = false;
36 
37  /* this counts how many times ionize is called in this model after startr,
38  * and is flag used by ionize to understand it is being called the first time*/
39  nTotalIoniz = 0;
40  /* these are variables to remember the biggest error in the
41  * electron density, and the zone in which it occurred */
42  BigEdenError = 0.;
43  AverEdenError = 0.;
44  BigHeatCoolError = 0.;
45  AverHeatCoolError = 0.;
46  BigPressError = 0.;
47  AverPressError = 0.;
48  strcpy( chSolverEden, "SECA" );
49  strcpy( chSolverTemp, "vWDB" );
50  strcpy( chNotConverged, "none" );
51  strcpy( chConvEden, "none" );
53  /* iterate to convergence flag */
54  lgAutoIt = false;
55  /* convergence criteria */
56  autocv = 0.20f;
57  lgAllTransitions = false;
58  lgConvTemp = true;
59  lgConvPres = true;
60  lgConvEden = true;
61  lgUpdateCouplings = false;
62  /* >>chng 04 jan 25, only set lgConvIoniz true where used in ConvXXX path */
63  /*lgConvIoniz = true;*/
64 
65  /* this is the default allowed relative error in the pressure */
66  PressureErrorAllowed = 0.01f;
67 
69 
70  /* default error in total gas-phase density of each element, including molecules */
72 
73  /* this is abort option set with SET PRESIONIZ command */
74  limPres2Ioniz = 3000;
75 
76  nTeFail = 0;
77  nTotalFailures = 0;
78  nPreFail = 0;
79  failmx = 0.;
80  nIonFail = 0;
81  nPopFail = 0;
82  nNeFail = 0;
83  nGrainFail = 0;
84  dCmHdT = 0.;
85 }
86 
88 {
89  DEBUG_ENTRY( "t_conv::register_()" );
90  for( size_t i=0; i<m_counters.size(); ++i )
91  {
92  if (name == m_labels[i])
93  {
94  fprintf(ioQQQ,"Internal error: convergence counter '%s' already"
95  " registered\n", name.c_str());
97  }
98  }
99  size_t newtype = m_counters.size();
100  m_counters.push_back(0);
101  m_counters_zone.push_back(0);
102  m_labels.push_back(name);
103  return ConvergenceCounter(this, newtype);
104 }
105 
long int nGrainFail
Definition: conv.h:222
long int nTeFail
Definition: conv.h:201
bool lgConvEden
Definition: conv.h:195
Definition: conv.h:75
double MaxFractionalDensityStepPerIteration
Definition: conv.h:270
double EdenErrorAllowed
Definition: conv.h:263
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:87
char chNotConverged[INPUT_LINE_LENGTH]
Definition: conv.h:128
bool lgConvPres
Definition: conv.h:192
realnum BigHeatCoolError
Definition: conv.h:174
t_conv conv
Definition: conv.cpp:5
long int nNeFail
Definition: conv.h:210
long int limPres2Ioniz
Definition: conv.h:154
void resetConvIoniz()
Definition: conv.h:93
realnum GasPhaseAbundErrorAllowed
Definition: conv.h:281
realnum AverPressError
Definition: conv.h:179
realnum BigPressError
Definition: conv.h:178
FILE * ioQQQ
Definition: cddefines.cpp:7
realnum AverHeatCoolError
Definition: conv.h:175
bool lgAllTransitions
Definition: conv.h:252
realnum PressureErrorAllowed
Definition: conv.h:268
realnum autocv
Definition: conv.h:258
bool lgMap
Definition: conv.h:231
long int nPres2Ioniz
Definition: conv.h:145
std::vector< long > m_counters_zone
Definition: conv.h:302
#define EXIT_FAILURE
Definition: cddefines.h:168
realnum IonizErrorAllowed
Definition: conv.h:276
double dCmHdT
Definition: conv.h:284
#define cdEXIT(FAIL)
Definition: cddefines.h:482
realnum HeatCoolRelErrorAllowed
Definition: conv.h:274
long int nTotalIoniz
Definition: conv.h:159
std::vector< long > m_counters
Definition: conv.h:301
long int nPreFail
Definition: conv.h:207
long int LimFail
Definition: conv.h:228
bool lgConvTemp
Definition: conv.h:189
void resetCounters()
Definition: conv.h:315
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
bool lgAutoIt
Definition: conv.h:249
realnum failmx
Definition: conv.h:204
realnum AverEdenError
Definition: conv.h:171
bool lgUpdateCouplings
Definition: conv.h:255
long int nPopFail
Definition: conv.h:219
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
std::vector< string > m_labels
Definition: conv.h:303
long int nIonFail
Definition: conv.h:216
bool lgLastSweepThisZone
Definition: conv.h:150
char chSolverEden[20]
Definition: conv.h:238
realnum BigEdenError
Definition: conv.h:213
char chSolverTemp[20]
Definition: conv.h:242
long int nTotalFailures
Definition: conv.h:198