Skip to content

Issue 1219 smooth approximations#1223

Merged
brosaplanella merged 16 commits into
developfrom
issue-1219-smooth-approximations
Nov 4, 2020
Merged

Issue 1219 smooth approximations#1223
brosaplanella merged 16 commits into
developfrom
issue-1219-smooth-approximations

Conversation

@valentinsulzer

Copy link
Copy Markdown
Member

Description

Add smooth versions of the heaviside, minimum, and maximum operators, which can all have discontinuous values and/or derivatives. This clearly improves the performance of the solver, when applicable. A new setting min_max_heaviside_smoothing_parameter can be set to choose the degree of smoothing (or "exact" for no smoothing).

Fixes #1219

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

@codecov

codecov Bot commented Nov 3, 2020

Copy link
Copy Markdown

Codecov Report

Merging #1223 into develop will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1223      +/-   ##
===========================================
+ Coverage    97.92%   97.98%   +0.05%     
===========================================
  Files          249      250       +1     
  Lines        14184    14576     +392     
===========================================
+ Hits         13890    14282     +392     
  Misses         294      294              
Impacted Files Coverage Δ
pybamm/models/submodels/particle/base_particle.py 100.00% <ø> (ø)
pybamm/expression_tree/binary_operators.py 95.76% <100.00%> (+0.22%) ⬆️
pybamm/expression_tree/concatenations.py 97.57% <100.00%> (+0.09%) ⬆️
pybamm/expression_tree/functions.py 100.00% <100.00%> (ø)
pybamm/expression_tree/symbol.py 98.03% <100.00%> (+0.15%) ⬆️
pybamm/expression_tree/unary_operators.py 100.00% <100.00%> (ø)
...ernal_circuit/function_control_external_circuit.py 98.07% <100.00%> (ø)
pybamm/parameters/electrical_parameters.py 100.00% <100.00%> (ø)
pybamm/settings.py 100.00% <100.00%> (ø)
pybamm/solvers/algebraic_solver.py 100.00% <100.00%> (ø)
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33e2278...f0c9915. Read the comment docs.

@brosaplanella brosaplanella left a comment

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.

Looks good, only two minor comments (the one on the CHANGELOG might not require any action).

Comment thread CHANGELOG.md Outdated

## Optimizations

- Add (optional) smooth approximations for the `minimum`, `maximum`, `Heaviside`, and `AbsoluteValue` operators ([#1223](https://github.com/pybamm-team/PyBaMM/pull/1223))

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.

Very minor thing: should minimum and maximum be capitalised or is it because the smooth approximation is for the method but not for the class?

Comment thread examples/scripts/DFN.py Outdated

# load model
model = pybamm.lithium_ion.DFN()
model = pybamm.lithium_ion.SPM()

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.

This should be DFN

@brosaplanella brosaplanella left a comment

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.

Looks great, thanks Tino!

@brosaplanella brosaplanella merged commit d3b1cca into develop Nov 4, 2020
@brosaplanella brosaplanella deleted the issue-1219-smooth-approximations branch November 4, 2020 16:28
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.

Look into using smooth approximations for min, max, heaviside

2 participants