Test explicit Adams-Bashforth class of ODE solvers.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
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(lorenz) :: 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(lorenz) :: previous(1:ab_steps) !< Previous time steps solutions.
integer(I_P) :: s !< AB steps counter.
integer :: step !< Time steps counter.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
print "(A)", 'Integrating Lorenz equations by means of Adams-Bashforth class of solvers'
do s=1, ab_steps
print "(A)", ' AB-'//trim(str(.true.,s))
call ab_integrator%init(steps=s)
select case(s)
case(1, 2, 3)
call rk_integrator%init(stages=s)
case(4)
call rk_integrator%init(stages=5)
endselect
call attractor%init(initial_state=initial_state, sigma=sigma, rho=rho, beta=beta, steps=s)
solution(0, 0) = 0._R_P
solution(1:space_dimension, 0) = attractor%output()
do step = 1, num_steps
if (s>=step) then
! the time steps from 1 to s - 1 must be computed with other scheme...
call rk_integrator%integrate(U=attractor, stage=rk_stage, dt=dt, t=solution(0, step))
previous(step) = attractor
else
call ab_integrator%integrate(U=attractor, previous=previous(1:s), dt=dt, t=solution(0, step-s:step-1))
endif
solution(0, step) = step * dt
solution(1:space_dimension, step) = attractor%output()
enddo
call save_results(title='FOODIE test: Lorenz equation integration, explicit Adams-Bashforth '//trim(str(.true., s))//' steps', &
filename='lorenz_integration-ab-'//trim(str(.true., s)))
enddo
print "(A)", 'Finish!'
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine test_ab