Skip to content

Commit

Permalink
fix: Never pass nodes at the final output time
Browse files Browse the repository at this point in the history
Nodes can never impact a stream at the final output time (since impacts are always computed over the subsequent timestep). Detect the final output time and never pass nodes at or after this time.
  • Loading branch information
abensonca committed Sep 18, 2024
1 parent 61a6ae9 commit 51e6155
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions source/galactic.filters.stream_impact.F90
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ logical function streamImpactPasses(self,node) result(passes)
!!{
Filter based on whether a subhalo can impact a stream in the timestep.
!!}
use :: Galacticus_Nodes, only : nodeComponentBasic, nodeComponentSatellite
use :: Galacticus_Nodes , only : nodeComponentBasic , nodeComponentSatellite
use :: Numerical_Constants_Astronomical, only : Mpc_per_km_per_s_To_Gyr
use :: Vectors, only : Vector_Magnitude
use :: Vectors , only : Vector_Magnitude
implicit none
class (galacticFilterStreamImpact), intent(inout) :: self
type (treeNode ), intent(inout), target :: node
Expand All @@ -134,7 +134,7 @@ logical function streamImpactPasses(self,node) result(passes)
type (treeNode ) , pointer :: nodeWork
double precision , dimension(3) :: position , velocity
double precision :: timeImpactMinimum, timeImpactMaximum, &
& speed
& speed , timeOutputNext

if (node%isSatellite()) then
! Find the position and velocity of the subhalo relative to its final host.
Expand All @@ -151,11 +151,15 @@ logical function streamImpactPasses(self,node) result(passes)
speed =Vector_Magnitude(velocity)
timeImpactMinimum=(-speed*self%radiusOrbitalStream-Dot_Product(velocity,position))/speed**2*Mpc_per_km_per_s_To_Gyr
timeImpactMaximum=(+speed*self%radiusOrbitalStream-Dot_Product(velocity,position))/speed**2*Mpc_per_km_per_s_To_Gyr
! Determine if the node passes. Note that the impact times computed above are relative to the current time, so we must include that offset here.
basic => node%basic()
passes = timeImpactMinimum < self%outputTimes_%timeNext(basic%time())-basic%time() &
& .and. &
& timeImpactMaximum > 0.0d0
! Determine if the node passes. Note that the impact times computed above are relative to the current time, so we must
! include that offset here.
basic => node %basic ( )
timeOutputNext = self%outputTimes_%timeNext(basic%time())
passes = timeOutputNext > 0.0d0 & ! Negative next output time indicates no more outputs,
& .and. & ! so no stream impact can occur.
& timeImpactMinimum < timeOutputNext-basic%time() &
& .and. &
& timeImpactMaximum > 0.0d0
else
! Non-subhalos are always passed.
passes=.true.
Expand Down

0 comments on commit 51e6155

Please sign in to comment.