![]()  | 
   
  
 
gear_module contains adaptive high-order Gear solver More...
Functions/Subroutines | |
| subroutine, public | init_gear_solver (Y, t_init, h_init) | 
| Initialize iteration variables.  More... | |
| subroutine, public | init_dydt (dYdt) | 
| Initialize dYdt component of the Nordsieck vector.  More... | |
| real(r_kind) function, public | get_time () | 
| The current time.  More... | |
| real(r_kind) function, public | get_timestep () | 
| The current timestep.  More... | |
| subroutine, public | set_timestep (timestep) | 
| Set the current timestep.  More... | |
| subroutine, public | revert_timestep (timestep) | 
| Revert a timestep.  More... | |
| real(r_kind) function, public | get_l1 () | 
| The current l_1 (in Fortran: l(2))  More... | |
| real(r_kind) function, dimension(net_size), public | get_solution () | 
| Gives a copy of the solution at the current time.  More... | |
| real(r_kind) function, dimension(net_size), public | get_predictor_y () | 
| Determines the predicted y_next.  More... | |
| real(r_kind) function, dimension(net_size), public | get_predictor_dydt () | 
| Determines the predicted dydt_next.  More... | |
| subroutine, public | get_solution_at (time_inter, Y_inter) | 
| Determines the solution at a given point in time for [ti-h, ti].  More... | |
| subroutine, public | shift_tau | 
| Shifts tau vector and controls the current time.  More... | |
| subroutine, public | nordsieck_product | 
| Nordsieck vector-matrix product.  More... | |
| subroutine, public | set_xi | 
| Function to calculate xi (needed for getting l in the corrector step)  More... | |
| subroutine, public | set_l | 
| Function to calculate \( \ell \) (needed for the corrector step)  More... | |
| subroutine, public | set_new_result (ydiff) | 
| Updates the solution (corrector step)  More... | |
| subroutine, public | prepare_next_step | 
| Stepsize and order control to pepare the next step.  More... | |
| subroutine, private | geterrors | 
| Calculate errors (helper functions below)  More... | |
| subroutine | errorq | 
| Calculate the errors for the current order.  More... | |
| subroutine, private | errorqm1 | 
| Calculate the errors for the order (q-1)  More... | |
| subroutine, private | errorqp1 | 
| Calculate the errors for the order (q+1)  More... | |
| subroutine, private | qfun (helpprod, qval) | 
| Calculate Helper function Q.  More... | |
| subroutine | cfun (qp1, xi_in, helpprod, cval) | 
| Calculate helper function C.  More... | |
| subroutine, private | shiftorder | 
| Adjusts the order, if possible and necessary. This is done every qth step, or earlier in case the time step was modified.  More... | |
| real(r_kind) function, private | get_cfactor (q_val) | 
| Function to set the conservative timestep factor depending on the current order q.  More... | |
Variables | |
| integer, parameter, private | histsize = 13 | 
| length of history in tau, e, ...  More... | |
| integer, parameter, private | qmax = 5 | 
| maximum order of q  More... | |
| real(r_kind), dimension(6, 6), private | amat = reshape( (/ 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, 0.0d0, 1.0d0, 2.0d0, 3.0d0, 4.0d0, 5.0d0, 0.0d0, 0.0d0, 1.0d0, 3.0d0, 6.0d0,10.0d0, 0.0d0, 0.0d0, 0.0d0, 1.0d0, 4.0d0,10.0d0, 0.0d0, 0.0d0, 0.0d0, 0.0d0, 1.0d0, 5.0d0, 0.0d0, 0.0d0, 0.0d0, 0.0d0, 0.0d0, 1.0d0 /), (/6, 6/) ) | 
| Helper Matrix.  More... | |
| integer, private | ifac | 
| integer, dimension(qmax+1), private | helperarr = (/ (ifac, ifac=1,qmax+1) /) | 
| integer, dimension(qmax+1), private | factorial | 
| integer, public | gear_nr_count = 0 | 
| counter for NR steps  More... | |
| integer, private | q | 
| integer, private | n | 
| integer, private | nq | 
| real(r_kind), private | ti | 
| real(r_kind), private | h | 
| integer, private | q_ini = 1 | 
| start with order 1  More... | |
| integer, private | n_ini = 1 | 
| iteration step  More... | |
| integer, private | nq_ini = 1 | 
| iteration step at current order  More... | |
| real(r_kind), dimension(histsize), private | tau | 
| hlist inverted  More... | |
| real(r_kind), dimension(:,:), allocatable, private | z | 
| Nordsieck vector It is defined as.  More... | |
| real(r_kind), dimension(:,:), allocatable, private | znew | 
| Predictor step.  More... | |
| real(r_kind), dimension(histsize), private | xi | 
| real(r_kind), dimension(:), allocatable, private | en | 
| real(r_kind), dimension(:,:), allocatable, private | e | 
| real(r_kind), dimension(histsize), private | l | 
| real(r_kind), dimension(histsize), private | el | 
| real(r_kind), dimension(:), allocatable, private | errq | 
| real(r_kind), dimension(:), allocatable, private | errqm1 | 
| real(r_kind), dimension(:), allocatable, private | errqp1 | 
| integer, private | alloc_stat | 
| real(r_kind), private | hq | 
| real(r_kind), private | hqp1 | 
| real(r_kind), private | hqm1 | 
gear_module contains adaptive high-order Gear solver
The solver is described by, e.g., Byrne & Hindmarsh (1975), ACM TOMS 1(1), p.71. The basic idea is to estimate the most efficient way between a larger timestep, but a higher order (and therefore computationally more expensive) or a smaller timestep and a lower order solution. The Gear solver therefore calculates the timestep based on an error estimation originating from the solution using different orders.
Edited:
| subroutine gear_module::cfun | ( | integer, intent(in) | qp1, | 
| real(r_kind), dimension(histsize), intent(in) | xi_in, | ||
| real(r_kind), intent(in) | helpprod, | ||
| real(r_kind), intent(out) | cval | ||
| ) | 
Calculate helper function C.
The function is defined as:
\[ C_{n+1} = \frac{\prod \limits _{i=1}^{q} \xi _{i}}{(q+1)!}\left[1+ \prod \limits _{i=2}^{q} \frac{t_{n+1} - t_{n+1-i}}{t_n -t_{n+1-i}} \right]. \]
Definition at line 747 of file gear_module.f90.
| subroutine gear_module::errorq | 
Calculate the errors for the current order.
The error is defined as:
\[ \vec{E}_{n+1}(q) = -\frac{1}{\ell _1}\left[ 1+ \prod _{i=2}^{q}\left( \frac{t_{n+1}-t_{n+1-i}}{t_{n}-t_{n+1-i}} \right) \right] ^{-1} \vec{e}_{n+1} \]
Definition at line 597 of file gear_module.f90.
      
  | 
  private | 
