Skip to content

Added contact resistance - #2598

Merged
valentinsulzer merged 15 commits into
pybamm-team:developfrom
DrSOKane:develop
Jan 25, 2023
Merged

valentinsulzer merged 15 commits into
pybamm-team:developfrom
DrSOKane:develop

Conversation

@DrSOKane

@DrSOKane DrSOKane commented Jan 9, 2023 •

Copy link
Copy Markdown
Contributor

Description

A new parameter "Contact resistance [Ohm]" has been added. This allows for the creation of a new variable "Contact voltage [V]", which is the same as "Terminal voltage [V]" but corrects for said contact resistance.

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@DrSOKane

Copy link
Copy Markdown
Contributor Author

The BPX test is failing because contact resistance is not included in the BPX schema. If everything else about this PR is fine, I can raise an issue on the BPX Github. But I can see why you might be concerned about my having created separate variables for voltage with/without contact resistance.

@valentinsulzer

Copy link
Copy Markdown
Member

IMO the contact resistance parameter should be optional (i.e. add an option where it's not used and hence not needed).
I don't know what the procedure is for adding parameters to BPX

if "Current [A]" in variables:
I = variables["Current [A]"]
V_contact_dim = V_dim - I * param.R_contact
elif self.options["operating mode"] == "explicit power":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, wouldn't P=I*V_contact? And similar for explicit resistance? As in, the measured power would include the contact resistance? Or am I wrong?

It seems to me the cleanest way to do this would be to have a "contact resistance" option (so that the parameter is optional as @tinosulzer suggests) and then not allow "contact resistance" and "explicit power/resistance"?

Comment thread tests/unit/test_parameters/test_bpx.py Outdated
"in parallel to make a cell": 34,
"External surface area [m2]": 3.79e-2,
"Volume [m3]": 1.28e-4,
"Contact resistance [Ohm]": 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this from here and the test will pass. BPX doesn't let you add extra fields that aren't in the schema, so it throws an error. You already hard-code zero contact resistance in bpx.py. If users want to read in BPX and add the contact parameter resistance after, they can do that in the usual way.

@DrSOKane

Copy link
Copy Markdown
Contributor Author

All of the above issues have now been resolved but it's now failing to build scikits-odes...

@valentinsulzer

Copy link
Copy Markdown
Member

Yes, @martinjrobins is working on fixing the scikits issue (not related to your changes)

@valentinsulzer

Copy link
Copy Markdown
Member

If you merge the latest version of develop it should work now

@codecov

codecov Bot commented Jan 18, 2023 •

Copy link
Copy Markdown

Codecov Report

Base: 99.69% // Head: 99.69% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (9f8d315) compared to base (dad2b10).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2598   +/-   ##
========================================
  Coverage    99.69%   99.69%           
========================================
  Files          271      271           
  Lines        19560    19573   +13     
========================================
+ Hits         19500    19513   +13     
  Misses          60       60           
Impacted Files Coverage Δ
pybamm/input/parameters/lead_acid/Sulzer2019.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/Ai2020.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/Chen2020.py 100.00% <ø> (ø)
...input/parameters/lithium_ion/Chen2020_composite.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/Ecker2015.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/Marquis2019.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/Mohtat2020.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/NCA_Kim2011.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/OKane2022.py 100.00% <ø> (ø)
pybamm/input/parameters/lithium_ion/ORegan2022.py 100.00% <ø> (ø)
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

"Local voltage [V]": self.param.ocv_ref + V_cc * pot_scale,
"Terminal voltage": V,
"Terminal voltage [V]": V_dim,
"Terminal voltage": V - delta_phi_contact,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this minus and not plus?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also would be good to add contact resistance as its own variable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Contact resistance [Ohm]" is a parameter. Did you mean make "Contact overpotential [V]" a variable? I can do that if you think it's appropriate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I meant contact overpotential as a variable. Also smart to ignore my dumb minus vs plus comment, brain fart on my part

@valentinsulzer
valentinsulzer merged commit 8543525 into pybamm-team:develop Jan 25, 2023
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 this pull request may close these issues.

3 participants