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

Allow custom experiment steps #3530

Closed
valentinsulzer opened this issue Nov 16, 2023 · 2 comments · Fixed by #3835
Closed

Allow custom experiment steps #3530

valentinsulzer opened this issue Nov 16, 2023 · 2 comments · Fixed by #3835

Comments

@valentinsulzer
Copy link
Member

The logic for specifying how experiment steps work is currently in the Simulation class. We should move this to the Step classes, so that users can specify any custom behavior they want for which variable controls the step, and which variable(s) are used in the termination. This will have the added benefit of reducing some of the complexity of the simulation class.

This involves replacing any if statement that checks op.type with a call to a function in the step class, e.g. https://github.com/pybamm-team/PyBaMM/blob/develop/pybamm/simulation.py#L222

@valentinsulzer
Copy link
Member Author

Adding custom events should be really easy and could be done first separately, we just need to implement a Step.events() function that returns the appropriate event(s)

PyBaMM/pybamm/simulation.py

Lines 279 to 284 in 7c15368

new_model.events.append(
pybamm.Event(
"Current cut-off [A] [experiment]",
abs(new_model.variables["Current [A]"]) - term["value"],
)
)

We could allow the termination argument of Step to take in this function directly

@rtimms rtimms mentioned this issue Nov 24, 2023
8 tasks
valentinsulzer added a commit that referenced this issue Dec 6, 2023
valentinsulzer added a commit that referenced this issue Dec 6, 2023
@valentinsulzer
Copy link
Member Author

For the custom steps, there will be two separate cases:

  1. Current is specified explicitly, either as a constant or as a function of other variables, user supplies the explicit expression
  2. Current is an algebraic variable, user supplies the algebraic expression for the current variable

Current and C-rate falls into 1, everything else falls into 2.

We will need two different CustomStep classes (e.g. CustomStepExplicit, CustomStepAlgebraic`) with examples for each one.

valentinsulzer added a commit that referenced this issue Mar 1, 2024
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this issue Aug 12, 2024
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this issue Aug 12, 2024
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this issue Aug 12, 2024
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this issue Aug 12, 2024
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this issue Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant