patrick-kidger / patrick-kidger/diffrax

Could you give an example of interactively step through a implicit solver?

Open
#633 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature question
Dominant language
Python
Stars
2.1k
Forks
189
Avg merge
3d 18h
Merged PRs (30d)
1

Description

In this example, https://docs.kidger.site/diffrax/usage/manual-stepping/, how to replace the explicit solver with implicit ones? Here is my try, but got the following error:


import jax.numpy as jnp
import diffrax
from diffrax import ODETerm

vector_field = lambda t, y, args: -y
term = ODETerm(vector_field)
solver = diffrax.ImplicitEuler()

t0 = 0
dt0 = 0.05
t1 = 1
y0 = jnp.array(1.0)
args = None

tprev = t0
tnext = t0 + dt0
y = y0
state = solver.init(term, tprev, tnext, y0, args)

while tprev < t1:
    y, _, _, state, _ = solver.step(term, tprev, tnext, y, args, state, made_jump=False)
    print(f"At time {tnext} obtained value {y}")
    tprev = tnext
    tnext = min(tprev + dt0, t1)


The error message:


    raise RuntimeError("Type of `other` not understood.")
RuntimeError: Type of `other` not understood.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the manual-stepping documentation page and run the reported Python snippet using diffrax. Compare the explicit example with the ImplicitEuler init and step calls, then document a working interactive implicit-solver example whose execution no longer raises the reported RuntimeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.