Skip to content
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

SecondOrderDDEProblem (and underlying DynamicalDDEProblem) #14

Merged
merged 2 commits into from
Jan 31, 2021

Conversation

wi11dey
Copy link
Contributor

@wi11dey wi11dey commented Jan 31, 2021

Hey @ChrisRackauckas,

Following up on last semester, this PR has the plumbing necessary for SecondOrderDDEProblem that seems to be working well in Photron the last few weeks. It mirrors the structure of SecondOrderODEProblem, with the necessary changes in order to support a history function as well as 2 initial conditions. DelayDiffEq.jl requires a one-line change for this to work, because before it would only wrap the concrete DDEFunction rather than any AbstractDDEFunction: SciML/DelayDiffEq.jl#203

Once Photron reaches stability, I can add its Lienard-Wiechert solver to DiffEqProblemLibrary.jl/src/dde as an example of how to use this problem to solve relativistic physics.

Companion PRs:

@codecov
Copy link

codecov bot commented Jan 31, 2021

Codecov Report

Merging #14 (39bdaea) into master (49c8fa5) will decrease coverage by 0.05%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #14      +/-   ##
=========================================
- Coverage    2.92%   2.87%   -0.06%     
=========================================
  Files          37      37              
  Lines        2663    2712      +49     
=========================================
  Hits           78      78              
- Misses       2585    2634      +49     
Impacted Files Coverage Δ
src/SciMLBase.jl 50.00% <ø> (ø)
src/problems/dde_problems.jl 0.00% <0.00%> (ø)
src/scimlfunctions.jl 2.92% <0.00%> (-0.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49c8fa5...c555ead. Read the comment docs.

function DynamicalDDEProblem(f::DynamicalDDEFunction,h::Function,tspan,p=NullParameters();kwargs...)
DynamicalDDEProblem(f,h(p,first(tspan))...,h,tspan,p;kwargs...)
end
function DynamicalDDEProblem(f1::Function,f2::Function,args...;kwargs...)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Varargs are used here so the optional v0, u0 initial conditions can be handled by dispatch by the two constructors above, and the code doesn't have to be repeated for any of the following constructors. f1 and f2's types are specified to be Function so that the constructor doesn't just pull out the first 2 arguments of and try to pass on the rest, which would result in more confusing dispatch errors down the line if an incorrect call is made.

end
function Base.getproperty(f::DynamicalDDEFunction, name::Symbol)
if name === :f
# Use the f property as an alias for calling the function itself, so DynamicalDDEFunction fits the same interface as DDEFunction as expected by the ODEFunctionWrapper in DelayDiffEq.jl.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See SciML/DelayDiffEq.jl#203: this is so that ODEFunctionWrapper can expect all AbstractDDEFunctions to define f.f with the entire DDE.

src/problems/dde_problems.jl Outdated Show resolved Hide resolved
src/problems/dde_problems.jl Outdated Show resolved Hide resolved
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Copy link
Member

@ChrisRackauckas ChrisRackauckas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good thanks.

@ChrisRackauckas ChrisRackauckas merged commit 36911f9 into SciML:master Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants