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

DFN with particle size distributions #1602

Merged
merged 22 commits into from
Aug 24, 2021

Conversation

tobykirk
Copy link
Contributor

@tobykirk tobykirk commented Aug 10, 2021

Description

Added two submodels (FickianManySizeDistributions and FastManySizeDistributions) to enable size distributions to be used in the DFN model, as in this paper. These are analogous to the FickianSingleSizeDistribution and FastSingleSizeDistribution submodels (used for the MPM) but including x-dependence. Features accessed using options = {"particle size": "distribution"}.

Also added an example notebook DFN-with-particle-size-distributions.ipynb and script.

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

@tobykirk tobykirk changed the title Size distribution dfn DFN with particle size distributions Aug 10, 2021
@codecov
Copy link

codecov bot commented Aug 11, 2021

Codecov Report

Merging #1602 (e236e9c) into develop (15a71cc) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1602      +/-   ##
===========================================
+ Coverage    97.97%   97.99%   +0.01%     
===========================================
  Files          324      327       +3     
  Lines        18521    18665     +144     
===========================================
+ Hits         18146    18290     +144     
  Misses         375      375              
Impacted Files Coverage Δ
pybamm/expression_tree/symbol.py 98.25% <ø> (ø)
...bamm/models/full_battery_models/lithium_ion/spm.py 100.00% <ø> (ø)
...amm/models/full_battery_models/lithium_ion/spme.py 100.00% <ø> (ø)
pybamm/models/submodels/particle/base_particle.py 100.00% <ø> (ø)
...bamm/models/full_battery_models/lithium_ion/dfn.py 100.00% <100.00%> (ø)
...bamm/models/full_battery_models/lithium_ion/mpm.py 100.00% <100.00%> (ø)
...s/full_battery_models/lithium_ion/newman_tobias.py 100.00% <100.00%> (ø)
pybamm/models/submodels/particle/__init__.py 100.00% <100.00%> (ø)
...els/submodels/particle/no_distribution/__init__.py 100.00% <100.00%> (ø)
...dels/particle/no_distribution/fickian_diffusion.py 100.00% <100.00%> (ø)
... and 12 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 15a71cc...e236e9c. 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.

Awesome @tobykirk ! S

if particle_side == "Fickian diffusion":
self.submodels[
domain.lower() + " particle"
] = pybamm.particle.FickianManyParticles(self.param, domain)
Copy link
Member

Choose a reason for hiding this comment

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

can we rename these submodels? the "many" here is confusing. maybe XDistribution/XAveraged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the whole naming convention with "many" and "single" is getting more cumbersome/confusing, I agree. Instead of making the class names longer, I've gone with submodules size_distribution and no_distribution (could do size_averaged instead) to differentiate them. Then the class names indicate just the transport model (Fickian, polynomial profile, etc) and whether it is "x-averaged". For example,

particle.FickianManyParticles is now particle.no_distribution.FickianDiffusion
particle.FickianSingleParticles is now particle.no_distribution.XAveragedFickianDiffusion
particle.FickianManySizeDistributions is now particle.size_distribution.FickianDiffusion
particle.FickianSingleSizeDistribution is now particle.size_distribution.XAveragedFickianDiffusion

Could also maybe group them into x_averaged and x_full submodules in a similar way, if that would make it even clearer. (Easily changed)

[self.domain.lower() + " particle"],
{
"secondary": self.domain.lower() + " particle size",
"tertiary": self.domain.lower() + " electrode",
Copy link
Member

Choose a reason for hiding this comment

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

not x-averaged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, thanks, this should be x-averaged.

import unittest


class TestManySizeDistributions(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

getting rid of these submodel tests anyway so no need to add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, removed them (I modified the existing particle submodel tests just so that they pass, didn't bother to fully rename everything there).

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.

Ok perfect, merging

@valentinsulzer valentinsulzer merged commit bf4c1eb into pybamm-team:develop Aug 24, 2021
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.

2 participants