Test explicit Adams-Bashforth class of ODE solvers.
subroutine test_ab()
!---------------------------------------------------------------------------------------------------------------------------------
!< Test explicit Adams-Bashforth class of ODE solvers.
!---------------------------------------------------------------------------------------------------------------------------------
type(integrator_runge_kutta_tvd) :: rk_integrator !< Runge-Kutta integrator.
integer, parameter :: rk_stages=5 !< Runge-Kutta stages number.
type(euler_1D) :: rk_stage(1:rk_stages) !< Runge-Kutta stages.
type(integrator_adams_bashforth) :: ab_integrator !< Adams-Bashforth integrator.
integer, parameter :: ab_steps=4 !< Adams-Bashforth steps number.
type(euler_1D) :: previous(1:ab_steps) !< Previous time steps solutions.
integer :: step !< Time steps counter.
real(R_P) :: dt !< Time step.
real(R_P) :: t(1:ab_steps) !< Times.
integer(I_P) :: s !< AB steps counter.
integer(I_P) :: ss !< AB substeps counter.
integer(I_P) :: steps_range(1:2) !< Steps used.
character(len=:), allocatable :: title !< Output files title.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
print "(A)", 'Integrating 1D Euler equations by means of Adams-Bashforth class of solvers'
steps_range = [1, ab_steps] ; if (stages_steps>0) steps_range = [stages_steps, stages_steps]
do s=steps_range(1), steps_range(2)
print "(A)", ' AB-'//trim(str(s,.true.))
title = '1D Euler equations integration, explicit Adams-Bashforth, t='//str(n=t_final)//trim(str( s,.true.))//' steps'
call ab_integrator%init(steps=s)
select case(s)
case(1)
call domain%init(Ni=Ni, Ns=Ns, Dx=Dx, BC_L=BC_L, BC_R=BC_R, initial_state=initial_state, cp0=cp0, cv0=cv0, steps=s, ord=1)
call rk_integrator%init(stages=s)
case(2, 3)
call domain%init(Ni=Ni, Ns=Ns, Dx=Dx, BC_L=BC_L, BC_R=BC_R, initial_state=initial_state, cp0=cp0, cv0=cv0, steps=s, ord=3)
call rk_integrator%init(stages=s)
case(4, 5)
call domain%init(Ni=Ni, Ns=Ns, Dx=Dx, BC_L=BC_L, BC_R=BC_R, initial_state=initial_state, cp0=cp0, cv0=cv0, steps=s, ord=7)
call rk_integrator%init(stages=5)
endselect
t = 0._R_P
call save_time_serie(title=title, filename=output//'-'//trim(str( s,.true.))//'-time_serie.dat', t=t(s))
step = 1
do while(t(s)<t_final)
if (verbose) print "(A)", ' Time step: '//str(n=dt)//', Time: '//str(n=t)
dt = domain%dt(Nmax=0, Tmax=t_final, t=t(s), CFL=0.1_R_P*CFL)
if (s>=step) then
! the time steps from 1 to s - 1 must be computed with other scheme...
call rk_integrator%integrate(U=domain, stage=rk_stage, dt=dt, t=t(s))
previous(step) = domain
if (step>1) then
t(step) = t(step-1) + dt
else
t(step) = dt
endif
else
call ab_integrator%integrate(U=domain, previous=previous(1:s), dt=dt, t=t)
do ss=1, s-1
t(ss) = t(ss + 1)
enddo
t(s) = t(s) + dt
endif
step = step + 1
call save_time_serie(t=t(s))
enddo
call save_time_serie(t=t(s), finish=.true.)
call save_results(title=title, basename=output//'-'//trim(str( s,.true.)))
enddo
print "(A)", 'Finish!'
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine test_ab