Skip to content

replacing rounded faraday constant with exact value in bpx.py#4290

Merged
kratman merged 10 commits into
pybamm-team:developfrom
dion-w:patch-2
Jul 31, 2024
Merged

replacing rounded faraday constant with exact value in bpx.py#4290
kratman merged 10 commits into
pybamm-team:developfrom
dion-w:patch-2

Conversation

@dion-w
Copy link
Copy Markdown
Contributor

@dion-w dion-w commented Jul 24, 2024

Description

The faraday constant has an exact value, calculated by the exact values of the avogadro constant and the elementray charge [see here]. Using a rounded value may introduce systemic errors further down the line that can be easily avoided with this new value.

Fixes # (issue)

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: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

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

Comment thread CHANGELOG.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.46%. Comparing base (f255c38) to head (ffb465a).
Report is 163 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4290   +/-   ##
========================================
  Coverage    99.45%   99.46%           
========================================
  Files          288      288           
  Lines        22091    22079   -12     
========================================
- Hits         21971    21960   -11     
+ Misses         120      119    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

dion-w and others added 2 commits July 24, 2024 13:37
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Copy link
Copy Markdown
Member

@arjxn-py arjxn-py left a comment

Choose a reason for hiding this comment

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

Thanks @dion-w, looks good

Copy link
Copy Markdown
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @dion-w! Just a small suggestion on the style for the CHANGELOG entry (maybe we should catch things like this with a Markdown linter as well).

Comment thread CHANGELOG.md
@rtimms
Copy link
Copy Markdown
Contributor

rtimms commented Jul 24, 2024

FYI you can do pybamm.constants.F or pybamm.constants.F.value if you need a number instead of a symbol.

@kratman
Copy link
Copy Markdown
Contributor

kratman commented Jul 24, 2024

FYI you can do pybamm.constants.F or pybamm.constants.F.value if you need a number instead of a symbol.

I agree, using a constant from a library is better than updating this file.

One other thing to check would be if the BPX standard specifies a value for Faraday constant. Sometimes standards specify the precision to ensure that things are constant between implementations

Comment thread pybamm/parameters/bpx.py Outdated
dion-w and others added 5 commits July 30, 2024 09:08
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
@agriyakhetarpal agriyakhetarpal requested a review from kratman July 31, 2024 11:09
@agriyakhetarpal
Copy link
Copy Markdown
Member

Re-requested review/approval from @kratman since he previously requested changes

@kratman kratman merged commit 8983f43 into pybamm-team:develop Jul 31, 2024
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
…-team#4290)

* updated faraday constant to exact value in bpx.py

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>

* Update CHANGELOG.md

* Update pybamm/parameters/bpx.py

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>

---------

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Co-authored-by: Arjun Verma <arjunverma.oc@gmail.com>
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.

5 participants