beta_decay_rate_module.f90
Go to the documentation of this file.
1 !> @file beta_decay_rate_module.f90
2 !!
3 !! The error file code for this file is ***W12***.
4 !! Contains the module \ref beta_decay_rate_module.
5 
6 
7 !>
8 !! @brief This module contains subroutines to include external beta decays
9 !!
10 !! The external beta decays are given in a different format compared
11 !! to reaclib. They tabulate the halflife of a nucleus together
12 !! with Pn probabilities (beta delayed neutron emission). The file
13 !! includes up to P10n (10 beta delayed neutrons), which can not be
14 !! calculated in the default reaclib format (There P2n is max. in chapter 3,
15 !! or P3n in the new reaclib format in chapter 11). An example entry looks like:
16 !!\file{...
17 !! ca73 6.200000e-04
18 !! 0.0000 0.0100 0.0200 0.0100 0.2800 0.0800 0.4000 0.0700 0.1100 0.0100 0.0100
19 !! ...}
20 !!
21 !! Some tables, however, tabulate until P10n, for example,
22 !! [Moeller et al. 2019](https://matthewmumpower.com/publications/paper/2019/moller/nuclear-properties-for-astrophysical-and-radioactive-ion-beam-applications-ii)
23 !!
24 !! @author Moritz Reichert
25 !! @date 24.01.21
26 #include "macros.h"
29  implicit none
30 
31  !> Type for storing the beta decay data with Pn channels
32  type,private :: beta_pn_type
33  integer :: idx_parent !< Index of parent in abundance array
34  integer,dimension(11) :: idx_daughter !< Index of daughter in abundance array
35  integer :: z_parent !< Atomic number of parent
36  integer :: n_parent !< Neutron number of parent
37  real(r_kind),dimension(11) :: pn !< Pn probabilities
38  real(r_kind),dimension(11) :: qval !< Qvalue of the channels
39  real(r_kind) :: av_qtot !< Average Q-Value
40  real(r_kind) :: av_qnu !< Average Q-Value of neutrinos
41  real(r_kind) :: nu_frac !< Energy fraction of neutrinos
42  real(r_kind) :: halflife !< halflife of parent (s)
43  end type beta_pn_type
44  type(beta_pn_type),dimension(:),allocatable,private :: beta_pn !< Array storing the reaction rates
45  integer,private :: nbeta_pn !< Number of beta decays
46 
47 
48 
49  type(reactionrate_type),dimension(:),allocatable,public :: beta_decays !< array containing external beta decays
50  integer,public :: nbeta !< total number of external beta decays
51  logical,private :: ext_decays !< Flag if external beta decays are used
52  ! Helper variables for ignoring specific sources
53  character(len=4),allocatable,dimension(:),private :: src_ignore
54  integer,private :: src_ignore_length
55 
56  !
57  ! Public and private fields and methods of the module
58  !
59  public:: &
61  private:: &
63 
64 contains
65 
66  !> Initialize external beta decay rates.
67  !!
68  !! This subroutine counts and reads the rates into the array
69  !! \ref beta_decays.
70  !!
71  !! @author M. Reichert
72  !! @date 25.01.21
73  subroutine init_ext_beta_rates()
78  implicit none
79  integer :: beta_unit !< File ID of external beta decay file
80  integer :: alloc_stat !< Allocation status
81 
82  ! External beta decay flag
83  ext_decays = .false.
84 
85  if (use_beta_decay_file .and. (.not. use_prepared_network)) then
86  ! Flag that external beta decays are used
87  ext_decays = .true.
88 
89  ! Check if some sources should be ignored
91 
92  beta_unit= open_infile(beta_decay_file)
93  call count_reactions(beta_unit)
94 
95  !----- allocate the array of beta decays
96  allocate(beta_pn(nbeta_pn),stat=alloc_stat)
97  if ( alloc_stat /= 0) call raise_exception('Allocation of "beta_pn" failed',&
98  "init_ext_beta_rates",&
99  120001)
100 
101 
102  ! Read the beta decays
103  call read_beta_decays(beta_unit)
104  ! Close the file again
105  call close_io_file(beta_unit,beta_decay_file)
106 
107  ! ! Say how many there were
108  if (verbose_level .ge. 1) then
109  call write_data_to_std_out("Amount beta-decay format rates",int_to_str(nbeta_pn*11))
110  end if
111  end if
112 
113  end subroutine init_ext_beta_rates
114 
115 
116  !> Merge external beta decays into the larger rate array.
117  !!
118  !! The return value of this routine will be a larger rate array
119  !! and a new length
120  !!
121  !! @author M. Reichert
122  !! @date 25.01.21
123  subroutine merge_beta_decays(rrate_array,rrate_length)
127  implicit none
128  type(reactionrate_type),dimension(:),allocatable,intent(inout) :: rrate_array !< Large rate array, containing all reactions
129  integer,intent(inout) :: rrate_length !< length of rrate_array
130  integer :: alloc_stat !< Allocation state
131 
132 
133 
134  if (ext_decays .and. (.not. use_prepared_network)) then
135  if (nbeta_pn .ne. 0) then
136  if (.not. allocated(rrate_array)) then
137  ! Create an array in the correct format
139 
140  rrate_length = nbeta
141  !-- Allocate the reaclib rate array
142  allocate(rrate_array(nbeta),stat=alloc_stat)
143  if ( alloc_stat /= 0) call raise_exception('Allocation of "rrate_array" failed.',&
144  "merge_beta_decays",&
145  120001)
146  rrate_array(1:nbeta) = beta_decays(1:nbeta)
147  else
148  ! Check if we should not put some reactions into the array
149  call ignore_reactions(rrate_array,rrate_length)
150  !----- merge weak rates into rrate
151  call remove_weak_rates(rrate_array,rrate_length)
152  end if
153  !-- Deallocate the reaclib rate array
154  deallocate(beta_decays,stat=alloc_stat)
155  if (alloc_stat .ne. 0) call raise_exception('Deallocation of "beta_decays" failed',&
156  "merge_beta_decays", 120002)
157  end if
158  end if
159 
160  end subroutine merge_beta_decays
161 
162 
163  !> Subroutine to remove weak rates from the beta decay rate array
164  !!
165  !! This subroutine ensures that \ref parameter_class::beta_decay_src_ignore
166  !! is working. It removes all reactions from the array \ref beta_pn
167  !! that are listed in \ref parameter_class::beta_decay_src_ignore.
168  !!
169  !! @author M. Reichert
170  subroutine ignore_reactions(rrate_array,rrate_length)
171  use global_class, only: isotope
173  implicit none
174  integer,intent(in) :: rrate_length
175  type(reactionrate_type),dimension(:),allocatable :: rrate_array
176  type(beta_pn_type),dimension(:),allocatable :: rrate_tmp
177 
178  integer :: i,j
179  integer :: idx
180  integer :: z_tmp,n_tmp
181  integer :: replace_count
182  logical,dimension(:),allocatable :: mask
183  integer :: istat
184 
185  ! Check if you really want to add the rate
186  if (src_ignore_length .gt. 0) then
187  replace_count = 0
188  allocate(mask(nbeta_pn),stat=istat)
189  if (istat .ne. 0) call raise_exception('Allocation of "mask" failed',"ignore_reactions",&
190  120001)
191  mask(:) = .true.
192 
193  do i=1,nbeta_pn
194  ! Get the parent again and compare,
195  ! note that this could be vastly improved...
196  do j=1,rrate_length
197  if ((.not. rrate_array(j)%is_weak) .or. &
198  (.not. rrate_array(j)%reac_type .eq. rrt_betm) .or. &
199  (.not. rrate_array(j)%group .eq. 1)) cycle
200  if (rrate_array(j)%parts(1) .ne. beta_pn(i)%idx_parent) cycle
201 
202  ! Found the chapter 1 rate, is it included in the src_ignore list?
203  if (any(src_ignore .eq. adjustr(rrate_array(j)%source))) then
204  replace_count = replace_count+1
205  mask(i) = .false.
206  end if
207  end do
208  end do
209 
210  if (replace_count .gt. 0) then
211 
212  ! Say something
213  if (verbose_level .ge. 2) then
214  print*,"Ignoring "//int_to_str(replace_count)//" beta-decay rates by source criterium (beta_decay_src_ignore)."
215  end if
216 
217  ! Now we have a mask, pack the array
218  rrate_tmp = pack(beta_pn,mask)
219 
220  deallocate(beta_pn,stat=istat)
221  if (istat .ne. 0) call raise_exception('Deallocation of "beta_pn" failed',"ignore_reactions",&
222  120002)
223  ! We removed rates so adjust the size
224  nbeta_pn = nbeta_pn-replace_count
225 
226  ! Allocate beta_decays with new length
227  allocate(beta_pn(nbeta_pn),stat=istat)
228  if (istat .ne. 0) call raise_exception('Allocation of "beta_pn" failed',"ignore_reactions",&
229  120001)
230  ! Copy the temporary array back
231  beta_pn(1:nbeta_pn) = rrate_tmp(1:nbeta_pn)
232 
233  ! Deallocate the temporary array again
234  deallocate(rrate_tmp,stat=istat)
235  if (istat .ne. 0) call raise_exception('Deallocation of "rrate_tmp" failed',"ignore_reactions",&
236  120002)
237  else
238  ! Say something
239  if (verbose_level .ge. 2) then
240  print*,"Warning: Specified 'beta_decay_src_ignore', but no rate ignored."
241  end if
242  end if
243 
244  end if
245 
246 
247  end subroutine ignore_reactions
248 
249 
250 
251  !> Count the amount of external beta decays.
252  !!
253  !! After this routine has been called, nbeta will contain the amount of
254  !! external beta decay rates.
255  !!
256  !! @author M. Reichert
257  !! @date 25.01.21
258  subroutine count_reactions(sourcefile)
259  use global_class, only: isotope
260  use benam_class, only: findaz, benam
261  implicit none
262 
263  integer, intent(in) :: sourcefile !< file id to read beta decays
264 
265  real(r_kind),dimension(11) :: pn !< P0 to P10 channel probabilities
266  character(5) :: parent !< Name of the parent nucleus
267  real(r_kind) :: halflife !< halflife of the parent nucleus
268  integer :: count !< Counter for the reaction rates
269  integer :: read_stat !< Read status in the file
270  integer :: index_tmp !< Temporary index of the nucleus in net_names
271  integer :: z_tmp !< Temporary storage for amount of protons
272  integer :: n_tmp !< Temporary storage for amount of neutrons
273  integer :: a_tmp !< Temporary storage for amount of nucleons
274  integer :: j !< Loop variable
275 
276 
277  count = 0
278  ! Count the number of reactions
279  beta_loop: do
280  read(sourcefile,*, iostat = read_stat) parent,halflife
281  read(sourcefile,*, iostat = read_stat) pn(1:11)
282  index_tmp = benam(parent)
283  if (read_stat /= 0) exit
284  if (index_tmp .eq. 0) cycle
285 
286  ! Ensure that at least one daughter is
287  ! also in the table
288  ! Find out decay products
289  z_tmp = isotope(index_tmp)%p_nr
290  n_tmp = isotope(index_tmp)%n_nr
291  a_tmp = z_tmp + n_tmp
292  do j=1,11
293  ! Daughter index
294  index_tmp = findaz(a_tmp-(j-1),z_tmp+1)
295  if (index_tmp .ne. -1) exit
296  end do
297  ! The nucleus was found
298  if (j .ne. 12) count = count + 1
299 
300  end do beta_loop
301 
302  nbeta_pn = count
303 
304  end subroutine count_reactions
305 
306 
307  !> Remove beta decays from the rate array
308  !!
309  !! This routine removes beta decays in case that they exist in
310  !! another format ( see parameter_class::use_beta_decay_file ).
311  !!
312  !! @author Moritz Reichert
313  subroutine remove_weak_rates(rrate_array,length_rate_array)
316  implicit none
317 
318  logical,dimension(:),allocatable :: mask,mask_bet
319  logical :: delete
320  integer :: replace_count
321  integer :: istat
322  integer :: i,j,k,m
323  integer :: length_rate_array
324  integer :: nbeta_clean
325  type(reactionrate_type),dimension(:),allocatable :: rrate_tmp
326  type(reactionrate_type),dimension(:),allocatable :: rrate_array
327 
328  info_entry("remove_weak_rates")
329  replace_count = 0
330  allocate(mask(length_rate_array),stat=istat)
331  if (istat .ne. 0) call raise_exception('Allocation of "mask" failed',"remove_weak_rates",&
332  120001)
333  mask(:) = .true.
334 
335  do i = 1 , length_rate_array
336  if ((.not. rrate_array(i)%is_weak) .or. &
337  (.not. rrate_array(i)%reac_type .eq. rrt_betm)) cycle
338  do j=1, nbeta_pn
339  if (beta_pn(j)%idx_parent .eq. rrate_array(i)%parts(1)) then
340 
341  part_loop: do k=2,6
342  if (rrate_array(i)%parts(k) .eq. 0) exit part_loop
343  delete = .false.
344 
345  parts_bet: do m=1,11
346  ! Daughter included?
347  if (beta_pn(j)%idx_daughter(m) .eq. -1) cycle parts_bet
348 
349  if ((beta_pn(j)%idx_daughter(m) .eq. rrate_array(i)%parts(k)) &
350  .or. (rrate_array(i)%parts(k) .eq. ineu)) then
351  delete = .true.
352  exit parts_bet
353  end if
354 
355  end do parts_bet
356  ! Was something else than all possible daughters or neutrons?
357  if (delete .eqv. .false.) exit part_loop
358  end do part_loop
359 
360  if (delete) then
361  mask(i) = .false.
362  replace_count = replace_count + 1
363  end if
364  end if
365  end do
366  end do
367 
368  if (verbose_level.ge.2) then
369  print*,'Replacing ',replace_count,' weak rates!'
370  end if
371 
372  ! Remove the rates and implement other decay rates
373  if ((replace_count .gt. 0) .or. (nbeta_pn .gt. 0)) then
374 
375  ! Get the beta decay rates in reactionrate_type format
377 
378  ! Deallocate the old array
379  deallocate(beta_pn,stat=istat)
380  if (istat .ne. 0) call raise_exception('Deallocation of "beta_pn" failed',"remove_weak_rates",&
381  120002)
382 
383  ! Now merge the two arrays
384  allocate(rrate_tmp(length_rate_array-replace_count),stat=istat)
385  if (istat .ne. 0) call raise_exception('Allocation of "rrate_tmp" failed',"remove_weak_rates",&
386  120001)
387 
388  rrate_tmp = pack(rrate_array,mask)
389 
390  deallocate(rrate_array,stat=istat)
391  if (istat .ne. 0) call raise_exception('Deallocation of "rrate" failed',"remove_weak_rates",&
392  120002)
393  length_rate_array = length_rate_array-replace_count
394 
395  allocate(rrate_array(length_rate_array+nbeta),stat=istat)
396  if (istat .ne. 0) call raise_exception('Allocation of "rrate" failed',"remove_weak_rates",&
397  120001)
398 
399  rrate_array(1:length_rate_array) = rrate_tmp(1:length_rate_array)
400  rrate_array(length_rate_array+1:length_rate_array+nbeta) = beta_decays(1:nbeta)
401  length_rate_array = length_rate_array + nbeta
402 
403  deallocate(rrate_tmp,stat=istat)
404  if (istat .ne. 0) call raise_exception('Deallocation of "rrate_tmp" failed',"remove_weak_rates",&
405  120002)
406  end if
407 
408  info_exit("remove_weak_rates")
409  end subroutine remove_weak_rates
410 
411 
412 
413  !> Convert \ref beta_pn_type to \ref reactionrate_type
414  !!
415  !! Creates a reactionrate_type array from the beta_pn_type array.
416  !! Rates with Pn of 0 will not result in an extra rate.
417  !!
418  !! @author Moritz Reichert
419  !! @date 28.02.2023
420  subroutine create_rrate_array(rrate_beta,rrate_beta_length)
424  implicit none
425  type(reactionrate_type), allocatable, intent(out) :: rrate_beta(:) !< Reaction rates in reactionrate_type format
426  integer, intent(out) :: rrate_beta_length !< Length of rrate_beta
427 
428  integer :: i,j !< Loop variables
429  integer :: istat !< Status variable
430  integer :: count !< Counter for the reaction rates
431 
432  ! First count the amount of necessary beta decay rates
433  count = 0
434  do i=1,nbeta_pn
435  pn_loop: do j=1,11
436  if (beta_pn(i)%pn(j) .eq. 0) cycle pn_loop
437  count = count + 1
438  end do pn_loop
439  end do
440 
441  rrate_beta_length = count
442 
443  ! Allocate the array
444  allocate(rrate_beta(count),stat=istat)
445  if (istat .ne. 0) call raise_exception('Allocation of "rrate_beta" failed',"create_rrate_array",&
446  120001)
447 
448  ! Fill the array
449  count = 0
450  do i=1,nbeta_pn
451  pn_loop2: do j=1,11
452  if (beta_pn(i)%pn(j) .eq. 0) cycle pn_loop2
453  count = count + 1
454  rrate_beta(count)%parts(:) = 0
455  rrate_beta(count)%source = "wext" ! weak-extern
456  rrate_beta(count)%is_reverse = .false.
457  rrate_beta(count)%cached = -1
458  rrate_beta(count)%is_resonant = .false.
459  rrate_beta(count)%is_weak = .true.
460  rrate_beta(count)%is_const = .true.
461  rrate_beta(count)%q_value = beta_pn(i)%Qval(j)
462  rrate_beta(count)%reac_src = rrs_wext
463  rrate_beta(count)%reac_type = rrt_betm
464  rrate_beta(count)%param(:) = 0.0d0
465  rrate_beta(count)%one_over_n_fac = 1.0d0
466 
467  ! Get the amount of energy radiated away by neutrinos
468  if ((beta_pn(i)%Av_Qtot .eq. -1) .or. (beta_pn(i)%Av_Qnu .eq. -1)) then
469  if (use_neutrino_loss_file) then
470  if (qnuloss(beta_pn(i)%idx_parent) .ne. -1) then
471  rrate_beta(count)%nu_frac = qnuloss(beta_pn(i)%idx_parent)/beta_pn(i)%Av_Qtot
472  else
473  rrate_beta(count)%nu_frac = heating_frac
474  end if
475  else
476  rrate_beta(count)%nu_frac = heating_frac
477  end if
478  else
479  rrate_beta(count)%nu_frac = beta_pn(i)%Av_Qnu/beta_pn(i)%Av_Qtot
480  end if
481 
482  rrate_beta(count)%group = min(j,2) ! Put all remaining rates into chapter 2
483  rrate_beta(count)%parts(1) = beta_pn(i)%idx_parent ! parent nucleus
484  rrate_beta(count)%ch_amount(1) = -1 ! Parent is destroyed
485 
486  if (j-1 .eq. 0) then
487  rrate_beta(count)%parts(2) = beta_pn(i)%idx_daughter(j) ! decay product
488  rrate_beta(count)%ch_amount(2) = 1 ! product is created
489  else
490  rrate_beta(count)%parts(2) = ineu ! neutrons
491  rrate_beta(count)%parts(3) = beta_pn(i)%idx_daughter(j) ! decay product
492  rrate_beta(count)%ch_amount(2) = j-1 ! j-1 nuclei are created
493  rrate_beta(count)%ch_amount(3) = 1 ! product is created
494  end if
495 
496  ! Put the correct reaclib parameter
497  rrate_beta(count)%param(1) = dlog(beta_pn(i)%Pn(j)*(dlog(2.0d0)/beta_pn(i)%halflife))
498 
499  end do pn_loop2
500  end do
501 
502  end subroutine create_rrate_array
503 
504 
505 
506 
507 
508  !>
509  !! Reads beta decays from a separate file.
510  !!
511  !! This routine is thought to read beta decays in a different format than reaclib.
512  !! An advantage of this is that we can implement more than the P2n channel.
513  !! The new format allows beta delayed neutrons up to 10 neutrons that become more
514  !! important close to stability.
515  !! An example input file could look like:
516  !!\file{
517  !! ca73 6.200000e-04
518  !! 0.0000 0.0100 0.0200 0.0100 0.2800 0.0800 0.4000 0.0700 0.1100 0.0100 0.0100 }
519  !! which will replace the decay of ca73 with a half life of 6.2e-04s and the listet Pn probabilities.
520  !! Additionally, the average Q-Value and the average neutrino Q-Value can be given optionally in the first line.
521  !! In this case an entry could look like:
522  !! ca73 1.268195e-03 2.443690e+01 9.034672e+00
523  !! 0.0030 0.0000 0.0010 0.0000 0.0020 0.9950 0.0000 0.0000 0.0000 0.0000 0.0000 }
524  !! where the first line gives the name of the parent nucleus, the half life, the average Q-Value and the
525  !! average neutrino Q-Value.
526  !!
527  !! @author Moritz Reichert
528  !!
529  !! \b Edited:
530  !! - 20.05.19
531  !! .
532  subroutine read_beta_decays(sourcefile)
533  use global_class, only: isotope,ineu
534  use benam_class, only: benam, findaz
536  use parameter_class, only: unit
537  implicit none
538  integer, intent(in) :: sourcefile !< file id to read beta decays
539  !
540  real(r_kind),dimension(11) :: pn !< P0 to P10 channel probabilities
541  character(5) :: parent !< Name of the parent nucleus
542  real(r_kind) :: halflife !< halflife of the parent nucleus
543  real(r_kind) :: qtot !< Average total Q-Value
544  real(r_kind) :: qnu !< Average neutrino Q-Value
545  real(r_kind) :: probnot !< Probability of not included daughters
546  type(reactionrate_type) :: rr_tmp !< temporary reaction rate
547  integer :: count !< Counter for the reaction rates
548  integer :: read_stat !< Read status in the file
549  integer :: index_tmp !< Temporary index of the nucleus in net_names
550  integer :: z_tmp !< Temporary storage for amount of protons
551  integer :: n_tmp !< Temporary storage for amount of neutrons
552  integer :: a_tmp !< Temporary storage for amount of nucleons
553  character(200) :: helper !< helper variable to get the amount of columns in the file
554  integer :: par_ind_tmp!< Index of parent nucleus in net_names
555  integer :: col_count !< Amount of columns in the file
556  integer :: fformat !< Format of the file
557  integer :: j !< Loop variable
558  integer :: i !< Loop variable
559 
560  info_entry("read_beta_decays")
561 
562  rewind(sourcefile)
563 
564  ! Find out the number of columns in the first line of the file
565  ! This defines the format
566  read(sourcefile,"(A)", iostat = read_stat) helper
567  col_count = 0
568  do i = 2,200
569  if ((helper(i-1:i-1) .ne. ' ') .and. (helper(i:i) .eq. ' ')) then
570  ! Count the columns
571  col_count = col_count +1
572  end if
573  end do
574 
575  ! Check if the file is compatible
576  if (col_count .eq. 2) then
577  fformat = 1
578  else if (col_count .eq. 4) then
579  fformat = 2
580  else
581  call raise_exception('First line of the beta decay file has an incompatible amount of columns. '//&
582  'It should be either 2 or 4, but got '//int_to_str(col_count)//".",&
583  "read_beta_decays")!! TODO Give error code!
584  end if
585 
586  ! Rewind the file again to start reading
587  rewind(sourcefile)
588 
589  i = 0
590  read_loop: do
591  if (fformat .eq. 1) then
592  read(sourcefile,*, iostat = read_stat) parent,halflife
593  qnu = -1
594  qtot = -1
595  elseif (fformat .eq. 2) then
596  read(sourcefile,*, iostat = read_stat) parent,halflife,qtot,qnu
597  end if
598  read(sourcefile,*, iostat = read_stat) pn(1:11)
599 
600  if (read_stat /= 0) exit read_loop
601  par_ind_tmp = benam(parent)
602  if (par_ind_tmp .eq. 0) cycle read_loop
603 
604  ! Take care of nuclei that are not included.
605  ! Find out decay products
606  z_tmp = isotope(par_ind_tmp)%p_nr
607  n_tmp = isotope(par_ind_tmp)%n_nr
608  a_tmp = z_tmp + n_tmp
609 
610  do j=1,11
611  ! Daughter index
612  index_tmp = findaz(a_tmp-(j-1),z_tmp+1)
613  if (index_tmp .ne. -1) exit
614  end do
615 
616  ! There was no daughter nucleus included at all.
617  ! Don't include this rate
618  if (j .eq. 12) cycle read_loop
619 
620  ! Next rate
621  i = i + 1
622 
623  ! Fill the struct with decay information
624  beta_pn(i)%halflife = halflife
625  beta_pn(i)%idx_parent = par_ind_tmp
626  beta_pn(i)%Z_parent = z_tmp
627  beta_pn(i)%N_parent = n_tmp
628  beta_pn(i)%Av_Qnu = qnu
629  beta_pn(i)%Av_Qtot = qtot
630 
631  do j=1,11
632  index_tmp = findaz(a_tmp-(j-1),z_tmp+1)
633  beta_pn(i)%idx_daughter(j) = index_tmp
634  beta_pn(i)%Pn(j) = pn(j)
635  ! Fill the Q-value
636  beta_pn(i)%Qval(j) = 0
637  if (beta_pn(i)%idx_daughter(j) .ne. -1) then
638  beta_pn(i)%Qval(j) = isotope(par_ind_tmp)%mass_exc - &
639  (isotope(ineu)%mass_exc*float(j-1)+isotope(beta_pn(i)%idx_daughter(j))%mass_exc)
640  end if
641  end do
642  probnot = 0
643  do j=11,1,-1
644  if (beta_pn(i)%idx_daughter(j) .eq. -1) then
645  probnot = probnot + beta_pn(i)%Pn(j)
646  beta_pn(i)%Pn(j) = 0
647  end if
648 
649  if ((beta_pn(i)%idx_daughter(j) .ne. -1) .and. (probnot .ne. 0)) then
650  beta_pn(i)%Pn(j) = beta_pn(i)%Pn(j) + probnot
651  probnot = 0
652  end if
653  end do
654  ! Take also care if the very left nuclei where not included
655  ! Loop through it again but from left to right
656  if (probnot .ne. 0) then
657  do j=1,11,1
658  if (beta_pn(i)%idx_daughter(j) .eq. -1) then
659  probnot = probnot + beta_pn(i)%Pn(j)
660  beta_pn(i)%Pn(j) = 0
661  end if
662 
663  if ((beta_pn(i)%idx_daughter(j) .ne. -1) .and. (probnot .ne. 0)) then
664  beta_pn(i)%Pn(j) = beta_pn(i)%Pn(j) + probnot
665  probnot = 0
666  end if
667  end do
668  end if
669 
670  if (beta_pn(i)%Av_Qtot .eq. -1) then
671  do j=1,11,1
672  beta_pn(i)%Av_Qtot = beta_pn(i)%Av_Qtot + beta_pn(i)%Pn(j)*beta_pn(i)%Qval(j)
673  end do
674  end if
675 
676  ! Lets see, this should always work. If not there is something conceptional wrong. Raise exception...
677  if (probnot .ne. 0) then
678  call raise_exception('No daughter nucleus of beta decay file seemed to be implemented.',&
679  "read_beta_decays")!! TODO Give error code!
680  end if
681  end do read_loop
682 
683  info_exit("read_beta_decays")
684  end subroutine read_beta_decays
685 
686 
687 
688 
689 
690 
691 end module beta_decay_rate_module
beta_decay_rate_module::merge_beta_decays
subroutine, public merge_beta_decays(rrate_array, rrate_length)
Merge external beta decays into the larger rate array.
Definition: beta_decay_rate_module.f90:124
parameter_class::use_prepared_network
logical use_prepared_network
Use a prepared folder with all necessary data in binary format.
Definition: parameter_class.f90:94
global_class::reactionrate_type
reaction rate type
Definition: global_class.f90:44
benam_class::findaz
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,...
Definition: benam_class.f90:887
parameter_class::beta_decay_file
character(max_fname_len) beta_decay_file
File for reading in beta decays in different format.
Definition: parameter_class.f90:183
parameter_class::beta_decay_src_ignore
character(max_fname_len) beta_decay_src_ignore
Source flag(s) to ignore within the beta decay file.
Definition: parameter_class.f90:95
error_msg_class
Error handling routines.
Definition: error_msg_class.f90:16
benam_class::benam
integer function, public benam(name)
Returns the index number of isotope 'name'.
Definition: benam_class.f90:251
beta_decay_rate_module::count_reactions
subroutine, private count_reactions(sourcefile)
Count the amount of external beta decays.
Definition: beta_decay_rate_module.f90:259
beta_decay_rate_module
This module contains subroutines to include external beta decays.
Definition: beta_decay_rate_module.f90:27
parameter_class::use_neutrino_loss_file
logical use_neutrino_loss_file
Use a file with Qnu values?
Definition: parameter_class.f90:105
error_msg_class::int_to_str
character(:) function, allocatable, public int_to_str(num)
Converts a given integer to a string.
Definition: error_msg_class.f90:224
parameter_class::use_beta_decay_file
logical use_beta_decay_file
switch for using different format for beta decays
Definition: parameter_class.f90:93
error_msg_class::raise_exception
subroutine, public raise_exception(msg, sub, error_code)
Raise a exception with a given error message.
Definition: error_msg_class.f90:245
mergesort_module::rrate_ms
subroutine, public rrate_ms(x, xs, y, ys, r, ptz, rate_out)
Merges two tables of rates (of type global_class::reactionrate_type).
Definition: mergesort_module.f90:227
global_class::ineu
integer, public ineu
Definition: global_class.f90:94
global_class::isotope
type(isotope_type), dimension(:), allocatable, public isotope
all nuclides used in the network
Definition: global_class.f90:34
beta_decay_rate_module::nbeta
integer, public nbeta
total number of external beta decays
Definition: beta_decay_rate_module.f90:50
nucstuff_class
Module with helper functions such as rate tabulation, partition functions, and theoretical weak rates...
Definition: nucstuff_class.f90:11
rrs_wext
#define rrs_wext
Definition: macros.h:55
beta_decay_rate_module::beta_pn_type
Type for storing the beta decay data with Pn channels.
Definition: beta_decay_rate_module.f90:32
beta_decay_rate_module::create_rrate_array
subroutine create_rrate_array(rrate_beta, rrate_beta_length)
Convert beta_pn_type to reactionrate_type.
Definition: beta_decay_rate_module.f90:421
global_class::qnuloss
real(r_kind), dimension(:), allocatable, public qnuloss
Qnu for decay of each isotope [MeV].
Definition: global_class.f90:96
mergesort_module::rrate_sort
subroutine, public rrate_sort(num, rate_array)
Sorts chapter one of the rate array.
Definition: mergesort_module.f90:676
beta_decay_rate_module::nbeta_pn
integer, private nbeta_pn
Number of beta decays.
Definition: beta_decay_rate_module.f90:45
beta_decay_rate_module::remove_weak_rates
subroutine, private remove_weak_rates(rrate_array, length_rate_array)
Remove beta decays from the rate array.
Definition: beta_decay_rate_module.f90:314
parameter_class::unit
type(unit_type), public unit
constants and unit conversion factors
Definition: parameter_class.f90:54
parameter_class::heating_frac
real(r_kind) heating_frac
use this fraction of nuclear-generated energy for heating
Definition: parameter_class.f90:123
beta_decay_rate_module::init_ext_beta_rates
subroutine, public init_ext_beta_rates()
Initialize external beta decay rates.
Definition: beta_decay_rate_module.f90:74
file_handling_class
Provide some basic file-handling routines.
Definition: file_handling_class.f90:18
r_kind
#define r_kind
Definition: macros.h:46
nucstuff_class::analyze_src_string
subroutine, public analyze_src_string(input_string, output_array, length_output)
Analyze a string and split it with delimiter ";".
Definition: nucstuff_class.f90:422
beta_decay_rate_module::src_ignore_length
integer, private src_ignore_length
Definition: beta_decay_rate_module.f90:54
rrt_betm
#define rrt_betm
Definition: macros.h:59
file_handling_class::open_infile
integer function, public open_infile(file_name)
Same for reading (input file)
Definition: file_handling_class.f90:126
global_class
Contains types and objects shared between multiple modules.
Definition: global_class.f90:19
beta_decay_rate_module::read_beta_decays
subroutine, private read_beta_decays(sourcefile)
Reads beta decays from a separate file.
Definition: beta_decay_rate_module.f90:533
beta_decay_rate_module::ext_decays
logical, private ext_decays
Flag if external beta decays are used.
Definition: beta_decay_rate_module.f90:51
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
beta_decay_rate_module::beta_decays
type(reactionrate_type), dimension(:), allocatable, public beta_decays
array containing external beta decays
Definition: beta_decay_rate_module.f90:49
beta_decay_rate_module::beta_pn
type(beta_pn_type), dimension(:), allocatable, private beta_pn
Array storing the reaction rates.
Definition: beta_decay_rate_module.f90:44
mergesort_module
Module mergesort_module for merging arrays of rates.
Definition: mergesort_module.f90:16
beta_decay_rate_module::ignore_reactions
subroutine ignore_reactions(rrate_array, rrate_length)
Subroutine to remove weak rates from the beta decay rate array.
Definition: beta_decay_rate_module.f90:171
parameter_class
Contains all runtime parameters as well as phys and math constants.
Definition: parameter_class.f90:24
beta_decay_rate_module::src_ignore
character(len=4), dimension(:), allocatable, private src_ignore
Definition: beta_decay_rate_module.f90:53
benam_class
Subroutines needed to initialise the network.
Definition: benam_class.f90:11