From b5b44fdead4efab665ee774092966dccb61c02cc Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Mon, 6 Jun 2011 10:58:55 -0400 Subject: [PATCH] More cosmological parameters --- src/h5_readFlash.cpp | 27 ++++++++++++++++++++++----- src/h5_readFlash.hpp | 5 ++++- src/loadFlash.cpp | 8 ++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/h5_readFlash.cpp b/src/h5_readFlash.cpp index b6b82a3..0c7b11d 100644 --- a/src/h5_readFlash.cpp +++ b/src/h5_readFlash.cpp @@ -23,8 +23,11 @@ int ipvz_out = 5; void h5_read_runtime_parameters (H5File* file, /* file handle */ - double* LBox, // box size - int* numPart) // number of particles + double* LBox, // box size + int* numPart, + double *hubble, + double *omegam, + double *omegalambda) // number of particles { int MAX_PARM = 200; @@ -47,6 +50,8 @@ void h5_read_runtime_parameters str_runtime_params_t *str_rt_parms; log_runtime_params_t *log_rt_parms; + double omegarad; + int i; nint_runtime_parameters = MAX_PARM; @@ -141,18 +146,30 @@ void h5_read_runtime_parameters /* done with reals */ // grab the data we want - for (i = 0; i < nreal_runtime_parameters; i++) { + for (i = 0; i < nreal_runtime_parameters; i++) { if (strncmp(real_runtime_parameter_names[i],"xmax",4) == 0 ) { *LBox = real_runtime_parameter_values[i]; } + if (strncmp(int_runtime_parameter_names[i],"hubbleconstant", 14) == 0 ) { + *hubble = real_runtime_parameter_values[i]; + } + if (strncmp(int_runtime_parameter_names[i],"omegamatter", 11) == 0 ) { + *omegam = real_runtime_parameter_values[i]; + } + if (strncmp(int_runtime_parameter_names[i],"omegaradiation", 11) == 0 ) { + omegarad = real_runtime_parameter_values[i]; + } } - - for (i = 0; i < nint_runtime_parameters; i++) { + + for (i = 0; i < nint_runtime_parameters; i++) { if (strncmp(int_runtime_parameter_names[i],"pt_numx",7) == 0 ) { *numPart = int_runtime_parameter_values[i]; *numPart = *numPart * *numPart * *numPart; } } + + *omegalambda = 1-(*omegam)-omegarad; + } diff --git a/src/h5_readFlash.hpp b/src/h5_readFlash.hpp index aee38e5..0d7d3f1 100644 --- a/src/h5_readFlash.hpp +++ b/src/h5_readFlash.hpp @@ -14,7 +14,10 @@ using namespace H5; void h5_read_runtime_parameters (H5File* file, /* file handle */ double* LBox, - int* numPart); + int* numPart, + double* hubble, + double* omegam, + double* omegalambda); void h5_read_flash3_particles (H5File* file, int* totalparticles, diff --git a/src/loadFlash.cpp b/src/loadFlash.cpp index f732cb8..de665d8 100644 --- a/src/loadFlash.cpp +++ b/src/loadFlash.cpp @@ -20,11 +20,12 @@ SimuData *CosmoTool::loadFlashMulti(const char *fname, int id, int loadflags) H5File *fileID; H5std_string filename; //char filename[81]; - double lbox, time; + double lbox, time, hubble, omegam, omegalambda; int npart; const double kpc2cm = 3.08568025e21; const double km2cm = 1.e5; + const double hubble2cm = 3.240779270005e-18; if (id != 0) throw NoSuchFileException(); @@ -42,9 +43,12 @@ SimuData *CosmoTool::loadFlashMulti(const char *fname, int id, int loadflags) h5_read_flash3_header_info(&file, &time); data->time = time; - h5_read_runtime_parameters(&file, &lbox, &npart); + h5_read_runtime_parameters(&file, &lbox, &npart, &hubble, &omegam, &omegalambda); data->TotalNumPart = data->NumPart = npart; data->BoxSize = lbox/kpc2cm; + data->Hubble = hubble/hubble2cm; + data->Omega_M = omegam; + data->Omega_Lambda = omegalambda; // particle data for (int i = 0; i < 3; i++) {