pybamm-team / PyBaMM

Fast and flexible physics-based battery models in Python
https://www.pybamm.org/
BSD 3-Clause "New" or "Revised" License
1.12k stars 547 forks source link

Plot Voltage Components for Composite Electrodes #4434

Open mleot opened 2 months ago

mleot commented 2 months ago

Description

I would like to see the functionality for plotting the different over potentials separated by particle phases for a composite electrode, in the plot_voltage_components function.

Motivation

Having visibility into the contributions of each phase toward the net overpotentials would allow for better understanding of the dynamics in composite electrode systems.

Possible Implementation

I suggest that the definitions of overpotentials and labels be done differently when the cell is a half-cell. I also suggest that the new 'battery' overpotential variables be defined when the composite electrode model is being used.

Additional context

I attempted to make the changes locally, when I noticed a few interesting things that may deserve attention. I noticed in the BaseBatteryModel.set_voltage_variables() method, it appeared that there was no case where the secondary phase overpotentials would be extracted from the variables.

def set_voltage_variables(self):
        if self.options.negative["particle phases"] == "1":
            # Only one phase, no need to distinguish between
            # "primary" and "secondary"
            phase_n = ""
        else:
            # add a space so that we can use "" or (e.g.) "primary " interchangeably
            # when naming variables
            phase_n = "primary "
        if self.options.positive["particle phases"] == "1":
            phase_p = ""
        else:
            phase_p = "primary "

I wasn't sure if this behavior was a bug, or if this is the intended behavior. Maybe I am missing it, but I don't see where exactly the secondary phase overpotentials would be stored or accessed.

mleot commented 2 months ago

I opened a pull request (draft) just to demonstrate an example and ask others for their opinion. In this version, I pulled both primary and secondary reaction and particle concentration overpotentials for a half cell, and took the average of the two. I know this isn't the correct way to go about this, but this is the result:

image

The dashed voltage line is not aligned with the sum of the overpotentials. Maybe there is something fundamentally different for half-cell plot voltage_components that I don't understand yet.