Skip to content

Commit

Permalink
Merge d278c38 into a0ef97d
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro3 committed May 25, 2016
2 parents a0ef97d + d278c38 commit 681788a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/ODE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ function ode23s(F, y0, tspan; reltol = 1.0e-5, abstol = 1.0e-8,
h = tdir * min(abs(h), maxstep)

y = y0
tout = Array(typeof(t), 1)
# below promotion should maybe be replaced by using make_consistent_types
tout = Array(promote_type(typeof(t), Float64), 1)
tout[1] = t # first output time
yout = Array(typeof(y0), 1)
yout[1] = deepcopy(y) # first output solution
Expand Down
11 changes: 7 additions & 4 deletions test/interface-tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ ODE.isoutofdomain(y::CompSol) = any(isnan, vcat(y.rho[:], y.x, y.p))


################################################################################

# define RHSs of differential equations
# delta, V and g are parameters
function rhs(t, y, delta, V, g)
H = [[-delta/2 V]; [V delta/2]]

rho_dot = -im*H*y.rho + im*y.rho*H
x_dot = y.p
p_dot = -y.x

return CompSol( rho_dot, x_dot, p_dot)
end

# inital conditons
rho0 = zeros(2,2);
rho0[1,1]=1.;
Expand All @@ -75,6 +75,9 @@ for solver in solvers
end
t,y2 = solver((t,y)->rhs(t, y, delta0, V0, g0), y0, linspace(0., endt, 500))
@test norm(y1[end]-y2[end])<0.1

# test that typeof(tspan)==Vector{Int} does not throw:
t,y2 = solver((t,y)->rhs(t, y, delta0, V0, g0), y0, [0,1])
end
println("ok.")

Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ for solver in solvers
t,y=solver((t,y)->2t, 0., [0:.001:1;])
@test maximum(abs(y-t.^2)) < tol

# test typeof(tspan)==Vector{Int} does not throw
t,y=solver((t,y)->2t, 0., [0,1])

# dy
# -- = y ==> y = y0*e.^t
Expand Down

0 comments on commit 681788a

Please sign in to comment.