Calculate the errors for the order (q-1)
The error is defined as:
\[ \vec{E}_{n+1}(q-1) = - \frac{\prod \limits _{i=1}^{q-1} \xi _i } {\ell _1 (q-1)} \frac{h^q \vec{y}_{n+1}^{(q)}}{q!} \]
Definition at line 632 of file gear_module.f90.
      
  | 
  private | 
Calculate the errors for the order (q+1)
The error is defined as:
\[ \vec{E}_{n+1}(q+1) = \frac{-\xi_{q+1}(\vec{e}_{n+1}-Q_{n+1}\vec{e}_n) } {(q+2)\ell _1 (q+1)\left[1+ \prod \limits_{i=2}^{q} \frac{t_{n+1}-t_{n+1-i}} {t_n-t_{n+1-i}} \right] } \]
Definition at line 665 of file gear_module.f90.
      
  | 
  private | 
Function to set the conservative timestep factor depending on the current order q.
Definition at line 835 of file gear_module.f90.
| real(r_kind) function, public gear_module::get_l1 | 
The current l_1 (in Fortran: l(2))
Definition at line 280 of file gear_module.f90.
| real(r_kind) function, dimension(net_size), public gear_module::get_predictor_dydt | 
Determines the predicted dydt_next.
This returns the predicted dydt from the predictor step from z_new.
Definition at line 331 of file gear_module.f90.
| real(r_kind) function, dimension(net_size), public gear_module::get_predictor_y | 
Determines the predicted y_next.
The predicted abundance is stored in z_new(1,:)
Definition at line 313 of file gear_module.f90.
| real(r_kind) function, dimension(net_size), public gear_module::get_solution | 
Gives a copy of the solution at the current time.
The solution abundance is stored at z(1,:).
Definition at line 296 of file gear_module.f90.
| subroutine, public gear_module::get_solution_at | ( | real(r_kind), intent(in) | time_inter, | 
| real(r_kind), dimension(net_size), intent(out) | Y_inter | ||
| ) | 
Determines the solution at a given point in time for [ti-h, ti].
Definition at line 345 of file gear_module.f90.
| real(r_kind) function, public gear_module::get_time | 
| real(r_kind) function, public gear_module::get_timestep | 
      
  | 
  private | 
