Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Issue with SEI + Composite Integrations #4123

Closed
mpegis opened this issue May 31, 2024 · 1 comment · Fixed by #4153
Closed

[Bug]: Issue with SEI + Composite Integrations #4123

mpegis opened this issue May 31, 2024 · 1 comment · Fixed by #4153
Assignees
Labels
bug Something isn't working

Comments

@mpegis
Copy link

mpegis commented May 31, 2024

PyBaMM Version

24.1

Python Version

3.10

Describe the bug

I am having an issue running an SEI submodel on both anode phases of the chen2020 composite electrode. It only seems to work when I use SEI: "single option","none" instead of the OCP formatting for model options

Its interesting that the solution output for running chen2020_composite works fine when the model option is "SEI": (("solvent-diffusion limited"),"none"). Despite the lack of domain submodel specification (primary/secondary) at the model init step, it still solves the model, but the output variables do not have negative electrode domain specified for SEI growth.

Please let me know if you see an easy workaround. I am trying to simply play around with SEI growth on a specific domain of a composite electrode (or both)

Steps to Reproduce

This is the problem code. It also fails to execute when SEI is only defined for a single anode phase (none for both others in the stack). It only works when you define a single submodel per electrode, despite the chen2020_composite parameter set having domain-specified phases for degradation

import pybamm
model = pybamm.lithium_ion.DFN(
    {
        "particle phases": ("2", "1"),
        "open-circuit potential": (("single", "current sigmoid"), "single"),
        "SEI": (("solvent-diffusion limited","solvent-diffusion limited"),"none")
    }
)
parameters = pybamm.ParameterValues("Chen2020_composite")
experiment = pybamm.Experiment(["Rest for 10 minutes"])
sim = pybamm.Simulation(model, experiment=experiment, parameter_values=parameters)
sol = sim.solve(calc_esoh=False)

Relevant log output

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[43], line 2
      1 import pybamm
----> 2 model = pybamm.lithium_ion.DFN(
      3     {
      4         "particle phases": ("2", "1"),
      5         "open-circuit potential": (("single", "current sigmoid"), "single"),
      6         "SEI": (("solvent-diffusion limited","solvent-diffusion limited"),"none")
      7     }
      8 )
      9 parameters = pybamm.ParameterValues("Chen2020_composite")
     10 experiment = pybamm.Experiment(["Rest for 10 minutes"])

File ~/micromamba/envs/bpechem4/lib/python3.10/site-packages/pybamm/models/full_battery_models/lithium_ion/dfn.py:27, in DFN.__init__(self, options, name, build)
     24 self.x_average = False
     25 super().__init__(options, name)
---> 27 self.set_submodels(build)
     29 pybamm.citations.register("Doyle1993")

File ~/micromamba/envs/bpechem4/lib/python3.10/site-packages/pybamm/models/full_battery_models/lithium_ion/base_lithium_ion_model.py:59, in BaseModel.set_submodels(self, build)
     56 self.set_total_interface_submodel()
     58 if build:
---> 59     self.build_model()

File ~/micromamba/envs/bpechem4/lib/python3.10/site-packages/pybamm/models/full_battery_models/base_battery_model.py:1054, in BaseBatteryModel.build_model(self)
   1052 def build_model(self):
   1053     # Build model variables and equations
-> 1054     self._build_model()
   1056     # Set battery specific variables
   1057     pybamm.logger.debug(f"Setting voltage variables ({self.name})")

File ~/micromamba/envs/bpechem4/lib/python3.10/site-packages/pybamm/models/base_model.py:828, in BaseModel._build_model(self)
    825 pybamm.logger.info(f"Start building {self.name}")
    827 if self._built_fundamental is False:
--> 828     self.build_fundamental()
    830 self.build_coupled_variables()
    832 self.build_model_equations()

File ~/micromamba/envs/bpechem4/lib/python3.10/site-packages/pybamm/models/base_model.py:730, in BaseModel.build_fundamental(self)
    726 for submodel_name, submodel in self.submodels.items():
    727     pybamm.logger.debug(
    728         f"Getting fundamental variables for {submodel_name} submodel ({self.name})"
    729     )
--> 730     submodel_fundamental_variables = submodel.get_fundamental_variables()
    731     self._variables_by_submodel[submodel_name].update(
    732         submodel_fundamental_variables
    733     )
    734     self.variables.update(submodel_fundamental_variables)

File ~/micromamba/envs/bpechem4/lib/python3.10/site-packages/pybamm/models/submodels/interface/sei/sei_growth.py:75, in SEIGrowth.get_fundamental_variables(self)
     72 L_inner, L_outer = Ls
     74 SEI_option = getattr(self.options, domain)["SEI"]
---> 75 if SEI_option.startswith("ec reaction limited"):
     76     L_inner = 0 * L_inner  # Set L_inner to zero, copying domains
     78 variables = self._get_standard_thickness_variables(L_inner, L_outer)

AttributeError: 'tuple' object has no attribute 'startswith'
@mpegis mpegis added the bug Something isn't working label May 31, 2024
@valentinsulzer valentinsulzer self-assigned this May 31, 2024
parkec3 pushed a commit to parkec3/PyBaMM that referenced this issue Jun 3, 2024
kratman pushed a commit that referenced this issue Jun 7, 2024
…tions updated (#4153)

* #4123 fix

* Updated plating.py with same bug fix from issue 4123

* Bug fix combined to one line

* style: pre-commit fixes

---------

Co-authored-by: Caitlin Parke <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@mpegis
Copy link
Author

mpegis commented Jun 10, 2024

Hey Folks - The PR seemed to fix my issue when I declared SEI on both Si/Gr phases in Chen2020, but now I am seeing a different error when defining a single SEI on one phase with "none" on the other/cathode.

import pybamm 
model = pybamm.lithium_ion.DFN(
    {
        "particle phases": ("2", "1"),
        "open-circuit potential": (("single", "current sigmoid"), "single"),
        "SEI": (("none","solvent-diffusion limited"),"none")
    }
)
parameters = pybamm.ParameterValues("Chen2020_composite")
experiment = pybamm.Experiment(["Rest for 10 minutes"])
sim = pybamm.Simulation(model, experiment=experiment, parameter_values=parameters)
sol = sim.solve(calc_esoh=False)

Is giving me this error


UnboundLocalError Traceback (most recent call last)
))
--> 182 j_inner = inner_sei_proportion * Arrhenius * j_sei
183 j_outer = (1 - inner_sei_proportion) * Arrhenius * j_sei
185 variables.update(self._get_standard_concentration_variables(variables))

UnboundLocalError: cannot access local variable 'j_sei' where it is not associated with a value

Was curious if I missed another model option or if this is expected behavior?

Thanks!

js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this issue Aug 12, 2024
…tions updated (pybamm-team#4153)

* pybamm-team#4123 fix

* Updated plating.py with same bug fix from issue 4123

* Bug fix combined to one line

* style: pre-commit fixes

---------

Co-authored-by: Caitlin Parke <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants