Hello, I am studying the workings of the Battery model so I can develop my own specific PV + BESS (Lithium-Ion) dispatch schemes, for my masters research. My current task is to have a good grasp on the electrochemical model that governs the general operation process of SAM's available battery modes (Shepherd Model). From my current understanding, each cell is modelled as a dependent voltage source in series (with constant parameters A,B,K), with a constant resistance R0, and a terminal voltage. Thing is, I'm having difficulties to comprehend in which order the algorithm calculates each of the electric quantities. If the equation gives terminal voltage as a function of q = integral(idt) at each hourly time step, where would the current value come from? I know that the algorithm sets as inputs global maximum and minimum states of charge and maximum current flow rates by hourly step, but what would be the "initializing steps" for each iteration? For now, I am supposing that for each step, a maximum charge quantity is set to be discharged from or charged into the battery, which relates to the quantities by P = VI. SAM would then solve the system of the equivalent circuit and P = VI? I'm a bit confused by these initial conditions, and I'd very glad if I could obtain some clarifications.