thermal_neutrino_module.f90
Go to the documentation of this file.
1 !> @file thermal_neutrino_module.f90
2 !!
3 !! Contains the module \ref thermal_neutrino_module
4 !!
5 
6 !>
7 !! @brief The thermal_neutrino_module serves as interface to
8 !! the neutrino emission routines from the sneut5.f90 file.
9 !!
10 !! The thermal_neutrino_module is based on the fit of
11 !! [Itoh et al. 1996](https://ui.adsabs.harvard.edu/abs/1996ApJS..102..411I/abstract)
12 !! accessed via [Cococubed](https://cococubed.com/code_pages/nuloss.shtml).
13 !!
14 !! @author M. Reichert
15 !! @date 12.04.2023
16 include 'sneut5.f90'
17 include 'funct_fermi1.f90'
18 #include "../macros.h"
20 
21  ! Variables for output
22  real(r_kind),public, save :: snu = 0 !< Neutrino emissivity (erg/g)
23  real(r_kind),public, save :: spair = 0 !< Pair production emissivity (erg/g)
24  real(r_kind),public, save :: splas = 0 !< Plasmon emission emissivity (erg/g)
25  real(r_kind),public, save :: sphot = 0 !< Photo neutrino emissivity (erg/g)
26  real(r_kind),public, save :: sbrem = 0 !< Bremsstrahlung emissivity (erg/g)
27  real(r_kind),public, save :: sreco = 0 !< Recombination neutrino emissivity (erg/g)
28 
29  !
30  ! Public and private fields and methods of the module.
31  !
32  public:: &
34 ! private:: &
35 
36 
37 contains
38 
39 
40 !> @brief Initializes the thermal_neutrino_module.
41 !!
42 !! This subroutine is called in the initialization of the code.
43 !! It only contains debug statements.
44 !!
45 !! @author M. Reichert
46 !! @date 12.04.2023
51  implicit none
52  real(r_kind) :: temp
53  real(r_kind) :: rho
54  real(r_kind) :: dummy
55  real(r_kind) :: abar
56  real(r_kind) :: ye
57  integer :: id_debug
58  real(r_kind) :: i
59 
60  ! Only do something if the parameters are enabled
61  if ((use_thermal_nu_loss) .and. (heating_mode .gt. 0)) then
62  if (verbose_level .gt. 1) then
63  ! Make everyone aware that thermal neutrinos are used
64  write(*,*) "Using thermal neutrino loss"
65  end if
66 
67  if (verbose_level .gt. 2) then
68  ! Write debug file to check if the neutrino loss is working correctly
69  id_debug = open_outfile('debug_thermal_neutrino_loss.dat')
70 
71  ! Write header
72  write(id_debug,"(A)") "# Thermal neutrino losses for constant temperature and a 50 percent mixture of C12 and O16"
73  write(id_debug,"(A1,(A14,3x),*(A15,3x))") "#", "T(GK)", "rho(g cm^-3)", "snu(erg/g/s)", "spair(erg/g/s)", &
74  "splas(erg/g/s)", "sphot(erg/g/s)", "sbrem(erg/g/s)", "sreco(erg/g/s)"
75  ! The following will produce the same data as plotted on
76  ! https://cococubed.com/code_pages/nuloss.shtml
77  ! Set the constant conditions
78  temp = 5e-1
79  abar = 14
80  ye = 0.5
81  do i=0,12,0.01
82  rho = 10**i
83  call thermal_neutrinos(abar,ye,temp,rho,1d0,dummy)
84  write(id_debug,"(*(E15.5E3,3x))") temp,rho,snu,spair,splas,sphot,sbrem,sreco
85  end do
86 
87  ! Close the file again
88  call close_io_file(id_debug,'debug_thermal_neutrino_loss.dat')
89  end if
90  end if
91 end subroutine thermal_neutrino_init
92 
93 
94 !> @brief Calculates the neutrino emissivity.
95 !!
96 !! This subroutine is an interface to the subroutine
97 !! sneut5_aa from the sneut5.f90 file.
98 !! It calculates the neutrino emissivity and its derivatives
99 !! with respect to temperature, density, average mass number and
100 !! average atomic number.
101 !! The derivatives are not used in the current version of the code.
102 !! The file sneut5.f90 is based on the fit of
103 !! [Itoh et al. 1996](https://ui.adsabs.harvard.edu/abs/1996ApJS..102..411I/abstract)
104 !! accessed via [Cococubed](https://cococubed.com/code_pages/nuloss.shtml).
105 !!
106 !! @author M. Reichert
107 !! @date 12.04.2023
108 subroutine thermal_neutrinos(abar,Ye,temp,den,timestep,neutrino_loss)
109  implicit none
110  real(r_kind),intent(in) :: abar !< Average mass number
111  real(r_kind),intent(in) :: ye !< Electron fraction
112  real(r_kind),intent(in) :: temp !< Temperature (GK)
113  real(r_kind),intent(in) :: den !< Density (g/cm^3)
114  real(r_kind),intent(in) :: timestep !< Timestep (s)
115  real(r_kind),intent(out) :: neutrino_loss !< Neutrino emissivity (erg/s/cm^3)
116  ! Internal variables
117  real(r_kind) :: dsnudt,dsnudd,dsnuda,dsnudz !< Derivatives of neutrino emissivity
118  real(r_kind) :: t_k !< Temperature in Kelvin
119  real(r_kind) :: zbar !< Average atomic number
120 
121  info_entry("thermal_neutrinos")
122 
123  ! Calculate average atomic number
124  zbar = abar*ye
125 
126  ! Convert to Kelvin
127  t_k = temp*1.0e9
128  call sneut5_aa(t_k,den,abar,zbar, &
129  snu,dsnudt,dsnudd,dsnuda,dsnudz, &
131 
132  spair = spair*timestep !erg/g/s -> erg/g
133  splas = splas*timestep !erg/g/s -> erg/g
134  sphot = sphot*timestep !erg/g/s -> erg/g
135  sbrem = sbrem*timestep !erg/g/s -> erg/g
136  sreco = sreco*timestep !erg/g/s -> erg/g
137 
138  ! Set output variable
139  neutrino_loss = snu*timestep
140 
141  info_exit("thermal_neutrinos")
142 
143 end subroutine thermal_neutrinos
144 
145 
146 end module thermal_neutrino_module
thermal_neutrino_module::sreco
real(r_kind), save, public sreco
Recombination neutrino emissivity (erg/g)
Definition: thermal_neutrino_module.f90:27
thermal_neutrino_module::spair
real(r_kind), save, public spair
Pair production emissivity (erg/g)
Definition: thermal_neutrino_module.f90:23
thermal_neutrino_module::sphot
real(r_kind), save, public sphot
Photo neutrino emissivity (erg/g)
Definition: thermal_neutrino_module.f90:25
thermal_neutrino_module::thermal_neutrinos
subroutine, public thermal_neutrinos(abar, Ye, temp, den, timestep, neutrino_loss)
Calculates the neutrino emissivity.
Definition: thermal_neutrino_module.f90:109
thermal_neutrino_module::snu
real(r_kind), save, public snu
Neutrino emissivity (erg/g)
Definition: thermal_neutrino_module.f90:22
thermal_neutrino_module
The thermal_neutrino_module serves as interface to the neutrino emission routines from the sneut5....
Definition: thermal_neutrino_module.f90:19
file_handling_class
Provide some basic file-handling routines.
Definition: file_handling_class.f90:18
parameter_class::heating_mode
integer heating_mode
Mode for heating: 0 - no heating, 1 - heating using an entropy equation, 2 - heating from the energy ...
Definition: parameter_class.f90:148
r_kind
#define r_kind
Definition: macros.h:46
parameter_class::use_thermal_nu_loss
logical use_thermal_nu_loss
Whether to include thermal neutrino loss or not.
Definition: parameter_class.f90:99
thermal_neutrino_module::splas
real(r_kind), save, public splas
Plasmon emission emissivity (erg/g)
Definition: thermal_neutrino_module.f90:24
file_handling_class::open_outfile
integer function, public open_outfile(file_name)
Shorthand for opening a new file for writing (output file)
Definition: file_handling_class.f90:108
file_handling_class::close_io_file
subroutine, public close_io_file(unit_no, file_name)
Close an external file.
Definition: file_handling_class.f90:144
sneut5_aa
subroutine sneut5_aa(temp, den, abar, zbar, snu, dsnudt, dsnudd, dsnuda, dsnudz, spair, splas, sphot, sbrem, sreco)
Definition: sneut5.f90:4
thermal_neutrino_module::sbrem
real(r_kind), save, public sbrem
Bremsstrahlung emissivity (erg/g)
Definition: thermal_neutrino_module.f90:26
thermal_neutrino_module::thermal_neutrino_init
subroutine, public thermal_neutrino_init()
Initializes the thermal_neutrino_module.
Definition: thermal_neutrino_module.f90:48
parameter_class
Contains all runtime parameters as well as phys and math constants.
Definition: parameter_class.f90:24