30 integer,
dimension(2) :: parts
32 character(4) :: source
34 integer :: n_temp_grid
39 real(
r_kind),
dimension(:),
allocatable :: temp_grid
40 real(
r_kind),
dimension(:),
allocatable :: rho_grid
41 real(
r_kind),
dimension(:,:),
allocatable:: mue_kin
42 real(
r_kind),
dimension(:,:),
allocatable:: dmue_kin_dt
43 real(
r_kind),
dimension(:,:),
allocatable:: dmue_kin_dr
44 real(
r_kind),
dimension(:,:),
allocatable:: dmue_kin_dt_dr
45 real(
r_kind),
dimension(:,:),
allocatable:: beta_rate
46 real(
r_kind),
dimension(:,:),
allocatable:: dbeta_dt
47 real(
r_kind),
dimension(:,:),
allocatable:: dbeta_dr
48 real(
r_kind),
dimension(:,:),
allocatable:: dbeta_dt_dr
49 real(
r_kind),
dimension(:,:),
allocatable:: ft_rate
50 real(
r_kind),
dimension(:,:),
allocatable:: dft_dt
51 real(
r_kind),
dimension(:,:),
allocatable:: dft_dr
52 real(
r_kind),
dimension(:,:),
allocatable:: dft_dt_dr
53 real(
r_kind),
dimension(:,:),
allocatable:: nu_loss
159 allocate(
weak_rate(i)%dmue_kin_dT(nt,nr),&
183 character(len=7) :: tmp
185 if (verbose_level .ge. 1)
then
187 elseif (verbose_level .ge. 2)
then
188 if (
nweak .gt. 0)
write(*,
"(A)")
""
189 if (
nweak .gt. 0)
write(*,
"(A)")
" FFN rates: "
190 if (
nweak .gt. 0)
write(*,
"(A)")
" |---------------------------|"
192 if (
nweak .gt. 0)
write(*,
"(A)")
" | Total :"//adjustr(tmp)//
" |"
194 if (
n_ec .gt. 0)
write(*,
"(A)")
" | Electron-capture :"//adjustr(tmp)//
" |"
196 if (
n_o .gt. 0)
write(*,
"(A)")
" | Beta-decay :"//adjustr(tmp)//
" |"
197 if (
nweak .gt. 0)
write(*,
"(A)")
" |---------------------------|"
198 if (
nweak .gt. 0)
write(*,
"(A)")
""
215 integer,
intent(inout) :: rrate_length
217 integer :: alloc_stat
218 integer :: new_length
221 if (.not.
allocated(rrate_array))
then
223 allocate(rrate_array(
nweak),stat=alloc_stat)
224 if ( alloc_stat /= 0)
call raise_exception(
'Allocation of "rrate_array" failed.',&
225 "merge_theoretical_weak_rates",440001)
229 call rrate_sort(rrate_length,rrate_array(1:rrate_length))
235 rrate_length = new_length
237 if (
allocated(rrate_array))
deallocate(rrate_array)
238 allocate(rrate_array(rrate_length),stat=alloc_stat)
239 if ( alloc_stat /= 0)
call raise_exception(
'Allocation of "rrate_array" failed.',&
240 "merge_theoretical_weak_rates",440001)
241 rrate_array(1:rrate_length) = rrate_tmp(1:rrate_length)
265 character(len=*),
intent(in) :: path
268 logical :: allocated_or_not
281 if (status /= 0)
call raise_exception(
'Allocation of "weak_rate" failed.',&
282 "read_binary_weak_reaction_data",440001)
296 read(file_id) allocated_or_not
297 if (allocated_or_not)
then
301 read(file_id) allocated_or_not
302 if (allocated_or_not)
then
306 read(file_id) allocated_or_not
307 if (allocated_or_not)
then
311 read(file_id) allocated_or_not
312 if (allocated_or_not)
then
316 read(file_id) allocated_or_not
317 if (allocated_or_not)
then
321 read(file_id) allocated_or_not
322 if (allocated_or_not)
then
324 read(file_id)
weak_rate(i)%dmue_kin_dT_dR
326 read(file_id) allocated_or_not
327 if (allocated_or_not)
then
331 read(file_id) allocated_or_not
332 if (allocated_or_not)
then
336 read(file_id) allocated_or_not
337 if (allocated_or_not)
then
341 read(file_id) allocated_or_not
342 if (allocated_or_not)
then
346 read(file_id) allocated_or_not
347 if (allocated_or_not)
then
351 read(file_id) allocated_or_not
352 if (allocated_or_not)
then
356 read(file_id) allocated_or_not
357 if (allocated_or_not)
then
361 read(file_id) allocated_or_not
362 if (allocated_or_not)
then
366 read(file_id) allocated_or_not
367 if (allocated_or_not)
then
375 if (status /= 0)
call raise_exception(
'Allocation of "rrate_weak_exp" failed.',&
376 "read_binary_weak_reaction_data",440001)
395 character(len=*),
intent(in) :: path
399 if (.not.
weak)
return
425 write(file_id)
allocated(
weak_rate(i)%temp_grid)
427 write(file_id)
allocated(
weak_rate(i)%rho_grid)
429 write(file_id)
allocated(
weak_rate(i)%mue_kin)
431 write(file_id)
allocated(
weak_rate(i)%dmue_kin_dT)
433 write(file_id)
allocated(
weak_rate(i)%dmue_kin_dR)
435 write(file_id)
allocated(
weak_rate(i)%dmue_kin_dT_dR)
436 if (
allocated(
weak_rate(i)%dmue_kin_dT_dR))
write(file_id)
weak_rate(i)%dmue_kin_dT_dR
437 write(file_id)
allocated(
weak_rate(i)%beta_rate)
439 write(file_id)
allocated(
weak_rate(i)%dbeta_dT)
441 write(file_id)
allocated(
weak_rate(i)%dbeta_dR)
443 write(file_id)
allocated(
weak_rate(i)%dbeta_dT_dR)
445 write(file_id)
allocated(
weak_rate(i)%ft_rate)
447 write(file_id)
allocated(
weak_rate(i)%dft_dT)
449 write(file_id)
allocated(
weak_rate(i)%dft_dR)
451 write(file_id)
allocated(
weak_rate(i)%dft_dT_dR)
453 write(file_id)
allocated(
weak_rate(i)%nu_loss)
489 real(
r_kind),
intent(in) :: temp
490 real(
r_kind),
intent(in) :: rho
491 real(
r_kind),
intent(in) :: ye
492 real(
r_kind),
intent(out) :: rat_calc
493 logical,
optional :: nuloss
496 real(
r_kind) :: rbeta,rft,repsi,rnu
504 wind = int(rrate%param(1))
512 if (
present(nuloss))
then
515 rnu = rnu/(rft+rbeta)
527 if (
present(nuloss))
then
537 if ((epsi.lt.1.d-100).or.(rft.le.9.d-99))
then
540 repsi = dlog(2.d0)*epsi/rft
545 rat_calc = repsi + rbeta
550 if (
present(nuloss))
then
554 rrate%nu_frac = rnu/rrate%q_value
669 integer,
intent(in) :: sourcefile
670 integer,
intent(out) :: cnt
672 real(
r_kind) :: qfwd, qbwd
673 real(
r_kind) :: min_rho,max_rho,min_temp,max_temp
674 character*4,
dimension(2) :: wnam
675 character*5,
dimension(2) :: wparts
676 integer,
dimension(2) :: parts_index
677 real(
r_kind),
dimension(:),
allocatable :: beta_bwd,ec_ft,nu_loss,beta_fwd,mue_tmp
678 real(
r_kind),
dimension(:),
allocatable :: pc_ft,anu_loss,t_grid,r_grid
679 integer,
dimension(:),
allocatable :: sort_keys
680 character(len=300) :: null
681 integer :: i,j,k,read_stat,alloc_stat,len_rate
683 logical :: cycle_loop
685 info_entry(
"readweak_logft")
690 read(sourcefile,101, iostat = read_stat) wnam(1),qfwd
691 if (read_stat /= 0)
exit
692 read(sourcefile,101) wnam(2),qbwd
694 read(sourcefile,*)null
699 read(sourcefile,
"(a)", iostat = read_stat)null
700 if (trim(adjustl(null)) .eq.
"end")
exit len_rate_loop
701 if (read_stat /= 0)
exit len_rate_loop
702 len_rate = len_rate+1
707 parts_index(j) =
benam(wparts(j))
708 if (parts_index(j) .eq. 0)
then
717 if ( alloc_stat /= 0)
call raise_exception(
'Allocation of "weak_rate" failed',&
718 "readweak_logft",440001)
725 read(sourcefile,101, iostat = read_stat) wnam(1),qfwd
726 if (read_stat /= 0)
exit
727 read(sourcefile,101) wnam(2),qbwd
729 read(sourcefile,*)null
734 read(sourcefile,
"(a)", iostat = read_stat)null
735 if (trim(adjustl(null)) .eq.
"end")
exit len_rate_loop2
736 if (read_stat /= 0)
exit len_rate_loop2
737 len_rate = len_rate+1
738 end do len_rate_loop2
742 parts_index(j) =
benam(wparts(j))
743 if (parts_index(j) .eq. 0)
then
759 read(sourcefile,101, iostat = read_stat) wnam(1),qfwd
760 if (read_stat /= 0)
exit
761 read(sourcefile,101) wnam(2),qbwd
763 read(sourcefile,*)null
769 parts_index(j) =
benam(wparts(j))
770 if (parts_index(j) .eq. 0)
then
776 read(sourcefile,
"(a)", iostat = read_stat)null
777 if (trim(adjustl(null)) .eq.
"end")
exit len_rate_loop3
778 if (read_stat /= 0)
exit len_rate_loop3
779 end do len_rate_loop3
784 if (
allocated(beta_bwd))
then
785 if (
size(beta_bwd) .ne.
weak_rate(k)%n_points)
then
786 deallocate(beta_bwd,ec_ft,nu_loss,beta_fwd,pc_ft,anu_loss,t_grid,r_grid,sort_keys,mue_tmp,stat=read_stat)
787 if (read_stat /= 0)
call raise_exception(
"Deallocation of rate variables failed!",&
788 "readweak_logft",440002)
795 if (read_stat /= 0)
call raise_exception(
"Allocation of rate variables failed!",&
796 "readweak_logft",440001)
804 if (read_stat /= 0)
call raise_exception(
"Allocation of rate variables failed!",&
805 "readweak_logft",440001)
809 min_temp=huge(min_temp)
810 max_temp=-1*huge(min_temp)
811 min_rho =huge(min_temp)
812 max_rho =-1*huge(min_temp)
815 read(sourcefile,*)t_grid(i),r_grid(i),mue_tmp(i),beta_bwd(i),ec_ft(i),nu_loss(i),beta_fwd(i),pc_ft(i),anu_loss(i)
816 if (t_grid(i)<min_temp)min_temp=t_grid(i)
817 if (t_grid(i)>max_temp)max_temp=t_grid(i)
818 if (r_grid(i)<min_rho) min_rho =r_grid(i)
819 if (r_grid(i)>max_rho) max_rho =r_grid(i)
821 read(sourcefile,
'(a1)')null
829 if (t_grid(i) .ne. t_grid(i-1)) count = count + 1
837 if (t_grid(i) .ne. t_grid(i-1))
then
839 weak_rate(k)%temp_grid(count) = t_grid(i)
857 if (r_grid(i) .ne. r_grid(i-1)) count = count + 1
865 if (r_grid(i) .ne. r_grid(i-1))
then
885 if (read_stat /= 0)
call raise_exception(
"Allocation of rate variables failed!",&
886 "readweak_logft",440001)
891 call raise_exception(
"The weak rate grid was not a regular grid! Check weak rate:"//&
892 isotope(parts_index(1))%name//
" ---> "//
isotope(parts_index(2))%name//&
896 "readweak_logft",440003)
901 weak_rate(k)%beta_rate(i,j) = beta_fwd(count)
902 weak_rate(k)%mue_kin(i,j) = mue_tmp(count)
904 weak_rate(k)%nu_loss(i,j) = anu_loss(count)
933 if (read_stat /= 0)
call raise_exception(
"Allocation of rate variables failed!",&
934 "readweak_logft",440001)
939 weak_rate(k)%beta_rate(i,j) = beta_bwd(count)
940 weak_rate(k)%mue_kin(i,j) = mue_tmp(count)
942 weak_rate(k)%nu_loss(i,j) = nu_loss(count)
962 info_exit(
"readweak_logft")
964 101
format(t16,a4,t38,f8.4)
989 real(
r_kind),
intent(in) :: ltemp
990 real(
r_kind),
intent(in) :: rho
991 real(
r_kind),
intent(in) :: ye
995 lrho = dlog10(rho*ye)
997 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index)
1020 real(
r_kind),
intent(in) :: lrho
1021 real(
r_kind),
intent(in) :: ltemp
1022 logical,
intent(in),
optional :: force_cubic
1028 if (.not.
present(force_cubic))
then
1032 wr =
lininter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%ft_rate,&
1033 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1035 wr =
lininter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%beta_rate,&
1036 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1038 wr =
lininter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%mue_kin,&
1039 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1041 wr =
lininter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%nu_loss,&
1042 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1045 "weak_inter",440009)
1049 wr =
cubinter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%ft_rate,&
1050 wrt%dft_dT,wrt%dft_dR,wrt%dft_dT_dR,&
1051 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1053 wr =
cubinter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%beta_rate,&
1054 wrt%dbeta_dT,wrt%dbeta_dR,wrt%dbeta_dT_dR,&
1055 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1057 wr =
cubinter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%mue_kin,&
1058 wrt%dmue_kin_dT,wrt%dmue_kin_dR,wrt%dmue_kin_dT_dR,&
1059 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1061 call raise_exception(
"Cubic interpolation not implemented for nu_loss",&
1066 "weak_inter",440004)
1070 wr =
cubinter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%ft_rate,&
1071 wrt%dft_dT,wrt%dft_dR,wrt%dft_dT_dR,&
1072 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1074 wr =
cubinter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%beta_rate,&
1075 wrt%dbeta_dT,wrt%dbeta_dR,wrt%dbeta_dT_dR,&
1076 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1078 wr =
cubinter_2d(ltemp,lrho,wrt%temp_grid,wrt%rho_grid,wrt%mue_kin,&
1079 wrt%dmue_kin_dT,wrt%dmue_kin_dR,wrt%dmue_kin_dT_dR,&
1080 wrt%n_temp_grid,wrt%n_rho_grid,
wk_index,2)
1082 call raise_exception(
"Cubic interpolation not implemented for nu_loss",&
1088 if (wr .lt. -30)
then
1095 if (wr .ne. wr)
call raise_exception(
"Value got NaN in interpolation.",&
1125 integer :: i, j, k, elements_still_to_replace,elements_still_to_remove
1128 info_entry(
"reload_exp_weak_rates")
1134 do while ((elements_still_to_replace .gt. 0).or.(elements_still_to_remove .gt. 0))
1145 rrate(i)%is_weak = .true.
1151 rrate(i)%ch_amount(1) = -1.d0
1153 if (
rrate(i)%parts(k).ne.0)
rrate(i)%ch_amount(k) = 1.d0
1155 elements_still_to_replace = elements_still_to_replace - 1
1160 if (.not.replaced)
then
1162 rrate(i)%is_reverse = .false.
1163 rrate(i)%is_resonant = .false.
1164 rrate(i)%is_weak = .true.
1167 rrate(i)%ch_amount(:)= 0.d0
1168 rrate(i)%param(:) = 0
1169 rrate(i)%param(1) = -99
1170 rrate(i)%nu_frac = 0
1179 elements_still_to_remove = elements_still_to_remove - 1
1183 if (i .gt.
nreac)
exit
1190 if (elements_still_to_replace .gt. 0)
call raise_exception(
"Couldn't replace all weak rates!",&
1191 "reload_exp_weak_rates",&
1193 if (elements_still_to_replace .lt. 0)
call raise_exception(
"Replaced too many rates!",&
1194 "reload_exp_weak_rates",&
1196 if (elements_still_to_remove .gt. 0)
call raise_exception(
"Couldn't remove all weak rates!",&
1197 "reload_exp_weak_rates",&
1199 if (elements_still_to_remove .lt. 0)
call raise_exception(
"Removed too many rates!",&
1200 "reload_exp_weak_rates",&
1202 info_exit(
"reload_exp_weak_rates")
1225 real(r_kind) :: temp_min,temp_max,temp_incr
1226 real(r_kind) :: rho_min ,rho_max ,rho_incr,rholog
1227 real(r_kind) :: temp_tmp,rho_tmp,ye_tmp
1228 real(r_kind) :: rat_pc,rat_ec,rat_bm,rat_bp
1230 if (verbose_level .ge. 2)
then
1231 temp_min = 0.0; temp_max = 101; temp_incr = 0.01
1232 rho_min = 0.5; rho_max = 10.5; rho_incr = 0.25
1245 if ((ind_n_p .eq. -1) .or. (ind_p_n .eq. -1))
return
1248 write(funit,*)
"#Temp [GK] rho*ye bp ec bm pc wk11 wk12 wk21 wk22"
1251 do i=1, int((temp_max-temp_min)/temp_incr)
1253 do j=1, int((rho_max-rho_min)/rho_incr)
1254 rholog = 10**rho_tmp
1262 write(funit,
"((6es12.5,4I4))") temp_tmp,rho_tmp,rat_bp,rat_ec,rat_bm,rat_pc,
wk_index(1,1),
wk_index(1,2),
wk_index(2,1),
wk_index(2,2)
1263 rho_tmp = rho_tmp+rho_incr
1265 temp_tmp = temp_tmp+temp_incr
1284 integer,
intent(in) :: cnt
1285 integer :: min_index, alloc_stat
1289 allocate(weak_temp(
nweak),stat=alloc_stat)
1290 if(alloc_stat /= 0)
call raise_exception(
'Allocation of "weak_temp" failed',&
1295 if(
weak_rate(k)%parts(1).gt.0) min_index = k
1302 else if((
weak_rate(j)%parts(1).gt.0).and. &
1312 deallocate(weak_temp)