From 563a6c9f0792b6845ecb627e36fc923ec3ed0b44 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Thu, 10 Dec 2020 13:29:07 +0100 Subject: [PATCH 01/15] added a minimum panphasia resolution --- example.conf | 1 + src/plugins/random_panphasia.cc | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/example.conf b/example.conf index db8fa73..92f438e 100644 --- a/example.conf +++ b/example.conf @@ -98,6 +98,7 @@ seed = 12345 # generator = PANPHASIA # descriptor = [Panph1,L10,(800,224,576),S9,CH1564365824,MXXL] +# PanphasiaMinRootResolution = 512 # requires the white noise reallisation to be made at least at that resolution (default is 512) ##> The MUSIC1 multi-scale random number generator is provided for convenience ## warning: MUSIC1 generator is not MPI parallel (yet) (memory is needed for full field on each task) diff --git a/src/plugins/random_panphasia.cc b/src/plugins/random_panphasia.cc index afd7b5f..90c7746 100644 --- a/src/plugins/random_panphasia.cc +++ b/src/plugins/random_panphasia.cc @@ -171,10 +171,12 @@ protected: { // if ngrid is not a multiple of i_base, then we need to enlarge and then sample down ngrid_ = pcf_->get_value("setup", "GridRes"); + size_t ngidminsize_panphasia = pcf_->get_value_safe("random", "PanphasiaMinRootResolution",512); grid_p_ = pdescriptor_->i_base; - lextra_ = (log10((double)ngrid_ / (double)grid_p_) + 0.001) / log10(2.0); + lextra_ = (log10((double)std::max(ngrid_,ngidminsize_panphasia) / (double)grid_p_) + 0.001) / log10(2.0); + // lmin ngrid_panphasia_ = (1 << lextra_) * grid_p_; From bce685d10276939a01c1ffb24029d949ff4a704c Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Thu, 10 Dec 2020 15:55:36 +0100 Subject: [PATCH 02/15] fixed a compiler error just introduced --- src/plugins/random_panphasia.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/random_panphasia.cc b/src/plugins/random_panphasia.cc index 90c7746..123c0e2 100644 --- a/src/plugins/random_panphasia.cc +++ b/src/plugins/random_panphasia.cc @@ -175,7 +175,7 @@ protected: grid_p_ = pdescriptor_->i_base; - lextra_ = (log10((double)std::max(ngrid_,ngidminsize_panphasia) / (double)grid_p_) + 0.001) / log10(2.0); + lextra_ = (log10((double)std::max(ngrid_,ngidminsize_panphasia) / (double)grid_p_) + 0.001) / log10(2.0); // lmin ngrid_panphasia_ = (1 << lextra_) * grid_p_; From 315790a1292de8ca29b3315c38e47fa7cb73877e Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Thu, 10 Dec 2020 17:06:33 +0100 Subject: [PATCH 03/15] one more tuning of panphasia minimum noise grid size --- src/plugins/random_panphasia.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/random_panphasia.cc b/src/plugins/random_panphasia.cc index 123c0e2..1244699 100644 --- a/src/plugins/random_panphasia.cc +++ b/src/plugins/random_panphasia.cc @@ -171,21 +171,21 @@ protected: { // if ngrid is not a multiple of i_base, then we need to enlarge and then sample down ngrid_ = pcf_->get_value("setup", "GridRes"); - size_t ngidminsize_panphasia = pcf_->get_value_safe("random", "PanphasiaMinRootResolution",512); + int ngidminsize_panphasia = pcf_->get_value_safe("random", "PanphasiaMinRootResolution",512); grid_p_ = pdescriptor_->i_base; - lextra_ = (log10((double)std::max(ngrid_,ngidminsize_panphasia) / (double)grid_p_) + 0.001) / log10(2.0); - // lmin + lextra_ = (log10((double)ngrid_ / (double)grid_p_) + 0.001) / log10(2.0); + // lmin ngrid_panphasia_ = (1 << lextra_) * grid_p_; - - if( ngrid_panphasia_ < ngrid_ ){ + + if( ngrid_panphasia_ < ngidminsize_panphasia ){ lextra_++; ngrid_panphasia_*=2; } - assert( ngrid_panphasia_ >= ngrid_ ); - + assert( ngrid_panphasia_ >= ngidminsize_panphasia); + clear_panphasia_thread_states(); music::ilog.Print("PANPHASIA: using grid size %lld (level=%d)",ngrid_panphasia_, lextra_); From 0c4cb7e5aeeed21996c22945bccb2cdec59aaaf0 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Sun, 13 Dec 2020 11:19:45 +0100 Subject: [PATCH 04/15] final polishing touches to PANPHASIA plugin as suggested by Adrian Jenkins --- src/plugins/random_panphasia.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/random_panphasia.cc b/src/plugins/random_panphasia.cc index 1244699..d40e36b 100644 --- a/src/plugins/random_panphasia.cc +++ b/src/plugins/random_panphasia.cc @@ -171,7 +171,7 @@ protected: { // if ngrid is not a multiple of i_base, then we need to enlarge and then sample down ngrid_ = pcf_->get_value("setup", "GridRes"); - int ngidminsize_panphasia = pcf_->get_value_safe("random", "PanphasiaMinRootResolution",512); + int ngridminsize_panphasia = pcf_->get_value_safe("random", "PanphasiaMinRootResolution",512); grid_p_ = pdescriptor_->i_base; @@ -180,15 +180,18 @@ protected: ngrid_panphasia_ = (1 << lextra_) * grid_p_; - if( ngrid_panphasia_ < ngidminsize_panphasia ){ + while( ngrid_panphasia_ < ngridminsize_panphasia ){ lextra_++; ngrid_panphasia_*=2; } - assert( ngrid_panphasia_ >= ngidminsize_panphasia); + assert( ngrid_panphasia_ >= ngridminsize_panphasia); + clear_panphasia_thread_states(); music::ilog.Print("PANPHASIA: using grid size %lld (level=%d)",ngrid_panphasia_, lextra_); + if (ngridminsize_panphasia<512) + music::ilog.Print("PANPHASIA WARNING: PanphasiaMinRootResolution = %d below minimum recommended of 512",ngridminsize_panphasia); music::ilog.Print("PANPHASIA: running with %d threads", num_threads_, ngrid_panphasia_ ); coordinate_system_shift_[0] = -pcf_->get_value_safe("setup", "shift_x", 0); From c28dc782e373bf1c32a1b240017f1ae5e4e2a799 Mon Sep 17 00:00:00 2001 From: Michael Buehlmann Date: Mon, 28 Dec 2020 23:25:11 -0600 Subject: [PATCH 05/15] fix genericio plugin --- src/plugins/output_genericio.cc | 55 ++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/plugins/output_genericio.cc b/src/plugins/output_genericio.cc index b5ba88e..f77bef8 100644 --- a/src/plugins/output_genericio.cc +++ b/src/plugins/output_genericio.cc @@ -10,7 +10,7 @@ protected: real_t lunit_, vunit_, munit_; bool hacc_hydro_; float hacc_etamax_; - float hh_value_, rho_value_, mu_value_; + float hh_value_, rho_value_, mu_value_, uu_value_; std::vector ids; std::vector xx, yy, zz; std::vector vx, vy, vz; @@ -20,22 +20,43 @@ protected: public: //! constructor - explicit genericio_output_plugin(config_file &cf, cosmology::calculator &cc) - : output_plugin(cf, cc, "GenericIO") + explicit genericio_output_plugin(config_file &cf, std::unique_ptr &pcc) + : output_plugin(cf, pcc, "GenericIO") { - real_t astart = 1.0 / (1.0 + cf_.get_value("setup", "zstart")); + const double astart = 1.0 / (1.0 + cf_.get_value("setup", "zstart")); + const double hubble_param = pcc->cosmo_param_["h"]; lunit_ = cf_.get_value("setup", "BoxLength"); vunit_ = lunit_/astart; hacc_hydro_ = cf_.get_value_safe("output", "GenericIO_HACCHydro", false); // initial smoothing length is mean particle seperation hh_value_ = lunit_ / cf_.get_value("setup", "GridRes"); - // neutral value for molecular weight. FIXME: account for ionization? - const float primordial_x = 0.75; - mu_value_ = 4.0 / (1.0 + 3.0*primordial_x); - + double rhoc = 27.7519737 * 1e10; // in h^2 M_sol / Mpc^3 - rho_value_ = cc_.cosmo_param_["Omega_b"] * rhoc; munit_ = rhoc * std::pow(cf_.get_value("setup", "BoxLength"), 3); + + if(hacc_hydro_) { + const double omegab = pcc_->cosmo_param_["Omega_b"]; + const double gamma = cf_.get_value_safe("cosmology", "gamma", 5.0 / 3.0); + const double YHe = pcc_->cosmo_param_["YHe"]; + const double Tcmb0 = pcc_->cosmo_param_["Tcmb"]; + + // compute gas internal energy + const double npol = (fabs(1.0 - gamma) > 1e-7) ? 1.0 / (gamma - 1.) : 1.0; + const double unitv = 1e5; // km/s to cm/s + const double adec = 1.0 / (160. * std::pow(omegab * hubble_param * hubble_param / 0.022, 2.0 / 5.0)); + const double Tini = astart < adec ? Tcmb0 / astart : Tcmb0 / astart / astart * adec; + const double mu = (Tini > 1.e4) ? 4.0 / (8. - 5. * YHe) : 4.0 / (1. + 3. * (1. - YHe)); + const double ceint = 1.3806e-16 / 1.6726e-24 * Tini * npol / mu / unitv / unitv; + + uu_value_ = ceint/astart/astart; // probably needs a scale factor correction (might be in physical units). + mu_value_ = mu; + + music::ilog.Print("HACC : calculated redshift of decoupling: z_dec = %.2f", 1./adec - 1.); + music::ilog.Print("HACC : set initial gas temperature to %.2e K/mu", Tini / mu); + music::ilog.Print("HACC : set initial internal energy to %.2e km^2/s^2", ceint); + + rho_value_ = omegab * rhoc; + } } output_type write_species_as(const cosmo_species &) const { return output_type::particles; } @@ -65,17 +86,15 @@ public: vz.reserve(vz.size() + npart); ids.reserve(ids.size() + npart); - - auto _pos = reinterpret_cast(pc.get_pos32_ptr()); auto _vel = reinterpret_cast(pc.get_vel32_ptr()); auto _ids = reinterpret_cast(pc.get_ids64_ptr()); auto _mass = reinterpret_cast(pc.get_mass32_ptr()); for(size_t i=0; i creator("genericio"); +output_plugin_creator_concrete creator1("genericio"); } // namespace #endif // ENABLE_GENERICIO \ No newline at end of file From 622b61cac79f4e02bbbda51f254c942d2311c498 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 17:33:27 +0100 Subject: [PATCH 06/15] Set the smoothing-lengths to the mean inter-particle separation including the correct h-scaling --- src/plugins/output_swift.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index e66ee2c..8008155 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -152,7 +152,11 @@ public: std::vector data( npart_[0], ceint ); HDFWriteDataset(this_fname_, "PartType0/InternalEnergy", data); - data.assign( npart_[0], boxsize_ / cf_.get_value("setup","GridRes") ); + const double h = boxsize_ / hubble_param_ / cf_.get_value("setup","GridRes"); + + music::ilog.Print("Swift : set initial smoothing length to mean inter-part separation: %.2f Mpc", h); + + data.assign( npart_[0], h); HDFWriteDataset(this_fname_, "PartType0/SmoothingLength", data); } From e3606275ad80a582c9982cfcd0189736b39fabad Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 17:39:28 +0100 Subject: [PATCH 07/15] Moved the neutrinos to type 6 in the SWIFT plugin --- src/plugins/output_swift.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 8008155..8f74325 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -73,7 +73,7 @@ public: blongids_ = cf_.get_value_safe("output", "UseLongids", false); bdobaryons_ = cf_.get_value("setup","DoBaryons"); - for (int i = 0; i < 6; ++i) + for (int i = 0; i < 7; ++i) { npart_[i] = 0; npartTotal_[i] = 0; @@ -196,7 +196,7 @@ public: case cosmo_species::baryon: return 0; case cosmo_species::neutrino: - return 3; + return 6; } return -1; } From e9ebdc9e5decac5ba47549b2abb947c76e820fa2 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 17:49:24 +0100 Subject: [PATCH 08/15] Extended all the header arrays to have 7 entries in the SWIFT output plugin --- src/plugins/output_swift.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 8f74325..164b87a 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -22,9 +22,9 @@ #include "HDF_IO.hh" template -std::vector from_6array(const std::array& a) +std::vector from_7array(const std::array& a) { - return std::vector{{a[0], a[1], a[2], a[3], a[4], a[5]}}; + return std::vector{{a[0], a[1], a[2], a[3], a[4], a[5], a[6]}}; } template @@ -45,8 +45,8 @@ protected: bool blongids_, bdobaryons_; std::string this_fname_; - std::array npart_, npartTotal_, npartTotalHighWord_; - std::array mass_; + std::array npart_, npartTotal_, npartTotalHighWord_; + std::array mass_; double time_; public: @@ -119,10 +119,10 @@ public: HDFWriteGroupAttribute(fname_, "Header", "Dimension", 3); HDFWriteGroupAttribute(fname_, "Header", "BoxSize", lunit_); // in Mpc, not Mpc/h - HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_Total", from_6array(npartTotal_)); - HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_Total_HighWord", from_6array(npartTotalHighWord_)); - HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_ThisFile", from_6array(npart_)); - HDFWriteGroupAttribute(this_fname_, "Header", "MassTable", from_6array(mass_)); + HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_Total", from_7array(npartTotal_)); + HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_Total_HighWord", from_7array(npartTotalHighWord_)); + HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_ThisFile", from_7array(npart_)); + HDFWriteGroupAttribute(this_fname_, "Header", "MassTable", from_7array(mass_)); HDFWriteGroupAttribute(this_fname_, "Header", "Time", from_value(time_)); HDFWriteGroupAttribute(this_fname_, "Header", "Flag_Entropy_ICs", from_value(0)); From 3a67c50f36b9642bce8394a363a031bb12d8d113 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 17:56:06 +0100 Subject: [PATCH 09/15] Write the redshift in the header of SWIFT ICs since the code will check that against the value provided in the param file upon startup --- src/plugins/output_swift.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 164b87a..3dc16a6 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -41,7 +41,7 @@ protected: int num_files_, num_simultaneous_writers_; real_t lunit_, vunit_, munit_; - real_t boxsize_, hubble_param_, astart_; + real_t boxsize_, hubble_param_, astart_, zstart_; bool blongids_, bdobaryons_; std::string this_fname_; @@ -63,7 +63,8 @@ public: const double rhoc = 27.7519737; // in h^2 1e10 M_sol / Mpc^3 hubble_param_ = pcc->cosmo_param_["h"]; - astart_ = 1.0/(1.0+cf_.get_value("setup","zstart")); + zstart_ = cf_.get_value("setup","zstart"); + astart_ = 1.0/(1.0 + zstart_); boxsize_ = cf_.get_value("setup", "BoxLength"); lunit_ = boxsize_ / hubble_param_; // final units will be in Mpc (without h) @@ -125,6 +126,7 @@ public: HDFWriteGroupAttribute(this_fname_, "Header", "MassTable", from_7array(mass_)); HDFWriteGroupAttribute(this_fname_, "Header", "Time", from_value(time_)); + HDFWriteGroupAttribute(this_fname_, "Header", "Redshift", from_value(zstart_)); HDFWriteGroupAttribute(this_fname_, "Header", "Flag_Entropy_ICs", from_value(0)); HDFWriteGroupAttribute(this_fname_, "Header", "NumFilesPerSnapshot", from_value(num_files_)); From 408cefa1b376ba52daf0caae16e6cf160669c85a Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 18:55:25 +0100 Subject: [PATCH 10/15] Write some information about the monofonIC code into the generated IC file --- src/plugins/output_swift.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 3dc16a6..3973ff6 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -106,9 +106,15 @@ public: HDFWriteGroupAttribute(this_fname_, "Units", "Unit current in cgs (U_I)", 1.0); // 1 Ampere HDFWriteGroupAttribute(this_fname_, "Units", "Unit temperature in cgs (U_T)", 1.0); // 1 Kelvin - // TODO: Write MUSIC configuration header - HDFCreateGroup(fname_, "ICs_parameters"); - // ... + // Write MUSIC configuration header + HDFCreateGroup(this_fname_, "ICs_parameters"); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Code", std::string("MUSIC2 - monofonIC")); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Git Revision", std::string(GIT_REV)); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Git Tag", std::string(GIT_TAG)); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Git Branch", std::string(GIT_BRANCH)); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Precision", std::string(CMAKE_PRECISION_STR)); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Convolutions", std::string(CMAKE_CONVOLVER_STR)); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "PLT", std::string(CMAKE_PLT_STR)); } // use destructor to write header post factum From 646968423ce123c449c833cd51b6bc44b254f426 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 19:01:52 +0100 Subject: [PATCH 11/15] Update the units block written to the ICs by the SWIFT plugin to use the same constants as assumed internally by SWIFT. --- src/plugins/output_swift.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 3973ff6..970f2a1 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -98,13 +98,13 @@ public: // create output HDF5 file HDFCreateFile(this_fname_); - // Write UNITS header + // Write UNITS header using the physical constants assumed internally by SWIFT HDFCreateGroup(this_fname_, "Units"); - HDFWriteGroupAttribute(this_fname_, "Units", "Unit mass in cgs (U_M)", 1.98848e43); // 10^10 Msun in grams - HDFWriteGroupAttribute(this_fname_, "Units", "Unit length in cgs (U_L)", 3.08567758e24); // 1 Mpc in cm - HDFWriteGroupAttribute(this_fname_, "Units", "Unit time in cgs (U_t)", 3.08567758e19); // so that unit vel is 1 km/s - HDFWriteGroupAttribute(this_fname_, "Units", "Unit current in cgs (U_I)", 1.0); // 1 Ampere - HDFWriteGroupAttribute(this_fname_, "Units", "Unit temperature in cgs (U_T)", 1.0); // 1 Kelvin + HDFWriteGroupAttribute(this_fname_, "Units", "Unit mass in cgs (U_M)", 1.98841e43); // 10^10 Msun in grams + HDFWriteGroupAttribute(this_fname_, "Units", "Unit length in cgs (U_L)", 3.08567758149e24); // 1 Mpc in cm + HDFWriteGroupAttribute(this_fname_, "Units", "Unit time in cgs (U_t)", 3.08567758149e19); // so that unit vel is 1 km/s + HDFWriteGroupAttribute(this_fname_, "Units", "Unit current in cgs (U_I)", 1.0); // 1 Ampere + HDFWriteGroupAttribute(this_fname_, "Units", "Unit temperature in cgs (U_T)", 1.0); // 1 Kelvin // Write MUSIC configuration header HDFCreateGroup(this_fname_, "ICs_parameters"); From e9a6a1aa589e0d29d97b1c3ed15723b0a9e139f0 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 19:07:58 +0100 Subject: [PATCH 12/15] Small fixes --- src/plugins/output_swift.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 970f2a1..5b397f5 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -124,7 +124,7 @@ public: { HDFCreateGroup(this_fname_, "Header"); HDFWriteGroupAttribute(fname_, "Header", "Dimension", 3); - HDFWriteGroupAttribute(fname_, "Header", "BoxSize", lunit_); // in Mpc, not Mpc/h + HDFWriteGroupAttribute(fname_, "Header", "BoxSize", boxsize_ / hubble_param_); // in Mpc, not Mpc/h HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_Total", from_7array(npartTotal_)); HDFWriteGroupAttribute(this_fname_, "Header", "NumPart_Total_HighWord", from_7array(npartTotalHighWord_)); @@ -137,7 +137,7 @@ public: HDFWriteGroupAttribute(this_fname_, "Header", "NumFilesPerSnapshot", from_value(num_files_)); - // write GAS internal energy if baryons are enabled + // write GAS internal energy and smoothing length if baryons are enabled if( bdobaryons_ ) { const double gamma = cf_.get_value_safe("cosmology", "gamma", 5.0 / 3.0); From 012c306e30727bc2a7948829eabc315cf2ff3590 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 19:29:23 +0100 Subject: [PATCH 13/15] Fix a bug where the wrong file name was used in the output plugin super-class in MPI mode --- src/plugins/output_swift.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 5b397f5..e9dea7b 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -92,6 +92,10 @@ public: this_fname_ += "." + std::to_string(thisrank); #endif + // Now that we modified the filename for MPI support, propagate the change to the super-class + // as it does operations on the file behind our back. + fname_ = this_fname_; + // delete output file if it exists unlink(this_fname_.c_str()); From cf7060dc1a7860122a3f1f14e5ad219dca5d5418 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sun, 28 Feb 2021 19:31:32 +0100 Subject: [PATCH 14/15] Print the initial energy as well as the initial temperature to the screen --- src/plugins/output_swift.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index e9dea7b..1c7335c 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -159,7 +159,8 @@ public: const double mu = (Tini > 1.e4) ? 4.0 / (8. - 5. * YHe) : 4.0 / (1. + 3. * (1. - YHe)); const double ceint = 1.3806e-16 / 1.6726e-24 * Tini * npol / mu / unitv / unitv; - music::ilog.Print("Swift : set initial gas temperature to %.2f K/mu", Tini / mu); + music::ilog.Print("Swift : Calculated initial gas temperature: %.2f K/mu", Tini / mu); + music::ilog.Print("Swift : set initial internal energy to %.2e km^2/s^2", ceint); std::vector data( npart_[0], ceint ); HDFWriteDataset(this_fname_, "PartType0/InternalEnergy", data); From e6b5b6464f7ba2215b1bbd47fe4c38d961bf3698 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Sat, 13 Mar 2021 21:26:45 +0100 Subject: [PATCH 15/15] Write more information about the IC code to the ICs' header in the SWIFT i/o plugin --- src/plugins/output_swift.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/plugins/output_swift.cc b/src/plugins/output_swift.cc index 1c7335c..636a936 100644 --- a/src/plugins/output_swift.cc +++ b/src/plugins/output_swift.cc @@ -111,6 +111,17 @@ public: HDFWriteGroupAttribute(this_fname_, "Units", "Unit temperature in cgs (U_T)", 1.0); // 1 Kelvin // Write MUSIC configuration header + int order = cf_.get_value("setup", "LPTorder"); + std::string load = cf_.get_value("setup", "ParticleLoad"); + std::string tf = cf_.get_value("cosmology", "transfer"); + std::string cosmo_set = cf_.get_value("cosmology", "ParameterSet"); + std::string rng = cf_.get_value("random", "generator"); + int do_fixing = cf_.get_value("setup", "DoFixing"); + int do_invert = cf_.get_value("setup", "DoInversion"); + int do_baryons = cf_.get_value("setup", "DoBaryons"); + int do_baryonsVrel = cf_.get_value("setup", "DoBaryonVrel"); + int L = cf_.get_value("setup", "GridRes"); + HDFCreateGroup(this_fname_, "ICs_parameters"); HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Code", std::string("MUSIC2 - monofonIC")); HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Git Revision", std::string(GIT_REV)); @@ -119,6 +130,25 @@ public: HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Precision", std::string(CMAKE_PRECISION_STR)); HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Convolutions", std::string(CMAKE_CONVOLVER_STR)); HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "PLT", std::string(CMAKE_PLT_STR)); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "LPT Order", order); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Particle Load", load); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Transfer Function", tf); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Cosmology Parameter Set", cosmo_set); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Random Generator", rng); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Mode Fixing", do_fixing); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Mode inversion", do_invert); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Baryons", do_baryons); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Baryons Relative Velocity", do_baryonsVrel); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Grid Resolution", L); + + if (tf == "CLASS") { + double ztarget = cf_.get_value("cosmology", "ztarget"); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Target Redshift", ztarget); + } + if (rng == "PANPHASIA") { + std::string desc = cf_.get_value("random", "descriptor"); + HDFWriteGroupAttribute(this_fname_, "ICs_parameters", "Descriptor", desc); + } } // use destructor to write header post factum