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

#3611 use actual cell volume for average total heating #3707

Merged
merged 5 commits into from
Jan 16, 2024

Conversation

rtimms
Copy link
Contributor

@rtimms rtimms commented Jan 10, 2024

Description

Computes the average heat source over the entire cell volume, not just the electrode volume.

Changes:

  • The parameters GeometricParameters.A_cooling and GeometricParameters.V_cell are now computed from the electrode heights, widths and thicknesses if the "cell geometry" option is "pouch" and from the parameters "Cell cooling surface area [m2]" and "Cell volume [m3]", respectively, otherwise.
  • New variables "Ohmic heating per unit electrode-pair area [W.m-2]", "Irreversible electrochemical heating per unit electrode-pair area [W.m-2]", "Reversible heating per unit electrode-pair area [W.m-2]" and "Total heating per unit electrode-pair area [W.m-2]" that correspond to the various heat source terms per unit area of simulated electrode
  • The variables "Volume-averaged ... heating [W.m-3]" are computed by integrating over the simulated electrode volume (of volume L*L_y*L_z) and then dividing by the actual cell volume GeometricParameters.V_cell.

Example:

import pybamm

model = pybamm.lithium_ion.DFN(options={"thermal": "lumped"})

experiment = pybamm.Experiment(["Rest for 1 s", "Discharge at 1C until 3.6 V"])

parameter_values = pybamm.ParameterValues("ORegan2022")
parameter_values["Cell volume [m3]"] = 70e-3 * ((21e-3 / 2) ** 2) * 3.14159

sim = pybamm.Simulation(
    model=model, experiment=experiment, parameter_values=parameter_values
)

sol = sim.solve()

contributing_layers = [
    "Negative current collector",
    "Negative electrode",
    "Separator",
    "Positive electrode",
    "Positive current collector",
]

thickness = sum(
    [parameter_values[layer + " thickness [m]"] for layer in contributing_layers]
)
electrode_volume = (
    thickness
    * parameter_values["Electrode height [m]"]
    * parameter_values["Electrode width [m]"]
)

print(
    "Difference of local and global volumetric heat source:",
    sol["X-averaged total heating [W.m-3]"].entries
    - sol["Volume-averaged total heating [W.m-3]"].entries,
)

print(
    "Difference of volume-corrected local and global volumetric heat source:",
    sol["X-averaged total heating [W.m-3]"].entries * electrode_volume
    - sol["Volume-averaged total heating [W.m-3]"].entries
    * parameter_values["Cell volume [m3]"],
)
print("Global (cell) volume:", parameter_values["Cell volume [m3]"])
print("Local (modelled) volume:", electrode_volume)

Fixes #3611

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: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@rtimms
Copy link
Contributor Author

rtimms commented Jan 10, 2024

ejfdickinson @darryl-ad can you take a look to see if this fixes the issue, please?

@Saransh-cpp this is a bug fix that would be good to get into 24.1 once it is approved

Copy link
Contributor

@darryl-ad darryl-ad left a comment

Choose a reason for hiding this comment

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

@rtimms I'll leave the semantics discussion to Edmund, but I can confirm that this produces results in line with what we expected to see for Volume-averaged cell temperature [K] and Volume-averaged total heating [W.m-3].

However, should you also account for Number of electrode pairs connected in parallel to make a cell (see line comment)?

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3e57733) 99.59% compared to head (5457e74) 99.59%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3707   +/-   ##
========================================
  Coverage    99.59%   99.59%           
========================================
  Files          258      258           
  Lines        20798    20811   +13     
========================================
+ Hits         20713    20726   +13     
  Misses          85       85           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Sponsor 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, thanks!

"Reversible heating [W.m-3]": Q_rev,
"X-averaged reversible heating [W.m-3]": Q_rev_av,
"Volume-averaged reversible heating [W.m-3]": Q_rev_vol_av,
"Integrated reversible heating per unit electrode-pair area "
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Not totally convinced by the name. I find clearer "Total reversible heating per unit electrode-pair area [W.m-2]", but at the same time I can see how a user might find this more confusing, so happy to leave it like that.

In my mind, "total" already means the integrated value and the "per ... area" and units make it clear enough how it has been integrated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I avoided "total" as we already use that to mean "sum of irreversible and reversible", but happy to take suggestions

Choose a reason for hiding this comment

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

I'd suggest that you just delete the word "Integrated"; I agree with @brosaplanella that "per __" intrinsically makes clear how the quantity is scaled. You have long established the approach of using the same name with different units to account for normalisation, and I think that is also fine.

If you are always using "Total" to mean "sum of irreversible and irreversible" then the name "Total reversible heating" is malformed, though.

In the realm of breaking changes, I would call the [W.m-3] quantities a "volumetric heat source" and the [W] quantities a "heat rate".

