What are the ways to reinitialize the model with the previous state?

Hello everyone!

I am trying to find a way to replicate the solution of the 2 cycles of one simulation by solving one cycle at a time and then reinitialize. The experiment consist of [discharge, rest, charge, rest] = Cycle, in total one simulation contains 2 cycles.

There are ways to reinitialize the model in pybamm that I found:

  1. sim.solve(starting_solution=previous_solution)

there is a time correction with t_start_shifted = np.nextafter(t_start, np.inf)

  1. new_model = model.set_initial_conditions_from(solution = previous_solution, inplace=False)

then construct new simulation class with the new model and solve. The solution starts at t=0, there is no time correction through np.nextafter()

However I struggle to “reconstruct” the same 2-cycle solution if I use one of these methods… I thought, solving in a loop one cycle at a time and using the 1. method of re-initialization would deliver the same solution of 2-cycle solution, but it is not.

I think. the problem lies in the calculation of the consistent initial state for the next cycle after the first.

Is there a more simple way to solve one cycle after another and get same results as if solving the cycling sequence at once?

Geri

Hi Geri. I’m not exactly sure what you are trying to do here, but note that resolving an simulation with an experiment will restart the experimental protocol from the beginning, but perhaps you were already expecting this. Perhaps you can post your scripts (2 x 1-cycle versus 2-cycle) and plot the results so we can see the deviation between the two?