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

Partitoned Methods not working for HODEs #179

Closed
ndefilippis opened this issue Nov 3, 2023 · 1 comment
Closed

Partitoned Methods not working for HODEs #179

ndefilippis opened this issue Nov 3, 2023 · 1 comment

Comments

@ndefilippis
Copy link

It seems like there is some typing issue with converting an HODEProblem to a PODEProblem such that partitioning methods don't working for Hamiltonian problems. Here's some code along with an error I get

function H(t, q, p, params)
    return 1/2*p[1]^2 - q[1]^2;
end

function f1(f1, t, q, p, params)
    f1[1] = -2*q[1]
end

function v(v, t, q, p, params);
    v[1] = p[1]
end

hprob = HODEProblem(v, f1, H, (0.0, 10.0), 0.1, (q = [0.0], p = [1.0]));
integrator = GeometricIntegrator(hprob, LobattoIIIAIIIB(2));
integrate(integrator);

and I get this error

MethodError: no method matching compute_stage_q!(::SolutionStepPODE{Float64, Float64, Vector{Float64}, Vector{Float64}, Vector{Float64}, NamedTuple{(:t, :q, :p, :v, :f), Tuple{OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}}}, NamedTuple{(), Tuple{}}, NullParameters, 2}, ::HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, ::EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}, ::GeometricIntegrators.Integrators.EPRKCache{Float64, 1, 2}, ::Int64, ::Int64, ::Float64)
Stacktrace:
 [1] integrate_step!(int::GeometricIntegrator{EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}, HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, GeometricIntegrators.Integrators.CacheDict{HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}}, NoSolver, NoInitialGuess, SolutionStepPODE{Float64, Float64, Vector{Float64}, Vector{Float64}, Vector{Float64}, NamedTuple{(:t, :q, :p, :v, :f), Tuple{OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}}}, NamedTuple{(), Tuple{}}, NullParameters, 2}})
   @ GeometricIntegrators.Integrators C:\Users\ndefi\.julia\packages\GeometricIntegrators\uE6qJ\src\integrators\rk\integrators_eprk.jl:0
 [2] integrate!
   @ C:\Users\ndefi\.julia\packages\GeometricIntegrators\uE6qJ\src\integrators\integrator.jl:57 [inlined]
 [3] integrate!(sol::GeometricSolution{Float64, Float64, NamedTuple{(:q, :p), Tuple{DataSeries{Float64, Vector{Float64}}, DataSeries{Float64, Vector{Float64}}}}, HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, NamedTuple{(:q, :p), Tuple{NullPeriodicity, NullPeriodicity}}}, int::GeometricIntegrator{EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}, HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, GeometricIntegrators.Integrators.CacheDict{HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}}, NoSolver, NoInitialGuess, SolutionStepPODE{Float64, Float64, Vector{Float64}, Vector{Float64}, Vector{Float64}, NamedTuple{(:t, :q, :p, :v, :f), Tuple{OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}}}, NamedTuple{(), Tuple{}}, NullParameters, 2}}, n₁::Int64, n₂::Int64)
   @ GeometricIntegrators.Integrators C:\Users\ndefi\.julia\packages\GeometricIntegrators\uE6qJ\src\integrators\integrator.jl:89
 [4] integrate!(sol::GeometricSolution{Float64, Float64, NamedTuple{(:q, :p), Tuple{DataSeries{Float64, Vector{Float64}}, DataSeries{Float64, Vector{Float64}}}}, HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, NamedTuple{(:q, :p), Tuple{NullPeriodicity, NullPeriodicity}}}, int::GeometricIntegrator{EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}, HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, GeometricIntegrators.Integrators.CacheDict{HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}}, NoSolver, NoInitialGuess, SolutionStepPODE{Float64, Float64, Vector{Float64}, Vector{Float64}, Vector{Float64}, NamedTuple{(:t, :q, :p, :v, :f), Tuple{OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}}}, NamedTuple{(), Tuple{}}, NullParameters, 2}})
   @ GeometricIntegrators.Integrators C:\Users\ndefi\.julia\packages\GeometricIntegrators\uE6qJ\src\integrators\integrator.jl:124
 [5] integrate(integrator::GeometricIntegrator{EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}, HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, GeometricIntegrators.Integrators.CacheDict{HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}}, NoSolver, NoInitialGuess, SolutionStepPODE{Float64, Float64, Vector{Float64}, Vector{Float64}, Vector{Float64}, NamedTuple{(:t, :q, :p, :v, :f), Tuple{OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}}}, NamedTuple{(), Tuple{}}, NullParameters, 2}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GeometricIntegrators.Integrators C:\Users\ndefi\.julia\packages\GeometricIntegrators\uE6qJ\src\integrators\integrator.jl:25
 [6] integrate(integrator::GeometricIntegrator{EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}, HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, GeometricIntegrators.Integrators.CacheDict{HODEProblem{Float64, Float64, Vector{Float64}, HODE{typeof(v), typeof(f1), typeof(H), NullInvariants, NullParameters, NullPeriodicity}, NamedTuple{(:v, :f, :h), Tuple{typeof(v), typeof(f1), typeof(H)}}, NamedTuple{(), Tuple{}}, NamedTuple{(:q, :p), Tuple{Vector{Float64}, Vector{Float64}}}, NullParameters}, EPRK{PartitionedTableau{Float64, 2, Int64, Int64, Int64, 4}}}, NoSolver, NoInitialGuess, SolutionStepPODE{Float64, Float64, Vector{Float64}, Vector{Float64}, Vector{Float64}, NamedTuple{(:t, :q, :p, :v, :f), Tuple{OffsetArrays.OffsetVector{Float64, Vector{Float64}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}, OffsetArrays.OffsetVector{Vector{Float64}, Vector{Vector{Float64}}}}}, NamedTuple{(), Tuple{}}, NullParameters, 2}})
   @ GeometricIntegrators.Integrators C:\Users\ndefi\.julia\packages\GeometricIntegrators\uE6qJ\src\integrators\integrator.jl:24
@michakraus
Copy link
Member

Many thanks for reporting this issue. This was actually an issue in the explicit partitioned Runge-Kutta integrator rather than the conversion. It's fixed and I added some more tests to catch issues like this.

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

No branches or pull requests

2 participants