Also (pedantically), "ohmic" should be lowercase (c.f. voltaic, faradaic). Not worth changing if breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, yes, those “Total…” shouldn’t be there, not sure why I put them there. Probably not worth changing the capitalisation of Ohmic.

To avoid any other breaking changes I’ll keep the same names and infer things from units.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember now, the “Total” came from copy the definition of the existing “Total heating [W]” variable. I’ll make these changes. Otherwise, does this look correct?

@rtimms
Copy link
Contributor Author

rtimms commented Jan 15, 2024

@ejfdickinson I'll wait for your comments before merging, but want to get this merged soon so it is in the next release - thanks!

Copy link

@ejfdickinson ejfdickinson left a comment

Choose a reason for hiding this comment

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

Added one comment under the nomenclature discussion - the implementation seems fine based on @darryl-ad 's review.

"Reversible heating [W.m-3]": Q_rev,
"X-averaged reversible heating [W.m-3]": Q_rev_av,
"Volume-averaged reversible heating [W.m-3]": Q_rev_vol_av,
"Integrated reversible heating per unit electrode-pair area "

Choose a reason for hiding this comment

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

I'd suggest that you just delete the word "Integrated"; I agree with @brosaplanella that "per __" intrinsically makes clear how the quantity is scaled. You have long established the approach of using the same name with different units to account for normalisation, and I think that is also fine.

If you are always using "Total" to mean "sum of irreversible and irreversible" then the name "Total reversible heating" is malformed, though.

In the realm of breaking changes, I would call the [W.m-3] quantities a "volumetric heat source" and the [W] quantities a "heat rate".

Also (pedantically), "ohmic" should be lowercase (c.f. voltaic, faradaic). Not worth changing if breaking.

@rtimms
Copy link
Contributor Author

rtimms commented Jan 16, 2024

@martinjrobins @jsbrittain this JAX test failure seems unrelated to the changes here. any idea what the issue may be?

@kratman kratman merged commit 5900ada into develop Jan 16, 2024
41 checks passed
@kratman kratman deleted the issue-3611-cell-volume branch January 16, 2024 17:00
Saransh-cpp pushed a commit that referenced this pull request Jan 16, 2024
* #3611 use actual cell volume for average total heating

* #3611 changelog

* #3611 account for number of electrode pairs

* #3611 update variable names
rtimms added a commit that referenced this pull request May 16, 2024
* Bump to v23.9rc0

* Merge pull request #3412 from agriyakhetarpal/drop-i686-manylinux2014-support

Drop support for i686 manylinux

* Merge pull request #3413 from Saransh-cpp/improve-release-workflow

Improve release workflow, add a note, bump version manually

* Merge pull request #3436 from Saransh-cpp/fortnightly-wheels

Build wheels on the 1st and 15th of every month

* Merge pull request #3445 from pybamm-team/issue-3428-rename-exchange

#3428 exchange-current density error

* Merge pull request #3449 from pybamm-team/i3431-windows-wheels

Fix failing windows wheel builds

* Merge pull request #3456 from abillscmu/issue-3224-initial_soc

make initial soc work with half cell models

* Merge pull request #3467 from abillscmu/bugfix/initial_soh

* Merge pull request #3423 from jsbrittain/jax_gpu

JaxSolver fails when using GPU support with no input parameters

* Fix changelog

* Merge pull request #3475 from arjxn-py/fix-default-imports

Resolve default imports for optional dependencies

* Bump - `v23.9rc1`

* Fix date in CHANGELOG

* Bump version to v23.9

