davidrpugh / pyCollocation

Python package for solving initial value problems (IVP) and two-point boundary value problems (2PBVP).
MIT License
17 stars 8 forks source link

Example Suggestions: Heat quation, Lorenz equations, Lotka-Volterra equations and Sturm-Liouville Equation #46

Open fusion809 opened 8 years ago

fusion809 commented 8 years ago

Hi,

I'm quite the fan of this Python module, and I wanted to suggest the following examples:

Would be best to solve it with the original parameters: sigma, beta and rho. x[0] = y[0] = z[0] = 1 on t ∈ [0,100].

where lambda is the eigenvalue of the equation. This problem is integrated over the range x ∈ [0,∞], although a range of [0,100] is good enough to get the first 10 or more eigenvalues. Plus it has the boundary conditions y(0) = y(∞) = 0. This equation has the exact solution:

where Ai is the Airy Ai function. The eigenvalues are the zeros of the Airy Ai function, with their negative sign replaced with a positive sign.

davidrpugh commented 8 years ago

@fusion809 Thanks! Always good to hear from a user. I will look into adding these as examples. Please fell free to submit a PR for you favorite examples and I will certainly include it!

fusion809 commented 8 years ago

I don't think this module can presently be used to solve Sturm-Liouville problems, can it?

davidrpugh commented 8 years ago

I do know. I have never solved a Sturm-Liouville problem before. Can you explain what is required?

fusion809 commented 8 years ago

Well, I must admit part of the reason I want more examples is because I am so unfamiliar with your present examples that I can't gather how to use pyCollocation from them. So I was hoping examples I'm more familiar with might help me follow it, although it does like quite a helpful tool. Essentially what you do is you express the problem in terms of matrices, e.g., say the H matrix represents LHS of the above SL problem then you can express the problem as the matrix equation:

Hy = lambda y

then it becomes a eigenvalue/eigenvector problem from linear algebra, with the solution contained in the y vector being the eigenvector and lambda being the eigenvalues. In terms of what you'd use, Python module-wise, it'd probably be linalg.eig.

davidrpugh commented 8 years ago

PyCollocation was designed to solve non-linear boundary problems commonly encountered in economics. Which might be why the examples seem so unfamiliar. Currently you need to be able to express your problem as y = f(t, y)` along with some boundary conditions. Is the SL problem always linear?

fusion809 commented 8 years ago

Yep they are always linear, their most generalized form is:

Most notable one is the Schrodinger equation. Although nonlinear ODE eigenvalue problems do exist.

davidrpugh commented 8 years ago

OK. I have never tried to solve a linear problem using pyCollocation. I am pretty busy at the moment, but when I get some free time I will see if it is possible. I am pretty sure it is possible...