pybamm-team / liionpack

A battery pack simulation tool that uses the PyBaMM framework
https://liionpack.readthedocs.io/en/latest/
MIT License
83 stars 26 forks source link

Symbolic pre-solve for circuit equations? #137

Open valentinsulzer opened 2 years ago

valentinsulzer commented 2 years ago

Since the structure of the Modified Nodal Analysis equations never changes for a given circuit, we make the circuit set-up and solve time almost negligible by pre-solving the linear system with symbolic values for the resistances and OCVs. I think sympy can do this. Then at each iteration, we just substitute in the resistance and OCV and evaluate the pre-solved equations.

Thinking further along this line of thought, we could (in theory) completely remove the separate pybamm solve <-> model solve by integrating the pre-solved circuit equations into the pybamm model and just solving one big model. However, it's less clear how to parallelize this.

TomTranter commented 2 years ago

Great ideas, I had thought about making one big system but you do need the stepping for the thermal equations if you include external sources and cell to cell connections that don't exist in the electrical network. I'm very open to exploring these ideas though as if you could just a big system at sundials and get parallelisation done for you that might be better. Definitely we should implement a pre-solve

TomTranter commented 2 years ago

@tinosulzer would you have time to work on this?

valentinsulzer commented 2 years ago

Not for a while