1

I am trying to solve a differential equation using scipy.integrate.solve_ivp using the "rk45" method. However, directly after the first actual call to my system function f, the script crashes without any exception message or similar, it just stops. The same thing happens when I try to run it using the debugger as python3 -m pdb ./solve.py. I also tried using the trace module as described here. However, that gives me too much information and I don't really see where exactly the error appears. The error strictly appears directly after the system function is called, somewhere in the scipy module.

I currently have not constructed a minimal example to reproduce this, I might add that later. For now, I am wondering if there are further ways I could try to debug this problem. The error might occur somewhere outside of the actual python code.

When I try running it in Juypter, the same error message as shown in this question appears.

Here is the example:

import numpy
import scipy.integrate as integrate

N = 300

def f(t, x):
    return numpy.ravel(numpy.ones((2, N, N, N), dtype=complex))

ival = numpy.ravel(numpy.ones((2, N, N, N), dtype=complex))
integrate.solve_ivp(f, (0, 100), ival)
HerpDerpington
  • 3,751
  • 4
  • 27
  • 43
  • 2
    *"I currently have not constructed a minimal example to reproduce this, I might add that later."* Sooner is better. It will be easier for someone to help you if you provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Warren Weckesser Apr 18 '22 at 16:49
  • 2
    Have you tried one of the other solvers, such as [`scipy.integrate.odeint`](https://scipy.github.io/devdocs/reference/generated/scipy.integrate.odeint.html)? If you give `odeint` the argument `tfirst=True`, you can use the same functions that define the differential equations as used in `solve_ivp`. – Warren Weckesser Apr 18 '22 at 16:52
  • 1
    @WarrenWeckesser Found a very simple one. – HerpDerpington Apr 18 '22 at 18:59
  • 3
    Your state vector `x` has length 54000000, and each element is 16 bytes, so each vector requires almost 900 megabytes. The solver will have several of these in memory at any one time, so it will require a few gigabytes at least. How much memory do you have? What platform/OS are you using? (Some platforms don't handle "out of memory" conditions very nicely.) Do you run into problems if `N` is much smaller? – Warren Weckesser Apr 18 '22 at 20:12

0 Answers0