Skip to content

Include contact resistance heating in lumped total heating - #5890

Open
chenyi6758-source wants to merge 5 commits into
pybamm-team:mainfrom
chenyi6758-source:fix/lumped-total-heating-contact-resistance
Open

chenyi6758-source wants to merge 5 commits into
pybamm-team:mainfrom
chenyi6758-source:fix/lumped-total-heating-contact-resistance

Conversation

@chenyi6758-source

Copy link
Copy Markdown

Closes #5879.

The temperature equation in Lumped.set_rhs includes the contact resistance heat, but "Total heating [W]" (and the volume-averaged total) did not, so the reported total was missing the I^2R term.

This folds the contact resistance heat into the two total-heating variables and drops the now-duplicated term from set_rhs. The temperature trajectory is unchanged (verified bit-identical before/after with R_c = 0.05); with "contact resistance" off the added terms are zero.

@chenyi6758-source
chenyi6758-source requested a review from a team as a code owner October 12, 2026 03:07
@rtimms

rtimms commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up. A few things before this can close #5879:

  1. It fixes only part of [Bug]: "contact resistance" lowers the voltage but adds no I²R heat with "x-full" and pouch thermal models #5879. The main bug there is that "x-full" and the pouch-cell thermal models add no contact-resistance heat at all, so the temperature doesn't change with R_c. This PR only changes the lumped model's reported total, so please change "Closes [Bug]: "contact resistance" lowers the voltage but adds no I²R heat with "x-full" and pouch thermal models #5879" to "Part of [Bug]: "contact resistance" lowers the voltage but adds no I²R heat with "x-full" and pouch thermal models #5879", or cover the other thermal models too. Adding the contact heat once in BaseThermal, spread uniformly over the cell volume, would give every thermal option the heat and the reporting in one place.
  2. The lumped totals are inconsistent. Only "Total heating [W]" and "Volume-averaged total heating [W.m-3]" include the contact heat; "Total heating [W.m-3]", "X-averaged total heating [W.m-3]" and "Total heating per unit electrode-pair area [W.m-2]" still leave it out.
  3. There's no test. A check that the extra "Total heating [W]" from switching on contact resistance equals I**2 * R_c would cover it.

This is the same kind of bug as #5820 (an electrical loss that never reaches the heat source), which #5841 and #5875 address for the SEI film and side reactions.

@rtimms

rtimms commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

One more on the implementation: please compute the new totals before the dict and drop the comments, e.g.

Q_W = variables["Total heating [W]"] + Q_cr_W
Q_vol_av = variables["Volume-averaged total heating [W.m-3]"] + Q_cr_vol_av

then put "Total heating [W]": Q_W and "Volume-averaged total heating [W.m-3]": Q_vol_av in the update. Better still, add the contact heat where the totals are built in BaseThermal, so every thermal model and every total-heating variable includes it. That would also cover x-full and the pouch models from #5879.

chenyi6758-source and others added 2 commits October 12, 2026 15:08
Added contact resistance heating calculation to total heating.

@rtimms rtimms 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.

Thanks for the update — moving the heat into BaseThermal is the right direction, and x-full and the pouch models now heat up. A few things are still open from my earlier comments, plus two new issues from the last commit. I checked with an energy balance: temperature held at ambient, R_c 0 → 0.05 Ω, extra "Total heating [W]" over ∫I²R_c dt. The ratio is 1.818 for lumped and 0.818 for x-full and x-lumped 1+1D/2+1D.

  1. Lumped now double counts. The lumped.py additions are still there on top of the BaseThermal term, so both the totals and the temperature equation get the contact heat twice. Please revert lumped.py to main, except remove Q_cr_vol_av from set_rhs, since it's now inside Q_vol_av. Keep the "Lumped contact resistance heating" variables.
  2. Volume normalisation. The heat is spread over the electrode stack but divided by V_cell, so only L_x·L_y·L_z·n / V_cell of I²R ends up in the model. Divide by the stack volume and broadcast over Q.domain, so half-cells work too:
    V_stack = self.param.n_electrodes_parallel * self.param.L_y * self.param.L_z * self.param.L_x
    Q_cr = I**2 * self.param.R_contact(T_vol_av) / V_stack
    Q = Q + pybamm.FullBroadcast(Q_cr, Q.domain, "current collector")
    and move the # Compute the X-average… comment back above the averaging code.
  3. Tests (still needed). test_temperature_dependent_contact_resistance[x-full] now fails: it compares .entries from two solves with different step counts. Use sol["Contact overpotential [V]"](t) instead. Please also add an energy-balance test like test_sei_film_heating in #5841, over lumped, x-full and x-lumped 1+1D/2+1D, asserting that the extra heat equals ∫I²R_c dt. With 1 and 2 applied, I get 1.000 for all of them.
  4. CHANGELOG / description. This now covers every thermal option, so "Closes #5879" is fine. Please update the bullet and drop the "bit-identical" note.

@rtimms

rtimms commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Thanks @chenyi6758, this is what I was after. With the heat added in BaseThermal, x-full and the pouch models now heat up with R_c. On #5879's reproducer, x-full went from exactly 0 K to a visible rise. Your energy-balance test covers all four paths. Two small things, either here or in a follow-up:

  1. "Total heating [W]" now includes the contact heat, but none of the component variables does, so the components no longer add up to the total. Could you add "Contact resistance heating [W]" (and [W.m-3]) in BaseThermal for every thermal model, and have Lumped drop its own calculate_Q_cr_* copy? Then the heat is computed in one place.
  2. Please merge main. The CHANGELOG conflicts, and fix: include side-reaction heat from SEI growth and lithium plating #5875 adds a test next to yours in test_thermal_models.py, so whichever lands second needs a trivial merge.

This branch has not been deployed

No deployments
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.

[Bug]: "contact resistance" lowers the voltage but adds no I²R heat with "x-full" and pouch thermal models

2 participants