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

R average operator not recognising custom particle domains #4576

Open isaacbasil opened 1 week ago

isaacbasil commented 1 week ago

Hi,

I am keen to start contributing to Pybamm, but I have never contributed to any open-source project before, so I am looking for an easy entry point so that I can understand the process. I came across something in my work which might be a good start:

I am using Pybamm to solve a custom model, which is a DFN variant with several particle domains. Thus, the particle domain name is now something like 'positive particle 1' rather than just 'positive particle'. However, when using the pybamm.r_average() operator, it does not recognise this domain as a particle domain, due to the following line,

has_particle_domain = symbol.domain != [] and symbol.domain[0].endswith("particle")

I know I could just change my domain name to something like 'ID 1 positive particle' and it would bypass this problem. But to me it makes more sense to fix the problem as follows:

has_particle_domain = symbol.domain != [] and "particle" in symbol.domain[0]

Can anyone think of any problems with this? If not I will go ahead and try make a pull request.