-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
cache symbol shapes for testing #749
Comments
after further investigation it turns out the thing that is very slow to discretise is the flux in the particles, so might be worth looking there instead |
discretisation reuses parts of the tree it's already discretised so in theory it shouldn't scale too badly with number of variables, but some specific variables might cause problems. One potential bottleneck is hashing of large arrays in |
yeah it is just those two variables in particular (particle flux in neg and pos electrode). I'll look properly at some point, but it could be the way we handle boundary conditions in gradient. at the moment we loop over secondary points and keep concatenating onto a |
Ah interesting, yeah that could be very inefficient - maybe that part could be defined as another matrix multiplication? |
yeah i think it definitely can be written that way. might take a look and do it as part of #741, will probably be next week though |
Last week i did some profiling and found that line 690 in discretisation is always calling test_shape. This slows things down considerably. Do you want to address that in this issue or should I create a separate one? |
it turns out the thing that was being slow that prompted me to make this issue was the handling of boundary conditions when you have lots of particles. i’m planning to fix that as part of #741. i think this issue can either be closed or you could use this issue to fix the slow test shape. will the solution to that to be to only call test shape in debug mode or something similar? |
It might be easy to speed up
def evaluate_for_shape(self):
"""Evaluate expression tree to find its shape. For symbols that cannot be
evaluated directly (e.g. `Variable` or `Parameter`), a vector of the appropriate
shape is returned instead, using the symbol's domain.
See :meth:`pybamm.Symbol.evaluate()`
"""
try:
return self._saved_evaluate_for_shape
except AttributeError:
self._saved_evaluate_for_shape = self._evaluate_for_shape()
return self._saved_evaluate_for_shape Hopefully this will provide some speed up, as currently |
I've changed the way |
For some bigger problems discretising all of the variables can be slow. It would be good to have the option to only discretise the variables actually used by the model and then be able to discretise a user specified list of variables after solving for post-processing etc.
The text was updated successfully, but these errors were encountered: