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 692 external temperature matrix #728

Merged
merged 36 commits into from
Nov 20, 2019

Conversation

Scottmar93
Copy link
Contributor

Description

Added a more general method for interfacing with external variables. Can choose any submodel to be external and then one needs to just pass the variable that would have been solved for by the submodel if it wasn't made external to the solver at each time step. This only works for stepping.

Works for solvers except Casadi (tino knows how to get this working though).

I have also added a couple of helper methods to Simulation that make it easy to pass and extract arrays corresponding to variables to/from pybamm.

Fixes #692

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.

  • 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 Nov 13, 2019

Codecov Report

Merging #728 into master will increase coverage by 0.07%.
The diff coverage is 99.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #728      +/-   ##
==========================================
+ Coverage   98.27%   98.35%   +0.07%     
==========================================
  Files         175      175              
  Lines        9351     9599     +248     
==========================================
+ Hits         9190     9441     +251     
+ Misses        161      158       -3
Impacted Files Coverage Δ
pybamm/solvers/idaklu_solver.py 87.25% <ø> (ø) ⬆️
...m/models/full_battery_models/base_battery_model.py 99.65% <100%> (+0.02%) ⬆️
pybamm/solvers/dae_solver.py 99.63% <100%> (+0.1%) ⬆️
pybamm/expression_tree/exceptions.py 100% <100%> (ø) ⬆️
pybamm/models/submodels/base_submodel.py 100% <100%> (ø) ⬆️
pybamm/spatial_methods/spatial_method.py 95.06% <100%> (+0.12%) ⬆️
pybamm/spatial_methods/finite_volume.py 97% <100%> (+0.02%) ⬆️
pybamm/models/base_model.py 98.57% <100%> (+0.05%) ⬆️
pybamm/discretisations/discretisation.py 99.73% <100%> (+0.02%) ⬆️
pybamm/solvers/ode_solver.py 97.91% <100%> (+0.64%) ⬆️
... and 4 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 68539d3...dbdd10c. Read the comment docs.

Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

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

Thanks Scott, looks great. I wonder if it might be a bit neater to set external models by doing e.g. options = {"thermal": "external"} instead of the extra list, but not a very strongly held opinion.
Could you also edit the set_temperature_spm_1plus1D results file with this new format, and add a corresponding example for 1D?

pybamm/discretisations/discretisation.py Show resolved Hide resolved
pybamm/discretisations/discretisation.py Outdated Show resolved Hide resolved
Copy link
Contributor

@rtimms rtimms left a comment

Choose a reason for hiding this comment

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

thanks @Scottmar93 looks great! like how you retain all the features/derived variables of the submodel that you set externally. can the script results/2plus1D/set_temperature_spm_1plus1D.py be updated to use this functionality? then i think the submodel x_lumped_1D_set_temperature can be removed. Need to keep the set potential model for now until we have implemented potentiostatic.

pybamm/discretisations/discretisation.py Show resolved Hide resolved
Copy link
Contributor

@rtimms rtimms left a comment

Choose a reason for hiding this comment

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

looks great, thanks @Scottmar93 !

@Scottmar93 Scottmar93 merged commit 20a0c23 into master Nov 20, 2019
@valentinsulzer valentinsulzer deleted the issue-692-external-temperature-matrix branch November 21, 2019 21:38
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.

Input external temperature matrix
3 participants