-
-
Notifications
You must be signed in to change notification settings - Fork 233
Add symbolic tspan field to System struct (fixes #847) #3837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,8 +23,90 @@ for T in [:NonlinearSystem, :DiscreteSystem, :ImplicitDiscreteSystem] | |||||||
| @eval @deprecate $T(args...; kwargs...) System(args...; kwargs...) | ||||||||
| end | ||||||||
|
|
||||||||
| for T in [:ODEProblem, :DDEProblem, :SDEProblem, :SDDEProblem, :DAEProblem, | ||||||||
| :BVProblem, :DiscreteProblem, :ImplicitDiscreteProblem] | ||||||||
| # Time-dependent problems with keyword tspan | ||||||||
| for T in [:ODEProblem, :SDEProblem, :BVProblem, :DDEProblem, :SDDEProblem] | ||||||||
| for (pType, pCanonical) in [ | ||||||||
| (AbstractDict, :p), | ||||||||
| (AbstractArray{<:Pair}, :(Dict(p))), | ||||||||
| (AbstractArray, :(isempty(p) ? Dict() : Dict(parameters(sys) .=> p))) | ||||||||
| ], | ||||||||
| (uType, uCanonical) in [ | ||||||||
| (Nothing, :(Dict())), | ||||||||
| (AbstractDict, :u0), | ||||||||
| (AbstractArray{<:Pair}, :(Dict(u0))), | ||||||||
| (AbstractArray, :(isempty(u0) ? Dict() : Dict(unknowns(sys) .=> u0))) | ||||||||
| ] | ||||||||
|
|
||||||||
| @eval function SciMLBase.$T(sys::System, u0::$uType, tspan, p::$pType; kw...) | ||||||||
| ctor = string($T) | ||||||||
| uCan = string($(QuoteNode(uCanonical))) | ||||||||
| pCan = string($(QuoteNode(pCanonical))) | ||||||||
| @warn """ | ||||||||
| `$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use | ||||||||
| `$ctor(sys, merge($uCan, $pCan); tspan=tspan)` instead. | ||||||||
| """ | ||||||||
| SciMLBase.$T(sys, merge($uCanonical, $pCanonical); tspan=tspan, kw...) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||
| end | ||||||||
| @eval function SciMLBase.$T{iip}( | ||||||||
| sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip} | ||||||||
| ctor = string($T{iip}) | ||||||||
| uCan = string($(QuoteNode(uCanonical))) | ||||||||
| pCan = string($(QuoteNode(pCanonical))) | ||||||||
| @warn """ | ||||||||
| `$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use | ||||||||
| `$ctor(sys, merge($uCan, $pCan); tspan=tspan)` instead. | ||||||||
| """ | ||||||||
| return SciMLBase.$T{iip}(sys, merge($uCanonical, $pCanonical); tspan=tspan, kw...) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||
| end | ||||||||
| @eval function SciMLBase.$T{iip, spec}( | ||||||||
| sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip, spec} | ||||||||
| ctor = string($T{iip, spec}) | ||||||||
| uCan = string($(QuoteNode(uCanonical))) | ||||||||
| pCan = string($(QuoteNode(pCanonical))) | ||||||||
| @warn """ | ||||||||
| `$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use | ||||||||
| `$ctor(sys, merge($uCan, $pCan); tspan=tspan)` instead. | ||||||||
| """ | ||||||||
| return $T{iip, spec}(sys, merge($uCanonical, $pCanonical); tspan=tspan, kw...) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||
| end | ||||||||
| end | ||||||||
|
|
||||||||
| for pType in [SciMLBase.NullParameters, Nothing], uType in [Any, Nothing] | ||||||||
|
|
||||||||
| @eval function SciMLBase.$T(sys::System, u0::$uType, tspan, p::$pType; kw...) | ||||||||
| ctor = string($T) | ||||||||
| pT = string($(QuoteNode(pType))) | ||||||||
| @warn """ | ||||||||
| `$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use | ||||||||
| `$ctor(sys, u0; tspan=tspan)` instead. | ||||||||
| """ | ||||||||
| $T(sys, u0; tspan=tspan, kw...) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||
| end | ||||||||
| @eval function SciMLBase.$T{iip}( | ||||||||
| sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip} | ||||||||
| ctor = string($T{iip}) | ||||||||
| pT = string($(QuoteNode(pType))) | ||||||||
| @warn """ | ||||||||
| `$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use | ||||||||
| `$ctor(sys, u0; tspan=tspan)` instead. | ||||||||
| """ | ||||||||
| return $T{iip}(sys, u0; tspan=tspan, kw...) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||
| end | ||||||||
| @eval function SciMLBase.$T{iip, spec}( | ||||||||
| sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip, spec} | ||||||||
| ctor = string($T{iip, spec}) | ||||||||
| pT = string($(QuoteNode(pType))) | ||||||||
| @warn """ | ||||||||
| `$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use | ||||||||
| `$ctor(sys, u0; tspan=tspan)` instead. | ||||||||
| """ | ||||||||
| return $T{iip, spec}(sys, u0; tspan=tspan, kw...) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||
| end | ||||||||
| end | ||||||||
| end | ||||||||
|
|
||||||||
| # Problems with positional tspan (unchanged) | ||||||||
| for T in [:DAEProblem, :DiscreteProblem, :ImplicitDiscreteProblem] | ||||||||
| for (pType, pCanonical) in [ | ||||||||
| (AbstractDict, :p), | ||||||||
| (AbstractArray{<:Pair}, :(Dict(p))), | ||||||||
|
|
||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not try and change our problem constructor syntax. This applies for every file in this subdirectory - the Also, this just takes the |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,12 +1,20 @@ | ||||
| @fallback_iip_specialize function SciMLBase.BVProblem{iip, spec}( | ||||
| sys::System, op, tspan; | ||||
| sys::System, op; tspan = nothing, | ||||
| check_compatibility = true, cse = true, | ||||
| checkbounds = false, eval_expression = false, eval_module = @__MODULE__, | ||||
| expression = Val{false}, guesses = Dict(), callback = nothing, | ||||
| kwargs...) where {iip, spec} | ||||
| check_complete(sys, BVProblem) | ||||
| check_compatibility && check_compatible_system(BVProblem, sys) | ||||
| isnothing(callback) || error("BVP solvers do not support callbacks.") | ||||
|
|
||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
| # Use system's tspan as default if not provided | ||||
| if tspan === nothing | ||||
| tspan = get_tspan(sys) | ||||
| if tspan === nothing | ||||
| throw(ArgumentError("tspan must be provided either as an argument or defined in the system")) | ||||
| end | ||||
| end | ||||
|
|
||||
| dvs = unknowns(sys) | ||||
| op = to_varmap(op, dvs) | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -39,12 +39,20 @@ | |||
| end | ||||
|
|
||||
| @fallback_iip_specialize function SciMLBase.DDEProblem{iip, spec}( | ||||
| sys::System, op, tspan; | ||||
| sys::System, op; tspan = nothing, | ||||
| callback = nothing, check_length = true, cse = true, checkbounds = false, | ||||
| eval_expression = false, eval_module = @__MODULE__, check_compatibility = true, | ||||
| u0_constructor = identity, expression = Val{false}, kwargs...) where {iip, spec} | ||||
| check_complete(sys, DDEProblem) | ||||
| check_compatibility && check_compatible_system(DDEProblem, sys) | ||||
|
|
||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
| # Use system's tspan as default if not provided | ||||
| if tspan === nothing | ||||
| tspan = get_tspan(sys) | ||||
| if tspan === nothing | ||||
| throw(ArgumentError("tspan must be provided either as an argument or defined in the system")) | ||||
| end | ||||
| end | ||||
|
|
||||
| f, u0, | ||||
| p = process_SciMLProblem(DDEFunction{iip, spec}, sys, op; | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -70,12 +70,20 @@ | |||
| end | ||||
|
|
||||
| @fallback_iip_specialize function SciMLBase.ODEProblem{iip, spec}( | ||||
| sys::System, op, tspan; | ||||
| sys::System, op; tspan = nothing, | ||||
| callback = nothing, check_length = true, eval_expression = false, | ||||
| expression = Val{false}, eval_module = @__MODULE__, check_compatibility = true, | ||||
| kwargs...) where {iip, spec} | ||||
| check_complete(sys, ODEProblem) | ||||
| check_compatibility && check_compatible_system(ODEProblem, sys) | ||||
|
|
||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
| # Use system's tspan as default if not provided | ||||
| if tspan === nothing | ||||
| tspan = get_tspan(sys) | ||||
| if tspan === nothing | ||||
| throw(ArgumentError("tspan must be provided either as an argument or defined in the system")) | ||||
| end | ||||
| end | ||||
|
|
||||
| f, u0, | ||||
| p = process_SciMLProblem(ODEFunction{iip, spec}, sys, op; | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -40,13 +40,21 @@ | |||
| end | ||||
|
|
||||
| @fallback_iip_specialize function SciMLBase.SDDEProblem{iip, spec}( | ||||
| sys::System, op, tspan; | ||||
| sys::System, op; tspan = nothing, | ||||
| callback = nothing, check_length = true, cse = true, checkbounds = false, | ||||
| eval_expression = false, eval_module = @__MODULE__, check_compatibility = true, | ||||
| u0_constructor = identity, sparse = false, sparsenoise = sparse, | ||||
| expression = Val{false}, kwargs...) where {iip, spec} | ||||
| check_complete(sys, SDDEProblem) | ||||
| check_compatibility && check_compatible_system(SDDEProblem, sys) | ||||
|
|
||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
| # Use system's tspan as default if not provided | ||||
| if tspan === nothing | ||||
| tspan = get_tspan(sys) | ||||
| if tspan === nothing | ||||
| throw(ArgumentError("tspan must be provided either as an argument or defined in the system")) | ||||
| end | ||||
| end | ||||
|
|
||||
| f, u0, | ||||
| p = process_SciMLProblem(SDDEFunction{iip, spec}, sys, op; | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -65,12 +65,20 @@ | |||
| end | ||||
|
|
||||
| @fallback_iip_specialize function SciMLBase.SDEProblem{iip, spec}( | ||||
| sys::System, op, tspan; | ||||
| sys::System, op; tspan = nothing, | ||||
| callback = nothing, check_length = true, eval_expression = false, | ||||
| eval_module = @__MODULE__, check_compatibility = true, sparse = false, | ||||
| sparsenoise = sparse, expression = Val{false}, kwargs...) where {iip, spec} | ||||
| check_complete(sys, SDEProblem) | ||||
| check_compatibility && check_compatible_system(SDEProblem, sys) | ||||
|
|
||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
| # Use system's tspan as default if not provided | ||||
| if tspan === nothing | ||||
| tspan = get_tspan(sys) | ||||
| if tspan === nothing | ||||
| throw(ArgumentError("tspan must be provided either as an argument or defined in the system")) | ||||
| end | ||||
| end | ||||
|
|
||||
| f, u0, | ||||
| p = process_SciMLProblem(SDEFunction{iip, spec}, sys, op; | ||||
|
|
||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds the field to the system, but does not handle it in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be touched