From c86d1d03d7edd96fe7692dcc34ce5d9e6baf0873 Mon Sep 17 00:00:00 2001 From: Claudia Lagos Date: Mon, 1 Jul 2024 13:51:37 +0800 Subject: [PATCH] Simplifying calculation in define_central_subhalo Only the Mvir definition is now inside the if of apply_fix_mass swapping. --- src/tree_builder.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/tree_builder.cpp b/src/tree_builder.cpp index 4f65ced7..274af97e 100644 --- a/src/tree_builder.cpp +++ b/src/tree_builder.cpp @@ -215,24 +215,27 @@ SubhaloPtr TreeBuilder::define_central_subhalo(HaloPtr &halo, SubhaloPtr &subhal halo->position = subhalo->position; halo->velocity = subhalo->velocity; + double mvir = subhalo->Mvir; // calculate subhalo properties based on halo mass if number of particles is too small or in the case of applying the fix to mass swapping events: if(dark_matter_params.apply_fix_to_mass_swapping_events){ - double mvir = halo->Mvir; - double z= sim_params.redshifts[subhalo->snapshot]; - double npart = mvir/sim_params.particle_mass; + mvir = halo->Mvir; + } - subhalo->concentration = darkmatterhalos->nfw_concentration(mvir, z); + double z= sim_params.redshifts[subhalo->snapshot]; + double npart = mvir/sim_params.particle_mass; - if (subhalo->concentration < 1) { - throw invalid_argument("concentration is <1, cannot continue. Please check input catalogue"); - } - subhalo->lambda = darkmatterhalos->halo_lambda(*subhalo, mvir, z, npart); - subhalo->Vvir = darkmatterhalos->halo_virial_velocity(mvir, z); + subhalo->concentration = darkmatterhalos->nfw_concentration(mvir, z); + + if (subhalo->concentration < 1) { + throw invalid_argument("concentration is <1, cannot continue. Please check input catalogue"); } + subhalo->lambda = darkmatterhalos->halo_lambda(*subhalo, mvir, z, npart); + subhalo->Vvir = darkmatterhalos->halo_virial_velocity(mvir, z); halo->concentration = subhalo->concentration; halo->lambda = subhalo->lambda; + /** If virial velocity of halo (which is calculated from the total mass and redshift) is smaller than the virial velocity of the central subhalo, which is directly calculated in VELOCIraptor, then adopt the VELOCIraptor one.**/