diff --git a/source/nodes.operators.analyses.mass_accretion_history.F90 b/source/nodes.operators.analyses.mass_accretion_history.F90 new file mode 100644 index 0000000000..8008f42441 --- /dev/null +++ b/source/nodes.operators.analyses.mass_accretion_history.F90 @@ -0,0 +1,119 @@ +!! Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, +!! 2019, 2020, 2021, 2022, 2023 +!! Andrew Benson +!! +!! This file is part of Galacticus. +!! +!! Galacticus is free software: you can redistribute it and/or modify +!! it under the terms of the GNU General Public License as published by +!! the Free Software Foundation, either version 3 of the License, or +!! (at your option) any later version. +!! +!! Galacticus is distributed in the hope that it will be useful, +!! but WITHOUT ANY WARRANTY; without even the implied warranty of +!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +!! GNU General Public License for more details. +!! +!! You should have received a copy of the GNU General Public License +!! along with Galacticus. If not, see . + + !!{ + Implements a node operator class that collects and stores the mass accretion history of each node. + !!} + + !![ + + A node operator class that collects and stores the mass accretion history of each node. + + !!] + type, extends(nodeOperatorClass) :: nodeOperatorMassAccretionHistory + !!{ + A node operator class that collects and stores the mass accretion history of each node. + !!} + private + integer :: massAccretionHistoryTimeID, massAccretionHistoryMassID + contains + procedure :: nodeInitialize => massAccretionHistoryNodeInitialize + end type nodeOperatorMassAccretionHistory + + interface nodeOperatorMassAccretionHistory + !!{ + Constructors for the {\normalfont \ttfamily massAccretionHistory} node operator class. + !!} + module procedure massAccretionHistoryConstructorParameters + module procedure massAccretionHistoryConstructorInternal + end interface nodeOperatorMassAccretionHistory + +contains + + function massAccretionHistoryConstructorParameters(parameters) result(self) + !!{ + Constructor for the {\normalfont \ttfamily massAccretionHistory} node operator class which takes a parameter set as input. + !!} + use :: Input_Parameters, only : inputParameters + implicit none + type(nodeOperatorMassAccretionHistory) :: self + type(inputParameters ), intent(inout) :: parameters + + self=nodeOperatorMassAccretionHistory() + !![ + + !!] + return + end function massAccretionHistoryConstructorParameters + + function massAccretionHistoryConstructorInternal() result(self) + !!{ + Internal constructor for the {\normalfont \ttfamily massAccretionHistory} node operator class. + !!} + use :: Galacticus_Nodes, only : defaultBasicComponent + implicit none + type(nodeOperatorMassAccretionHistory) :: self + + !![ + + + !!] + return + end function massAccretionHistoryConstructorInternal + + subroutine massAccretionHistoryNodeInitialize(self,node) + !!{ + Record the mass accretion history of the node. + !!} + use :: Galacticus_Nodes, only : nodeComponentBasic + implicit none + class (nodeOperatorMassAccretionHistory), intent(inout), target :: self + type (treeNode ), intent(inout), target :: node + double precision , dimension(:) , allocatable :: times , masses + type (treeNode ) , pointer :: nodeWork + class (nodeComponentBasic ) , pointer :: basic + integer :: countNodes + + if (associated(node%firstChild)) return + nodeWork => node + countNodes = 1 + do while (nodeWork%isPrimaryProgenitor()) + countNodes = countNodes +1 + nodeWork => nodeWork %parent + end do + allocate(times (countNodes)) + allocate(masses(countNodes)) + nodeWork => node + countNodes = 1 + basic => nodeWork%basic() + times (countNodes) = basic %time () + masses (countNodes) = basic %mass () + do while (nodeWork%isPrimaryProgenitor()) + countNodes = countNodes +1 + nodeWork => nodeWork %parent + basic => nodeWork %basic () + times (countNodes) = basic %time () + masses(countNodes) = basic %mass () + end do + basic => node%basic() + call basic%floatRank1MetaPropertySet(self%massAccretionHistoryTimeID,times ) + call basic%floatRank1MetaPropertySet(self%massAccretionHistoryMassID,masses) + return + end subroutine massAccretionHistoryNodeInitialize + diff --git a/source/nodes.property_extractor.mass_accretion_history.F90 b/source/nodes.property_extractor.mass_accretion_history.F90 new file mode 100644 index 0000000000..5dc20d65b9 --- /dev/null +++ b/source/nodes.property_extractor.mass_accretion_history.F90 @@ -0,0 +1,160 @@ +!! Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, +!! 2019, 2020, 2021, 2022, 2023 +!! Andrew Benson +!! +!! This file is part of Galacticus. +!! +!! Galacticus is free software: you can redistribute it and/or modify +!! it under the terms of the GNU General Public License as published by +!! the Free Software Foundation, either version 3 of the License, or +!! (at your option) any later version. +!! +!! Galacticus is distributed in the hope that it will be useful, +!! but WITHOUT ANY WARRANTY; without even the implied warranty of +!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +!! GNU General Public License for more details. +!! +!! You should have received a copy of the GNU General Public License +!! along with Galacticus. If not, see . + + !![ + + + A node property extractor which extracts the mass accretion history for each node. + + + !!] + type, extends(nodePropertyExtractorList) :: nodePropertyExtractorMassAccretionHistory + !!{ + A property extractor which extracts the mass accretion history for each node. + !!} + private + integer :: massAccretionHistoryTimeID, massAccretionHistoryMassID + contains + procedure :: elementCount => massAccretionHistoryElementCount + procedure :: extract => massAccretionHistoryExtract + procedure :: names => massAccretionHistoryNames + procedure :: descriptions => massAccretionHistoryDescriptions + procedure :: unitsInSI => massAccretionHistoryUnitsInSI + end type nodePropertyExtractorMassAccretionHistory + + interface nodePropertyExtractorMassAccretionHistory + !!{ + Constructors for the ``massAccretionHistory'' output extractor class. + !!} + module procedure massAccretionHistoryConstructorParameters + module procedure massAccretionHistoryConstructorInternal + end interface nodePropertyExtractorMassAccretionHistory + +contains + + function massAccretionHistoryConstructorParameters(parameters) result(self) + !!{ + Constructor for the ``massAccretionHistory'' property extractor class which takes a parameter set as input. + !!} + use :: Input_Parameters, only : inputParameter, inputParameters + implicit none + type(nodePropertyExtractorMassAccretionHistory) :: self + type(inputParameters ), intent(inout) :: parameters + + self=nodePropertyExtractorMassAccretionHistory() + !![ + + !!] + return + end function massAccretionHistoryConstructorParameters + + function massAccretionHistoryConstructorInternal() result(self) + !!{ + Internal constructor for the ``massAccretionHistory'' output extractor property extractor class. + !!} + implicit none + type(nodePropertyExtractorMassAccretionHistory) :: self + + !![ + + + !!] + return + end function massAccretionHistoryConstructorInternal + + integer function massAccretionHistoryElementCount(self) + !!{ + Return a count of the number of properties extracted. + !!} + implicit none + class(nodePropertyExtractorMassAccretionHistory), intent(inout) :: self + + massAccretionHistoryElementCount=2 + return + end function massAccretionHistoryElementCount + + function massAccretionHistoryExtract(self,node,instance) result(massAccretionHistory) + !!{ + Implement a massAccretionHistory output extractor. + !!} + use :: Galacticus_Nodes, only : nodeComponentBasic + implicit none + double precision , dimension(:,:), allocatable :: massAccretionHistory + class (nodePropertyExtractorMassAccretionHistory), intent(inout) :: self + type (treeNode ), intent(inout) :: node + type (multiCounter ), intent(inout) , optional :: instance + class (nodeComponentBasic ) , pointer :: basic + double precision , dimension(: ), allocatable :: times , masses + !$GLC attributes unused :: instance + !$GLC attributes initialized :: times, masses + + basic => node %basic ( ) + times = basic%floatRank1MetaPropertyGet(self%massAccretionHistoryTimeID) + masses = basic%floatRank1MetaPropertyGet(self%massAccretionHistoryMassID) + allocate(massAccretionHistory(size(times),2)) + massAccretionHistory(:,1)=times + massAccretionHistory(:,2)=masses + return + end function massAccretionHistoryExtract + + subroutine massAccretionHistoryNames(self,names) + !!{ + Return the names of the {\normalfont \ttfamily massAccretionHistory} properties. + !!} + implicit none + class(nodePropertyExtractorMassAccretionHistory), intent(inout) :: self + type (varying_string ), intent(inout), dimension(:) , allocatable :: names + !$GLC attributes unused :: self + + allocate(names(2)) + names(1)=var_str('haloAccretionHistoryTime') + names(2)=var_str('haloAccretionHistoryMass') + return + end subroutine massAccretionHistoryNames + + subroutine massAccretionHistoryDescriptions(self,descriptions) + !!{ + Return the descriptions of the {\normalfont \ttfamily massAccretionHistory} properties. + !!} + implicit none + class(nodePropertyExtractorMassAccretionHistory), intent(inout) :: self + type (varying_string ), intent(inout), dimension(:) , allocatable :: descriptions + !$GLC attributes unused :: self + + allocate(descriptions(2)) + descriptions(1)=var_str('The time at which the DMO mass of the halo is tabulated.') + descriptions(2)=var_str('The DMO mass of the halo as a function of time.' ) + return + end subroutine massAccretionHistoryDescriptions + + function massAccretionHistoryUnitsInSI(self) result(unitsInSI) + !!{ + Return the units of the {\normalfont \ttfamily massAccretionHistory} properties in the SI system. + !!} + use :: Numerical_Constants_Astronomical, only : massSolar, gigaYear + implicit none + double precision , dimension(:) , allocatable :: unitsInSI + class (nodePropertyExtractorMassAccretionHistory), intent(inout) :: self + !$GLC attributes unused :: self + + allocate(unitsInSI(2)) + unitsInSI(1)=gigaYear + unitsInSI(2)=massSolar + return + end function massAccretionHistoryUnitsInSI