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

[Bug]: Solution last_state can't be used as a starting solution #2788

Closed
brosaplanella opened this issue Mar 20, 2023 · 4 comments · Fixed by #2822
Closed

[Bug]: Solution last_state can't be used as a starting solution #2788

brosaplanella opened this issue Mar 20, 2023 · 4 comments · Fixed by #2822
Assignees
Labels
bug Something isn't working

Comments

@brosaplanella
Copy link
Member

PyBaMM Version

23.2

Python Version

3.9.16

Describe the bug

When trying to use the last_state as a starting solution for a new simulation it breaks because

AttributeError: 'Solution' object has no attribute 'steps'

The issue seems to be here:

starting_solution.steps,

Steps to Reproduce

import pybamm

model = pybamm.lithium_ion.SPM()

experiment = pybamm.Experiment(["Discharge at 1C until 3.5 V"])
sim = pybamm.Simulation(model, experiment=experiment)
solution = sim.solve()

experiment2 = pybamm.Experiment(["Discharge at 1C until 2.5 V"])
sim2 = pybamm.Simulation(model, experiment=experiment2)
solution2 = sim2.solve(starting_solution=solution.last_state)

Relevant log output

Traceback (most recent call last):
  File "/home/brosaplanella/support-pybamm/.github/profile/mwe.py", line 11, in <module>
    solution2 = sim2.solve(starting_solution=solution.last_state)
  File "/home/brosaplanella/support-pybamm/env/lib/python3.9/site-packages/pybamm/simulation.py", line 663, in solve
    starting_solution.steps,
AttributeError: 'Solution' object has no attribute 'steps'
@brosaplanella brosaplanella added the bug Something isn't working label Mar 20, 2023
@valentinsulzer
Copy link
Member

This is a bug, easiest way to fix it is to add some extra logic for that case in simulation.py (i.e. initialize steps to be an empty list)

@manjunathnilugal
Copy link

manjunathnilugal commented Mar 22, 2023

Is there is any method to fix this issue as of now until the issues is resolved.
It is mentioned to to add steps = [ ], in simulation.py file, @tinosulzer could you please tell in brief.

@manjunathnilugal
Copy link

How to implement this in the current version of pybamm, i.e. in my local system

@jsbrittain
Copy link
Contributor

@manjunathnilugal Hi - The change has been merged so should be available immediately in the develop branch. If you want to make this change in your local system, you will need to alter this line in simulation.py to [starting_solution] as here.

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.

4 participants