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

Added support for time series temperature in an experiment step #4855

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

Rishab87
Copy link
Contributor

Description

Added support for time series temperature in an experiment step, now it can be passed something like this:

    experiment = pybamm.Experiment(
        [pybamm.step.voltage(voltage_profile, temperature=temperature_profile)]
    )

Fixes #4200

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)

Important checks:

Please confirm the following before marking the PR as ready for review:

  • No style issues: nox -s pre-commit
  • All tests pass: nox -s tests
  • The documentation builds: nox -s doctests
  • Code is commented for hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@Rishab87 Rishab87 requested a review from a team as a code owner February 17, 2025 12:18
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.70%. Comparing base (0d5af5c) to head (cf39627).
Report is 12 commits behind head on develop.

Files with missing lines Patch % Lines
src/pybamm/experiment/step/base_step.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4855      +/-   ##
===========================================
- Coverage    98.70%   98.70%   -0.01%     
===========================================
  Files          304      304              
  Lines        23432    23459      +27     
===========================================
+ Hits         23129    23155      +26     
- Misses         303      304       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 550 to 560
if isinstance(temperature_and_units, np.ndarray):
if temperature_and_units.ndim == 2 and temperature_and_units.shape[1] == 2:
# Assume first column is time (s) and second column is temperature (K)
times = temperature_and_units[:, 0]
temps = temperature_and_units[:, 1]
# Create an interpolant function parameter that depends on time
return pybamm.Interpolant(times, temps, pybamm.t, interpolator="linear")
else:
raise ValueError(
"Temperature time-series must be a 2D array with two columns (time, temperature)."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you write a test for this. Sometimes it is easiest to cover error handling code by extracting a smaller function and using that in the tests. You can make the if-else block a helper function, then covering it in tests should be easy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah sure, I'll add a test for it

Copy link
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 the tests

@Rishab87 Rishab87 requested a review from kratman February 18, 2025 15:17
@Rishab87
Copy link
Contributor Author

Rishab87 commented Mar 1, 2025

Can I get a review on this?

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.

Applying arbitrary temperature and voltage profiles in an experiment step
3 participants