Changeset 1179
- Timestamp:
- 06/09/07 13:18:05 (18 months ago)
- Location:
- trunk/source
- Files:
-
- 16 modified
-
abundances.cpp (modified) (1 diff)
-
cddefines.h (modified) (1 diff)
-
conv_init_solution.cpp (modified) (4 diffs)
-
conv_temp_eden_ioniz.cpp (modified) (2 diffs)
-
date.h (modified) (1 diff)
-
init_defaults_preparse.cpp (modified) (2 diffs)
-
map.cpp (modified) (3 diffs)
-
mole_h2.cpp (modified) (1 diff)
-
optimize_func.cpp (modified) (1 diff)
-
parse_commands.cpp (modified) (1 diff)
-
parse_constant.cpp (modified) (2 diffs)
-
parse_coronal.cpp (modified) (2 diffs)
-
parse_stop.cpp (modified) (1 diff)
-
phycon.h (modified) (1 diff)
-
prt_comment.cpp (modified) (1 diff)
-
stopcalc.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/abundances.cpp
r1147 r1179 223 223 /* if stop temp set below default then we are going into cold and possibly molecular 224 224 * gas - check some parameters in this case */ 225 if( called.lgTalk && (StopCalc.tend < TE ND||225 if( called.lgTalk && (StopCalc.tend < TEMP_STOP_DEFAULT || 226 226 /* thermal.ConstTemp def is zero, set pos when used */ 227 (thermal.ConstTemp > 0. && thermal.ConstTemp < TE ND) ) )227 (thermal.ConstTemp > 0. && thermal.ConstTemp < TEMP_STOP_DEFAULT ) ) ) 228 228 { 229 229 -
trunk/source/cddefines.h
r1148 r1179 175 175 const int NHYDRO_MAX_LEVEL = 401; 176 176 177 /** dimension of vector to do with number of iterations stored178 * so, this is the the most that can possibly be performed */179 /*const int ITR DIM = 200;*/180 181 177 /** number of hydrogen species in hmole */ 182 178 const int N_H_MOLEC = 8; 183 179 184 /** stopping temperature */ 185 const double TEND = 4000.; 180 /** The default value of the stopping temperature */ 181 const double TEMP_STOP_DEFAULT = 4000.; 182 /** highest temperature to ever allow */ 183 const double TEMP_LIMIT_HIGH = 1e10; 184 /** lowest temperature to ever allow */ 185 const double TEMP_LIMIT_LOW = 2.8; 186 186 187 187 /** this is used to add to depth to prevent div or log of zero */ -
trunk/source/conv_init_solution.cpp
r1178 r1179 4 4 #include "cddefines.h" 5 5 #include "trace.h" 6 #include "stopcalc.h"7 6 #include "struc.h" 8 7 #include "rfield.h" … … 328 327 phycon.te, thermal.htot, thermal.ctot, Cool_min_Heat ); 329 328 } 330 /* check range 10-4000K, T eLowest usually 2.8K, set with SET LOWEST command329 /* check range 10-4000K, TEMP_LIMIT_LOW is lowest possible temperature 331 330 * following are series of tests that determine the factor by which 332 331 * which can change the temperature. must be VERY small when 333 332 * ice formation on grains is important due to exponential sublimation 334 333 * rate. Also small when molecules are important, to keep chemistry 335 * within limits of lineariz ationsolver */334 * within limits of linearized solver */ 336 335 fac2 = 0.8; 337 while( phycon.te*fac2 > StopCalc.TeLowest&& Cool_min_Heat >= 0. && !lgAbort )336 while( phycon.te*fac2 > TEMP_LIMIT_LOW && Cool_min_Heat >= 0. && !lgAbort ) 338 337 { 339 338 double oxy_in_grains; … … 474 473 ShowMe(); 475 474 475 /* this is an error return, calculation will immediately stop */ 476 476 DEBUG_EXIT( "ConvInitSolution()" ); 477 return(1); 478 } 479 else if( thermal.ctot > thermal.htot ) 480 { 481 /* even at lowest temp, too much cooling; no solution possible */ 482 fprintf( ioQQQ, 483 "PROBLEM The initial kinetic temperature was below %.1e K," 484 " the lowest possible temperature I can consider." 485 "\nSorry, but I cannot go on.\n\n", 486 TEMP_LIMIT_LOW ); 487 477 488 /* this is an error return, calculation will immediately stop */ 478 return(1);479 }480 else if( thermal.ctot > thermal.htot )481 {482 /* even at lowest temp, too much cooling; no solution possible */483 fprintf( ioQQQ, " Equilibrium temperature below T=%8.2e. If this is OK, then reset with LOWEST command. This is ConvInitSolution. TeLowest was%9.2e\n",484 phycon.te, StopCalc.TeLowest );485 486 489 DEBUG_EXIT( "ConvInitSolution()" ); 487 /* this is an error return, calculation will immediately stop */488 490 return(1); 489 491 } … … 505 507 506 508 /* coming up to here te is either 4,000 (usually) or 10^6 */ 507 t1 = StopCalc.TeLowest/1.001;509 t1 = TEMP_LIMIT_LOW/1.001; 508 510 509 511 /* >>chng 96 dec 28, added div by factor to prevent checking on temp > 1e10 */ 510 t2 = StopCalc.TeHighest*1.001/factor;512 t2 = TEMP_LIMIT_HIGH*1.001/factor; 511 513 if( trace.nTrConvg ) 512 514 { -
trunk/source/conv_temp_eden_ioniz.cpp
r761 r1179 14 14 #include "colden.h" 15 15 #include "h2.h" 16 #include "stopcalc.h"17 16 #include "pressure.h" 18 17 #include "dense.h" … … 943 942 { 944 943 bool lgRet; 945 /* >>chng 03 sep 19, add check on StopCalc.TeLowest*/944 /* >>chng 03 sep 19, add check on TEMP_LIMIT_LOW */ 946 945 if( fabs(thermal.htot - thermal.ctot)/thermal.htot <= conv.HeatCoolRelErrorAllowed || 947 thermal.lgTSetOn || phycon.te <= StopCalc.TeLowest)946 thermal.lgTSetOn || phycon.te <= TEMP_LIMIT_LOW ) 948 947 { 949 948 /* announce that temp is converged if relative heating - cooling mismatch -
trunk/source/date.h
r1175 r1179 9 9 #define YEAR 107 10 10 #define MONTH 5 11 #define DAY 711 #define DAY 9 -
trunk/source/init_defaults_preparse.cpp
r1178 r1179 143 143 StopCalc.AV_point = 1e30f; 144 144 /* highest allowed temperature */ 145 StopCalc.T2High = 1e12f; 146 147 /* highest and lowest temperatures to ever allow */ 148 StopCalc.TeHighest = 1e10f; 149 StopCalc.TeLowest = 2.8f; 145 StopCalc.T2High = (float)TEMP_LIMIT_HIGH; 150 146 151 147 /* the floor sets a limit to the temperature in the calculation - … … 155 151 156 152 /* this is in cddefines.h and is 4000 */ 157 StopCalc.tend = (float)TE ND;153 StopCalc.tend = (float)TEMP_STOP_DEFAULT; 158 154 /* ending column densities */ 159 155 StopCalc.HColStop = COLUMN_INIT; -
trunk/source/map.cpp
r759 r1179 6 6 #include "thermal.h" 7 7 #include "cooling.h" 8 #include "stopcalc.h"9 8 #include "called.h" 10 9 #include "dense.h" … … 125 124 { 126 125 /* create some sort of map of heating-cooling */ 127 tlowst = MAX2(map.RangeMap[0], StopCalc.TeLowest);126 tlowst = MAX2(map.RangeMap[0],TEMP_LIMIT_LOW); 128 127 tmin = tlowst*0.998; 129 tmax = MIN2(map.RangeMap[1], StopCalc.TeHighest)*1.002;128 tmax = MIN2(map.RangeMap[1],TEMP_LIMIT_HIGH)*1.002; 130 129 131 130 /* we want about nMapStep (=20) steps between high and low temperature */ … … 137 136 factor = 1./factor; 138 137 /* TeHighest is highest possible temperature, 1E10 */ 139 phycon.te = (MIN2(map.RangeMap[1], StopCalc.TeHighest)/factor);138 phycon.te = (MIN2(map.RangeMap[1],TEMP_LIMIT_HIGH)/factor); 140 139 } 141 140 -
trunk/source/mole_h2.cpp
r1178 r1179 2831 2831 conv.HeatCoolRelErrorAllowed/2. 2832 2832 /* >>chng 04 may 09, do not check on error in heating if constant temperature */ 2833 /*&& !(thermal.lgTSetOn || phycon.te <= StopCalc.TeLowest)*/ )2833 /*&& !(thermal.lgTSetOn || phycon.te <= TEMP_LIMIT_LOW )*/ ) 2834 2834 { 2835 2835 /* default on HeatCoolRelErrorAllowed is 0.02 */ -
trunk/source/optimize_func.cpp
r1178 r1179 130 130 GridInitialize(); 131 131 } 132 133 /* Line fluxes now in commn blocks, so extract and 134 * compare with observations */ 135 chisq = 0.0; 136 for( i=0; i < MAXCAT; i++ ) 137 { 138 nobs_cat[i] = 0; 139 chi2_cat[i] = 0.0; 140 } 141 142 if( LineSave.ipNormWavL < 0 ) 143 { 144 fprintf( ioQQQ, 145 " Normalization line array index is bad. What has gone wrong?\n" ); 146 puts( "[Stop in optimize_func]" ); 147 cdEXIT(EXIT_FAILURE); 148 } 149 snorm = LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent]; 150 151 if( snorm == 0. ) 152 { 153 fprintf( ioQQQ, "\n\n PROBLEM Normalization line has zero intensity. What has gone wrong?\n" ); 154 fprintf( ioQQQ, " Is spectrum normalized to a species that does not exist?\n" ); 155 puts( "[Stop in optimize_func]" ); 156 cdEXIT(EXIT_FAILURE); 157 } 158 159 /* first print all warnings */ 160 cdWarnings(ioQQQ); 161 162 /* cycle through the observational values */ 163 nfound = 0; 164 165 /* first is to optimize relative emission line spectrum */ 166 if( optimize.lgOptLin ) 167 { 168 /* set pointers to all optimized lines if first call */ 169 if( !lgLinSet ) 170 { 171 lgHIT = true; 172 lgLinSet = true; 132 else 133 { 134 /* this branch optimizing, not grid 135 / * extract line fluxes and compare with observations */ 136 chisq = 0.0; 137 for( i=0; i < MAXCAT; i++ ) 138 { 139 nobs_cat[i] = 0; 140 chi2_cat[i] = 0.0; 141 } 142 143 if( LineSave.ipNormWavL < 0 ) 144 { 145 fprintf( ioQQQ, 146 " Normalization line array index is bad. What has gone wrong?\n" ); 147 puts( "[Stop in optimize_func]" ); 148 cdEXIT(EXIT_FAILURE); 149 } 150 151 if( (snorm = LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent]) == 0. ) 152 { 153 fprintf( ioQQQ, "\n\n PROBLEM Normalization line has zero intensity. What has gone wrong?\n" ); 154 fprintf( ioQQQ, " Is spectrum normalized to a species that does not exist?\n" ); 155 puts( "[Stop in optimize_func]" ); 156 cdEXIT(EXIT_FAILURE); 157 } 158 159 /* first print all warnings */ 160 cdWarnings(ioQQQ); 161 162 /* cycle through the observational values */ 163 nfound = 0; 164 165 /* first is to optimize relative emission line spectrum */ 166 if( optimize.lgOptLin ) 167 { 168 /* set pointers to all optimized lines if first call */ 169 if( !lgLinSet ) 170 { 171 lgHIT = true; 172 lgLinSet = true; 173 for( i=0; i < optimize.nlobs; i++ ) 174 { 175 double temp1, temp2; 176 cap4(chFind , (char*)optimize.chLineLabel[i]); 177 /* j = 0; */ 178 179 /* >> chng 06 may 04, use cdLine instead of ad hoc treatment. 180 * no need to complain, cdLine will do it automatically. */ 181 /* this is an intensity, get the line, returns false if could not find it */ 182 j=cdLine( chFind , optimize.wavelength[i] , &temp1, &temp2 ); 183 if( j<=0 ) 184 { 185 fprintf( ioQQQ, "\n" ); 186 lgHIT = false; 187 } 188 else 189 { 190 ipobs[i] = j; 191 } 192 } 193 194 /* we did not find the line */ 195 if( !lgHIT ) 196 { 197 fprintf( ioQQQ, "\n\n Optimizer could not find one or more lines.\n" ); 198 fprintf( ioQQQ, " Sorry.\n"); 199 puts( "[Stop in optimize_func]" ); 200 cdEXIT(EXIT_FAILURE); 201 } 202 } 203 204 for( i=0; i < 10; i++ ) 205 { 206 optimize.SavGenericData[i] = 0.; 207 } 208 173 209 for( i=0; i < optimize.nlobs; i++ ) 174 210 { 175 double temp1, temp2; 176 cap4(chFind , (char*)optimize.chLineLabel[i]); 177 /* j = 0; */ 178 179 /* >> chng 06 may 04, use cdLine instead of ad hoc treatment. 180 * no need to complain, cdLine will do it automatically. */ 181 /* this is an intensity, get the line, returns false if could not find it */ 182 j=cdLine( chFind , optimize.wavelength[i] , &temp1, &temp2 ); 183 if( j<=0 ) 211 /* and find corresponding model value by straight search */ 212 nfound += 1; 213 scld = (double)LineSv[ipobs[i]].sumlin[LineSave.lgLineEmergent]/(double)snorm*LineSave.ScaleNormLine; 214 chi1 = chi2_func(scld,(double)optimize.xLineInt_Obs[i],(double)optimize.xLineInt_error[i]); 215 cat = 0; 216 nobs_cat[cat]++; 217 chi2_cat[cat] += chi1; 218 219 fprintf( ioQQQ, " %4.4s ", 220 LineSv[ipobs[i]].chALab); 221 222 prt_wl( ioQQQ,LineSv[ipobs[i]].wavelength); 223 224 fprintf( ioQQQ, "%12.5f%12.5f%12.5f%12.2e Relative intensity", 225 scld, 226 optimize.xLineInt_Obs[i], 227 optimize.xLineInt_error[i], 228 chi1 ); 229 230 fprintf( ioQQQ, "\n" ); 231 232 if( i<10 ) 184 233 { 185 fprintf( ioQQQ, "\n" ); 186 lgHIT = false; 234 optimize.SavGenericData[i] = chi1; 187 235 } 188 else 236 } 237 } 238 239 /* >>chng 06 may 04, moved this from above so that it only 240 * gets printed if all lines are found */ 241 /*if( optimize.lgOptLum || optimize.lgOptCol || optimize.lgOptTemp || optimize.lgOptLin )*/ 242 if( optimize.lgOptimize ) 243 { 244 fprintf( ioQQQ, " ID Model Observed error chi**2 Type\n" ); 245 } 246 else 247 { 248 ASSERT( grid.lgGrid ); 249 } 250 251 /* this is to optimize a mean temperature */ 252 if( optimize.lgOptTemp ) 253 { 254 for( i=0; i < optimize.nTempObs; i++ ) 255 { 256 if( cdTemp(/*(char*)*/optimize.chTempLab[i],optimize.ionTemp[i], &temp_theory, optimize.chTempWeight[i]) ) 189 257 { 190 ipobs[i] = j; 258 /* did not find column density */ 259 fprintf(ioQQQ," optimizer did not find column density %s %li \n", 260 optimize.chTempLab[i],optimize.ionTemp[i] ); 261 puts( "[Stop in optimize_func]" ); 262 cdEXIT(EXIT_FAILURE); 191 263 } 192 } 193 194 /* we did not find the line */ 195 if( !lgHIT ) 196 { 197 fprintf( ioQQQ, "\n\n Optimizer could not find one or more lines.\n" ); 198 fprintf( ioQQQ, " Sorry.\n"); 199 puts( "[Stop in optimize_func]" ); 200 cdEXIT(EXIT_FAILURE); 201 } 202 } 203 204 for( i=0; i < 10; i++ ) 205 { 206 optimize.SavGenericData[i] = 0.; 207 } 208 209 for( i=0; i < optimize.nlobs; i++ ) 210 { 211 /* and find corresponding model value by straight search */ 264 nfound += 1; 265 chi1 = chi2_func(temp_theory,(double)optimize.temp_obs[i],(double)optimize.temp_error[i]); 266 cat = 3; 267 nobs_cat[cat]++; 268 chi2_cat[cat] += chi1; 269 270 fprintf( ioQQQ, " %4.4s %2ld ", 271 optimize.chTempLab[i], 272 optimize.ionTemp[i] ); 273 PrintE82( ioQQQ, temp_theory ); 274 fprintf( ioQQQ, " "); 275 PrintE82( ioQQQ, optimize.temp_obs[i] ); 276 fprintf( ioQQQ, " %.5f %.2e", 277 optimize.temp_error[i], chi1 ); 278 fprintf( ioQQQ, " Temperature\n"); 279 } 280 } 281 282 /* option to optimize column densities */ 283 if( optimize.lgOptCol ) 284 { 285 for( i=0; i < optimize.ncobs; i++ ) 286 { 287 if( cdColm((char*)optimize.chColDen_label[i],optimize.ion_ColDen[i], &theocl) ) 288 { 289 /* did not find column density */ 290 fprintf(ioQQQ," optimizer did not find column density %s %li \n", 291 optimize.chColDen_label[i],optimize.ion_ColDen[i] ); 292 puts( "[Stop in optimize_func]" ); 293 cdEXIT(EXIT_FAILURE); 294 } 295 nfound += 1; 296 chi1 = chi2_func(theocl,(double)optimize.ColDen_Obs[i],(double)optimize.chColDen_error[i]); 297 cat = 1; 298 nobs_cat[cat]++; 299 chi2_cat[cat] += chi1; 300 301 fprintf( ioQQQ, " %4.4s%6ld%12.4e%12.4e%12.5f%12.2e Column density\n", 302 optimize.chColDen_label[i], optimize.ion_ColDen[i], theocl, 303 optimize.ColDen_Obs[i], optimize.chColDen_error[i], chi1 ); 304 } 305 } 306 307 /* option to optimize line flux */ 308 if( optimize.lgOptLum ) 309 { 212 310 nfound += 1; 213 scld = (double)LineSv[ipobs[i]].sumlin[LineSave.lgLineEmergent]/(double)snorm*LineSave.ScaleNormLine; 214 chi1 = chi2_func(scld,(double)optimize.xLineInt_Obs[i],(double)optimize.xLineInt_error[i]); 215 cat = 0; 311 if( LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent] > 0.f ) 312 { 313 predin = log10(LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent]) + radius.Conv2PrtInten; 314 help = pow(10.,predin-(double)optimize.optint); 315 chi1 = chi2_func(help,1.,(double)optimize.optier); 316 } 317 else 318 { 319 predin = -999.99999; 320 chi1 = (double)FLT_MAX; 321 } 322 cat = 2; 216 323 nobs_cat[cat]++; 217 324 chi2_cat[cat] += chi1; 218 325 219 fprintf( ioQQQ, " %4.4s ", 220 LineSv[ipobs[i]].chALab); 221 222 prt_wl( ioQQQ,LineSv[ipobs[i]].wavelength); 223 224 fprintf( ioQQQ, "%12.5f%12.5f%12.5f%12.2e Relative intensity", 225 scld, 226 optimize.xLineInt_Obs[i], 227 optimize.xLineInt_error[i], 326 fprintf( ioQQQ, " %4.4s%6f%12.5f%12.5f%12.5f%12.2e Line intensity\n", 327 LineSv[LineSave.ipNormWavL].chALab, 328 LineSv[LineSave.ipNormWavL].wavelength, 329 predin, 330 optimize.optint, 331 optimize.optier, 228 332 chi1 ); 229 230 fprintf( ioQQQ, "\n" ); 231 232 if( i<10 ) 233 { 234 optimize.SavGenericData[i] = chi1; 235 } 236 } 237 } 238 239 /* >>chng 06 may 04, moved this from above so that it only 240 * gets printed if all lines are found */ 241 if( optimize.lgOptLum || optimize.lgOptCol || optimize.lgOptTemp || optimize.lgOptLin ) 242 { 243 fprintf( ioQQQ, " ID Model Observed error chi**2 Type\n" ); 244 } 245 else 246 { 247 ASSERT( grid.lgGrid ); 248 } 249 250 /* this is to optimize a mean temperature */ 251 if( optimize.lgOptTemp ) 252 { 253 for( i=0; i < optimize.nTempObs; i++ ) 254 { 255 if( cdTemp(/*(char*)*/optimize.chTempLab[i],optimize.ionTemp[i], &temp_theory, optimize.chTempWeight[i]) ) 256 { 257 /* did not find column density */ 258 fprintf(ioQQQ," optimizer did not find column density %s %li \n", 259 optimize.chTempLab[i],optimize.ionTemp[i] ); 260 puts( "[Stop in optimize_func]" ); 261 cdEXIT(EXIT_FAILURE); 262 } 263 nfound += 1; 264 chi1 = chi2_func(temp_theory,(double)optimize.temp_obs[i],(double)optimize.temp_error[i]); 265 cat = 3; 266 nobs_cat[cat]++; 267 chi2_cat[cat] += chi1; 268 269 fprintf( ioQQQ, " %4.4s %2ld ", 270 optimize.chTempLab[i], 271
