Skip to content

Commit ce4abea

Browse files
Jhah2025jiaxiu hanvalentinsulzerrtimms
authored
Enable contact overpotential display (#5247)
Co-authored-by: jiaxiu han <[email protected]> Co-authored-by: Valentin Sulzer <[email protected]> Co-authored-by: Robert Timms <[email protected]>
1 parent aa78954 commit ce4abea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/pybamm/plotting/plot_voltage_components.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ def plot_voltage_components(
110110
"Ohmic negative electrode overpotential",
111111
"Ohmic positive electrode overpotential",
112112
]
113+
# Only add the contact overpotential label if its values are not (numerically) all zero
114+
if not np.allclose(
115+
solution["Contact overpotential [V]"].entries, 0, atol=1e-12, equal_nan=True
116+
):
117+
overpotentials.append("Contact overpotential [V]")
118+
labels.append("Contact overpotential")
113119

114120
# Plot
115121
# Initialise
@@ -152,8 +158,9 @@ def plot_voltage_components(
152158
# Plot components
153159
for overpotential, label in zip(overpotentials, labels, strict=False):
154160
# negative overpotentials are positive for a discharge and negative for a charge
161+
# Contact overpotential is positive for a discharge and negative for a charge
155162
# so we have to multiply by -1 to show them correctly
156-
sgn = -1 if "egative" in overpotential else 1
163+
sgn = -1 if ("egative" in overpotential or "Contact" in overpotential) else 1
157164
multiplier = sgn if "attery" in overpotential else sgn * num_cells
158165
bottom = top + multiplier * solution[overpotential].entries
159166
ax.fill_between(time, bottom, top, **kwargs_fill, label=label)

0 commit comments

Comments
 (0)