~abenson/galacticus/v0.9.0

« back to all changes in this revision

Viewing changes to source/stellar_populations.properties.instantaneous.F90

  • Committer: Andrew Benson
  • Date: 2010-05-27 14:18:28 UTC
  • Revision ID: abesnson@its.caltech.edu-20100527141828-dzvnjovtiq02impa
* Importing full Galacticus code as developed to date.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!% Contains a module which implements stellar population properties in the instantaneous recycling approximation.
 
2
 
 
3
module Stellar_Population_Properties_Instantaneous
 
4
  !% Implements stellar population properties in the instantaneous recycling approximation.
 
5
  private
 
6
  public :: Stellar_Population_Properties_Instantaneous_Initialize
 
7
 
 
8
contains
 
9
 
 
10
  !# <stellarPopulationPropertiesMethod>
 
11
  !#  <unitName>Stellar_Population_Properties_Instantaneous_Initialize</unitName>
 
12
  !# </stellarPopulationPropertiesMethod>
 
13
  subroutine Stellar_Population_Properties_Instantaneous_Initialize(stellarPopulationPropertiesMethod &
 
14
       &,Stellar_Population_Properties_Rates_Get,Stellar_Population_Properties_History_Count_Get&
 
15
       &,Stellar_Population_Properties_History_Create_Do)
 
16
    !% Initializes the instantaneous recycling approximation stellar population properties module.
 
17
    use ISO_Varying_String
 
18
    implicit none
 
19
    type(varying_string),          intent(in)    :: stellarPopulationPropertiesMethod
 
20
    procedure(),          pointer, intent(inout) :: Stellar_Population_Properties_Rates_Get&
 
21
         &,Stellar_Population_Properties_History_Count_Get,Stellar_Population_Properties_History_Create_Do
 
22
    
 
23
    if (stellarPopulationPropertiesMethod == 'instantaneous') then
 
24
       Stellar_Population_Properties_Rates_Get         =>  Stellar_Population_Properties_Rates_Instantaneous    
 
25
       Stellar_Population_Properties_History_Count_Get =>  Stellar_Population_Properties_History_Count_Instantaneous    
 
26
       Stellar_Population_Properties_History_Create_Do => Stellar_Population_Properties_History_Create_Instantaneous
 
27
    end if
 
28
    return
 
29
  end subroutine Stellar_Population_Properties_Instantaneous_Initialize
 
30
 
 
31
  integer function Stellar_Population_Properties_History_Count_Instantaneous()
 
32
    !% Returns the number of histories required by the instantaneous stellar populations properties module.
 
33
    implicit none
 
34
  
 
35
    ! We require no histories.  
 
36
    Stellar_Population_Properties_History_Count_Instantaneous=0
 
37
    return
 
38
  end function Stellar_Population_Properties_History_Count_Instantaneous
 
39
  
 
40
  subroutine Stellar_Population_Properties_Rates_Instantaneous(starFormationRate,fuelAbundances,thisNode,thisHistory,stellarMassRate&
 
41
       &,stellarAbundancesRates,stellarLuminositiesRates,fuelMassRate,fuelAbundancesRates,energyInputRate)
 
42
    !% Return an array of stellar population property rates of change given a star formation rate and fuel abundances.
 
43
    use Tree_Nodes
 
44
    use Tree_Node_Methods
 
45
    use Abundances_Structure
 
46
    use Histories
 
47
    use Star_Formation_IMF
 
48
    use Stellar_Population_Properties_Luminosities
 
49
    use Stellar_Feedback
 
50
    implicit none
 
51
    double precision,          intent(out)                 :: stellarMassRate,fuelMassRate,energyInputRate
 
52
    type(abundancesStructure), intent(out)                 :: stellarAbundancesRates,fuelAbundancesRates
 
53
    double precision,          intent(out),   dimension(:) :: stellarLuminositiesRates
 
54
    double precision,          intent(in)                  :: starFormationRate
 
55
    type(abundancesStructure), intent(in)                  :: fuelAbundances
 
56
    type(treeNode),            intent(inout), pointer      :: thisNode
 
57
    type(history),             intent(inout)               :: thisHistory
 
58
    integer                                                :: imfSelected
 
59
    double precision                                       :: recycledFractionInstantaneous,yieldInstantaneous,fuelMetallicity&
 
60
         &,stellarMetalsRateOfChange,fuelMetalsRateOfChange,time
 
61
 
 
62
    ! Get the instantaneous recycling rate for the IMF.
 
63
    recycledFractionInstantaneous=IMF_Recycled_Fraction_Instantaneous(starFormationRate,fuelAbundances)
 
64
 
 
65
    ! Get the yield for this IMF.
 
66
    yieldInstantaneous=IMF_Yield_Instantaneous(starFormationRate,fuelAbundances)
 
67
 
 
68
    ! Get the metallicity of the fuel supply.
 
69
    fuelMetallicity=Abundances_Get_Metallicity(fuelAbundances)
 
70
 
 
71
    ! Set the stellar and fuel mass rates of change.
 
72
    stellarMassRate= (1.0d0-recycledFractionInstantaneous)*starFormationRate
 
73
    fuelMassRate   =-stellarMassRate
 
74
 
 
75
    ! Set energy input rate to canonical value assuming that all energy is injected instantaneously.
 
76
    energyInputRate=starFormationRate*feedbackEnergyInputAtInfinityCanonical
 
77
 
 
78
    ! Set the rates of change of the stellar and fuel metallicities.
 
79
    stellarMetalsRateOfChange=stellarMassRate*fuelMetallicity
 
80
    fuelMetalsRateOfChange   =-stellarMetalsRateOfChange+yieldInstantaneous*starFormationRate
 
81
    call stellarAbundancesRates%metallicitySet(stellarMetalsRateOfChange)
 
82
    call fuelAbundancesRates   %metallicitySet(fuelMetalsRateOfChange   )
 
83
 
 
84
    ! Get the IMF.
 
85
    imfSelected=IMF_Select(starFormationRate,fuelAbundances)
 
86
 
 
87
    ! Get the current cosmological time for this node.
 
88
    time=Tree_Node_Time(thisNode)
 
89
 
 
90
    ! Set luminosity rates of change.
 
91
    if (size(stellarLuminositiesRates) > 0) stellarLuminositiesRates=starFormationRate&
 
92
         &*Stellar_Population_Luminosities_Get(imfSelected,time,fuelAbundances)
 
93
 
 
94
    return
 
95
  end subroutine Stellar_Population_Properties_Rates_Instantaneous
 
96
 
 
97
  subroutine Stellar_Population_Properties_History_Create_Instantaneous(thisNode,thisHistory)
 
98
    !% Create any history required for storing stellar population properties. The instantaneous method requires none, so just return.
 
99
    use Tree_Nodes
 
100
    use Histories
 
101
    implicit none
 
102
    type(treeNode), intent(inout), pointer :: thisNode
 
103
    type(history),  intent(inout) :: thisHistory
 
104
  
 
105
    return
 
106
  end subroutine Stellar_Population_Properties_History_Create_Instantaneous
 
107
 
 
108
end module Stellar_Population_Properties_Instantaneous