Skip to content

Commit 9cd83e1

Browse files
authored
Fix #13 (#14)
1 parent 3c41182 commit 9cd83e1

8 files changed

+37
-37
lines changed

Project.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name = "F1Method"
22
uuid = "d5605bae-6d76-11e9-2fd7-71bcf42edbaa"
33
authors = ["Benoit Pasquier <briochemc@gmail.com>"]
4-
version = "0.5.0"
4+
version = "0.5.1"
55

66
[deps]
7-
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
87
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
98
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9+
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1010

1111
[compat]
12-
DiffEqBase = "6"
1312
ForwardDiff = "0.10"
13+
SciMLBase = "1"
1414
julia = "1"
1515

1616
[extras]

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ A requirement of the F-1 algorithm is that the Jacobian matrix `A = ∇ₓF` can
7070
To use the F-1 algorithm, the user must:
7171

7272
- Make sure that there is a suitable algorithm `alg` to solve the steady-state equation
73-
- overload the `solve` function and the `SteadyStateProblem` constructor from [DiffEqBase](https://github.com/JuliaDiffEq/DiffEqBase.jl). (An example is given in the CI tests — see, e.g., the [`test/simple_setup.jl`](test/simple_setup.jl) file.)
73+
- overload the `solve` function and the `SteadyStateProblem` constructor from [SciMLBase](https://github.com/JuliaDiffEq/SciMLBase.jl). (An example is given in the CI tests — see, e.g., the [`test/simple_setup.jl`](test/simple_setup.jl) file.)
7474
- Provide the derivatives of `f` and `F` with respect to the state, `x`.
7575

7676
## A concrete example
7777

78-
Make sure you have overloaded `solve` from DiffEqBase
78+
Make sure you have overloaded `solve` from SciMLBase
7979
(an example of how to do this is given in the [documentation](https://briochemc.github.io/F1Method.jl/stable/)).
8080
Once initial values for the state, `x`, and parameters, `p`, are chosen, simply initialize the required memory cache, `mem` via
8181

docs/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[deps]
2-
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
32
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
43
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
4+
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
55

66
[compat]
77
Documenter = "~0.27"

docs/make.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Documenter, F1Method
2-
using LinearAlgebra, DiffEqBase, ForwardDiff
2+
using LinearAlgebra, SciMLBase, ForwardDiff
33

44
makedocs(
55
sitename="F1Method Documentation",

docs/src/index.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ In this case, there are a number of shortcuts that can be leveraged.
1414
```@meta
1515
DocTestSetup = quote
1616
using F1Method
17-
using LinearAlgebra, DiffEqBase, ForwardDiff
17+
using LinearAlgebra, SciMLBase, ForwardDiff
1818
end
1919
```
2020

@@ -63,8 +63,8 @@ f(x,p) = state_mismatch(x) + parameter_mismatch(p)
6363
```
6464

6565
Once these are set up, we need to let the F-1 method know how to solve for the steady-state.
66-
We do this by using the [DiffEqBase](https://github.com/SciML/DiffEqBase.jl) API.
67-
For that, we first write a small Newton solver algorithm, we overload the `solve` function from DiffEqBase, and we overload the `SteadyStateProblem` constructor.
66+
We do this by using the [SciMLBase](https://github.com/SciML/SciMLBase.jl) API.
67+
For that, we first write a small Newton solver algorithm, we overload the `solve` function from SciMLBase, and we overload the `SteadyStateProblem` constructor.
6868

6969
```jldoctest usage
7070
function newton_solve(F, ∇ₓF, x; Ftol=1e-10)
@@ -75,23 +75,23 @@ function newton_solve(F, ∇ₓF, x; Ftol=1e-10)
7575
end
7676
7777
# Create a type for the solver's algorithm
78-
struct MyAlg <: DiffEqBase.AbstractSteadyStateAlgorithm end
78+
struct MyAlg <: SciMLBase.AbstractSteadyStateAlgorithm end
7979
80-
# Overload DiffEqBase's solve function
81-
function DiffEqBase.solve(prob::DiffEqBase.AbstractSteadyStateProblem,
80+
# Overload SciMLBase's solve function
81+
function SciMLBase.solve(prob::SciMLBase.AbstractSteadyStateProblem,
8282
alg::MyAlg;
8383
Ftol=1e-10)
84-
# Define the functions according to DiffEqBase.SteadyStateProblem type
84+
# Define the functions according to SciMLBase.SteadyStateProblem type
8585
p = prob.p
8686
x0 = copy(prob.u0)
8787
dx, df = copy(x0), copy(x0)
8888
F(x) = prob.f(x, p)
8989
∇ₓF(x) = prob.f.jac(x, p)
90-
# Compute `u_steady` and `resid` as per DiffEqBase using my algorithm
90+
# Compute `u_steady` and `resid` as per SciMLBase using my algorithm
9191
x_steady = newton_solve(F, ∇ₓF, x0, Ftol=Ftol)
9292
resid = F(x_steady)
93-
# Return the common DiffEqBase solution type
94-
DiffEqBase.build_solution(prob, alg, x_steady, resid; retcode=:Success)
93+
# Return the common SciMLBase solution type
94+
SciMLBase.build_solution(prob, alg, x_steady, resid; retcode=:Success)
9595
end
9696
9797
# output

src/F1Method.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refer to the Equation numbers in the above manuscript. A bibtex
77
citation file is available in the GitHub repository.
88
======================================================================#
99

10-
using LinearAlgebra, ForwardDiff, DiffEqBase
10+
using LinearAlgebra, ForwardDiff, SciMLBase
1111

1212
"""
1313
Mem

test/diffusion_problem.jl

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Test, FormulaOneMethod
33

44
#@testset "Testing in a diffusion system" begin
55

6-
using LinearAlgebra, SparseArrays, SuiteSparse, DiffEqBase, FormulaOneMethod
6+
using LinearAlgebra, SparseArrays, SuiteSparse, SciMLBase, FormulaOneMethod
77

88
# 2D Laplacian
99
function laplacian_2D(nx, ny, k)
@@ -64,31 +64,31 @@ using Test, FormulaOneMethod
6464
end
6565

6666
# Create a type for the solver's algorithm
67-
struct MyAlg <: DiffEqBase.AbstractSteadyStateAlgorithm end
67+
struct MyAlg <: SciMLBase.AbstractSteadyStateAlgorithm end
6868

69-
# Overload DiffEqBase's solve function
70-
function DiffEqBase.solve(prob::DiffEqBase.AbstractSteadyStateProblem,
69+
# Overload SciMLBase's solve function
70+
function SciMLBase.solve(prob::SciMLBase.AbstractSteadyStateProblem,
7171
alg::MyAlg;
7272
Ftol=1e-10)
73-
# Define the functions according to DiffEqBase.SteadyStateProblem type
73+
# Define the functions according to SciMLBase.SteadyStateProblem type
7474
p = prob.p
7575
t = 0
7676
x0 = copy(prob.u0)
7777
dx, df = copy(x0), copy(x0)
7878
F(x) = prob.f(dx, x, p, t)
7979
∇ₓF(x) = prob.f(df, dx, x, p, t)
80-
# Compute `u_steady` and `resid` as per DiffEqBase using my algorithm
80+
# Compute `u_steady` and `resid` as per SciMLBase using my algorithm
8181
x_steady = newton_solve(F, x0, Ftol=Ftol)
8282
resid = F(x_steady)
83-
# Return the common DiffEqBase solution type
84-
DiffEqBase.build_solution(prob, alg, x_steady, resid; retcode=:Success)
83+
# Return the common SciMLBase solution type
84+
SciMLBase.build_solution(prob, alg, x_steady, resid; retcode=:Success)
8585
end
8686

87-
# Overload DiffEqBase's SteadyStateProblem constructor
88-
function DiffEqBase.SteadyStateProblem(F, x, p)
87+
# Overload SciMLBase's SteadyStateProblem constructor
88+
function SciMLBase.SteadyStateProblem(F, x, p)
8989
f(dx, x, p, t) = F(x, p)
9090
f(df, dx, x, p, t) = ∇ₓF(x, p)
91-
return DiffEqBase.SteadyStateProblem(f, x, p)
91+
return SciMLBase.SteadyStateProblem(f, x, p)
9292
end
9393

9494
# Define objective function f(x,p) and ∇ₓf(x,p)

test/rosenbrock.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module SubModuleRosenBrock
55
using Test
66
using F1Method
77
using LinearAlgebra
8-
using DiffEqBase
8+
using SciMLBase
99
using ForwardDiff
1010

1111
# Set up:
@@ -22,23 +22,23 @@ function newton_solve(F, ∇ₓF, x; Ftol=1e-10)
2222
end
2323

2424
# Create a type for the solver's algorithm
25-
struct MyAlg <: DiffEqBase.AbstractSteadyStateAlgorithm end
25+
struct MyAlg <: SciMLBase.AbstractSteadyStateAlgorithm end
2626

27-
# Overload DiffEqBase's solve function
28-
function DiffEqBase.solve(prob::DiffEqBase.AbstractSteadyStateProblem,
27+
# Overload SciMLBase's solve function
28+
function SciMLBase.solve(prob::SciMLBase.AbstractSteadyStateProblem,
2929
alg::MyAlg;
3030
Ftol=1e-10)
31-
# Define the functions according to DiffEqBase.SteadyStateProblem type
31+
# Define the functions according to SciMLBase.SteadyStateProblem type
3232
p = prob.p
3333
x0 = copy(prob.u0)
3434
dx, df = copy(x0), copy(x0)
3535
F(x) = prob.f(x, p)
3636
∇ₓF(x) = prob.f.jac(x, p)
37-
# Compute `u_steady` and `resid` as per DiffEqBase using my algorithm
37+
# Compute `u_steady` and `resid` as per SciMLBase using my algorithm
3838
x_steady = newton_solve(F, ∇ₓF, x0, Ftol=Ftol)
3939
resid = F(x_steady)
40-
# Return the common DiffEqBase solution type
41-
DiffEqBase.build_solution(prob, alg, x_steady, resid; retcode=:Success)
40+
# Return the common SciMLBase solution type
41+
SciMLBase.build_solution(prob, alg, x_steady, resid; retcode=:Success)
4242
end
4343

4444

0 commit comments

Comments
 (0)