fix: rename composite ESOH phase-capacity inputs off the MSMR name pattern - #5738
Open
rtimms wants to merge 5 commits into
Open
fix: rename composite ESOH phase-capacity inputs off the MSMR name pattern#5738rtimms wants to merge 5 commits into
rtimms wants to merge 5 commits into
Conversation
…ttern The composite electrode-SOH model named its phase-capacity input parameters Q_n_1 / Q_p_1 / Q_n_2 / Q_p_2. Those match the deprecated-MSMR name pattern in msmr.py, so check_parameter_values reported every composite solve as using a renamed parameter -- naming an internal input the caller never set and cannot change -- and injected a phantom "... host site occupancy capacity (N) [A.h]" key into the solver inputs alongside it. The names are internal to electrode_soh_composite: built there, consumed there. Renaming them to Q_n_prim / Q_n_sec / Q_p_prim / Q_p_sec matches the prim/sec vocabulary already used for the phases (param.n.prim, param.n.sec) and leaves the MSMR check to fire only on real MSMR names. Fixes #5737 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Asserting that no DeprecationWarning at all escapes a composite solve made the test answerable by any third-party deprecation. Match the rename message instead, which is the warning the collision actually produces. Also drop the changelog's claim that the phantom renamed key reaches the solver: _set_up_model_inputs keeps only the names the model declares, so it is discarded. The warning was the whole user-visible symptom. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Matching any "has been renamed to" warning made the test answerable by an unrelated deprecation in the parameter set -- as "electrode diffusivity" -> "particle diffusivity" would be, from the same call site. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5738 +/- ##
==========================================
+ Coverage 98.12% 98.20% +0.08%
==========================================
Files 340 340
Lines 32743 32743
==========================================
+ Hits 32128 32156 +28
+ Misses 615 587 -28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The keys show up in all_inputs on the ESOH sub-simulation's solution, which a caller can hold via the public esoh_sim kwarg, so anyone introspecting them needs the mapping rather than a description of the fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5737.
Description
electrode_soh_compositenamed its phase-capacityInputParametersQ_n_1/Q_p_1/Q_n_2/Q_p_2. Those match the deprecated-MSMR name pattern inmsmr.py:so when the inputs reach
ParameterValues.check_parameter_valuesviaBaseSolver._set_up_model_inputs, the deprecation branch fires. Two effects, on every composite / multi-phase initial-state solve:DeprecationWarningtelling the user to rename a parameter they never set and cannot change — it names PyBaMM's own internal input.values[new_param] = values.get(param)adds e.g.Negative electrode host site occupancy capacity (1) [A.h]alongsideQ_n_1. On this path it goes no further —_set_up_model_inputskeeps only the names the model declares, so the phantom entry is discarded before the solver sees it. The warning is the whole user-visible symptom; I overstated this in the issue and have corrected it there.The collision is accidental: the composite
Q_n_1is a phase capacity (primary/secondary particle), the MSMRQ_n_1is a host site capacity.Fix
Rename to
Q_n_prim/Q_n_sec/Q_p_prim/Q_p_sec, which matches theprim/secvocabulary already used for the phases (param.n.prim,param.n.sec) and the existing symbol-suffix convention elsewhere (R_n_priminstandard_spatial_vars, thevar_ptskeys).On whether this is breaking. No documented API takes these names:
solve_split,solve_full, andget_initial_stoichiometries_compositeall build them internally fromparameter_values, theirinputskwarg is a different namespace (it is forwarded toparameter_values.evaluate), and the returned dicts hold only stoichiometries. They do not appear insummary_variables(all 102 use display names) or in the user model'ssolution.all_inputs([{}]).They are visible in one place, so I would not call them unreachable: the ESOH sub-simulation's solution, which a caller can hold via the public
esoh_simkwarg onsolve_full—Reading those keys is introspection rather than a documented contract, and code that does it fails with a loud
KeyErrorrather than silently wrong numbers, so I have treated this as non-breaking and spelled the old -> new mapping out in the CHANGELOG instead. Happy to be overruled.I also considered aligning with the
"Primary: Negative electrode capacity [A.h]"convention and did not:PHASE_NAMES = ["Primary: ", "Secondary: "](parameters/bpx.py:95) buildsParameterValueskeys, whereas these areInputParameternames sitting inall_inputsnext toQ_Li,V_init,SOC_init, andz_1. A long display-style string there would be the only one of its kind and would read as a parameter-set key.Note the names are also built dynamically at
_get_electrode_capacity_equation(f"Q_{e}_1"/f"Q_{e}_2"), which a grep for the literal strings misses; both forms are updated.Narrowing
_VALID_NAME_REinstead would be wrong:Q_n_1genuinely is a legacy MSMR name, so the check is correct on the name it is handed. The problem was that the composite path chose that name for something else.Verification
Before, on
main:Added
TestElectrodeSOHComposite::test_phase_capacity_inputs_are_not_deprecated_msmr_names, which fails onmainand passes here.Local runs (
tests/unit/test_models,test_parameters,test_simulation.py,test_base_simulation.py,test_experiments,test_serialisation,test_batch_study.py): 2770 passed, 13 skipped.test_solvers/test_idaklu_jax.pyfails identically on unmodifiedmainin my environment, so it is untouched by this change and left to CI.Type of change
Checklist:
nox -s pre-commitnox -s tests(see note above on the environmentalidaklu_jaxfailures)nox -s doctests— not run; no docs touched