37 " ConvEdenIoniz called, entering eden loop using solver %s.\n",
50 double n1, error1, n2, error2;
53 bool lgHysteresis =
false;
55 for(
int n=0; n < 3; ++n )
57 const int DEF_ITER = 10;
72 NeTrack.
add( n1, error1 );
76 else if( abs(
safe_div( error1, n1 )) < factor )
79 n2 = ( error1 > 0. ) ? n1*(1.-factor) : n1*(1.+factor);
86 NeTrack.
add( n2, error2 );
91 while( error1*error2 > 0. && j++ < DEF_ITER )
95 double deriv = NeTrack.
deriv(5);
101 double step =
safe_div( -1.2*error1, deriv, 0. );
102 step =
sign(
min( abs(step), factor*n1 ), step );
105 NeTrack.
add( n2, error2 );
110 fprintf(
ioQQQ,
" ConvEdenIoniz: bracket failure 1 n1: %e %e n2: %e %e\n",
111 n1, error1, n2, error2 );
117 while( error1*error2 > 0. && j++ < 20*DEF_ITER )
121 n2 = ( error1 > 0. ) ? n1*(1.-factor) : n1*(1.+factor);
123 NeTrack.
add( n2, error2 );
128 fprintf(
ioQQQ,
" ConvEdenIoniz: bracket failure 2 n1: %e %e n2: %e %e\n",
129 n1, error1, n2, error2 );
136 if( NeTrack.
init_bracket( n1, error1, n2, error2 ) == 0 )
142 NeTrack.
set_tol(2.*DBL_EPSILON*n2);
144 double NeNew = 0.5*(n1+n2);
145 for(
int i = 0; i < (1<<(n/2))*DEF_ITER; i++ )
162 if( abs(nBound) >= 3 )
166 fprintf(
ioQQQ,
" ConvEdenIoniz: hysteresis detected\n" );
188 double n1=0., error1=0., n2=0., error2=0.;
189 const int MAX_ITER = 20;
190 for(
int n=0; n < MAX_ITER; ++n )
198 else if ( n == 1 || (n1-n2)*(error1-error2) <= 0.0 )
209 double nt = (n1*error2 - n2*error1)/(error2-error1);
210 if (fabs(nt-n2) > 2*fabs(n2-n1))
222 fprintf(
ioQQQ,
"LONG Nzone %ld Loop %d density %15.8g true %15.8g error %15.8g\n",
238 fprintf(
ioQQQ,
" ConvEdenIoniz: entry eden %.4e -> %.4e rel chng %.2f%% accuracy %.2f%%\n",
241 fprintf(
ioQQQ,
" ConvEdenIoniz returns converged=%c reason %s\n",
286 for(
int i=0; i < 5; ++i )
298 fprintf(
ioQQQ,
" EdenError: eden %.4e EdenTrue %.4e rel. err. %.4e\n",
void RT_OTS_Update(double *SumOTS)
double bracket_width() const
void add(double x, double fx)
void print_history() const
ConvergenceCounter register_(const string name)
void CoolEvaluate(double *tot)
STATIC double EdenError(double eden)
void RT_line_all_escape(realnum *error)
bool fp_equal(sys_float x, sys_float y, int n=3)
const char * chConvIoniz() const
int init_bracket(double x1, double fx1, double x2, double fx2)
sys_float safe_div(sys_float x, sys_float y, sys_float res_0by0)
#define DEBUG_ENTRY(funcname)
int fprintf(const Output &stream, const char *format,...)
double deriv(int n, double &sigma) const
void setConvIonizFail(const char *reason, double oldval, double newval)
int in_bounds(double x) const
void EdenChange(double EdenNew)
const bool lgConvBaseHeatTest