SciML / diffeqpy

Solving differential equations in Python using DifferentialEquations.jl and the SciML Scientific Machine Learning organization
MIT License
508 stars 39 forks source link

Segfault when using sympy symbols as initial conditions. #129

Open LilithHafner opened 8 months ago

LilithHafner commented 8 months ago

This segfaults:

from diffeqpy import de
from sympy import Symbol

# Exponential decay
def f(u, p, t):
    return [-u[0] * p]

u0 = Symbol('u0') # or 1.0
p = Symbol('p') # or 1.0
t = (0.0, 1.0)

problem = de.ODEProblem(f, [u0], t, p)
solution = de.solve(problem)

Changing p and u0 to floats instead of symbolic variables fixes the problem:

u0 = 1.0 u0 = Symbol('u0')
p = 1.0 Correct answer Segfault
p = Symbol('p') Error Segfault

Versions


Python 3.11.6 (main, Oct  2 2023, 20:46:14) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
diffeqpy 2.2.0
sympy 1.12
DifferentialEquations 7.11.0
Julia Version 1.9.3
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores