Skip to content

Conversation

@pipliggins
Copy link
Contributor

@pipliggins pipliggins commented Sep 13, 2025

Description

Input parameters should not be able to be used as initial conditions (see #1261), but a bug was present where if more than one input parameter was provided but not all were used as initial conditions, the error warning could be bypassed.

Allows input parameters used as initial conditions to be included within lists of inputs to the solver by converting model.y0 to model.y0_list, and calculating one initial state per input parameter set.

This rolls back a lot of the changes made by #4981 as the functionality is added to all the solvers; the initial_conditions argument added for IDAKLU has been removed in favour of allowing all inputs to be included within inputs.

Fixes #5154
Fixes #5131

@codecov
Copy link

codecov bot commented Sep 13, 2025

Codecov Report

❌ Patch coverage is 93.78238% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.76%. Comparing base (4a19a92) to head (ceee46c).

Files with missing lines Patch % Lines
src/pybamm/solvers/base_solver.py 95.90% 5 Missing ⚠️
src/pybamm/solvers/jax_solver.py 78.57% 3 Missing ⚠️
src/pybamm/models/base_model.py 71.42% 2 Missing ⚠️
src/pybamm/solvers/idaklu_solver.py 94.28% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5191      +/-   ##
===========================================
- Coverage    98.80%   98.76%   -0.05%     
===========================================
  Files          321      321              
  Lines        27395    27410      +15     
===========================================
+ Hits         27068    27071       +3     
- Misses         327      339      +12     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rtimms
Copy link
Contributor

rtimms commented Sep 15, 2025

Does this still allow for the case where there is an InputParameter in the initial conditions but there is only one solver? I.e. there is just a dict of inputs not a list of dicts. That case should still work IMO.

@pipliggins
Copy link
Contributor Author

Does this still allow for the case where there is an InputParameter in the initial conditions but there is only one solver? I.e. there is just a dict of inputs not a list of dicts. That case should still work IMO.

Still works; going to edit this PR actually to make it a new feature that a list of input parameters can be provided and the inputs will be distributed correctly (useful for PyBoP).

@pipliggins pipliggins changed the title Fixes input parameters being used in initial conditions Allow lists of input parameters as initial conditions Sep 17, 2025
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@pipliggins pipliggins marked this pull request as ready for review October 27, 2025 16:20
@pipliggins pipliggins requested a review from a team as a code owner October 27, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: input parameters that affect the initial condition not handled IDAKLU solver JAX: add option for multiple initial conditions

2 participants