1

I have a list of complex differential equations that I need to step through "in parallel" (integrating one time step for equation 1, then one time step in equation 2, then another on in equation 1, etc): the solver needs to be "re-entrant". I've been trying to use scipy.integrate.ode. My problem is exactly the same as solving two uncoupled ODEs within a loop using python and scipy.integrate.ode, except with complex differential equations. Thus I can't use the 'dopri5', which is for real-valued ODEs only.

Is there any complex re-entrant ODE solver available in Python (preferably with an interface that isn't too radically different from scipy.integrate.ode)?

Using multiprocessing to have the solver in multiple processes (as proposed here) isn't really an option, because the overhead of sending back the states through IPC would be prohibitive. Another comment on the same question mentions that the sundials-library that underlies the scipy solver actually is re-entrant, but presumably Scipy hasn't caught up. Are there any other Python wrappers for sundials? I can't find any information whether the mentioned scikits-odes package is re-entrant.

I also tried simply replacing scipy.integrate.ode with scipy.integrate.complex_ode, but that crashes with a TypeError: can't multiply sequence by non-int of type 'complex' that I haven't investigated any further.

My actual code where this entire problem comes up is here: https://github.com/qucontrol/krotov/blob/fe7c7240b6b7090b176b96f7d6d2f6b96bc39816/src/krotov/propagators.py#L156

Michael Goerz
  • 4,300
  • 3
  • 23
  • 31
  • You can always wrap your complex computation by composing the complex input from the first and last half of the real input vector and separating the real and complex parts of the derivative as parts of the result vector. – Lutz Lehmann Feb 24 '19 at 09:29
  • Are you sure that you really need to swap back and forth between the different equations and cannot just use one bigger equation comprising the two? – Wrzlprmft Feb 24 '19 at 10:15
  • @LutzL, that's certainly an option, but only as a last resort. I'll have to see how much overhead that'll create. – Michael Goerz Feb 26 '19 at 16:55
  • @Wrzlprmft, combining the different equations is mathematically possible, but doesn't fit into the larger API at all, unfortunately. – Michael Goerz Feb 26 '19 at 16:55

0 Answers0