Calculate errors (helper functions below)
Calculates the errors (E, E(q+1), and E(q-1)) by calling the respective subroutines errorq, errorqm1, errorqp1. Also estimates the resulting timestep from each order.
Edited:
Definition at line 545 of file gear_module.f90.
| subroutine, public gear_module::init_dydt | ( | real(r_kind), dimension(net_size), intent(in) | dYdt | ) | 
Initialize dYdt component of the Nordsieck vector.
Stores h * dYdt in the Nordsieck vector z(2,:).
Definition at line 180 of file gear_module.f90.
| subroutine, public gear_module::init_gear_solver | ( | real(r_kind), dimension(net_size), intent(in) | Y, | 
| real(r_kind), intent(in) | t_init, | ||
| real(r_kind), intent(in) | h_init | ||
| ) | 
Initialize iteration variables.
Here, all necessary allocations are done. And the initial abundance is written into the abundance history array (z(1,:)).
Definition at line 130 of file gear_module.f90.
| subroutine, public gear_module::nordsieck_product | 
Nordsieck vector-matrix product.
This calculates:
\[ \vec{z}_{n+1}^{(0)} = \mathbf{A} \cdot \vec{z}_n \]
and stores the result in z_new.
Definition at line 392 of file gear_module.f90.
| subroutine, public gear_module::prepare_next_step | 
Stepsize and order control to pepare the next step.
Definition at line 502 of file gear_module.f90.
      
  | 
  private | 
Calculate Helper function Q.
Q is defined as:
\[ Q_{n+1} =\frac{C_{n+1}}{C_n}\left( \frac{h_{n+1}}{h_n}\right)^{q+1} \\ \]
Definition at line 706 of file gear_module.f90.
| subroutine, public gear_module::revert_timestep | ( | real(r_kind), intent(in) | timestep | ) | 
Revert a timestep.
This routine reverts the timestep of Gear to the previous timestep. It is used in case the result did not converge
Definition at line 261 of file gear_module.f90.
| subroutine, public gear_module::set_l | 
Function to calculate \( \ell \) (needed for the corrector step)
\[ \begin{align} \ell _0 (q) &=1, \nonumber \\ \quad \ell_1(q)&=\sum \limits _{i=1}^{q} \left( \xi _i ^{-1} \right), \nonumber\\ \quad \ell_j (q) &= \ell_j(q-1)+\ell_{j-1}(q-1)/\xi _q, \nonumber\\ \quad \ell _q (q) &= \left( \prod \limits_{i=1}^{q}\xi _i \right) ^{-1}. \nonumber \end{align} \]
Definition at line 447 of file gear_module.f90.
| subroutine, public gear_module::set_new_result | ( | real(r_kind), dimension(net_size), intent(in) | ydiff | ) | 
Updates the solution (corrector step)
This routine calculates
\[ \vec{z}_{n+1}=\vec{z}_{n+1}^{(0)}+\vec{e}_{n+1}\vec{\ell} \]
Definition at line 475 of file gear_module.f90.
| subroutine, public gear_module::set_timestep | ( | real(r_kind), intent(in) | timestep | ) | 
Set the current timestep.
Definition at line 232 of file gear_module.f90.
| subroutine, public gear_module::set_xi | 
Function to calculate xi (needed for getting l in the corrector step)
xi is defined as:
\[ \xi _i = \frac{t_{n+1} - t_{n+1-i}}{h} \]
Definition at line 420 of file gear_module.f90.
| subroutine, public gear_module::shift_tau | 
Shifts tau vector and controls the current time.
Definition at line 370 of file gear_module.f90.
      
  | 
  private | 
