[SciPy-User] Troubles with odeint or ode
Tue Nov 3 13:04:57 CST 2009
I'm trying to solve an ODE system that models a parametric oscillator with
complex amplitudes at two freqencies.
I'm new to python. This problem is simply solved in matlab using ode45.
If I try to use odeint I cannot set parameters like tolerances or max step.
The result is constant-valued solutions.
Trying with ode class and ZVODE integrator, I have that total intensity is not
conserved. I have weird quasi-periodic oscillations.
I do know that my equations have excess degrees of freedom and I know from
symmetries what the integrals of motion are, but in Matlab this works pretty well.
Here is the code with odeint
import numpy as N
import scipy as S
import pylab as P
A1 = Y
A2 = Y
A1d = 1j*A2*N.conj(A1)
A2d = 1j*(A1**2/2.0 + dk*A2)
return [A1d, A2d]
nplot = 10000
zmax = 10.0
zstep = zmax/nplot
dk = 0.5 # normalised detuning/dispersion
phi0 = 0.0*N.pi # initial dephasing
eta0 = 0.3 # initial pump intensity
# initial values
u20 = N.sqrt(eta0)*N.exp(1j*phi0)
u10 = N.sqrt(2*(1-eta0))
# are conserved quantities constant?
Ptot = N.abs(Y[:,0])**2/2+ N.abs(Y[:,1])**2
# then Hamiltonian...
p1 = P.plot(N.arange(0,zmax+zstep-0.0001,zstep),N.abs(Y[:,0]))
p2 = P.plot(N.arange(0,zmax+zstep-0.0001,zstep),N.abs(Y[:,1]))
Thank you very much for your help.
More information about the SciPy-User