Skip to content

Commit d2c5898

Browse files
Merge pull request #5 from SciML/nonlinear
SteadyStateSolution => NonlinearSolution and alg traits
2 parents f7b2a5e + f6da79a commit d2c5898

File tree

6 files changed

+48
-60
lines changed

6 files changed

+48
-60
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SciMLBase"
22
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
33
authors = ["Chris Rackauckas <[email protected]> and contributors"]
4-
version = "1.0.1"
4+
version = "1.1.0"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/SciMLBase.jl

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,24 @@ abstract type AbstractLinearProblem{bType,isinplace} <: SciMLProblem end
4545
"""
4646
$(TYPEDEF)
4747
48-
Base for types which define nonlinear systems.
49-
"""
50-
abstract type AbstractNonlinearProblem{uType,isinplace} <: SciMLProblem end
51-
52-
"""
53-
$(TYPEDEF)
54-
5548
Base for types which define integrals suitable for quadrature.
5649
"""
5750
abstract type AbstractQuadratureProblem{isinplace} <: SciMLProblem end
5851

5952
"""
6053
$(TYPEDEF)
6154
62-
Base for types which define equations for optimization
55+
Base for types which define equations for optimization.
6356
"""
6457
abstract type AbstractOptimizationProblem{isinplace} <: SciMLProblem end
6558

6659
"""
6760
$(TYPEDEF)
6861
69-
Base for types which define steady state problems for ODE systems.
62+
Base for types which define nonlinear solve problems (f(u)=0).
7063
"""
71-
abstract type AbstractSteadyStateProblem{uType,isinplace} <: DEProblem end
64+
abstract type AbstractNonlinearProblem{uType,isinplace} <: DEProblem end
65+
const AbstractSteadyStateProblem{uType,isinplace} = AbstractNonlinearProblem{uType,isinplace}
7266

7367
"""
7468
$(TYPEDEF)
@@ -396,7 +390,7 @@ abstract type AbstractQuadratureSolution{T,N} <: AbstractNoTimeSolution{T,N} end
396390
"""
397391
$(TYPEDEF)
398392
"""
399-
abstract type AbstractSteadyStateSolution{T,N} <: AbstractNoTimeSolution{T,N} end
393+
const AbstractSteadyStateSolution{T,N} = AbstractNonlinearSolution{T,N}
400394

401395
"""
402396
$(TYPEDEF)
@@ -488,6 +482,7 @@ abstract type AbstractADType end
488482
include("utils.jl")
489483
include("function_wrappers.jl")
490484
include("scimlfunctions.jl")
485+
include("alg_traits.jl")
491486

492487
include("operators/operators.jl")
493488
include("operators/diffeq_operator.jl")
@@ -511,7 +506,7 @@ include("problems/pde_problems.jl")
511506
include("problems/problem_traits.jl")
512507

513508
include("solutions/basic_solutions.jl")
514-
include("solutions/steady_state_solutions.jl")
509+
include("solutions/nonlinear_solutions.jl")
515510
include("solutions/ode_solutions.jl")
516511
include("solutions/rode_solutions.jl")
517512
include("solutions/dae_solutions.jl")

src/alg_traits.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
isautodifferentiable(alg::DEAlgorithm) = false
2+
isadaptive(alg::DEAlgorithm) = true # Default to assuming adaptive, safer error("Adaptivity algorithm trait not set.")
3+
isdiscrete(alg::DEAlgorithm) = false

src/solutions/basic_solutions.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ function build_solution(prob::AbstractLinearProblem,
1919
LinearSolution{T,N,typeof(u),typeof(resid),typeof(prob),typeof(alg)}(u,resid,prob,alg,retcode)
2020
end
2121

22-
struct NonlinearSolution{T,N,uType,R,P,A} <: AbstractNonlinearSolution{T,N}
23-
u::uType
24-
resid::R
25-
prob::P
26-
alg::A
27-
retcode::Symbol
28-
end
29-
30-
function build_solution(prob::AbstractNonlinearProblem,
31-
alg,u,resid;calculate_error = true,
32-
retcode = :Default, kwargs...)
33-
34-
T = eltype(eltype(u))
35-
N = length((size(u)...,))
36-
37-
NonlinearSolution{T,N,typeof(u),typeof(resid),typeof(prob),typeof(alg)}(u,resid,prob,alg,retcode)
38-
end
39-
4022
struct QuadratureSolution{T,N,uType,R,P,A,C} <: AbstractQuadratureSolution{T,N}
4123
u::uType
4224
resid::R
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
$(TYPEDEF)
3+
"""
4+
struct NonlinearSolution{T,N,uType,R,P,A,O} <: AbstractNonlinearSolution{T,N}
5+
u::uType
6+
resid::R
7+
prob::P
8+
alg::A
9+
retcode::Symbol
10+
original::O
11+
end
12+
13+
const SteadyStateSolution = NonlinearSolution
14+
15+
function build_solution(prob::AbstractNonlinearProblem,
16+
alg,u,resid;calculate_error = true,
17+
retcode = :Default,
18+
original = nothing,
19+
kwargs...)
20+
21+
T = eltype(eltype(u))
22+
N = length((size(prob.u0)...,))
23+
24+
NonlinearSolution{T,N,typeof(u),typeof(resid),
25+
typeof(prob),typeof(alg),typeof(original)}(
26+
u,resid,prob,alg,retcode,original)
27+
end
28+
29+
function sensitivity_solution(sol::AbstractNonlinearProblem,u)
30+
T = eltype(eltype(u))
31+
N = length((size(sol.prob.u0)...,))
32+
33+
NonlinearSolution{T,N,typeof(u),typeof(sol.resid),
34+
typeof(sol.prob),typeof(sol.alg),
35+
typeof(sol.original)}(
36+
u,sol.resid,sol.prob,sol.alg,sol.retcode,sol.original)
37+
end

src/solutions/steady_state_solutions.jl

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)