~abenson/galacticus/v0.9.0

« back to all changes in this revision

Viewing changes to source/stellar_astrophysics.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 calculation of stellar astrophysics.
 
2
 
 
3
module Stellar_Astrophysics
 
4
  !% Implements calculation of stellar astrophysics.
 
5
  use ISO_Varying_String
 
6
  private
 
7
  public :: Star_Ejected_Mass, Star_Initial_Mass, Star_Metal_Yield_Mass, Star_Lifetime
 
8
  
 
9
  ! Flag to indicate if this module has been initialized.  
 
10
  logical              :: stellarAstrophysicsInitialized=.false.
 
11
 
 
12
  ! Name of cosmology functions method used.
 
13
  type(varying_string) :: stellarAstrophysicsMethod
 
14
 
 
15
  ! Pointer to the functions that actually do the calculations.
 
16
  procedure(Stellar_Astrophysics_Template), pointer :: Star_Ejected_Mass_Get     => null()
 
17
  procedure(Stellar_Astrophysics_Template), pointer :: Star_Initial_Mass_Get     => null()
 
18
  procedure(Stellar_Astrophysics_Template), pointer :: Star_Metal_Yield_Mass_Get => null()
 
19
  procedure(Stellar_Astrophysics_Template), pointer :: Star_Lifetime_Get         => null()
 
20
 
 
21
  abstract interface
 
22
     double precision function Stellar_Astrophysics_Template(inputParameter1,inputParameter2)
 
23
       double precision, intent(in) :: inputParameter1,inputParameter2
 
24
     end function Stellar_Astrophysics_Template
 
25
  end interface
 
26
 
 
27
contains
 
28
 
 
29
  subroutine Stellar_Astrophysics_Initialize
 
30
    !% Initialize the stellar astrophysics module.
 
31
    use Galacticus_Error
 
32
    use Input_Parameters
 
33
    !# <include directive="stellarAstrophysicsMethod" type="moduleUse">
 
34
    include 'stellar_astrophysics.modules.inc'
 
35
    !# </include>
 
36
    implicit none
 
37
 
 
38
    !$omp critical(Stellar_Astrophysics_Initialization) 
 
39
    ! Initialize if necessary.
 
40
    if (.not.stellarAstrophysicsInitialized) then
 
41
       ! Get the stellar tracks method parameter.
 
42
       !@ <inputParameter>
 
43
       !@   <name>stellarAstrophysicsMethod</name>
 
44
       !@   <defaultValue>file</defaultValue>       
 
45
       !@   <attachedTo>module</attachedTo>
 
46
       !@   <description>
 
47
       !@     The name of the method to be used for stellar astrophysics calculations.
 
48
       !@   </description>
 
49
       !@ </inputParameter>
 
50
       call Get_Input_Parameter('stellarAstrophysicsMethod',stellarAstrophysicsMethod,defaultValue='file')
 
51
       ! Include file that makes calls to all available method initialization routines.
 
52
       !# <include directive="stellarAstrophysicsMethod" type="code" action="subroutine">
 
53
       !#  <subroutineArgs>stellarAstrophysicsMethod,Star_Ejected_Mass_Get,Star_Initial_Mass_Get,Star_Metal_Yield_Mass_Get,Star_Lifetime_Get</subroutineArgs>
 
54
       include 'stellar_astrophysics.inc'
 
55
       !# </include>
 
56
       if (.not.(associated(Star_Ejected_Mass_Get).and.associated(Star_Initial_Mass_Get).and.associated(Star_Metal_Yield_Mass_Get).and.associated(Star_Lifetime_Get))) &
 
57
            & call Galacticus_Error_Report('Stellar_Astrophysics','method '//char(stellarAstrophysicsMethod)//' is unrecognized')
 
58
       stellarAstrophysicsInitialized=.true.
 
59
    end if
 
60
    !$omp end critical(Stellar_Astrophysics_Initialization) 
 
61
 
 
62
    return
 
63
  end subroutine Stellar_Astrophysics_Initialize
 
64
 
 
65
  double precision function Star_Initial_Mass(lifetime,metallicity)
 
66
    !% Returns the initial mass of a star of given {\tt lifetime} and {\tt metallicity}.
 
67
    implicit none
 
68
    double precision, intent(in) :: lifetime,metallicity
 
69
    
 
70
    ! Initialize the module.
 
71
    call Stellar_Astrophysics_Initialize
 
72
    
 
73
    ! Get the answer using the selected method.
 
74
    Star_Initial_Mass=Star_Initial_Mass_Get(lifetime,metallicity)
 
75
    
 
76
    return
 
77
  end function Star_Initial_Mass
 
78
  
 
79
  double precision function Star_Ejected_Mass(initialMass,metallicity)
 
80
    !% Returns the mass ejected by a star of given {\tt initialMass} and {\tt metallicity}.
 
81
    implicit none
 
82
    double precision, intent(in) :: initialMass,metallicity
 
83
    
 
84
    ! Initialize the module.
 
85
    call Stellar_Astrophysics_Initialize
 
86
    
 
87
    ! Get the answer using the selected method.
 
88
    Star_Ejected_Mass=Star_Ejected_Mass_Get(initialMass,metallicity)
 
89
    
 
90
    return
 
91
  end function Star_Ejected_Mass
 
92
  
 
93
  double precision function Star_Metal_Yield_Mass(initialMass,metallicity)
 
94
    !% Returns the metal mass yielded by a star of given {\tt initialMass} and {\tt metallicity}.
 
95
    implicit none
 
96
    double precision, intent(in) :: initialMass,metallicity
 
97
    
 
98
    ! Initialize the module.
 
99
    call Stellar_Astrophysics_Initialize
 
100
    
 
101
    ! Get the answer using the selected method.
 
102
    Star_Metal_Yield_Mass=Star_Metal_Yield_Mass_Get(initialMass,metallicity)
 
103
    
 
104
    return
 
105
  end function Star_Metal_Yield_Mass
 
106
  
 
107
  double precision function Star_Lifetime(initialMass,metallicity)
 
108
    !% Returns the lifetime of a star of given {\tt initialMass} and {\tt metallicity}.
 
109
    implicit none
 
110
    double precision, intent(in) :: initialMass,metallicity
 
111
    
 
112
    ! Initialize the module.
 
113
    call Stellar_Astrophysics_Initialize
 
114
    
 
115
    ! Get the answer using the selected method.
 
116
    Star_Lifetime=Star_Lifetime_Get(initialMass,metallicity)
 
117
    
 
118
    return
 
119
  end function Star_Lifetime
 
120
  
 
121
end module Stellar_Astrophysics