diff --git a/Project.toml b/Project.toml index fdda079ae..c53a75bbf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SciMLBase" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" authors = ["Chris Rackauckas and contributors"] -version = "1.0.1" +version = "1.1.0" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index a63ad67a3..5686c3b9e 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -45,13 +45,6 @@ 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 @@ -59,16 +52,17 @@ 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) @@ -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) @@ -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") @@ -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") diff --git a/src/alg_traits.jl b/src/alg_traits.jl new file mode 100644 index 000000000..e32f502f2 --- /dev/null +++ b/src/alg_traits.jl @@ -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 diff --git a/src/solutions/basic_solutions.jl b/src/solutions/basic_solutions.jl index fa17db2f5..cb236b168 100644 --- a/src/solutions/basic_solutions.jl +++ b/src/solutions/basic_solutions.jl @@ -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 diff --git a/src/solutions/nonlinear_solutions.jl b/src/solutions/nonlinear_solutions.jl new file mode 100644 index 000000000..3006986f8 --- /dev/null +++ b/src/solutions/nonlinear_solutions.jl @@ -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 diff --git a/src/solutions/steady_state_solutions.jl b/src/solutions/steady_state_solutions.jl deleted file mode 100644 index 79aabb8c7..000000000 --- a/src/solutions/steady_state_solutions.jl +++ /dev/null @@ -1,29 +0,0 @@ -""" -$(TYPEDEF) -""" -struct SteadyStateSolution{T,N,uType,R,P,A} <: AbstractSteadyStateSolution{T,N} - u::uType - resid::R - prob::P - alg::A - retcode::Symbol -end - -function build_solution(prob::AbstractSteadyStateProblem, - alg,u,resid;calculate_error = true, - retcode = :Default, kwargs...) - - T = eltype(eltype(u)) - N = length((size(prob.u0)...,)) - - SteadyStateSolution{T,N,typeof(u),typeof(resid),typeof(prob),typeof(alg)}(u,resid,prob,alg,retcode) -end - -function sensitivity_solution(sol::AbstractSteadyStateSolution,u) - T = eltype(eltype(u)) - N = length((size(sol.prob.u0)...,)) - - SteadyStateSolution{T,N,typeof(u),typeof(sol.resid), - typeof(sol.prob),typeof(sol.alg)}( - u,sol.resid,sol.prob,sol.alg,sol.retcode) -end