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

Issue 580 processed variable #581

Merged
merged 12 commits into from
Oct 24, 2019
Merged

Conversation

valentinsulzer
Copy link
Member

@valentinsulzer valentinsulzer commented Aug 4, 2019

Description

Change ProcessedVariable to be able to plot variables as functions of t, x and z
This is still pretty hacky but seems to work ok for now.
We will need to think of a better way to do this at some point, perhaps by assigning some more attributes to the variables during discretisation (e.g. whether they depend on x, r or z)

Getting a codacy error with eval(...) but can't get ast.literal_eval(...) to work. How bad is it to use eval?

Fixes #580

Type of change

  • New feature (non-breaking change which adds functionality)

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
  • Any dependent changes have been merged and published in downstream modules

@codecov
Copy link

codecov bot commented Aug 4, 2019

Codecov Report

Merging #581 into master will decrease coverage by 0.02%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #581      +/-   ##
==========================================
- Coverage   98.24%   98.22%   -0.03%     
==========================================
  Files         151      151              
  Lines        7393     7418      +25     
==========================================
+ Hits         7263     7286      +23     
- Misses        130      132       +2
Impacted Files Coverage Δ
pybamm/spatial_methods/spatial_method.py 92.06% <100%> (ø) ⬆️
pybamm/expression_tree/binary_operators.py 98.41% <100%> (ø) ⬆️
pybamm/discretisations/discretisation.py 97.64% <100%> (ø) ⬆️
pybamm/expression_tree/unary_operators.py 96.6% <100%> (+0.01%) ⬆️
pybamm/expression_tree/functions.py 99.31% <90%> (-0.69%) ⬇️
pybamm/expression_tree/parameter.py 95.34% <90%> (-1.71%) ⬇️
pybamm/processed_variable.py 94.65% <93.47%> (+0.14%) ⬆️

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 4202941...19e86a2. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 4, 2019

Codecov Report

Merging #581 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #581      +/-   ##
==========================================
+ Coverage   98.54%   98.59%   +0.04%     
==========================================
  Files         169      169              
  Lines        8441     8450       +9     
==========================================
+ Hits         8318     8331      +13     
+ Misses        123      119       -4
Impacted Files Coverage Δ
pybamm/expression_tree/concatenations.py 98.63% <ø> (+0.57%) ⬆️
pybamm/spatial_methods/spatial_method.py 95.65% <100%> (ø) ⬆️
pybamm/expression_tree/vector.py 100% <100%> (ø) ⬆️
pybamm/expression_tree/functions.py 100% <100%> (ø) ⬆️
pybamm/expression_tree/binary_operators.py 98.41% <100%> (-0.03%) ⬇️
pybamm/processed_variable.py 97.19% <100%> (+1.67%) ⬆️
pybamm/discretisations/discretisation.py 100% <100%> (ø) ⬆️
pybamm/expression_tree/symbol.py 97.65% <100%> (+0.07%) ⬆️
pybamm/expression_tree/parameter.py 97.14% <100%> (+0.08%) ⬆️
pybamm/expression_tree/matrix.py 100% <100%> (ø) ⬆️
... and 1 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 79c9d34...ba6cb49. Read the comment docs.

Copy link
Contributor

@martinjrobins martinjrobins left a comment

Choose a reason for hiding this comment

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

Thanks @tinosulzer, some queries below which should be dealt with first. I also don't think there is any documentation on what auxiliary_domains are? Is this part of Symbol, if so it should be described here: https://pybamm.readthedocs.io/en/latest/source/expression_tree/symbol.html

Would we need to assign some more attributes to the variables during discretisation? We have the domain/auxiliary_domain, perhaps there should be some logic somewhere that maps between domain/auxiliary_domain and a list of coordinates. Sounds like this should be in the mesh?

Regarding the eval's. They are a bit of a security hole, not that we are terribly concerned with security with modelling packages :) But I think you could get rid of them just using an if statement? So it might be worth doing this to get rid of the error.

pybamm/expression_tree/parameter.py Outdated Show resolved Hide resolved
pybamm/processed_variable.py Outdated Show resolved Hide resolved
pybamm/processed_variable.py Show resolved Hide resolved
Copy link
Contributor

@martinjrobins martinjrobins left a comment

Choose a reason for hiding this comment

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

These changes look great, thanks @tinosulzer

@valentinsulzer valentinsulzer merged commit d4db5b2 into master Oct 24, 2019
@valentinsulzer valentinsulzer deleted the issue-580-processed-variable branch October 24, 2019 12:37
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.

ProcessedVariable for 1+1D models
2 participants