Skip to content

Commit

Permalink
Add test for SDE problem with de.jit
Browse files Browse the repository at this point in the history
  • Loading branch information
himoto committed Nov 20, 2024
1 parent 40fe330 commit f86f920
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions diffeqpy/tests/test_sde.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,29 @@ def g(du,u,p,t):
p = [10.0,28.0,2.66]
prob = de.SDEProblem(numba_f, numba_g, u0, tspan, p)
sol = de.solve(prob)


def test_jit():

def f(du, u, p, t):
x, y, z = u
sigma, rho, beta = p
du[0] = sigma * (y - x)
du[1] = x * (rho - z) - y
du[2] = x * y - beta * z

def g(du, u, p, t):
du[0] = 0.3 * u[0]
du[1] = 0.3 * u[1]
du[2] = 0.3 * u[2]

u0 = [1.0, 0.0, 0.0]
tspan = (0.0, 100.0)
p = [10.0, 28.0, 2.66]
prob = de.jit(de.SDEProblem(f, g, u0, tspan, p))
sol = de.solve(prob)
assert sol.t[-1] == tspan[-1], f"Solver did not reach the final time. Last time: {sol.t[-1]}"
assert len(sol.u) > 0, "Solution is empty."
assert all(
abs(sol.u[i][j]) < float("inf") for j in range(len(u0)) for i in range(len(sol.t))
), "Solution contains non-finite values."

0 comments on commit f86f920

Please sign in to comment.