Go to the documentation of this file.
46 integer,
parameter ::
qmax = 5
49 reshape( (/ 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, &
50 0.0d0, 1.0d0, 2.0d0, 3.0d0, 4.0d0, 5.0d0, &
51 0.0d0, 0.0d0, 1.0d0, 3.0d0, 6.0d0,10.0d0, &
52 0.0d0, 0.0d0, 0.0d0, 1.0d0, 4.0d0,10.0d0, &
53 0.0d0, 0.0d0, 0.0d0, 0.0d0, 1.0d0, 5.0d0, &
54 0.0d0, 0.0d0, 0.0d0, 0.0d0, 0.0d0, 1.0d0 /), (/6, 6/) )
81 real(
r_kind),
dimension(:,:),
allocatable ::
z
91 real(
r_kind),
dimension(:,:),
allocatable ::
e
113 histsize,
qmax,
amat,
ifac,
helperarr,
factorial,
gear_eps,
q,
n,
nq,
ti,
h, &
114 q_ini,
n_ini,
nq_ini,
tau,
z,
znew,
xi,
en,
e,
l,
el,
errq,
errqm1,
errqp1, &
133 real(
r_kind),
dimension(net_size),
intent(in) :: y
134 real(
r_kind),
intent(in) :: t_init
135 real(
r_kind),
intent(in) :: h_init
143 if (.not.
allocated(
z))
then
183 real(
r_kind),
dimension(net_size),
intent(in) :: dydt
235 real(
r_kind),
intent(in) :: timestep
263 real(
r_kind),
intent(in) :: timestep
348 real(
r_kind),
intent(in) :: time_inter
349 real(
r_kind),
dimension(net_size),
intent(out) :: y_inter
354 if ((time_inter.gt.
ti-
tau(1)) .and. (time_inter.le.
ti))
then
356 y_inter = y_inter + (((time_inter -
ti)/
tau(1))**(j-1.0d0))*
z(j,1:
net_size)
458 l(iback) =
l(iback) +
l(iback-1)/
xi(j)
478 real(
r_kind),
dimension(net_size),
intent(in) :: ydiff
507 if(
q>1 .and.
nq==
q)
then
556 if(maxval(
errq) < 1.d-100)
then
561 if(maxval(
errqm1) < 1.d-100)
then
568 if (
q .ne.
qmax)
then
569 if(maxval(
errqp1) < 1.d-100)
then
601 real(r_kind) :: tdiff1, tdiff2, tprod
610 tdiff1 = tdiff1 + sum(
tau(1:i))
611 tdiff2 = tdiff1 -
tau(1)
612 tprod = tprod*tdiff1/tdiff2
644 xiprod = xiprod*product(
xi(1:qm1))
645 xiprod = xiprod/(
l(2)*qm1)
671 real(
r_kind) :: xiqp1,tdiff1,tdiff2,helpprod,qval
676 xiqp1 = xiqp1 + sum(
tau(1:qp1))
683 tdiff1 = tdiff1 + sum(
tau(1:i))
684 tdiff2 = tdiff1 -
tau(1)
685 helpprod = helpprod*tdiff1/tdiff2
687 helpprod = helpprod + 1.0d0
689 call qfun(helpprod,qval)
708 real(
r_kind),
intent(in) :: helpprod
709 real(
r_kind),
intent(out) :: qval
714 real(
r_kind) :: helpprod2, tdiff1, tdiff2, cfac1, cfac2, helpfac
723 tdiff1 = tdiff1 + sum(
tau(2:i+1))
724 tdiff2 = tdiff1 -
tau(2)
725 helpprod2 = helpprod2*tdiff1/tdiff2
727 helpprod2 = helpprod2 + 1.0d0
731 helpfac = cfac1/cfac2
732 qval = helpfac*((
tau(1)/
tau(2))**qp1)
747 subroutine cfun(qp1,xi_in,helpprod,cval)
750 integer,
intent(in) :: qp1
751 real(r_kind),
dimension(histsize),
intent(in) :: xi_in
752 real(r_kind),
intent(in) :: helpprod
753 real(r_kind),
intent(out) :: cval
756 real(r_kind) :: facqp1,xiprod
766 xiprod = xiprod*product(xi_in(1:
q))
767 cval = xiprod*helpprod/facqp1
798 el(iback) =
el(iback)*
xi(j-2) +
el(iback-1)
838 integer,
intent(in) :: q_val
846 elseif(q_val==4)
then
848 elseif(q_val==3)
then
850 elseif(q_val==2)
then
real(r_kind), dimension(:), allocatable, private en
subroutine, private errorqm1
Calculate the errors for the order (q-1)
real(r_kind) function, dimension(net_size), public get_predictor_dydt()
Determines the predicted dydt_next.
real(r_kind) function, public get_time()
The current time.
real(r_kind), dimension(:,:), allocatable, private znew
Predictor step.
real(r_kind), dimension(histsize), private l
subroutine, public init_gear_solver(Y, t_init, h_init)
Initialize iteration variables.
real(r_kind) gear_eps
Abundance accuracy for gear solver.
integer gear_nr_maxcount
Maximum newton-raphson iterations for gear solver.
real(r_kind), dimension(:), allocatable, private errq
subroutine, public get_solution_at(time_inter, Y_inter)
Determines the solution at a given point in time for [ti-h, ti].
real(r_kind) gear_nr_eps
Convergence criterion for the newton-raphson of the gear solver.
real(r_kind) function, public get_timestep()
The current timestep.
subroutine, public set_xi
Function to calculate xi (needed for getting l in the corrector step)
real(r_kind) gear_escale
Normalization cutoff for gear solver, similar to timestep_Ymin for Euler.
integer, dimension(qmax+1), private helperarr
integer, private q_ini
start with order 1
integer, public gear_nr_count
counter for NR steps
integer, dimension(qmax+1), private factorial
real(r_kind) gear_cfactor
Conservative timestep factor for gear solver [0.1, ... , 0.4].
subroutine, public raise_exception(msg, sub, error_code)
Raise a exception with a given error message.
real(r_kind), dimension(:,:), allocatable, private e
real(r_kind), dimension(histsize), private el
real(r_kind) function, dimension(net_size), public get_solution()
Gives a copy of the solution at the current time.
subroutine, public set_new_result(ydiff)
Updates the solution (corrector step)
real(r_kind), dimension(:), allocatable, private errqm1
subroutine errorq
Calculate the errors for the current order.
subroutine, public set_timestep(timestep)
Set the current timestep.
real(r_kind), private hqm1
subroutine, private shiftorder
Adjusts the order, if possible and necessary. This is done every qth step, or earlier in case the tim...
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)
real(r_kind) function, dimension(net_size), public get_predictor_y()
Determines the predicted y_next.
integer, private alloc_stat
subroutine cfun(qp1, xi_in, helpprod, cval)
Calculate helper function C.
subroutine, public set_l
Function to calculate (needed for the corrector step)
subroutine, private errorqp1
Calculate the errors for the order (q+1)
integer, parameter, private qmax
maximum order of q
real(r_kind), dimension(histsize), private tau
hlist inverted
subroutine, public prepare_next_step
Stepsize and order control to pepare the next step.
real(r_kind) gear_timestep_max
For gear solver.
real(r_kind), private hqp1
subroutine, private qfun(helpprod, qval)
Calculate Helper function Q.
Contains types and objects shared between multiple modules.
real(r_kind), dimension(histsize), private xi
subroutine, private geterrors
Calculate errors (helper functions below)
real(r_kind) function, private get_cfactor(q_val)
Function to set the conservative timestep factor depending on the current order q.
real(r_kind), dimension(:), allocatable, private errqp1
subroutine, public nordsieck_product
Nordsieck vector-matrix product.
real(r_kind), dimension(6, 6), private amat
Helper Matrix.
integer, private nq_ini
iteration step at current order
real(r_kind), dimension(:,:), allocatable, private z
Nordsieck vector It is defined as.
subroutine, public revert_timestep(timestep)
Revert a timestep.
subroutine, public shift_tau
Shifts tau vector and controls the current time.
gear_module contains adaptive high-order Gear solver
integer, parameter, private histsize
length of history in tau, e, ...
subroutine, public init_dydt(dYdt)
Initialize dYdt component of the Nordsieck vector.
integer, private n_ini
iteration step
Contains all runtime parameters as well as phys and math constants.