Skip to content

Commit

Permalink
Merge pull request SciML#7 from JuliaDiffEq/07
Browse files Browse the repository at this point in the history
update to v0.7
  • Loading branch information
ChrisRackauckas authored Jul 18, 2018
2 parents a95469e + 6970ae3 commit 65b6aef
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: julia
os:
- linux
julia:
- 0.6
- 0.7
- nightly
matrix:
allow_failures:
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.6
julia 0.7-beta2
DiffEqBase 3.0.0
NLsolve 0.14.0
Compat 0.17.0
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
4 changes: 1 addition & 3 deletions src/SteadyStateDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ using Reexport
@reexport using DiffEqBase

using NLsolve, DiffEqCallbacks

using LinearAlgebra
using Compat

import DiffEqBase: solve

include("algorithms.jl")
include("solve.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/algorithms.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstract type SteadyStateDiffEqAlgorithm <: AbstractSteadyStateAlgorithm end
abstract type SteadyStateDiffEqAlgorithm <: DiffEqBase.AbstractSteadyStateAlgorithm end

struct SSRootfind{F} <: SteadyStateDiffEqAlgorithm
nlsolve::F
Expand Down
18 changes: 11 additions & 7 deletions src/solve.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function solve(prob::AbstractSteadyStateProblem,alg::SteadyStateDiffEqAlgorithm,args...;abstol=1e-8,kwargs...)
function DiffEqBase.__solve(prob::DiffEqBase.AbstractSteadyStateProblem,
alg::SteadyStateDiffEqAlgorithm,args...;
abstol=1e-8,kwargs...)

if prob.mass_matrix != I
error("This solver is not able to use mass matrices.")
Expand Down Expand Up @@ -32,15 +34,17 @@ function solve(prob::AbstractSteadyStateProblem,alg::SteadyStateDiffEqAlgorithm,
u = alg.nlsolve(f!,u0,abstol)
resid = similar(u)
f!(resid,u)
build_solution(prob,alg,u,resid;retcode = :Success)
DiffEqBase.build_solution(prob,alg,u,resid;retcode = :Success)
else
error("Algorithm not recognized")
end
end

function solve(prob::AbstractSteadyStateProblem,alg::DynamicSS,args...;kwargs...)
_prob = ODEProblem(prob.f,prob.u0,(0.0,Inf),prob.p,
mass_matrix=prob.mass_matrix,
jac_prototype=prob.jac_prototype)
solve(_prob,alg.alg,args...;kwargs...,callback=TerminateSteadyState(alg.abstol,alg.reltol))
function DiffEqBase.__solve(prob::DiffEqBase.AbstractSteadyStateProblem,
alg::DynamicSS,args...;kwargs...)

_prob = remake(prob;tspan=(0.0,Inf))

solve(_prob,alg.alg,args...;kwargs...,
callback=TerminateSteadyState(alg.abstol,alg.reltol))
end
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using SteadyStateDiffEq, DiffEqBase, NLsolve, Sundials
using Base.Test
using Test

function f(du,u,p,t)
du[1] = 2 - 2u[1]
Expand All @@ -17,7 +17,7 @@ f(du,sol.u,nothing,0)

prob = ODEProblem(f,u0,(0.0,1.0))
prob = SteadyStateProblem(prob)
sol = solve(prob,SSRootfind(nlsolve = (f,u0,abstol) -> (res=NLsolve.nlsolve(f,u0,autodiff=true,method=:newton,iterations=Int(1e6),ftol=abstol);res.zero) ))
sol = solve(prob,SSRootfind(nlsolve = (f,u0,abstol) -> (res=NLsolve.nlsolve(f,u0,autodiff=:forward,method=:newton,iterations=Int(1e6),ftol=abstol);res.zero) ))

f(du,sol.u,nothing,0)
@test du == [0,0]
Expand Down

0 comments on commit 65b6aef

Please sign in to comment.