/*ConvIoniz called by ConvEdenIonz, it calls ionize until converged */ #include #include "cddefines.h" #include "tcool.h" #include "heat.h" #include "trace.h" #include "converge.h" void ConvIoniz(void) { long int /* the oinization loop counter */ loopi , /* the limit to how many times we will try calling ionize before giving up */ LoopLimit; # ifdef DEBUG_FUN fputs( "<+>ConvIoniz()\n", debug_fp ); # endif /* this routine is called by ConvTempIonz, it calls ionize * until it converges */ if( conv.lgSearch ) { /* expand limit to number of calls to ionize during search phase */ LoopLimit = 30; } else { LoopLimit = 20; } /* zero the ionization loop counter */ loopi = 0; /* do not go into the loop with first call to ioniz, * since results will be bogus - do it here */ if( !conv.lgSearch && conv.nPres2Ioniz == 0 ) { ionize(loopi); } strcpy( conv.chConvIoniz, " NONE!!!!!" ); /* this is ionization/electron density convergence loop * keep calling ionize until lgIonDone is true */ do { /* set the convergece flag to TRUE, * if anything changes in ionize, it will be set false */ conv.lgConvIoniz = TRUE; /* compute the current ionization, ots rates, secondary ionization rates */ ionize(loopi); if( trace.lgTrConvg>3 ) { /* cooling has not been evaluated yet */ fprintf( ioQQQ, " ConvIoniz%4ld heat:%10.2e cool:%10.2e ", loopi, heat.htot , tcool.ctot ); /* this is flag saying whether or not ionization/eden has converged */ if( conv.lgConvIoniz ) { fprintf( ioQQQ, " ioniz converged\n" ); } else { fprintf( ioQQQ, " ioniz no conv:%10.10s old %10.2e new %10.2e OscilOTS %c\n", conv.chConvIoniz , conv.BadConvIoniz[0],conv.BadConvIoniz[1] , TorF(conv.lgOscilOTS) ); } } /* increment ionization loop, and keep going until we converge */ ++loopi; } while( !conv.lgConvIoniz && loopi < LoopLimit ); /* if trace convergence is in operation and we did not converge, give warning */ if( trace.lgTrConvg && !conv.lgConvIoniz ) { fprintf( ioQQQ, " ConvIoniz>>>>>>>>>>exit without converging!!!!\n"); } # ifdef DEBUG_FUN fputs( " <->ConvIoniz()\n", debug_fp ); # endif return; }