00001
00002
00003
00004 #include "cddefines.h"
00005 #include "thermal.h"
00006 #include "dynamics.h"
00007 #include "radius.h"
00008 #include "conv.h"
00009 #include "phycon.h"
00010 #include "save.h"
00011
00012
00013 static const int IPRINT = 100;
00014
00015
00016 void CoolSave(FILE * io)
00017 {
00018 long int i,
00019 ip,
00020 is;
00021
00022 int nFail;
00023
00024 double cset,
00025 cool_total,
00026 heat_total;
00027
00028 realnum
00029 *csav,
00030 *sgnsav;
00031 long int *index;
00032
00033 DEBUG_ENTRY( "CoolSave()" );
00034
00035
00036 index = (long int *)CALLOC((size_t)thermal.ncltot,sizeof(long int));
00037 csav = (realnum *)CALLOC((size_t)thermal.ncltot,sizeof(realnum));
00038 sgnsav = (realnum *)CALLOC((size_t)thermal.ncltot,sizeof(realnum));
00039
00040 cool_total = thermal.ctot;
00041 heat_total = thermal.htot;
00042
00043
00044
00045
00046
00047
00048 cool_total -= dynamics.Cool();
00049 heat_total -= dynamics.Heat();
00050 # if 0
00051 if(dynamics.Cool > dynamics.Heat())
00052 {
00053 cool_total -= dynamics.Heat();
00054 heat_total -= dynamics.Heat();
00055 }
00056 else
00057 {
00058 cool_total -= dynamics.Cool;
00059 heat_total -= dynamics.Cool;
00060 }
00061 # endif
00062
00063
00064
00065
00066 cset = cool_total*save.WeakHeatCool;
00067
00068
00069 ip = thermal.ncltot;
00070
00071 for( i=0; i < ip; i++ )
00072 {
00073 csav[i] = (realnum)(MAX2(thermal.cooling[i],thermal.heatnt[i])/
00074 SDIV(cool_total));
00075
00076
00077 if( thermal.heatnt[i] == 0. )
00078 {
00079 sgnsav[i] = 1.;
00080 }
00081 else
00082 {
00083 sgnsav[i] = -1.;
00084 }
00085 }
00086
00087
00088
00089
00090 spsort(
00091
00092 csav,
00093
00094 ip,
00095
00096 index,
00097
00098
00099 -1,
00100
00101 &nFail);
00102
00103
00104 if( !conv.lgConvTemp )
00105 {
00106 fprintf( io, "#>>>> Temperature not converged.\n" );
00107 }
00108 else if( !conv.lgConvEden )
00109 {
00110 fprintf( io, "#>>>> Electron density not converged.\n" );
00111 }
00112 else if( !conv.lgConvIoniz )
00113 {
00114 fprintf( io, "#>>>> Ionization not converged.\n" );
00115 }
00116 else if( !conv.lgConvPres )
00117 {
00118 fprintf( io, "#>>>> Pressure not converged.\n" );
00119 }
00120
00121
00122
00123
00124 fprintf( io, "%.5e\t%.4e\t%.4e\t%.4e",
00125 radius.depth_mid_zone,
00126 phycon.te,
00127 heat_total,
00128 cool_total );
00129
00130
00131 ip = MIN2( ip , IPRINT );
00132
00133
00134
00135
00136 for( is=0; is < ip; is++ )
00137 {
00138 if(is > 4 && (thermal.cooling[index[is]] < cset && thermal.heatnt[index[is]] < cset))
00139 break;
00140 fprintf( io, "\t%s %.1f\t%.7f",
00141 thermal.chClntLab[index[is]],
00142 thermal.collam[index[is]],
00143 sign(csav[index[is]],sgnsav[index[is]]) );
00144 }
00145 fprintf( io, " \n" );
00146
00147
00148 free(sgnsav);
00149 free(csav);
00150 free(index);
00151 return;
00152 }