41 integer,
parameter :: verb = 2
49 type(ode_solution) :: sol
50 type(ode_problem) :: pb
51 type(ode_solver) :: slv
57 real(RP),
parameter :: t0 = 0.0_rp
58 real(RP),
parameter :: T = 1.5_rp
59 integer ,
parameter :: L_meth =
ode_cn 60 real(RP),
parameter :: dt = 0.1_rp
64 type(ode_output) :: ode_out
75 write(*,*)
"ode_Lin_0d : start" 82 write(*,*)
"================================== OUTPUT SETTINGS" 83 ode_out = ode_output(t0, t, n=1)
84 call set(ode_out, verb=5)
85 call set(ode_out, vxn_period = 0.1_rp, vxn_plot=.true.)
86 if (verb>0)
call print(ode_out)
92 write(*,*)
"================================== TIME DISCRETISATION" 95 if (verb>0)
call print(pb)
99 slv = ode_solver(pb,
ode_slv_1s, l_meth=l_meth, verb=verb)
100 if (verb>0)
call print(slv)
105 sol = ode_solution(slv, pb)
106 if (verb>0)
call print(sol)
111 write(*,*)
"================================== NUMERICAL RESOLUTION" 112 write(*,*)
"================================== 1- USER-DEFINED OUTPUT" 115 call initialcond(sol, pb, slv, t0, (/1.0_rp/))
121 call solve(sol, slv, pb, t0, t, dt)
124 write(*,*)
"================================== NUMERICAL RESOLUTION" 125 write(*,*)
"================================== 2- PRE-DEFINED OUTPUT& 126 & USING 'ode-output' type" 129 call initialcond(sol, pb, slv, t0, (/1.0_rp/))
132 call assemble(ode_out, dt)
135 call solve(sol, slv, pb, t0, t, dt, output=ode_out)
138 write(*,*)
" Error = |y_h(T) - y(T)| / |y(T)| = ", &
139 & abs(sol%V(1,1) - exp(t)) / exp(t)
141 write(*,*)
"ode_Lin_0d : end" 146 real(RP),
dimension(:),
intent(out) :: yy
147 real(RP),
dimension(:),
intent(in) :: xx
153 subroutine id_m(yy,xx)
154 real(RP),
dimension(:),
intent(out) :: yy
155 real(RP),
dimension(:),
intent(in) :: xx
162 real(RP) ,
intent(in) :: tn
163 type(ode_solution),
intent(in) :: s
164 logical ,
intent(inout) :: stop
166 if (tn<=real_tol)
then 167 print*,
'Solving with a user_defined_output:' 168 print*,
'Resolution method = ', name_ode_method(l_meth)
169 print*,
' Time t | y_h(t) | errro |y_h(t) - y(t)|/y(t)' 171 print*,
real(tn, SP),
real(s%v, SP),
real(abs(s%v-exp(tn))/exp(tn), sp)
subroutine, public choral_init(verb)
Initialisation for the CHORAL library
TOP-LEVEL MODULE FOR THE LIBRARY CHORAL
integer, parameter ode_cn
Crank Nicholson.
program ode_lin_0d
EXAMPLE FOR THE RESOLUTION OF:
integer, parameter ode_pb_lin
Linear ODE : .
subroutine user_defined_output(tn, s, stop)
integer, parameter ode_slv_1s
onestep