Go to the documentation of this file.
70 real(
r_kind),
intent(in) :: time
71 real(
r_kind),
intent(in) :: temp
72 integer,
intent(in),
optional :: idx
73 real(
r_kind),
intent(in) :: rho
74 real(
r_kind),
intent(in) :: ye
75 real(
r_kind),
intent(in) :: rkm
76 real(
r_kind),
intent(out),
optional :: rat_calc
79 logical :: is_same_step
81 real(
r_kind) :: eta_e,eta_p
83 integer :: reac_origin
97 is_same_step = .false.
104 if (is_same_step .eqv. .false.)
then
119 call chempot(1.d9*temp,rho,ye,eta_e,eta_p)
120 mue = eta_e * temp * 1.d9 *
unit%k_MeV
125 if ((
nuflag.ge.1) .and. ((time .lt. nu_max_time) .or. (nu_max_time .eq. -1d0)))
then
126 call nuflux(time, rkm)
133 if (
present(rrate_array).eqv..false.)
return
137 src = rrate_array(idx)%source
138 reac_origin = rrate_array(idx)%reac_src
143 if (reac_origin .eq.
rrs_twr)
then
146 else if (reac_origin .eq.
rrs_tabl)
then
149 else if (reac_origin .eq.
rrs_nu)
then
152 else if (reac_origin .eq.
rrs_detb)
then
155 else if (reac_origin .eq.
rrs_fiss)
then
158 else if (reac_origin .eq.
rrs_wext)
then
161 else if (reac_origin .eq.
rrs_aext)
then
164 else if (reac_origin .eq.
rrs_reacl)
then
169 "'."//new_line(
"A")//
"Reaction source is: "//src,&
170 "calculate_reaction_rate", 280011)
177 rrate_array(idx)%cached_p = rat_calc
180 if(
iscreen .eqv. .true.) rat_calc=rat_calc*dexp(
hv(idx))
183 rat_calc = rat_calc * rrate_array(idx)%one_over_n_fac
188 if (trim(adjustl(src)) .eq.
'ec') rat_calc = rat_calc * elnd
191 select case (rrate_array(idx)%group)
193 if (rrate_array(idx)%is_reverse)
then
194 rat_calc = rat_calc * (
pf(rrate_array(idx)%parts(2))*
pf(rrate_array(idx)%parts(3))* &
195 pf(rrate_array(idx)%parts(4))*
pf(rrate_array(idx)%parts(5)))/ &
196 pf(rrate_array(idx)%parts(1))
199 rat_calc = rat_calc * rho
200 if (rrate_array(idx)%is_reverse)
then
201 rat_calc = rat_calc * (
pf(rrate_array(idx)%parts(3))*
pf(rrate_array(idx)%parts(4)) * &
202 pf(rrate_array(idx)%parts(5))*
pf(rrate_array(idx)%parts(6))) / &
203 (
pf(rrate_array(idx)%parts(1))*
pf(rrate_array(idx)%parts(2)))
206 rat_calc = rat_calc * rho**2
207 if (rrate_array(idx)%is_reverse)
then
208 rat_calc = rat_calc * (
pf(rrate_array(idx)%parts(4))*
pf(rrate_array(idx)%parts(5)) &
209 / (
pf(rrate_array(idx)%parts(1))*
pf(rrate_array(idx)%parts(2)) &
210 *
pf(rrate_array(idx)%parts(3))))
213 rat_calc = rat_calc * rho**3
214 if (rrate_array(idx)%is_reverse)
then
215 rat_calc = rat_calc * (
pf(rrate_array(idx)%parts(5))*
pf(rrate_array(idx)%parts(6))) &
216 / (
pf(rrate_array(idx)%parts(1))*
pf(rrate_array(idx)%parts(2)) &
217 *
pf(rrate_array(idx)%parts(3))*
pf(rrate_array(idx)%parts(4)))
223 "calculate_reaction_rate",280009)
234 rrate_array(idx)%cached = rat_calc
289 subroutine abchange (time, itemp, rho, Ye, rkm, Y, dYdt, evolution_mode)
295 real(
r_kind),
intent(in) :: time
296 real(
r_kind),
intent(in) :: itemp
297 real(
r_kind),
intent(in) :: rho
298 real(
r_kind),
intent(in) :: ye
299 real(
r_kind),
intent(in) :: rkm
300 real(
r_kind),
dimension(:),
intent(in) :: y
301 real(
r_kind),
dimension(:),
intent(inout) :: dydt
302 integer,
intent(in) :: evolution_mode
314 if (itemp.le.freeze_rate_temp)
then
315 temp = freeze_rate_temp
317 print *,
"Freezing rates at "//
num_to_str(freeze_rate_temp)//
" GK"
342 if ((evolution_mode.eq.em_nse).and.(
rrate(i)%is_weak.eqv..false.)) cycle outer
364 select case (
rrate(i)%group)
367 if (
rrate(i)%parts(j) .eq. 0)
exit
368 dydt(
rrate(i)%parts(j)) = dydt(
rrate(i)%parts(j)) + rat * &
373 if (
rrate(i)%parts(j) .eq. 0)
exit
374 dydt(
rrate(i)%parts(j)) = dydt(
rrate(i)%parts(j)) + rat * &
375 rrate(i)%ch_amount(j) * y(
rrate(i)%parts(1)) * &
380 if (
rrate(i)%parts(j) .eq. 0)
exit
381 dydt(
rrate(i)%parts(j)) = dydt(
rrate(i)%parts(j)) + rat * &
382 rrate(i)%ch_amount(j) * y(
rrate(i)%parts(1)) * &
387 if (
rrate(i)%parts(j) .eq. 0)
exit
388 dydt(
rrate(i)%parts(j)) = dydt(
rrate(i)%parts(j)) + rat * &
389 rrate(i)%ch_amount(j) * y(
rrate(i)%parts(1)) * &
390 y(
rrate(i)%parts(2)) * y(
rrate(i)%parts(3)) * &
401 if ((rat .ge. infty) .or. (rat .ne. rat))
then
404 new_line(
"A")//
"was infinity or NaN.",&
410 if ((fissflag.ne.0) .and. (evolution_mode.ne.em_nse))
then
428 if ((rat .ge. infty) .or. (rat .ne. rat))
then
431 " was infinity or NaN.",
"abchange",280004)
433 if (y(
fissrate(i)%fissparts(1)) .eq. 0)
then
446 if ((rat .ge. infty) .or. (rat .ne. rat))
then
449 " was infinity or NaN.",
"abchange",280005)
483 real(
r_kind),
intent(in) :: rat
485 real(
r_kind),
dimension(net_size),
intent(in) :: y
488 integer :: zero_count
496 if ((rrate_in%reac_type .eq.
rrt_nf) .or. &
497 (rrate_in%reac_type .eq.
rrt_bf) .or. &
498 (rrate_in%reac_type .eq.
rrt_sf))
then
505 if (y(rrate_in%parts(i)) .le. 0) zero_count = zero_count+1
506 if (zero_count .gt. 1)
exit
508 if (zero_count .gt. 1) res = .true.
538 subroutine jacobi_init (time, itemp, rho, rkm, Y, Y_p, dYdt, rhs, h, evolution_mode)
548 real(
r_kind),
intent(in) :: time
549 real(
r_kind),
intent(in) :: itemp
550 real(
r_kind),
intent(in) :: rho
551 real(
r_kind),
intent(in) :: rkm
552 real(
r_kind),
dimension(:),
intent(in) :: y
553 real(
r_kind),
dimension(:),
intent(in) :: y_p
554 real(
r_kind),
dimension(:),
intent(inout) :: dydt
555 real(
r_kind),
dimension(:),
intent(inout) :: rhs
556 real(
r_kind),
intent(in) :: h
557 integer,
intent(in) :: evolution_mode
565 character*1,
dimension(6) :: descra
571 info_entry(
"jacobi_init")
577 descra = (/
"G",
" ",
" ",
"F",
" ",
" "/)
582 ye= sum(isotope(1:net_size)%p_nr*y(1:net_size))
590 elseif (ye.lt.0)
then
592 'jacobi_init',280007)
596 if(dlog10(rho*ye).ne.dlog10(rho*ye))
then
599 "Density is : "//trim(adjustl(
num_to_str(rho)))//
" [g/ccm]."//new_line(
"A")//&
601 'jacobi_init',280009)
605 if (itemp.le.freeze_rate_temp)
then
606 temp = freeze_rate_temp
608 print *,
"Freezing rates at "//
num_to_str(freeze_rate_temp)//
" GK"
632 vals(
dia(i)) = 1.d0/h
634 elseif(solver==1)
then
651 if ((evolution_mode.eq.em_nse).and.(rr_tmp%is_weak.eqv..false.)) cycle outer
655 (rr_tmp%reac_src .eq.
rrs_nu))
then
667 select case (rr_tmp%group)
671 if (rr_tmp%parts(j) .eq. 0)
exit
672 dydt(rr_tmp%parts(j)) = dydt(rr_tmp%parts(j)) + rat * &
673 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1))
675 vals(rr_tmp%cscf_ind(1,j)) = vals(rr_tmp%cscf_ind(1,j)) - rat * &
681 if (rr_tmp%parts(j) .eq. 0)
exit
682 dydt(rr_tmp%parts(j)) = dydt(rr_tmp%parts(j)) + rat * &
683 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
686 vals(rr_tmp%cscf_ind(1,j)) = vals(rr_tmp%cscf_ind(1,j)) - rat * &
687 rr_tmp%ch_amount(j) * y(rr_tmp%parts(2))
688 vals(rr_tmp%cscf_ind(2,j)) = vals(rr_tmp%cscf_ind(2,j)) - rat * &
689 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1))
694 if (rr_tmp%parts(j) .eq. 0)
exit
695 dydt(rr_tmp%parts(j)) = dydt(rr_tmp%parts(j)) + rat * &
696 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
697 y(rr_tmp%parts(2)) * y(rr_tmp%parts(3))
699 vals(rr_tmp%cscf_ind(1,j)) = vals(rr_tmp%cscf_ind(1,j)) - rat * &
700 rr_tmp%ch_amount(j) * y(rr_tmp%parts(2)) * &
702 vals(rr_tmp%cscf_ind(2,j)) = vals(rr_tmp%cscf_ind(2,j)) - rat * &
703 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
705 vals(rr_tmp%cscf_ind(3,j)) = vals(rr_tmp%cscf_ind(3,j)) - rat * &
706 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
712 if (rr_tmp%parts(j) .eq. 0)
exit
713 dydt(rr_tmp%parts(j)) = dydt(rr_tmp%parts(j)) + rat * &
714 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
715 y(rr_tmp%parts(2)) * y(rr_tmp%parts(3)) * y(rr_tmp%parts(4))
717 vals(rr_tmp%cscf_ind(1,j)) = vals(rr_tmp%cscf_ind(1,j)) - rat * &
718 rr_tmp%ch_amount(j) * y(rr_tmp%parts(2)) * &
719 y(rr_tmp%parts(3)) * y(rr_tmp%parts(4))
720 vals(rr_tmp%cscf_ind(2,j)) = vals(rr_tmp%cscf_ind(2,j)) - rat * &
721 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
722 y(rr_tmp%parts(3)) * y(rr_tmp%parts(4))
723 vals(rr_tmp%cscf_ind(3,j)) = vals(rr_tmp%cscf_ind(3,j)) - rat * &
724 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
725 y(rr_tmp%parts(2)) * y(rr_tmp%parts(4))
726 vals(rr_tmp%cscf_ind(4,j)) = vals(rr_tmp%cscf_ind(4,j)) - rat * &
727 rr_tmp%ch_amount(j) * y(rr_tmp%parts(1)) * &
728 y(rr_tmp%parts(2)) * y(rr_tmp%parts(3))
734 ,
"jacobi_init",280009)
738 rrate(i)%cached = rat
743 if ((rat .gt. infty) .or. (rat .ne. rat))
then
747 new_line(
"A")//
"was infinity or NaN."//new_line(
"A")//&
748 "Logarithm of screening factor was "//
num_to_str(
hv(i)),&
749 "jacobi_init",280003)
753 new_line(
"A")//
"was infinity or NaN.",&
754 "jacobi_init",280003)
764 if ((fissflag.ne.0) .and. (evolution_mode.ne.em_nse))
then
765 fissloop:
do i=1,
nfiss
776 if (verbose_level .ge. 2)
then
777 if (
fissrate(i)%fissparts(1) .ne. ineu)
then
778 write(*,*)
"Fission rate is overflowing. Fissioning nucleus is "//&
779 trim(adjustl(isotope(
fissrate(i)%fissparts(1))%name))
781 write(*,*)
"Fission rate is overflowing. Fissioning nucleus is "//&
782 trim(adjustl(isotope(
fissrate(i)%fissparts(2))%name))
796 if ((y(
fissrate(i)%fissparts(1)) .le. 0) .and. (solver .eq. 0))
then
818 if ((y(
fissrate(i)%fissparts(1)) * y(
fissrate(i)%fissparts(2)) .le. 0) .and. (solver .eq. 0))
then
848 if (verbose_level .ge. 2)
then
850 if (dydt(i).ne.dydt(i))
then
851 call raise_exception(
"dYdt of "//trim(adjustl(net_names(i)))//
" is NaN.",&
852 "jacobi_init",280010)
856 rhs = dydt + d*(y_p - y)
858 call mkl_dcscmv(
'T',net_size,net_size,1.d0,descra,vals,
rows,
pt_b, &
860 elseif(solver==1)
then
863 dydt = dydt + d*(y_p-y)
865 info_exit(
"jacobi_init")
integer iwformat
defines format of the weak rates (0 = tabulated, 1 = log<ft>)
real(r_kind) function, dimension(net_size), public get_predictor_dydt()
Determines the predicted dydt_next.
Module to calculate electron screening.
real(r_kind), dimension(:), allocatable, public vals
contains non-zero matrix elements (of the Jacobian)
real(r_kind) freeze_rate_temp
Tmperature at which rates get frozen (for reacl. rates this should be 1d-2GK)
character *5, dimension(:), allocatable, public net_names
list of isotopes contained in the network
type(reactionrate_type), dimension(:), allocatable, public rrate
array containing all reaction rates used in the network
subroutine, public calculate_nu_rate(rrate, rat_calc)
Calculates the cross section times the neutrino flux.
Module that deals with reaclib reaction rates.
Takes care of the temperature and entropy updates due to the nuclear energy release.
real(r_kind), parameter, private rate_min_cutoff
Minimum cutoff for the reaction rates.
real(r_kind), private old_dens
character(50) function, public reaction_string(reac)
Return a string to represent a given reaction.
Module to deal with fission reactions.
real(r_kind), dimension(:), allocatable, public pf
partition functions
character(:) function, allocatable, public int_to_str(num)
Converts a given integer to a string.
integer, dimension(:), allocatable, public dia
dia(j) gives the index into vals that contains the (j,j) diagonal element of the matrix
subroutine, public raise_exception(msg, sub, error_code)
Raise a exception with a given error message.
logical function skip_rate(rat, rrate_in, Y)
Function to decide whether a rate can contribute or not.
real(r_kind), private old_temp
integer, public nfiss
Amount of fission rates.
integer, dimension(:), allocatable, public pt_e
pt_e(j)-pt_b(j) gives the index into vals that contains the LAST non-zero element of column j of the ...
logical use_timmes_mue
Use electron chemical potentials from timmes EOS for theoretical weak rates.
subroutine, public abchange(time, itemp, rho, Ye, rkm, Y, dYdt, evolution_mode)
This subroutine calculates the change in abundances (dYdt) due to reaction rates at given temperature...
logical, private nu_shutoff_indicator
Indicator for debug statement.
real(r_kind), private old_time
type(isotope_type), dimension(:), allocatable, public isotope
all nuclides used in the network
real(r_kind), public mue
chemical potential of the electron
Module with helper functions such as rate tabulation, partition functions, and theoretical weak rates...
Contains variables and parameters related to neutrino fluxes.
integer, dimension(:,:), allocatable, public jind
jind(i,j) contains the index of jacobian entry in vals
subroutine, public calculate_detailed_balance(temp, rrate_array, inverse_rate, rate)
Calculate the inverse rate from the forward one via detailed balance.
logical, public weak
switch for weak rates
real(r_kind), private old_ye
Module that deals with inverse reaction rates.
real(r_kind) function, public get_l1()
The current l_1 (in Fortran: l(2))
integer, public net_size
total number of isotopes (network size)
Calculate the effective phase space integral needed for the log(ft) weak rates.
type(unit_type), public unit
constants and unit conversion factors
real(r_kind), parameter, private rate_max_cutoff
Maximum cutoff for the reaction rates.
real(r_kind) function, dimension(net_size), public get_predictor_y()
Determines the predicted y_next.
type(fissionrate_type), dimension(:), allocatable, public fissrate
Array storing fission reactions.
real(r_kind), private old_rad
character(:) function, allocatable, public num_to_str(num)
Converts a given real to a string with format "(1pE10.2)".
subroutine reset_qdot(time)
Reset the qdot variable.
logical, public tabulated
switch for tabulated rates
integer heating_mode
Mode for heating: 0 - no heating, 1 - heating using an entropy equation, 2 - heating from the energy ...
Contains subroutines for sparse matrix assembly and the solver core.
integer, dimension(:), allocatable, public rows
rows(i) is the number of the row in the matrix that contains the i-th value in vals
subroutine, public tabulated_index(temp)
Set tab_index for a given temperature.
subroutine chempot(temp, den, ye, etaele, etapos)
Given a temperature temp [K], density den [g/cm**3], and a composition characterized by y_e,...
real(r_kind), dimension(:), allocatable, public hv
Screening correction.
subroutine calculate_qdot(rrate, Y, h)
logical, private freeze_rate_indicator
Indicator for debug statement.
integer, parameter, public fiss_neglect
Amount of fission fragments not to be neglected.
subroutine, public jacobi_init(time, itemp, rho, rkm, Y, Y_p, dYdt, rhs, h, evolution_mode)
This subroutine calculates the entries in the jacobian and the right-hand side of the numerical integ...
integer function get_nr_reactants(group)
Get number of reactants of the reaction based on the reaclib chapter.
Contains subroutines to assemble the system Jacobian and changes in the abundances.
real(r_kind), dimension(9), public t9_pow
Powers of T, used for the rates.
subroutine, public screen(t9, rho, n, ye, mode)
This function calculates the screening coefficients hv.
This module contains everything for the tabulated rates that can replace reaclib rates.
integer, dimension(:), allocatable, public pt_b
pt_b(j) gives the index into vals that contains the FIRST non-zero element of column j of the matrix
subroutine, public inter_partf(temp, interpol)
Calculates partition function.
Contains types and objects shared between multiple modules.
real(r_kind) nu_max_time
Maximum time for neutrino reactions to react.
subroutine, public calculate_tab_rate(rrate, temp, rat_calc)
Calculates the tabulated rate.
integer, public nreac
total number of reactions
subroutine calculate_reacl_rate(rrate, rat_calc)
Calculate a reaclib rate.
This module contains everything for the theoretical weak rates that are added into the rate array.
subroutine, public calc_t9_pow(t9)
A helper to compute powers of temperature used in the reaction rates.
subroutine, private calculate_reaction_rate(time, temp, rho, Ye, rkm, rrate_array, idx, rat_calc)
Subroutine to calculate the reaction rates.
integer nuflag
defines type of neutrino reactions used
logical, public iscreen
Flag whether screening is enabled or not.
gear_module contains adaptive high-order Gear solver
Contains all runtime parameters as well as phys and math constants.
subroutine, public calculate_twr_rate(rrate, temp, rho, Ye, rat_calc, nuloss)
Calculate the theoretical weak rate.
Subroutines needed to initialise the network.