Comments (14)
It seems, that some of the solvers in "symplectic_perform_step.jl" silently assume, that f.f2(p, q) == p
for the very first calculation in perform_step!
(for example lines 1133 and 1275). The corresponding initialize!
functions evaluate f.f2
and leave it in a variable, which is not used by perform_step!
. That is the case for KahanLi8
and SofSpa10
, and also the constant variants, but is correct for SymplecticEuler
. It will be necessary to check and fix each individual algorithm.
from diffeqphysics.jl.
Are the inputs flipped?
from diffeqphysics.jl.
I think no, just trying with flipped (p, q)
in the definition of H gave nothing reasonable:
julia> H(q, p, param) = p^2/20
H (generic function with 1 method)
julia> prob = HamiltonianProblem(H, p0, q0, (0., 1.))
ODEProblem with uType ArrayPartition{Float64,Tuple{Float64,Float64}} and tType Float64. In-place: false
timespan: (0.0, 1.0)
u0: 1.00.0
julia> sol = solve(prob, dt=0.001)
retcode: Success
Interpolation: specialized 6th order interpolation
t: 7-element Array{Float64,1}:
0.0
0.001
0.011
0.07787167758977546
0.26173425803838424
0.5841996582033573
1.0
u: 7-element Array{ArrayPartition{Float64,Tuple{Float64,Float64}},1}:
(1.0, 0.0)
(0.9999999500000004, 0.0009999999833333335)
(0.9999939500061004, 0.010999977816680087)
(0.9996968154128554, 0.07786380759988994)
(0.9965767138414221, 0.2614355260679268)
(0.9829840154332482, 0.5808823065288845)
(0.9504152802553116, 0.9834164685913813)
julia> sol(1.0)
(0.9504152802553114, 0.9834164685913813)
julia> sol = solve(prob, SofSpa10(), dt=0.001);
julia> sol(1.0)
(0.9980287849980085, 0.03937199652442939)
from diffeqphysics.jl.
Try another integrator? Maybe there's an issue there. Is prob.f what you'd expect?
from diffeqphysics.jl.
Is prob.f what you'd expect?
That looks fine.
julia> prob.f
(::DynamicalODEFunction{false,ODEFunction{false,DiffEqPhysics.var"#3#7"{typeof(H),Float64},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},ODEFunction{false,DiffEqPhysics.var"#5#9"{typeof(H),Float64},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}) (generic function with 2 methods)
julia> prob.f.f1(p0, q0, nothing, 0.0)
0.0
julia> prob.f.f2(p0, q0, nothing, 0.0)
0.1
from diffeqphysics.jl.
Try another integrator?
That one worked as expected:
julia> sol = solve(prob, Tsit5(), dt=0.001);
julia> sol(1.0)
(1.0, 0.09999999999999959)
from diffeqphysics.jl.
Another one again fails:
julia> sol = solve(prob, KahanLi6(), dt=0.001);
julia> sol(1.0)
(1.0, 0.27647264980326564)
from diffeqphysics.jl.
Are you sure the definition of f
isn't flipped? #58 might've been wrong.
from diffeqphysics.jl.
What do you mean? I will x-check #58 - there was no intention to change any logic there.
from diffeqphysics.jl.
No changes except (v,x,p) was renamed to (p,q,param) consistently.
I will repeat my experiments with the older release...
from diffeqphysics.jl.
I use now the pre#58 releases
julia> VERSION
v"1.5.3"
(tmp) pkg> st
Status `/tmp/Project.toml`
[055956cb] DiffEqPhysics v3.7.0
[0c46a032] DifferentialEquations v6.16.0
and there is no difference in the results.
from diffeqphysics.jl.
When I go back more than a year, using the default algo now produces a correct result, but the other algorithms produce exactly the same false results (except of Tsit5, which remains correct).
julia> VERSION
v"1.3.1"
(tmp) pkg> st
Status `/tmp/Project.toml`
[055956cb] DiffEqPhysics v3.2.0
[0c46a032] DifferentialEquations v6.0.0
from diffeqphysics.jl.
I think somewhere along the lines the definition flipped the order of the equations and it's now incorrect in this library. Somehow our tests didn't catch that...
from diffeqphysics.jl.
I will take me the time to investigate and keep you informed.
from diffeqphysics.jl.
Related Issues (20)
- Numerical solution for Euler–Lagrange equation
- Numerical solution for Hamilton's equations
- ArrayPartition n-body system
- having problems adding HOT 10
- Cache the GradientConfig and JacobianConfig for the HamiltonianProblems
- Thread safety of HamiltonianProblem
- package dependency errors? HOT 2
- Handling animations of n-body problems via iterators HOT 1
- Comments on N-body problem HOT 2
- GIFs shouldn't be placed in repository
- New package for N-body simulations HOT 2
- Register HOT 21
- Confusing Notation HOT 1
- TagBot trigger issue HOT 6
- pendulum example is broken HOT 1
- Harmonic oscillator mass ignored HOT 1
- Solving non-autonomous `HamiltonianProblem` no longer works HOT 1
- Euler-Legrange Equations
- Lennard-Jones Fluids
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diffeqphysics.jl.