cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
conv.h
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 
4 #ifndef CONV_H_
5 #define CONV_H_
6 
13 #include "module.h"
14 
17 void ConvIterCheck( void );
18 
21 bool ConvInitSolution();
22 
27 int ConvPresTempEdenIoniz(void);
28 
32 int ConvTempEdenIoniz(void);
33 
37 int ConvEdenIoniz(void);
38 
41 int ConvIoniz(void);
42 
47 void ConvFail(
48  /* chMode is one of "pres", "eden", "ioni", "pops", "grai", "temp" */
49  const char chMode[],
50  /* chDetail - string giving details about the convergence failure */
51  const char chDetail[] );
52 
60 int ConvBase(long loopi);
61 
65 int eden_sum(void);
66 
68 void EdenChange( double EdenNew );
69 
70 class ConvergenceCounter;
71 
75 struct t_conv : public module {
76 
77  const char *chName() const
78  {
79  return "conv";
80  }
81  void zero();
82  void comment(t_warnings&) {}
83 
86 
87 private:
91 
92 public:
94  {
95  m_lgConvIoniz = true;
96  strncpy(m_chConvIoniz, "NONE!!!!!", INPUT_LINE_LENGTH-1);
97  m_BadConvIoniz[0] = 0.0;
98  m_BadConvIoniz[1] = 0.0;
99  }
100  void setConvIonizFail(const char* reason, double oldval, double newval)
101  {
102  m_lgConvIoniz = false;
103  strncpy(m_chConvIoniz, reason, INPUT_LINE_LENGTH-1);
105  m_BadConvIoniz[0] = oldval;
106  m_BadConvIoniz[1] = newval;
107  }
108  bool lgConvIoniz() const
109  {
110  return m_lgConvIoniz;
111  }
112  const char *chConvIoniz() const
113  {
114  return m_chConvIoniz;
115  }
116  double convIonizOldVal() const
117  {
118  return m_BadConvIoniz[0];
119  }
120  double convIonizNewVal() const
121  {
122  return m_BadConvIoniz[1];
123  }
124 
125 
129 
130 private:
133 
134 public:
137 
138 private:
141  double m_BadConvIoniz[2];
142 
143 public:
145  long int nPres2Ioniz;
146 
151 
154  long int limPres2Ioniz;
155 
159  long int nTotalIoniz;
160 
165 
168  bool lgSearch;
169 
172 
176 
180 
183 
187 
190 
193 
196 
198  long int nTotalFailures;
199 
201  long int nTeFail;
202 
205 
207  long int nPreFail;
208 
210  long int nNeFail;
211 
214 
216  long int nIonFail;
217 
219  long int nPopFail;
220 
222  long int nGrainFail;
223 
225  long int nChemFail;
226 
228  long int LimFail;
229 
231  bool lgMap;
232 
234  long int ifailz[12];
235 
238  char chSolverEden[20];
239 
242  char chSolverTemp[20];
243 
246  bool lgBadStop;
247 
249  bool lgAutoIt;
250 
253 
256 
259 
264 
269 
271 
275 
277 
282 
284  double dCmHdT;
285 
287  double sigma_dCmHdT;
288 
292  long int hist_pres_nzone;
293 
297  long int hist_temp_nzone;
298 
299 private:
300  // Variables monitoring progress of convergence
301  std::vector<long> m_counters;
302  std::vector<long> m_counters_zone;
303  std::vector<string> m_labels;
304 public:
305  size_t ntypes(void) const
306  {
307  return m_counters.size();
308  }
309  ConvergenceCounter register_(const string name);
310  void incrementCounter( const size_t type )
311  {
312  ++m_counters[type];
313  ++m_counters_zone[type];
314  }
316  {
317  for( size_t i=0; i<m_counters.size(); ++i )
318  m_counters[i] = 0;
319  }
321  {
322  for( size_t i=0; i<m_counters_zone.size(); ++i )
323  m_counters_zone[i] = 0;
324  }
325  long getCounter( const long type ) const
326  {
327  return m_counters[type];
328  }
329  long getCounter( const string name ) const
330  {
331  for( size_t i=0; i<m_counters.size(); ++i )
332  {
333  if (name == m_labels[i])
334  return m_counters[i];
335  }
336  return 0;
337  }
338  long getCounterZone( const long type ) const
339  {
340  return m_counters_zone[type];
341  }
342  const char* getCounterName( const long type ) const
343  {
344  return m_labels[type].c_str();
345  }
346 };
347 
349 {
351  size_t m_type;
352 public:
353  ConvergenceCounter(t_conv* convp, size_t type)
354  : m_conv(convp)
355  , m_type(type)
356  {}
358  {
360  return *this;
361  }
362 };
363 
364 extern t_conv conv;
365 
366 #endif /* CONV_H_ */
long int nGrainFail
Definition: conv.h:222
long getCounterZone(const long type) const
Definition: conv.h:338
long int nTeFail
Definition: conv.h:201
bool lgConvEden
Definition: conv.h:195
vector< double > hist_pres_density
Definition: conv.h:291
void comment(t_warnings &)
Definition: conv.h:82
ConvergenceCounter & operator++(void)
Definition: conv.h:357
Definition: conv.h:75
double MaxFractionalDensityStepPerIteration
Definition: conv.h:270
bool m_lgConvIoniz
Definition: conv.h:132
double EdenErrorAllowed
Definition: conv.h:263
vector< double > hist_pres_error
Definition: conv.h:291
const char * chName() const
Definition: conv.h:77
int ConvBase(long loopi)
Definition: conv_base.cpp:188
void zero()
Definition: conv.cpp:7
char chConvEden[INPUT_LINE_LENGTH]
Definition: conv.h:85
long getCounter(const string name) const
Definition: conv.h:329
bool lgFirstSweepThisZone
Definition: conv.h:148
ConvergenceCounter register_(const string name)
Definition: conv.cpp:87
char chNotConverged[INPUT_LINE_LENGTH]
Definition: conv.h:128
int eden_sum(void)
Definition: eden_sum.cpp:17
bool lgConvPres
Definition: conv.h:192
void resetCountersZone()
Definition: conv.h:320
realnum BigHeatCoolError
Definition: conv.h:174
t_conv conv
Definition: conv.cpp:5
long int nTotalIoniz_start
Definition: conv.h:164
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
double convIonizNewVal() const
Definition: conv.h:120
bool lgConvPops
Definition: conv.h:136
realnum AverPressError
Definition: conv.h:179
realnum BigPressError
Definition: conv.h:178
realnum AverHeatCoolError
Definition: conv.h:175
bool lgAllTransitions
Definition: conv.h:252
bool lgConvIoniz() const
Definition: conv.h:108
bool lgOscilOTS
Definition: conv.h:186
realnum PressureErrorAllowed
Definition: conv.h:268
int ConvTempEdenIoniz(void)
long int nChemFail
Definition: conv.h:225
realnum autocv
Definition: conv.h:258
bool lgBadStop
Definition: conv.h:246
bool lgIonStageTrimed
Definition: conv.h:182
vector< double > hist_temp_cool
Definition: conv.h:296
bool lgSearch
Definition: conv.h:168
long int hist_temp_nzone
Definition: conv.h:297
const char * chConvIoniz() const
Definition: conv.h:112
const char * getCounterName(const long type) const
Definition: conv.h:342
bool lgMap
Definition: conv.h:231
long int nPres2Ioniz
Definition: conv.h:145
std::vector< long > m_counters_zone
Definition: conv.h:302
long int ifailz[12]
Definition: conv.h:234
char m_chConvIoniz[INPUT_LINE_LENGTH]
Definition: conv.h:90
vector< double > hist_pres_current
Definition: conv.h:291
long getCounter(const long type) const
Definition: conv.h:325
vector< double > hist_temp_temp
Definition: conv.h:296
float realnum
Definition: cddefines.h:124
realnum IonizErrorAllowed
Definition: conv.h:276
const int INPUT_LINE_LENGTH
Definition: cddefines.h:301
double sigma_dCmHdT
Definition: conv.h:287
double dCmHdT
Definition: conv.h:284
double m_BadConvIoniz[2]
Definition: conv.h:141
realnum HeatCoolRelErrorAllowed
Definition: conv.h:274
long int hist_pres_nzone
Definition: conv.h:292
void ConvFail(const char chMode[], const char chDetail[])
Definition: conv_fail.cpp:16
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
void ConvIterCheck(void)
void incrementCounter(const size_t type)
Definition: conv.h:310
bool lgAutoIt
Definition: conv.h:249
realnum failmx
Definition: conv.h:204
realnum AverEdenError
Definition: conv.h:171
bool lgUpdateCouplings
Definition: conv.h:255
int ConvPresTempEdenIoniz(void)
vector< double > hist_temp_heat
Definition: conv.h:296
long int nPopFail
Definition: conv.h:219
int ConvIoniz(void)
Definition: conv_ioniz.cpp:11
size_t m_type
Definition: conv.h:351
std::vector< string > m_labels
Definition: conv.h:303
void setConvIonizFail(const char *reason, double oldval, double newval)
Definition: conv.h:100
size_t ntypes(void) const
Definition: conv.h:305
long int nIonFail
Definition: conv.h:216
t_conv * m_conv
Definition: conv.h:350
bool lgLastSweepThisZone
Definition: conv.h:150
void EdenChange(double EdenNew)
Definition: eden_change.cpp:11
char chSolverEden[20]
Definition: conv.h:238
int ConvEdenIoniz(void)
realnum BigEdenError
Definition: conv.h:213
Definition: module.h:26
char chSolverTemp[20]
Definition: conv.h:242
double convIonizOldVal() const
Definition: conv.h:116
long int nTotalFailures
Definition: conv.h:198
bool ConvInitSolution()
ConvergenceCounter(t_conv *convp, size_t type)
Definition: conv.h:353