Skip to content

Make "Contact resistance [Ohm]" a function of temperature#5604

Merged
rtimms merged 6 commits into
pybamm-team:mainfrom
rtimms:contact-resistance-function-of-temperature
Jun 16, 2026
Merged

Make "Contact resistance [Ohm]" a function of temperature#5604
rtimms merged 6 commits into
pybamm-team:mainfrom
rtimms:contact-resistance-function-of-temperature

Conversation

@rtimms

@rtimms rtimms commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

The "contact resistance" option adds a series resistance to the terminal voltage (and corresponding Ohmic heating). This PR makes the "Contact resistance [Ohm]" parameter a FunctionParameter of the volume-averaged cell temperature (a scalar), instead of a temperature-independent scalar.

It also reframes the documentation: as noted in BPX#130, this is really a lumped series resistance, not a true contact resistance. Renaming the parameter would be a painful breaking change, so the name "Contact resistance [Ohm]" is kept and the docs are updated to clarify what it represents.

Details

  • ElectricalParameters.R_contact is now a method R_contact(self, T) returning pybamm.FunctionParameter("Contact resistance [Ohm]", {"Temperature [K]": T}), matching the idiom used for other temperature-dependent parameters.
  • Callers in base_electrode.py (voltage drop) and thermal/lumped.py (I²R heating) pass the volume-averaged cell temperature.
  • Works for all thermal options"Volume-averaged cell temperature [K]" is a fundamental variable registered by every thermal submodel (isothermal, lumped, x-lumped, x-full).

Backward compatibility

Fully backward compatible. Existing parameter sets that supply a scalar (e.g. "Contact resistance [Ohm]": 0) keep working — PyBaMM auto-wraps a numeric value as a constant FunctionParameter. No parameter-set files were changed.

Testing

  • New parametrized integration test verifying a temperature-dependent R(T) across isothermal/lumped/x-full: matches the constant case at the reference temperature (isothermal) and produces a larger overpotential as the cell heats (lumped/x-full).
  • Existing contact-resistance tests (option validation, EIS, lumped heating) still pass.

🤖 Generated with Claude Code

Convert the scalar "Contact resistance [Ohm]" parameter into a
FunctionParameter of the volume-averaged cell temperature, which is
available for all thermal options. Existing scalar parameter values
keep working unchanged (auto-wrapped as constants).

Also reframe the documentation: despite the legacy name, this is a
lumped series resistance rather than a true contact resistance
(FaradayInstitution/BPX#130). The name is
kept to avoid a breaking change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rtimms rtimms requested a review from a team as a code owner June 15, 2026 10:58
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

rtimms and others added 2 commits June 15, 2026 11:58
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reword the docstrings and notebook to explain that "Contact resistance
[Ohm]" really represents the total series resistance of the cell (contact
resistances between layers, tab/weld/lead resistances), keeping the
parameter name. Drop the BPX link and breaking-change motivation from the
docstrings (kept in the changelog).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.10%. Comparing base (95db690) to head (f67a6d2).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5604      +/-   ##
==========================================
- Coverage   98.10%   98.10%   -0.01%     
==========================================
  Files         339      339              
  Lines       31779    31808      +29     
==========================================
+ Hits        31178    31204      +26     
- Misses        601      604       +3     

☔ View full report in Codecov by Harness.
📢 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

rtimms commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Note on the failing Read the Docs check: this is not caused by this PR.

Locally, all docs build steps pass on this branch:

  • HTML build: succeeds
  • PDF/LaTeX (latexmk): pybamm.pdf is produced
  • sphinx -b linkcheck (the RTD pre_build step): 0 broken links

The RTD failure is the strict pre_build linkcheck intermittently failing on pre-existing publisher citation DOIs (e.g. IOPscience links that redirect to a validate.perfdrive.com bot-detection wall when hit from RTD's datacenter IP). The same check is flaky on other open PRs (#5599, #5592 are red; #5601, #5598, #5584 are green), which confirms it's environmental rather than change-specific. A rebuild should go green.

aabills
aabills previously approved these changes Jun 15, 2026

@aabills aabills left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

overall fine but imo the docs are written a bit incorrectly

"$$\n",
"\n",
"Here $i_k$ is the current, $\\phi_k$ the potential, $a_k$ the surface area to volume ratio, $j_k$ the interfacial current density, $\\eta_k$ the overpotential, $U$ the open-circuit potential, $R_{cr}$ is the contact resistance, and $V_{cell}$ is the total cell volume. The averaged heat source term $\\bar{Q}$ is computed by taking the volume-average of $Q$.\n",
"Here $i_k$ is the current, $\\phi_k$ the potential, $a_k$ the surface area to volume ratio, $j_k$ the interfacial current density, $\\eta_k$ the overpotential, $U$ the open-circuit potential, $R_{cr}$ is the \"Contact resistance [Ohm]\" (which really represents the total series resistance of the cell, e.g. contact resistances between layers, and tab, weld and lead resistances, not only the contact resistance), and $V_{cell}$ is the total cell volume. The averaged heat source term $\\bar{Q}$ is computed by taking the volume-average of $Q$.\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

doesn't the "total series resistance of the cell" if read literally also include electrolyte resistance and butler-volmer?

Reword "total series resistance of the cell" to "additional series
resistance not already captured by the electrochemical model" so the
description does not read as also including electrolyte/Butler-Volmer
contributions. Fix typos in the notebook, trim verbose option docstring,
and remove the misleading "lumped" qualifier on the default option.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rtimms rtimms merged commit c8ff7bf into pybamm-team:main Jun 16, 2026
24 of 27 checks passed
BradyPlanden added a commit that referenced this pull request Jun 16, 2026
…monorepo-merge

Brings in 9 commits from origin/main since the last sync (0b3f7b2..ae2e620):
- #5616 BPX State "Initial state-of-charge" now applied (was ignored)
- #5604 "Contact resistance [Ohm]" can be a function of temperature
- #5610/#5612 fix incomplete BPX import for interpolated-table OCP branches
- #5609 preserve custom-model discretisation recipe across serialise/load
- #5613 linkcheck/lychee ignores for bot-blocked URLs
- #5611 add agent-guidance files (AGENTS.md + symlinks)
- #5614/#5615 security bumps (bleach 6.4.0, starlette 1.3.1, tornado 6.5.7)
- #5618 v26.6.2.0 release (changelog + CITATION.cff)

Resolution notes:
- Merge auto-resolved with zero textual conflicts; rename detection mapped all
  src/* -> packages/pybamm/src/* , tests/* -> packages/pybamm/tests/* and
  CITATION.cff -> packages/pybamm/CITATION.cff. Each relocated file verified
  byte-identical to origin/main.
- CHANGELOG.md: the auto-merge buried the unreleased monorepo #5512 "Features"
  entry inside the shipped [v26.6.2.0] block. Moved it back under [Unreleased];
  the file now equals origin/main plus only that one preserved entry.
- docs/conf.py and uv.lock are true 3-way unions: main's edits (linkcheck
  ignores; bleach/starlette/tornado bumps) combined with the monorepo's
  changes (bibtex path; workspace lock structure intact).
- New agent files (AGENTS.md and the CLAUDE.md/GEMINI.md/QWEN.md/.cursorrules/
  copilot-instructions symlinks) added at the repo root, symlinks preserved.
  NOTE: their content describes the pre-monorepo src/ and tests/ layout and
  will need reconciling to packages/pybamm/* as a follow-up.
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.

3 participants