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

Issue 784 simplify solver #800

Merged
merged 34 commits into from
Feb 4, 2020
Merged

Issue 784 simplify solver #800

merged 34 commits into from
Feb 4, 2020

Conversation

valentinsulzer
Copy link
Member

Description

Simplify the various solver classes by merging the set_up methods and getting rid of compute_solution. Also combined the implementations for external variables and inputs

Fixes #784
Fixes #789
Fixes #463

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
Copy link

codecov bot commented Jan 28, 2020

Codecov Report

Merging #800 into master will increase coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #800      +/-   ##
==========================================
+ Coverage   98.29%   98.41%   +0.11%     
==========================================
  Files         177      179       +2     
  Lines        9746     9910     +164     
==========================================
+ Hits         9580     9753     +173     
+ Misses        166      157       -9
Impacted Files Coverage Δ
pybamm/models/submodels/particle/base_particle.py 97.29% <ø> (ø) ⬆️
pybamm/parameters/parameter_values.py 100% <100%> (ø) ⬆️
pybamm/solvers/idaklu_solver.py 88.23% <100%> (+3.92%) ⬆️
pybamm/solvers/casadi_solver.py 100% <100%> (+1.17%) ⬆️
pybamm/util.py 100% <100%> (ø) ⬆️
pybamm/parameters/print_parameters.py 96.96% <100%> (ø) ⬆️
...models/full_battery_models/lithium_ion/__init__.py 100% <100%> (ø) ⬆️
...odels/full_battery_models/lithium_ion/basic_dfn.py 100% <100%> (ø)
.../models/submodels/thermal/isothermal/isothermal.py 100% <100%> (ø) ⬆️
pybamm/expression_tree/variable.py 100% <100%> (+7.89%) ⬆️
... and 10 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 5832658...b1e40e5. Read the comment docs.

Copy link
Contributor

@Scottmar93 Scottmar93 left a comment

Choose a reason for hiding this comment

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

Looks really good @tinosulzer. Certainly much simpler to work out what is going on in the solvers now by getting rid of the DAESolver and ODESolver classes and those multiple set_ups!! Also really like that you have tidied up external variables and have them and the input parameters treated in a similar way.

np.max(sol.fun), self.root_tol * len(sol.x)
)
)

def solve(self, model, t_eval, external_variables=None, inputs=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Does external variables actually work when just solving? I thought it was only implemented for "stepping"

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it should work identically with both now - though I guess the main use cases will be for stepping

@valentinsulzer valentinsulzer merged commit 93b3b25 into master Feb 4, 2020
@valentinsulzer valentinsulzer deleted the issue-784-simplify-solver branch February 4, 2020 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants