00001
00002
00003
00004
00005
00006 #include "cddefines.h"
00007 #include "taulines.h"
00008 #include "lines_service.h"
00009 #include "thermal.h"
00010 #include "cooling.h"
00011
00012
00013 void CoolAdd(
00014 const char *chLabel,
00015 float lambda,
00016 double cool)
00017 {
00018
00019 DEBUG_ENTRY( "CoolAdd()" );
00020
00021
00022
00023
00024 ASSERT( thermal.lgCoolEvalOK );
00025
00026
00027
00028 ASSERT( thermal.ncltot < NCOLNT );
00029
00030
00031 ASSERT( strlen( thermal.chClntLab[thermal.ncltot]) < NCOLNT_LAB_LEN );
00032 strcpy( thermal.chClntLab[thermal.ncltot], chLabel);
00033
00034
00035 thermal.collam[thermal.ncltot] = lambda;
00036
00037
00038 thermal.cooling[thermal.ncltot] = MAX2(0.,cool);
00039
00040
00041
00042 thermal.heatnt[thermal.ncltot] = MAX2(0.,-cool);
00043
00044
00045 thermal.ncltot += 1;
00046
00047 DEBUG_EXIT( "CoolAdd()" );
00048 return;
00049 }
00050
00051
00052 void CoolZero(void)
00053 {
00054
00055 DEBUG_ENTRY( "CoolZero()" );
00056
00057 thermal.ncltot = 0;
00058 thermal.dCooldT = 0.;
00059
00060
00061 memset(thermal.cooling , 0 , NCOLNT*sizeof(thermal.cooling[0] ) );
00062 memset(thermal.heatnt , 0 , NCOLNT*sizeof(thermal.heatnt[0] ) );
00063 # if 0
00064 for( i=0; i < NCOLNT; i++ )
00065 {
00066 thermal.cooling[i] = 0.;
00067 thermal.heatnt[i] = 0.;
00068 }
00069 # endif
00070
00071
00072
00073
00074 thermal.lgCoolEvalOK = true;
00075
00076 DEBUG_EXIT( "CoolZero()" );
00077 return;
00078 }
00079
00080
00081 void CoolSum(double *total)
00082 {
00083 long int i;
00084
00085 DEBUG_ENTRY( "CoolSum()" );
00086
00087
00088
00089 *total = 0.;
00090 thermal.coolheat = 0.;
00091
00092
00093 for( i=0; i < thermal.ncltot; i++ )
00094 {
00095 *total += thermal.cooling[i];
00096 thermal.coolheat += thermal.heatnt[i];
00097 }
00098 thermal.heating[0][12] = thermal.coolheat;
00099
00100
00101 if( thermal.htot > 0. )
00102 {
00103 if( thermal.coolheat/thermal.htot > 0.01 )
00104 {
00105
00106 for( i=0; i < thermal.ncltot; i++ )
00107 {
00108 if( thermal.heatnt[i]/thermal.htot > thermal.CoolHeatMax )
00109 {
00110 thermal.CoolHeatMax = (float)(thermal.heatnt[i]/thermal.htot);
00111 thermal.wlCoolHeatMax = thermal.collam[i];
00112 strcpy( thermal.chCoolHeatMax, thermal.chClntLab[i] );
00113 }
00114 }
00115 }
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 thermal.heatl = 0.;
00125 for( i=0; i < nWindLine; i++ )
00126 {
00127 if( TauLine2[i].IonStg < TauLine2[i].nelem+1-NISO )
00128 thermal.heatl += TauLine2[i].heat;
00129 }
00130
00131 for( i=1; i <= nLevel1; i++ )
00132 {
00133 thermal.heatl += TauLines[i].heat;
00134 }
00135 # if 0
00136
00137
00138 for( i=0; i < nCORotate; i++ )
00139 {
00140 thermal.heatl += C12O16Rotate[i].heat;
00141 thermal.heatl += C13O16Rotate[i].heat;
00142 }
00143 # endif
00144
00145
00146 thermal.heating[0][22] = thermal.heatl;
00147 {
00148
00149 enum {DEBUG_LOC=false};
00150
00151 if( DEBUG_LOC && thermal.heatl/thermal.ctot > 0.1 )
00152 {
00153 double thresh = 0.1;
00154 fprintf(ioQQQ," all heating lines > %.4f of heatl printed next \n",
00155 thresh );
00156 for( i=0; i < nWindLine; i++ )
00157 {
00158 if( TauLine2[i].IonStg < TauLine2[i].nelem+1-NISO )
00159 {
00160 if( TauLine2[i].heat/thermal.heatl > thresh )
00161 DumpLine( &TauLine2[i] );
00162 }
00163 }
00164
00165 for( i=1; i <= nLevel1; i++ )
00166 {
00167 if( TauLines[i].heat/thermal.heatl > thresh )
00168 DumpLine( &TauLines[i] );
00169 }
00170 }
00171 }
00172
00173
00174 if( *total <= 0. )
00175 {
00176 fprintf( ioQQQ, " CoolSum finds cooling <= 0%10.2e\n",
00177 *total );
00178 }
00179 if( thermal.heatl/thermal.ctot < -1e-15 )
00180 {
00181 fprintf( ioQQQ, " CoolSum finds negative heating %10.2e %10.2e\n",
00182 thermal.heatl, thermal.ctot );
00183
00184
00185 }
00186
00187
00188 thermal.lgCoolEvalOK = false;
00189
00190 DEBUG_EXIT( "CoolSum()" );
00191 return;
00192 }
00193