Skip to content

Commit

Permalink
Merge pull request #475 from galacticusorg/singleStepLabels
Browse files Browse the repository at this point in the history
Add labeling of progenitor halo origins when using the `singleStep` build controller
  • Loading branch information
abensonca authored Sep 18, 2023
2 parents 2819093 + 7e79de4 commit 2c11769
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 38 deletions.
5 changes: 3 additions & 2 deletions source/merger_trees.build.controller.F90
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ module Merger_Tree_Build_Controllers
<description>Alert the controller when new nodes are inserted into the tree.</description>
<type>void</type>
<pass>yes</pass>
<argument>type(treeNode), intent(inout) :: nodeCurrent , nodeProgenitor1</argument>
<argument>type(treeNode), intent(inout), optional :: nodeProgenitor2</argument>
<argument>type (treeNode), intent(inout) :: nodeCurrent , nodeProgenitor1</argument>
<argument>type (treeNode), intent(inout), optional :: nodeProgenitor2 </argument>
<argument>logical , intent(in ), optional :: didBranch </argument>
</method>
</functionClass>
!!]
Expand Down
11 changes: 6 additions & 5 deletions source/merger_trees.build.controller.branchless.F90
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ function branchlessBranchingProbabilityObject(self,node) result(mergerTreeBranch
return
end function branchlessBranchingProbabilityObject

subroutine branchlessNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2)
subroutine branchlessNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2,didBranch)
!!{
Act on the insertion of nodes into the merger tree.
!!}
implicit none
class(mergerTreeBuildControllerBranchless), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
!$GLC attributes unused :: self, nodeCurrent, nodeProgenitor1, nodeProgenitor2
class (mergerTreeBuildControllerBranchless), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
logical , intent(in ), optional :: didBranch
!$GLC attributes unused :: self, nodeCurrent, nodeProgenitor1, nodeProgenitor2, didBranch

! Nothing to do.
return
Expand Down
16 changes: 9 additions & 7 deletions source/merger_trees.build.controller.constrained.F90
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,20 @@ function constrainedBranchingProbabilityObject(self,node) result(mergerTreeBranc
return
end function constrainedBranchingProbabilityObject

subroutine constrainedNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2)
subroutine constrainedNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2,didBranch)
!!{
Act on the insertion of nodes into the merger tree.
!!}
use :: Galacticus_Nodes, only : nodeComponentBasic
implicit none
class (mergerTreeBuildControllerConstrained), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
class (nodeComponentBasic ), pointer :: basicCurrent , basicProgenitor1, &
& basicProgenitor2
logical :: isConstrained
class (mergerTreeBuildControllerConstrained), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
logical , intent(in ), optional :: didBranch
class (nodeComponentBasic ), pointer :: basicCurrent , basicProgenitor1, &
& basicProgenitor2
logical :: isConstrained
!$GLC attributes unused :: didBranch

