Sophisticated ODE systems in lean

I had a problem with the coincidence of the equation of the optical bubble, which is a first-order ODE system with complex values. I found that scipy can solve such a system, but their web page contains too little information, and I cannot understand it.

I have 8 connected first-order ODEs, and I have to generate a function like:

def derv(y):
    compute the time dervative of elements in y
    return answers as an array

then do complex_ode(derv)

My questions:

  • my y is not a list, but a matrix, how can I give a way out of the root that fits into complex_ode ()?
  • complex_ode() I need a Jacobian, I have no idea how to start building one and what type should it be?
  • Where should I put the initial conditions, as in a regular ode and linspace time?

this is a scipy complex_ode link: http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.complex_ode.html

- , .

+3
1

, . bloch - , , :-), .

http://massey.dur.ac.uk/jdp/code.html

, , complex_ode, , , , , scipy.integrate.ode :

 from scipy import eye
 from scipy.integrate import ode

 y0, t0 = [1.0j, 2.0], 0

 def f(t, y, arg1):
     return [1j*arg1*y[0] + y[1], -arg1*y[1]**2]
 def jac(t, y, arg1):
     return [[1j*arg1, 1], [0, -arg1*2*y[1]]]
 r = ode(f, jac).set_integrator('zvode', method='bdf', with_jacobian=True)
 r.set_initial_value(y0, t0).set_f_params(2.0).set_jac_params(2.0)
 t1 = 10
 dt = 1
 while r.successful() and r.t < t1:
     r.integrate(r.t+dt)
     print r.t, r.y

. , 8, 9 ODE, , , . , , ydot = f(t,y), def derv(), , derv(t,y). y , ! "" derv(t,y) :

Y = numpy.reshape(y,(num_rows,num_cols));

num_rows*num_cols = 8, ODE . . , , , :

out = numpy.reshape(Y,(8,1));

, , , . , , . , .

, , , , , . , .

+5

All Articles