Skip to content

Commit

Permalink
Checking infall properties are always well defined
Browse files Browse the repository at this point in the history
Adding more checks when using infall properties to make we don't
accidentally use the properties when they are not defined.
  • Loading branch information
cdplagos committed Jul 2, 2024
1 parent c86d1d0 commit ff263cb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dark_matter_halos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ double DarkMatterHalos::subhalo_dynamical_time (Subhalo &subhalo, double z){
else{
// When the satellite is born as satellite (no infall properties) or
// when we don't to apply the fix to mass swapping events
r = halo_virial_radius(subhalo.Mvir, z);;
r = halo_virial_radius(subhalo.Mvir, z);
v = subhalo.Vvir;
}

Expand Down
6 changes: 5 additions & 1 deletion src/disk_instability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,16 @@ void DiskInstability::create_starburst(SubhaloPtr &subhalo, Galaxy &galaxy, doub

// grow the BH only if its mass is already > 0 (so the BH has been seeded).
if(galaxy.smbh.mass > 0){
delta_mbh = agnfeedback->smbh_growth_starburst(galaxy.bulge_gas.mass, subhalo->Vvir, tdyn, galaxy);

double delta_mbh = 0;
if(subhalo->subhalo_type == Subhalo::SATELLITE && subhalo->Vvir_infall != 0 &&
darkmatterparams.apply_fix_to_mass_swapping_events){
// at infall for subhalos that become satellite
delta_mbh = agnfeedback->smbh_growth_starburst(galaxy.bulge_gas.mass, subhalo->Vvir_infall, tdyn, galaxy);
}
else{
delta_mbh = agnfeedback->smbh_growth_starburst(galaxy.bulge_gas.mass, subhalo->Vvir, tdyn, galaxy);
}

delta_mzbh = delta_mbh/galaxy.bulge_gas.mass * galaxy.bulge_gas.mass_metals;

Expand Down
15 changes: 12 additions & 3 deletions src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void Environment::process_satellite_subhalo_environment(Subhalo &satellite_subha
}

if(parameters.stripping && satellite_subhalo.infall_t != z){
// If I'm computing gradial ram pressure stripping of any form, then compute the ram pressure the satellite feels.
// If I'm computing gradual ram pressure stripping of any form, then compute the ram pressure the satellite feels.
if(parameters.gradual_stripping_halo || parameters.gradual_stripping_ism){
ram_press = ram_pressure(central_subhalo, satellite_subhalo, z);
}
Expand Down Expand Up @@ -248,7 +248,7 @@ void Environment::process_satellite_subhalo_environment(Subhalo &satellite_subha
// mass in metals to be tidally stripped is computed inside the function remove_tidal_stripped_stars.
BaryonBase lost_stellar;

if(satellite_subhalo.type1_galaxy()){
if(satellite_subhalo.type1_galaxy() && satellite_subhalo.Mvir_infall > 0){
// Apply here model of Errani et al. (2015) with rstar/a=0.2.
float ratio_mass = satellite_subhalo.Mvir / satellite_subhalo.Mvir_infall;
// Apply a maximum stripping of 99% in halo mass and on the other and a maximum of 1 in the ratio..
Expand Down Expand Up @@ -475,9 +475,18 @@ double Environment::ram_pressure_stripping_hot_gas(const SubhaloPtr &primary,

// Here use the sum of the current hot halo gas plus what has been stripped. This assumed that the density of gas is only affected by cooling
// and not ram pressure stripping.

float rvir = 0;
if (secondary.rvir_infall > 0){
rvir = secondary.rvir_infall;
}
else{
rvir = darkmatterhalos->halo_virial_radius(secondary.Mvir, z);
}

auto enc_mass = darkmatterhalos->enclosed_total_mass(secondary, z, r);
double func = parameters.alpha_rps_halo * shark::constants::G * enc_mass *
(secondary.hot_halo_gas.mass + secondary.hot_halo_gas_stripped.mass) / (8 * secondary.rvir_infall * std::pow(r,3)) / 1e18 -
(secondary.hot_halo_gas.mass + secondary.hot_halo_gas_stripped.mass) / (8 * rvir * std::pow(r,3)) / 1e18 -
ram_press;

return func;
Expand Down
5 changes: 4 additions & 1 deletion src/galaxy_mergers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,15 @@ void GalaxyMergers::create_starbursts(HaloPtr &halo, double z, double delta_t){
double tdyn = agnfeedback->smbh_accretion_timescale(galaxy, z);


delta_mbh = agnfeedback->smbh_growth_starburst(galaxy.bulge_gas.mass, subhalo->Vvir, tdyn, galaxy);
double delta_mbh = 0;
if(subhalo->subhalo_type == Subhalo::SATELLITE && subhalo->Vvir_infall != 0 &&
dark_matter_params.apply_fix_to_mass_swapping_events){
// at infall for subhalos that become satellite
delta_mbh = agnfeedback->smbh_growth_starburst(galaxy.bulge_gas.mass, subhalo->Vvir_infall, tdyn, galaxy);
}
else{
delta_mbh = agnfeedback->smbh_growth_starburst(galaxy.bulge_gas.mass, subhalo->Vvir, tdyn, galaxy);
}

if(galaxy.bulge_gas.mass > 0){
delta_mzbh = delta_mbh/galaxy.bulge_gas.mass * galaxy.bulge_gas.mass_metals;
Expand Down

0 comments on commit ff263cb

Please sign in to comment.