Cloudy
Spectral Synthesis Code for Astrophysics
 All Classes 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-2023 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();
18 
21 void ConvInitSolution();
22 
26 
29 void ConvTempEdenIoniz();
30 
33 void ConvEdenIoniz();
34 
36 void ConvIoniz();
37 
42 void ConvFail(
43  /* chMode is one of "pres", "eden", "ioni", "pops", "grai", "temp" */
44  const char chMode[],
45  /* chDetail - string giving details about the convergence failure */
46  const char chDetail[] );
47 
55 void ConvBase(long loopi);
56 
60 void eden_sum();
61 
63 void EdenChange( double EdenNew );
64 
65 class ConvergenceCounter;
66 
70 struct t_conv : public module {
71 
72  const char *chName() const
73  {
74  return "conv";
75  }
76  void zero();
77  void comment(t_warnings&) {}
78 
79 private:
82  string m_chConvIoniz;
83 
84 public:
86  {
87  m_lgConvIoniz = true;
88  m_chConvIoniz = "NONE!!!!!";
89  m_BadConvIoniz[0] = 0.0;
90  m_BadConvIoniz[1] = 0.0;
91  }
92  void setConvIonizFail(const char* reason, double oldval, double newval)
93  {
94  m_lgConvIoniz = false;
95  m_chConvIoniz = reason;
96  m_BadConvIoniz[0] = oldval;
97  m_BadConvIoniz[1] = newval;
98  }
99  bool lgConvIoniz() const
100  {
101  return m_lgConvIoniz;
102  }
103  const char *chConvIoniz() const
104  {
105  return m_chConvIoniz.c_str();
106  }
107  double convIonizOldVal() const
108  {
109  return m_BadConvIoniz[0];
110  }
111  double convIonizNewVal() const
112  {
113  return m_BadConvIoniz[1];
114  }
115 
116 
120 
121 private:
124 
125 public:
128 
129 private:
132  double m_BadConvIoniz[2];
133 
134 public:
136  long int nPres2Ioniz;
137 
142 
145  long int limPres2Ioniz;
146 
150  long int nTotalIoniz;
151 
156 
159  bool lgSearch;
160 
163 
167 
171 
174 
178 
181 
184 
187 
189  long int nTotalFailures;
190 
192  long int nTeFail;
193 
196 
198  long int nPreFail;
199 
201  long int nNeFail;
202 
205 
207  long int nIonFail;
208 
210  long int nPopFail;
211 
213  long int nGrainFail;
214 
216  long int nChemFail;
217 
219  long int LimFail;
220 
222  bool lgMap;
223 
225  long int ifailz[12];
226 
229  char chSolverEden[20];
230 
233  char chSolverTemp[20];
234 
237  bool lgBadStop;
238 
240  bool lgAutoIt;
241 
244 
247 
250 
255 
260 
262 
266 
268 
273 
275  double dCmHdT;
276 
278  double sigma_dCmHdT;
279 
283  long int hist_pres_nzone;
284 
288  long int hist_temp_nzone;
289 
290 private:
291  // Variables monitoring progress of convergence
292  std::vector<long> m_counters;
293  std::vector<long> m_counters_zone;
294  std::vector<string> m_labels;
295 public:
296  size_t ntypes(void) const
297  {
298  return m_counters.size();
299  }
300  ConvergenceCounter register_(const string name);
301  void incrementCounter( const size_t type )
302  {
303  ++m_counters[type];
304  ++m_counters_zone[type];
305  }
307  {
308  for( size_t i=0; i<m_counters.size(); ++i )
309  m_counters[i] = 0;
310  }
312  {
313  for( size_t i=0; i<m_counters_zone.size(); ++i )
314  m_counters_zone[i] = 0;
315  }
316  long getCounter( const long type ) const
317  {
318  return m_counters[type];
319  }
320  long getCounter( const string name ) const
321  {
322  for( size_t i=0; i<m_counters.size(); ++i )
323  {
324  if (name == m_labels[i])
325  return m_counters[i];
326  }
327  return 0;
328  }
329  long getCounterZone( const long type ) const
330  {
331  return m_counters_zone[type];
332  }
333  const char* getCounterName( const long type ) const
334  {
335  return m_labels[type].c_str();
336  }
337 };
338 
340 {
342  size_t m_type;
343 public:
344  ConvergenceCounter(t_conv* convp, size_t type)
345  : m_conv(convp)
346  , m_type(type)
347  {}
349  {
351  return *this;
352  }
353 };
354 
355 extern t_conv conv;
356 
357 #endif /* CONV_H_ */
long int nGrainFail
Definition: conv.h:213
long getCounterZone(const long type) const
Definition: conv.h:329
long int nTeFail
Definition: conv.h:192
bool lgConvEden
Definition: conv.h:186
Definition: warnings.h:11
vector< double > hist_pres_density
Definition: conv.h:282
void comment(t_warnings &)
Definition: conv.h:77
ConvergenceCounter & operator++(void)
Definition: conv.h:348
Definition: conv.h:70
double MaxFractionalDensityStepPerIteration
Definition: conv.h:261
bool m_lgConvIoniz
Definition: conv.h:123
double EdenErrorAllowed
Definition: conv.h:254
vector< double > hist_pres_error
Definition: conv.h:282
const char * chName() const
Definition: conv.h:72
void zero()
Definition: conv.cpp:7
long getCounter(const string name) const
Definition: conv.h:320
bool lgFirstSweepThisZone
Definition: conv.h:139
ConvergenceCounter register_(const string name)
Definition: conv.cpp:86
char chNotConverged[INPUT_LINE_LENGTH]
Definition: conv.h:119
Definition: conv.h:339
bool lgConvPres
Definition: conv.h:183
void resetCountersZone()
Definition: conv.h:311
realnum BigHeatCoolError
Definition: conv.h:165
long int nTotalIoniz_start
Definition: conv.h:155
long int nNeFail
Definition: conv.h:201
long int limPres2Ioniz
Definition: conv.h:145
void resetConvIoniz()
Definition: conv.h:85
realnum GasPhaseAbundErrorAllowed
Definition: conv.h:272
t_conv conv
Definition: conv.cpp:5
double convIonizNewVal() const
Definition: conv.h:111
bool lgConvPops
Definition: conv.h:127
realnum AverPressError
Definition: conv.h:170
realnum BigPressError
Definition: conv.h:169
realnum AverHeatCoolError
Definition: conv.h:166
bool lgAllTransitions
Definition: conv.h:243
bool lgConvIoniz() const
Definition: conv.h:99
bool lgOscilOTS
Definition: conv.h:177
realnum PressureErrorAllowed
Definition: conv.h:259
long int nChemFail
Definition: conv.h:216
void ConvInitSolution()
Definition: conv_init_solution.cpp:235
realnum autocv
Definition: conv.h:249
bool lgBadStop
Definition: conv.h:237
bool lgIonStageTrimed
Definition: conv.h:173
vector< double > hist_temp_cool
Definition: conv.h:287
bool lgSearch
Definition: conv.h:159
long int hist_temp_nzone
Definition: conv.h:288
const char * chConvIoniz() const
Definition: conv.h:103
const char * getCounterName(const long type) const
Definition: conv.h:333
bool lgMap
Definition: conv.h:222
void eden_sum()
Definition: eden_sum.cpp:17
long int nPres2Ioniz
Definition: conv.h:136
std::vector< long > m_counters_zone
Definition: conv.h:293
long int ifailz[12]
Definition: conv.h:225
vector< double > hist_pres_current
Definition: conv.h:282
void ConvIterCheck()
Definition: conv_itercheck.cpp:24
long getCounter(const long type) const
Definition: conv.h:316
vector< double > hist_temp_temp
Definition: conv.h:287
float realnum
Definition: cddefines.h:127
realnum IonizErrorAllowed
Definition: conv.h:267
const int INPUT_LINE_LENGTH
Definition: cddefines.h:311
double sigma_dCmHdT
Definition: conv.h:278
double dCmHdT
Definition: conv.h:275
double m_BadConvIoniz[2]
Definition: conv.h:132
realnum HeatCoolRelErrorAllowed
Definition: conv.h:265
long int hist_pres_nzone
Definition: conv.h:283
void ConvFail(const char chMode[], const char chDetail[])
Definition: conv_fail.cpp:16
long int nTotalIoniz
Definition: conv.h:150
std::vector< long > m_counters
Definition: conv.h:292
long int nPreFail
Definition: conv.h:198
long int LimFail
Definition: conv.h:219
bool lgConvTemp
Definition: conv.h:180
void resetCounters()
Definition: conv.h:306
string m_chConvIoniz
Definition: conv.h:82
void incrementCounter(const size_t type)
Definition: conv.h:301
void ConvEdenIoniz()
Definition: conv_eden_ioniz.cpp:21
bool lgAutoIt
Definition: conv.h:240
realnum failmx
Definition: conv.h:195
realnum AverEdenError
Definition: conv.h:162
bool lgUpdateCouplings
Definition: conv.h:246
vector< double > hist_temp_heat
Definition: conv.h:287
long int nPopFail
Definition: conv.h:210
size_t m_type
Definition: conv.h:342
void ConvTempEdenIoniz()
Definition: conv_temp_eden_ioniz.cpp:33
std::vector< string > m_labels
Definition: conv.h:294
void ConvPresTempEdenIoniz()
Definition: conv_pres_temp_eden_ioniz.cpp:22
void setConvIonizFail(const char *reason, double oldval, double newval)
Definition: conv.h:92
size_t ntypes(void) const
Definition: conv.h:296
long int nIonFail
Definition: conv.h:207
t_conv * m_conv
Definition: conv.h:341
bool lgLastSweepThisZone
Definition: conv.h:141
void EdenChange(double EdenNew)
Definition: eden_change.cpp:11
void ConvBase(long loopi)
Definition: conv_base.cpp:189
char chSolverEden[20]
Definition: conv.h:229
void ConvIoniz()
Definition: conv_ioniz.cpp:11
realnum BigEdenError
Definition: conv.h:204
Definition: module.h:26
char chSolverTemp[20]
Definition: conv.h:233
double convIonizOldVal() const
Definition: conv.h:107
long int nTotalFailures
Definition: conv.h:189
ConvergenceCounter(t_conv *convp, size_t type)
Definition: conv.h:344