Hello!
I have another question to the same implementation:
experiment_step = pybamm.Experiment(
[
(
#"Rest for 5 minutes",
"Discharge at 1C until 3. V",
"Charge at 1C until 4.2 V",
)
]
* 1
)
sim_step = pybamm.Simulation(
model,
experiment=experiment_step,
parameter_values=parameter_values,
solver=solver,
var_pts=var_pts,)
# solve stepwise
init_sol = None
solution_step = []
for cycle in range(nCycles):
sol = sim_step.solve(starting_solution=init_sol)
cycle_sol = sol.cycles[-1]
solution_step.append(cycle_sol)
init_sol = cycle_sol.last_state
print("Differences in states between step and sequential solutions for the first 2 cycles\n")
sol_step_0 = solution_step[0]
sol_step_1 = solution_step[1]
sol_seq_0 = sol_seq.cycles[0]
sol_seq_1 = sol_seq.cycles[1]
n_diff = sol_seq_0.all_models[0].concatenated_rhs.size
y_size = sol_seq_0.first_state.y.shape[0]
n_alg = sol_seq_0.all_models[0].concatenated_algebraic.size
print("Delta t_minus:", sol_step_0.last_state.t - sol_seq_0.last_state.t)
print("Delta t_plus:", sol_step_1.first_state.t - sol_seq_1.first_state.t)
print("Delta y_minus:", np.linalg.norm(sol_step_0.last_state.y[:,-1] - sol_seq_0.last_state.y[:,-1], ord = np.inf))
print("Delta y_plus:", np.linalg.norm(sol_step_1.first_state.y[:,-1] - sol_seq_1.first_state.y[:,-1], ord = np.inf))
print("Delta y[DIFFERENTIAL PART]_plus:", np.linalg.norm(sol_step_1.first_state.y[:n_diff,-1] - sol_seq_1.first_state.y[:n_diff,-1], ord = np.inf))
print("Delta y[ALGEBRAIC PART]_plus:", np.linalg.norm(sol_step_1.first_state.y[n_diff:,-1] - sol_seq_1.first_state.y[n_diff:,-1], ord = np.inf))
OUTPUT:
Differences in states between step and sequential solutions for the first 2 cycles
Delta t_minus: [0.]
Delta t_plus: [0.]
Delta y_minus: 0.0
Delta y_plus: 3.193136033363686e-11
Delta y[DIFFERENTIAL PART]_plus: 2.4807933485249123e-13
Delta y[ALGEBRAIC PART]_plus: 3.193136033363686e-11
I don’t see where I might have done some calculations wrong… Under Assumption that it is correct ( haha ) I expected the two computations deliver same results. Could someone please help me ?
In both cycles the time correction is the same, I expect the starting condition for the second cycle to be identical for both, but it is not…
(*)_minus and (*)_plus mean left and right limits of the (*)
Regards,
Geri