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

Loading simulations #960

Closed
Scottmar93 opened this issue Apr 15, 2020 · 5 comments · Fixed by #1475
Closed

Loading simulations #960

Scottmar93 opened this issue Apr 15, 2020 · 5 comments · Fixed by #1475
Assignees
Labels
bug Something isn't working

Comments

@Scottmar93
Copy link
Contributor

When loading a simulation using sim.load("something.p") I get the error:

No module named 'graphite_diffusivity_Kim2011'

But if I add the lines:

chemistry = pybamm.parameter_sets.NCA_Kim2011
parameter_values = pybamm.ParameterValues(chemistry=chemistry)

before loading the simulation, it loads and works fine.

Can anyone else can reproduce this? Might just be an issue with my own python setup.

@Scottmar93 Scottmar93 added the bug Something isn't working label Apr 15, 2020
@rtimms
Copy link
Contributor

rtimms commented Apr 15, 2020

yeah I get the same. looks like #792 is related.

also note that if you try to save after plotting you get

File "/home/user/Documents/PyBaMM/pybamm/simulation.py", line 748, in save
    pickle.dump(self, f, pickle.HIGHEST_PROTOCOL)
TypeError: can't pickle _tkinter.tkapp objects

might be worth fixing this too (presumably you can just remove all the plot stuff before saving)

@valentinsulzer
Copy link
Member

Yeah I get this issue too. Also get it if trying to save a simulation where one of the parameter functions has been defined locally.
It's definitely a problem with loading modules but I have no idea how to fix it.

@valentinsulzer valentinsulzer self-assigned this Apr 15, 2020
@valentinsulzer
Copy link
Member

valentinsulzer commented Apr 15, 2020

It looks like the problem is that the path to a particular function (e.g. graphite_diffusivity_Kim2011) is not added to the sys path by default. Some possible workarounds:

  1. (preferred but can't find how to do this) redefine the function locally inside ParameterValues. If not possible with python then maybe we could do it by creating some expression tree.
  2. Automatically import functions defined in inputs/parameters to the pybamm package. This isn't ideal as it doesn't deal with the case where a function has been defined locally
  3. Use something other than pickle that doesn't have this issue

@martinjrobins @tlestang any ideas?

@valentinsulzer valentinsulzer removed their assignment Apr 16, 2020
@tlestang tlestang self-assigned this May 12, 2020
@priyanshuone6
Copy link
Member

@tlestang Are you working on this issue? Can I work on this

@tlestang
Copy link
Contributor

No I'm not, feel free to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants