36 static double HeatOld=-1. , CoolOld=-1.;
47 double HeatRelChange = fabs(HeatChange)/
SDIV( HeatCoolMax );
48 double CoolRelChange = fabs(CoolChange)/
SDIV( HeatCoolMax );
49 bool lgConverged =
true;
67 bool lgConvergeCoolHeat =
false;
71 while( loop < LOOP_MAX && !lgConvergeCoolHeat && !
lgAbort )
80 fprintf(
ioQQQ,
" lgCoolNetConverge %li calls to ConvEdenIoniz, converged? %c\n",
81 loop ,
TorF( lgConvergeCoolHeat ) );
115 fprintf(
ioQQQ,
"PROBLEM CoolNet derivative oscillating in initial solution \n");
118 return lgConvergeCoolHeat;
157 enum {DEBUG_LOC=
false};
160 fprintf(
ioQQQ,
"DEBUG fraction molecular %.2e species %li O ices %.2e\n" ,
170 double TeChangeFactor;
194 TeChangeFactor = 0.999;
198 TeChangeFactor = 0.99;
205 TeChangeFactor = 0.97;
212 TeChangeFactor = 0.95;
217 TeChangeFactor = 0.8;
219 return TeChangeFactor;
232 bool lgConvergeCoolHeat;
281 fprintf(
ioQQQ,
"\nConvInitSolution entered \n" );
294 fprintf(
ioQQQ,
" ConvInitSolution called, ITER=%2ld resetting Te to %10.2e\n",
300 fprintf(
ioQQQ,
" search set true\n" );
327 fprintf(
ioQQQ,
" ========================================================================================================================\n");
328 fprintf(
ioQQQ,
" ConvInitSolution: search set false 2 Te=%.3e========================================================================================\n" ,
phycon.
te);
329 fprintf(
ioQQQ,
" ========================================================================================================================\n");
359 fprintf(
ioQQQ,
" ConvInitSolution called, new temperature.\n" );
398 fprintf(
ioQQQ,
"ConvInitSolution doing initial solution with temp=%.2e\n",
410 double CoolNet=0, dCoolNetDT=0;
412 lgConvergeCoolHeat =
false;
413 for( ionlup=0; ionlup<2; ++ionlup )
416 fprintf(
ioQQQ,
"ConvInitSolution calling lgCoolNetConverge "
417 "initial setup %li with Te=%.3e C=%.2e H=%.2e d(C-H)/dT %.3e\n",
430 if( !lgConvergeCoolHeat )
431 fprintf(
ioQQQ,
" PROBLEM ConvInitSolution did not converge the heating-cooling during initial search.\n");
436 fprintf(
ioQQQ,
" DISASTER PROBLEM ConvInitSolution: Search for "
437 "initial conditions aborted - lgAbort set true.\n" );
447 bool lgConvergedLoop =
false;
448 long int LoopThermal = 0;
452 const long int LIMIT_THERMAL_LOOP=300;
453 double CoolMHeatSave=-1. , TempSave=-1. , TeNew=-1.,CoolSave=-1;
454 while( !lgConvergedLoop && LoopThermal < LIMIT_THERMAL_LOOP )
457 CoolMHeatSave = CoolNet;
464 ASSERT( TeChangeFactor>0. && TeChangeFactor< 1. );
466 TeNew =
phycon.
te - CoolNet / dCoolNetDT;
475 fprintf(
ioQQQ,
"ConvInitSolution %4li TeNnew=%.3e "
476 "TeChangeFactor=%.3e Cnet/H=%.2e dCnet/dT=%10.2e Ne=%.3e"
477 " Ograins %.2e FracMoleMax %.2e\n",
478 LoopThermal , TeNew , TeChangeFactor ,
484 fprintf(
ioQQQ,
" Search for initial conditions aborted - "
485 "lgAbort set true, lgConvergeCoolHeat=%c.\n",
486 TorF(lgConvergeCoolHeat) );
497 lgConvergedLoop =
true;
498 else if( (CoolNet/fabs(CoolNet))*(CoolMHeatSave/fabs(CoolMHeatSave)) <= 0)
500 lgConvergedLoop =
true;
502 lgConvergedLoop =
true;
504 lgConvergedLoop =
true;
508 if( !lgConvergedLoop )
509 fprintf(
ioQQQ,
"PROBLEM ConvInitSolution: temperature solution not "
510 "found in initial search, final Te=%.2e\n",
520 fprintf(
ioQQQ,
" Change in sign of C-H found, Te brackets %.3e "
521 "%.3e Cool brackets %.3e %.3e ",
522 TempSave ,
phycon.
te , CoolMHeatSave , CoolNet);
536 double TeLn = (log(
thermal.
htot ) - Alog) / alpha ;
544 TeNew = pow(
EE , TeLn );
551 fprintf(
ioQQQ,
" interpolating to Te %.3e \n\n",
570 fprintf(
ioQQQ,
"\nConvInitSolution: end 1st iteration search phase "
577 fprintf(
ioQQQ,
" ConvInitSolution return, TE:%10.2e==================\n",
605 " PresTotCurrent 1st zn old values of PresTotlInit:%.3e"
671 for( nelem=2; nelem <
LIMELM; nelem++ )
674 for( i=0; i < nelem; i++ )
681 nelem_reflux = nelem;
712 fprintf(
ioQQQ,
" nflux updated from %li to %li, anu from %g to %g \n",
715 fprintf(
ioQQQ,
" caused by element %li ion %li \n",
716 nelem_reflux ,ion_reflux );