[Bug]: BatchStudy.solve silently ignores t_interp

Open Beginner friendly
#5,978 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@shresthgoel77-png is already working on this.

Since Oct 25, 2026.

  • #5979 by @shresthgoel77-png — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, testing

Research direction

Start in packages/pybamm/src/pybamm/batch_study.py at the BatchStudy.solve method and inspect the inner Simulation.solve call around lines 161–169. Compare its arguments with the direct call in the reproduction, then add regression coverage for both permutation modes. Done when batch solution times match the requested interpolation grid; the issue also requests a changelog entry.

Written by the indexing model from the issue text.

Description

bug
PyBaMM Version

0.0.1.dev16359+g5651a97ec — source checkout at commit 5651a97ecc5dfd1a2de8c2a1af13368263ee12ed

Python Version

Python 3.14.4 on Ubuntu/WSL2; pybammsolvers 0.11.1, NumPy 2.5.4, SciPy 1.18.1.

Describe the bug

BatchStudy.solve accepts t_interp, but does not forward it to the underlying Simulation.solve call. With the default IDAKLU solver, the resulting batch solutions therefore use adaptive solver output times instead of the requested interpolation grid.

An equivalent direct Simulation.solve call honours the requested grid. This prevents callers from obtaining batch results on a shared output grid for comparisons or data export.

Expected behaviour: In the example below, the batch solution's time array should match [0.0, 0.25, 0.5, 1.0], as the direct simulation does.

Actual behaviour: The batch solution returns a different time array. The behaviour was reproduced with both permutations=False and permutations=True.

In the inspected revision, t_interp is accepted in the method signature but omitted from the inner Simulation.solve call.

The adaptive point count shown below is specific to the reproduction environment; the issue is the ignored interpolation grid.

I would be happy to contribute a focused fix that forwards t_interp, with regression tests for both permutation modes and a changelog entry. I have prepared and tested a candidate patch locally, but have not opened a pull request. If appropriate, could a maintainer assign this issue to me?

Steps to Reproduce

Run the following against the unmodified source revision listed above. The example uses the default IDAKLU solver.

import numpy as np
import pybamm

state = pybamm.Variable("State")
model = pybamm.BaseModel()
model.rhs = {state: -state}
model.initial_conditions = {state: 1}
model.variables = {"State": state}

times = np.array([0.0, 0.25, 0.5, 1.0])

direct = pybamm.Simulation(model).solve(
    [0, 1], t_interp=times, calc_esoh=False
)

study = pybamm.BatchStudy({"decay": model})
study.solve([0, 1], t_interp=times, calc_esoh=False)
actual = study.sims[0].solution.t

print("Requested:", times)
print("Direct Simulation:", direct.t)
print("BatchStudy point count:", actual.size)
print("BatchStudy matches requested grid:", np.array_equal(actual, times))

Setting permutations=True in the BatchStudy constructor reproduces the same grid mismatch.

Relevant log output
Requested: [0.   0.25 0.5  1.  ]
Direct Simulation: [0.   0.25 0.5  1.  ]
BatchStudy point count: 27
BatchStudy matches requested grid: False
Dominant language
Python
Stars
1.7k
Forks
808
Avg merge
4d 4h
Merged PRs (30d)
55

Getting set up

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.

More from pybamm-team/PyBaMM

All issues in pybamm-team/PyBaMM

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.