44 fprintf(
ioQQQ,
" ConvTempEdenIoniz called, entering temp loop using solver %s.\n",
87 fprintf(
ioQQQ,
" ConvTempEdenIoniz: Te %e C %.4e H %.4e\n",
102 double t1=0, error1=0, t2, error2;
107 for(
int n=0; n < 5 && !
lgAbort; ++n )
109 const int DEF_ITER = 10;
110 const double DEF_FACTOR = 0.2;
111 double step, factor = DEF_FACTOR;
120 for(
int i=0; i < 100 && !
lgAbort; ++i )
125 double maxstep = factor*t1;
129 if( step == 0.0 || step > maxstep )
133 TeTrack.
add( t2, error2 );
139 if( i >= n && error1*error2 <= 0. )
147 fprintf(
ioQQQ,
" PROBLEM DISASTER - the kinetic temperature appears to be below the lower limit of the code,"
148 " %.3eK. It does not bracket thermal balance.\n",
150 fprintf(
ioQQQ,
" This calculation is aborting.\n Sorry.\n");
158 fprintf(
ioQQQ,
" ConvTempEdenIoniz: bracket1 fails t1: %e %e t2: %e %e\n",
159 t1, error1, t2, error2 );
168 if( TeTrack.
init_bracket( t1, error1, t2, error2 ) == 0 )
175 TeTrack.
set_tol(2.*DBL_EPSILON*t2);
177 if( error1 != 0.0 || error2 != 0.0 )
178 t2 = (t1*error2-t2*error1)/(error2-error1);
182 for(
int i = 0; i < (1<<(n/2))*DEF_ITER && !
lgAbort; i++ )
189 TeTrack.
add( t2, error2 );
212 fprintf(
ioQQQ,
" ConvTempEdenIoniz: Te %e C %.4e H %.4e (C-H)/H %.2f%%"
213 " d(C-H)/dT %.2e +/- %.2e\n",
269 fprintf(
ioQQQ,
" lgConvTemp: C-H rel err %.4e Te rel err %.4e converged=%c\n",
328 fprintf(
ioQQQ,
" CoolHeatError: Te: %.4e C: %.4e H: %.4e (C-H)/H: %.4e\n",
343 multimap<double,string> output;
352 sprintf( line,
"heat %s %e: %e %e\n",
354 output.insert( pair<const double,string>( fraction,
string(line) ) );
359 sprintf( line,
"cool %s %e: %e %e\n",
361 output.insert( pair<const double,string>( fraction,
string(line) ) );
365 dprintf(
ioQQQ,
" >>>>>>> STARTING COOLING DUMP <<<<<<\n" );
368 for( multimap<double,string>::reverse_iterator i=output.rbegin(); i != output.rend(); ++i )
370 dprintf(
ioQQQ,
" >>>>>>> FINISHED COOLING DUMP <<<<<<\n" );
375 multimap<double,string> output;
378 for(
int nelem=0; nelem <
LIMELM; ++nelem )
380 for(
int i=0; i <
LIMELM; ++i )
385 sprintf( line,
"heating(%i,%i): %e %e\n",
387 output.insert( pair<const double,string>( fraction,
string(line) ) );
392 dprintf(
ioQQQ,
" >>>>>>> STARTING HEATING DUMP <<<<<<\n" );
395 for( multimap<double,string>::reverse_iterator i=output.rbegin(); i != output.rend(); ++i )
397 dprintf(
ioQQQ,
" >>>>>>> FINISHED HEATING DUMP <<<<<<\n" );
double bracket_width() const
NORETURN void TotalInsanity(void)
void add(double x, double fx)
void print_history() const
ConvergenceCounter register_(const string name)
STATIC bool lgConvTemp(const iter_track &TeTrack)
STATIC void DumpHeatStack(double thres)
bool lgTemperatureConstant
STATIC void DumpCoolStack(double thres)
void TempChange(double TempNew, bool lgForceUpdate)
int ConvTempEdenIoniz(void)
void PresTotCurrent(void)
const double TEMP_LIMIT_LOW
vector< double > hist_temp_cool
bool fp_equal(sys_float x, sys_float y, int n=3)
int init_bracket(double x1, double fx1, double x2, double fx2)
int dprintf(FILE *fp, const char *format,...)
char chClntLab[NCOLNT][NCOLNT_LAB_LEN+1]
class molezone * local(void) const
molecule * findspecies(const char buf[])
vector< double > hist_temp_temp
double tabval(double r0, double depth) const
sys_float safe_div(sys_float x, sys_float y, sys_float res_0by0)
realnum HeatCoolRelErrorAllowed
double heating(long nelem, long ion)
realnum gas_phase[LIMELM]
#define DEBUG_ENTRY(funcname)
vector< double > hist_temp_heat
int fprintf(const Output &stream, const char *format,...)
double deriv(int n, double &sigma) const
STATIC double CoolHeatError(double temp)