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

fix bug in callbacks #2213

Merged
merged 2 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion pybamm/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def on_experiment_end(self, logs):
self.logger.notice("Finish experiment simulation, took {}".format(elapsed_time))

def on_experiment_error(self, logs):
pass
error = logs["error"]
pybamm.logger.error(f"Simulation error: {error}")

def on_experiment_infeasible(self, logs):
termination = logs["termination"]
Expand Down
3 changes: 2 additions & 1 deletion pybamm/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ def solve(
or step_solution.termination == "final time"
or "[experiment]" in step_solution.termination
):
callbacks.on_experiment_infeasible(logs)
feasible = False
break

Expand Down Expand Up @@ -897,6 +898,7 @@ def solve(
capacity_stop = None
logs["stopping conditions"]["capacity"] = capacity_stop

logs["elapsed time"] = timer.time()
callbacks.on_cycle_end(logs)

# Break if stopping conditions are met
Expand All @@ -913,7 +915,6 @@ def solve(

# Break if the experiment is infeasible (or errored)
if feasible is False:
callbacks.on_experiment_infeasible(logs)
break

if self.solution is not None and len(all_cycle_solutions) > 0:
Expand Down