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 1276 add models #1408

Merged
merged 15 commits into from
Mar 2, 2021
Merged

Issue 1276 add models #1408

merged 15 commits into from
Mar 2, 2021

Conversation

valentinsulzer
Copy link
Member

Description

  • Allow creating a Solution that consists of stepping different models
  • Reformat the simulation with experiment using this to be more efficient (at the cost of slightly longer set-up time)

Fixes #1276

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 Mar 1, 2021

Codecov Report

Merging #1408 (56fdcad) into develop (62610a5) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1408      +/-   ##
===========================================
+ Coverage    98.22%   98.27%   +0.04%     
===========================================
  Files          278      278              
  Lines        15804    16111     +307     
===========================================
+ Hits         15524    15833     +309     
+ Misses         280      278       -2     
Impacted Files Coverage Δ
pybamm/models/standard_variables.py 100.00% <ø> (ø)
...dels/submodels/interface/kinetics/base_kinetics.py 100.00% <ø> (ø)
pybamm/parameters/parameter_sets.py 100.00% <ø> (ø)
pybamm/experiments/experiment.py 98.34% <100.00%> (+0.01%) ⬆️
pybamm/models/base_model.py 99.20% <100.00%> (+0.09%) ⬆️
pybamm/plotting/quick_plot.py 100.00% <100.00%> (ø)
pybamm/simulation.py 97.94% <100.00%> (+0.74%) ⬆️
pybamm/solvers/base_solver.py 99.15% <100.00%> (+0.03%) ⬆️
pybamm/solvers/casadi_solver.py 100.00% <100.00%> (+0.47%) ⬆️
pybamm/solvers/processed_variable.py 99.59% <100.00%> (ø)
... and 33 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 62610a5...6de9a13. Read the comment docs.

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 Tino, thanks!

if isinstance(solution, pybamm.Solution):
final_state = final_state.data
if final_state.ndim == 1:
final_state_eval = np.array([final_state[-1]])
final_state_eval = final_state[-1:]
Copy link
Member

Choose a reason for hiding this comment

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

Probably a stupid question, but is this colon necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, just discovered this in python, it returns an array (which is needed) instead of a scalar

np.array([1,2,3])[-1] # --> 3
np.array([1,2,3])[-1:] # --> np.array([3])

@valentinsulzer valentinsulzer merged commit 53ba758 into develop Mar 2, 2021
@valentinsulzer valentinsulzer deleted the issue-1276-add-models branch March 2, 2021 16:46
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.

"Add" solutions from different models
2 participants