SciML / diffeqpy

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

Misunderstading of default Wiener process #102

Closed acubed3 closed 11 months ago

acubed3 commented 2 years ago

I would like to solve a system of coupled non-linear SDEs, which looks like

du[i] = f(u[i], t) dt + g(u[i], t) * dW,

where W is the Wiener process with zero mean and volatility sigma=2*D.

As I understand, diffeqpy uses the Wiener process with zero mean and unit volatility as default. To obtain the desired Wiener process, I write the following line:

D = 1.0
W = de.WienerProcess(0,2*D)

Next, I try to test my guess by runing the minimal working example from documentation with minor change:

from diffeqpy import de

D = 1.0
W = de.WienerProcess(0,2*D)

def f(u,p,t):
    return 1.01*u

def g(u,p,t):
    return 0.87*u

u0 = 0.5
tspan = (0.0,1.0)
prob = de.SDEProblem(f,g,u0,tspan, noise=W)
sol = de.solve(prob)

This code snippet raises RuntimeError:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [6], in <module>
      8 tspan = (0.0,1.0)
      9 prob = de.SDEProblem(f,g,u0,tspan, noise=W)
---> 10 sol = de.solve(prob)

RuntimeError: <PyCall.jlwrap (in a Julia function called from Python)
JULIA: type Array has no field dW

In addition, I provide the text-file with stacktrace.

ChrisRackauckas commented 11 months ago
from diffeqpy import de

D = 1.0
W = de.WienerProcess(0.0,2*D)

def f(u,p,t):
    return 1.01*u

def g(u,p,t):
    return 0.87*u

u0 = 0.5
tspan = (0.0,1.0)
prob = de.SDEProblem(f,g,u0,tspan, noise=W)
sol = de.solve(prob)

works fine on the v2.0 version.

acubed3 commented 11 months ago

@ChrisRackauckas , thanks so much. After one year, I will happy to see this