GithubHelp home page GithubHelp logo

Comments (4)

Datseris avatar Datseris commented on June 1, 2024 1

Yeap okay, I will do that after I learn how all these new stuff works.

I will also make a method
HamiltonianProblem(dHdq, dHdq, tspan) in case the user can do the differentiation by themselves. I know its is identical to the ODEProblem but having the Hamiltonian name will be not only nice but intuitive as well.

from diffeqphysics.jl.

ChrisRackauckas avatar ChrisRackauckas commented on June 1, 2024

Some more details. Hamiltonians can be written as H(p,q). This then gives equations of motion

dp/dt = - dH/dq
dq/dt = dH/dp

Those equations of motion define a PartitionedODEProblem, where the partition has a set of ODEs for p and a set of ODEs for q. OrdinaryDiffEq.jl can natively handle this kind of PartitionedODEProblem and use things like Verlets, or it can (soon) transform it into a standard ODE for all of the other algorithms. So the actual solving can be handled by that.

What needs to be done is that the equations of motion need to be generated using differentiation tools. I.e., use something like ForwardDiff to define the equations of motion using a user defined H(p,q) function (for vectors p and q).

from diffeqphysics.jl.

Datseris avatar Datseris commented on June 1, 2024

I would like to try and solve this issue.
How do you envision the interface?
Hamiltonian(p,q) -> PartitionedODEProblem etc?

I have had some experience with ForwardDiff for the DynamicalSystems package, so probably I can handle this... (don't be so sure though)

from diffeqphysics.jl.

ChrisRackauckas avatar ChrisRackauckas commented on June 1, 2024

How do you envision the interface?
ODEHamiltonian(p,q) -> PartitionedODEProblem etc?

Yes.

HamiltonianProblem(H,q0,p0,tspan)

Essentially what it will do is use ForwardDiff to make a function for dHdq and a function for dHdp, and build the ODEProblem((dHdq,dHdp),(q0,p0),tspan). This output can then be directly solved by the symplectic solvers.

So the only "hard part" is the differentiation, which should just be differentiating a closure ForwardDiff.derivative!((p)->H(p,q),...). And making tests of course. It actually should be pretty easy, but will be a nice convenience.

from diffeqphysics.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.