Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I3130-y-slice-bug #3313

Merged
merged 5 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

## Bug fixes

- Fixed a bug that occured in `check_ys_are_not_too_large` when trying to reference `y-slice` where the referenced variable was not a `pybamm.StateVector` ([#3313](https://github.com/pybamm-team/PyBaMM/pull/3313)
- Fixed a bug with `_Heaviside._evaluate_for_shape` which meant some expressions involving heaviside function and subtractions did not work ([#3306](https://github.com/pybamm-team/PyBaMM/pull/3306))
- The `OneDimensionalX` thermal model has been updated to account for edge/tab cooling and account for the current collector volumetric heat capacity. It now gives the correct behaviour compared with a lumped model with the correct total heat transfer coefficient and surface area for cooling. ([#3042](https://github.com/pybamm-team/PyBaMM/pull/3042))
- Fixed a bug where the "basic" lithium-ion models gave incorrect results when using nonlinear particle diffusivity ([#3207](https://github.com/pybamm-team/PyBaMM/pull/3207))
Expand Down
15 changes: 14 additions & 1 deletion pybamm/solvers/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,20 @@ def check_ys_are_not_too_large(self):
y = y[:, -1]
if np.any(y > pybamm.settings.max_y_value):
for var in [*model.rhs.keys(), *model.algebraic.keys()]:
y_var = y[model.variables[var.name].y_slices[0]]
var = model.variables[var.name]
# find the statevector corresponding to this variable
statevector = None
for node in var.pre_order():
if isinstance(node, pybamm.StateVector):
statevector = node

# there will always be a statevector, but just in case
if statevector is None: # pragma: no cover
raise RuntimeError(
"Cannot find statevector corresponding to variable {}"
.format(var.name)
)
y_var = y[statevector.y_slices[0]]
if np.any(y_var > pybamm.settings.max_y_value):
pybamm.logger.error(
f"Solution for '{var}' exceeds the maximum allowed value "
Expand Down
Loading