/home66/gary/public_html/cloudy/c08_branch/source/conv_ioniz.cpp

Go to the documentation of this file.
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
00002  * others.  For conditions of distribution and use see copyright notice in license.txt */
00003 /*ConvIoniz called by ConvEdenIonz, it calls ConvBase until converged */
00004 #include "cddefines.h"
00005 #include "thermal.h"
00006 #include "trace.h"
00007 #include "conv.h"
00008 
00009 /*ConvIoniz called by ConvEdenIonz, it calls ConvBase until converged 
00010  * returns 1 if error condition, 0 if ok */
00011 int ConvIoniz(void)
00012 {
00013         long int 
00014                 /* the ionization loop counter */
00015                 loopi ,
00016                 /* the limit to how many times we will try calling ConvBase before giving up */
00017                 LoopLimit;
00018 
00019         DEBUG_ENTRY( "ConvIoniz()" );
00020 
00021         /* this routine is called by ConvTempIonz, it calls ConvBase
00022          * until it converges */
00023 
00024         if( conv.lgSearch )
00025         {
00026                 /* expand limit to number of calls to ConvBase during search phase */
00027                 LoopLimit = 30;
00028         }
00029         else
00030         {
00031                 LoopLimit = 20;
00032         }
00033 
00034         /* zero the ionization loop counter */
00035         loopi = 0;
00036 
00037         /* do not go into the loop with first call to ionization,
00038          * since results will be bogus - do it here */
00039         if( !conv.lgSearch && conv.nPres2Ioniz == 0 )
00040         {
00041                 if( ConvBase(loopi) )
00042                 {
00043                         return 1;
00044                 }
00045         }
00046 
00047         strcpy( conv.chConvIoniz, " NONE!!!!!" );
00048         /* this is ionization/electron density convergence loop
00049          * keep calling ConvBase until lgIonDone is true */
00050         do 
00051         {
00052                 /* compute the current ionization, ots rates, secondary ionization rates */
00053                 if( ConvBase(loopi) )
00054                 {
00055 
00056                         return 1;
00057                 }
00058 
00059                 if( trace.nTrConvg>=4 )
00060                 {
00061                         /* cooling has not been evaluated yet */
00062                         fprintf( ioQQQ, 
00063                                 "    ConvIoniz4%4ld heat:%10.2e cool:%10.2e ", 
00064                           loopi, thermal.htot , thermal.ctot );
00065 
00066                         /* this is flag saying whether or not ionization/eden has converged */
00067                         if( conv.lgConvIoniz )
00068                         {
00069                                 fprintf( ioQQQ, " ioniz converged\n" );
00070                         }
00071                         else
00072                         {
00073                                 fprintf( ioQQQ, " ioniz no conv:%10.10s old %.4e new %.4e OscilOTS %c\n", 
00074                                   conv.chConvIoniz , 
00075                                   conv.BadConvIoniz[0] ,
00076                                   conv.BadConvIoniz[1] ,
00077                                   TorF(conv.lgOscilOTS) );
00078                         }
00079                 }
00080 
00081                 /* increment ionization loop, and keep going until we converge */
00082                 ++loopi;
00083         }       while( !conv.lgConvIoniz && loopi < LoopLimit && !lgAbort );
00084 
00085         if( !conv.lgConvIoniz )
00086         {
00087                 /* this is a major problem, ConvIoniz did not converge the ionization */
00088                 ++conv.nConvIonizFails;
00089                 /* this is flag saying that an ionization convergence problem occurred in this
00090                  * zone, will be used to help choose next dr
00091                  >>chng 06 dec 17, never used so removed 
00092                 ++conv.lgConvIonizThisZone; */
00093         }
00094 
00095         /* if trace convergence is in operation and we did not converge, give warning */
00096         if( trace.nTrConvg>=4 && !conv.lgConvIoniz )
00097         {
00098                 fprintf( ioQQQ, 
00099                         "    ConvIoniz4>>>>>>>>>>exit without converging after %li tries!!!!\n",loopi);
00100         }
00101 #       if 0
00102         {
00103 #include "grainvar.h"
00104 #include "dense.h"
00105 #include "mole.h"
00106         fprintf(ioQQQ,"DEBUG co mol eden\t%.2f\t%e\t%e\t%e\t%e\n",
00107                 fnzone,
00108                 dense.eden,
00109                 gv.TotalEden,
00110                 co.comole_eden ,
00111                 dense.EdenTrue);
00112         }
00113 #       endif
00114 
00115         return 0;
00116 }

Generated on Mon Feb 16 12:01:13 2009 for cloudy by  doxygen 1.4.7