From 51e6155a8d13cdf00d2e5fd3302340e1502a551e Mon Sep 17 00:00:00 2001 From: Andrew Benson Date: Wed, 18 Sep 2024 08:25:31 -0700 Subject: [PATCH] fix: Never pass nodes at the final output time 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. --- source/galactic.filters.stream_impact.F90 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/galactic.filters.stream_impact.F90 b/source/galactic.filters.stream_impact.F90 index 6151c49408..b1f0259b52 100644 --- a/source/galactic.filters.stream_impact.F90 +++ b/source/galactic.filters.stream_impact.F90 @@ -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 @@ -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. @@ -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.