Skip to content

Commit

Permalink
Ensuring ratio_sm is always well defined
Browse files Browse the repository at this point in the history
  • Loading branch information
cdplagos committed Jul 15, 2024
1 parent 747e9ca commit e70ecda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,14 @@ void Environment::process_satellite_subhalo_environment(Subhalo &satellite_subha

// compute how much has been lost since galaxy infall
float ratio_sm = std::pow(2, 3.57) * std::pow(ratio_mass, 2.06) / std::pow( 1 + ratio_mass, 3.57);
lost_stellar.mass = ratio_sm * satellite_subhalo.type1_galaxy()->star_central_infall.mass;
if(ratio_sm < 0){
ratio_sm = 0;
}
if(ratio_sm > 1){
ratio_sm = 1;
}

lost_stellar.mass = (1 - ratio_sm) * satellite_subhalo.star_central_infall.mass;

if(lost_stellar.mass < 0){
lost_stellar.restore_baryon();
Expand All @@ -288,7 +295,7 @@ void Environment::process_satellite_subhalo_environment(Subhalo &satellite_subha
// is stars_tidal_stripped.mass>0 is because stripping should have occurred already.
if(satellite.stars_tidal_stripped.mass == 0){
// compute how much has been lost since galaxy infall
lost_stellar.mass = ratio_sm * satellite.star_central_infall.mass;
lost_stellar.mass = (1 - ratio_sm) * satellite.stellar_mass();

lost_stellar = remove_tidal_stripped_stars(central_subhalo, satellite, lost_stellar);

Expand Down
7 changes: 3 additions & 4 deletions src/evolve_halos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ void adjust_main_galaxy(const SubhaloPtr &parent, const SubhaloPtr &descendant)
// Define the stellar content of the central at the moment of infall. So this applies only to subhalos that are currently central but will become
// satellite in the next snapshot. In this case also transfer stellar halo of the subhalo to the main progenitor subhalo.
if(parent_is_central && !desc_is_central){
// stellar mass at infall for galaxies type 1-2 (2 do not have a subhalo attached)
main_galaxy->star_central_infall.mass = main_galaxy->stellar_mass();
main_galaxy->star_central_infall.mass_metals = main_galaxy->stellar_mass_metals();

// stellar mass at infall for galaxies type 1-2 (2 do not have a subhalo attached)
//main_galaxy->star_central_infall.mass = main_galaxy->stellar_mass();
//main_galaxy->star_central_infall.mass_metals = main_galaxy->stellar_mass_metals();
// stellar mass at infall for galaxies type 1 (have a subhalo attached)
descendant->star_central_infall.mass = main_galaxy->stellar_mass();
descendant->star_central_infall.mass_metals = main_galaxy->stellar_mass_metals();
Expand Down

0 comments on commit e70ecda

Please sign in to comment.