basicCurrent => nodeCurrent %basic ( )
basicProgenitor1 => nodeProgenitor1%basic ( )
Expand Down
43 changes: 31 additions & 12 deletions source/merger_trees.build.controller.single_step.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
class (criticalOverdensityClass ), pointer :: criticalOverdensity_ => null()
double precision :: redshiftStep , criticalOverdensityStep
logical :: haltAfterStep
integer :: primaryLabelID , secondaryLabelID , &
& smoothLabelID
contains
final :: singleStepDestructor
procedure :: control => singleStepControl
Expand Down Expand Up @@ -112,6 +114,7 @@ function singleStepConstructorInternal(criticalOverdensityStep,haltAfterStep,cos
!!{
Internal constructor for the ``singleStep'' merger tree build controller class .
!!}
use :: Nodes_Labels, only : nodeLabelRegister
implicit none
type (mergerTreeBuildControllerSingleStep) :: self
double precision , intent(in ) :: criticalOverdensityStep
Expand All @@ -124,13 +127,16 @@ function singleStepConstructorInternal(criticalOverdensityStep,haltAfterStep,cos
<constructorAssign variables="criticalOverdensityStep, haltAfterStep, *cosmologyFunctions_, *criticalOverdensity_, *linearGrowth_, *mergerTreeBuildController_"/>
!!]

self%redshiftStep=self%cosmologyFunctions_ %redshiftFromExpansionFactor( &
& self%cosmologyFunctions_ %expansionFactor ( &
& self%criticalOverdensity_%timeOfCollapse ( &
& criticalOverdensityStep &
& ) &
& ) &
& )
self%redshiftStep =self%cosmologyFunctions_ %redshiftFromExpansionFactor( &
& self%cosmologyFunctions_ %expansionFactor ( &
& self%criticalOverdensity_%timeOfCollapse ( &
& criticalOverdensityStep &
& ) &
& ) &
& )
self% primaryLabelID=nodeLabelRegister('progenitorFirst' ,'Identifies progenitors that were sampled first from the progenitor mass distribution.' )
self%secondaryLabelID=nodeLabelRegister('progenitorSecond','Identifies progenitors that were sampled second from the progenitor mass distribution.')
self% smoothLabelID=nodeLabelRegister('progenitorSmooth','Identifies progenitors resulting from smooth/sub-resolution accretion.' )
return
end function singleStepConstructorInternal

Expand Down Expand Up @@ -235,6 +241,7 @@ logical function singleStepControlTimeMaximum(self,node,massBranch,criticalOverd
nodeNew %sibling => null()
call basic%massSet(massBranch )
call basic%timeSet(criticalOverdensityBranch)
call nodeLabelSet(self%smoothLabelID,nodeNew)
! Return false indicating that the current node is finished, so building should continue from its progenitor nodes.
singleStepControlTimeMaximum=.false.
return
Expand All @@ -253,15 +260,27 @@ function singleStepBranchingProbabilityObject(self,node) result(mergerTreeBranch
return
end function singleStepBranchingProbabilityObject

subroutine singleStepNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2)
subroutine singleStepNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2,didBranch)
!!{
Act on the insertion of nodes into the merger tree.
!!}
use :: Nodes_Labels, only : nodeLabelSet
implicit none
class(mergerTreeBuildControllerSingleStep), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2

class (mergerTreeBuildControllerSingleStep), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
logical , intent(in ), optional :: didBranch
!![
<optionalArgument name="didBranch" defaultsTo=".false."/>
!!]

call self%mergerTreeBuildController_%nodesInserted(nodeCurrent,nodeProgenitor1,nodeProgenitor2)
if (didBranch_) then
call nodeLabelSet(self% primaryLabelID,nodeProgenitor1)
if (present(nodeProgenitor2)) &
& call nodeLabelSet(self%secondaryLabelID,nodeProgenitor2)
else
call nodeLabelSet(self% smoothLabelID,nodeProgenitor1)
end if
return
end subroutine singleStepNodesInserted
11 changes: 6 additions & 5 deletions source/merger_trees.build.controller.subsample.F90
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,16 @@ function subsampleBranchingProbabilityObject(self,node) result(mergerTreeBranchi
return
end function subsampleBranchingProbabilityObject

subroutine subsampleNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2)
subroutine subsampleNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2,didBranch)
!!{
Act on the insertion of nodes into the merger tree.
!!}
implicit none
class(mergerTreeBuildControllerSubsample), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
!$GLC attributes unused :: self, nodeCurrent, nodeProgenitor1, nodeProgenitor2
class (mergerTreeBuildControllerSubsample), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
logical , intent(in ), optional :: didBranch
!$GLC attributes unused :: self, nodeCurrent, nodeProgenitor1, nodeProgenitor2, didBranch