* Fix docs about Jax solver compatibility with Python versions (#3702)

* Ensure correct Python versions for Jax solver compatibility

* Simplify array of Python versions

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* Use different conjunction

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* Merge pull request #3706 from agriyakhetarpal/fix-pybamm-install-odes

Make `pybamm_install_odes` a bit more robust

* #3690 fix issue with skipped steps (#3708)

* #3690 fix issue with skipped steps

* #3690 changelog

* #3690 add test

* #3611 use actual cell volume for average total heating (#3707)

* #3611 use actual cell volume for average total heating

* #3611 changelog

* #3611 account for number of electrode pairs

* #3611 update variable names

* Improve the release workflow (#3737)

* Try fixing the release workflow

* Turn off safety

* Fix CHANGELOG

* Add OS

* Use regex for better matches

* Update instructions, add safety checks

* checkout to the version branch for the final release

* Bump to v24.1rc1

* #3630 fix interpolant shape error (#3761)

* #3630 fix interpolant shape error

* #3630 changelog

* Bump to v24.1rc2

* Bump to v24.1

* Fix doctests failures in scheduled tests (#3784)

Closes #3781

* Resolve broken `scikits.odes` installation on self-hosted M-series runner (#3785)

* Try fixing M-series runner tests

This is being done by adding SuiteSparse and SUNDIALS installations which might have been missing on the runner, which broke `scikits.odes`.

* Don't use Homebrew SUNDIALS, use LD_LIBRARY_PATH

* Don't use Homebrew to install SUNDIALS

* Force remove pip cache for `scikits.odes`

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* add temperature dependence to MSMR model

* changelog

* fix tests

* fix example

* rob comments

* update notebook

---------

Co-authored-by: Ferran Brosa Planella <Ferran.Brosa-Planella@warwick.ac.uk>
Co-authored-by: Saransh Chopra <saransh0701@gmail.com>
Co-authored-by: Martin Robinson <martinjrobins@gmail.com>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Co-authored-by: Robert Timms <43040151+rtimms@users.noreply.github.com>
Co-authored-by: Saransh-cpp <Saransh-cpp@users.noreply.github.com>
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
…bamm-team#3707)

* pybamm-team#3611 use actual cell volume for average total heating

* pybamm-team#3611 changelog

* pybamm-team#3611 account for number of electrode pairs

* pybamm-team#3611 update variable names
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
* Bump to v23.9rc0

* Merge pull request pybamm-team#3412 from agriyakhetarpal/drop-i686-manylinux2014-support

Drop support for i686 manylinux

* Merge pull request pybamm-team#3413 from Saransh-cpp/improve-release-workflow

Improve release workflow, add a note, bump version manually

* Merge pull request pybamm-team#3436 from Saransh-cpp/fortnightly-wheels

Build wheels on the 1st and 15th of every month

* Merge pull request pybamm-team#3445 from pybamm-team/issue-3428-rename-exchange

pybamm-team#3428 exchange-current density error

* Merge pull request pybamm-team#3449 from pybamm-team/i3431-windows-wheels

Fix failing windows wheel builds

* Merge pull request pybamm-team#3456 from abillscmu/issue-3224-initial_soc

make initial soc work with half cell models

* Merge pull request pybamm-team#3467 from abillscmu/bugfix/initial_soh

* Merge pull request pybamm-team#3423 from jsbrittain/jax_gpu

JaxSolver fails when using GPU support with no input parameters

* Fix changelog

* Merge pull request pybamm-team#3475 from arjxn-py/fix-default-imports

Resolve default imports for optional dependencies

* Bump - `v23.9rc1`

* Fix date in CHANGELOG

* Bump version to v23.9

* Fix docs about Jax solver compatibility with Python versions (pybamm-team#3702)

* Ensure correct Python versions for Jax solver compatibility

* Simplify array of Python versions

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* Use different conjunction

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* Merge pull request pybamm-team#3706 from agriyakhetarpal/fix-pybamm-install-odes

Make `pybamm_install_odes` a bit more robust

* pybamm-team#3690 fix issue with skipped steps (pybamm-team#3708)

* pybamm-team#3690 fix issue with skipped steps

* pybamm-team#3690 changelog

* pybamm-team#3690 add test

* pybamm-team#3611 use actual cell volume for average total heating (pybamm-team#3707)

* pybamm-team#3611 use actual cell volume for average total heating

* pybamm-team#3611 changelog

* pybamm-team#3611 account for number of electrode pairs

* pybamm-team#3611 update variable names

* Improve the release workflow (pybamm-team#3737)

* Try fixing the release workflow

* Turn off safety

* Fix CHANGELOG

* Add OS

* Use regex for better matches

* Update instructions, add safety checks

* checkout to the version branch for the final release

* Bump to v24.1rc1

* pybamm-team#3630 fix interpolant shape error (pybamm-team#3761)

* pybamm-team#3630 fix interpolant shape error

* pybamm-team#3630 changelog

* Bump to v24.1rc2

* Bump to v24.1

* Fix doctests failures in scheduled tests (pybamm-team#3784)

Closes pybamm-team#3781

* Resolve broken `scikits.odes` installation on self-hosted M-series runner (pybamm-team#3785)

* Try fixing M-series runner tests

This is being done by adding SuiteSparse and SUNDIALS installations which might have been missing on the runner, which broke `scikits.odes`.

* Don't use Homebrew SUNDIALS, use LD_LIBRARY_PATH

* Don't use Homebrew to install SUNDIALS

* Force remove pip cache for `scikits.odes`

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* add temperature dependence to MSMR model

* changelog

* fix tests

* fix example

* rob comments

* update notebook

---------

Co-authored-by: Ferran Brosa Planella <Ferran.Brosa-Planella@warwick.ac.uk>
Co-authored-by: Saransh Chopra <saransh0701@gmail.com>
Co-authored-by: Martin Robinson <martinjrobins@gmail.com>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Co-authored-by: Robert Timms <43040151+rtimms@users.noreply.github.com>
Co-authored-by: Saransh-cpp <Saransh-cpp@users.noreply.github.com>
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.

[Bug]: Lumped thermal model conflates cell volume with electrode volume
5 participants