Skip to content

[Bug]: better error message when trying to use multiple input sets with experiments #5200

@martinjrobins

Description

@martinjrobins

PyBaMM Version

develop

Python Version

3.10

Describe the bug

The solve function on simulations and solvers can take a list of parameter sets and solve these in parallel. However, this is not support when a simulation is passed an experiment. If you try and do this, it fails with a non-informative error. This should be make more informative about this limitation

Steps to Reproduce

import pybamm
import matplotlib.pyplot as plt

import numpy as np

experiment = pybamm.Experiment(
    [("Charge at 1C for 1 hour or until 4.0 V")]
)

model = pybamm.lithium_ion.DFN()
params = pybamm.ParameterValues("Chen2020")
params["Positive particle diffusivity [m2.s-1]"] = "[input]"
params["Negative particle diffusivity [m2.s-1]"] = "[input]"
solver = pybamm.IDAKLUSolver(options={"num_threads": 4})

sim = pybamm.Simulation(model, solver=solver, experiment=experiment, parameter_values=params)

parameter_loop = [{"Positive particle diffusivity [m2.s-1]": 1e-15, "Negative particle diffusivity [m2.s-1]": 1e-15},
{"Positive particle diffusivity [m2.s-1]": 2e-15, "Negative particle diffusivity [m2.s-1]": 2e-15},
{"Positive particle diffusivity [m2.s-1]": 3e-15, "Negative particle diffusivity [m2.s-1]": 3e-15},
{"Positive particle diffusivity [m2.s-1]": 4e-15, "Negative particle diffusivity [m2.s-1]": 4e-15},
{"Positive particle diffusivity [m2.s-1]": 5e-15, "Negative particle diffusivity [m2.s-1]": 5e-15}]

solution = sim.solve(inputs=parameter_loop)

fails with

Relevant log output

Traceback (most recent call last):
  File "/home/mrobins/git/PyBaMM/test2.py", line 24, in <module>
    solution = sim.solve(inputs=parameter_loop)
  File "/home/mrobins/git/PyBaMM/src/pybamm/simulation.py", line 742, in solve
    inputs = {
TypeError: 'list' object is not a mapping

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions