Changeset 1751

Show
Ignore:
Timestamp:
01/22/08 13:18:24 (10 months ago)
Author:
rporter
Message:

trunk/source/grid_do.cpp - minor changes in grid/optimizer printout to make difference more clear.

trunk/source/iso_continuum_lower.cpp - fix bug when continuum was lowered in previous zone and then is not lowered.

trunk/source/iso_create.cpp - change lifetime calculation for upper level of extra lyman lines. Dramatically reduces startup time in fast models.

trunk/source/optimize_func.cpp - minor printout change

trunk/source/parse.h - declare ParseGrid?

trunk/source/parse_commands.cpp - call ParseGrid? instead of ParseOptimize? on GRID keyword

trunk/source/parse_grid.cpp - new file, extracted from ParseOptimize?

trunk/source/parse_optimize.cpp - remove GRID keyword as above

trunk/source/punch_fits.cpp - add fixit about FITS files problem with all double precision

trunk/tsuite/auto/dynamics_wind.in - increase itrzn - this has apparently been botching for a month

Location:
trunk
Files:
1 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/grid_do.cpp

    r1733 r1751  
    237237        } 
    238238 
    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 ); 
    243239 
    244240        if( strcmp(optimize.chOptRtn,"PHYM") == 0 ) 
    245241        { 
     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 
    246247                fprintf( ioQQQ, " The optimize_phymir method will be used" ); 
    247248                if( optimize.lgParallel ) { 
     
    255256        else if( strcmp(optimize.chOptRtn,"SUBP") == 0 ) 
    256257        { 
     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 
    257263                fprintf( ioQQQ, " Subplex method will be used.\n" ); 
    258264        } 
     
    260266        else if( strcmp(optimize.chOptRtn,"XSPE") == 0 ) 
    261267        { 
    262                 fprintf( ioQQQ, " Producing XSPEC output.\n" ); 
     268                fprintf( ioQQQ, " Producing grid output.\n" ); 
    263269        } 
    264270 
     
    267273                fprintf( ioQQQ, " I do not understand what method to use.\n" ); 
    268274                fprintf( ioQQQ, " Sorry.\n" ); 
    269                 puts( "[Stop in lgOptimize_do]" ); 
     275                puts( "[Stop in grid_do]" ); 
    270276                cdEXIT(EXIT_FAILURE); 
    271277        } 
    272278 
    273         fprintf( ioQQQ, "\n%4ld parameters will 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",  
    274280          optimize.nvary ); 
    275281 
  • trunk/source/iso_continuum_lower.cpp

    r1732 r1751  
    7979        { 
    8080                iso.lgLevelsLowered[ipISO][nelem] = true; 
     81                iso.lgLevelsEverLowered[ipISO][nelem] = true; 
    8182                hydro.lgReevalRecom = true; 
    8283                iso.n_HighestResolved_local[ipISO][nelem] = nc; 
     
    9495        { 
    9596                iso.lgLevelsLowered[ipISO][nelem] = true; 
     97                iso.lgLevelsEverLowered[ipISO][nelem] = true; 
    9698                hydro.lgReevalRecom = true; 
    9799                iso.n_HighestResolved_local[ipISO][nelem] = iso.n_HighestResolved_max[ipISO][nelem]; 
     
    118120                iso.nCollapsed_local[ipISO][nelem] = iso.nCollapsed_max[ipISO][nelem]; 
    119121                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 
    120133                iso.lgLevelsLowered[ipISO][nelem] = false; 
    121                 hydro.lgReevalRecom = false; 
    122134        } 
    123135 
  • trunk/source/iso_create.cpp

    r1732 r1751  
    3232STATIC void FillExtraLymanLine( transition *t, long ipISO, long nelem, long nHi ); 
    3333 
     34/* calculate radiative lifetime of an individual iso state */ 
     35STATIC double iso_state_lifetime( long ipISO, long nelem, long n, long l ); 
     36 
    3437/* calculate cascade probabilities, branching ratios, and associated errors. */ 
    3538STATIC void iso_cascade(void); 
     
    12361239{ 
    12371240        double Enerwn, Aul; 
    1238         long nLo; 
    12391241 
    12401242        DEBUG_ENTRY( "FillExtraLymanLine()" ); 
     
    12791281        t->Emis->Aul = (realnum)Aul; 
    12801282 
    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 ); 
    12961295 
    12971296        t->Emis->dampXvel = (realnum)( 1.f / t->Hi->lifetime / PI4 / t->EnergyWN ); 
     
    13241323        } 
    13251324        return; 
     1325} 
     1326 
     1327/* calculate radiative lifetime of an individual iso state */ 
     1328STATIC 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; 
    13261358} 
    13271359 
  • trunk/source/optimize_func.cpp

    r1732 r1751  
    411411                        } 
    412412 
    413                         fprintf( ioQQQ, " Optimal command: %s\n",  
     413                        fprintf( ioQQQ, " Varied command: %s\n",  
    414414                          input.chCardSav[np] ); 
    415415                } 
  • trunk/source/parse.h

    r1732 r1751  
    117117*/ 
    118118void ParseAtomCO(char *chCard ); 
     119 
     120/**ParseGrid parse the grid command  
     121\param *chCard 
     122*/ 
     123void ParseGrid(char *chCard); 
    119124 
    120125/**ParseInit parse the init command */ 
  • trunk/source/parse_commands.cpp

    r1732 r1751  
    937937                else if( strcmp(chKey4,"GRID") == 0 ) 
    938938                { 
    939                         /* option to optimize the model by varying certain parameters 
     939                        /* option to run grid of models by varying certain parameters 
    940940                         * in reads2 */ 
    941                         ParseOptimize(chCard); 
     941                        ParseGrid(chCard); 
    942942                } 
    943943 
  • trunk/source/parse_optimize.cpp

    r1732 r1751  
    246246        } 
    247247 
    248         else if( nMatch("GRID",chCard) || nMatch("XSPE",chCard) ) 
    249         { 
    250                 /* RP fake optimizer to run a grid of calculations, also accepts 
    251                  * 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                         else 
    295                         { 
    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  
    349248        else 
    350249        { 
  • trunk/source/punch_fits.cpp

    r1733 r1751  
    184184 
    185185        bytesAdded = 0; 
     186 
     187        fixit(); /* bitpix is wrong when realnum is double? */ 
    186188 
    187189        bytesAdded += addKeyword_txt( "SIMPLE"  , "T",                                  "file does conform to FITS standard", 1 ); 
  • trunk/tsuite/auto/dynamics_wind.in

    r1709 r1751  
    3737// 
    3838// >>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  
     40assert itrzn < 21 
    4041//  
    4142c dynamics_wind.in