Go to the documentation of this file.
65 (/2.8d0,3.5d0,4.0d0,5.0d0,6.4d0,8.0d0,10.0d0/)
142 if (verbose_level .gt. 2.)
then
146 write(
lumin_debugfile,
'(A)')
' Time [s], NLume [1/s], NLumebar [1/s], Fnue, Fnuebar, R[cm]'
181 real(
r_kind),
intent(in) :: time
187 real(
r_kind),
dimension(4) :: c0nu
191 real(
r_kind),
dimension(4) :: nlum
192 real(
r_kind),
dimension(4) :: fluxcom
202 r2=4.d0*
unit%pi*rcm*rcm
205 select case (neutrino_mode)
228 if ( time <=
ztime(i) )
exit
248 else if ( time .eq.
ztime(1) )
then
257 nlum(1)=dexp(nlum(1))
258 nlum(2)=dexp(nlum(2))
261 nlum(3)=dexp(nlum(3))
262 nlum(4)=dexp(nlum(4))
268 if (nlum(1).le.
nu_min_l) nlum(1)=0.d0
269 if (nlum(2).le.
nu_min_l) nlum(2)=0.d0
271 if (nlum(3).le.
nu_min_l) nlum(3)=0.d0
272 if (nlum(4).le.
nu_min_l) nlum(4)=0.d0
281 nlum(inuf) = nlum(inuf)*
unit%ergtomev/(
tempnu(inuf)*3.151374374)
290 nlum(inuf) = nlum(inuf)*
unit%ergtomev/(
tempnu(inuf)*3.151374374)
299 fluxcom(inuf) = c0nu(inuf) * nlum(inuf) / r2
300 fluxnu(inuf) = fluxcom(inuf)
305 fluxcom(inuf) = c0nu(inuf) * nlum(inuf) / r2
306 fluxnu(inuf) = fluxcom(inuf)
311 if (verbose_level .gt. 2)
then
313 time, nlum(1), nlum(2),
fluxnu(1)/c0nu(1),
fluxnu(2)/c0nu(2),rcm
340 real(
r_kind),
intent(out) :: rat_calc
347 wind = int(rrate%param(1))
353 if (nurate_tmp%kind .eq. 1)
then
355 rrate%nu_frac = -1d0*sign(1d0,rrate%q_value)*abs(
nurate(wind)%ravE/rrate%q_value)
356 else if (nurate_tmp%kind .eq. 2)
then
358 rrate%nu_frac = -1d0*sign(1d0,rrate%q_value)*abs(
nurate(wind)%ravE/rrate%q_value)
359 else if (nurate_tmp%kind .eq. 3)
then
362 rrate%nu_frac = -1d0*sign(1d0,rrate%q_value)*abs(
nurate(wind)%ravE/rrate%q_value)
363 else if (nurate_tmp%kind .eq. 4)
then
366 rrate%nu_frac = -1d0*sign(1d0,rrate%q_value)*abs(
nurate(wind)%ravE/rrate%q_value)
368 call raise_exception(
"Neutrino kind not implemented yet. "// &
369 "Got: "//trim(int_to_str(nurate_tmp%kind))//
". "// &
370 "Only 1, 2 (CC) and 3, 4 (NC) are supported.", &
371 "calculate_nu_rate", 330003)
402 integer :: i,j,n,k, typ
403 integer,
dimension(4) :: isave
405 real(
r_kind),
dimension(4) :: frac
406 real(
r_kind) :: cs1,cs2,t1,t2,ave,ave1,ave2
407 real(
r_kind),
dimension(2) :: csg
419 if ((isave(j).le.1).or.(isave(j).gt.
nt_nugrid)) cycle
422 frac(j)=(dlog(
tempnu(j))-t1)/(t2-t1)
430 if (typ .gt. 2) start = typ-2
433 inner_loop:
do k=start,4,2
435 if (
tempnu(k) .eq. 0.d0)
then
443 else if ( isave(k) .eq. 1 )
then
444 csg(count) =
nurate(i)%cs(1)
450 if (
nurate(i)%cs(isave(k)) .eq. 0.0d0 )
then
453 cs2=dlog(
nurate(i)%cs(isave(k)))
456 if (
nurate(i)%cs(isave(k)-1) .eq. 0.0d0 )
then
459 cs1=dlog(
nurate(i)%cs(isave(k)-1))
461 rcs=cs1+frac(k)*(cs2-cs1)
465 if ((
nurate(i)%avE(isave(k)-1) .eq. 0.0d0 ) .or. &
466 (
nurate(i)%avE(isave(k)) .eq. 0.0d0 ))
then
469 ave1 =
nurate(i)%avE(isave(k)-1)
470 ave2 =
nurate(i)%avE(isave(k))
471 ave = ave1+frac(k)*(ave2-ave1)
475 if (typ .le. 2)
exit inner_loop
503 integer,
parameter :: iflux=0
505 real(
r_kind),
intent(in) :: time
516 select case (neutrino_mode)
544 if ( time <=
ztime(i) )
exit
594 character(len=7) :: tmp
596 if (verbose_level .ge. 1)
then
598 elseif (verbose_level .ge. 2)
then
599 if (
nnu .gt. 0)
write(*,
"(A)")
""
600 if (
nnu .gt. 0)
write(*,
"(A)")
" Neutrino rates: "
601 if (
nnu .gt. 0)
write(*,
"(A)")
" |------------------------|"
603 if (
nnu .gt. 0)
write(*,
"(A)")
" | Total :"//adjustr(tmp)//
" |"
605 if (
n_nucleo .gt. 0)
write(*,
"(A)")
" | on nucleons :"//adjustr(tmp)//
" |"
607 if (
n_nuclei .gt. 0)
write(*,
"(A)")
" | nue on nuclei :"//adjustr(tmp)//
" |"
609 if (
n_anuclei .gt. 0)
write(*,
"(A)")
" | anue on nuclei:"//adjustr(tmp)//
" |"
611 if (
n_cc .gt. 0)
write(*,
"(A)")
" | CC on nuclei :"//adjustr(tmp)//
" |"
613 if (
n_nc .gt. 0)
write(*,
"(A)")
" | NC on nuclei :"//adjustr(tmp)//
" |"
614 if (
nnu .gt. 0)
write(*,
"(A)")
" |------------------------|"
615 if (
nnu .gt. 0)
write(*,
"(A)")
""
678 call raise_exception(
"Not implemented neutrino mode (nuflag: "// &
679 int_to_str(
nuflag)//
").",
"read_neutrino_rates",&
706 if (
rrate_nu(i)%parts(j) .eq. 0)
exit
741 character(len=*),
intent(in) :: path
743 integer :: alloc_stat
753 if (alloc_stat .ne. 0)
then
754 call raise_exception(
"Could not allocate nurate array.", &
755 "read_binary_neutrino_reaction_data", 330001)
779 character(len=*),
intent(in) :: path
821 character(len=*),
intent(in) :: reaction_file_path
822 integer,
intent(in) :: reactype
827 integer :: nreactions
828 integer :: reac_count
838 real(
r_kind),
dimension(7) :: cs
840 integer :: nucl_id_out
849 read(file_id,
'(9x,i3,6x,i3,12x,i3)',iostat=stat) &
855 if (nucl_id .ne. -1)
then
858 read(file_id,
'(I3, 2x, 7(E12.6,2x))') ch_id, cs(:)
861 if (((reactype .eq. 0 ) .and. (
nu_channels(ch_id)%type .gt. 2))) cycle
863 if (((reactype .eq. 1 ) .and. (
nu_channels(ch_id)%type .le. 2))) cycle
868 nucl_id_out =
findaz(a_out,z_out)
869 if (nucl_id_out .ne. -1) nreactions = nreactions + 1
874 read(file_id,
'(I3, 2x, 7(E12.6,2x))')
880 allocate(
nunuc(nreactions),stat=istat)
881 if (istat.ne.0)
call raise_exception(
'Allocation of "nunuc" failed.',&
882 "read_reactions_sieverding",330001)
890 read(file_id,
'(9x,i3,6x,i3,12x,i3)',iostat=stat) &
896 if (nucl_id .ne. -1)
then
899 read(file_id,
'(I3, 2x, 7(E12.6,2x))') ch_id, cs(:)
902 if (((reactype .eq. 0 ) .and. (
nu_channels(ch_id)%type .gt. 2))) cycle
904 if (((reactype .eq. 1 ) .and. (
nu_channels(ch_id)%type .le. 2))) cycle
909 nucl_id_out =
findaz(a_out,z_out)
911 if (nucl_id_out .ne. -1)
then
913 nunuc(reac_count)%parts(:) = 0
914 nunuc(reac_count)%ch_amount(:) = 0
915 nunuc(reac_count)%parts(1) = nucl_id
916 nunuc(reac_count)%parts(2) = nucl_id_out
917 nunuc(reac_count)%ch_amount(1) = -1
918 nunuc(reac_count)%ch_amount(2) = 1
944 nunuc(reac_count)%source =
"siev"
945 nunuc(reac_count)%cs(:) = cs(:)
946 nunuc(reac_count)%avE(:) = 0
950 if (
nunuc(reac_count)%kind .le. 2)
then
957 reac_count = reac_count + 1
964 read(file_id,
'(I3, 2x, 7(E12.6,2x))')
971 call write_data_to_std_out(
'Neutrino reactions on (A,Z)',int_to_str(nreactions))
1001 character(50) :: reaction_string
1005 reaction_string =
"("//int_to_str(nurate%kind)//
") "//&
1006 trim(adjustl(
net_names(nurate%parts(1))))
1012 reaction_string = trim(adjustl(reaction_string))//
" =>"
1017 if (nurate%parts(i) .ne. 0)
then
1018 if (.not. s_prod)
then
1019 reaction_string = trim(adjustl(reaction_string))//
" + "//&
1020 int_to_str(nurate%ch_amount(i))//
" "//&
1023 reaction_string = trim(adjustl(reaction_string))//
" "//&
1024 int_to_str(nurate%ch_amount(i))//
" "//&
1068 character(len=*),
intent(in) :: channel_file_path
1069 integer :: nchannels
1071 character(len=6) :: nutype
1072 character(len=2) :: reac_type
1078 integer :: filename_id
1091 read(filename_id,*,iostat=stat)
1093 nchannels = nchannels + 1
1098 if (stat.ne.0)
call raise_exception(
'Allocation of "nu_channels" failed.', &
1099 "read_channels", 330001)
1107 read(filename_id,
"(i3,x,a6,2x,a2,3x,i1,2x,i1,2x,i1)",iostat=stat) &
1108 id, nutype, reac_type, amount_p, amount_n, amount_a
1113 call raise_exception(
"Channel id does not match the line number. "// &
1114 "Expected: "//int_to_str(i)//
", got: "//int_to_str(id)//
".", &
1115 "read_channels", 330006)
1119 if (reac_type.eq.
"cc")
then
1120 if (trim(adjustl(nutype)).eq.
"nue")
then
1123 elseif (trim(adjustl(nutype)).eq.
"nuebar")
then
1127 call raise_exception(
"Unknown neutrino type in nu_channels file. "// &
1128 "Only 'nue' and 'nuebar' are allowed for CC reactions. "// &
1129 "Got: '"//trim(adjustl(nutype))//
"'.", &
1130 "read_channels", 330003 )
1133 else if (reac_type.eq.
"nc")
then
1134 if (trim(adjustl(nutype)).eq.
"nux")
then
1137 elseif (trim(adjustl(nutype)).eq.
"nuxbar")
then
1141 call raise_exception(
"Unknown neutrino type in nu_channels file. "// &
1142 "Only 'nux' and 'nuxbar' are allowed for NC reactions. "// &
1143 "Got: '"//trim(adjustl(nutype))//
"'.", &
1144 "read_channels", 330003 )
1147 call raise_exception(
"Unknown reaction type in nu_channels file. "// &
1148 "Only 'cc' and 'nc' are allowed. "// &
1149 "Got: '"//trim(adjustl(reac_type))//
"'.", &
1150 "read_channels", 330004 )
1161 nu_channels(i)%Adiff = amount_n+amount_p+amount_a*4
1236 integer,
intent(in) :: nufile
1237 integer,
intent(in) :: typ
1245 character(5),
dimension(2) :: nam
1246 integer,
dimension(2) :: parts,ind
1247 real(r_kind),
dimension(nt_nugrid) :: cs
1248 type(
nurate_type),
dimension(:),
allocatable :: nuc_tmp
1255 read(nufile,
'(2/)',iostat=stat)
1259 allocate(nuc_tmp(len))
1271 nurate(i)%ch_amount(:) = 0
1272 nurate(i)%ch_amount(1) = -1
1273 nurate(i)%ch_amount(2) = 1
1279 read(nufile,112,iostat=stat)parts(1:2),cs(1:
nt_nugrid)
1281 call ident(parts(2),parts(1),parts(2)+1,parts(1)-1 &
1282 ,nam(1),nam(2),ind(1),ind(2),err)
1285 nuc_tmp(i)%parts(:) = 0
1286 nuc_tmp(i)%parts(1:2) = ind
1287 nuc_tmp(i)%ch_amount(:) = 0
1288 nuc_tmp(i)%ch_amount(1) = -1
1289 nuc_tmp(i)%ch_amount(2) = 1
1290 nuc_tmp(i)%source =
'lznu'
1296 nunuc = nuc_tmp(1:i)
1303 read(nufile,112,iostat=stat)parts(1:2),cs(1:
nt_nugrid)
1305 call ident(parts(2),parts(1),parts(2)-1,parts(1)+1 &
1306 ,nam(1),nam(2),ind(1),ind(2),err)
1309 nuc_tmp(i)%parts(:) = 0
1310 nuc_tmp(i)%parts(1:2) = ind
1311 nuc_tmp(i)%ch_amount(:) = 0
1312 nuc_tmp(i)%ch_amount(1) = -1
1313 nuc_tmp(i)%ch_amount(2) = 1
1314 nuc_tmp(i)%source =
'lzan'
1326 111
format(5x,2a5,28x,a4/7(f6.2,4x)/7(f6.2,4x))
1327 112
format(/4x,i3,5x,i3/13x,7(f13.2))
1353 integer,
intent(inout) :: rrate_length
1354 integer :: alloc_stat
1355 integer :: new_length
1358 if (nuflag .ge. 1)
then
1359 new_length = rrate_length+
nnu
1360 if (
nnu .ne. 0)
then
1361 if (.not.
allocated(rrate_array))
then
1363 allocate(rrate_array(
nnu),stat=alloc_stat)
1364 if ( alloc_stat /= 0)
call raise_exception(
'Allocation of "rrate_array" failed.',&
1365 "merge_neutrino_rates",330001)
1367 rrate_length = new_length
1369 call rrate_sort(rrate_length,rrate_array(1:rrate_length))
1370 call rrate_ms(rrate_array(1:rrate_length),rrate_length,&
1372 rrate_length = new_length
1374 if (
allocated(rrate_array))
deallocate(rrate_array)
1375 allocate(rrate_array(rrate_length),stat=alloc_stat)
1376 if ( alloc_stat /= 0)
call raise_exception(
'Allocation of "rrate_array" failed.',&
1377 "merge_neutrino_rates",330001)
1378 rrate_array(1:rrate_length) = rrate_tmp(1:rrate_length)
1417 integer,
intent(in) :: nnu_in
1418 character(4),
dimension(4) :: nutypes
1421 nutypes = (/
' nen' , &
1427 if(
nurate(i)%source == nutypes(j))
then
1430 else if (j.gt.2)
then
subroutine, private write_reac_verbose_out()
Write the amount of individual reactions to the out.
real(r_kind), dimension(:), allocatable, public nlumxbar
(anti-)mu and tau neutrino number luminosities from trajectory
character(max_fname_len) lxbar
Muon and Tauon antineutrino luminosities [erg/s].
subroutine, public init_nuflux()
Initialize nuflux module.
type(nurate_type), dimension(:), allocatable, private anunuc
anti-neutrino reactions on nuclides
logical use_prepared_network
Use a prepared folder with all necessary data in binary format.
character *5, dimension(:), allocatable, public net_names
list of isotopes contained in the network
real(r_kind), dimension(:), allocatable, public tnuxbar
(anti-)mu and tau neutrino temperatures from trajectory
integer, public ipro
index of alphas, neutrons and protons
subroutine, public nucs()
Interpolate neutrino cross sections.
real(r_kind), private rs
Schwarzschild radius for M=mns [km], calculated in init_nuflux.
Module inter_module with interpolation routines.
integer, private n_nuclei
real(r_kind), dimension(nt_nugrid), private sigtempnu
temperature grid for neutrino cross sections
character(max_fname_len) enuebar
average electron-antineutrino energies [MeV]
real(r_kind), dimension(:), allocatable, public tnuebar
(anti-)electron neutrino temperatures from trajectory
integer function, public findaz(ai, zi)
Finds an isotope index in the network table, given its A and Z. In case it was not found,...
subroutine, public merge_neutrino_rates(rrate_array, rrate_length)
Routine to merge neutrino rates into rrate array.
subroutine, public calculate_nu_rate(rrate, rat_calc)
Calculates the cross section times the neutrino flux.
subroutine, public nutemp(time)
Calculates (anti-) neutrino temperatures.
subroutine, private set_nutype(nnu_in)
Set the type of a neutrino reaction.
real(r_kind), dimension(:), allocatable, public nlumebar
(anti-)electron neutrino number luminosities from trajectory
integer function, public benam(name)
Returns the index number of isotope 'name'.
Channel type for neutrino reactions according to Sieverding et al. 2018
subroutine readnucs(nufile, typ)
Reads neutrino-nuclei reaction file.
real(r_kind), dimension(:), allocatable, public tnue
logical, private include_nc_reactions
Flag to include neutrino reactions that are not charged current.
character(:) function, allocatable, public int_to_str(num)
Converts a given integer to a string.
subroutine, public output_binary_neutrino_reaction_data(path)
Write the reactions to a file in binary format.
subroutine, public raise_exception(msg, sub, error_code)
Raise a exception with a given error message.
subroutine, public rrate_ms(x, xs, y, ys, r, ptz, rate_out)
Merges two tables of rates (of type global_class::reactionrate_type).
integer, private n_anuclei
integer, private n_nucleo
real(r_kind) nu_min_t
Neutrino temperature cutoff for neutrino reactions [MeV].
character(max_fname_len) enux
average Muon and Tauon neutrino energies [MeV]
character(max_fname_len) neutrino_mode
Similar to trajectory mode.
data fields for neutrino rates given in Langanke&Kolbe 2001
integer, parameter, public max_fname_len
maximum length of filenames
character(50) function nurate_string(nurate)
This function returns a string with the reaction information.
real(r_kind) nu_min_l
Neutrino luminosity cutoff for neutrino reactions [erg/g/s].
subroutine, private read_binary_neutrino_reaction_data(path)
Read the reactions from a file in binary format.
type(isotope_type), dimension(:), allocatable, public isotope
all nuclides used in the network
subroutine, public write_data_to_std_out(str_msg, value_str, unit)
Write data to the standard output (usually OUT)
real(r_kind), dimension(:), allocatable, public nlume
real(r_kind), dimension(:), allocatable, public ztime
time information from trajectory
Contains variables and parameters related to neutrino fluxes.
real(r_kind), dimension(4), public fluxnu
Neutrino fluxes This variable is calculated and set in nuflux. The dimension 4 accounts for the diffe...
integer nnu
Amount of neutrino reactions.
Subroutines for equation parsing in case of an analytic trajectory or luminosity mode.
type(nurate_type), dimension(:), allocatable, public nurate
neutrino rates
type(nu_channel_type), dimension(:), allocatable nu_channels
Array of neutrino channels.
subroutine, public rrate_sort(num, rate_array)
Sorts chapter one of the rate array.
character(max_fname_len) nuchannel_file
Contains neutrino channel information as in Sieverding et al. 2018.
real(r_kind) function, public parse_string(input_string, var_value)
Takes a string and evaluates the expression.
character(max_fname_len) le
electron-neutrino luminosities [erg/s]
subroutine, private read_reactions_sieverding(reaction_file_path, reactype)
Read the reactions from a file in the format of Sieverding et al 2018.
type(unit_type), public unit
constants and unit conversion factors
character(max_fname_len) nunucleo_rates_file
neutrino reaction rates on nucleons
subroutine read_channels(channel_file_path)
Read the channels from a file in the format of Sieverding et al 2018.
Provide some basic file-handling routines.
integer, private lumin_debugfile
Debug file to write neutrino luminosities, neutrinospheres, and temperatures.
type(reactionrate_type), dimension(:), allocatable rrate_nu
Neutrino rate array.
integer zsteps
number of timesteps in the hydro trajectory
Contains arrays representing thermodynamic conditions from hydro trajectory file.
integer, parameter nt_nugrid
Length of the neutrino rate grid.
real(r_kind), dimension(4), private tempnu
Neutrino temperatures. This variable is set in nutemp either from the values of a trajectory or from ...
integer function, public open_infile(file_name)
Same for reading (input file)
character(len= *), parameter, private nu_binary_name
Name of the neutrino binary file.
integer function, public open_outfile(file_name)
Shorthand for opening a new file for writing (output file)
Contains types and objects shared between multiple modules.
character(:) function, allocatable, public get_net_name(index, trimmed)
Getter of net_names, translating indices to a nucleus name.
subroutine, private read_neutrino_rates()
Read neutrino reactions and fill the global_class::nurate array.
character(max_fname_len) enue
average electron-neutrino energies [MeV]
integer function, public open_unformatted_outfile(file_name)
Shorthand for opening a new unformatted file for writing (output file)
character(max_fname_len) lebar
electron-antineutrino luminosities [erg/s]
subroutine, public ident(z1, n1, z2, n2, nam1, nam2, ind1, ind2, err)
Identifies the nuclide names and indices corresponding to z,n combinations (z1,n1),...
real(r_kind), dimension(:), allocatable, public nlumx
integer function open_unformatted_infile(file_name)
Open an unformatted file for reading.
integer nuflag
defines type of neutrino reactions used
character(max_fname_len) nurates_file
Neutrino reactions on heavy nuclei as in Sieverding et al. 2018.
Module mergesort_module for merging arrays of rates.
type(nurate_type), dimension(:), allocatable, private nunuc
neutrino reactions on nuclides
character(max_fname_len) prepared_network_path
Prepared network folder.
character(max_fname_len) enuxbar
average Muon and Tauon antineutrino energies [MeV]
subroutine, public nuflux(time, rkm)
Determines neutrino flux for current time (in units of cm^-2 s^-1).
character(max_fname_len) lx
Muon and Tauon neutrino luminosities [erg/s].
Contains all runtime parameters as well as phys and math constants.
subroutine, public getcoefficients(rate_array, length_rate_array)
Returns the 1/n! factor where n is the number of equal isotopes entering a reaction....
subroutine, public nurate_ms(x, xs, y, ys, r)
Merges two tables of neutrino rates (of type global_class::nurate_type).
real(r_kind), dimension(:), allocatable, public tnux
Subroutines needed to initialise the network.