Changeset 2036
- Timestamp:
- 05/10/08 11:14:00 (6 months ago)
- Location:
- trunk
- Files:
-
- 10 modified
-
source/cddrive.h (modified) (3 diffs)
-
source/cdspec.cpp (modified) (3 diffs)
-
source/dense_fabden.cpp (modified) (1 diff)
-
source/grid.h (modified) (1 diff)
-
source/grid_xspec.cpp (modified) (7 diffs)
-
source/init_coreload.cpp (modified) (1 diff)
-
source/parse_punch.cpp (modified) (2 diffs)
-
source/punch_fits.cpp (modified) (4 diffs)
-
source/punch_line.cpp (modified) (1 diff)
-
tsuite/auto/ism_grid.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/cddrive.h
r1869 r2036 536 536 3 the reflected continuum, same units 537 537 538 4 diffuse continuousemission outward direction539 5 diffuse continuousemission, reflected538 4 diffuse emission outward direction 539 5 diffuse emission, reflected 540 540 541 541 6 collisional+recombination lines, outward … … 547 547 548 548 \param nEnergy the number of cells + 1 549 \param ipLoEnergy 550 \param ipHiEnergy 549 551 \param ReturnedSpectrum[] the returned spectrum, same size is two energy spectra (see option), returns nEnergy -1 pts 550 552 */ … … 552 554 int Option , 553 555 long int nEnergy , 556 long int ipLoEnergy, 557 long int ipHiEnergy, 554 558 realnum ReturnedSpectrum[] ); 555 559 -
trunk/source/cdspec.cpp
r1771 r2036 318 318 * 3 the reflected continuum, same units 319 319 * 320 * 4 diffuse continuous emission outward direction321 * 5 diffuse continuous emission, reflected322 * 323 * 6 collisional+recombination lines, outward324 * 7 collisional+recombination lines, reflected320 * 4 diffuse emission, lines + continuum, outward 321 * 5 diffuse emission, lines + continuum, reflected 322 * 323 * 6 diffuse continuous emission outward direction 324 * 7 diffuse continuous emission, reflected 325 325 * 326 326 * 8 total transmitted, lines and continuum … … 333 333 int nOption , 334 334 335 /* the number of cells + 1*/ 336 long int nEnergy , 335 /* the number of cells */ 336 long int nEnergy, 337 338 /* the index of the lowest and highest energy bounds to use. */ 339 long ipLoEnergy, 340 long ipHiEnergy, 337 341 338 342 /* the returned spectrum, same size is two energy spectra (see option), returns nEnergy -1 pts */ … … 340 344 341 345 { 342 /* this pointer will bet set to one of the cloudy continuum arrays */ 343 realnum *cont , 344 refac; 345 long int ncell , j; 346 347 /* flag saying whether we will need to free cont at the end */ 348 bool lgFREE; 346 realnum refac; 349 347 350 348 DEBUG_ENTRY( "cdSPEC2()" ); 351 349 350 ASSERT( ipLoEnergy >= 0 ); 351 ASSERT( ipLoEnergy < ipHiEnergy ); 352 ASSERT( ipHiEnergy < rfield.nupper ); 353 ASSERT( nEnergy == (ipHiEnergy-ipLoEnergy+1) ); 354 ASSERT( nEnergy >= 2 ); 355 352 356 ASSERT( nOption <= NUM_OUTPUT_TYPES ); 353 357 354 if( nOption == 1 ) 355 { 356 /* this is the incident continuum, col 2 of punch continuum command */ 357 cont = rfield.flux_total_incident; 358 lgFREE = false; 359 } 360 else if( nOption == 2 ) 361 { 362 /* the attenuated transmitted continuum, no diffuse emission, 363 * col 3 of punch continuum command */ 364 cont = rfield.flux; 365 lgFREE = false; 366 } 367 else if( nOption == 3 ) 368 { 369 /* reflected incident continuum, col 6 of punch continuum command */ 370 lgFREE = false; 371 cont = rfield.ConRefIncid; 372 } 373 else if( nOption == 4 ) 374 { 375 /* diffuse continuous emission outward direction */ 376 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 377 /* need to free the vector once done */ 378 lgFREE = true; 379 refac = (realnum)radius.r1r0sq*geometry.covgeo; 380 for( j=0; j<rfield.nflux; ++j) 381 { 382 cont[j] = rfield.ConEmitOut[j]*refac; 383 } 384 } 385 else if( nOption == 5 ) 386 { 387 /* reflected diffuse continuous emission */ 388 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 389 /* need to free the vector once done */ 390 lgFREE = true; 391 for( j=0; j<rfield.nflux; ++j) 392 { 393 cont[j] = rfield.ConEmitReflec[j]; 394 } 395 } 396 else if( nOption == 6 ) 397 { 398 /* all outward lines, */ 399 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 400 /* need to free the vector once done */ 401 lgFREE = true; 402 /* correct back to inner radius */ 403 refac = (realnum)radius.r1r0sq*geometry.covgeo; 404 for( j=0; j<rfield.nflux; ++j) 405 { 406 cont[j] = rfield.outlin[j]*refac; 407 } 408 } 409 else if( nOption == 7 ) 410 { 411 /* all reflected lines */ 412 if( geometry.lgSphere ) 413 { 414 refac = 0.; 415 } 416 else 417 { 418 refac = 1.; 419 } 420 421 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 422 /* need to free the vector once done */ 423 lgFREE = true; 424 for( j=0; j<rfield.nflux; ++j) 425 { 426 /* units of lines here are to cancel out with tricks applied to continuum cells 427 * when finally extracted below */ 428 cont[j] = rfield.reflin[j]*refac; 429 } 430 } 431 else if( nOption == 8 ) 432 { 433 /* total transmitted continuum */ 434 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 435 /* need to free the vector once done */ 436 lgFREE = true; 437 /* correct back to inner radius */ 438 refac = (realnum)radius.r1r0sq*geometry.covgeo; 439 for( j=0; j<rfield.nflux; ++j) 440 { 441 /* units of lines here are to cancel out with tricks applied to continuum cells 442 * when finally extracted below */ 443 cont[j] = (rfield.ConEmitOut[j]+ rfield.outlin[j])*refac 444 + rfield.flux[j]*(realnum)radius.r1r0sq; 445 } 446 } 447 else if( nOption == 9 ) 448 { 449 /* total reflected continuum */ 450 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 451 /* need to free the vector once done */ 452 lgFREE = true; 453 for( j=0; j<rfield.nflux; ++j) 454 { 455 /* units of lines here are to cancel out with tricks applied to continuum cells 456 * when finally extracted below */ 457 cont[j] = ((rfield.ConRefIncid[j]+rfield.ConEmitReflec[j]) + 358 for( long i = 0; i < nEnergy; i++ ) 359 { 360 long j = ipLoEnergy + i; 361 362 if( j >= rfield.nflux ) 363 { 364 ReturnedSpectrum[i] = SMALLFLOAT; 365 continue; 366 } 367 368 if( nOption == 1 ) 369 { 370 /* this is the incident continuum, col 2 of punch continuum command */ 371 ReturnedSpectrum[i] = rfield.flux_total_incident[j]; 372 } 373 else if( nOption == 2 ) 374 { 375 /* the attenuated transmitted continuum, no diffuse emission, 376 * col 3 of punch continuum command */ 377 ReturnedSpectrum[i] = rfield.flux[j]; 378 } 379 else if( nOption == 3 ) 380 { 381 /* reflected incident continuum, col 6 of punch continuum command */ 382 ReturnedSpectrum[i] = rfield.ConRefIncid[j]; 383 } 384 else if( nOption == 4 ) 385 { 386 /* correct back to inner radius */ 387 refac = (realnum)radius.r1r0sq*geometry.covgeo; 388 ReturnedSpectrum[i] = (rfield.outlin[j]+rfield.ConEmitOut[j])*refac; 389 } 390 else if( nOption == 5 ) 391 { 392 /* all reflected diffuse emission */ 393 if( geometry.lgSphere ) 394 { 395 refac = 0.; 396 } 397 else 398 { 399 refac = 1.; 400 } 401 402 ReturnedSpectrum[i] = (rfield.reflin[j]+rfield.ConEmitReflec[j])*refac; 403 } 404 else if( nOption == 6 ) 405 { 406 /* correct back to inner radius */ 407 refac = (realnum)radius.r1r0sq*geometry.covgeo; 408 ReturnedSpectrum[i] = rfield.outlin[j]*refac; 409 } 410 else if( nOption == 7 ) 411 { 412 /* all reflected line emission */ 413 if( geometry.lgSphere ) 414 { 415 refac = 0.; 416 } 417 else 418 { 419 refac = 1.; 420 } 421 422 ReturnedSpectrum[i] = rfield.reflin[j]*refac; 423 } 424 else if( nOption == 8 ) 425 { 426 /* total transmitted continuum */ 427 /* correct back to inner radius */ 428 refac = (realnum)radius.r1r0sq*geometry.covgeo; 429 ReturnedSpectrum[i] = (rfield.ConEmitOut[j]+ rfield.outlin[j])*refac 430 + rfield.flux[j]*(realnum)radius.r1r0sq; 431 } 432 else if( nOption == 9 ) 433 { 434 /* total reflected continuum */ 435 ReturnedSpectrum[i] = ((rfield.ConRefIncid[j]+rfield.ConEmitReflec[j]) + 458 436 rfield.reflin[j]); 459 437 } 460 } 461 else if( nOption == 10 ) 462 { 463 /* this is exp(-tau) */ 464 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 465 /* need to free the vector once done */ 466 lgFREE = true; 467 for( j=0; j<nEnergy; ++j) 468 { 438 else if( nOption == 10 ) 439 { 440 /* this is exp(-tau) */ 469 441 /* This is the TOTAL attenuation in both the continuum and lines. 470 442 * Jon Miller discovered that the line attenuation was missing in 07.02 */ 471 cont[j] = opac.ExpmTau[j]*rfield.trans_coef_total[j]; 472 } 473 } 474 else 475 { 476 fprintf(ioQQQ," cdSPEC called with impossible nOption (%i)\n", nOption); 477 cdEXIT(EXIT_FAILURE); 478 } 479 480 /* now generate the continua */ 481 for( ncell = 0; ncell < nEnergy; ++ncell ) 482 { 483 if( ncell >= rfield.nflux ) 484 { 485 ReturnedSpectrum[ncell] = SMALLFLOAT; 443 ReturnedSpectrum[i] = opac.ExpmTau[j]*rfield.trans_coef_total[j]; 486 444 } 487 445 else 488 446 { 489 ReturnedSpectrum[ncell] = cont[ncell]; 490 } 491 ASSERT( ReturnedSpectrum[ncell] >=0.f ); 492 } 493 494 /* need to free the vector once done if this flag was set */ 495 if( lgFREE ) 496 { 497 free(cont); 498 } 447 fprintf(ioQQQ," cdSPEC called with impossible nOption (%i)\n", nOption); 448 cdEXIT(EXIT_FAILURE); 449 } 450 451 ASSERT( ReturnedSpectrum[i] >=0.f ); 452 } 453 499 454 return; 500 455 } -
trunk/source/dense_fabden.cpp
r1771 r2036 10 10 double depth) 11 11 { 12 double a , b; 13 a = depth; 14 b = radius; 15 16 fprintf(ioQQQ,"PROBLEM DISASTER The default version of dense_fabden is " 17 "still in dense_fabden.cpp - edit and replace this file to use your version.\n"); 18 /* return val is example - must return density */ 19 return(a*b); 20 21 /* these are two examples of using this routine */ 22 # if 0 23 double fabden_v; 24 double z , z0 , density , rad_midplane; 25 DEBUG_ENTRY( "dense_fabden()" ); 26 27 /* this routine is called when the DLAW command is given, 28 * and must return the hydrogen density at the current radius or depth 29 * RADIUS is the radius, the distance from the center of symmetry. 30 * DEPTH is the depth into the cloud, from the illuminated face 31 * both are in cm 32 * 33 * radius, depth, and the array DensityLaw are double precision, although 34 * dense_fabden itself is not 35 * 36 * this is one way to generate a density 37 * dense_fabden = radius * depth 38 * 39 * this is how to use the parameters on the dlaw command 40 * dense_fabden = DensityLaw(1) + radius * DensityLaw(2) 41 * 42 * following must be removed if this sub is to be used */ 43 /*fprintf( ioQQQ, " the old version of dense_fabden must be deleted, and a new one put in place. Sorry.\n" );*/ 44 45 if( depth > radius ) 46 TotalInsanity(); 47 48 rad_midplane = radius * cos( dense.DensityLaw[0] ); 49 z = radius * sin( dense.DensityLaw[0] ); 50 z0 = 0.047 * pow( rad_midplane/AU , 1.25 ) * AU; 51 /* density in gm / cm3 */ 52 density = 1.4e-9 * pow( rad_midplane/AU , -11./4. ) * sexp( POW2(z/z0) ); 53 /* convert density to cm-3 */ 54 fabden_v = density/(ATOMIC_MASS_UNIT * 1.2); 55 56 fprintf(ioQQQ, "bug dense_fabden zone %.2f radius %e density %e \n", 57 fnzone , radius , fabden_v ); 58 return( fabden_v ); 59 # endif 60 61 #if 0 62 63 /* update stromgren radius to most recent value */ 12 double fabden_v = pow(10.,dense.DensityLaw[0]); 64 13 if( rfield.lgUSphON ) 65 dense.DensityLaw[2] = rfield.rstrom/PARSEC; 66 67 /* this is the density law used in the Wen & O'Dell, 1995, ApJ 438, 784 paper */ 68 powexp = MIN2((radius/parsec-dense.DensityLaw[2])/dense.DensityLaw[1],dense.DensityLaw[3]); 69 fabden_v = pow(10.,dense.DensityLaw[0])*exp(powexp); 70 71 fabden_v = dense.DensityLaw[0]; 72 /* just here to stop compilers from flagging unused vars */ 73 temp = radius + depth; 74 if( fabden_v == 0. ) 75 { 76 cdEXIT(EXIT_FAILURE); 77 } 78 else 79 { 80 /* when this routine is used the following branch is the correct exit */ 81 /* following should return correct value of the density at this position, 82 * temp is there to trick lint */ 83 return( fabden_v*temp ); 84 } 85 #endif 14 fabden_v *= pow(radius/rfield.rstrom,dense.DensityLaw[1]); 15 return fabden_v; 86 16 } -
trunk/source/grid.h
r1842 r2036 57 57 bool lgOutputTypeOn[NUM_OUTPUT_TYPES]; 58 58 59 long ipLoEnergy, ipHiEnergy; 60 realnum LoEnergy_keV, HiEnergy_keV; 61 59 62 } grid; 60 63 -
trunk/source/grid_xspec.cpp
r1842 r2036 9 9 #include "optimize.h" 10 10 #include "cddrive.h" 11 #include "continuum.h" 11 12 #include "rfield.h" 12 13 #include "grid.h" 14 #include "ipoint.h" 13 15 #include "called.h" 16 #include "physconst.h" 14 17 #include "prt.h" 15 18 … … 17 20 void gridXspec(realnum xc[], long int nInterpVars) 18 21 { 19 long int i, j, k; 20 double averageChi2; 22 long int i; 21 23 22 24 DEBUG_ENTRY( "gridXspec()" ); … … 79 81 grid.paramRange[i][5] = xc[i]+grid.paramIncrements[i]*(grid.numParamValues[i]-1.f)+grid.paramIncrements[i]/10.f; 80 82 81 for( j=0; j<grid.numParamValues[i]; j++ )83 for( long j=0; j<grid.numParamValues[i]; j++ ) 82 84 { 83 85 grid.paramData[i][j] = xc[i]+grid.paramIncrements[i]*j; … … 90 92 } 91 93 92 /* >>chng 06 aug 23, this logic now allows non-square parameter spaces. */93 94 for( i=0; i< grid.totNumModels; i++ ) 94 95 { 96 long j; 97 double averageChi2; 95 98 realnum variableVector[LIMPAR]; 96 99 … … 105 108 * second "volume" is product of grid.numParamValues[2]*grid.numParamValues[3]*....grid.numParamValues[n] 106 109 * last "volume" is unity. */ 107 for( k=j+1; k<nInterpVars; k++ )110 for( long k=j+1; k<nInterpVars; k++ ) 108 111 { 109 112 volumeOtherDimensions *= grid.numParamValues[k]; … … 210 213 { 211 214 long i1, i2; 212 grid.numEnergies = rfield.nupper-2; 215 216 if( grid.LoEnergy_keV == 0. ) 217 grid.ipLoEnergy = 0; 218 else 219 grid.ipLoEnergy = ipoint( grid.LoEnergy_keV * 1000. / EVRYD ); 220 221 if( grid.HiEnergy_keV == 0. || grid.HiEnergy_keV >= continuum.filbnd[continuum.nrange] ) 222 grid.ipHiEnergy = rfield.nflux - 1; 223 else 224 grid.ipHiEnergy = ipoint( grid.HiEnergy_keV * 1000. / EVRYD ); 225 226 grid.numEnergies = grid.ipHiEnergy - grid.ipLoEnergy + 1; 213 227 grid.Energies = (realnum*)MALLOC(sizeof(realnum)*(unsigned)(grid.numEnergies) ); 214 228 grid.Spectra = (realnum***)MALLOC(sizeof(realnum**)*(unsigned)(NUM_OUTPUT_TYPES) ); … … 241 255 * at this point nOptimiz has already been incremented for first model */ 242 256 if( grid.lgOutputTypeOn[i] ) 243 cdSPEC2( i, grid.numEnergies, grid. Spectra[i][optimize.nOptimiz]);257 cdSPEC2( i, grid.numEnergies, grid.ipLoEnergy, grid.ipHiEnergy, grid.Spectra[i][optimize.nOptimiz]); 244 258 } 245 259 return; -
trunk/source/init_coreload.cpp
r1935 r2036 306 306 grid.lgGridDone = false; 307 307 grid.lgStrictRepeat = false; 308 /* these are energy range... if not changed with command, 0. says just use energy limits of mesh */ 309 grid.LoEnergy_keV = 0.; 310 grid.HiEnergy_keV = 0.; 311 308 312 309 313 PunchFilesInit(); -
trunk/source/parse_punch.cpp
r1949 r2036 1619 1619 strcpy( punch.chPunch[punch.npunch], "LINR" ); 1620 1620 /* punch some details needed for line radiative transfer 1621 * routine in punch_line.c */1621 * routine in punch_line.cpp */ 1622 1622 Punch_Line_RT(punch.ipPnunit[punch.npunch],"READ"); 1623 1623 } … … 2143 2143 { 2144 2144 punch.lgPunLstIter[punch.npunch] = true; 2145 } 2146 2147 ipFFmt = 5; 2148 /* range option - important since so much data */ 2149 if( nMatch("RANGE",chCard) ) 2150 { 2151 /* get lower and upper range, must be in keV */ 2152 punch.punarg[punch.npunch][0] = (realnum)FFmtRead(chCard,&ipFFmt,INPUT_LINE_LENGTH,&lgEOL); 2153 punch.punarg[punch.npunch][1] = (realnum)FFmtRead(chCard,&ipFFmt,INPUT_LINE_LENGTH,&lgEOL); 2154 if( lgEOL ) 2155 { 2156 fprintf(ioQQQ,"There must be two numbers, the lower and upper energy range in keV.\nSorry.\n"); 2157 cdEXIT(EXIT_FAILURE); 2158 } 2159 if( punch.punarg[punch.npunch][0] >=punch.punarg[punch.npunch][1] ) 2160 { 2161 fprintf(ioQQQ,"The two energies for the range must be in increasing order.\nSorry.\n"); 2162 cdEXIT(EXIT_FAILURE); 2163 } 2164 2165 grid.LoEnergy_keV = punch.punarg[punch.npunch][0]; 2166 grid.HiEnergy_keV = punch.punarg[punch.npunch][1]; 2167 } 2168 else 2169 { 2170 /* these mean full energy range */ 2171 punch.punarg[punch.npunch][0] = 0; 2172 punch.punarg[punch.npunch][1] = 0; 2145 2173 } 2146 2174 -
trunk/source/punch_fits.cpp
r1960 r2036 77 77 long totNumModels, long numEnergies, long nintparm, long naddparm ); 78 78 STATIC void punchFITS_GenericHeader( long numEnergies ); 79 STATIC void punchFITS_GenericData( long numEnergies );79 STATIC void punchFITS_GenericData( long numEnergies, long ipLoEnergy, long ipHiEnergy ); 80 80 STATIC void writeCloudyDetails( void ); 81 81 STATIC long addComment( const char *CommentToAdd ); … … 128 128 punchFITS_PrimaryHeader( false ); 129 129 punchFITS_GenericHeader( rfield.nflux - 1 ); 130 punchFITS_GenericData( rfield.nflux -1 );130 punchFITS_GenericData( rfield.nflux -1, 0, rfield.nflux -2 ); 131 131 } 132 132 /* These are specially designed XSPEC outputs. */ … … 673 673 } 674 674 675 STATIC void punchFITS_GenericData( long numEnergies )675 STATIC void punchFITS_GenericData( long numEnergies, long ipLoEnergy, long ipHiEnergy ) 676 676 { 677 677 long i; … … 683 683 TransmittedSpectrum = (realnum*)MALLOC(sizeof(realnum)*(unsigned)(numEnergies) ); 684 684 685 cdSPEC2( 8, numEnergies, TransmittedSpectrum );685 cdSPEC2( 8, numEnergies, ipLoEnergy, ipHiEnergy, TransmittedSpectrum ); 686 686 687 687 /* Now add the energies data */ -
trunk/source/punch_line.cpp
r1960 r2036 343 343 if(nLine>=LIMLINE ) 344 344 { 345 fprintf(ioQQQ," PUNCH RT has too many lines - increase LIMLINE in punch_line.c \n");345 fprintf(ioQQQ," PUNCH RT has too many lines - increase LIMLINE in punch_line.cpp\n"); 346 346 cdEXIT(EXIT_FAILURE); 347 347 } -
trunk/tsuite/auto/ism_grid.in
r1840 r2036 39 39 punch heating "ism_grid.het" 40 40 punch coolign "ism_grid.col" 41 punch xspec mtable "ism_grid.fit" 41 punch xspec mtable "ism_grid.fit" range 0.1 3 keV 42 42 punch temperature "ism_grid.tem" 43 43 c
