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

Error when taking new_copy() of surface area parameters (lead acid) #1540

Closed
tobykirk opened this issue Jul 9, 2021 · 0 comments · Fixed by #1542
Closed

Error when taking new_copy() of surface area parameters (lead acid) #1540

tobykirk opened this issue Jul 9, 2021 · 0 comments · Fixed by #1542
Assignees

Comments

@tobykirk
Copy link
Contributor

tobykirk commented Jul 9, 2021

Making new copies, using new_copy(), of some lead acid parameters (surface area to volume ratios) produces an error with print_name. @priyanshuone6

To Reproduce

import pybamm

param = pybamm.LeadAcidParameters()

x_n = pybamm.standard_spatial_vars.x_n
a_n = param.a_n(x_n)
a_n_new = a_n.new_copy()

Giving error:

Traceback (most recent call last):
  File "/home/user/PyBaMM/scripts-and-notebooks/FOQS_debugging.py", line 13, in <module>
    a_n_new = a_n.new_copy()
  File "/home/user/PyBaMM/pybamm/expression_tree/parameter.py", line 195, in new_copy
    self._input_names, self.orphans, print_name=self.print_name
  File "/home/user/PyBaMM/pybamm/expression_tree/parameter.py", line 224, in _function_parameter_new_copy
    print_name=print_name,
  File "/home/user/PyBaMM/pybamm/expression_tree/parameter.py", line 109, in __init__
    self.print_name = print_name
  File "/home/user/PyBaMM/pybamm/expression_tree/symbol.py", line 972, in print_name
    self._print_name = prettify_print_name(name)
  File "/home/user/PyBaMM/pybamm/expression_tree/printing/print_name.py", line 60, in prettify_print_name
    subscript_re = re.findall(r"^a_+(\w+)", name)[0]
IndexError: list index out of range

The same for the function parameter a_p and their dimensional versions a_n_dimensional, a_p_dimensional. Can make new copies just fine of any other parameter that I've tried though.

Additional context
Necessary for pull request #1529 where a size_average() is applied to interface variables in base_interface.py, which should do nothing for lead acid models, i.e. just make new copies of variables. The above error arises when building the FOQS lead acid model.

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 a pull request may close this issue.

2 participants