Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trees issues fixes #15

Closed
wants to merge 27 commits into from
Closed

Trees issues fixes #15

wants to merge 27 commits into from

Conversation

cdplagos
Copy link
Collaborator

@cdplagos cdplagos commented Jun 27, 2024

Took code implemented by Angel Chandro and made several changes:

  • fixed the calculation for satellite subhalos to use the redshift at infall rather than the current redshift
  • separate the functions to redefine subhalo properties to have one for central and another for satellite subhalos. This was necessary as they need to be called in different places.
  • added an input parameter controlling whether we want (or not) to apply the fix to the mass swapping events.
  • Added a function on dark_matter_halos to redefine the angular momentum vector of subhalos in the case we use lambda_random.

Summary by Sourcery

This pull request addresses several issues related to the handling of subhalo properties, particularly for satellite subhalos. It introduces new features to control mass swapping events, separates functions for central and satellite subhalos, and fixes the calculation of properties using redshift at infall. The CI workflow and build system have been enhanced to improve testing and documentation processes.

  • New Features:
    • Added a function to redefine the angular momentum vector of subhalos when using lambda_random.
    • Introduced a new input parameter to control the application of fixes to mass swapping events.
    • Separated functions to redefine subhalo properties for central and satellite subhalos.
  • Bug Fixes:
    • Fixed the calculation for satellite subhalos to use the redshift at infall rather than the current redshift.
  • Enhancements:
    • Updated the calculation of halo virial radius and lambda to use properties at infall for satellite subhalos.
    • Enhanced the handling of subhalo properties by introducing checks and redefinitions based on infall properties.
  • Build:
    • Updated the build system to use Ninja for faster builds and added support for OpenMP on MacOS.
  • CI:
    • Refactored the CI workflow to include steps for downloading test datasets, running initial shark runs, and checking HDF5 properties documentation.
    • Added CI steps to check reproducibility of shark runs with fixed and random seeds.
  • Documentation:
    • Added a CI step to ensure HDF5 properties documentation is up to date.
  • Tests:
    • Added tests to check the reproducibility of shark runs with fixed seeds and multithreading.
    • Updated tests to include new input parameters and configurations.
  • Chores:
    • Updated the CMake configuration to find and use Boost 1.68 and OpenMP 2.0 or higher.

rtobar and others added 27 commits September 14, 2023 10:04
These were producing warnings, and thus prevented us from turning on
-Werror on CI, which is something we'd like to have. I checked with
Claudia, and she said it was safe to remove these.

Signed-off-by: Rodrigo Tobar <[email protected]>
This was issuing a warning, so let's get rid of it.

Signed-off-by: Rodrigo Tobar <[email protected]>
Also make sure our CI jobs check that it doesn't go out of sync.

Signed-off-by: Rodrigo Tobar <[email protected]>
The latter has been deprecated since numpy 1.6, and effectively removed
in the latest versions of numpy. The "density" argument has equivalent
semantics, and the documentation states that it should be used instead.

Signed-off-by: Rodrigo Tobar <[email protected]>
This flag contains the *space-separated* flags that are needed for
compiling OpenMP programs. This is not the format expected by
add_compile_options though, so we need to turn the string into a list
before passing it on.

Signed-off-by: Rodrigo Tobar <[email protected]>
There were a few things that were not correctly done around OpenMP
checks that are being corrected here, namely:

 * Change DECLARED -> DEFINED, since the former doesn't mean anything
   (so this code has been always wrong).
 * Change OPENMP_FOUND -> OpenMP_FOUND, with the latter being the more
   generic way of checking the result of find_package.
 * Use the correct casing for the rest of OpenMP* variable, which were
   previously uppercased in our code.
 * Add a check for the OpenMP_CXX_VERSION variable in particular, which
   might be set while OpenMP_VERSION might not.

Signed-off-by: Rodrigo Tobar <[email protected]>
This new port now tries to *not* rely too much on GitHub Actions
conventions (which are not that many, anyway), and also splits the big
test.sh script we used with Travis into smaller scripts in a new .ci
directory that can be invoked separately, therefore allowing us to model
each individual test as a different step on the GitHub Actions workflow.

Signed-off-by: Rodrigo Tobar <[email protected]>
Signed-off-by: Rodrigo Tobar <[email protected]>
The new file had been added to the tree, but wasn't included anywhere in
the documentation, duh!

Signed-off-by: Rodrigo Tobar <[email protected]>
The implicit build.image is deprecated, so let's use the new build.os
key explicitly instead.

Signed-off-by: Rodrigo Tobar <[email protected]>
We used to depend on >= 1.54, but in a809629 we accidentally raised the
minimum required Boost version to 1.68 (boost::optional::has_value() was
introduced in that version to align with std::optional). This version of
Boost is 5 years old though, so instead of modifying our code to cope
with older versions, we're probably better off declaring a higher
minimum version.

This was the original cause of #13, and thus it should prevent this
issue from happening again in the near future.

Signed-off-by: Rodrigo Tobar <[email protected]>
The option defaults to false, and indicates whether the lognormal
distribution used to draw lambda values should use a fix value of 0.03,
or a dynamic value based on the halo spin distribution following Kim et
al. (2015), as its m parameter (the natural logarithm of the
distribution's mean).

The Lagos et al. (2023) paper used this dependency, and therefore we're
also updating the sample configuration file that reflects that paper to
ensure reproducibility.

Signed-off-by: Rodrigo Tobar <[email protected]>
…current properties or at infall for satellites
…ent properties or at infall for satellites. Massive transients: read catalogue with halos affected by this
- separated the function to redefine subhalo properties into centrals
and satellites. This is done because the one for centrals needs to be
called before the function that defines ages, while the satellite one
needs to be called afterwards.

- Fixed the calculation for satellite subhalos to use the infall
redshift rather than the current redshift (given that it was using all
the properties at infall).
This leads to many changes to make sure one can run the previous model
without the fixing of mass swapping events (to help with
reproduceability).

Another change is to make sure the angular momentum vector L of subhalos
is redefine in the cases where lambda_random is used.
I also changed added a bool input to evolve_galaxy to indicate whether
we want to apply the fix for the mass swapping cases.
Copy link

sourcery-ai bot commented Jun 27, 2024

Reviewer's Guide by Sourcery

This pull request addresses several issues related to the handling of subhalos in the 'Trees' module. The changes include fixing the calculation for satellite subhalos to use the redshift at infall, separating functions for central and satellite subhalos, adding an input parameter to control mass swapping event fixes, and redefining the angular momentum vector of subhalos when using lambda_random.

File-Level Changes

Files Changes
src/dark_matter_halos.cpp
src/tree_builder.cpp
src/merger_tree_reader.cpp
src/gas_cooling.cpp
src/galaxy_mergers.cpp
src/disk_instability.cpp
src/environment.cpp
src/shark_runner.cpp
src/evolve_halos.cpp
src/agn_feedback.cpp
Updated various modules to handle new subhalo properties, including redshift at infall, mass swapping event fixes, and angular momentum redefinition.
include/physical_model.h
include/subhalo.h
include/dark_matter_halos.h
include/merger_tree_reader.h
include/galaxy.h
include/disk_instability.h
include/galaxy_mergers.h
include/tree_builder.h
include/simulation.h
Added new parameters and functions to handle subhalo properties at infall and mass swapping event fixes.
.github/workflows/build-and-test.yaml
.travis/test.sh
.ci/check_hdf5_docs.sh
.github/actions/download-shark-build/action.yaml
.github/workflows/build-docs.yml
.github/actions/setup-config-file/action.yaml
.ci/run_shark.sh
.ci/compare_galaxies.sh
Updated CI/CD workflows and scripts to handle new subhalo properties and added new test configurations.
CMakeLists.txt
.readthedocs.yaml
sample.cfg
sample_lagos23.cfg
Updated configuration files to handle new subhalo properties and build configurations.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@cdplagos cdplagos self-assigned this Jun 27, 2024
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @cdplagos - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt install libhdf5-dev hdf5-tools libboost-filesystem-dev libboost-program-options-dev libboost-log-dev cxxtest libgsl-dev
sudo apt install ninja-build libhdf5-dev hdf5-tools libboost-filesystem-dev libboost-program-options-dev libboost-log-dev cxxtest libgsl-dev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding -y flag to apt install

Adding the -y flag to apt install can help automate the installation process by automatically agreeing to the installation of packages.

Suggested change
sudo apt install ninja-build libhdf5-dev hdf5-tools libboost-filesystem-dev libboost-program-options-dev libboost-log-dev cxxtest libgsl-dev
sudo apt install -y ninja-build libhdf5-dev hdf5-tools libboost-filesystem-dev libboost-program-options-dev libboost-log-dev cxxtest libgsl-dev

* ``bh_accretion_rate_hh_history``: Black hole accretion rate due to hot halo cooling [Msun/yr/h].
* ``bh_accretion_rate_sb_history``: Black hole accretion rate due to starbursts [Msun/yr/h].
* ``bh_spin``: Black hole spin history [dimensionless].
* ``id_galaxy``: galaxy ID. Unique to this galaxy throughout time. If this galaxy never mergers onto a central, then its ID is always the same.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (documentation): Fix typo in documentation.

The word 'mergers' should be 'merges'.

Copy link
Collaborator Author

@cdplagos cdplagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are ok

@cdplagos cdplagos closed this Jun 27, 2024
@rtobar rtobar deleted the origin/trees-issues-fixes branch July 4, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants