Skip to content

Commit

Permalink
Merge pull request #153 from himoto/test-sde
Browse files Browse the repository at this point in the history
Add test for SDE problem with `de.jit`
  • Loading branch information
ChrisRackauckas authored Nov 21, 2024
2 parents 40fe330 + 4e0d150 commit 5902fd5
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.03 * u[0]
du[1] = 0.03 * u[1]
du[2] = 0.03 * 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 5902fd5

Please sign in to comment.