/* * this is the series of routines that converge the pressure, temperature, * electron density, and ionization, for a zone. Ideally, only the top * routine, ConvPresTempEdenIoniz, should be public */ /*ConvInitTemp drive search for initial temperature, for illuminated face, * called by cloudy, returns 1 if outside conditions appropriate for cloudy */ int ConvInitTemp(void); /*ConvPresTempEdenIoniz drive pressure, ionization, and thermal balance routines to converge * conditions in current zone. called by cloudy, calls ConvTempTempIoniz and PresChng */ void ConvPresTempEdenIoniz(void); /*PresChng evaluate the current pressure, and change needed to get it to PressureInit*/ void PresChng(void); /*ConvTempEdenIoniz converge ionization and temperature, called by ConvPresTempTempIoniz, * calls ConvTempIoniz */ void ConvTempEdenIoniz( void ); /*ConvEdenIoniz called by ConvTempEdenIoniz and ConvInitIonize, * it calls ConvIoniz and converges the electron density */ void ConvEdenIoniz(void); /*ConvIoniz called by ConvEdenIoniz, it calls ionize until ionization is converged */ void ConvIoniz(void); /*ionize main routine to drive ionization solution for all species */ void ionize( /* this tells how many times ionize has been called by ConvIoniz while * trying to converge electron density == 0 on first call - allows * logic in ionize to check for ots oscillations */ long loopi); /*ConvFail handle convergece failures, * pressure, temperature, electron density, ionization */ void ConvFail(char chMode[5] ); /* * the variables that deal with the convergence of the model */ EXTERN struct t_conv { /* has the electron density converged?? */ int lgConvEden; /* this says why the electron density did not converge, */ char chConvEden[11]; /* this flag is used in ConvIoniz to check that ionization has converged */ int lgConvIoniz; /* this says why the ionization did not converge, reasons can be a large * change in the level of ionization, or in the heating */ char chConvIoniz[11]; /* when the lgConvIoniz flag is set false, the old and new numbers, * the reason for the lack of convergence, should be set to following */ double BadConvIoniz[2]; /* this will count the number of ionizations in one call from ConPvPresTempIoniz*/ long int nPres2Ioniz; /* this will count the number of ionizations in all calls after zero*/ long int nTotalIoniz; /* lgSearch is true is initial temp-ion search underway, * false after first zone established */ int lgSearch; /* remember the biggest electron density error as test of convergence quality */ float BigEdenError; /* remember the average electron density error */ float AverEdenError; /* remember the biggest and average heating-cooling error */ float BigHeatCoolError; float AverHeatCoolError; /* remember the biggest and average pressure error */ float BigPressError; float AverPressError; /* flag set in ionize, saying whether ionization stage is trimmed down */ int lgIonStageTrimed; /* this says whether cooling-heating deriv is changing sign */ int lgCmHOsc; /* this says whether temp is changing sign */ int lgTOscl; /* this says whether electron density is changing sign */ int lgEdenOscl; /* this is true if ots rates are oscillating, and this is why ionization * is not converged */ int lgOscilOTS ; /* true if temperature is converged, false if not */ int lgConvTemp; /* true if pressure is converged, false if not */ int lgConvPres; /* *info related to the number of temperature or pressure failures */ /*nTeFail number of temperature failures*/ long int nTeFail; /*failmx is largest relative error in heating cooling match*/ float failmx; /*nPreFail is number of pressure failuers*/ long int nPreFail; /*nNeFail is number of electron density failuers*/ long int nNeFail; /*nIonFail is number of ionization failuers*/ long int nIonFail; /* number of grain ionization balance failures */ long int nGrainFail; } conv;