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

#1511 add function for initial soc #1512

Merged
merged 3 commits into from
Jun 13, 2021
Merged

Conversation

valentinsulzer
Copy link
Member

Description

Add function to set initial soc in a simulation

Fixes #1511

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 Jun 12, 2021

Codecov Report

Merging #1512 (7c6ef23) into develop (f6cb07a) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1512      +/-   ##
===========================================
+ Coverage    98.34%   98.41%   +0.06%     
===========================================
  Files          296      296              
  Lines        17149    17827     +678     
===========================================
+ Hits         16866    17545     +679     
+ Misses         283      282       -1     
Impacted Files Coverage Δ
...models/full_battery_models/lithium_ion/__init__.py 100.00% <100.00%> (ø)
...s/full_battery_models/lithium_ion/electrode_soh.py 100.00% <100.00%> (ø)
pybamm/simulation.py 98.20% <100.00%> (+0.07%) ⬆️
pybamm/expression_tree/array.py 100.00% <0.00%> (ø)
pybamm/expression_tree/scalar.py 100.00% <0.00%> (ø)
pybamm/parameters/base_parameters.py 100.00% <0.00%> (ø)
pybamm/expression_tree/binary_operators.py 99.78% <0.00%> (+0.12%) ⬆️
pybamm/solvers/base_solver.py 99.59% <0.00%> (+0.41%) ⬆️

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 f6cb07a...7c6ef23. Read the comment docs.

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.

handy! thanks @tinosulzer

self._built_model = None
self.op_conds_to_built_models = None

c_n_init = self.parameter_values[
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need to get the initial concentrations here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see

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

The initial stoichiometries that give the desired initial state of charge
"""
if initial_soc < 0 or initial_soc > 1:
raise ValueError("Initial SOC should be between 0 and 1")
Copy link
Member

Choose a reason for hiding this comment

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

This is currently not tested

@valentinsulzer valentinsulzer merged commit c8f2174 into develop Jun 13, 2021
@valentinsulzer valentinsulzer deleted the issue-1511-initial-soc branch June 13, 2021 19:45
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.

Specify initial SOC
3 participants