Changeset 1751
- Timestamp:
- 01/22/08 13:18:24 (10 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 modified
-
source/grid_do.cpp (modified) (4 diffs)
-
source/iso_continuum_lower.cpp (modified) (3 diffs)
-
source/iso_create.cpp (modified) (4 diffs)
-
source/optimize_func.cpp (modified) (1 diff)
-
source/parse.h (modified) (1 diff)
-
source/parse_commands.cpp (modified) (1 diff)
-
source/parse_grid.cpp (added)
-
source/parse_optimize.cpp (modified) (1 diff)
-
source/punch_fits.cpp (modified) (1 diff)
-
tsuite/auto/dynamics_wind.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/grid_do.cpp
r1733 r1751 237 237 } 238 238 239 fprintf( ioQQQ, " Up to%5ld iterations will be performed,\n",240 optimize.nIterOptim );241 fprintf( ioQQQ, " and the final version of the input file will be written to the file %s\n",242 chOptimFileName );243 239 244 240 if( strcmp(optimize.chOptRtn,"PHYM") == 0 ) 245 241 { 242 fprintf( ioQQQ, " Up to%5ld iterations will be performed,\n", 243 optimize.nIterOptim ); 244 fprintf( ioQQQ, " and the final version of the input file will be written to the file %s\n", 245 chOptimFileName ); 246 246 247 fprintf( ioQQQ, " The optimize_phymir method will be used" ); 247 248 if( optimize.lgParallel ) { … … 255 256 else if( strcmp(optimize.chOptRtn,"SUBP") == 0 ) 256 257 { 258 fprintf( ioQQQ, " Up to%5ld iterations will be performed,\n", 259 optimize.nIterOptim ); 260 fprintf( ioQQQ, " and the final version of the input file will be written to the file %s\n", 261 chOptimFileName ); 262 257 263 fprintf( ioQQQ, " Subplex method will be used.\n" ); 258 264 } … … 260 266 else if( strcmp(optimize.chOptRtn,"XSPE") == 0 ) 261 267 { 262 fprintf( ioQQQ, " Producing XSPECoutput.\n" );268 fprintf( ioQQQ, " Producing grid output.\n" ); 263 269 } 264 270 … … 267 273 fprintf( ioQQQ, " I do not understand what method to use.\n" ); 268 274 fprintf( ioQQQ, " Sorry.\n" ); 269 puts( "[Stop in lgOptimize_do]" );275 puts( "[Stop in grid_do]" ); 270 276 cdEXIT(EXIT_FAILURE); 271 277 } 272 278 273 fprintf( ioQQQ, "\n%4ld parameter swill be varied. The first lines, and the increments are:\n",279 fprintf( ioQQQ, "\n%4ld parameter(s) will be varied. The first lines, and the increments are:\n", 274 280 optimize.nvary ); 275 281 -
trunk/source/iso_continuum_lower.cpp
r1732 r1751 79 79 { 80 80 iso.lgLevelsLowered[ipISO][nelem] = true; 81 iso.lgLevelsEverLowered[ipISO][nelem] = true; 81 82 hydro.lgReevalRecom = true; 82 83 iso.n_HighestResolved_local[ipISO][nelem] = nc; … … 94 95 { 95 96 iso.lgLevelsLowered[ipISO][nelem] = true; 97 iso.lgLevelsEverLowered[ipISO][nelem] = true; 96 98 hydro.lgReevalRecom = true; 97 99 iso.n_HighestResolved_local[ipISO][nelem] = iso.n_HighestResolved_max[ipISO][nelem]; … … 118 120 iso.nCollapsed_local[ipISO][nelem] = iso.nCollapsed_max[ipISO][nelem]; 119 121 iso.n_HighestResolved_local[ipISO][nelem] = iso.n_HighestResolved_max[ipISO][nelem]; 122 123 /* if levels were lowered on last past but are not now, must reeval */ 124 if( iso.lgLevelsLowered[ipISO][nelem] ) 125 { 126 hydro.lgReevalRecom = true; 127 } 128 else 129 { 130 hydro.lgReevalRecom = false; 131 } 132 120 133 iso.lgLevelsLowered[ipISO][nelem] = false; 121 hydro.lgReevalRecom = false;122 134 } 123 135 -
trunk/source/iso_create.cpp
r1732 r1751 32 32 STATIC void FillExtraLymanLine( transition *t, long ipISO, long nelem, long nHi ); 33 33 34 /* calculate radiative lifetime of an individual iso state */ 35 STATIC double iso_state_lifetime( long ipISO, long nelem, long n, long l ); 36 34 37 /* calculate cascade probabilities, branching ratios, and associated errors. */ 35 38 STATIC void iso_cascade(void); … … 1236 1239 { 1237 1240 double Enerwn, Aul; 1238 long nLo;1239 1241 1240 1242 DEBUG_ENTRY( "FillExtraLymanLine()" ); … … 1279 1281 t->Emis->Aul = (realnum)Aul; 1280 1282 1281 t->Hi->lifetime = t->Emis->Aul; 1282 1283 /* Now loop over lower levels to get sum of As out, and invert for lifetime. */ 1284 for( nLo=2; nLo < nHi; nLo++ ) 1285 { 1286 double ea; 1287 1288 ea = H_Einstein_A( nHi, 1, nLo, 0, nelem+1-ipISO ); 1289 1290 ASSERT( ea > 0. ); 1291 t->Hi->lifetime += (realnum)ea; 1292 } 1293 1294 /* Now invert to get actual lifetime. */ 1295 t->Hi->lifetime = 1./t->Hi->lifetime; 1283 t->Hi->lifetime = iso_state_lifetime( ipISO, nelem, nHi, 1 ); 1284 1285 if( ipISO == ipHE_LIKE ) 1286 { 1287 /* iso_state_lifetime is not spin specific, must exclude helike triplet here. */ 1288 t->Hi->lifetime /= 3.; 1289 /* there is also necessary to correct the helike lifetimes */ 1290 t->Hi->lifetime *= 1.1722 * pow( (double)nelem, 0.1 ); 1291 } 1292 1293 /* would probably need a new lifetime algorithm for any other iso sequences. */ 1294 ASSERT( ipISO <= ipHE_LIKE ); 1296 1295 1297 1296 t->Emis->dampXvel = (realnum)( 1.f / t->Hi->lifetime / PI4 / t->EnergyWN ); … … 1324 1323 } 1325 1324 return; 1325 } 1326 1327 /* calculate radiative lifetime of an individual iso state */ 1328 STATIC double iso_state_lifetime( long ipISO, long nelem, long n, long l ) 1329 { 1330 /* >>refer hydro lifetimes Horbatsch, M. W., Horbatsch, M. and Hessels, E. A. 2005, JPhysB, 38, 1765 */ 1331 1332 double epsilon, tau, t0, eps2; 1333 /* mass of electron */ 1334 double m = ELECTRON_MASS; 1335 /* nuclear mass */ 1336 double M = (double)dense.AtomicWeight[nelem] * ATOMIC_MASS_UNIT; 1337 double mu = (m*M)/(M+m); 1338 long z = 1; 1339 long Z = nelem + 1 - ipISO; 1340 1341 DEBUG_ENTRY( "iso_state_lifetime()" ); 1342 1343 eps2 = 1. - ( l*l + l + 8./47. - (l+1.)/69./n ) / POW2( (double)n ); 1344 1345 epsilon = sqrt( eps2 ); 1346 1347 t0 = 3. * H_BAR * pow( (double)n, 5.) / 1348 ( 2. * POW4( (double)( z * Z ) ) * pow( FINE_STRUCTURE, 5. ) * mu * POW2( SPEEDLIGHT ) ) * 1349 POW2( (m + M)/(Z*m + z*M) ); 1350 1351 tau = t0 * ( 1. - eps2 ) / 1352 ( 1. + 19./88.*( (1./eps2 - 1.) * log( 1. - eps2 ) + 1. - 1353 0.5 * eps2 - 0.025 * eps2 * eps2 ) ); 1354 1355 ASSERT( tau > 0. ); 1356 1357 return tau; 1326 1358 } 1327 1359 -
trunk/source/optimize_func.cpp
r1732 r1751 411 411 } 412 412 413 fprintf( ioQQQ, " Optimalcommand: %s\n",413 fprintf( ioQQQ, " Varied command: %s\n", 414 414 input.chCardSav[np] ); 415 415 } -
trunk/source/parse.h
r1732 r1751 117 117 */ 118 118 void ParseAtomCO(char *chCard ); 119 120 /**ParseGrid parse the grid command 121 \param *chCard 122 */ 123 void ParseGrid(char *chCard); 119 124 120 125 /**ParseInit parse the init command */ -
trunk/source/parse_commands.cpp
r1732 r1751 937 937 else if( strcmp(chKey4,"GRID") == 0 ) 938 938 { 939 /* option to optimize the modelby varying certain parameters939 /* option to run grid of models by varying certain parameters 940 940 * in reads2 */ 941 Parse Optimize(chCard);941 ParseGrid(chCard); 942 942 } 943 943 -
trunk/source/parse_optimize.cpp
r1732 r1751 246 246 } 247 247 248 else if( nMatch("GRID",chCard) || nMatch("XSPE",chCard) )249 {250 /* RP fake optimizer to run a grid of calculations, also accepts251 * keyword XSPEC */252 strcpy( optimize.chOptRtn, "XSPE" );253 grid.lgGrid = true;254 255 /* 06 aug 22, change to accept three parameters: lower and upper limit and number of points. */256 /* scan off range for the previously selected variable */257 if( optimize.nparm > 0 )258 {259 realnum highvalue;260 long numPoints=0;261 262 ASSERT( optimize.nparm < LIMPAR );263 264 i = 5;265 optimize.varang[optimize.nparm-1][0] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);266 optimize.varang[optimize.nparm-1][1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);267 grid.paramIncrements[optimize.nparm-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);268 269 if( grid.paramIncrements[optimize.nparm-1] <= 0. )270 {271 fprintf( ioQQQ," The increment (third parameter) must be a positive number.\n" );272 fprintf( ioQQQ," Sorry.\n" );273 puts( "[Stop in ParseOptimize]" );274 cdEXIT( EXIT_FAILURE );275 }276 277 if( grid.paramIncrements[optimize.nparm-1] > ( optimize.varang[optimize.nparm-1][1] - optimize.varang[optimize.nparm-1][0] ) )278 {279 fprintf( ioQQQ," The increment (third parameter) must not be greater than the difference between the limits (first and second parameters.\n" );280 fprintf( ioQQQ," Sorry.\n" );281 puts( "[Stop in ParseOptimize]" );282 cdEXIT( EXIT_FAILURE );283 }284 285 if( lgEOL )286 {287 fprintf( ioQQQ," This command has changed since the definition given in Porter et al. 2006, PASP, 118, 920.\n" );288 fprintf( ioQQQ," The grid command now requires three parameters: lower limit, upper limit, and increment.\n" );289 fprintf( ioQQQ," The keywords RANGE and STEPS are no longer necessary.\n" );290 fprintf( ioQQQ," Sorry.\n" );291 puts( "[Stop in ParseOptimize]" );292 cdEXIT( EXIT_FAILURE );293 }294 else295 {296 ++optimize.nRangeSet;297 }298 299 /* Swap if second range parameter is less than the first. */300 if( optimize.varang[optimize.nparm-1][1] < optimize.varang[optimize.nparm-1][0] )301 {302 realnum temp = optimize.varang[optimize.nparm-1][0];303 optimize.varang[optimize.nparm-1][0] = optimize.varang[optimize.nparm-1][1];304 optimize.varang[optimize.nparm-1][1] = temp;305 }306 307 ASSERT( optimize.varang[optimize.nparm-1][1] - optimize.varang[optimize.nparm-1][0] > 0. );308 309 {310 realnum integer, tempNumPoints = (optimize.varang[optimize.nparm-1][1] -311 optimize.varang[optimize.nparm-1][0])/grid.paramIncrements[optimize.nparm-1];312 realnum fraction = modf( tempNumPoints, &integer );313 314 if( fraction > 0.99f || fraction < 0.01f )315 {316 optimize.varang[optimize.nparm-1][1] += 0.01f * grid.paramIncrements[optimize.nparm-1];317 fprintf( ioQQQ,"\n NOTE The range is very nearly (or exactly) an integer multiple of the increment.\n" );318 fprintf( ioQQQ," NOTE The upper limit has been increased by a small fraction of the increment to ensure that\n" );319 fprintf( ioQQQ," NOTE the specified upper limit is included in the grid.\n\n" );320 }321 }322 323 numPoints = 0;324 highvalue = optimize.varang[optimize.nparm-1][0];325 /* find the number of parameter values by incrementing from the lower limit up to the upper limit. */326 while( highvalue <= optimize.varang[optimize.nparm-1][1] )327 {328 ++numPoints;329 highvalue += grid.paramIncrements[optimize.nparm-1];330 }331 332 grid.numParamValues[optimize.nparm-1] = numPoints;333 334 if( grid.numParamValues[optimize.nparm-1] < 2 )335 {336 fprintf( ioQQQ, " NOTE must have at least two grid points\n" );337 }338 else if( grid.numParamValues[optimize.nparm-1] > 20 )339 {340 fprintf( ioQQQ, " NOTE There are %li grid points. Are you "341 "sure you want that many?\n" ,342 grid.numParamValues[optimize.nparm-1]);343 }344 345 grid.numParamValues[optimize.nparm-1] = MAX2( 2, grid.numParamValues[optimize.nparm-1] );346 }347 }348 349 248 else 350 249 { -
trunk/source/punch_fits.cpp
r1733 r1751 184 184 185 185 bytesAdded = 0; 186 187 fixit(); /* bitpix is wrong when realnum is double? */ 186 188 187 189 bytesAdded += addKeyword_txt( "SIMPLE" , "T", "file does conform to FITS standard", 1 ); -
trunk/tsuite/auto/dynamics_wind.in
r1709 r1751 37 37 // 38 38 // >>chng 03 dec 08, from 12 to 15, chng ots, zones 39 assert itrzn < 15 39 // >>chng 08 jan 23, from 15 to 21, unknown cause 40 assert itrzn < 21 40 41 // 41 42 c dynamics_wind.in
