-
-
Notifications
You must be signed in to change notification settings - Fork 574
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
Issue 2322 experiment steps #2960
Conversation
accept merge from @mbonkile
Accept Ruihehackathon changes by Jon
It was just getting a bit out of hand with the string parsing. I think it's reasonable to have basic instructions being a string and having to use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks! It would be good to have another reviewer's opinion before merging, at least about the API. Having slept on it, the approach on what is allowed as a string makes sense (in my mind: basic functionality can be passed as string, advanced functionality requires using the new classes).
In any case, we can always bring existing functionality into the string if we see a big demand.
EDIT: before merging please add line to CHANGELOG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer to use "instruction" or "step" instead of experiment with lower case "e" for the new steps of the Experiment. Or maybe even make adding steps a method of the Experiment class. Also some more documentation on the termination conditions that can be applied to both the experiment._Step and the Experiment and how they interact would be good. I don't think we should be allowing ambient temperature to get over-written at the step level either. That feels like a top level control condition and also a bit of a hack that should really just be part of an input variable
Hi all, I reckon that I am still in learning and adapting these discussions and the webpage of GitHub (there are so many buttons and information here), all the changes make sense to me as being part of the team to implement this new function. |
…issue-2322-experiment-steps # Conflicts: # examples/notebooks/models/lithium-plating.ipynb
@brosaplanella are you looking into the benchmark regression before merging? |
It seems it's only one benchmark failing which could be a random fail:
Rerunning the benchmarks now to see if that's the case. |
Now another one fails but it is a small regression, so happy to merge. I think @tinosulzer wanted to bring the period back in though... |
Description
Reformat the backend for specifying experiment steps.
The underlying (private) class for steps is called
_Step
. This class should never be called directly, instead the steps of an experiment can be specified via helper functions as follows:pybamm.experiment.string
should be used to specify a string with more options:period
argument replaces putting "(10 second period)" in the string (e.g. `period="10 minutes")temperature
argument replaces putting "at 25 oC" in the string (e.g. `temperature="25 oC")tags
argument replaces tagging a string with "[tag1]" (e.g.tags=["tag1"]
)For example, the string
"Discharge at 1C until 2.5V at 30oC (1 second period) [tag1]"
is nowpybamm.experiment.string("Discharge at 1C until 2.5V", period="1 second", temperature="30oC", tags="tag1")
. Period can be a string or a float (in which case it is in seconds). Temperature can be a string or a float (in which case it is in Kelvin). Tags can be a single string or a list of strings.If a string does not need any extra options, the string can be passed directly to
pybamm.Experiment
without using thepybamm.experiment.string
function, i.e. the following experiments are equivalentand
is equivalent to
"Discharge at 1A for 1 hour or until 2.5V"
. The period, temperature, and tags options are the same as forpybamm.experiment.string
.These methods can also be used for drive cycles:
The functionality
pybamm.Experiment(["Run US06 (W)"], drive_cycles={"US06": drive_cycle})
has been deprecatedFixes #2322 #2982
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run
(see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python run-tests.py --all
$ python run-tests.py --doctest
You can run unit and doctests together at once, using
$ python run-tests.py --quick
.Further checks: