Skip to content

Commit

Permalink
Simplifying calculation in define_central_subhalo
Browse files Browse the repository at this point in the history
Only the Mvir definition is now inside the if of apply_fix_mass
swapping.
  • Loading branch information
cdplagos committed Jul 1, 2024
1 parent 8932d9e commit c86d1d0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/tree_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.**/
Expand Down

0 comments on commit c86d1d0

Please sign in to comment.