You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a model with the IDAKLU solver and some output_variables and the solution contains INTERPOLANT_EXTRAPOLATION events, pybamm complains about y_slice vectors being too short.
import pybamm
import numpy as np
# Define inputs
inputs = {
"Current function [A]": 0.222,
"Separator porosity": 0.3,
}
# Set-up the model
options = {"cell geometry": "arbitrary", "thermal": "lumped"}
model = pybamm.lithium_ion.DFN(options=options)
geometry = model.default_geometry
# param = model.default_parameter_values
param = pybamm.ParameterValues.create_from_bpx(r"lfp_18650_cell_BPX.json")
param.update(inputs)
var = pybamm.standard_spatial_vars
var_pts = {var.x_n: 20, var.x_s: 20, var.x_p: 20, var.r_n: 10, var.r_p: 10}
# Use a short time-vector for this example
t_eval = np.linspace(0, 360, 10)
# Include the variable of interest in output_variables
output_variables = [
"Voltage [V]",
"Current [A]",
"Time [min]",
"X-averaged cell temperature [C]", # want to retrieve this and print the output
]
# Create the IDAKLU Solver object
idaklu_solver = pybamm.IDAKLUSolver(
rtol=1e-6, atol=1e-6, output_variables=output_variables
)
sim = pybamm.Simulation(
model,
parameter_values=param,
geometry=geometry,
var_pts=var_pts,
solver=idaklu_solver,
output_variables=output_variables,
)
sol = sim.solve(
t_eval=t_eval,
calculate_sensitivities=True,
)
Relevant log output
File "/Users/pipliggins/Documents/repos/pybamm-local/issue_test_copy.py", line 47, in<module>
sol = sim.solve(
^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/simulation.py", line 534, in solve
self._solution = solver.solve(
^^^^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/solvers/base_solver.py", line 957, in solve
self.check_extrapolation(solution, model.events)
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/solvers/base_solver.py", line 1497, in check_extrapolation
and event.expression.evaluate(t, y, inputs=inputs) < self.extrap_tol
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/expression_tree/functions.py", line 130, in evaluate
evaluated_children = [
^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/expression_tree/functions.py", line 131, in<listcomp>
child.evaluate(t, y, y_dot, inputs) forchildin self.children
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/expression_tree/binary_operators.py", line 160, in evaluate
left = self.left.evaluate(t, y, y_dot, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/expression_tree/binary_operators.py", line 160, in evaluate
left = self.left.evaluate(t, y, y_dot, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/expression_tree/binary_operators.py", line 161, in evaluate
right = self.right.evaluate(t, y, y_dot, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/expression_tree/symbol.py", line 817, in evaluate
return self._base_evaluate(t, y, y_dot, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pipliggins/Documents/repos/pybamm-local/src/pybamm/expression_tree/state_vector.py", line 292, in _base_evaluate
raise ValueError(
ValueError: y is too short, so value with slice is smaller than expected
The text was updated successfully, but these errors were encountered:
PyBaMM Version
develop
Python Version
3.11.6
Describe the bug
When running a model with the IDAKLU solver and some output_variables and the solution contains INTERPOLANT_EXTRAPOLATION events, pybamm complains about y_slice vectors being too short.
The code to reproduce is taken from #4414 .
Steps to Reproduce
Relevant log output
The text was updated successfully, but these errors were encountered: