67 character(len=4),
allocatable,
dimension(:),
private ::
src_ignore
69 character(len=4),
allocatable,
dimension(:),
private ::
src_q_reacl
71 character(len=4),
allocatable,
dimension(:),
private ::
src_q_winvn
103 info_entry(
"init_inverse_rates")
113 if (verbose_level .ge. 2)
then
114 write(*,*)
"Detailed balance: ignoring source : ",
src_ignore
115 write(*,*)
"Detailed balance: use Q-value reaclib: ",
src_q_reacl
116 write(*,*)
"Detailed balance: use Q-value winvn : ",
src_q_winvn
119 info_exit(
"init_inverse_rates")
142 integer,
intent(inout) :: rrate_length
150 integer,
dimension(11) :: ignore_inv
155 info_entry(
"merge_inverse_rates")
165 ignore_inv = (/-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1/)
173 rr_tmp = rrate_array(i)
175 if (verbose_level .gt. 2)
then
177 if (rr_tmp%is_weak .and. rr_tmp%is_reverse)
then
178 write(*,*)
"Detected rate that is weak and reverse!"
183 if (rr_tmp%is_weak) cycle
184 if (rr_tmp%reac_src .eq.
rrs_nu) cycle
185 if (rr_tmp%reac_src .eq.
rrs_fiss) cycle
187 if (any(
src_ignore .eq. adjustr(rr_tmp%source))) cycle
190 if (any(ignore_inv==rr_tmp%group)) cycle
193 if (rr_tmp%is_reverse)
then
204 allocate(new_rrate_array(newlength), stat = rstat)
205 if (rstat /= 0)
call raise_exception(
'Allocation of "new_rrate_array" failed.',&
206 "merge_inverse_rates", 260001)
212 rr_tmp = rrate_array(i)
217 if (rr_tmp%is_reverse .and. (.not. rr_tmp%is_weak) .and. &
218 (.not. (any(ignore_inv==rr_tmp%group))) .and. &
219 (.not. (any(
src_ignore == adjustr(rr_tmp%source)))))
then
224 new_rrate_array(count) = rr_tmp
234 rr_tmp = new_rrate_array(i)
237 if (any(ignore_inv==rr_tmp%group) .or. &
238 any(
src_ignore == adjustr(rr_tmp%source)))
then
243 if (rr_tmp%is_reverse)
then
248 if (rr_tmp%is_weak) cycle
249 if (rr_tmp%reac_src .eq.
rrs_nu) cycle
250 if (rr_tmp%reac_src .eq.
rrs_fiss) cycle
255 new_rrate_array(count)%param(1)=i
264 new_rrate_array(count)%q_value = -new_rrate_array(i)%q_value
268 new_rrate_array(i)%q_value = -new_rrate_array(count)%q_value
276 if (
ninv .ne. 0)
then
281 if (verbose_level .ge. 2)
then
282 call write_reac_rate(new_rrate_array,newlength,rrate_array,rrate_length)
286 deallocate(rrate_array, stat = rstat)
287 if (rstat /= 0)
call raise_exception(
'Deallocation of "rrate_array" failed.',&
288 "merge_inverse_rates", 260002)
289 allocate(rrate_array(newlength), stat = rstat)
290 if (rstat /= 0)
call raise_exception(
'Allocation of "rrate_array" failed.',&
291 "merge_inverse_rates", 260001)
293 rrate_array(:) = new_rrate_array(:)
294 deallocate(new_rrate_array, stat = rstat)
295 if (rstat /= 0)
call raise_exception(
'Deallocation of "new_rrate_array" failed.',&
296 "merge_inverse_rates", 260002)
298 rrate_length = newlength
303 info_exit(
"merge_inverse_rates")
332 integer :: nr_prod,nr_react
333 integer :: inv_chapter
337 inverse_rate%param(:) = 0
338 inverse_rate%source =
"detb"
340 inverse_rate%is_weak = .false.
341 inverse_rate%is_resonant = forward_rate%is_resonant
342 inverse_rate%reac_type =
rrt_o
343 inverse_rate%nu_frac = 0
354 inverse_rate%is_reverse = .true.
362 if (forward_rate%group .eq. 8)
then
363 nr_prod = count(forward_rate%parts/=0)-nr_react
368 inverse_rate%group=inv_chapter
371 inverse_rate%parts(:) = 0
373 inverse_rate%parts(i) = forward_rate%parts(i+nr_react)
376 inverse_rate%parts(j+nr_prod) = forward_rate%parts(j)
380 inverse_rate%q_value = 0
382 inverse_rate%q_value = inverse_rate%q_value - &
383 isotope(inverse_rate%parts(i))%mass_exc
386 inverse_rate%q_value = inverse_rate%q_value + &
387 isotope(inverse_rate%parts(j+nr_prod))%mass_exc
391 inverse_rate%param(2) = dble(nr_prod-nr_react)
395 inverse_rate%param(3) = 1
397 inverse_rate%param(3) = inverse_rate%param(3) * &
398 dble(
isotope(inverse_rate%parts(i))%mass)
401 inverse_rate%param(3) = inverse_rate%param(3) / &
402 dble(
isotope(inverse_rate%parts(j+nr_prod))%mass)
406 inverse_rate%param(5) = 1
408 inverse_rate%param(5) = inverse_rate%param(5) * &
409 (2.0*
isotope(inverse_rate%parts(i))%spin+1.0)
412 inverse_rate%param(5) = inverse_rate%param(5) / &
413 (2.0*
isotope(inverse_rate%parts(j+nr_prod))%spin+1.0)
417 inverse_rate%q_value = -inverse_rate%q_value
418 inverse_rate%param(2) = -inverse_rate%param(2)
419 inverse_rate%param(3) = -dlog(inverse_rate%param(3)**(3.0/2.0))
420 inverse_rate%param(4) = (3./2.)*dlog((
unit%mass_u/((2.0*
unit%pi*(
unit%hbc*1d-13)**2.))))
421 inverse_rate%param(5) = -dlog(inverse_rate%param(5))
456 real(
r_kind),
intent(in) :: temp
457 real(
r_kind),
intent(out) :: rate
463 real(
r_kind),
parameter :: cutoff_cr_h=90
464 real(
r_kind),
parameter :: cutoff_cr_m=70
465 real(
r_kind),
parameter :: cutoff_cr_l=60
466 real(
r_kind),
parameter :: cutoff_t9_h=1d0
467 real(
r_kind),
parameter :: cutoff_t9_m=8d-1
468 real(
r_kind),
parameter :: cutoff_t9_l=5d-1
472 if (.not. use_detailed_balance)
then
473 call raise_exception(
"Parameter for enabling detailed balance calculation was "//&
474 "turned off, but trying to calculate it."//new_line(
"A"),&
475 "calculate_detailed_balance",260005)
478 kbt = (
unit%k_mev*1.0d9*temp)
481 forward_rate = rrate_array(int(inverse_rate%param(1)))
485 rat = dlog(forward_rate%cached_p)
488 delta = dlog(forward_rate%one_over_n_fac/inverse_rate%one_over_n_fac)
491 rate = inverse_rate%param(3) +\
492 inverse_rate%param(2) * inverse_rate%param(4) +\
493 inverse_rate%param(5) +\
495 inverse_rate%param(2)*dlog(kbt**(3./2.))+\
496 inverse_rate%q_value/(kbt)-\
497 inverse_rate%param(2)*dlog(
unit%n_a) +\
516 if ((temp .lt. cutoff_t9_h ) .and. (inverse_rate%q_value .gt. 0))
then
519 if ((temp .gt. cutoff_t9_l) .and. (temp .le. cutoff_t9_m))
then
521 maxrat = (cutoff_cr_l*(cutoff_t9_m-temp) + cutoff_cr_m*(temp-cutoff_t9_l))/&
522 (cutoff_t9_m-cutoff_t9_l)
523 elseif ((temp .gt. cutoff_t9_m) .and. (temp .le. cutoff_t9_h))
then
525 maxrat = (cutoff_cr_m*(cutoff_t9_h-temp) + cutoff_cr_h*(temp-cutoff_t9_m))/&
526 (cutoff_t9_h-cutoff_t9_m)
532 if ((rate .gt. maxrat)) rate = maxrat
537 if ((rate .gt. cutoff_cr_h)) rate = cutoff_cr_h
567 integer,
intent(in) :: nrea,nrea_old
571 integer :: idx_ne20,idx_mg24
572 integer :: idx_na20,idx_c12
573 integer :: idx_d,idx_li7,idx_he3
574 real(
r_kind),
dimension(301) :: temp_grid
575 real(
r_kind),
dimension(11,301) :: rat_forward
576 real(
r_kind),
dimension(11,301) :: rat_inverse
577 real(
r_kind),
dimension(11,301) :: rat_inverse_reacl
584 temp_grid(i) = temp_grid(i-1)+0.01d0
586 temp_grid = 10d0**temp_grid
591 rat_inverse_reacl(:,:)=0d0
594 idx_ne20 =
benam(
" ne20")
595 idx_mg24 =
benam(
" mg24")
597 idx_na20 =
benam(
" na20")
600 idx_li7 =
benam(
" li7")
602 idx_he3 =
benam(
" he3")
604 idx_c12 =
benam(
" c12")
612 if ((((rate_array(i)%parts(1) .eq.
ihe4) .and. &
613 (rate_array(i)%parts(2) .eq. idx_ne20)) .or. &
614 ((rate_array(i)%parts(1) .eq. idx_ne20) .and. &
615 (rate_array(i)%parts(2) .eq.
ihe4))) .and. &
616 (rate_array(i)%parts(3) .eq. idx_mg24) .and. &
617 (rate_array(i)%group .eq. 4))
then
619 rat_forward(4,j) = rat_forward(4,j)+rat_tmp
620 rate_array(i)%cached_p = rat_tmp
624 if (( (rate_array(i)%parts(1) .eq.
ihe4) .and. &
625 (rate_array(i)%parts(2) .eq.
ihe4) .and. &
626 (rate_array(i)%parts(3) .eq.
ihe4) .and. &
627 (rate_array(i)%parts(4) .eq. idx_c12)) .and. &
628 (rate_array(i)%group .eq. 8))
then
630 rat_forward(8,j) = rat_forward(8,j)+rat_tmp
631 rate_array(i)%cached_p = rat_tmp
635 if ((((rate_array(i)%parts(1) .eq.
ineu) .and. &
636 (rate_array(i)%parts(2) .eq. idx_na20)) .or. &
637 ((rate_array(i)%parts(1) .eq. idx_na20) .and. &
638 (rate_array(i)%parts(2) .eq.
ineu))) .and. &
639 (((rate_array(i)%parts(3) .eq.
ipro) .and. &
640 (rate_array(i)%parts(4) .eq. idx_ne20)) .or. &
641 ((rate_array(i)%parts(3) .eq. idx_ne20) .and. &
642 (rate_array(i)%parts(4) .eq.
ipro))) .and. &
643 (rate_array(i)%group .eq. 5))
then
645 rat_forward(5,j) = rat_forward(5,j)+rat_tmp
646 rate_array(i)%cached_p = rat_tmp
650 if ((((rate_array(i)%parts(1) .eq. idx_d) .and. &
651 (rate_array(i)%parts(2) .eq. idx_li7) .and. &
652 (rate_array(i)%parts(3) .eq.
ineu)) .and. &
653 (rate_array(i)%parts(4) .eq.
ihe4) .and. &
654 (rate_array(i)%parts(5) .eq.
ihe4)) .and. &
655 (rate_array(i)%group .eq. 6))
then
657 rat_forward(6,j) = rat_forward(6,j)+rat_tmp
658 rate_array(i)%cached_p = rat_tmp
662 if ((((rate_array(i)%parts(1) .eq. idx_he3) .and. &
663 (rate_array(i)%parts(2) .eq. idx_li7) .and. &
664 (rate_array(i)%parts(3) .eq.
ineu)) .and. &
665 (rate_array(i)%parts(4) .eq.
ipro) .and. &
666 (rate_array(i)%parts(5) .eq.
ihe4) .and. &
667 (rate_array(i)%parts(6) .eq.
ihe4)) .and. &
668 (rate_array(i)%group .eq. 7))
then
670 rat_forward(7,j) = rat_forward(7,j)+rat_tmp
671 rate_array(i)%cached_p = rat_tmp
675 if ((((rate_array(i)%parts(1) .eq.
ineu) .and. &
676 (rate_array(i)%parts(2) .eq.
ipro) .and. &
677 (rate_array(i)%parts(3) .eq.
ipro)) .and. &
678 (rate_array(i)%parts(4) .eq.
ipro) .and. &
679 (rate_array(i)%parts(5) .eq. idx_d)) .and. &
680 (rate_array(i)%group .eq. 9))
then
682 rat_forward(9,j) = rat_forward(9,j)+rat_tmp
683 rate_array(i)%cached_p = rat_tmp
689 if ((((rate_array(i)%parts(3) .eq.
ihe4) .and. &
690 (rate_array(i)%parts(2) .eq. idx_ne20)) .or. &
691 ((rate_array(i)%parts(2) .eq.
ihe4) .and. &
692 (rate_array(i)%parts(3) .eq. idx_ne20))) .and. &
693 (rate_array(i)%parts(1) .eq. idx_mg24) .and. &
694 (rate_array(i)%group .eq. 2) .and. &
695 (rate_array(i)%source .eq.
"detb"))
then
697 rat_inverse(4,j) = rat_inverse(4,j)+rat_tmp
698 rate_array(i)%cached_p = rat_tmp
702 if (( (rate_array(i)%parts(2) .eq.
ihe4) .and. &
703 (rate_array(i)%parts(3) .eq.
ihe4) .and. &
704 (rate_array(i)%parts(4) .eq.
ihe4) .and. &
705 (rate_array(i)%parts(1) .eq. idx_c12)) .and. &
706 (rate_array(i)%group .eq. 3) .and. &
707 (rate_array(i)%source .eq.
"detb"))
then
709 rat_inverse(8,j) = rat_inverse(8,j)+rat_tmp
710 rate_array(i)%cached_p = rat_tmp
714 if ((((rate_array(i)%parts(3) .eq.
ineu) .and. &
715 (rate_array(i)%parts(4) .eq. idx_na20)) .or. &
716 ((rate_array(i)%parts(3) .eq. idx_na20) .and. &
717 (rate_array(i)%parts(4) .eq.
ineu))) .and. &
718 (((rate_array(i)%parts(1) .eq.
ipro) .and. &
719 (rate_array(i)%parts(2) .eq. idx_ne20)) .or. &
720 ((rate_array(i)%parts(1) .eq. idx_ne20) .and. &
721 (rate_array(i)%parts(2) .eq.
ipro))) .and. &
722 (rate_array(i)%group .eq. 5) .and. &
723 (rate_array(i)%source .eq.
"detb"))
then
725 rat_inverse(5,j) = rat_inverse(5,j)+rat_tmp
726 rate_array(i)%cached_p = rat_tmp
730 if ((((rate_array(i)%parts(4) .eq. idx_d) .and. &
731 (rate_array(i)%parts(5) .eq. idx_li7)) .or. &
732 ((rate_array(i)%parts(5) .eq. idx_d) .and. &
733 (rate_array(i)%parts(4) .eq. idx_li7)) .and. &
734 ((rate_array(i)%parts(1) .eq.
ineu) .and. &
735 (rate_array(i)%parts(2) .eq.
ihe4) .and. &
736 (rate_array(i)%parts(3) .eq.
ihe4)) .or. &
737 ((rate_array(i)%parts(1) .eq.
ihe4) .and. &
738 (rate_array(i)%parts(2) .eq.
ineu) .and. &
739 (rate_array(i)%parts(3) .eq.
ihe4)) .or. &
740 ((rate_array(i)%parts(1) .eq.
ihe4) .and. &
741 (rate_array(i)%parts(2) .eq.
ihe4) .and. &
742 (rate_array(i)%parts(3) .eq.
ineu))) .and. &
743 (rate_array(i)%group .eq. 9) .and. &
744 (rate_array(i)%source .eq.
"detb"))
then
746 rat_inverse(6,j) = rat_inverse(6,j)+rat_tmp
747 rate_array(i)%cached_p = rat_tmp
751 if ((((rate_array(i)%parts(5) .eq. idx_he3) .and. &
752 (rate_array(i)%parts(6) .eq. idx_li7) .and. &
753 (rate_array(i)%parts(1) .eq.
ineu)) .and. &
754 (rate_array(i)%parts(2) .eq.
ipro) .and. &
755 (rate_array(i)%parts(3) .eq.
ihe4) .and. &
756 (rate_array(i)%parts(4) .eq.
ihe4)) .and. &
757 (rate_array(i)%group .eq. 10) .and. &
758 (rate_array(i)%source .eq.
"detb"))
then
760 rat_inverse(7,j) = rat_inverse(7,j)+rat_tmp
761 rate_array(i)%cached_p = rat_tmp
765 if ((((rate_array(i)%parts(3) .eq.
ineu) .and. &
766 (rate_array(i)%parts(4) .eq.
ipro) .and. &
767 (rate_array(i)%parts(5) .eq.
ipro)) .and. &
768 (rate_array(i)%parts(1) .eq.
ipro) .and. &
769 (rate_array(i)%parts(2) .eq. idx_d)) .and. &
770 (rate_array(i)%group .eq. 6) .and. &
771 (rate_array(i)%source .eq.
"detb"))
then
773 rat_inverse(9,j) = rat_inverse(9,j)+rat_tmp
774 rate_array(i)%cached_p = rat_tmp
780 if ((((rate_array_old(i)%parts(3) .eq.
ihe4) .and. &
781 (rate_array_old(i)%parts(2) .eq. idx_ne20)) .or. &
782 ((rate_array_old(i)%parts(2) .eq.
ihe4) .and. &
783 (rate_array_old(i)%parts(3) .eq. idx_ne20))) .and. &
784 (rate_array_old(i)%parts(1) .eq. idx_mg24) .and. &
785 (rate_array_old(i)%group .eq. 2))
then
787 rat_inverse_reacl(4,j) = rat_inverse_reacl(4,j)+rat_tmp
788 rate_array_old(i)%cached_p = rat_tmp
792 if (( (rate_array_old(i)%parts(2) .eq.
ihe4) .and. &
793 (rate_array_old(i)%parts(3) .eq.
ihe4) .and. &
794 (rate_array_old(i)%parts(4) .eq.
ihe4) .and. &
795 (rate_array_old(i)%parts(1) .eq. idx_c12)) .and. &
796 (rate_array_old(i)%group .eq. 3))
then
798 rat_inverse_reacl(8,j) = rat_inverse_reacl(8,j)+rat_tmp
799 rate_array_old(i)%cached_p = rat_tmp
802 if ((((rate_array_old(i)%parts(3) .eq.
ineu) .and. &
803 (rate_array_old(i)%parts(4) .eq. idx_na20)) .or. &
804 ((rate_array_old(i)%parts(3) .eq. idx_na20) .and. &
805 (rate_array_old(i)%parts(4) .eq.
ineu))) .and. &
806 (((rate_array_old(i)%parts(1) .eq.
ipro) .and. &
807 (rate_array_old(i)%parts(2) .eq. idx_ne20)) .or. &
808 ((rate_array_old(i)%parts(1) .eq. idx_ne20) .and. &
809 (rate_array_old(i)%parts(2) .eq.
ipro))) .and. &
810 (rate_array_old(i)%group .eq. 5))
then
812 rat_inverse_reacl(5,j) = rat_inverse_reacl(5,j)+rat_tmp
813 rate_array_old(i)%cached_p = rat_tmp
817 if ((((rate_array_old(i)%parts(4) .eq. idx_d) .and. &
818 (rate_array_old(i)%parts(5) .eq. idx_li7) .and. &
819 (rate_array_old(i)%parts(1) .eq.
ineu)) .and. &
820 (rate_array_old(i)%parts(2) .eq.
ihe4) .and. &
821 (rate_array_old(i)%parts(3) .eq.
ihe4)) .and. &
822 (rate_array_old(i)%group .eq. 9))
then
824 rat_inverse_reacl(6,j) = rat_inverse_reacl(6,j)+rat_tmp
825 rate_array_old(i)%cached_p = rat_tmp
829 if ((((rate_array_old(i)%parts(5) .eq. idx_he3) .and. &
830 (rate_array_old(i)%parts(6) .eq. idx_li7) .and. &
831 (rate_array_old(i)%parts(1) .eq.
ineu)) .and. &
832 (rate_array_old(i)%parts(2) .eq.
ipro) .and. &
833 (rate_array_old(i)%parts(3) .eq.
ihe4) .and. &
834 (rate_array_old(i)%parts(4) .eq.
ihe4)) .and. &
835 (rate_array_old(i)%group .eq. 10))
then
837 rat_inverse_reacl(7,j) = rat_inverse_reacl(7,j)+rat_tmp
838 rate_array_old(i)%cached_p = rat_tmp
842 if ((((rate_array_old(i)%parts(3) .eq.
ineu) .and. &
843 (rate_array_old(i)%parts(4) .eq.
ipro) .and. &
844 (rate_array_old(i)%parts(5) .eq.
ipro)) .and. &
845 (rate_array_old(i)%parts(1) .eq.
ipro) .and. &
846 (rate_array_old(i)%parts(2) .eq. idx_d)) .and. &
847 (rate_array_old(i)%group .eq. 6))
then
849 rat_inverse_reacl(9,j) = rat_inverse_reacl(9,j)+rat_tmp
850 rate_array_old(i)%cached_p = rat_tmp
857 rat_inverse_reacl(i,j) = max(rat_inverse_reacl(i,j),1d-99)
858 rat_inverse(i,j) = max(rat_inverse(i,j),1d-99)
859 rat_forward(i,j) = max(rat_forward(i,j),1d-99)
864 write(file_id,
"(A)")
"# File to check inverse rates. The inverse rates calculated (I) and "
865 write(file_id,
"(A)")
"# from the reaclib (IR) should agree. There might be slight deviations"
866 write(file_id,
"(A)")
"# due to different Q-values in the Reaclib and winvn file."
867 write(file_id,
"(A)")
"# Tested are a couple of chapters, e.g.,"
868 write(file_id,
"(A)")
"# Chapter 4: Ne20 + He4 -> Mg24"
869 write(file_id,
"(A)")
"# Chapter 5: n + Na20 -> p Ne20"
870 write(file_id,
"(A)")
"# Chapter 6: d + Li7 -> n + He4 + He4"
871 write(file_id,
"(A)")
"# Chapter 7: He3 + Li7 -> n + p + He4 + He4"
872 write(file_id,
"(A)")
"# Chapter 8: He4 + He4 + He4 -> C12"
873 write(file_id,
"(A)")
"# Chapter 9: n + p + p -> p + d"
874 write(file_id,
"(A)")
"###############################################"
875 write(file_id,
"(A)")
"# T [GK], F (4), I (4), IR (4),"//&
876 " F (5), I (5), IR (5),"//&
877 " F (6), I (6), IR (6),"//&
878 " F (7), I (7), IR (7),"//&
879 " F (8), I (8), IR (8),"//&
880 " F (9), I (9), IR (9)"
882 write(file_id,
"(*(1pE13.4))")temp_grid(i),rat_forward(4,i),rat_inverse(4,i),rat_inverse_reacl(4,i),&
883 rat_forward(5,i),rat_inverse(5,i),rat_inverse_reacl(5,i),&
884 rat_forward(6,i),rat_inverse(6,i),rat_inverse_reacl(6,i),&
885 rat_forward(7,i),rat_inverse(7,i),rat_inverse_reacl(7,i),&
886 rat_forward(8,i),rat_inverse(8,i),rat_inverse_reacl(8,i),&
887 rat_forward(9,i),rat_inverse(9,i),rat_inverse_reacl(9,i)
906 if (verbose_level .ge. 1)
then