Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow arguments to f and G functions #8

Open
sdx23 opened this issue Dec 11, 2016 · 5 comments
Open

allow arguments to f and G functions #8

sdx23 opened this issue Dec 11, 2016 · 5 comments

Comments

@sdx23
Copy link

sdx23 commented Dec 11, 2016

odeint has args=[] for this purpose. In case of sdeint we'd possibly need two separate parameters, argsf and argsG.

@mattja
Copy link
Owner

mattja commented Dec 13, 2016

Thanks, I think that is a useful suggestion, so that we can provide an interface as close to odeint as possible.
I'll implement this when I can get some time.
In the meantime you can get the same effect by passing a python closure in place of f or G.

@HuwLittle
Copy link

Hey there! Has any progress been made on this addition, would really appreciate it :)

@mattja
Copy link
Owner

mattja commented Dec 19, 2017

In the current version, it is easy to achieve the same goal by using a function closure, so it is not a very high priority.
A pull request adding this functionality would be welcome, of course.

@LorenzoBottaccioli
Copy link

@mattja can you provide an example using the function closure?

@mattja
Copy link
Owner

mattja commented Jul 2, 2019

import numpy as np
import sdeint

def close(func, *args):
    def newfunc(x, t):
        return func(x, t, *args)
    return newfunc

tspan = np.linspace(0.0, 5.0, 5001)
x0 = 0.1

def f(x, t, a, b):
    return -(a + x*b**2)*(1 - x**2)

def g(x, t, a, b):
    return b*(1 - x**2)

args = (1.0, 0.8)
result = sdeint.itoint(close(f, *args), close(g, *args), x0, tspan)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants