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