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

#1722 store first states #1759

Merged
merged 2 commits into from
Oct 27, 2021
Merged

Conversation

brosaplanella
Copy link
Sponsor Member

Description

Added a variable to the solution called all_first_states which is a list of the first_state of each cycle.

Fixes #1722

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 Oct 26, 2021

Codecov Report

Merging #1759 (61b858b) into develop (3a120d7) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1759   +/-   ##
========================================
  Coverage    99.28%   99.28%           
========================================
  Files          343      343           
  Lines        18894    18900    +6     
========================================
+ Hits         18759    18765    +6     
  Misses         135      135           
Impacted Files Coverage Δ
pybamm/simulation.py 98.06% <100.00%> (+0.02%) ⬆️
pybamm/solvers/solution.py 100.00% <100.00%> (ø)

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 3a120d7...61b858b. Read the comment docs.

@@ -935,6 +945,7 @@ def solve(
if self.solution is not None and len(all_cycle_solutions) > 0:
self.solution.cycles = all_cycle_solutions
self.solution.set_summary_variables(all_summary_variables)
self.solution.all_first_states = all_first_states
Copy link
Member

Choose a reason for hiding this comment

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

couldn't this whole PR be a one-liner with

self.solution.all_first_states = [cycle.first_state for cycle in self.solution.cycles]

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

I have tried and it doesn't work because if the cycle is not stored cycle is None so you can't pull the first state.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah makes sense

Copy link
Member

Choose a reason for hiding this comment

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

I forgot that's why we were doing this in the first place haha

@brosaplanella brosaplanella merged commit f2c36a1 into develop Oct 27, 2021
@brosaplanella brosaplanella deleted the issue-1722-store-first-states branch October 27, 2021 10:17
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.

Always store first state of each cycle in experiments
2 participants