Skip to content

Commit

Permalink
Merge pull request #5 from SciML/nonlinear
Browse files Browse the repository at this point in the history
SteadyStateSolution => NonlinearSolution and alg traits
  • Loading branch information
ChrisRackauckas authored Jan 27, 2021
2 parents f7b2a5e + f6da79a commit d2c5898
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SciMLBase"
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
authors = ["Chris Rackauckas <[email protected]> and contributors"]
version = "1.0.1"
version = "1.1.0"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
19 changes: 7 additions & 12 deletions src/SciMLBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,24 @@ abstract type AbstractLinearProblem{bType,isinplace} <: SciMLProblem end
"""
$(TYPEDEF)
Base for types which define nonlinear systems.
"""
abstract type AbstractNonlinearProblem{uType,isinplace} <: SciMLProblem end

"""
$(TYPEDEF)
Base for types which define integrals suitable for quadrature.
"""
abstract type AbstractQuadratureProblem{isinplace} <: SciMLProblem end

"""
$(TYPEDEF)
Base for types which define equations for optimization
Base for types which define equations for optimization.
"""
abstract type AbstractOptimizationProblem{isinplace} <: SciMLProblem end

"""
$(TYPEDEF)
Base for types which define steady state problems for ODE systems.
Base for types which define nonlinear solve problems (f(u)=0).
"""
abstract type AbstractSteadyStateProblem{uType,isinplace} <: DEProblem end
abstract type AbstractNonlinearProblem{uType,isinplace} <: DEProblem end
const AbstractSteadyStateProblem{uType,isinplace} = AbstractNonlinearProblem{uType,isinplace}

"""
$(TYPEDEF)
Expand Down Expand Up @@ -396,7 +390,7 @@ abstract type AbstractQuadratureSolution{T,N} <: AbstractNoTimeSolution{T,N} end
"""
$(TYPEDEF)
"""
abstract type AbstractSteadyStateSolution{T,N} <: AbstractNoTimeSolution{T,N} end
const AbstractSteadyStateSolution{T,N} = AbstractNonlinearSolution{T,N}

"""
$(TYPEDEF)
Expand Down Expand Up @@ -488,6 +482,7 @@ abstract type AbstractADType end
include("utils.jl")
include("function_wrappers.jl")
include("scimlfunctions.jl")
include("alg_traits.jl")

include("operators/operators.jl")
include("operators/diffeq_operator.jl")
Expand All @@ -511,7 +506,7 @@ include("problems/pde_problems.jl")
include("problems/problem_traits.jl")

include("solutions/basic_solutions.jl")
include("solutions/steady_state_solutions.jl")
include("solutions/nonlinear_solutions.jl")
include("solutions/ode_solutions.jl")
include("solutions/rode_solutions.jl")
include("solutions/dae_solutions.jl")
Expand Down
3 changes: 3 additions & 0 deletions src/alg_traits.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
isautodifferentiable(alg::DEAlgorithm) = false
isadaptive(alg::DEAlgorithm) = true # Default to assuming adaptive, safer error("Adaptivity algorithm trait not set.")
isdiscrete(alg::DEAlgorithm) = false
18 changes: 0 additions & 18 deletions src/solutions/basic_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,6 @@ function build_solution(prob::AbstractLinearProblem,
LinearSolution{T,N,typeof(u),typeof(resid),typeof(prob),typeof(alg)}(u,resid,prob,alg,retcode)
end

struct NonlinearSolution{T,N,uType,R,P,A} <: AbstractNonlinearSolution{T,N}
u::uType
resid::R
prob::P
alg::A
retcode::Symbol
end

function build_solution(prob::AbstractNonlinearProblem,
alg,u,resid;calculate_error = true,
retcode = :Default, kwargs...)

T = eltype(eltype(u))
N = length((size(u)...,))

NonlinearSolution{T,N,typeof(u),typeof(resid),typeof(prob),typeof(alg)}(u,resid,prob,alg,retcode)
end

struct QuadratureSolution{T,N,uType,R,P,A,C} <: AbstractQuadratureSolution{T,N}
u::uType
resid::R
Expand Down
37 changes: 37 additions & 0 deletions src/solutions/nonlinear_solutions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
$(TYPEDEF)
"""
struct NonlinearSolution{T,N,uType,R,P,A,O} <: AbstractNonlinearSolution{T,N}
u::uType
resid::R
prob::P
alg::A
retcode::Symbol
original::O
end

const SteadyStateSolution = NonlinearSolution

function build_solution(prob::AbstractNonlinearProblem,
alg,u,resid;calculate_error = true,
retcode = :Default,
original = nothing,
kwargs...)

T = eltype(eltype(u))
N = length((size(prob.u0)...,))

NonlinearSolution{T,N,typeof(u),typeof(resid),
typeof(prob),typeof(alg),typeof(original)}(
u,resid,prob,alg,retcode,original)
end

function sensitivity_solution(sol::AbstractNonlinearProblem,u)
T = eltype(eltype(u))
N = length((size(sol.prob.u0)...,))

NonlinearSolution{T,N,typeof(u),typeof(sol.resid),
typeof(sol.prob),typeof(sol.alg),
typeof(sol.original)}(
u,sol.resid,sol.prob,sol.alg,sol.retcode,sol.original)
end
29 changes: 0 additions & 29 deletions src/solutions/steady_state_solutions.jl

This file was deleted.

0 comments on commit d2c5898

Please sign in to comment.