! Nothing to do.
return
Expand Down
11 changes: 6 additions & 5 deletions source/merger_trees.build.controller.uncontrolled.F90
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,16 @@ function uncontrolledBranchingProbabilityObject(self,node) result(mergerTreeBran
return
end function uncontrolledBranchingProbabilityObject

subroutine uncontrolledNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2)
subroutine uncontrolledNodesInserted(self,nodeCurrent,nodeProgenitor1,nodeProgenitor2,didBranch)
!!{
Act on the insertion of nodes into the merger tree.
!!}
implicit none
class(mergerTreeBuildControllerUncontrolled), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
!$GLC attributes unused :: self, nodeCurrent, nodeProgenitor1, nodeProgenitor2
class (mergerTreeBuildControllerUncontrolled), intent(inout) :: self
type (treeNode ), intent(inout) :: nodeCurrent , nodeProgenitor1
type (treeNode ), intent(inout), optional :: nodeProgenitor2
logical , intent(in ), optional :: didBranch
!$GLC attributes unused :: self, nodeCurrent, nodeProgenitor1, nodeProgenitor2, didBranch

! Nothing to do.
return
Expand Down
8 changes: 6 additions & 2 deletions source/merger_trees.construct.builder.Cole2000.F90
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ recursive subroutine cole2000BuildBranch(tree,massResolution,nodeIndex,nodeTip)
! Compute the critical overdensity corresponding to this new node.
deltaCritical1=self_%criticalOverdensityUpdate(branchDeltaCriticalCurrent,branchMassCurrent,nodeMass1,nodeNew1)
call basicNew1%timeSet(deltaCritical1)
! Inform the build controller of this new node.
call self_%workers(numberWorker)%mergerTreeBuildController_%nodesInserted(nodeCurrent,nodeNew1)
! Create links from old to new node and vice-versa.
nodeCurrent%firstChild => nodeNew1
nodeNew1%parent => nodeCurrent
Expand Down Expand Up @@ -613,6 +615,8 @@ recursive subroutine cole2000BuildBranch(tree,massResolution,nodeIndex,nodeTip)
! Set properties of the new node.
call basicNew1%massSet(nodeMass1 )
call basicNew1%timeSet(deltaCritical1)
! Inform the build controller of this new node.
call self_%workers(numberWorker)%mergerTreeBuildController_%nodesInserted(nodeCurrent,nodeNew1)
! Create links from old to new node and vice-versa.
nodeCurrent%firstChild => nodeNew1
nodeNew1 %parent => nodeCurrent
Expand Down Expand Up @@ -797,7 +801,7 @@ recursive subroutine cole2000BuildBranch(tree,massResolution,nodeIndex,nodeTip)
call basicNew2%massSet(nodeMass2 )
call basicNew2%timeSet(deltaCritical2)
! Inform the build controller of these new nodes.
call self_%workers(numberWorker)%mergerTreeBuildController_%nodesInserted(nodeCurrent,nodeNew1,nodeNew2)
call self_%workers(numberWorker)%mergerTreeBuildController_%nodesInserted(nodeCurrent,nodeNew1,nodeNew2,didBranch=.true.)
! Create links from old to new nodes and vice-versa. (Ensure that the first child node is the more massive progenitor.)
if (nodeMass2 > nodeMass1) then
nodeCurrent%firstChild => nodeNew2
Expand All @@ -813,7 +817,7 @@ recursive subroutine cole2000BuildBranch(tree,massResolution,nodeIndex,nodeTip)
else
! Second branch would be subresolution - do not create it.
! Inform the build controller of the new node.
call self_%workers(numberWorker)%mergerTreeBuildController_%nodesInserted(nodeCurrent,nodeNew1)
call self_%workers(numberWorker)%mergerTreeBuildController_%nodesInserted(nodeCurrent,nodeNew1 ,didBranch=.true.)
! Create links from old to new nodes and vice-versa.
nodeCurrent %firstChild => nodeNew1
nodeNew1 %sibling => null()
Expand Down

1 comment on commit 2c11769

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Milky Way model benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 2c11769 Previous: c02ffb6 Ratio
Milky Way model - Likelihood - localGroupMassVelocityDispersionRelation 1.0769978886767 -logℒ 0.906402852432514 -logℒ 1.19

This comment was automatically generated by workflow using github-action-benchmark.

CC: @abensonca

Please sign in to comment.