Adjusts the order, if possible and necessary. This is done every qth step, or earlier in case the time step was modified.
Definition at line 782 of file gear_module.f90.
      
  | 
  private | 
Definition at line 95 of file gear_module.f90.
      
  | 
  private | 
Helper Matrix.
This Matrix is defined by:
\[ A_{ij}=\begin{cases}0 & \text{if } i<j\\\begin{pmatrix}i\\j\end{pmatrix} = \frac{i!}{j!(i-j)!} & \text{if } i\ge j\end{cases} \qquad \text{with } i,j \in [0,1,...,q] \]
The Taylor-series of \(\vec{y}_n\) truncated at order q, can be calculated as the product of the Nordsieck vector (z).
Definition at line 48 of file gear_module.f90.
      
  | 
  private | 
Definition at line 91 of file gear_module.f90.
Definition at line 92 of file gear_module.f90.
      
  | 
  private | 
Definition at line 90 of file gear_module.f90.
      
  | 
  private | 
Definition at line 93 of file gear_module.f90.
      
  | 
  private | 
Definition at line 93 of file gear_module.f90.
      
  | 
  private | 
Definition at line 93 of file gear_module.f90.
      
  | 
  private | 
Definition at line 65 of file gear_module.f90.
| integer, public gear_module::gear_nr_count = 0 | 
counter for NR steps
Definition at line 68 of file gear_module.f90.
      
  | 
  private | 
Definition at line 72 of file gear_module.f90.
Definition at line 64 of file gear_module.f90.
      
  | 
  private | 
length of history in tau, e, ...
Definition at line 45 of file gear_module.f90.
      
  | 
  private | 
Definition at line 96 of file gear_module.f90.
      
  | 
  private | 
Definition at line 96 of file gear_module.f90.
      
  | 
  private | 
Definition at line 96 of file gear_module.f90.
      
  | 
  private | 
Definition at line 63 of file gear_module.f90.
Definition at line 92 of file gear_module.f90.
      
  | 
  private | 
Definition at line 71 of file gear_module.f90.
      
  | 
  private | 
iteration step
Definition at line 76 of file gear_module.f90.
      
  | 
  private | 
Definition at line 71 of file gear_module.f90.
      
  | 
  private | 
iteration step at current order
Definition at line 77 of file gear_module.f90.
      
  | 
  private | 
Definition at line 71 of file gear_module.f90.
      
  | 
  private | 
start with order 1
Definition at line 75 of file gear_module.f90.
      
  | 
  private | 
maximum order of q
Definition at line 46 of file gear_module.f90.
hlist inverted
Definition at line 80 of file gear_module.f90.
      
  | 
  private | 
Definition at line 72 of file gear_module.f90.
Definition at line 89 of file gear_module.f90.
      
  | 
  private | 
Nordsieck vector It is defined as.
\[ \vec{z}_n = \left[\vec{y}_n,h\dot{\vec{y}}_n,\frac{h^2 \ddot{\vec{y}}_n}{2!} ,...,\frac{h^q \vec{y}_n^{(q)}}{q!} \right] \]
Definition at line 81 of file gear_module.f90.
      
  | 
  private | 
Predictor step.
Definition at line 88 of file gear_module.f90.