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

#1465 allow evaluate parameter to return arrays #1472

Merged
merged 2 commits into from
Apr 29, 2021

Conversation

rtimms
Copy link
Contributor

@rtimms rtimms commented Apr 29, 2021

Description

ParameterValues.evaluate() can now return arrays so that you can evaluate parameter functions as

import pybamm

params = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Chen2020)
i0 = params["Negative electrode exchange-current density [A.m-2]"]
x = pybamm.linspace(3000,6000,100)
params.evaluate(i0(1000,x,300))

Also, plot and plot2D now take and return the axis ax for easier customization
.
Fixes #1465

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 Apr 29, 2021

Codecov Report

Merging #1472 (cb04f46) into develop (b4735e1) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1472   +/-   ##
========================================
  Coverage    98.37%   98.37%           
========================================
  Files          282      282           
  Lines        16602    16602           
========================================
  Hits         16332    16332           
  Misses         270      270           
Impacted Files Coverage Δ
pybamm/parameters/parameter_values.py 99.43% <100.00%> (ø)
pybamm/plotting/plot.py 100.00% <100.00%> (ø)
pybamm/plotting/plot2D.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 b4735e1...cb04f46. 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.

Looks great, thanks @rtimms ! @Saransh-cpp can you also edit the example in #1458 to use this?

@valentinsulzer
Copy link
Member

just needs a changelog before merging

@Saransh-cpp
Copy link
Member

Looks great, thanks @rtimms ! @Saransh-cpp can you also edit the example in #1458 to use this?

Yes, I will edit the example once this is merged.

@rtimms rtimms merged commit a31e209 into develop Apr 29, 2021
@rtimms rtimms deleted the issue-1465-evaluate-function-parameters branch April 29, 2021 18:02
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.

Plot parameter functions
3 participants