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 realnum 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 return;
00047 }
00048
00049
00050 void CoolZero(void)
00051 {
00052
00053 DEBUG_ENTRY( "CoolZero()" );
00054
00055 thermal.ncltot = 0;
00056 thermal.dCooldT = 0.;
00057 thermal.dHeatdT = 0.;
00058
00059
00060 memset(thermal.cooling , 0 , NCOLNT*sizeof(thermal.cooling[0] ) );
00061 memset(thermal.heatnt , 0 , NCOLNT*sizeof(thermal.heatnt[0] ) );
00062
00063
00064 for( int i = 0; i <= LIMELM ; i++ )
00065 thermal.elementcool[i] = 0.;
00066 thermal.dima = 0.;
00067
00068
00069
00070
00071 thermal.lgCoolEvalOK = true;
00072 return;
00073 }
00074
00075
00076 void CoolSum(double *total)
00077 {
00078 long int i;
00079
00080 DEBUG_ENTRY( "CoolSum()" );
00081
00082
00083
00084 *total = 0.;
00085 thermal.coolheat = 0.;
00086
00087
00088 for( i=0; i < thermal.ncltot; i++ )
00089 {
00090 *total += thermal.cooling[i];
00091 thermal.coolheat += thermal.heatnt[i];
00092 }
00093 thermal.heating[0][12] = thermal.coolheat;
00094
00095
00096 if( thermal.htot > 0. )
00097 {
00098 if( thermal.coolheat/thermal.htot > 0.01 )
00099 {
00100
00101 for( i=0; i < thermal.ncltot; i++ )
00102 {
00103 if( thermal.heatnt[i]/thermal.htot > thermal.CoolHeatMax )
00104 {
00105 thermal.CoolHeatMax = (realnum)(thermal.heatnt[i]/thermal.htot);
00106 thermal.wlCoolHeatMax = thermal.collam[i];
00107 strcpy( thermal.chCoolHeatMax, thermal.chClntLab[i] );
00108 }
00109 }
00110 }
00111 }
00112
00113
00114
00115
00116
00117
00118
00119 thermal.heatl = 0.;
00120 for( i=0; i < nWindLine; i++ )
00121 {
00122 if( (*TauLine2[i].Hi()).IonStg() < (*TauLine2[i].Hi()).nelem()+1-NISO )
00123 thermal.heatl += TauLine2[i].Coll().heat();
00124 }
00125
00126 for( i=1; i <= nLevel1; i++ )
00127 {
00128 thermal.heatl += TauLines[i].Coll().heat();
00129 }
00130
00131
00132 for( long ipSpecies=0; ipSpecies<nSpecies; ipSpecies++ )
00133 {
00134 if( dBaseSpecies[ipSpecies].lgActive )
00135 {
00136 for (TransitionList::iterator tr=dBaseTrans[ipSpecies].begin();
00137 tr != dBaseTrans[ipSpecies].end(); ++tr)
00138 {
00139 int ipHi = (*tr).ipHi();
00140 if (ipHi >= dBaseSpecies[ipSpecies].numLevels_local || (*tr).ipCont() <= 0)
00141 continue;
00142 thermal.heatl += (*tr).Coll().heat();
00143 }
00144 }
00145 }
00146
00147
00148
00149 thermal.heating[0][22] = thermal.heatl;
00150 {
00151 enum {DEBUG_LOC=false};
00152 if( DEBUG_LOC && thermal.heatl/thermal.ctot > 0.1 )
00153 {
00154 double thresh = 0.1;
00155 fprintf(ioQQQ," all heating lines > %.4f of heatl printed next \n",
00156 thresh );
00157 for( i=0; i < nWindLine; i++ )
00158 {
00159 if( (*TauLine2[i].Hi()).IonStg() < (*TauLine2[i].Hi()).nelem()+1-NISO )
00160 {
00161 if( TauLine2[i].Coll().heat()/thermal.heatl > thresh )
00162 DumpLine( TauLine2[i] );
00163 }
00164 }
00165
00166 for( i=1; i <= nLevel1; i++ )
00167 {
00168 if( TauLines[i].Coll().heat()/thermal.heatl > thresh )
00169 DumpLine( TauLines[i] );
00170 }
00171
00172
00173 for (int ipSpecies=0; ipSpecies < nSpecies; ++ipSpecies)
00174 {
00175 for( EmissionList::iterator em=dBaseTrans[ipSpecies].Emis().begin();
00176 em != dBaseTrans[ipSpecies].Emis().end(); ++em)
00177 {
00178 if( (*em).Tran().Coll().heat()/thermal.heatl > thresh )
00179 DumpLine( (*em).Tran() );
00180 }
00181 }
00182 }
00183 }
00184
00185
00186 if( *total <= 0. )
00187 {
00188 fprintf( ioQQQ, " CoolSum finds cooling <= 0%10.2e\n",
00189 *total );
00190 }
00191 if( thermal.heatl/thermal.ctot < -1e-15 )
00192 {
00193 fprintf( ioQQQ, " CoolSum finds negative heating %10.2e %10.2e\n",
00194 thermal.heatl, thermal.ctot );
00195 }
00196
00197
00198 thermal.lgCoolEvalOK = false;
00199 return;
00200 }