Hi all, can I use any of scipy.integrate.ode/odeint etc. for complex systems? How? Here is what I'm doing, but I only get r.y real, instead of complex (and the result is different from Matlab). ---------------------------------------- import numpy import scipy.integrate.ode def f(t, y, betaA, betaB, CAB): M = numpy.array([[1j * betaA, CAB], [-CAB, 1j * betaB]]) return numpy.dot(M, y) betaA = 1. betaB = 1. CAB = 1. t0 = 0. t1 = 1. dt = .01 y0 = numpy.array([1, 0]).astype(complex) r = scipy.integrate.ode(f).set_integrator('vode').set_initial_value(y0, t0).set_f_params(betaA, betaB, CAB) while r.successful() and r.t < t1: r.integrate(r.t + dt) print r.t, r.y ---------------------------------------- Thank you in advance, Lorenzo
Le vendredi 16 novembre 2007 à 15:53 +0100, lorenzo bolla a écrit :
Hi all, can I use any of scipy.integrate.ode/odeint etc. for complex systems? How?
You may need to separate real and imaginary parts of your complex unknowns : you need to transform y(t)=[y0(t), y1(t)] with y0 and y1 complex signals into: y(t)=[real(y0(t)), imag(y0(t)), real (y1(t)), imag(y1(t))] and modify your matrix M as well. Can anyone confirm? -- Fabricio
On Fri, 16 Nov 2007 16:19:08 +0100 Fabrice Silva <Fabrice.Silva@crans.org> wrote:
Le vendredi 16 novembre 2007 à 15:53 +0100, lorenzo bolla a écrit :
Hi all, can I use any of scipy.integrate.ode/odeint etc. for complex systems? How?
You may need to separate real and imaginary parts of your complex unknowns : you need to transform y(t)=[y0(t), y1(t)] with y0 and y1 complex signals into: y(t)=[real(y0(t)), imag(y0(t)), real (y1(t)), imag(y1(t))]
and modify your matrix M as well.
Can anyone confirm? -- Fabricio
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
AFAIK, you can also apply the patch which is available at http://projects.scipy.org/scipy/scipy/ticket/334 So you can integrate complex ODE's directly without doubling the size. Please let me know how it works for you. Nils
Nils Wagner wrote:
AFAIK, you can also apply the patch which is available at
http://projects.scipy.org/scipy/scipy/ticket/334
So you can integrate complex ODE's directly without doubling the size. Please let me know how it works for you.
Please let us all know. :-) DG
Nils
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
I quickly tried to compile scipy with the patch, but it failed (on cygwin). I had no time to investigate the problem further, but I'll let you know as soon as possible more details. L. PS: for now, I solved the problem by doubling the size of the system as Fabrice pointed out. On Nov 16, 2007 6:43 PM, David.Goldsmith <David.L.Goldsmith@noaa.gov> wrote:
Nils Wagner wrote:
AFAIK, you can also apply the patch which is available at
http://projects.scipy.org/scipy/scipy/ticket/334
So you can integrate complex ODE's directly without doubling the size. Please let me know how it works for you.
Please let us all know. :-)
DG
Nils
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
Fri, 16 Nov 2007 20:08:22 +0100, lorenzo bolla wrote:
I quickly tried to compile scipy with the patch, but it failed (on cygwin). I had no time to investigate the problem further, but I'll let you know as soon as possible more details. L.
This may be a cygwin-related issue, I'd appreciate more information. The patches compile & test fine for me on Ubuntu atop Scipy r3546. (Except that the zvode-test.patch needs a rediff.) -- Pauli Virtanen
Fri, 16 Nov 2007 20:41:14 +0000, Pauli Virtanen wrote:
Fri, 16 Nov 2007 20:08:22 +0100, lorenzo bolla wrote:
I quickly tried to compile scipy with the patch, but it failed (on cygwin). I had no time to investigate the problem further, but I'll let you know as soon as possible more details. L.
This may be a cygwin-related issue,
Ok, it seems that someone else is also having problems on Cygwin (see the post titled "Problems compiling Scipy with Cygwin"): the VODE module even without patches fails to compile. Did you check whether you are compile an unpatched Scipy? -- Pauli Virtanen
I managed to compile scipy with the zvode.patch. Just one observation: doing $> patch < zvode.patch in the scipy/scipy/integrate directory is not enough: you also need to move zvode.f in odepack/ directory and the others *.f in linpack_lite/ directory. That is what I missed last time. Thank you again, Lorenzo. On 11/19/07, Pauli Virtanen <pav@iki.fi> wrote:
Fri, 16 Nov 2007 20:41:14 +0000, Pauli Virtanen wrote:
Fri, 16 Nov 2007 20:08:22 +0100, lorenzo bolla wrote:
I quickly tried to compile scipy with the patch, but it failed (on cygwin). I had no time to investigate the problem further, but I'll let you know as soon as possible more details. L.
This may be a cygwin-related issue,
Ok, it seems that someone else is also having problems on Cygwin (see the post titled "Problems compiling Scipy with Cygwin"): the VODE module even without patches fails to compile. Did you check whether you are compile an unpatched Scipy?
-- Pauli Virtanen
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
participants (5)
-
David.Goldsmith
-
Fabrice Silva
-
lorenzo bolla
-
Nils Wagner
-
Pauli Virtanen