pybop-team/PyBOP

Update BaseModel.simulate() for IDAKLU `output_variables`

Closed this issue · 0 comments

Feature description

Starting with PyBaMM v23.5 it is possible to pass predefined output variables to the IDAKLU solver. This feature eliminates the need to access the pybamm.solution class, as the solver returns the requested output variables directly. For PyBOP this would be the cost.signal object.

This should reduce computation time and memory requirements as we avoid the pybamm.solution class altogether.

Motivation

Reduce inference/optimisation time, simplify the codebase.

Possible implementation

Example taken from tests for the output_variable solver functionality:

Solve for a subset of variables and compare results

    output_variables = [
        "Voltage [V]",
        "Time [min]",
        "x [m]",
        "Negative particle flux [mol.m-2.s-1]",
        "Throughput capacity [A.h]",  # ExplicitTimeIntegral
    ]

    solver = pybamm.IDAKLUSolver(
        atol=1e-8, rtol=1e-8,
        options=options,
        output_variables=output_variables,
    )

    sol = solver.solve(
        model,
        t_eval,
        inputs=input_parameters,
        calculate_sensitivities=True,
    )

Additional context

No response