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

probsolve_ivp for ODE that is a function of t #850

Open
qing42102 opened this issue Jan 2, 2024 · 0 comments
Open

probsolve_ivp for ODE that is a function of t #850

qing42102 opened this issue Jan 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@qing42102
Copy link

qing42102 commented Jan 2, 2024

Describe the bug
If the ODE is a function of t, then probsolve_ivp gives the error TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'. Upon further investigation, it turns out that t is passed in as None to the ODE function sometimes. Thus, this will give an error when performing any numerical operator on t. Is there something that I need to change in the ODE function to make it work when it's a function of t? I can post the entire traceback if needed.

To Reproduce

def stiff_ode(t, y):
    lambda_val = 2
    print(t)
    return lambda_val * y + np.exp(-t)

# Initial and final time value
t0 = 0.0
tmax = 1.0

# Initial condition
y0 = np.array([1])

sol = probsolve_ivp(stiff_ode, t0, tmax, y0, algo_order=2, adaptive=True, atol=1e-2, rtol=1e-2)

Expected behavior
There shouldn't be an error and t shouldn't be passed in as None to the ODE function.

System:

  • Conda environment
  • Python 3.10
  • ProbNum 0.1.25
  • NumPy 1.25
@qing42102 qing42102 added the bug Something isn't working label Jan 2, 2024
@qing42102 qing42102 changed the title probsolve_ivp for ODE that is a function of t probsolve_ivp for ODE that is a function of t Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant