Skip to content

Issue 2358 add temperature to experiment - #2518

Merged
valentinsulzer merged 15 commits into
developfrom
issue-2358-add-temperature-to-experiment
Feb 17, 2023
Merged

valentinsulzer merged 15 commits into
developfrom
issue-2358-add-temperature-to-experiment

Conversation

@Scottmar93

Copy link
Copy Markdown
Contributor

Description

Extension of the experiment class to allow control of the temperature.

Input form is now:

     "Charge at C/3 for 1 hour at 25oC (1 second period)"

Open to suggestions on where best to have the temperature.

Also added a global temperature for the experiment and made some minor modifications to the ECM to ensure it is compatible with the temperature control.

Getting a minor error in the docs when building which appears to also be in develop:
image

Fixes #2358

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.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov

codecov Bot commented Dec 4, 2022 •

Copy link
Copy Markdown

Codecov Report

Base: 99.69% // Head: 99.69% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (1fe0c9e) compared to base (3c30f50).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 1fe0c9e differs from pull request most recent head e8d78a8. Consider uploading reports for the commit e8d78a8 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2518   +/-   ##
========================================
  Coverage    99.69%   99.69%           
========================================
  Files          271      271           
  Lines        19586    19594    +8     
========================================
+ Hits         19526    19534    +8     
  Misses          60       60           
Impacted Files Coverage Δ
pybamm/input/parameters/ecm/example_set.py 100.00% <ø> (ø)
pybamm/experiments/experiment.py 100.00% <100.00%> (ø)
pybamm/parameters/ecm_parameters.py 100.00% <100.00%> (ø)
pybamm/simulation.py 100.00% <100.00%> (ø)
pybamm/parameters/bpx.py 92.85% <0.00%> (-0.05%) ⬇️
...m/models/full_battery_models/base_battery_model.py 99.78% <0.00%> (-0.01%) ⬇️
pybamm/__init__.py 100.00% <0.00%> (ø)
pybamm/solvers/base_solver.py 100.00% <0.00%> (ø)
pybamm/solvers/casadi_solver.py 99.66% <0.00%> (ø)
pybamm/solvers/idaklu_solver.py 99.06% <0.00%> (ø)
... and 56 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@valentinsulzer valentinsulzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Just some implementation comments

Comment thread pybamm/experiments/experiment.py Outdated
Comment thread pybamm/experiments/experiment.py Outdated
Comment thread pybamm/simulation.py
Comment on lines +373 to +382
if op_number == 0:
experiment_parameter_values.update(
{
"Initial temperature [K]": ambient_temperature,
}
)
else:
experiment_parameter_values.update(
{"Ambient temperature [K]": self._original_temperature}
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment explaining why this needs to be done like this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added:

            # If at the first operation, then the initial temperature
            # should be the ambient temperature.

I thought this was the most intuitive behavior but I guess we don't absolutely have to have the cell start at the ambient temperature. Can either always start at 25oC or take whatever is in the parameter_values? What's your thoughts?

@Scottmar93

Copy link
Copy Markdown
Contributor Author

Making the changes for this today. Apologies for the delays

@Scottmar93

Copy link
Copy Markdown
Contributor Author

I reformatted the checking for the temperature condition a bit so that we just match a regex. If we don't find the regex for temperature then we raise a pybamm.logger.warning and use the globally set temperature or the temperature from the parameter values.

Unfortunately, this does mean that cases typos in the temperature part of the string will only be raised as a warning but still pass through. I think this is the awkward side effect of not requiring the temperature to be in the string (for backwards compatibility).
Will raise an error in a few cases though such as if "oC" is in the string but no match has been found.

@valentinsulzer valentinsulzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good, I think this is the correct level of error-checking while still allowing back-compatibility. Can you update changelog?

@Scottmar93

Copy link
Copy Markdown
Contributor Author

Nice thanks, have updated

@valentinsulzer
valentinsulzer merged commit c9e2a45 into develop Feb 17, 2023
@valentinsulzer
valentinsulzer deleted the issue-2358-add-temperature-to-experiment branch February 17, 2023 18:44
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 this pull request may close these issues.

Add "temperature" argument to experiment

2 participants