1
!% Contains a module which implements calculation of stellar astrophysics.
3
module Stellar_Astrophysics
4
!% Implements calculation of stellar astrophysics.
7
public :: Star_Ejected_Mass, Star_Initial_Mass, Star_Metal_Yield_Mass, Star_Lifetime
9
! Flag to indicate if this module has been initialized.
10
logical :: stellarAstrophysicsInitialized=.false.
12
! Name of cosmology functions method used.
13
type(varying_string) :: stellarAstrophysicsMethod
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()
22
double precision function Stellar_Astrophysics_Template(inputParameter1,inputParameter2)
23
double precision, intent(in) :: inputParameter1,inputParameter2
24
end function Stellar_Astrophysics_Template
29
subroutine Stellar_Astrophysics_Initialize
30
!% Initialize the stellar astrophysics module.
33
!# <include directive="stellarAstrophysicsMethod" type="moduleUse">
34
include 'stellar_astrophysics.modules.inc'
38
!$omp critical(Stellar_Astrophysics_Initialization)
39
! Initialize if necessary.
40
if (.not.stellarAstrophysicsInitialized) then
41
! Get the stellar tracks method parameter.
43
!@ <name>stellarAstrophysicsMethod</name>
44
!@ <defaultValue>file</defaultValue>
45
!@ <attachedTo>module</attachedTo>
47
!@ The name of the method to be used for stellar astrophysics calculations.
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'
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.
60
!$omp end critical(Stellar_Astrophysics_Initialization)
63
end subroutine Stellar_Astrophysics_Initialize
65
double precision function Star_Initial_Mass(lifetime,metallicity)
66
!% Returns the initial mass of a star of given {\tt lifetime} and {\tt metallicity}.
68
double precision, intent(in) :: lifetime,metallicity
70
! Initialize the module.
71
call Stellar_Astrophysics_Initialize
73
! Get the answer using the selected method.
74
Star_Initial_Mass=Star_Initial_Mass_Get(lifetime,metallicity)
77
end function Star_Initial_Mass
79
double precision function Star_Ejected_Mass(initialMass,metallicity)
80
!% Returns the mass ejected by a star of given {\tt initialMass} and {\tt metallicity}.
82
double precision, intent(in) :: initialMass,metallicity
84
! Initialize the module.
85
call Stellar_Astrophysics_Initialize
87
! Get the answer using the selected method.
88
Star_Ejected_Mass=Star_Ejected_Mass_Get(initialMass,metallicity)
91
end function Star_Ejected_Mass
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}.
96
double precision, intent(in) :: initialMass,metallicity
98
! Initialize the module.
99
call Stellar_Astrophysics_Initialize
101
! Get the answer using the selected method.
102
Star_Metal_Yield_Mass=Star_Metal_Yield_Mass_Get(initialMass,metallicity)
105
end function Star_Metal_Yield_Mass
107
double precision function Star_Lifetime(initialMass,metallicity)
108
!% Returns the lifetime of a star of given {\tt initialMass} and {\tt metallicity}.
110
double precision, intent(in) :: initialMass,metallicity
112
! Initialize the module.
113
call Stellar_Astrophysics_Initialize
115
! Get the answer using the selected method.
116
Star_Lifetime=Star_Lifetime_Get(initialMass,metallicity)
119
end function Star_Lifetime
121
end module Stellar_Astrophysics