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

separate boundary grad and value extrapolation, make grad default quadratic #4614

Merged
merged 8 commits into from
Nov 27, 2024

Conversation

aabills
Copy link
Contributor

@aabills aabills commented Nov 25, 2024

Description

Issue #4433 pointed out that the boundary gradient is only first-order accurate. This is by default true, though the option to make it quadratic exists. I ran into this doing something else.

I tried setting it to be default quadratic, but this caused many test failures, often related to the diffusivity becoming negative when extrapolated. I'm guessing users have tuned parameter sets to just barely work with linear extrapolation:
test

In any case, linear extrapolation for boundary values is less of a priority than for boundary gradients.

So, this pull request separates extrapolation methods for boundary gradient and boundary value, and sets the default to be quadratic for the gradient. This solves the issue discussed in #4433 while not breaking other parameter sets.

Here is the modified graph from #4433
test_boundary_grad

Fixes #4433

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
  • Tests added that prove fix is effective or that feature works

@aabills aabills changed the title separate boundary grad and val, make grad default quadratic separate boundary grad and value extrapolation, make grad default quadratic Nov 25, 2024
Copy link
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

This should probably also be listed under breaking changes in the changelog, even though it probably will not impact many users

src/pybamm/spatial_methods/spatial_method.py Show resolved Hide resolved
@aabills
Copy link
Contributor Author

aabills commented Nov 25, 2024

This should probably also be listed under breaking changes in the changelog, even though it probably will not impact many users

agreed, will do

@aabills aabills requested a review from kratman November 26, 2024 17:23
kratman
kratman previously approved these changes Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.21%. Comparing base (991a594) to head (8af9587).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4614   +/-   ##
========================================
  Coverage    99.21%   99.21%           
========================================
  Files          302      302           
  Lines        22857    22858    +1     
========================================
+ Hits         22678    22679    +1     
  Misses         179      179           

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

brosaplanella
brosaplanella previously approved these changes Nov 27, 2024
Copy link
Member

@brosaplanella brosaplanella left a comment

Choose a reason for hiding this comment

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

Looks good, just a cosmetic suggestion in the CHANGELOG.

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Ferran Brosa Planella <[email protected]>
@kratman kratman dismissed stale reviews from brosaplanella and themself via e3031a6 November 27, 2024 16:21
kratman
kratman previously approved these changes Nov 27, 2024
brosaplanella
brosaplanella previously approved these changes Nov 27, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
@kratman kratman dismissed stale reviews from brosaplanella and themself via 8af9587 November 27, 2024 20:13
Copy link
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

Re-approving after merging with the release branch

@kratman kratman merged commit 72c23ea into pybamm-team:develop Nov 27, 2024
23 checks passed
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.

[Bug]: BoundaryGradient is only first-order accurate
3 participants